antd-solid 0.0.12 → 0.0.13
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/css/index.css +10 -77
- package/dist/index.esm.js +7819 -2492
- package/dist/index.umd.js +1 -1
- package/es/Alert/index.d.ts +10 -0
- package/es/Alert/index.js +26 -0
- package/es/Button/index.d.ts +16 -4
- package/es/Button/index.js +107 -59
- package/es/Button/index.scss.js +1 -1
- package/es/Checkbox/Group.d.ts +19 -0
- package/es/Checkbox/Group.js +49 -0
- package/es/Checkbox/index.d.ts +15 -0
- package/es/Checkbox/index.js +60 -0
- package/es/CodeInput/index.d.ts +18 -0
- package/es/CodeInput/index.js +72 -0
- package/es/Collapse/Item.d.ts +46 -0
- package/es/Collapse/Item.js +130 -0
- package/es/Collapse/context.d.ts +5 -0
- package/es/Collapse/context.js +8 -0
- package/es/Collapse/index.d.ts +25 -10
- package/es/Collapse/index.js +95 -74
- package/es/Collapse/utils.d.ts +8 -0
- package/es/Collapse/utils.js +35 -0
- package/es/ColorPicker/ColorPickerInput.d.ts +3 -0
- package/es/ColorPicker/ColorPickerInput.js +250 -0
- package/es/ColorPicker/ColorPickerSelect.d.ts +3 -0
- package/es/ColorPicker/ColorPickerSelect.js +71 -0
- package/es/ColorPicker/ColorPickerSlider.d.ts +3 -0
- package/es/ColorPicker/ColorPickerSlider.js +115 -0
- package/es/ColorPicker/color.d.ts +24 -0
- package/es/ColorPicker/color.js +63 -0
- package/es/ColorPicker/context.d.ts +9 -0
- package/es/ColorPicker/context.js +5 -0
- package/es/ColorPicker/index.d.ts +31 -0
- package/es/ColorPicker/index.js +139 -0
- package/es/Command/context.d.ts +9 -0
- package/es/Command/context.js +11 -0
- package/es/Command/createCommand.d.ts +17 -0
- package/es/Command/createCommand.js +112 -0
- package/es/Command/index.d.ts +7 -0
- package/es/Command/index.js +9 -0
- package/es/Command/useCommandProps.d.ts +13 -0
- package/es/Command/useCommandProps.js +28 -0
- package/es/Compact/CompactContextIsolator.d.ts +3 -0
- package/es/Compact/CompactContextIsolator.js +15 -0
- package/es/Compact/context.d.ts +4 -0
- package/es/Compact/context.js +7 -0
- package/es/Compact/index.d.ts +11 -9
- package/es/Compact/index.js +28 -13
- package/es/Compact/index.scss.js +6 -0
- package/es/ConfigProvider/context.d.ts +11 -0
- package/es/ConfigProvider/context.js +15 -0
- package/es/ConfigProvider/dark/colorAlgorithm.d.ts +2 -0
- package/es/ConfigProvider/dark/colorAlgorithm.js +9 -0
- package/es/ConfigProvider/dark/colors.d.ts +3 -0
- package/es/ConfigProvider/dark/colors.js +47 -0
- package/es/ConfigProvider/dark/index.d.ts +2 -0
- package/es/ConfigProvider/dark/index.js +11 -0
- package/es/ConfigProvider/index.d.ts +32 -0
- package/es/ConfigProvider/index.js +44 -0
- package/es/ConfigProvider/light/colorAlgorithm.d.ts +2 -0
- package/es/ConfigProvider/light/colorAlgorithm.js +9 -0
- package/es/ConfigProvider/light/colors.d.ts +3 -0
- package/es/ConfigProvider/light/colors.js +45 -0
- package/es/ConfigProvider/light/index.d.ts +2 -0
- package/es/ConfigProvider/light/index.js +11 -0
- package/es/ConfigProvider/seed.d.ts +3 -0
- package/es/ConfigProvider/seed.js +22 -0
- package/es/ConfigProvider/types/index.d.ts +594 -0
- package/es/ConfigProvider/types/index.js +1 -0
- package/es/ConfigProvider/utils/genColorMapToken.d.ts +7 -0
- package/es/ConfigProvider/utils/genColorMapToken.js +85 -0
- package/es/ConfigProvider/utils/getAlphaColor.d.ts +2 -0
- package/es/ConfigProvider/utils/getAlphaColor.js +44 -0
- package/es/ConfigProvider/utils/index.d.ts +3 -0
- package/es/ConfigProvider/utils/index.js +181 -0
- package/es/ContextMenu/index.d.ts +8 -0
- package/es/ContextMenu/index.js +99 -0
- package/es/Cursor/index.d.ts +6 -0
- package/es/Cursor/index.js +71 -0
- package/es/DelayShow/index.d.ts +16 -0
- package/es/DelayShow/index.js +27 -0
- package/es/Divider/index.d.ts +17 -0
- package/es/Divider/index.js +71 -0
- package/es/Drawer/index.d.ts +20 -16
- package/es/Drawer/index.js +162 -111
- package/es/Drawer/index.scss.js +1 -1
- package/es/Dropdown/index.d.ts +16 -0
- package/es/Dropdown/index.js +47 -0
- package/es/Element/index.d.ts +10 -0
- package/es/Element/index.js +42 -0
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.d.ts +2 -1
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +25 -9
- package/es/Empty/assets/EmptySvg.js +1 -1
- package/es/Empty/assets/SimpleEmptySvg.js +1 -1
- package/es/Empty/index.d.ts +4 -2
- package/es/Empty/index.js +23 -13
- package/es/Form/Form.d.ts +8 -5
- package/es/Form/Form.js +50 -34
- package/es/Form/FormItem.d.ts +10 -5
- package/es/Form/FormItem.js +121 -104
- package/es/Form/context.d.ts +9 -9
- package/es/Form/context.js +4 -2
- package/es/Fragment/index.d.ts +4 -0
- package/es/Fragment/index.js +7 -0
- package/es/Image/index.d.ts +10 -0
- package/es/Image/index.js +37 -0
- package/es/Input/TextArea.d.ts +23 -0
- package/es/Input/TextArea.js +84 -0
- package/es/Input/index.d.ts +44 -0
- package/es/Input/index.js +213 -0
- package/es/Input/index.scss.js +6 -0
- package/es/InputNumber/index.d.ts +30 -0
- package/es/InputNumber/index.js +122 -0
- package/es/{InputNumber.test.js → InputNumber/index.test.js} +2 -1
- package/es/Menu/InternalMenu.d.ts +22 -0
- package/es/Menu/InternalMenu.js +196 -0
- package/es/Menu/index.d.ts +75 -0
- package/es/Menu/index.js +64 -0
- package/es/Message/Message.d.ts +9 -0
- package/es/Message/Message.js +34 -0
- package/es/Message/index.d.ts +12 -0
- package/es/Message/index.js +80 -0
- package/es/Message/index.scss.js +6 -0
- package/es/Message/useMessage.d.ts +6 -0
- package/es/Message/useMessage.js +54 -0
- package/es/Modal/index.d.ts +73 -0
- package/es/Modal/index.js +237 -0
- package/es/Modal/index.scss.js +6 -0
- package/es/Modal/useModal.d.ts +5 -0
- package/es/Modal/useModal.js +51 -0
- package/es/Modal/warning.d.ts +5 -0
- package/es/Modal/warning.js +43 -0
- package/es/{Popconfirm.d.ts → Popconfirm/index.d.ts} +2 -2
- package/es/Popconfirm/index.js +62 -0
- package/es/{Popover.d.ts → Popover/index.d.ts} +2 -2
- package/es/{Popover.js → Popover/index.js} +7 -12
- package/es/Progress/Circle.d.ts +16 -0
- package/es/Progress/Circle.js +122 -0
- package/es/Progress/index.d.ts +5 -2
- package/es/Progress/index.js +70 -65
- package/es/Radio/Button.d.ts +7 -0
- package/es/Radio/Button.js +72 -0
- package/es/Radio/Group.d.ts +18 -0
- package/es/Radio/Group.js +57 -0
- package/es/Radio/index.d.ts +14 -0
- package/es/Radio/index.js +68 -0
- package/es/RangeInput/index.d.ts +23 -0
- package/es/RangeInput/index.js +208 -0
- package/es/Result/index.js +49 -0
- package/es/Segmented/index.d.ts +10 -7
- package/es/Segmented/index.js +54 -53
- package/es/Select/index.d.ts +17 -0
- package/es/Select/index.js +75 -0
- package/es/SelectInput/index.d.ts +39 -0
- package/es/SelectInput/index.js +245 -0
- package/es/Slider/index.d.ts +47 -0
- package/es/Slider/index.js +177 -0
- package/es/Space/index.d.ts +13 -0
- package/es/Space/index.js +16 -0
- package/es/Spin/index.d.ts +19 -0
- package/es/Spin/index.js +82 -0
- package/es/{Switch.d.ts → Switch/index.d.ts} +9 -0
- package/es/Switch/index.js +41 -0
- package/es/{Table.d.ts → Table/index.d.ts} +6 -2
- package/es/Table/index.js +71 -0
- package/es/Tabs/index.d.ts +49 -0
- package/es/Tabs/index.js +256 -0
- package/es/Timeline/index.js +31 -0
- package/es/Tooltip/context.d.ts +5 -0
- package/es/Tooltip/context.js +5 -0
- package/es/Tooltip/index.d.ts +64 -0
- package/es/Tooltip/index.js +499 -0
- package/es/Transformer/index.d.ts +88 -0
- package/es/Transformer/index.js +882 -0
- package/es/Tree/SingleLevelTree.d.ts +28 -0
- package/es/Tree/SingleLevelTree.js +299 -0
- package/es/Tree/index.d.ts +83 -0
- package/es/Tree/index.js +197 -0
- package/es/TreeFor/index.d.ts +31 -0
- package/es/TreeFor/index.js +80 -0
- package/es/TreeSelect/index.d.ts +26 -0
- package/es/TreeSelect/index.js +98 -0
- package/es/{Upload.d.ts → Upload/index.d.ts} +8 -1
- package/es/Upload/index.js +112 -0
- package/es/assets/svg/ColorPickUp.d.ts +4 -0
- package/es/assets/svg/ColorPickUp.js +25 -0
- package/es/assets/svg/Crosshair.d.ts +7 -0
- package/es/assets/svg/Crosshair.js +51 -0
- package/es/assets/svg/Resize.d.ts +4 -0
- package/es/assets/svg/Resize.js +25 -0
- package/es/assets/svg/Rotate.d.ts +4 -0
- package/es/assets/svg/Rotate.js +20 -0
- package/es/assets/svg/RotateArrow.d.ts +4 -0
- package/es/assets/svg/RotateArrow.js +21 -0
- package/es/assets/svg/common.d.ts +2 -0
- package/es/assets/svg/common.js +9 -0
- package/es/hooks/createControllableValue.d.ts +1 -1
- package/es/hooks/createControllableValue.js +16 -17
- package/es/hooks/createTransition.d.ts +6 -2
- package/es/hooks/createTransition.js +12 -8
- package/es/hooks/useClickAway.d.ts +1 -1
- package/es/hooks/useClickAway.js +4 -3
- package/es/hooks/useComponentSize.d.ts +3 -0
- package/es/hooks/useComponentSize.js +12 -0
- package/es/hooks/useCounter.d.ts +12 -0
- package/es/hooks/useCounter.js +30 -0
- package/es/hooks/useFocus.d.ts +2 -0
- package/es/hooks/useFocus.js +24 -0
- package/es/hooks/useHover.d.ts +2 -0
- package/es/hooks/useHover.js +33 -0
- package/es/hooks/useLocale.d.ts +1 -0
- package/es/hooks/useLocale.js +11 -0
- package/es/hooks/useMouse.d.ts +1 -0
- package/es/hooks/useMouse.js +18 -0
- package/es/hooks/useScroll.d.ts +2 -0
- package/es/hooks/useScroll.js +29 -0
- package/es/hooks/useSize.d.ts +8 -2
- package/es/hooks/useSize.js +25 -13
- package/es/hooks/useVirtualList.d.ts +14 -0
- package/es/hooks/useVirtualList.js +45 -0
- package/es/index.d.ts +59 -8
- package/es/index.js +51 -21
- package/es/locale/en_US.d.ts +3 -0
- package/es/locale/en_US.js +9 -0
- package/es/locale/index.d.ts +5 -0
- package/es/locale/index.js +1 -0
- package/es/locale/zh_CN.d.ts +3 -0
- package/es/locale/zh_CN.js +9 -0
- package/es/types/index.d.ts +11 -2
- package/es/utils/animation.d.ts +6 -0
- package/es/utils/animation.js +20 -0
- package/es/utils/array.d.ts +2 -1
- package/es/utils/array.js +5 -1
- package/es/utils/domPoint.d.ts +7 -0
- package/es/utils/domPoint.js +11 -0
- package/es/utils/math.d.ts +17 -0
- package/es/utils/math.js +25 -0
- package/es/utils/number.d.ts +1 -0
- package/es/utils/number.js +14 -0
- package/es/utils/setupGlobalDrag.d.ts +10 -0
- package/es/utils/setupGlobalDrag.js +38 -0
- package/es/utils/solid.d.ts +2 -2
- package/es/utils/solid.js +7 -8
- package/package.json +10 -11
- package/es/ColorPicker.d.ts +0 -8
- package/es/ColorPicker.js +0 -6
- package/es/DatePicker.d.ts +0 -19
- package/es/DatePicker.js +0 -9
- package/es/Image.d.ts +0 -9
- package/es/Image.js +0 -22
- package/es/Input.d.ts +0 -29
- package/es/Input.js +0 -144
- package/es/InputNumber.d.ts +0 -11
- package/es/InputNumber.js +0 -92
- package/es/Modal.d.ts +0 -47
- package/es/Modal.js +0 -210
- package/es/Popconfirm.js +0 -64
- package/es/Radio.d.ts +0 -27
- package/es/Radio.js +0 -93
- package/es/Result.js +0 -29
- package/es/Select.d.ts +0 -16
- package/es/Select.js +0 -113
- package/es/Skeleton.d.ts +0 -9
- package/es/Skeleton.js +0 -9
- package/es/Spin.d.ts +0 -10
- package/es/Spin.js +0 -28
- package/es/Switch.js +0 -30
- package/es/Table.js +0 -57
- package/es/Tabs.d.ts +0 -17
- package/es/Tabs.js +0 -117
- package/es/Timeline.js +0 -30
- package/es/Tooltip.d.ts +0 -34
- package/es/Tooltip.js +0 -302
- package/es/Tree.d.ts +0 -28
- package/es/Tree.js +0 -198
- package/es/Upload.js +0 -96
- package/es/hooks/createUpdateEffect.d.ts +0 -5
- package/es/hooks/createUpdateEffect.js +0 -12
- package/es/utils/EventEmitter.d.ts +0 -7
- package/es/utils/EventEmitter.js +0 -13
- package/es/utils/ReactToSolid.d.ts +0 -8
- package/es/utils/ReactToSolid.js +0 -30
- package/es/utils/SolidToReact.d.ts +0 -8
- package/es/utils/SolidToReact.js +0 -23
- package/es/utils/component.d.ts +0 -31
- package/es/utils/component.js +0 -68
- package/es/utils/zh_CN.d.ts +0 -2
- package/es/utils/zh_CN.js +0 -236
- package/src/Button/index.scss +0 -9
- package/src/Button/index.tsx +0 -137
- package/src/Collapse/index.tsx +0 -86
- package/src/ColorPicker.tsx +0 -11
- package/src/Compact/index.tsx +0 -20
- package/src/DatePicker.tsx +0 -30
- package/src/Drawer/index.scss +0 -53
- package/src/Drawer/index.tsx +0 -211
- package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -15
- package/src/Empty/assets/EmptySvg.tsx +0 -43
- package/src/Empty/assets/SimpleEmptySvg.tsx +0 -16
- package/src/Empty/index.tsx +0 -25
- package/src/Form/Form.tsx +0 -94
- package/src/Form/FormItem.tsx +0 -141
- package/src/Form/context.ts +0 -16
- package/src/Form/index.ts +0 -13
- package/src/Image.tsx +0 -29
- package/src/Input.tsx +0 -202
- package/src/InputNumber.test.tsx +0 -46
- package/src/InputNumber.tsx +0 -139
- package/src/Modal.tsx +0 -221
- package/src/Popconfirm.tsx +0 -75
- package/src/Popover.tsx +0 -30
- package/src/Progress/index.tsx +0 -81
- package/src/Radio.tsx +0 -142
- package/src/Result.tsx +0 -38
- package/src/Segmented/index.tsx +0 -95
- package/src/Select.tsx +0 -138
- package/src/Skeleton.tsx +0 -14
- package/src/Spin.tsx +0 -34
- package/src/Switch.tsx +0 -34
- package/src/Table.tsx +0 -53
- package/src/Tabs.tsx +0 -131
- package/src/Timeline.tsx +0 -33
- package/src/Tooltip.tsx +0 -340
- package/src/Tree.tsx +0 -247
- package/src/Upload.tsx +0 -143
- package/src/hooks/createControllableValue.ts +0 -68
- package/src/hooks/createTransition.ts +0 -52
- package/src/hooks/createUpdateEffect.ts +0 -16
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useClickAway.ts +0 -18
- package/src/hooks/useSize.ts +0 -26
- package/src/index.ts +0 -47
- package/src/types/index.ts +0 -5
- package/src/utils/EventEmitter.ts +0 -15
- package/src/utils/ReactToSolid.tsx +0 -38
- package/src/utils/SolidToReact.tsx +0 -27
- package/src/utils/array.ts +0 -21
- package/src/utils/component.tsx +0 -85
- package/src/utils/solid.ts +0 -61
- package/src/utils/zh_CN.ts +0 -236
- /package/es/{InputNumber.test.d.ts → InputNumber/index.test.d.ts} +0 -0
- /package/es/{Result.d.ts → Result/index.d.ts} +0 -0
- /package/es/{Timeline.d.ts → Timeline/index.d.ts} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createComponent, memo } from 'solid-js/web';
|
|
2
|
+
import { isEmpty, remove } from 'lodash-es';
|
|
3
|
+
import { For, createMemo, createSignal, untrack, Show } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
function TreeFor(props) {
|
|
6
|
+
return createComponent(For, {
|
|
7
|
+
get each() {
|
|
8
|
+
return props.each;
|
|
9
|
+
},
|
|
10
|
+
get fallback() {
|
|
11
|
+
return props.fallback;
|
|
12
|
+
},
|
|
13
|
+
children: (item, index) => {
|
|
14
|
+
const nextEach = createMemo(() => props.nextEach(item));
|
|
15
|
+
const isParent = createMemo(() => !isEmpty(nextEach()));
|
|
16
|
+
const [filteredNextEach, setFilteredNextEach] = createSignal(untrack(nextEach) ?? []);
|
|
17
|
+
const isEmptyChildren = createMemo(() => isEmpty(filteredNextEach()));
|
|
18
|
+
const onChildChange = (child, value) => {
|
|
19
|
+
setFilteredNextEach(prev => {
|
|
20
|
+
if (value) {
|
|
21
|
+
if (prev.includes(child)) {
|
|
22
|
+
return prev;
|
|
23
|
+
} else {
|
|
24
|
+
prev.push(child);
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
if (prev.includes(child)) {
|
|
28
|
+
remove(prev, v => v === child);
|
|
29
|
+
} else {
|
|
30
|
+
return prev;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return [...prev];
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const options = {
|
|
37
|
+
index,
|
|
38
|
+
parentList: props.parentList,
|
|
39
|
+
parentIndexes: props.parentIndexes,
|
|
40
|
+
isParent,
|
|
41
|
+
isEmptyChildren,
|
|
42
|
+
onChildChange: props.onChildChange
|
|
43
|
+
};
|
|
44
|
+
const isExpanded = createMemo(() => props.expanded ? props.expanded(item, options) : true);
|
|
45
|
+
return [memo(() => props.children(item, options)), createComponent(Show, {
|
|
46
|
+
get when() {
|
|
47
|
+
return memo(() => !!isParent())() && isExpanded();
|
|
48
|
+
},
|
|
49
|
+
get children() {
|
|
50
|
+
return createComponent(TreeFor, {
|
|
51
|
+
get each() {
|
|
52
|
+
return nextEach();
|
|
53
|
+
},
|
|
54
|
+
get nextEach() {
|
|
55
|
+
return props.nextEach;
|
|
56
|
+
},
|
|
57
|
+
onChildChange: onChildChange,
|
|
58
|
+
get expanded() {
|
|
59
|
+
return props.expanded;
|
|
60
|
+
},
|
|
61
|
+
get children() {
|
|
62
|
+
return props.children;
|
|
63
|
+
},
|
|
64
|
+
get parentList() {
|
|
65
|
+
return [...(props.parentList ?? []), item];
|
|
66
|
+
},
|
|
67
|
+
get parentIndexes() {
|
|
68
|
+
return [...(props.parentIndexes ?? []), index()];
|
|
69
|
+
},
|
|
70
|
+
get fallback() {
|
|
71
|
+
return props.fallback;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
})];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { TreeFor as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type JSXElement } from 'solid-js';
|
|
2
|
+
import { type Key } from '../types';
|
|
3
|
+
import { type TreeProps } from '../Tree';
|
|
4
|
+
import { type SelectInputProps } from '../SelectInput';
|
|
5
|
+
export interface TreeSelectNode<T = Key> {
|
|
6
|
+
value: T;
|
|
7
|
+
label: JSXElement;
|
|
8
|
+
children?: TreeSelectNode[] | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface TreeSelectProps<T = Key> extends Pick<SelectInputProps<Key>, 'multiple' | 'allowClear' | 'class' | 'disabled' | 'placeholder' | 'status' | 'size'>, Pick<TreeProps<TreeSelectNode<T>>, 'treeData' | 'checkable' | 'checkStrategy'> {
|
|
11
|
+
defaultValue?: T | T[] | undefined;
|
|
12
|
+
value?: T | T[] | undefined;
|
|
13
|
+
onChange?: (value: T | T[] | undefined) => void;
|
|
14
|
+
/**
|
|
15
|
+
* 自定义节点 label、value、children 的字段
|
|
16
|
+
* 默认 { label: 'label', value: 'value', children: 'children' }
|
|
17
|
+
*/
|
|
18
|
+
fieldNames?: {
|
|
19
|
+
label?: string | ((node: TreeSelectNode<T>) => JSXElement);
|
|
20
|
+
value?: string | ((node: TreeSelectNode<T>) => T);
|
|
21
|
+
children?: string | ((node: TreeSelectNode<T>) => Array<TreeSelectNode<T>> | undefined);
|
|
22
|
+
};
|
|
23
|
+
labelRender?: (options: TreeSelectNode<T> | undefined) => JSXElement;
|
|
24
|
+
}
|
|
25
|
+
declare const TreeSelect: <T = Key>(props: TreeSelectProps<T>) => import("solid-js").JSX.Element;
|
|
26
|
+
export default TreeSelect;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createComponent, mergeProps, insert, template } from 'solid-js/web';
|
|
2
|
+
import { splitProps, untrack, createMemo, Show } from 'solid-js';
|
|
3
|
+
import { isNil, isEmpty, get } from 'lodash-es';
|
|
4
|
+
import createControllableValue from '../hooks/createControllableValue.js';
|
|
5
|
+
import Tree from '../Tree/index.js';
|
|
6
|
+
import SelectInput from '../SelectInput/index.js';
|
|
7
|
+
import { unwrapStringOrJSXElement } from '../utils/solid.js';
|
|
8
|
+
import Empty from '../Empty/index.js';
|
|
9
|
+
|
|
10
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class="px-4px py-8px">`);
|
|
11
|
+
const TreeSelect = props => {
|
|
12
|
+
const [selectInputProps] = splitProps(props, ['multiple', 'allowClear', 'class', 'disabled', 'placeholder', 'status', 'size']);
|
|
13
|
+
const [treeProps] = splitProps(props, ['treeData', 'checkable', 'checkStrategy']);
|
|
14
|
+
const fieldNames = Object.assign({
|
|
15
|
+
label: 'label',
|
|
16
|
+
value: 'value',
|
|
17
|
+
children: 'children'
|
|
18
|
+
}, untrack(() => props.fieldNames));
|
|
19
|
+
const getLabel = node => {
|
|
20
|
+
const labelFieldName = fieldNames.label;
|
|
21
|
+
return typeof labelFieldName === 'function' ? labelFieldName(node) : unwrapStringOrJSXElement(get(node, labelFieldName));
|
|
22
|
+
};
|
|
23
|
+
const getValue = node => {
|
|
24
|
+
const valueFieldName = fieldNames.value;
|
|
25
|
+
return typeof valueFieldName === 'function' ? valueFieldName(node) : get(node, valueFieldName);
|
|
26
|
+
};
|
|
27
|
+
const getChildren = node => {
|
|
28
|
+
const childrenFieldName = fieldNames.children;
|
|
29
|
+
return typeof childrenFieldName === 'function' ? childrenFieldName(node) : get(node, childrenFieldName);
|
|
30
|
+
};
|
|
31
|
+
const optionMap = createMemo(() => {
|
|
32
|
+
const map = new Map();
|
|
33
|
+
const treeForEach = list => {
|
|
34
|
+
list?.forEach(item => {
|
|
35
|
+
const key = getValue(item);
|
|
36
|
+
map.set(key, item);
|
|
37
|
+
const children = getChildren(item);
|
|
38
|
+
if (!isEmpty(children)) {
|
|
39
|
+
treeForEach(children);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
treeForEach(props.treeData);
|
|
44
|
+
return map;
|
|
45
|
+
});
|
|
46
|
+
const [value, setValue] = createControllableValue(props);
|
|
47
|
+
const valueArr = createMemo(() => props.multiple ? value() : isNil(value()) ? value() : [value()]);
|
|
48
|
+
const setValueArr = v => {
|
|
49
|
+
setValue(props.multiple ? v : v?.[0]);
|
|
50
|
+
};
|
|
51
|
+
return createComponent(SelectInput, mergeProps(selectInputProps, {
|
|
52
|
+
labelRender: v => props.labelRender ? props.labelRender(optionMap().get(v)) : getLabel(optionMap().get(v)) ?? v,
|
|
53
|
+
get value() {
|
|
54
|
+
return valueArr();
|
|
55
|
+
},
|
|
56
|
+
onChange: setValueArr,
|
|
57
|
+
content: close => createComponent(Show, {
|
|
58
|
+
get when() {
|
|
59
|
+
return !isEmpty(props.treeData);
|
|
60
|
+
},
|
|
61
|
+
get fallback() {
|
|
62
|
+
return createComponent(Empty.PRESENTED_IMAGE_SIMPLE, {});
|
|
63
|
+
},
|
|
64
|
+
get children() {
|
|
65
|
+
var _el$ = _tmpl$();
|
|
66
|
+
insert(_el$, createComponent(Tree, mergeProps({
|
|
67
|
+
get multiple() {
|
|
68
|
+
return props.multiple;
|
|
69
|
+
},
|
|
70
|
+
blockNode: true,
|
|
71
|
+
get fieldNames() {
|
|
72
|
+
return {
|
|
73
|
+
title: fieldNames.label,
|
|
74
|
+
key: fieldNames.value,
|
|
75
|
+
children: fieldNames.children
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}, () => props.checkable ? {
|
|
79
|
+
selectedKeys: [],
|
|
80
|
+
checkedKeys: valueArr(),
|
|
81
|
+
checkOnClick: true,
|
|
82
|
+
onCheck: checkedKeys => {
|
|
83
|
+
setValueArr(checkedKeys);
|
|
84
|
+
}
|
|
85
|
+
} : {
|
|
86
|
+
selectedKeys: valueArr(),
|
|
87
|
+
onSelect: selectedKeys => {
|
|
88
|
+
setValueArr(selectedKeys);
|
|
89
|
+
if (!props.multiple) close();
|
|
90
|
+
}
|
|
91
|
+
}, treeProps)));
|
|
92
|
+
return _el$;
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { TreeSelect as default };
|
|
@@ -50,8 +50,15 @@ export interface UploadProps<T = any> extends ParentProps {
|
|
|
50
50
|
onAdd?: (fileList: Array<Signal<T>>) => void;
|
|
51
51
|
multiple?: boolean;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* 根据一个 File 对象创建一个 UploadFile 对象
|
|
55
|
+
* @param file
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
declare function createUploadFile(file: File): UploadFile;
|
|
59
|
+
declare function request<T = any>(uploadFileSignal: Signal<UploadFile<T>>, customRequest: UploadProps['customRequest']): Promise<UploadFile<T>>;
|
|
54
60
|
declare const Upload: Component<UploadProps> & {
|
|
55
61
|
request: typeof request;
|
|
62
|
+
createUploadFile: typeof createUploadFile;
|
|
56
63
|
};
|
|
57
64
|
export default Upload;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { delegateEvents, insert, use, effect, className, setAttribute, template } from 'solid-js/web';
|
|
2
|
+
import { nanoid } from 'nanoid';
|
|
3
|
+
import { mergeProps, createSignal } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
var _tmpl$ = /*#__PURE__*/template(`<span><input class=hidden type=file>`);
|
|
6
|
+
/**
|
|
7
|
+
* 根据一个 File 对象创建一个 UploadFile 对象
|
|
8
|
+
* @param file
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function createUploadFile(file) {
|
|
12
|
+
const id = `upload-${nanoid()}`;
|
|
13
|
+
return {
|
|
14
|
+
id,
|
|
15
|
+
file,
|
|
16
|
+
name: file.name,
|
|
17
|
+
type: file.type,
|
|
18
|
+
size: file.size,
|
|
19
|
+
status: 'pending',
|
|
20
|
+
percent: 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async function request(uploadFileSignal, customRequest) {
|
|
24
|
+
const [uploadFile, setUploadFile] = uploadFileSignal;
|
|
25
|
+
const {
|
|
26
|
+
file
|
|
27
|
+
} = uploadFile();
|
|
28
|
+
if (!file) return await Promise.reject(new Error('file is required'));
|
|
29
|
+
return await new Promise((resolve, reject) => {
|
|
30
|
+
customRequest?.({
|
|
31
|
+
file,
|
|
32
|
+
onProgress(event) {
|
|
33
|
+
setUploadFile(value => ({
|
|
34
|
+
...value,
|
|
35
|
+
status: 'uploading',
|
|
36
|
+
percent: event.percent ?? 0
|
|
37
|
+
}));
|
|
38
|
+
},
|
|
39
|
+
onSuccess(response) {
|
|
40
|
+
const newValue = setUploadFile(value => ({
|
|
41
|
+
...value,
|
|
42
|
+
status: 'finished',
|
|
43
|
+
response
|
|
44
|
+
}));
|
|
45
|
+
resolve(newValue);
|
|
46
|
+
},
|
|
47
|
+
onError(err) {
|
|
48
|
+
setUploadFile(value => ({
|
|
49
|
+
...value,
|
|
50
|
+
status: 'error'
|
|
51
|
+
}));
|
|
52
|
+
reject(err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const Upload = _props => {
|
|
58
|
+
let input;
|
|
59
|
+
const props = mergeProps({
|
|
60
|
+
customRequest: ({
|
|
61
|
+
file,
|
|
62
|
+
onSuccess,
|
|
63
|
+
onError
|
|
64
|
+
}) => {
|
|
65
|
+
if (!_props.action) return;
|
|
66
|
+
const formData = new FormData();
|
|
67
|
+
formData.append('file', file);
|
|
68
|
+
fetch(_props.action, {
|
|
69
|
+
method: _props.method ?? 'post',
|
|
70
|
+
body: formData
|
|
71
|
+
}).then(onSuccess).catch(onError);
|
|
72
|
+
}
|
|
73
|
+
}, _props);
|
|
74
|
+
return (() => {
|
|
75
|
+
var _el$ = _tmpl$(),
|
|
76
|
+
_el$2 = _el$.firstChild;
|
|
77
|
+
_el$.$$click = () => input?.click();
|
|
78
|
+
insert(_el$, () => props.children, _el$2);
|
|
79
|
+
_el$2.$$input = e => {
|
|
80
|
+
const fileList = [];
|
|
81
|
+
for (const file of Array.from(e.target.files ?? [])) {
|
|
82
|
+
// eslint-disable-next-line solid/reactivity
|
|
83
|
+
const uploadFileSignal = createSignal(createUploadFile(file));
|
|
84
|
+
request(uploadFileSignal, props.customRequest);
|
|
85
|
+
fileList.push(uploadFileSignal);
|
|
86
|
+
}
|
|
87
|
+
props.onAdd?.(fileList);
|
|
88
|
+
e.target.value = '';
|
|
89
|
+
};
|
|
90
|
+
var _ref$ = input;
|
|
91
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : input = _el$2;
|
|
92
|
+
effect(_p$ => {
|
|
93
|
+
var _v$ = props.class,
|
|
94
|
+
_v$2 = props.accept,
|
|
95
|
+
_v$3 = props.multiple;
|
|
96
|
+
_v$ !== _p$.e && className(_el$, _p$.e = _v$);
|
|
97
|
+
_v$2 !== _p$.t && setAttribute(_el$2, "accept", _p$.t = _v$2);
|
|
98
|
+
_v$3 !== _p$.a && (_el$2.multiple = _p$.a = _v$3);
|
|
99
|
+
return _p$;
|
|
100
|
+
}, {
|
|
101
|
+
e: undefined,
|
|
102
|
+
t: undefined,
|
|
103
|
+
a: undefined
|
|
104
|
+
});
|
|
105
|
+
return _el$;
|
|
106
|
+
})();
|
|
107
|
+
};
|
|
108
|
+
Upload.request = request;
|
|
109
|
+
Upload.createUploadFile = createUploadFile;
|
|
110
|
+
delegateEvents(["click", "input"]);
|
|
111
|
+
|
|
112
|
+
export { Upload as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { effect, setAttribute, style, template } from 'solid-js/web';
|
|
2
|
+
import { commonStyle } from './common.js';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<svg viewBox="0 0 1024 1024"xmlns=http://www.w3.org/2000/svg><path d="M856.2176 347.904l-90.624 90.624 53.504 53.504a52.3264 52.3264 0 1 1-73.984 73.984l-71.5776-71.6288-444.928 444.9792a25.6 25.6 0 0 1-13.4656 7.0656l-133.1712 24.576a25.6 25.6 0 0 1-29.7984-29.7984l24.576-133.1712a25.6 25.6 0 0 1 7.0656-13.4656l444.928-444.9792-71.68-71.6288a52.3264 52.3264 0 0 1 73.984-73.984l53.504 53.504 90.624-90.624a128 128 0 0 1 181.0432 181.0432z m-291.328 37.888l-439.296 439.3472-16.384 88.7808 88.832-16.384 439.296-439.296-72.448-72.448z">`);
|
|
5
|
+
const ColorPickUpSvg = props => {
|
|
6
|
+
return (() => {
|
|
7
|
+
var _el$ = _tmpl$();
|
|
8
|
+
effect(_p$ => {
|
|
9
|
+
var _v$ = props.class,
|
|
10
|
+
_v$2 = {
|
|
11
|
+
...commonStyle,
|
|
12
|
+
...props.style
|
|
13
|
+
};
|
|
14
|
+
_v$ !== _p$.e && setAttribute(_el$, "class", _p$.e = _v$);
|
|
15
|
+
_p$.t = style(_el$, _v$2, _p$.t);
|
|
16
|
+
return _p$;
|
|
17
|
+
}, {
|
|
18
|
+
e: undefined,
|
|
19
|
+
t: undefined
|
|
20
|
+
});
|
|
21
|
+
return _el$;
|
|
22
|
+
})();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { ColorPickUpSvg as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type JSX, type Component } from 'solid-js';
|
|
2
|
+
import { type StyleProps } from '../../types';
|
|
3
|
+
declare const CrosshairSvg: Component<StyleProps & Pick<JSX.SvgSVGAttributes<SVGSVGElement>, 'ref'> & {
|
|
4
|
+
innerColor: string;
|
|
5
|
+
outerColor: string;
|
|
6
|
+
}>;
|
|
7
|
+
export default CrosshairSvg;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { use, effect, setAttribute, style, template } from 'solid-js/web';
|
|
2
|
+
import { commonStyle } from './common.js';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<svg viewBox="0 0 26 26"version=1.1 xmlns=http://www.w3.org/2000/svg><line x1=50% x2=50% y2=100% stroke-width=3></line><line x1=50% x2=50% y2=100% stroke-width=1></line><line x1=100% y1=50% y2=50% stroke-width=3></line><line x1=100% y1=50% y2=50% stroke-width=1></line><circle cx=50% cy=50% r=32.7% fill=none stroke-width=3></circle><circle cx=50% cy=50% r=32.7% fill=none stroke-width=1>`);
|
|
5
|
+
const CrosshairSvg = props => {
|
|
6
|
+
return (() => {
|
|
7
|
+
var _el$ = _tmpl$(),
|
|
8
|
+
_el$2 = _el$.firstChild,
|
|
9
|
+
_el$3 = _el$2.nextSibling,
|
|
10
|
+
_el$4 = _el$3.nextSibling,
|
|
11
|
+
_el$5 = _el$4.nextSibling,
|
|
12
|
+
_el$6 = _el$5.nextSibling,
|
|
13
|
+
_el$7 = _el$6.nextSibling;
|
|
14
|
+
var _ref$ = props.ref;
|
|
15
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : props.ref = _el$;
|
|
16
|
+
effect(_p$ => {
|
|
17
|
+
var _v$ = props.class,
|
|
18
|
+
_v$2 = {
|
|
19
|
+
...commonStyle,
|
|
20
|
+
...props.style
|
|
21
|
+
},
|
|
22
|
+
_v$3 = props.outerColor,
|
|
23
|
+
_v$4 = props.innerColor,
|
|
24
|
+
_v$5 = props.outerColor,
|
|
25
|
+
_v$6 = props.innerColor,
|
|
26
|
+
_v$7 = props.outerColor,
|
|
27
|
+
_v$8 = props.innerColor;
|
|
28
|
+
_v$ !== _p$.e && setAttribute(_el$, "class", _p$.e = _v$);
|
|
29
|
+
_p$.t = style(_el$, _v$2, _p$.t);
|
|
30
|
+
_v$3 !== _p$.a && setAttribute(_el$2, "stroke", _p$.a = _v$3);
|
|
31
|
+
_v$4 !== _p$.o && setAttribute(_el$3, "stroke", _p$.o = _v$4);
|
|
32
|
+
_v$5 !== _p$.i && setAttribute(_el$4, "stroke", _p$.i = _v$5);
|
|
33
|
+
_v$6 !== _p$.n && setAttribute(_el$5, "stroke", _p$.n = _v$6);
|
|
34
|
+
_v$7 !== _p$.s && setAttribute(_el$6, "stroke", _p$.s = _v$7);
|
|
35
|
+
_v$8 !== _p$.h && setAttribute(_el$7, "stroke", _p$.h = _v$8);
|
|
36
|
+
return _p$;
|
|
37
|
+
}, {
|
|
38
|
+
e: undefined,
|
|
39
|
+
t: undefined,
|
|
40
|
+
a: undefined,
|
|
41
|
+
o: undefined,
|
|
42
|
+
i: undefined,
|
|
43
|
+
n: undefined,
|
|
44
|
+
s: undefined,
|
|
45
|
+
h: undefined
|
|
46
|
+
});
|
|
47
|
+
return _el$;
|
|
48
|
+
})();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { CrosshairSvg as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { effect, setAttribute, style, template } from 'solid-js/web';
|
|
2
|
+
import { commonStyle } from './common.js';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<svg viewBox="0 0 1024 1024"xmlns=http://www.w3.org/2000/svg><path fill=black stroke=white stroke-width=50 d="M531.2 179.2l130.133333 140.8c4.266667 4.266667 6.4 10.666667 6.4 14.933333-2.133333 4.266667-6.4 6.4-14.933333 6.4h-85.333333v341.333334h85.333333c8.533333 0 12.8 2.133333 14.933333 6.4 2.133333 4.266667 0 8.533333-6.4 14.933333l-130.133333 140.8c-4.266667 6.4-12.8 8.533333-19.2 8.533333s-14.933333-2.133333-19.2-8.533333l-130.133333-140.8c-4.266667-4.266667-6.4-10.666667-6.4-14.933333 2.133333-4.266667 6.4-6.4 14.933333-6.4h85.333333v-341.333334h-85.333333c-8.533333 0-12.8-2.133333-14.933333-6.4-2.133333-4.266667 0-8.533333 6.4-14.933333l130.133333-140.8c4.266667-6.4 12.8-8.533333 19.2-8.533333s14.933333 2.133333 19.2 8.533333z">`);
|
|
5
|
+
const Resize = props => {
|
|
6
|
+
return (() => {
|
|
7
|
+
var _el$ = _tmpl$();
|
|
8
|
+
effect(_p$ => {
|
|
9
|
+
var _v$ = props.class,
|
|
10
|
+
_v$2 = {
|
|
11
|
+
...commonStyle,
|
|
12
|
+
...props.style
|
|
13
|
+
};
|
|
14
|
+
_v$ !== _p$.e && setAttribute(_el$, "class", _p$.e = _v$);
|
|
15
|
+
_p$.t = style(_el$, _v$2, _p$.t);
|
|
16
|
+
return _p$;
|
|
17
|
+
}, {
|
|
18
|
+
e: undefined,
|
|
19
|
+
t: undefined
|
|
20
|
+
});
|
|
21
|
+
return _el$;
|
|
22
|
+
})();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { Resize as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { spread, mergeProps, template } from 'solid-js/web';
|
|
2
|
+
import { commonStyle } from './common.js';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<svg viewBox="0 0 27 27"xmlns=http://www.w3.org/2000/svg><g><path data-follow-fill=currentColor fill-rule=evenodd clip-rule=evenodd d="M13.55 27c7.269 0 13.161-5.893 13.161-13.162C26.711 6.569 20.82.677 13.55.677 6.281.677.389 6.569.389 13.838c0 7.269 5.892 13.161 13.161 13.161Zm8.062-10.286 2.062-2.872c.409-.556.22-1.08-.45-1.08h-1.17c-.508-4.132-4.116-7.479-8.502-7.479-2.324 0-4.443.99-5.932 2.52-.467.426-.467 1.015-.131 1.367.343.376.9.442 1.415 0a6.48 6.48 0 0 1 4.648-1.964c3.371 0 6.071 2.455 6.562 5.556h-1.276c-.655 0-.851.524-.45 1.08l2.07 2.872c.32.45.826.45 1.154 0Zm-8.061 5.678c2.34 0 4.459-.99 5.948-2.52.459-.434.459-1.023.131-1.375-.352-.376-.9-.433-1.424.008a6.457 6.457 0 0 1-4.655 1.964 6.61 6.61 0 0 1-6.555-5.556h1.26c.663 0 .851-.523.45-1.072l-2.062-2.88c-.327-.45-.834-.45-1.153 0l-2.07 2.872c-.401.557-.221 1.08.45 1.08h1.186c.507 4.133 4.116 7.48 8.494 7.48Z"fill=currentColor>`);
|
|
5
|
+
const Rotate = props => {
|
|
6
|
+
return (() => {
|
|
7
|
+
var _el$ = _tmpl$();
|
|
8
|
+
spread(_el$, mergeProps(props, {
|
|
9
|
+
get style() {
|
|
10
|
+
return {
|
|
11
|
+
...commonStyle,
|
|
12
|
+
...props.style
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}), true, true);
|
|
16
|
+
return _el$;
|
|
17
|
+
})();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { Rotate as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { spread, mergeProps, template } from 'solid-js/web';
|
|
2
|
+
import { commonStyle } from './common.js';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<svg viewBox="0 0 1000 1000"xmlns=http://www.w3.org/2000/svg><path fill=black stroke-width=50 stroke=white d="M 100,700 l 210,-150 v 105 Q 700,700 655,310 h -105 L 700,100 l 150,210 h -105 Q 745,745 310,745 v 105 L 100,700">`);
|
|
5
|
+
const RotateArrowSvg = props => {
|
|
6
|
+
return (() => {
|
|
7
|
+
var _el$ = _tmpl$();
|
|
8
|
+
_el$.firstChild;
|
|
9
|
+
spread(_el$, mergeProps(props, {
|
|
10
|
+
get style() {
|
|
11
|
+
return {
|
|
12
|
+
...commonStyle,
|
|
13
|
+
...props.style
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}), true, true);
|
|
17
|
+
return _el$;
|
|
18
|
+
})();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { RotateArrowSvg as default };
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { createSignal } from 'solid-js';
|
|
2
|
-
import createUpdateEffect from './createUpdateEffect.js';
|
|
1
|
+
import { untrack, createSignal, createComputed, on } from 'solid-js';
|
|
3
2
|
|
|
4
3
|
function createControllableValue(props, options = {}) {
|
|
5
4
|
const {
|
|
6
|
-
defaultValuePropName
|
|
7
|
-
valuePropName
|
|
8
|
-
trigger
|
|
9
|
-
} =
|
|
5
|
+
defaultValuePropName,
|
|
6
|
+
valuePropName,
|
|
7
|
+
trigger
|
|
8
|
+
} = Object.assign({
|
|
9
|
+
defaultValuePropName: 'defaultValue',
|
|
10
|
+
valuePropName: 'value',
|
|
11
|
+
trigger: 'onChange'
|
|
12
|
+
}, options);
|
|
10
13
|
const getValue = () => props[valuePropName];
|
|
11
14
|
// 为什么不使用 Object.hasOwn?
|
|
12
15
|
// solid 的 proxy 对象对于任何 key,都会返回 true
|
|
13
16
|
const isControlled = () => Object.keys(props).includes(valuePropName);
|
|
14
|
-
|
|
15
|
-
if (isControlled()) {
|
|
16
|
-
defaultValue = getValue();
|
|
17
|
-
} else if (Object.keys(props).includes(defaultValuePropName)) {
|
|
18
|
-
defaultValue = props[defaultValuePropName];
|
|
19
|
-
}
|
|
17
|
+
const defaultValue = Object.keys(props).includes(defaultValuePropName) ? untrack(() => props[defaultValuePropName]) : options.defaultValue;
|
|
20
18
|
const [value, _setValue] = createSignal(defaultValue);
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
});
|
|
19
|
+
createComputed(on(getValue, () => {
|
|
20
|
+
if (isControlled()) _setValue(getValue());
|
|
21
|
+
}));
|
|
25
22
|
const setValue = v => {
|
|
26
|
-
const
|
|
23
|
+
const _value = untrack(value);
|
|
24
|
+
const newValue = typeof v === 'function' ? v(_value) : v;
|
|
25
|
+
if (newValue === _value) return;
|
|
27
26
|
if (!isControlled()) {
|
|
28
27
|
_setValue(newValue);
|
|
29
28
|
}
|
|
@@ -3,6 +3,10 @@ import { type Accessor } from 'solid-js';
|
|
|
3
3
|
* dom 节点显示或隐藏时的动画
|
|
4
4
|
* @param target
|
|
5
5
|
* @param when
|
|
6
|
-
* @param
|
|
6
|
+
* @param props.name 动画类名
|
|
7
7
|
*/
|
|
8
|
-
export default function createTransition(target: Accessor<HTMLElement | undefined | null>, when: Accessor<boolean>,
|
|
8
|
+
export default function createTransition(target: Accessor<HTMLElement | undefined | null>, when: Accessor<boolean>, props?: {
|
|
9
|
+
name?: string;
|
|
10
|
+
onAfterEnter?: (element: Element) => void;
|
|
11
|
+
onAfterExit?: (element: Element) => void;
|
|
12
|
+
}): void;
|
|
@@ -4,32 +4,36 @@ import { createEffect, on } from 'solid-js';
|
|
|
4
4
|
* dom 节点显示或隐藏时的动画
|
|
5
5
|
* @param target
|
|
6
6
|
* @param when
|
|
7
|
-
* @param
|
|
7
|
+
* @param props.name 动画类名
|
|
8
8
|
*/
|
|
9
|
-
function createTransition(target, when,
|
|
9
|
+
function createTransition(target, when, props = {}) {
|
|
10
10
|
createEffect(on(when, input => {
|
|
11
11
|
const targetValue = target();
|
|
12
12
|
if (!targetValue) return;
|
|
13
13
|
if (input) {
|
|
14
14
|
targetValue.style.display = '';
|
|
15
|
-
targetValue.classList.add(`${
|
|
15
|
+
targetValue.classList.add(`${props.name}-enter-active`, `${props.name}-enter`);
|
|
16
16
|
requestAnimationFrame(() => {
|
|
17
|
-
targetValue.classList.
|
|
17
|
+
targetValue.classList.add(`${props.name}-enter-to`);
|
|
18
|
+
targetValue.classList.remove(`${props.name}-enter`);
|
|
18
19
|
});
|
|
19
20
|
const onTransitionEnd = () => {
|
|
20
|
-
targetValue.classList.remove(`${
|
|
21
|
+
targetValue.classList.remove(`${props.name}-enter-active`, `${props.name}-enter-to`);
|
|
21
22
|
targetValue.removeEventListener('transitionend', onTransitionEnd);
|
|
23
|
+
props.onAfterEnter?.(targetValue);
|
|
22
24
|
};
|
|
23
25
|
targetValue.addEventListener('transitionend', onTransitionEnd);
|
|
24
26
|
} else {
|
|
25
|
-
targetValue.classList.add(`${
|
|
27
|
+
targetValue.classList.add(`${props.name}-exit-active`, `${props.name}-exit`);
|
|
26
28
|
requestAnimationFrame(() => {
|
|
27
|
-
targetValue.classList.
|
|
29
|
+
targetValue.classList.add(`${props.name}-exit-to`);
|
|
30
|
+
targetValue.classList.remove(`${props.name}-exit`);
|
|
28
31
|
});
|
|
29
32
|
const onTransitionEnd = () => {
|
|
30
33
|
targetValue.style.display = 'none';
|
|
31
|
-
targetValue.classList.remove(`${
|
|
34
|
+
targetValue.classList.remove(`${props.name}-exit-active`, `${props.name}-exit-to`);
|
|
32
35
|
targetValue.removeEventListener('transitionend', onTransitionEnd);
|
|
36
|
+
props.onAfterExit?.(targetValue);
|
|
33
37
|
};
|
|
34
38
|
targetValue.addEventListener('transitionend', onTransitionEnd);
|
|
35
39
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Accessor } from 'solid-js';
|
|
2
|
-
export default function useClickAway<T extends Event = Event>(onClickAway: (event: T) => void, target?: Accessor<Element | Element[]>): void;
|
|
2
|
+
export default function useClickAway<T extends Event = Event>(onClickAway: (event: T) => void, target?: Accessor<Element | Element[] | undefined>): void;
|