x-ui-design 1.0.30 → 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/components/Input/Input.d.ts +11 -0
- 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 -56
- package/dist/index.d.ts +1 -150
- package/dist/index.esm.js +3433 -3863
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3395 -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/dist/esm/types/components/Input/Input.d.ts +0 -16
- 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 -228
- 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
package/lib/hooks/usePosition.ts
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { Placement } from "../types";
|
|
2
|
-
import {
|
|
3
|
-
CSSProperties,
|
|
4
|
-
RefObject,
|
|
5
|
-
useCallback,
|
|
6
|
-
useEffect,
|
|
7
|
-
useState
|
|
8
|
-
} from "react";
|
|
9
|
-
|
|
10
|
-
type TPosition = {
|
|
11
|
-
isOpen: boolean;
|
|
12
|
-
popupRef: RefObject<HTMLDivElement | null>;
|
|
13
|
-
triggerRef: RefObject<HTMLDivElement | null>;
|
|
14
|
-
getPopupContainer?: HTMLElement;
|
|
15
|
-
placement?: Placement;
|
|
16
|
-
offset?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function getScrollParent(
|
|
20
|
-
el: HTMLElement | null,
|
|
21
|
-
includeSelf = false
|
|
22
|
-
): HTMLElement | null {
|
|
23
|
-
if (!el) return null;
|
|
24
|
-
|
|
25
|
-
let current: HTMLElement | null = includeSelf ? el : el.parentElement;
|
|
26
|
-
|
|
27
|
-
while (current) {
|
|
28
|
-
const style = getComputedStyle(current);
|
|
29
|
-
|
|
30
|
-
const overflowY = style.overflowY;
|
|
31
|
-
const overflowX = style.overflowX;
|
|
32
|
-
|
|
33
|
-
const canScroll =
|
|
34
|
-
overflowY === 'auto' ||
|
|
35
|
-
overflowY === 'scroll' ||
|
|
36
|
-
overflowX === 'auto' ||
|
|
37
|
-
overflowX === 'scroll';
|
|
38
|
-
|
|
39
|
-
if (canScroll) {
|
|
40
|
-
return current;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
current = current.parentElement;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return document.scrollingElement as HTMLElement;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const clampWithinContainer = (
|
|
50
|
-
left: number,
|
|
51
|
-
popupWidth: number,
|
|
52
|
-
containerRect: DOMRect
|
|
53
|
-
) => {
|
|
54
|
-
const minLeft = containerRect.left + document.documentElement.scrollLeft;
|
|
55
|
-
const maxLeft = containerRect.right + document.documentElement.scrollLeft - popupWidth;
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
minLeft,
|
|
59
|
-
maxLeft,
|
|
60
|
-
leftPosition: Math.min(Math.max(left, minLeft), maxLeft)
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const usePosition = ({
|
|
65
|
-
isOpen,
|
|
66
|
-
offset = 4,
|
|
67
|
-
popupRef,
|
|
68
|
-
placement,
|
|
69
|
-
triggerRef,
|
|
70
|
-
getPopupContainer
|
|
71
|
-
}: TPosition): {
|
|
72
|
-
showPlacement: string;
|
|
73
|
-
dropdownPosition: CSSProperties
|
|
74
|
-
} => {
|
|
75
|
-
const [showPlacement, setShowPlacement] = useState('');
|
|
76
|
-
const [_dropdownPosition, setDropdownPosition] = useState<CSSProperties>({});
|
|
77
|
-
|
|
78
|
-
const dropdownPosition = useCallback(() => {
|
|
79
|
-
if (!triggerRef.current) {
|
|
80
|
-
return {};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const inputRect = triggerRef.current?.getBoundingClientRect();
|
|
84
|
-
const dropdownHeight = popupRef.current?.offsetHeight || (popupRef.current?.offsetHeight || 0);
|
|
85
|
-
const containerRect = (getPopupContainer || getScrollParent(triggerRef.current, true) || document.body).getBoundingClientRect();
|
|
86
|
-
|
|
87
|
-
const spaceAbove = inputRect.top - containerRect.top;
|
|
88
|
-
const spaceBelow = containerRect.bottom - inputRect.bottom;
|
|
89
|
-
|
|
90
|
-
const _shouldShowAbove = spaceBelow < dropdownHeight && spaceAbove > dropdownHeight;
|
|
91
|
-
const hasRight = placement?.includes('Right');
|
|
92
|
-
|
|
93
|
-
if (getPopupContainer) {
|
|
94
|
-
const { minLeft, maxLeft, leftPosition } = clampWithinContainer(
|
|
95
|
-
hasRight
|
|
96
|
-
? (inputRect.left || 0) + (triggerRef.current?.offsetWidth || 0) - (popupRef.current?.offsetWidth || 0)
|
|
97
|
-
: (inputRect.left || 0) + document.documentElement.scrollLeft,
|
|
98
|
-
popupRef.current?.offsetWidth || 0,
|
|
99
|
-
containerRect
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const _center = (minLeft + maxLeft) < (popupRef.current?.offsetWidth || 0) ? 'center' : ''
|
|
103
|
-
setShowPlacement(_shouldShowAbove ? `bottom ${_center}` : `${_center}`);
|
|
104
|
-
|
|
105
|
-
const _top = (inputRect.top || 0) + document.documentElement.scrollTop;
|
|
106
|
-
|
|
107
|
-
if (_shouldShowAbove) {
|
|
108
|
-
setDropdownPosition({
|
|
109
|
-
top: _top - (popupRef.current?.offsetHeight || 0) + 4 - (offset !== 4 ? offset * 2 : 0),
|
|
110
|
-
left: leftPosition
|
|
111
|
-
})
|
|
112
|
-
} else {
|
|
113
|
-
setDropdownPosition({
|
|
114
|
-
top: _top + (triggerRef.current?.offsetHeight || 0) + offset,
|
|
115
|
-
left: leftPosition
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
setDropdownPosition({
|
|
120
|
-
top:
|
|
121
|
-
(_shouldShowAbove
|
|
122
|
-
? triggerRef.current.offsetTop -
|
|
123
|
-
(popupRef.current?.offsetHeight || dropdownHeight) - offset * 2
|
|
124
|
-
: triggerRef.current.offsetTop + triggerRef.current?.offsetHeight) + offset,
|
|
125
|
-
...(hasRight ? {
|
|
126
|
-
left: (() => {
|
|
127
|
-
const { minLeft, maxLeft, leftPosition } = clampWithinContainer(
|
|
128
|
-
triggerRef.current.offsetLeft +
|
|
129
|
-
(triggerRef.current?.offsetWidth || 0) -
|
|
130
|
-
(popupRef.current?.offsetWidth || dropdownHeight),
|
|
131
|
-
popupRef.current?.offsetWidth || dropdownHeight,
|
|
132
|
-
containerRect
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
const _center = (minLeft + maxLeft) < (popupRef.current?.offsetWidth || 0) ? 'center' : ''
|
|
136
|
-
setShowPlacement(_shouldShowAbove ? `bottom ${_center}` : `${_center}`);
|
|
137
|
-
|
|
138
|
-
return leftPosition
|
|
139
|
-
})()
|
|
140
|
-
} : {
|
|
141
|
-
left: (() => {
|
|
142
|
-
const { minLeft, maxLeft, leftPosition } = clampWithinContainer(
|
|
143
|
-
triggerRef.current.offsetLeft,
|
|
144
|
-
popupRef.current?.offsetWidth || dropdownHeight,
|
|
145
|
-
containerRect
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
const _center = (minLeft + maxLeft) < (popupRef.current?.offsetWidth || 0) ? 'center' : ''
|
|
149
|
-
setShowPlacement(_shouldShowAbove ? `bottom ${_center}` : `${_center}`);
|
|
150
|
-
|
|
151
|
-
return leftPosition
|
|
152
|
-
})()
|
|
153
|
-
})
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}, [
|
|
157
|
-
offset,
|
|
158
|
-
popupRef,
|
|
159
|
-
placement,
|
|
160
|
-
triggerRef,
|
|
161
|
-
getPopupContainer
|
|
162
|
-
]);
|
|
163
|
-
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
if (!isOpen) return;
|
|
166
|
-
|
|
167
|
-
const _dropdownPosition = () => dropdownPosition();
|
|
168
|
-
|
|
169
|
-
_dropdownPosition();
|
|
170
|
-
|
|
171
|
-
const controller = new AbortController();
|
|
172
|
-
|
|
173
|
-
const scrollableParents = getScrollParent(triggerRef.current, true);
|
|
174
|
-
|
|
175
|
-
scrollableParents?.addEventListener('scroll', _dropdownPosition, {
|
|
176
|
-
passive: true,
|
|
177
|
-
signal: controller.signal
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
window.addEventListener('scroll', _dropdownPosition, {
|
|
181
|
-
passive: true,
|
|
182
|
-
signal: controller.signal
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
window.addEventListener('resize', _dropdownPosition, {
|
|
186
|
-
signal: controller.signal
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
return () => {
|
|
190
|
-
controller.abort();
|
|
191
|
-
};
|
|
192
|
-
}, [
|
|
193
|
-
isOpen,
|
|
194
|
-
triggerRef,
|
|
195
|
-
getPopupContainer,
|
|
196
|
-
dropdownPosition
|
|
197
|
-
]);
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
showPlacement,
|
|
201
|
-
dropdownPosition: {
|
|
202
|
-
..._dropdownPosition,
|
|
203
|
-
opacity: Object.keys(_dropdownPosition).length ? 1 : 0
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
package/lib/hooks/useWatch.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useState } from 'react';
|
|
2
|
-
import { FormContext } from '../components/Form/Form';
|
|
3
|
-
import { RuleType } from '../types';
|
|
4
|
-
import { FormInstance } from '../types/form';
|
|
5
|
-
|
|
6
|
-
type UseWatchProps = {
|
|
7
|
-
name?: string;
|
|
8
|
-
defaultValue?: RuleType;
|
|
9
|
-
form?: FormInstance;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const useWatch = ({ name, defaultValue, form }: UseWatchProps) => {
|
|
13
|
-
const formContext = useContext(FormContext);
|
|
14
|
-
const formInstance = form || formContext;
|
|
15
|
-
|
|
16
|
-
if (!formInstance) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
'useWatch must be used within a Form or with a form instance.'
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const [value, setValue] = useState(() => {
|
|
23
|
-
return name
|
|
24
|
-
? formInstance.getFieldValue(name) ?? defaultValue
|
|
25
|
-
: formInstance.getFieldsValue() ?? defaultValue;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (!name) {
|
|
30
|
-
const unsubscribe = formInstance.subscribeToForm(setValue);
|
|
31
|
-
|
|
32
|
-
return () => unsubscribe();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const unsubscribe = formInstance.subscribeToField(name, setValue);
|
|
36
|
-
|
|
37
|
-
return () => unsubscribe();
|
|
38
|
-
}, [name, formInstance]);
|
|
39
|
-
|
|
40
|
-
return value;
|
|
41
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import type { FormInstance } from '../types/form';
|
|
3
|
-
|
|
4
|
-
export function useWatchError(form: FormInstance, name: string): string[] | undefined {
|
|
5
|
-
const [errors, setErrors] = useState<string[] | undefined>(form.getFieldError(name));
|
|
6
|
-
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
// Subscribe directly to error changes
|
|
9
|
-
const unsubscribe = form.subscribeToError?.(name, (newErrors: string[] | undefined) => {
|
|
10
|
-
setErrors(newErrors);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// Initialize on mount
|
|
14
|
-
setErrors(form.getFieldError(name));
|
|
15
|
-
|
|
16
|
-
return unsubscribe;
|
|
17
|
-
}, [form, name]);
|
|
18
|
-
|
|
19
|
-
return errors;
|
|
20
|
-
}
|
package/lib/index.ts
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
// Styles
|
|
2
|
-
import dynamic from 'next/dynamic';
|
|
3
|
-
import './styles/global.css';
|
|
4
|
-
|
|
5
|
-
const Button = dynamic(() => import('@/components/Button/Button'), { ssr: false });
|
|
6
|
-
const Checkbox = dynamic(() => import('@/components/Checkbox/Checkbox'), { ssr: false });
|
|
7
|
-
const Switch = dynamic(() => import('@/components/Switch/Switch'), { ssr: false });
|
|
8
|
-
const Empty = dynamic(() => import('@/components/Empty/Empty'), { ssr: false });
|
|
9
|
-
const Upload = dynamic(() => import('@/components/Upload/Upload'), { ssr: false });
|
|
10
|
-
|
|
11
|
-
const DatePicker = dynamic(() => import('@/components/DatePicker/DatePicker'), { ssr: false });
|
|
12
|
-
const RangePicker = dynamic(() => import('@/components/DatePicker/RangePicker/RangePicker'), { ssr: false });
|
|
13
|
-
const TimePicker = dynamic(() => import('@/components/DatePicker/TimePicker/TimePicker'), { ssr: false });
|
|
14
|
-
|
|
15
|
-
const Form = dynamic(() => import('@/components/Form/Form'), { ssr: false });
|
|
16
|
-
const FormItem = dynamic(() => import('@/components/Form/Item/Item'), { ssr: false });
|
|
17
|
-
|
|
18
|
-
const Input = dynamic(() => import('@/components/Input/Input'), { ssr: false });
|
|
19
|
-
const Textarea = dynamic(() => import('@/components/Input/Textarea/Textarea'), { ssr: false });
|
|
20
|
-
|
|
21
|
-
const Radio = dynamic(() => import('@/components/Radio/Radio'), { ssr: false });
|
|
22
|
-
const RadioButton = dynamic(() => import('@/components/Radio/Button/Button'), { ssr: false });
|
|
23
|
-
const RadioGroup = dynamic(() => import('@/components/Radio/Group/Group'), { ssr: false });
|
|
24
|
-
|
|
25
|
-
const Select = dynamic(() => import('@/components/Select/Select'), { ssr: false });
|
|
26
|
-
const Option = dynamic(() => import('@/components/Select/Option/Option'), { ssr: false });
|
|
27
|
-
const Tag = dynamic(() => import('@/components/Select/Tag/Tag'), { ssr: false });
|
|
28
|
-
|
|
29
|
-
const Skeleton = dynamic(() => import('@/components/Skeleton/Skeleton'), { ssr: false });
|
|
30
|
-
const SkeletonAvatar = dynamic(() => import('@/components/Skeleton/Avatar/Avatar'), { ssr: false });
|
|
31
|
-
const SkeletonButton = dynamic(() => import('@/components/Skeleton/Button/Button'), { ssr: false });
|
|
32
|
-
const SkeletonImage = dynamic(() => import('@/components/Skeleton/Image/Image'), { ssr: false });
|
|
33
|
-
const SkeletonInput = dynamic(() => import('@/components/Skeleton/Input/Input'), { ssr: false });
|
|
34
|
-
|
|
35
|
-
const Menu = dynamic(() => import('@/components/Menu/Menu'), { ssr: false });
|
|
36
|
-
const MenuItem = dynamic(() => import('@/components/Menu/Item/Item'), { ssr: false });
|
|
37
|
-
const MenuSubMenu = dynamic(() => import('@/components/Menu/SubMenu/SubMenu'), { ssr: false });
|
|
38
|
-
|
|
39
|
-
const Dropdown = dynamic(() => import('@/components/Dropdown/Dropdown'), { ssr: false });
|
|
40
|
-
|
|
41
|
-
const Popover = dynamic(() => import('@/components/Popover/Popover'), { ssr: false });
|
|
42
|
-
|
|
43
|
-
const Result = dynamic(() => import('@/components/Result/Result'), { ssr: false });
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
Button,
|
|
47
|
-
Checkbox,
|
|
48
|
-
Empty,
|
|
49
|
-
DatePicker,
|
|
50
|
-
RangePicker,
|
|
51
|
-
TimePicker,
|
|
52
|
-
Form,
|
|
53
|
-
FormItem,
|
|
54
|
-
Input,
|
|
55
|
-
Textarea,
|
|
56
|
-
Radio,
|
|
57
|
-
RadioButton,
|
|
58
|
-
RadioGroup,
|
|
59
|
-
Select,
|
|
60
|
-
Option,
|
|
61
|
-
Tag,
|
|
62
|
-
Skeleton,
|
|
63
|
-
SkeletonAvatar,
|
|
64
|
-
SkeletonButton,
|
|
65
|
-
SkeletonImage,
|
|
66
|
-
SkeletonInput,
|
|
67
|
-
Upload,
|
|
68
|
-
Switch,
|
|
69
|
-
Menu,
|
|
70
|
-
MenuItem,
|
|
71
|
-
MenuSubMenu,
|
|
72
|
-
Dropdown,
|
|
73
|
-
Popover,
|
|
74
|
-
Result
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export {
|
|
78
|
-
ClearIcon,
|
|
79
|
-
ArrowIcon,
|
|
80
|
-
LoadingIcon,
|
|
81
|
-
CheckIcon,
|
|
82
|
-
SearchIcon,
|
|
83
|
-
CalendarIcon,
|
|
84
|
-
SuccessIcon,
|
|
85
|
-
ErrorIcon,
|
|
86
|
-
DateDistanceIcon,
|
|
87
|
-
TimeIcon,
|
|
88
|
-
StampleIcon,
|
|
89
|
-
TrashIcon,
|
|
90
|
-
SpinerIcon,
|
|
91
|
-
} from '@/components/Icons';
|
|
92
|
-
|
|
93
|
-
// Hooks
|
|
94
|
-
export { useForm } from '@/hooks/useForm';
|
|
95
|
-
export { useWatch } from '@/hooks/useWatch';
|
|
96
|
-
|
|
97
|
-
export type {
|
|
98
|
-
FormInstance,
|
|
99
|
-
RuleObject,
|
|
100
|
-
RuleRender,
|
|
101
|
-
FieldData,
|
|
102
|
-
FieldInstancesInputRef,
|
|
103
|
-
FieldError,
|
|
104
|
-
FormProps,
|
|
105
|
-
FormItemChildComponentProps
|
|
106
|
-
} from '@/types/form';
|
|
107
|
-
|
|
108
|
-
export type {
|
|
109
|
-
DefaultProps,
|
|
110
|
-
TargetProps,
|
|
111
|
-
RuleTypes,
|
|
112
|
-
RuleType,
|
|
113
|
-
MouseEventHandlerSelect,
|
|
114
|
-
SyntheticBaseEvent,
|
|
115
|
-
Placement
|
|
116
|
-
} from '@/types';
|
|
117
|
-
|
|
118
|
-
export type {
|
|
119
|
-
CheckboxProps
|
|
120
|
-
} from '@/types/checkbox';
|
|
121
|
-
|
|
122
|
-
export type {
|
|
123
|
-
InputProps,
|
|
124
|
-
TextareaProps
|
|
125
|
-
} from '@/types/input';
|
|
126
|
-
|
|
127
|
-
export type {
|
|
128
|
-
PopoverProps
|
|
129
|
-
} from '@/types/popover';
|
|
130
|
-
|
|
131
|
-
export type {
|
|
132
|
-
ButtonType,
|
|
133
|
-
ButtonProps,
|
|
134
|
-
BaseButtonProps
|
|
135
|
-
} from '@/types/button';
|
|
136
|
-
|
|
137
|
-
export type {
|
|
138
|
-
ItemType,
|
|
139
|
-
MenuProps,
|
|
140
|
-
SubMenuItem
|
|
141
|
-
} from '@/types/menu';
|
|
142
|
-
|
|
143
|
-
export type {
|
|
144
|
-
DropdownProps,
|
|
145
|
-
DropdownItemType,
|
|
146
|
-
} from '@/types/dropdown';
|
|
147
|
-
|
|
148
|
-
export type {
|
|
149
|
-
ResultProps,
|
|
150
|
-
ResultStatusType
|
|
151
|
-
} from '@/types/result';
|
|
152
|
-
|
|
153
|
-
export type {
|
|
154
|
-
RadioProps,
|
|
155
|
-
RadioGroupProps,
|
|
156
|
-
RadioButtonProps
|
|
157
|
-
} from '@/types/radio';
|
|
158
|
-
|
|
159
|
-
export type {
|
|
160
|
-
TDatePickerProps,
|
|
161
|
-
TRangePickerProps,
|
|
162
|
-
TimePickerProps
|
|
163
|
-
} from '@/types/datepicker';
|
|
164
|
-
|
|
165
|
-
export type {
|
|
166
|
-
SelectProps,
|
|
167
|
-
OptionType,
|
|
168
|
-
OptionProps,
|
|
169
|
-
CustomTagProps,
|
|
170
|
-
TagProps,
|
|
171
|
-
DisplayValueType
|
|
172
|
-
} from '@/types/select';
|
|
173
|
-
|
|
174
|
-
export type {
|
|
175
|
-
RcFile,
|
|
176
|
-
UploadFile,
|
|
177
|
-
UploadProps,
|
|
178
|
-
UploadChangeParam
|
|
179
|
-
} from '@/types/upload';
|
|
180
|
-
|
|
181
|
-
export { FormContext } from '@/components/Form/Form';
|
|
182
|
-
|
|
183
|
-
export { clsx, createArray, parseValue } from '@/helpers'
|
|
184
|
-
export { flattenChildren } from '@/helpers/flatten';
|
package/lib/styles/global.css
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
/* MAIN */
|
|
3
|
-
--xui-color-hover: #f5f5f5;
|
|
4
|
-
--xui-color-disabled: #e6e6e6;
|
|
5
|
-
|
|
6
|
-
--xui-primary-color: #1677ff;
|
|
7
|
-
--xui-primary-color-light: #40a9ff;
|
|
8
|
-
|
|
9
|
-
--xui-text-color: rgba(0, 0, 0, 0.88);
|
|
10
|
-
--xui-text-color-light: rgba(0, 0, 0, 0.5);
|
|
11
|
-
|
|
12
|
-
--xui-error-color: #ff4d4f;
|
|
13
|
-
--xui-error-color-light: #ff6668;
|
|
14
|
-
--xui-success-color: #52c41a;
|
|
15
|
-
|
|
16
|
-
--xui-background-color: #ffffff;
|
|
17
|
-
|
|
18
|
-
/* FONTS */
|
|
19
|
-
--xui-font-size-xs: 12px;
|
|
20
|
-
--xui-font-size-sm: 14px;
|
|
21
|
-
--xui-font-size-md: 14px;
|
|
22
|
-
--xui-font-size-lg: 16px;
|
|
23
|
-
|
|
24
|
-
/* BORDERS */
|
|
25
|
-
--xui-border-radius-sm: 4px;
|
|
26
|
-
--xui-border-radius-md: 4px;
|
|
27
|
-
--xui-border-radius-lg: 6px;
|
|
28
|
-
|
|
29
|
-
--xui-border-color: #d9d9d9;
|
|
30
|
-
|
|
31
|
-
/* SELECT */
|
|
32
|
-
--xui-select-primary-color: var(--xui-primary-color);
|
|
33
|
-
--xui-select-background-color: var(--xui-background-color);
|
|
34
|
-
|
|
35
|
-
/* MENU */
|
|
36
|
-
--xui-menu-inline-bg: rgba(0, 0, 0, 0.02);
|
|
37
|
-
|
|
38
|
-
/* RESULT */
|
|
39
|
-
--xui-result-bg: #fff;
|
|
40
|
-
--xui-result-color: rgba(0, 0, 0, 0.85);
|
|
41
|
-
--xui-subtle-color: rgba(0, 0, 0, 0.45);
|
|
42
|
-
--xui-padding: 24px;
|
|
43
|
-
--xui-gap: 16px;
|
|
44
|
-
--xui-icon-size: 72px;
|
|
45
|
-
--xui-max-width: 560px;
|
|
46
|
-
--xui-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
html {
|
|
50
|
-
font-family: sans-serif;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.globalEllipsis {
|
|
54
|
-
text-overflow: ellipsis;
|
|
55
|
-
overflow: hidden;
|
|
56
|
-
white-space: nowrap;
|
|
57
|
-
}
|
package/lib/types/button.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, CSSProperties, ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
export const ButtonTypes = [
|
|
4
|
-
'default',
|
|
5
|
-
'primary',
|
|
6
|
-
'dashed',
|
|
7
|
-
'link',
|
|
8
|
-
'text',
|
|
9
|
-
'ghost'
|
|
10
|
-
] as const;
|
|
11
|
-
export const ButtonShapes = ['default', 'circle', 'round'] as const;
|
|
12
|
-
export const ButtonVariantTypes = [
|
|
13
|
-
'outlined',
|
|
14
|
-
'dashed',
|
|
15
|
-
'solid',
|
|
16
|
-
'filled',
|
|
17
|
-
'text',
|
|
18
|
-
'link'
|
|
19
|
-
] as const;
|
|
20
|
-
export const ButtonColorTypes = [
|
|
21
|
-
'default',
|
|
22
|
-
'primary',
|
|
23
|
-
'danger',
|
|
24
|
-
'blue',
|
|
25
|
-
'purple',
|
|
26
|
-
'cyan',
|
|
27
|
-
'green',
|
|
28
|
-
'magenta',
|
|
29
|
-
'pink',
|
|
30
|
-
'red',
|
|
31
|
-
'orange',
|
|
32
|
-
'yellow',
|
|
33
|
-
'volcano',
|
|
34
|
-
'geekblue',
|
|
35
|
-
'lime',
|
|
36
|
-
'gold'
|
|
37
|
-
] as const;
|
|
38
|
-
|
|
39
|
-
export type ButtonType = (typeof ButtonTypes)[number];
|
|
40
|
-
export type ButtonShape = (typeof ButtonShapes)[number];
|
|
41
|
-
export type ButtonVariantType = (typeof ButtonVariantTypes)[number];
|
|
42
|
-
export type ButtonColorType = (typeof ButtonColorTypes)[number];
|
|
43
|
-
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
|
44
|
-
export type ButtonHTMLType = 'button' | 'submit' | 'reset';
|
|
45
|
-
|
|
46
|
-
export interface BaseButtonProps {
|
|
47
|
-
type?: ButtonType;
|
|
48
|
-
color?: ButtonColorType;
|
|
49
|
-
variant?: ButtonVariantType;
|
|
50
|
-
icon?: ReactNode;
|
|
51
|
-
iconPosition?: 'start' | 'end';
|
|
52
|
-
shape?: ButtonShape;
|
|
53
|
-
size?: SizeType;
|
|
54
|
-
disabled?: boolean;
|
|
55
|
-
loading?:
|
|
56
|
-
| boolean
|
|
57
|
-
| {
|
|
58
|
-
delay?: number;
|
|
59
|
-
icon?: ReactNode;
|
|
60
|
-
};
|
|
61
|
-
prefixCls?: string;
|
|
62
|
-
prefixClsV3?: string;
|
|
63
|
-
className?: string;
|
|
64
|
-
rootClassName?: string;
|
|
65
|
-
ghost?: boolean;
|
|
66
|
-
danger?: boolean;
|
|
67
|
-
block?: boolean;
|
|
68
|
-
children?: ReactNode;
|
|
69
|
-
classNames?: {
|
|
70
|
-
icon?: string;
|
|
71
|
-
};
|
|
72
|
-
styles?: {
|
|
73
|
-
icon?: CSSProperties;
|
|
74
|
-
};
|
|
75
|
-
child?: ReactNode
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface ButtonProps
|
|
79
|
-
extends BaseButtonProps,
|
|
80
|
-
Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'type'> {
|
|
81
|
-
href?: string;
|
|
82
|
-
htmlType?: ButtonHTMLType;
|
|
83
|
-
}
|
package/lib/types/checkbox.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ForwardedRef,
|
|
3
|
-
KeyboardEventHandler,
|
|
4
|
-
MouseEvent,
|
|
5
|
-
MouseEventHandler,
|
|
6
|
-
ReactNode
|
|
7
|
-
} from 'react';
|
|
8
|
-
import { DefaultProps, TargetProps } from '.';
|
|
9
|
-
|
|
10
|
-
export type CheckboxProps = DefaultProps & {
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
onChange?: (e: MouseEvent<HTMLInputElement> & TargetProps) => void;
|
|
13
|
-
onClick?: MouseEventHandler<HTMLElement>;
|
|
14
|
-
onMouseEnter?: MouseEventHandler<HTMLElement>;
|
|
15
|
-
onMouseLeave?: MouseEventHandler<HTMLElement>;
|
|
16
|
-
onKeyPress?: KeyboardEventHandler<HTMLElement>;
|
|
17
|
-
onKeyDown?: KeyboardEventHandler<HTMLElement>;
|
|
18
|
-
value?: boolean;
|
|
19
|
-
tabIndex?: number;
|
|
20
|
-
name?: string;
|
|
21
|
-
children?: ReactNode;
|
|
22
|
-
id?: string;
|
|
23
|
-
autoFocus?: boolean;
|
|
24
|
-
type?: string;
|
|
25
|
-
skipGroup?: boolean;
|
|
26
|
-
required?: boolean;
|
|
27
|
-
defaultChecked?: boolean;
|
|
28
|
-
checked?: boolean;
|
|
29
|
-
titleClick?: boolean;
|
|
30
|
-
ref?: ForwardedRef<HTMLDivElement>;
|
|
31
|
-
controlled?: boolean;
|
|
32
|
-
};
|