mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-01-18 16:54:00 +08:00
feat: add events to mentions & add defaultOpen property to modal
This commit is contained in:
parent
b127c703e9
commit
a49e7d0d53
@ -37,7 +37,7 @@ const options = {
|
|||||||
methods: {},
|
methods: {},
|
||||||
slots: [],
|
slots: [],
|
||||||
styleSlots: ['content'],
|
styleSlots: ['content'],
|
||||||
events: ['onChange', 'onClear', 'onPressEnter'],
|
events: ['onChange', 'onClear', 'onPressEnter', 'onFocus', 'onBlur'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,7 +61,6 @@ export const Mentions = implementRuntimeComponent(options)(props => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onPressEnter = () => {
|
const onPressEnter = () => {
|
||||||
// TODO complete onPressEnter methods
|
|
||||||
callbackMap?.onPressEnter?.();
|
callbackMap?.onPressEnter?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,6 +70,8 @@ export const Mentions = implementRuntimeComponent(options)(props => {
|
|||||||
onPressEnter={onPressEnter}
|
onPressEnter={onPressEnter}
|
||||||
onClear={onClear}
|
onClear={onClear}
|
||||||
className={css(customStyle?.content)}
|
className={css(customStyle?.content)}
|
||||||
|
onBlur={() => callbackMap?.onBlur?.()}
|
||||||
|
onFocus={() => callbackMap?.onFocus?.()}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
{...cProps}
|
{...cProps}
|
||||||
value={value}
|
value={value}
|
||||||
|
@ -5,24 +5,9 @@ import { Type, Static } from '@sinclair/typebox';
|
|||||||
import { FALLBACK_METADATA, getComponentProps } from '../sunmao-helper';
|
import { FALLBACK_METADATA, getComponentProps } from '../sunmao-helper';
|
||||||
import { MenuPropsSpec as BaseMenuPropsSpec } from '../generated/types/Menu';
|
import { MenuPropsSpec as BaseMenuPropsSpec } from '../generated/types/Menu';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Category } from '../constants/category';
|
|
||||||
|
|
||||||
const MenuPropsSpec = Type.Object({
|
const MenuPropsSpec = Type.Object({
|
||||||
...BaseMenuPropsSpec,
|
...BaseMenuPropsSpec,
|
||||||
defaultActiveKey: Type.String({
|
|
||||||
title: 'Default Active Key',
|
|
||||||
category: Category.Basic,
|
|
||||||
}),
|
|
||||||
items: Type.Array(
|
|
||||||
Type.Object({
|
|
||||||
key: Type.String(),
|
|
||||||
text: Type.String(),
|
|
||||||
disabled: Type.Optional(Type.Boolean()),
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
category: Category.Basic,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
const MenuStateSpec = Type.Object({
|
const MenuStateSpec = Type.Object({
|
||||||
activeKey: Type.Optional(Type.String()),
|
activeKey: Type.Optional(Type.String()),
|
||||||
@ -38,6 +23,7 @@ const exampleProperties: Static<typeof MenuPropsSpec> = {
|
|||||||
{ key: 'key1', text: 'item1' },
|
{ key: 'key1', text: 'item1' },
|
||||||
{ key: 'key2', text: 'item2' },
|
{ key: 'key2', text: 'item2' },
|
||||||
],
|
],
|
||||||
|
ellipsis:false,
|
||||||
defaultActiveKey: 'key1',
|
defaultActiveKey: 'key1',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ const exampleProperties: Static<typeof ModalPropsSpec> = {
|
|||||||
closable: true,
|
closable: true,
|
||||||
maskClosable: true,
|
maskClosable: true,
|
||||||
confirmLoading: false,
|
confirmLoading: false,
|
||||||
|
defaultOpen:true
|
||||||
};
|
};
|
||||||
export const Modal = implementRuntimeComponent({
|
export const Modal = implementRuntimeComponent({
|
||||||
version: 'arco/v1',
|
version: 'arco/v1',
|
||||||
@ -43,8 +44,8 @@ export const Modal = implementRuntimeComponent({
|
|||||||
},
|
},
|
||||||
})(props => {
|
})(props => {
|
||||||
const { subscribeMethods, slotsElements, customStyle, callbackMap } = props;
|
const { subscribeMethods, slotsElements, customStyle, callbackMap } = props;
|
||||||
const { getElement, title, ...cProps } = getComponentProps(props);
|
const { getElement, title, defaultOpen, ...cProps } = getComponentProps(props);
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(defaultOpen);
|
||||||
const contentRef = useRef<HTMLDivElement | null>(null);
|
const contentRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
const afterOpen = () => {
|
const afterOpen = () => {
|
||||||
|
@ -16,6 +16,7 @@ export const LinkPropsSpec = {
|
|||||||
hoverable: Type.Boolean({
|
hoverable: Type.Boolean({
|
||||||
title: 'Hoverable',
|
title: 'Hoverable',
|
||||||
category: Category.Style,
|
category: Category.Style,
|
||||||
|
description: 'Whether to hide background when hover'
|
||||||
}),
|
}),
|
||||||
status: StringUnion(['success', 'warning', 'error'], {
|
status: StringUnion(['success', 'warning', 'error'], {
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
|
@ -8,19 +8,48 @@ export const MenuPropsSpec = {
|
|||||||
// title: 'theme',
|
// title: 'theme',
|
||||||
// category: Category.Style,
|
// category: Category.Style,
|
||||||
// }),
|
// }),
|
||||||
mode: StringUnion(['vertical', 'horizontal']),
|
mode: StringUnion(['vertical', 'horizontal'], {
|
||||||
|
title: 'Mode',
|
||||||
|
category: Category.Basic
|
||||||
|
}),
|
||||||
|
items: Type.Array(
|
||||||
|
Type.Object({
|
||||||
|
key: Type.String(),
|
||||||
|
text: Type.String(),
|
||||||
|
disabled: Type.Optional(Type.Boolean()),
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
title:'Items',
|
||||||
|
category: Category.Basic,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
defaultActiveKey: Type.String({
|
||||||
|
title: 'Default Active Key',
|
||||||
|
category: Category.Basic,
|
||||||
|
}),
|
||||||
autoOpen: Type.Boolean({
|
autoOpen: Type.Boolean({
|
||||||
|
title: 'Auto Open',
|
||||||
description: 'Whether to expand all multi-level menus by default',
|
description: 'Whether to expand all multi-level menus by default',
|
||||||
|
category: Category.Basic
|
||||||
}),
|
}),
|
||||||
collapse: Type.Boolean({
|
collapse: Type.Boolean({
|
||||||
|
title: 'Collapse',
|
||||||
category: Category.Style,
|
category: Category.Style,
|
||||||
}),
|
}),
|
||||||
// accordion: Type.Boolean({
|
// accordion: Type.Boolean({
|
||||||
// category: Category.Style,
|
// category: Category.Style,
|
||||||
// }),
|
// }),
|
||||||
// ellipsis: Type.Boolean({
|
ellipsis: Type.Boolean({
|
||||||
// description: 'Whether the horizontal menu automatically collapses when it overflows',
|
title: 'Ellipsis',
|
||||||
// }),
|
description: 'Whether the horizontal menu automatically collapses when it overflows',
|
||||||
autoScrollIntoView: Type.Boolean(),
|
category: Category.Basic
|
||||||
hasCollapseButton: Type.Boolean(),
|
}),
|
||||||
|
autoScrollIntoView: Type.Boolean({
|
||||||
|
title: 'Auto Scroll Into View',
|
||||||
|
category: Category.Basic
|
||||||
|
}),
|
||||||
|
hasCollapseButton: Type.Boolean({
|
||||||
|
title: 'Collapse Button',
|
||||||
|
category: Category.Basic
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
@ -7,6 +7,10 @@ export const ModalPropsSpec = {
|
|||||||
category: Category.Basic,
|
category: Category.Basic,
|
||||||
weight: 10,
|
weight: 10,
|
||||||
}),
|
}),
|
||||||
|
defaultOpen:Type.Boolean({
|
||||||
|
title:'Default Open',
|
||||||
|
category: Category.Behavior,
|
||||||
|
}),
|
||||||
mask: Type.Boolean({
|
mask: Type.Boolean({
|
||||||
title: 'Mask',
|
title: 'Mask',
|
||||||
category: Category.Style,
|
category: Category.Style,
|
||||||
|
Loading…
Reference in New Issue
Block a user