x-ui-design 1.0.29 → 1.0.31-gamma.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -22
- package/dist/{esm/types/components → components}/DatePicker/DatePicker.d.ts +1 -2
- package/dist/{esm/types/components → components}/DatePicker/RangePicker/RangePicker.d.ts +1 -2
- package/dist/{esm/types/components → components}/Dropdown/Dropdown.d.ts +1 -2
- package/dist/{esm/types/components → components}/Empty/Empty.d.ts +1 -2
- package/dist/{esm/types/components → components}/Form/Item/Item.d.ts +1 -2
- package/dist/components/Icons/Icons.d.ts +18 -0
- package/dist/{esm/types/components → components}/Input/Input.d.ts +1 -2
- package/dist/{esm/types/components → components}/Input/Textarea/Textarea.d.ts +1 -2
- package/dist/{esm/types/components → components}/Popover/Popover.d.ts +1 -2
- package/dist/{esm/types/components → components}/Radio/Button/Button.d.ts +1 -2
- package/dist/{esm/types/components → components}/Radio/Group/Group.d.ts +1 -2
- package/dist/{esm/types/components → components}/Radio/Radio.d.ts +1 -2
- package/dist/{esm/types/components → components}/Result/Result.d.ts +1 -2
- package/dist/{esm/types/components → components}/Switch/Switch.d.ts +1 -2
- package/dist/{esm/types/components → components}/Upload/Upload.d.ts +1 -2
- package/dist/esm/types/index.d.ts +0 -50
- package/dist/index.d.ts +1 -144
- package/dist/index.esm.js +3436 -3863
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3398 -3825
- package/dist/index.js.map +1 -1
- package/package.json +22 -20
- package/.github/workflows/x-ui-design.yml +0 -14
- package/compile.sh +0 -15
- package/dist/esm/types/components/Icons/Icons.d.ts +0 -19
- package/eslint.config.mjs +0 -16
- package/lib/components/Button/Button.tsx +0 -136
- package/lib/components/Button/index.ts +0 -1
- package/lib/components/Button/style.css +0 -197
- package/lib/components/Checkbox/Checkbox.tsx +0 -131
- package/lib/components/Checkbox/index.ts +0 -1
- package/lib/components/Checkbox/style.css +0 -95
- package/lib/components/ConditionalWrapper/index.tsx +0 -12
- package/lib/components/DatePicker/DatePicker.tsx +0 -526
- package/lib/components/DatePicker/RangePicker/RangePicker.tsx +0 -500
- package/lib/components/DatePicker/RangePicker/index.ts +0 -1
- package/lib/components/DatePicker/RangePicker/style.css +0 -434
- package/lib/components/DatePicker/TimePicker/TimePicker.tsx +0 -497
- package/lib/components/DatePicker/TimePicker/index.ts +0 -1
- package/lib/components/DatePicker/TimePicker/style.css +0 -197
- package/lib/components/DatePicker/index.ts +0 -1
- package/lib/components/DatePicker/style.css +0 -318
- package/lib/components/Dropdown/Dropdown.tsx +0 -234
- package/lib/components/Dropdown/index.ts +0 -1
- package/lib/components/Dropdown/style.css +0 -124
- package/lib/components/Empty/Empty.tsx +0 -45
- package/lib/components/Empty/index.ts +0 -1
- package/lib/components/Empty/style.css +0 -13
- package/lib/components/Form/Form.tsx +0 -130
- package/lib/components/Form/Item/Item.tsx +0 -294
- package/lib/components/Form/Item/index.ts +0 -1
- package/lib/components/Form/Item/style.css +0 -61
- package/lib/components/Form/index.ts +0 -1
- package/lib/components/Icons/Icons.tsx +0 -433
- package/lib/components/Icons/index.ts +0 -15
- package/lib/components/Input/Input.tsx +0 -216
- package/lib/components/Input/Textarea/Textarea.tsx +0 -110
- package/lib/components/Input/Textarea/index.ts +0 -1
- package/lib/components/Input/Textarea/style.css +0 -104
- package/lib/components/Input/index.ts +0 -1
- package/lib/components/Input/style.css +0 -137
- package/lib/components/Menu/Item/Item.tsx +0 -65
- package/lib/components/Menu/Menu.tsx +0 -261
- package/lib/components/Menu/SubMenu/SubMenu.tsx +0 -68
- package/lib/components/Menu/index.css +0 -145
- package/lib/components/Menu/index.ts +0 -1
- package/lib/components/Popover/Popover.tsx +0 -135
- package/lib/components/Popover/index.ts +0 -1
- package/lib/components/Popover/style.css +0 -82
- package/lib/components/Radio/Button/Button.tsx +0 -42
- package/lib/components/Radio/Button/index.ts +0 -1
- package/lib/components/Radio/Button/style.css +0 -43
- package/lib/components/Radio/Group/Group.tsx +0 -105
- package/lib/components/Radio/Group/index.ts +0 -1
- package/lib/components/Radio/Group/style.css +0 -53
- package/lib/components/Radio/Radio.tsx +0 -83
- package/lib/components/Radio/index.ts +0 -1
- package/lib/components/Radio/style.css +0 -73
- package/lib/components/Result/Result.tsx +0 -39
- package/lib/components/Result/index.ts +0 -1
- package/lib/components/Result/style.css +0 -173
- package/lib/components/Select/Option/Option.tsx +0 -49
- package/lib/components/Select/Option/index.ts +0 -1
- package/lib/components/Select/Option/style.css +0 -50
- package/lib/components/Select/Select.tsx +0 -935
- package/lib/components/Select/Tag/Tag.tsx +0 -43
- package/lib/components/Select/Tag/index.ts +0 -1
- package/lib/components/Select/Tag/style.css +0 -87
- package/lib/components/Select/index.ts +0 -1
- package/lib/components/Select/style.css +0 -186
- package/lib/components/Skeleton/Avatar/Avatar.tsx +0 -61
- package/lib/components/Skeleton/Avatar/index.ts +0 -1
- package/lib/components/Skeleton/Avatar/style.css +0 -27
- package/lib/components/Skeleton/Button/Button.tsx +0 -44
- package/lib/components/Skeleton/Button/index.ts +0 -1
- package/lib/components/Skeleton/Button/style.css +0 -50
- package/lib/components/Skeleton/Image/Image.tsx +0 -45
- package/lib/components/Skeleton/Image/index.ts +0 -1
- package/lib/components/Skeleton/Image/style.css +0 -23
- package/lib/components/Skeleton/Input/Input.tsx +0 -42
- package/lib/components/Skeleton/Input/index.ts +0 -1
- package/lib/components/Skeleton/Input/style.css +0 -56
- package/lib/components/Skeleton/Skeleton.tsx +0 -97
- package/lib/components/Skeleton/index.ts +0 -1
- package/lib/components/Skeleton/style.css +0 -84
- package/lib/components/Switch/Switch.tsx +0 -68
- package/lib/components/Switch/index.css +0 -50
- package/lib/components/Switch/index.ts +0 -1
- package/lib/components/Upload/Upload.tsx +0 -291
- package/lib/components/Upload/index.ts +0 -1
- package/lib/components/Upload/style.css +0 -151
- package/lib/global.d.ts +0 -1
- package/lib/helpers/flatten.ts +0 -26
- package/lib/helpers/index.ts +0 -52
- package/lib/helpers/mask.ts +0 -52
- package/lib/hooks/useForm.ts +0 -548
- package/lib/hooks/usePosition.ts +0 -206
- package/lib/hooks/useWatch.ts +0 -41
- package/lib/hooks/useWatchError.ts +0 -20
- package/lib/index.ts +0 -184
- package/lib/styles/global.css +0 -57
- package/lib/types/button.ts +0 -83
- package/lib/types/checkbox.ts +0 -32
- package/lib/types/datepicker.ts +0 -165
- package/lib/types/dropdown.ts +0 -41
- package/lib/types/empty.ts +0 -8
- package/lib/types/form.ts +0 -179
- package/lib/types/index.ts +0 -38
- package/lib/types/input.ts +0 -72
- package/lib/types/menu.ts +0 -55
- package/lib/types/popover.ts +0 -16
- package/lib/types/radio.ts +0 -69
- package/lib/types/result.ts +0 -22
- package/lib/types/select.ts +0 -126
- package/lib/types/skeleton.ts +0 -62
- package/lib/types/switch.ts +0 -22
- package/lib/types/upload.ts +0 -67
- package/lib/utils/index.ts +0 -37
- package/lib/utils/lazy.ts +0 -17
- package/next.config.ts +0 -7
- package/rollup.config.js +0 -71
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +0 -48
- package/src/app/layout.d.ts +0 -5
- package/src/app/layout.tsx +0 -16
- package/src/app/page.d.ts +0 -1
- package/src/app/page.tsx +0 -21
- package/tsconfig.json +0 -46
- /package/dist/{esm/types/components → components}/Button/Button.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Button/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Checkbox/Checkbox.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Checkbox/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/ConditionalWrapper/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/RangePicker/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/TimePicker/TimePicker.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/TimePicker/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/DatePicker/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Dropdown/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Empty/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Form/Form.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Form/Item/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Form/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Icons/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Input/Textarea/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Input/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/Item/Item.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/Menu.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/SubMenu/SubMenu.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Menu/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Popover/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Radio/Button/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Radio/Group/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Radio/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Result/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Option/Option.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Option/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Select.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Tag/Tag.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/Tag/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Select/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Avatar/Avatar.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Avatar/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Button/Button.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Button/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Image/Image.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Image/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Input/Input.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Input/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/Skeleton.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Skeleton/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Switch/index.d.ts +0 -0
- /package/dist/{esm/types/components → components}/Upload/index.d.ts +0 -0
- /package/dist/{esm/types/helpers → helpers}/flatten.d.ts +0 -0
- /package/dist/{esm/types/helpers → helpers}/index.d.ts +0 -0
- /package/dist/{esm/types/helpers → helpers}/mask.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/useForm.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/usePosition.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/useWatch.d.ts +0 -0
- /package/dist/{esm/types/hooks → hooks}/useWatchError.d.ts +0 -0
- /package/dist/{esm/types/types → types}/button.d.ts +0 -0
- /package/dist/{esm/types/types → types}/checkbox.d.ts +0 -0
- /package/dist/{esm/types/types → types}/datepicker.d.ts +0 -0
- /package/dist/{esm/types/types → types}/dropdown.d.ts +0 -0
- /package/dist/{esm/types/types → types}/empty.d.ts +0 -0
- /package/dist/{esm/types/types → types}/form.d.ts +0 -0
- /package/dist/{esm/types/types → types}/index.d.ts +0 -0
- /package/dist/{esm/types/types → types}/input.d.ts +0 -0
- /package/dist/{esm/types/types → types}/menu.d.ts +0 -0
- /package/dist/{esm/types/types → types}/popover.d.ts +0 -0
- /package/dist/{esm/types/types → types}/radio.d.ts +0 -0
- /package/dist/{esm/types/types → types}/result.d.ts +0 -0
- /package/dist/{esm/types/types → types}/select.d.ts +0 -0
- /package/dist/{esm/types/types → types}/skeleton.d.ts +0 -0
- /package/dist/{esm/types/types → types}/switch.d.ts +0 -0
- /package/dist/{esm/types/types → types}/upload.d.ts +0 -0
- /package/dist/{esm/types/utils → utils}/index.d.ts +0 -0
- /package/dist/{esm/types/utils → utils}/lazy.d.ts +0 -0
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, {
|
|
4
|
-
FC,
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
ReactNode,
|
|
8
|
-
useCallback,
|
|
9
|
-
createContext,
|
|
10
|
-
MouseEvent,
|
|
11
|
-
useRef
|
|
12
|
-
} from "react";
|
|
13
|
-
import { MenuMode, MenuProps } from "../../types/menu";
|
|
14
|
-
import MenuItem from "./Item/Item";
|
|
15
|
-
import SubMenu from "./SubMenu/SubMenu";
|
|
16
|
-
import { prefixClsMenu } from "../../utils";
|
|
17
|
-
import "./index.css";
|
|
18
|
-
|
|
19
|
-
export const MenuContext = createContext<{
|
|
20
|
-
mode: MenuMode;
|
|
21
|
-
inlineIndent: number;
|
|
22
|
-
inlineCollapsed: boolean;
|
|
23
|
-
selectedKeys: string[];
|
|
24
|
-
openKeys: string[];
|
|
25
|
-
toggleOpen: (key: string, level?: "1" | "2") => void;
|
|
26
|
-
onItemClick: (key: string, domEvent?: MouseEvent) => void;
|
|
27
|
-
triggerSubMenuAction?: "hover" | "click";
|
|
28
|
-
} | null>(null);
|
|
29
|
-
|
|
30
|
-
const Menu: FC<MenuProps> & {
|
|
31
|
-
Item: typeof MenuItem;
|
|
32
|
-
SubMenu: typeof SubMenu;
|
|
33
|
-
} = ({
|
|
34
|
-
prefixCls = prefixClsMenu,
|
|
35
|
-
className = "",
|
|
36
|
-
style,
|
|
37
|
-
defaultOpenKeys = [],
|
|
38
|
-
defaultSelectedKeys = [],
|
|
39
|
-
openKeys: openKeysProp,
|
|
40
|
-
selectedKeys: selectedKeysProp,
|
|
41
|
-
mode = "vertical",
|
|
42
|
-
multiple = false,
|
|
43
|
-
inlineCollapsed = false,
|
|
44
|
-
inlineIndent = 24,
|
|
45
|
-
triggerSubMenuAction = "hover",
|
|
46
|
-
onClick,
|
|
47
|
-
onSelect,
|
|
48
|
-
onDeselect,
|
|
49
|
-
onOpenChange,
|
|
50
|
-
selectable = true,
|
|
51
|
-
children,
|
|
52
|
-
items
|
|
53
|
-
}) => {
|
|
54
|
-
const hasInteracted = useRef(false);
|
|
55
|
-
|
|
56
|
-
const [openKeys, setOpenKeys] = useState<string[]>(openKeysProp ?? defaultOpenKeys);
|
|
57
|
-
const [selectedKeys, setSelectedKeys] = useState<string[]>(selectedKeysProp ?? defaultSelectedKeys);
|
|
58
|
-
|
|
59
|
-
const _triggerSubMenuActionClick = useMemo(() => {
|
|
60
|
-
if (mode === 'inline') {
|
|
61
|
-
return "click";
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return triggerSubMenuAction
|
|
65
|
-
}, [triggerSubMenuAction, mode]);
|
|
66
|
-
|
|
67
|
-
const toggleOpen = useCallback(
|
|
68
|
-
(key: string, level?: "1" | "2") => {
|
|
69
|
-
setOpenKeys((_openKeys) => {
|
|
70
|
-
const isOpen = _openKeys?.includes(key);
|
|
71
|
-
|
|
72
|
-
const openKeysData = level
|
|
73
|
-
? [...(_triggerSubMenuActionClick === 'click' ? level === "2" ? [..._openKeys] : [] : _openKeys), key]
|
|
74
|
-
: [key];
|
|
75
|
-
|
|
76
|
-
const next = [...new Set(isOpen
|
|
77
|
-
? _openKeys.filter((k) => k !== key)
|
|
78
|
-
: openKeysData)];
|
|
79
|
-
|
|
80
|
-
if (openKeysProp === undefined) {
|
|
81
|
-
_openKeys = next;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
onOpenChange?.(next);
|
|
85
|
-
|
|
86
|
-
return _openKeys
|
|
87
|
-
})
|
|
88
|
-
},
|
|
89
|
-
[openKeysProp, hasInteracted, _triggerSubMenuActionClick]
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const onItemClick = useCallback(
|
|
93
|
-
(key: string, domEvent?: MouseEvent) => {
|
|
94
|
-
if (!selectable) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
let nextSelected = [...(selectedKeys || [])];
|
|
99
|
-
const already = nextSelected.includes(key);
|
|
100
|
-
|
|
101
|
-
if (multiple) {
|
|
102
|
-
nextSelected = already ? nextSelected.filter((k) => k !== key) : [...nextSelected, key];
|
|
103
|
-
} else {
|
|
104
|
-
nextSelected = [key];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (selectedKeysProp === undefined) {
|
|
108
|
-
setSelectedKeys(nextSelected);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
onSelect?.({ key, keyPath: [key], selectedKeys: nextSelected });
|
|
112
|
-
onClick?.({ key, keyPath: [key], domEvent: domEvent as MouseEvent });
|
|
113
|
-
|
|
114
|
-
if (already && multiple) {
|
|
115
|
-
onDeselect?.({ key, keyPath: [key] });
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
[multiple, onClick, onSelect, onDeselect, selectedKeys, selectable, selectedKeysProp]
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const menuContext = useMemo(
|
|
122
|
-
() => ({
|
|
123
|
-
mode,
|
|
124
|
-
inlineIndent,
|
|
125
|
-
inlineCollapsed,
|
|
126
|
-
selectedKeys: selectedKeys || [],
|
|
127
|
-
openKeys: openKeys || [],
|
|
128
|
-
toggleOpen,
|
|
129
|
-
onItemClick,
|
|
130
|
-
triggerSubMenuAction: _triggerSubMenuActionClick,
|
|
131
|
-
}),
|
|
132
|
-
[
|
|
133
|
-
mode,
|
|
134
|
-
inlineIndent,
|
|
135
|
-
inlineCollapsed,
|
|
136
|
-
selectedKeys,
|
|
137
|
-
openKeys,
|
|
138
|
-
toggleOpen,
|
|
139
|
-
onItemClick,
|
|
140
|
-
_triggerSubMenuActionClick
|
|
141
|
-
]
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<MenuContext.Provider value={menuContext}>
|
|
146
|
-
<ul
|
|
147
|
-
role="menu"
|
|
148
|
-
style={style}
|
|
149
|
-
className={`${prefixCls}-${mode} ${prefixCls || ''} ${className || ''}`}
|
|
150
|
-
>
|
|
151
|
-
{items
|
|
152
|
-
? items.map((it, index) => {
|
|
153
|
-
if (it.type === 'divider') {
|
|
154
|
-
return (
|
|
155
|
-
<span
|
|
156
|
-
key={`${it.key}_${index}_divider`}
|
|
157
|
-
className={`${prefixCls}-divider`}
|
|
158
|
-
/>
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (it.type === 'group') {
|
|
163
|
-
return (
|
|
164
|
-
<div key={index + it.key}>
|
|
165
|
-
<MenuItem
|
|
166
|
-
key={`${it.key}_${index}_${it.label}_menu-item`}
|
|
167
|
-
itemKey={it.key}
|
|
168
|
-
label={it.label}
|
|
169
|
-
icon={it.icon}
|
|
170
|
-
className={`${prefixCls}-item-disabled`}
|
|
171
|
-
/>
|
|
172
|
-
|
|
173
|
-
{(it.children || []).map((c, i) => (
|
|
174
|
-
<MenuItem
|
|
175
|
-
key={`${c.key}_${i}_menu-item`}
|
|
176
|
-
itemKey={c.key}
|
|
177
|
-
label={c.label}
|
|
178
|
-
icon={c.icon}
|
|
179
|
-
className={`${prefixCls}-item-group`}
|
|
180
|
-
/>
|
|
181
|
-
))}
|
|
182
|
-
</div>
|
|
183
|
-
)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return it.children ? (
|
|
187
|
-
<SubMenu
|
|
188
|
-
key={`${it.key}_${it.label}_${index}_sub_menu`}
|
|
189
|
-
itemKey={it.key}
|
|
190
|
-
title={it.label}
|
|
191
|
-
icon={it.icon}
|
|
192
|
-
level="1"
|
|
193
|
-
>
|
|
194
|
-
{it.children.map((c, idx) => {
|
|
195
|
-
if (c.type === 'group') {
|
|
196
|
-
return (
|
|
197
|
-
<div key={c.key + idx}>
|
|
198
|
-
<MenuItem
|
|
199
|
-
key={`${c.key}_${idx}_menu-item`}
|
|
200
|
-
itemKey={c.key}
|
|
201
|
-
label={c.label}
|
|
202
|
-
icon={c.icon}
|
|
203
|
-
className={`${prefixCls}-item-disabled`}
|
|
204
|
-
/>
|
|
205
|
-
|
|
206
|
-
{(c.children || []).map((c, _i) => (
|
|
207
|
-
<MenuItem
|
|
208
|
-
key={`${c.key}_${_i}_menu-item`}
|
|
209
|
-
itemKey={c.key}
|
|
210
|
-
label={c.label}
|
|
211
|
-
icon={c.icon}
|
|
212
|
-
className={`${prefixCls}-item-group`}
|
|
213
|
-
/>
|
|
214
|
-
))}
|
|
215
|
-
</div>
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return c.children ? <SubMenu
|
|
220
|
-
key={`${c.key}_${c.label}_${idx}_sub_menu`}
|
|
221
|
-
className={`${prefixCls}-sub-list-sub`}
|
|
222
|
-
itemKey={c.key}
|
|
223
|
-
title={c.label}
|
|
224
|
-
icon={c.icon}
|
|
225
|
-
level="2"
|
|
226
|
-
>
|
|
227
|
-
{c.children.map((c, _idx) => (
|
|
228
|
-
<MenuItem
|
|
229
|
-
key={`${c.key}_${_idx}_${c.label}_menu-item`}
|
|
230
|
-
itemKey={c.key}
|
|
231
|
-
label={c.label}
|
|
232
|
-
icon={c.icon}
|
|
233
|
-
/>
|
|
234
|
-
))}
|
|
235
|
-
</SubMenu> :
|
|
236
|
-
<MenuItem
|
|
237
|
-
key={`${index}_${c.key}_${c.label}_menu-item`}
|
|
238
|
-
itemKey={c.key}
|
|
239
|
-
label={c.label}
|
|
240
|
-
icon={c.icon} />
|
|
241
|
-
})}
|
|
242
|
-
</SubMenu>
|
|
243
|
-
) : (
|
|
244
|
-
<MenuItem
|
|
245
|
-
key={`${index}_${it.key}_menu-item`}
|
|
246
|
-
itemKey={it.key}
|
|
247
|
-
label={it.label}
|
|
248
|
-
icon={it.icon}
|
|
249
|
-
/>
|
|
250
|
-
)
|
|
251
|
-
})
|
|
252
|
-
: children}
|
|
253
|
-
</ul>
|
|
254
|
-
</MenuContext.Provider>
|
|
255
|
-
);
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
Menu.Item = MenuItem;
|
|
259
|
-
Menu.SubMenu = SubMenu;
|
|
260
|
-
|
|
261
|
-
export default Menu;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { FC, useCallback, useContext } from "react";
|
|
4
|
-
import { MenuContext } from "../Menu";
|
|
5
|
-
import { SubMenuItem } from "../../../types/menu";
|
|
6
|
-
import { ArrowIcon } from "../../../components/Icons";
|
|
7
|
-
import { prefixClsMenu } from "../../../utils";
|
|
8
|
-
|
|
9
|
-
const SubMenu: FC<SubMenuItem> = ({
|
|
10
|
-
itemKey,
|
|
11
|
-
title,
|
|
12
|
-
icon,
|
|
13
|
-
children,
|
|
14
|
-
className = '',
|
|
15
|
-
level,
|
|
16
|
-
prefixCls = prefixClsMenu
|
|
17
|
-
}) => {
|
|
18
|
-
const menuContext = useContext(MenuContext);
|
|
19
|
-
|
|
20
|
-
if (!menuContext) {
|
|
21
|
-
throw new Error('MenuItem must be used within a Menu');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const { openKeys, toggleOpen, triggerSubMenuAction } = menuContext;
|
|
25
|
-
|
|
26
|
-
const isOpen = openKeys.includes(itemKey);
|
|
27
|
-
|
|
28
|
-
const handleClick = useCallback(() => {
|
|
29
|
-
if (triggerSubMenuAction === "click") {
|
|
30
|
-
toggleOpen(itemKey, level);
|
|
31
|
-
}
|
|
32
|
-
}, [itemKey, level]);
|
|
33
|
-
|
|
34
|
-
const handleHover = useCallback((_: boolean) => {
|
|
35
|
-
if (triggerSubMenuAction === "hover") {
|
|
36
|
-
toggleOpen(itemKey, level);
|
|
37
|
-
}
|
|
38
|
-
}, [itemKey, level]);
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<li
|
|
42
|
-
className={`${prefixCls}-sub ${className}`}
|
|
43
|
-
{
|
|
44
|
-
...(triggerSubMenuAction === "hover" ? {
|
|
45
|
-
onMouseEnter: () => handleHover(true),
|
|
46
|
-
onMouseLeave: () => handleHover(false)
|
|
47
|
-
} : {})
|
|
48
|
-
}
|
|
49
|
-
>
|
|
50
|
-
<div className={`${prefixCls}-sub-title`} onClick={handleClick}>
|
|
51
|
-
{icon && <span className={`${prefixCls}-sub-icon`}>
|
|
52
|
-
{icon}
|
|
53
|
-
</span>}
|
|
54
|
-
<span className={`${prefixCls}-sub-label`}>{title}</span>
|
|
55
|
-
<span className={`${prefixCls}-sub-arrow`}>
|
|
56
|
-
{<ArrowIcon isOpen={isOpen} />}
|
|
57
|
-
</span>
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
{!isOpen ? null :
|
|
61
|
-
<ul className={`${prefixCls}-sub-list`}>
|
|
62
|
-
{children}
|
|
63
|
-
</ul>}
|
|
64
|
-
</li>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default SubMenu;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
.xUi-menu {
|
|
2
|
-
gap: 4px;
|
|
3
|
-
margin: 0;
|
|
4
|
-
padding: 4px;
|
|
5
|
-
display: flex;
|
|
6
|
-
font-size: 14px;
|
|
7
|
-
list-style: none;
|
|
8
|
-
border-radius: 4px;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
user-select: none;
|
|
11
|
-
box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.xUi-menu-sub-list {
|
|
15
|
-
gap: 4px;
|
|
16
|
-
margin: 0;
|
|
17
|
-
padding: 4px;
|
|
18
|
-
display: flex;
|
|
19
|
-
list-style: none;
|
|
20
|
-
border-radius: 4px;
|
|
21
|
-
height: max-content;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
background: var(--xui-background-color);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.xUi-menu-item-group {
|
|
27
|
-
padding: 0 24px !important;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.xUi-menu-vertical .xUi-menu-sub-list {
|
|
31
|
-
top: 0;
|
|
32
|
-
z-index: 1;
|
|
33
|
-
left: 100%;
|
|
34
|
-
right: -100%;
|
|
35
|
-
width: min-content;
|
|
36
|
-
min-width: 160px;
|
|
37
|
-
position: absolute;
|
|
38
|
-
background-color: #fff;
|
|
39
|
-
box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.xUi-menu-horizontal {
|
|
43
|
-
display: flex;
|
|
44
|
-
flex-direction: row;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.xUi-menu-item {
|
|
48
|
-
display: flex;
|
|
49
|
-
height: 40px;
|
|
50
|
-
padding: 0 12px;
|
|
51
|
-
cursor: pointer;
|
|
52
|
-
border-radius: 4px;
|
|
53
|
-
align-items: center;
|
|
54
|
-
transition: background 0.3s;
|
|
55
|
-
color: var(--xui-text-color);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.xUi-menu-item:hover {
|
|
59
|
-
background: rgba(0, 0, 0, 0.04);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.xUi-menu-item-icon {
|
|
63
|
-
margin-right: 8px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.xUi-menu-sub {
|
|
67
|
-
position: relative;
|
|
68
|
-
border-radius: 6px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.xUi-menu-sub-title {
|
|
72
|
-
height: 40px;
|
|
73
|
-
display: flex;
|
|
74
|
-
padding: 0 12px;
|
|
75
|
-
cursor: pointer;
|
|
76
|
-
align-items: center;
|
|
77
|
-
|
|
78
|
-
&:hover {
|
|
79
|
-
border-radius: 6px;
|
|
80
|
-
background-color: var(--xui-color-hover);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.xUi-menu-sub-label {
|
|
85
|
-
flex: 1;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.xUi-menu-sub-arrow {
|
|
89
|
-
margin-left: 8px;
|
|
90
|
-
transition: transform 0.2s;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.xUi-menu-vertical .xUi-menu-sub-arrow {
|
|
94
|
-
transform: rotate(-90deg);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.xUi-menu-group {
|
|
98
|
-
margin: 0;
|
|
99
|
-
padding: 0;
|
|
100
|
-
list-style: none;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.xUi-menu-group-title {
|
|
104
|
-
font-size: 12px;
|
|
105
|
-
padding: 8px 12px;
|
|
106
|
-
color: rgba(0, 0, 0, 0.45);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.xUi-menu-group-list {
|
|
110
|
-
margin: 0;
|
|
111
|
-
padding: 0;
|
|
112
|
-
list-style: none;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.xUi-menu-divider {
|
|
116
|
-
display: block;
|
|
117
|
-
margin: 0 auto;
|
|
118
|
-
width: calc(100% - 16px);
|
|
119
|
-
border-bottom: 1px solid var(--xui-color-disabled);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.xUi-menu-item.xUi-menu-item-disabled {
|
|
123
|
-
cursor: auto;
|
|
124
|
-
opacity: 0.6;
|
|
125
|
-
|
|
126
|
-
&:hover {
|
|
127
|
-
background-color: unset;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.xUi-menu-inline .xUi-menu-sub-list {
|
|
132
|
-
background-color: var(--xui-menu-inline-bg);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.xUi-menu-inline .xUi-menu-item {
|
|
136
|
-
padding: 0 24px;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.xUi-menu-inline .xUi-menu-sub-title {
|
|
140
|
-
padding: 0 20px;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.xUi-menu-inline .xUi-menu-sub-list-sub .xUi-menu-item {
|
|
144
|
-
padding: 0 30px;
|
|
145
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Menu } from './Menu';
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState, cloneElement, isValidElement, Children, useEffect, useMemo, useCallback } from "react";
|
|
2
|
-
import { usePosition } from "../../hooks/usePosition";
|
|
3
|
-
import { clsx } from '../../helpers';
|
|
4
|
-
import { PopoverProps } from "../../types/popover";
|
|
5
|
-
import { ConditionalWrapper } from '../ConditionalWrapper';
|
|
6
|
-
import { createPortal } from 'react-dom';
|
|
7
|
-
import { prefixClsPopover } from "../../utils";
|
|
8
|
-
import './style.css';
|
|
9
|
-
|
|
10
|
-
const Popover = ({
|
|
11
|
-
prefixCls = prefixClsPopover,
|
|
12
|
-
content,
|
|
13
|
-
children,
|
|
14
|
-
trigger = "click",
|
|
15
|
-
placement = "bottom",
|
|
16
|
-
open,
|
|
17
|
-
visible,
|
|
18
|
-
title,
|
|
19
|
-
style = {},
|
|
20
|
-
overlayClassName = '',
|
|
21
|
-
overlayStyle = {},
|
|
22
|
-
onVisibleChange,
|
|
23
|
-
getPopupContainer
|
|
24
|
-
}: PopoverProps) => {
|
|
25
|
-
const triggerRef = useRef<HTMLDivElement>(null);
|
|
26
|
-
const popupRef = useRef<HTMLDivElement>(null);
|
|
27
|
-
|
|
28
|
-
const [innerOpen, setInnerOpen] = useState(false);
|
|
29
|
-
|
|
30
|
-
const isOpen = visible !== undefined ? visible : open !== undefined ? open : innerOpen;
|
|
31
|
-
|
|
32
|
-
const { dropdownPosition, showPlacement } = usePosition({
|
|
33
|
-
isOpen,
|
|
34
|
-
offset: 10,
|
|
35
|
-
popupRef,
|
|
36
|
-
placement,
|
|
37
|
-
triggerRef,
|
|
38
|
-
getPopupContainer: getPopupContainer?.(triggerRef.current as HTMLElement)
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
const handleClickOutside = (e: MouseEvent) => {
|
|
43
|
-
if (
|
|
44
|
-
popupRef.current &&
|
|
45
|
-
!popupRef.current.contains(e.target as Node) &&
|
|
46
|
-
triggerRef.current &&
|
|
47
|
-
!triggerRef.current.contains(e.target as Node)
|
|
48
|
-
) {
|
|
49
|
-
setInnerOpen(false);
|
|
50
|
-
onVisibleChange?.(false);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
55
|
-
|
|
56
|
-
return () => {
|
|
57
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
58
|
-
};
|
|
59
|
-
}, []);
|
|
60
|
-
|
|
61
|
-
const handleOnClick = useCallback(() => {
|
|
62
|
-
const newState = !isOpen;
|
|
63
|
-
|
|
64
|
-
onVisibleChange?.(newState);
|
|
65
|
-
setInnerOpen(newState);
|
|
66
|
-
}, [isOpen, trigger]);
|
|
67
|
-
|
|
68
|
-
const handleOnMouseEnter = useCallback(() => {
|
|
69
|
-
if (trigger === "hover") {
|
|
70
|
-
onVisibleChange?.(true);
|
|
71
|
-
setInnerOpen(true);
|
|
72
|
-
}
|
|
73
|
-
}, [trigger]);
|
|
74
|
-
|
|
75
|
-
const handleOnMouseLeave = useCallback(() => {
|
|
76
|
-
if (trigger === "hover") {
|
|
77
|
-
onVisibleChange?.(false);
|
|
78
|
-
setInnerOpen(false);
|
|
79
|
-
}
|
|
80
|
-
}, [trigger]);
|
|
81
|
-
|
|
82
|
-
const childProps = useMemo(() => trigger === "click"
|
|
83
|
-
? { onClick: handleOnClick }
|
|
84
|
-
: { onMouseEnter: handleOnMouseEnter, onMouseLeave: handleOnMouseLeave },
|
|
85
|
-
[trigger]);
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<>
|
|
89
|
-
{Children.map(children, (child, index) => {
|
|
90
|
-
if (!isValidElement(child)) {
|
|
91
|
-
child = <div>{child}</div>
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return cloneElement(child, {
|
|
95
|
-
key: index,
|
|
96
|
-
...(index === 0 ? {
|
|
97
|
-
style,
|
|
98
|
-
...childProps,
|
|
99
|
-
ref: triggerRef,
|
|
100
|
-
className: `${prefixCls}-wrapper-content`,
|
|
101
|
-
} : {}),
|
|
102
|
-
})
|
|
103
|
-
})}
|
|
104
|
-
|
|
105
|
-
{isOpen && (
|
|
106
|
-
<ConditionalWrapper
|
|
107
|
-
condition={!!getPopupContainer}
|
|
108
|
-
wrapper={(element) =>
|
|
109
|
-
getPopupContainer
|
|
110
|
-
? createPortal(element, getPopupContainer(popupRef.current as HTMLElement))
|
|
111
|
-
: <>{element}</>
|
|
112
|
-
}
|
|
113
|
-
>
|
|
114
|
-
<div
|
|
115
|
-
ref={popupRef}
|
|
116
|
-
{...childProps}
|
|
117
|
-
className={clsx(prefixCls, `${prefixCls}-${placement}`, overlayClassName)}
|
|
118
|
-
style={{
|
|
119
|
-
zIndex: 1000,
|
|
120
|
-
position: "absolute",
|
|
121
|
-
...overlayStyle,
|
|
122
|
-
...dropdownPosition
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
{title && <div className={`${prefixCls}-title`}>{title}</div>}
|
|
126
|
-
<div className={`${prefixCls}-inner`}>{content}</div>
|
|
127
|
-
<div className={`${prefixCls}-arrow ${showPlacement}`} />
|
|
128
|
-
</div>
|
|
129
|
-
</ConditionalWrapper>
|
|
130
|
-
)}
|
|
131
|
-
</>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export default Popover;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Popover } from '../Popover/Popover'
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
.xUi-popover {
|
|
2
|
-
&::before {
|
|
3
|
-
left: 0;
|
|
4
|
-
top: -10px;
|
|
5
|
-
content: "";
|
|
6
|
-
width: 100%;
|
|
7
|
-
height: 10px;
|
|
8
|
-
z-index: 10000;
|
|
9
|
-
position: absolute;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.xUi-popover-wrapper-content {
|
|
14
|
-
cursor: pointer;
|
|
15
|
-
max-width: fit-content;
|
|
16
|
-
width: -webkit-fill-available;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.xUi-popover {
|
|
20
|
-
width: max-content;
|
|
21
|
-
background: var(--xui-background-color);
|
|
22
|
-
border-radius: 6px;
|
|
23
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
24
|
-
padding: 8px 12px;
|
|
25
|
-
z-index: 1000;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.xUi-popover-title {
|
|
29
|
-
padding: 4px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.xUi-popover-inner {
|
|
33
|
-
font-size: 14px;
|
|
34
|
-
color: var(--xui-text-color);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.xUi-popover-arrow {
|
|
38
|
-
width: 10px;
|
|
39
|
-
height: 10px;
|
|
40
|
-
position: absolute;
|
|
41
|
-
top: -6px;
|
|
42
|
-
left: 12px;
|
|
43
|
-
background: var(--xui-background-color);
|
|
44
|
-
border-left: 0.5px solid var(--xui-border-color);
|
|
45
|
-
border-top: 0.5px solid var(--xui-border-color);
|
|
46
|
-
transform: rotate(45deg);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.xUi-popover-arrow {
|
|
50
|
-
width: 10px;
|
|
51
|
-
height: 10px;
|
|
52
|
-
position: absolute;
|
|
53
|
-
top: -6px;
|
|
54
|
-
left: 12px;
|
|
55
|
-
background: var(--xui-background-color);
|
|
56
|
-
border-left: 0.5px solid var(--xui-border-color);
|
|
57
|
-
border-top: 0.5px solid var(--xui-border-color);
|
|
58
|
-
transform: rotate(45deg);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.xUi-popover-right .xUi-popover-arrow,
|
|
62
|
-
.xUi-popover-topRight .xUi-popover-arrow,
|
|
63
|
-
.xUi-popover-bottomRight .xUi-popover-arrow {
|
|
64
|
-
left: unset;
|
|
65
|
-
right: 12px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.xUi-popover-arrow.bottom {
|
|
69
|
-
top: unset;
|
|
70
|
-
bottom: -6px;
|
|
71
|
-
border-left: unset;
|
|
72
|
-
border-top: unset;
|
|
73
|
-
border-right: 0.5px solid var(--xui-border-color);
|
|
74
|
-
border-bottom: 0.5px solid var(--xui-border-color);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.xUi-popover-arrow.center {
|
|
78
|
-
left: 0;
|
|
79
|
-
right: 0;
|
|
80
|
-
margin: 0 auto;
|
|
81
|
-
}
|
|
82
|
-
|