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
package/es/utils/array.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { isNil } from 'lodash-es';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 如果传入一个非数组字段,则将其转化为数组
|
|
3
5
|
* @param value
|
|
6
|
+
* @param allowNil 如果设置为 false,则 value isNil 的情况下,会返回空数组
|
|
4
7
|
* @returns
|
|
5
8
|
*/
|
|
6
|
-
function toArray(value) {
|
|
9
|
+
function toArray(value, allowNil = true) {
|
|
10
|
+
if (!allowNil && isNil(value)) return [];
|
|
7
11
|
return Array.isArray(value) ? value : [value];
|
|
8
12
|
}
|
|
9
13
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 角度转弧度
|
|
3
|
+
* @param degrees
|
|
4
|
+
*/
|
|
5
|
+
export declare function degToRad(degrees: number): number;
|
|
6
|
+
/**
|
|
7
|
+
* 弧度转角度
|
|
8
|
+
* @param degrees
|
|
9
|
+
*/
|
|
10
|
+
export declare function radToDeg(radian: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* 获取两个点之间的距离
|
|
13
|
+
* @param p1
|
|
14
|
+
* @param p2
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function distance(p1: DOMPoint, p2: DOMPoint): number;
|
package/es/utils/math.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 角度转弧度
|
|
3
|
+
* @param degrees
|
|
4
|
+
*/
|
|
5
|
+
function degToRad(degrees) {
|
|
6
|
+
return degrees / 180 * Math.PI;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 弧度转角度
|
|
10
|
+
* @param degrees
|
|
11
|
+
*/
|
|
12
|
+
function radToDeg(radian) {
|
|
13
|
+
return radian / Math.PI * 180;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 获取两个点之间的距离
|
|
17
|
+
* @param p1
|
|
18
|
+
* @param p2
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
function distance(p1, p2) {
|
|
22
|
+
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { degToRad, distance, radToDeg };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function inRange(number: number, start: number, end: number, boundary?: '()' | '[]' | '[)' | '(]'): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function inRange(number, start, end, boundary = '[)') {
|
|
2
|
+
switch (boundary) {
|
|
3
|
+
case '()':
|
|
4
|
+
return number > start && number < end;
|
|
5
|
+
case '[]':
|
|
6
|
+
return number >= start && number <= end;
|
|
7
|
+
case '[)':
|
|
8
|
+
return number >= start && number < end;
|
|
9
|
+
case '(]':
|
|
10
|
+
return number > start && number <= end;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { inRange };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设置全局拖动监听器,用于解决:
|
|
3
|
+
* - 鼠标移到 disabled 元素上后 mouseup 事件丢失
|
|
4
|
+
* - 拖动过程中误选中文字
|
|
5
|
+
*
|
|
6
|
+
* @param onMove - 鼠标移动时触发的回调函数
|
|
7
|
+
* @param onEnd - 鼠标抬起时触发的回调函数
|
|
8
|
+
* @param cursor - 拖拽过程中的 style.cursor
|
|
9
|
+
*/
|
|
10
|
+
export declare function setupGlobalDrag(onMove: (e: MouseEvent) => void, onEnd?: (e: MouseEvent) => void, cursor?: string): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设置全局拖动监听器,用于解决:
|
|
3
|
+
* - 鼠标移到 disabled 元素上后 mouseup 事件丢失
|
|
4
|
+
* - 拖动过程中误选中文字
|
|
5
|
+
*
|
|
6
|
+
* @param onMove - 鼠标移动时触发的回调函数
|
|
7
|
+
* @param onEnd - 鼠标抬起时触发的回调函数
|
|
8
|
+
* @param cursor - 拖拽过程中的 style.cursor
|
|
9
|
+
*/
|
|
10
|
+
function setupGlobalDrag(onMove, onEnd, cursor) {
|
|
11
|
+
const originalPointerEvents = document.body.style.pointerEvents;
|
|
12
|
+
const originalCursor = document.documentElement.style.cursor;
|
|
13
|
+
if (cursor) {
|
|
14
|
+
document.documentElement.style.cursor = cursor;
|
|
15
|
+
}
|
|
16
|
+
const abortController = new AbortController();
|
|
17
|
+
window.addEventListener('mousemove', e => {
|
|
18
|
+
// 延迟设置 document.body.style.pointerEvents,直到 mousemove 触发,这样才算 drag。避免影响自身及子元素的 click 事件
|
|
19
|
+
document.body.style.pointerEvents = 'none'; // 防止 mouseup 被 disabled 元素吞掉,以及拖拽时误选中文字等
|
|
20
|
+
onMove(e);
|
|
21
|
+
}, {
|
|
22
|
+
signal: abortController.signal,
|
|
23
|
+
capture: true
|
|
24
|
+
});
|
|
25
|
+
window.addEventListener('mouseup', e => {
|
|
26
|
+
onEnd?.(e);
|
|
27
|
+
document.body.style.pointerEvents = originalPointerEvents;
|
|
28
|
+
if (cursor) {
|
|
29
|
+
document.documentElement.style.cursor = originalCursor;
|
|
30
|
+
}
|
|
31
|
+
abortController.abort();
|
|
32
|
+
}, {
|
|
33
|
+
once: true,
|
|
34
|
+
capture: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { setupGlobalDrag };
|
package/es/utils/solid.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { type JSXElement, type JSX, type Ref } from 'solid-js';
|
|
3
2
|
import { type StringOrJSXElement } from '../types';
|
|
4
3
|
/**
|
|
@@ -7,7 +6,6 @@ import { type StringOrJSXElement } from '../types';
|
|
|
7
6
|
* @returns
|
|
8
7
|
*/
|
|
9
8
|
export declare function isBaseType(value: JSXElement): value is string | number | boolean | null | undefined;
|
|
10
|
-
export declare function solidToReact(children: JSXElement): number | boolean | (string & {}) | React.FunctionComponentElement<import("./SolidToReact").SolidToReactProps> | null | undefined;
|
|
11
9
|
export declare function dispatchEventHandlerUnion<T, E extends Event>(handler: JSX.EventHandlerUnion<T, E> | undefined, e: E & {
|
|
12
10
|
currentTarget: T;
|
|
13
11
|
target: Element;
|
|
@@ -16,3 +14,5 @@ export declare function unwrapStringOrJSXElement(value: StringOrJSXElement): JSX
|
|
|
16
14
|
export declare function setRef<T>(props: {
|
|
17
15
|
ref?: Ref<T>;
|
|
18
16
|
}, value: T | null): void;
|
|
17
|
+
export declare function unwrapFunction<T>(value: T | (() => T)): T;
|
|
18
|
+
export declare function isEmptyJSXElement(element: JSXElement): boolean;
|
package/es/utils/solid.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { untrack } from 'solid-js';
|
|
3
2
|
import { isNil } from 'lodash-es';
|
|
4
|
-
import SolidToReact from './SolidToReact.js';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* 判断 JSXElement 是否是基础类型
|
|
@@ -11,11 +9,6 @@ import SolidToReact from './SolidToReact.js';
|
|
|
11
9
|
function isBaseType(value) {
|
|
12
10
|
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || value === null || value === undefined;
|
|
13
11
|
}
|
|
14
|
-
function solidToReact(children) {
|
|
15
|
-
return isBaseType(children) ? children : React.createElement(SolidToReact, {
|
|
16
|
-
children
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
12
|
function dispatchEventHandlerUnion(handler, e) {
|
|
20
13
|
if (isNil(handler)) {
|
|
21
14
|
return;
|
|
@@ -36,5 +29,11 @@ function setRef(props, value) {
|
|
|
36
29
|
}
|
|
37
30
|
});
|
|
38
31
|
}
|
|
32
|
+
function unwrapFunction(value) {
|
|
33
|
+
return typeof value === 'function' ? value() : value;
|
|
34
|
+
}
|
|
35
|
+
function isEmptyJSXElement(element) {
|
|
36
|
+
return element === undefined || element === null || typeof element === 'boolean' || element === '' || Array.isArray(element) && element.length === 0;
|
|
37
|
+
}
|
|
39
38
|
|
|
40
|
-
export { dispatchEventHandlerUnion, isBaseType, setRef,
|
|
39
|
+
export { dispatchEventHandlerUnion, isBaseType, isEmptyJSXElement, setRef, unwrapFunction, unwrapStringOrJSXElement };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-solid",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/index.esm.js",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"devDependencies": {
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
"@solidjs/testing-library": "^0.7.0",
|
|
15
15
|
"@testing-library/jest-dom": "^5.16.5",
|
|
16
16
|
"@types/lodash-es": "^4.17.7",
|
|
17
|
-
"@types/react": "^18.0.26",
|
|
18
|
-
"@types/react-dom": "^18.0.9",
|
|
19
17
|
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
20
18
|
"@typescript-eslint/parser": "^6.16.0",
|
|
21
19
|
"@unocss/cli": "^0.51.8",
|
|
@@ -35,6 +33,7 @@
|
|
|
35
33
|
"husky": "^8.0.3",
|
|
36
34
|
"jsdom": "^21.1.1",
|
|
37
35
|
"lint-staged": "^15.2.0",
|
|
36
|
+
"prettier": "^3.2.4",
|
|
38
37
|
"rollup": "^3.21.0",
|
|
39
38
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
40
39
|
"rollup-plugin-import-css": "^3.2.1",
|
|
@@ -43,23 +42,24 @@
|
|
|
43
42
|
"sass": "^1.69.6",
|
|
44
43
|
"typescript": "^5.1.6",
|
|
45
44
|
"vite-plugin-solid": "^2.7.0",
|
|
46
|
-
"vitepress": "1.
|
|
45
|
+
"vitepress": "1.3.4",
|
|
47
46
|
"vitest": "^0.30.1"
|
|
48
47
|
},
|
|
49
48
|
"keywords": [],
|
|
50
49
|
"author": "",
|
|
51
50
|
"license": "ISC",
|
|
52
51
|
"dependencies": {
|
|
52
|
+
"@ant-design/colors": "^7.0.2",
|
|
53
|
+
"@ctrl/tinycolor": "^4.1.0",
|
|
53
54
|
"antd": "^5.10.2",
|
|
54
55
|
"classnames": "^2.3.2",
|
|
55
56
|
"lodash-es": "^4.17.21",
|
|
56
57
|
"nanoid": "^5.0.1",
|
|
58
|
+
"number-precision": "^1.6.0",
|
|
57
59
|
"prismjs": "^1.29.0",
|
|
58
|
-
"
|
|
59
|
-
"react-dom": "^18.2.0",
|
|
60
|
-
"solid-js": "^1.8.7",
|
|
60
|
+
"solid-js": "^1.9.7",
|
|
61
61
|
"solid-transition-group": "^0.2.3",
|
|
62
|
-
"yup": "^1.
|
|
62
|
+
"yup": "^1.6.1"
|
|
63
63
|
},
|
|
64
64
|
"lint-staged": {
|
|
65
65
|
"**/*.{js,jsx,ts,tsx}": [
|
|
@@ -70,8 +70,7 @@
|
|
|
70
70
|
"files": [
|
|
71
71
|
"dist",
|
|
72
72
|
"es",
|
|
73
|
-
"css"
|
|
74
|
-
"src"
|
|
73
|
+
"css"
|
|
75
74
|
],
|
|
76
75
|
"scripts": {
|
|
77
76
|
"docs:dev": "vitepress dev docs",
|
package/es/ColorPicker.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Color } from 'antd/es/color-picker';
|
|
2
|
-
export interface ColorPickerProps {
|
|
3
|
-
defaultValue?: string | Color;
|
|
4
|
-
value?: string | Color;
|
|
5
|
-
onChange?: (value: Color, hex: string) => void;
|
|
6
|
-
}
|
|
7
|
-
declare const _default: (props: import("antd").ColorPickerProps) => import("solid-js").JSX.Element;
|
|
8
|
-
export default _default;
|
package/es/ColorPicker.js
DELETED
package/es/DatePicker.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type DatePickerProps, type RangePickerProps } from 'antd/es/date-picker';
|
|
2
|
-
declare const RangePicker: import("solid-js").Component<Omit<RangePickerProps & {
|
|
3
|
-
dropdownClassName?: string | undefined;
|
|
4
|
-
popupClassName?: string | undefined;
|
|
5
|
-
rootClassName?: string | undefined;
|
|
6
|
-
}, "className"> & {
|
|
7
|
-
class?: string | undefined;
|
|
8
|
-
}>;
|
|
9
|
-
declare const DatePicker: import("solid-js").Component<Omit<DatePickerProps & {
|
|
10
|
-
status?: '' | 'error' | 'warning' | undefined;
|
|
11
|
-
hashId?: string | undefined;
|
|
12
|
-
popupClassName?: string | undefined;
|
|
13
|
-
rootClassName?: string | undefined;
|
|
14
|
-
}, "className"> & {
|
|
15
|
-
class?: string | undefined;
|
|
16
|
-
}> & {
|
|
17
|
-
RangePicker: typeof RangePicker;
|
|
18
|
-
};
|
|
19
|
-
export default DatePicker;
|
package/es/DatePicker.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DatePicker as DatePicker$1 } from 'antd';
|
|
2
|
-
import { replaceClassName, reactToSolidComponent } from './utils/component.js';
|
|
3
|
-
|
|
4
|
-
const RangePicker = replaceClassName(reactToSolidComponent(DatePicker$1.RangePicker));
|
|
5
|
-
const _DatePicker = replaceClassName(reactToSolidComponent(DatePicker$1));
|
|
6
|
-
const DatePicker = _DatePicker;
|
|
7
|
-
DatePicker.RangePicker = RangePicker;
|
|
8
|
-
|
|
9
|
-
export { DatePicker as default };
|
package/es/Image.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type JSXElement } from 'solid-js';
|
|
2
|
-
declare const _Image: import("solid-js").Component<Omit<import("antd").ImageProps, "className"> & {
|
|
3
|
-
class?: string | undefined;
|
|
4
|
-
}>;
|
|
5
|
-
type ImageProps = Omit<Parameters<typeof _Image>[0], 'placeholder'> & {
|
|
6
|
-
placeholder?: JSXElement;
|
|
7
|
-
};
|
|
8
|
-
declare function Image(_props: ImageProps): import("solid-js").JSX.Element;
|
|
9
|
-
export default Image;
|
package/es/Image.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createComponent, mergeProps, template } from 'solid-js/web';
|
|
2
|
-
import { Image as Image$1 } from 'antd';
|
|
3
|
-
import { replaceClassName, reactToSolidComponent, configProvider } from './utils/component.js';
|
|
4
|
-
import { solidToReact } from './utils/solid.js';
|
|
5
|
-
import { createMemo } from 'solid-js';
|
|
6
|
-
import { mapValues } from 'lodash-es';
|
|
7
|
-
|
|
8
|
-
const _tmpl$ = /*#__PURE__*/template(`<div class="ant-inline-flex">`);
|
|
9
|
-
const _Image = replaceClassName(reactToSolidComponent(configProvider(Image$1), () => _tmpl$()));
|
|
10
|
-
function Image(_props) {
|
|
11
|
-
const props = createMemo(() => mapValues(_props, (value, key) => {
|
|
12
|
-
switch (key) {
|
|
13
|
-
case 'placeholder':
|
|
14
|
-
return solidToReact(value);
|
|
15
|
-
default:
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
}));
|
|
19
|
-
return createComponent(_Image, mergeProps(props));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { Image as default };
|
package/es/Input.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { JSX, JSXElement, Component } from 'solid-js';
|
|
2
|
-
type CommonInputProps<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement> = JSX.CustomAttributes<T> & {
|
|
3
|
-
textarea?: boolean;
|
|
4
|
-
defaultValue?: string | undefined;
|
|
5
|
-
value?: string | undefined;
|
|
6
|
-
addonBefore?: JSXElement;
|
|
7
|
-
addonAfter?: JSXElement;
|
|
8
|
-
prefix?: JSXElement;
|
|
9
|
-
suffix?: JSXElement;
|
|
10
|
-
placeholder?: string;
|
|
11
|
-
/**
|
|
12
|
-
* 仅供 InputNumber 使用
|
|
13
|
-
*/
|
|
14
|
-
actions?: JSXElement;
|
|
15
|
-
/**
|
|
16
|
-
* 设置校验状态
|
|
17
|
-
*/
|
|
18
|
-
status?: 'error' | 'warning';
|
|
19
|
-
onChange?: JSX.InputEventHandler<T, InputEvent>;
|
|
20
|
-
onPressEnter?: JSX.EventHandler<T, KeyboardEvent>;
|
|
21
|
-
onKeyDown?: JSX.EventHandler<T, KeyboardEvent>;
|
|
22
|
-
};
|
|
23
|
-
export declare function CommonInput<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement>(props: CommonInputProps<T> & Omit<JSX.InputHTMLAttributes<T>, 'onChange' | 'onInput' | 'onKeyDown'>): JSX.Element;
|
|
24
|
-
export type InputProps = Omit<CommonInputProps, 'actions' | 'textarea'> & Omit<JSX.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onInput' | 'onKeyDown'>;
|
|
25
|
-
export type TextAreaProps = Omit<CommonInputProps<HTMLTextAreaElement>, 'prefix' | 'suffix' | 'textarea'> & Omit<JSX.TextareaHTMLAttributes<HTMLTextAreaElement>, 'actions' | 'onChange' | 'onInput' | 'onKeyDown'>;
|
|
26
|
-
declare const Input: Component<InputProps> & {
|
|
27
|
-
TextArea: Component<TextAreaProps>;
|
|
28
|
-
};
|
|
29
|
-
export default Input;
|
package/es/Input.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { createComponent, Dynamic, mergeProps, insert, effect, className, style, template } from 'solid-js/web';
|
|
2
|
-
import { isNil, omit } from 'lodash-es';
|
|
3
|
-
import { splitProps, createMemo, Show } from 'solid-js';
|
|
4
|
-
import cs from 'classnames';
|
|
5
|
-
import createControllableValue from './hooks/createControllableValue.js';
|
|
6
|
-
import Compact from './Compact/index.js';
|
|
7
|
-
|
|
8
|
-
const _tmpl$ = /*#__PURE__*/template(`<div>`),
|
|
9
|
-
_tmpl$2 = /*#__PURE__*/template(`<div class="ant-mr-4px">`),
|
|
10
|
-
_tmpl$3 = /*#__PURE__*/template(`<div class="ant-ml-4px">`),
|
|
11
|
-
_tmpl$4 = /*#__PURE__*/template(`<div class="ant-[display:var(--input-after-display)] ant-absolute ant-top-0 ant-bottom-0 ant-right-0 ant-h-[calc(100%-2px)] ant-translate-y-1px -ant-translate-x-1px">`);
|
|
12
|
-
const statusClassDict = {
|
|
13
|
-
default: disabled => cs('ant-[border:1px_solid_var(--ant-color-border)]', !disabled && 'hover:ant-border-[var(--ant-color-primary)] focus-within:ant-border-[var(--ant-color-primary)] focus-within:ant-[box-shadow:0_0_0_2px_rgba(5,145,255,0.1)]'),
|
|
14
|
-
error: disabled => cs('ant-[border:1px_solid_var(--ant-color-error)]', !disabled && 'hover:ant-border-[var(--light-error-color)] focus-within:ant-[box-shadow:0_0_0_2px_rgba(255,38,5,.06)]'),
|
|
15
|
-
warning: disabled => cs('ant-[border:1px_solid_var(--warning-color)]', !disabled && 'hover:ant-border-[var(--color-warning-border-hover)] focus-within:ant-[box-shadow:0_0_0_2px_rgba(255,215,5,.1)]')
|
|
16
|
-
};
|
|
17
|
-
function CommonInput(props) {
|
|
18
|
-
const [{
|
|
19
|
-
style: style$1,
|
|
20
|
-
onChange,
|
|
21
|
-
onPressEnter,
|
|
22
|
-
onKeyDown
|
|
23
|
-
}, inputProps] = splitProps(props, ['defaultValue', 'value', 'class', 'addonBefore', 'addonAfter', 'suffix', 'onChange', 'onPressEnter', 'onKeyDown', 'actions', 'style']);
|
|
24
|
-
const [_, controllableProps] = splitProps(props, ['onChange']);
|
|
25
|
-
const [value, setValue] = createControllableValue(controllableProps);
|
|
26
|
-
const inputWrapClass = createMemo(() => cs('ant-px-11px ant-py-4px ant-rounded-6px', !props.textarea && 'ant-h-32px', props.addonBefore ? 'ant-rounded-l-0' : Compact.compactItemRoundedLeftClass, props.addonAfter ? 'ant-rounded-r-0' : Compact.compactItemRoundedRightClass, statusClassDict[props.status ?? 'default'](!!inputProps.disabled), Compact.compactItemRounded0Class, Compact.compactItemZIndexClass));
|
|
27
|
-
const hasPrefixOrSuffix = createMemo(() => !isNil(props.prefix) || !isNil(props.suffix) || !isNil(props.actions));
|
|
28
|
-
const inputJSX = createComponent(Dynamic, mergeProps({
|
|
29
|
-
get component() {
|
|
30
|
-
return props.textarea ? 'textarea' : 'input';
|
|
31
|
-
}
|
|
32
|
-
}, inputProps, {
|
|
33
|
-
get ["class"]() {
|
|
34
|
-
return cs('ant-w-full ant-[outline:none] ant-text-14px', !hasPrefixOrSuffix() && inputWrapClass(), inputProps.disabled && 'ant-bg-[var(--ant-color-bg-container-disabled)] ant-cursor-not-allowed');
|
|
35
|
-
},
|
|
36
|
-
get value() {
|
|
37
|
-
return value() ?? '';
|
|
38
|
-
},
|
|
39
|
-
onInput: e => {
|
|
40
|
-
setValue(e.target.value);
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
42
|
-
onChange?.(e);
|
|
43
|
-
if (Object.keys(props).includes('value')) {
|
|
44
|
-
e.target.value = value();
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
onKeyDown: e => {
|
|
48
|
-
if (e.key === 'Enter') {
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
50
|
-
onPressEnter?.(e);
|
|
51
|
-
}
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
53
|
-
onKeyDown?.(e);
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
return (() => {
|
|
57
|
-
const _el$ = _tmpl$();
|
|
58
|
-
insert(_el$, createComponent(Show, {
|
|
59
|
-
get when() {
|
|
60
|
-
return props.addonBefore;
|
|
61
|
-
},
|
|
62
|
-
get children() {
|
|
63
|
-
const _el$2 = _tmpl$();
|
|
64
|
-
insert(_el$2, () => props.addonBefore);
|
|
65
|
-
effect(() => className(_el$2, cs('ant-shrink-0 ant-flex ant-justify-center ant-items-center ant-px-11px ant-bg-[rgba(0,0,0,.02)] ant-[border:1px_solid_var(--ant-color-border)] ant-border-r-0 ant-rounded-l-6px ant-text-14px', Compact.compactItemRounded0Class, Compact.compactItemRoundedLeftClass)));
|
|
66
|
-
return _el$2;
|
|
67
|
-
}
|
|
68
|
-
}), null);
|
|
69
|
-
insert(_el$, createComponent(Show, {
|
|
70
|
-
get when() {
|
|
71
|
-
return hasPrefixOrSuffix();
|
|
72
|
-
},
|
|
73
|
-
fallback: inputJSX,
|
|
74
|
-
get children() {
|
|
75
|
-
const _el$3 = _tmpl$();
|
|
76
|
-
insert(_el$3, createComponent(Show, {
|
|
77
|
-
get when() {
|
|
78
|
-
return props.prefix;
|
|
79
|
-
},
|
|
80
|
-
get children() {
|
|
81
|
-
const _el$4 = _tmpl$2();
|
|
82
|
-
insert(_el$4, () => props.prefix);
|
|
83
|
-
return _el$4;
|
|
84
|
-
}
|
|
85
|
-
}), null);
|
|
86
|
-
insert(_el$3, inputJSX, null);
|
|
87
|
-
insert(_el$3, createComponent(Show, {
|
|
88
|
-
get when() {
|
|
89
|
-
return props.suffix;
|
|
90
|
-
},
|
|
91
|
-
get children() {
|
|
92
|
-
const _el$5 = _tmpl$3();
|
|
93
|
-
insert(_el$5, () => props.suffix);
|
|
94
|
-
return _el$5;
|
|
95
|
-
}
|
|
96
|
-
}), null);
|
|
97
|
-
insert(_el$3, createComponent(Show, {
|
|
98
|
-
get when() {
|
|
99
|
-
return props.actions;
|
|
100
|
-
},
|
|
101
|
-
get children() {
|
|
102
|
-
const _el$6 = _tmpl$4();
|
|
103
|
-
insert(_el$6, () => props.actions);
|
|
104
|
-
return _el$6;
|
|
105
|
-
}
|
|
106
|
-
}), null);
|
|
107
|
-
effect(() => className(_el$3, cs('ant-flex ant-items-center ant-w-full ant-relative ant-[--input-after-display:none] hover:ant-[--input-after-display:block] p:hover-child[input]:ant-border-[var(--ant-color-primary)]', inputWrapClass())));
|
|
108
|
-
return _el$3;
|
|
109
|
-
}
|
|
110
|
-
}), null);
|
|
111
|
-
insert(_el$, createComponent(Show, {
|
|
112
|
-
get when() {
|
|
113
|
-
return props.addonAfter;
|
|
114
|
-
},
|
|
115
|
-
get children() {
|
|
116
|
-
const _el$7 = _tmpl$();
|
|
117
|
-
insert(_el$7, () => props.addonAfter);
|
|
118
|
-
effect(() => className(_el$7, cs('ant-shrink-0 ant-flex ant-justify-center ant-items-center ant-px-11px ant-bg-[rgba(0,0,0,.02)] ant-[border:1px_solid_var(--ant-color-border)] ant-border-l-0 ant-rounded-r-6px ant-text-14px', Compact.compactItemRounded0Class, Compact.compactItemRoundedRightClass)));
|
|
119
|
-
return _el$7;
|
|
120
|
-
}
|
|
121
|
-
}), null);
|
|
122
|
-
effect(_p$ => {
|
|
123
|
-
const _v$ = cs('ant-flex ant-w-full', Compact.compactItemClass),
|
|
124
|
-
_v$2 = style$1;
|
|
125
|
-
_v$ !== _p$._v$ && className(_el$, _p$._v$ = _v$);
|
|
126
|
-
_p$._v$2 = style(_el$, _v$2, _p$._v$2);
|
|
127
|
-
return _p$;
|
|
128
|
-
}, {
|
|
129
|
-
_v$: undefined,
|
|
130
|
-
_v$2: undefined
|
|
131
|
-
});
|
|
132
|
-
return _el$;
|
|
133
|
-
})();
|
|
134
|
-
}
|
|
135
|
-
const Input = props => {
|
|
136
|
-
return createComponent(CommonInput, mergeProps(() => omit(props, ['actions'])));
|
|
137
|
-
};
|
|
138
|
-
Input.TextArea = props => {
|
|
139
|
-
return createComponent(CommonInput, mergeProps({
|
|
140
|
-
textarea: true
|
|
141
|
-
}, () => omit(props, ['prefix', 'suffix', 'actions'])));
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export { CommonInput, Input as default };
|
package/es/InputNumber.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Component } from 'solid-js';
|
|
2
|
-
import { type InputProps } from './Input';
|
|
3
|
-
export interface InputNumberProps extends Omit<InputProps, 'defaultValue' | 'value' | 'onChange' | 'inputAfter' | 'onKeyDown' | 'min' | 'max' | 'suffix'> {
|
|
4
|
-
defaultValue?: number | null | undefined;
|
|
5
|
-
value?: number | null | undefined;
|
|
6
|
-
onChange?: (value: number | null) => void;
|
|
7
|
-
min?: number;
|
|
8
|
-
max?: number;
|
|
9
|
-
}
|
|
10
|
-
declare const InputNumber: Component<InputNumberProps>;
|
|
11
|
-
export default InputNumber;
|
package/es/InputNumber.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { delegateEvents, createComponent, mergeProps as mergeProps$1, template } from 'solid-js/web';
|
|
2
|
-
import { mergeProps, splitProps, createSignal, untrack, createEffect, on } from 'solid-js';
|
|
3
|
-
import { CommonInput } from './Input.js';
|
|
4
|
-
import { isNil, clamp } from 'lodash-es';
|
|
5
|
-
import { dispatchEventHandlerUnion } from './utils/solid.js';
|
|
6
|
-
|
|
7
|
-
const _tmpl$ = /*#__PURE__*/template(`<div class="ant-flex ant-flex-col ant-h-full ant-w-24px ant-[border-left:1px_solid_var(--ant-color-border)]"><div class="ant-text-12px ant-flex ant-justify-center ant-items-center ant-h-1/2 ant-cursor-pointer ant-opacity-70 hover:ant-h-100% hover:ant-text-[var(--ant-color-primary)] ant-transition-color ant-transition-height ant-transition-duration-500"><div class="i-ant-design:up-outlined"></div></div><div class="ant-[border-top:1px_solid_var(--ant-color-border)] ant-text-12px ant-flex ant-justify-center ant-items-center ant-h-1/2 ant-cursor-pointer ant-opacity-70 hover:ant-h-100% hover:ant-text-[var(--ant-color-primary)] ant-transition-color ant-transition-height ant-transition-duration-500"><div class="i-ant-design:down-outlined">`);
|
|
8
|
-
const isEmptyValue = value => isNil(value) || value === '';
|
|
9
|
-
const InputNumber = _props => {
|
|
10
|
-
const props = mergeProps({
|
|
11
|
-
min: -Infinity,
|
|
12
|
-
max: Infinity
|
|
13
|
-
}, _props);
|
|
14
|
-
const [_, inputProps] = splitProps(props, ['defaultValue', 'value', 'onChange', 'onBlur']);
|
|
15
|
-
const clampValue = v => untrack(() => clamp(v, props.min, props.max));
|
|
16
|
-
let prev = null;
|
|
17
|
-
const updatePrev = v => {
|
|
18
|
-
if (prev === v) return;
|
|
19
|
-
prev = v;
|
|
20
|
-
props.onChange?.(prev);
|
|
21
|
-
};
|
|
22
|
-
const [value, setValue] = createSignal(untrack(() => props.value ?? props.defaultValue));
|
|
23
|
-
createEffect(on(() => props.value, () => {
|
|
24
|
-
setValue(props.value);
|
|
25
|
-
}, {
|
|
26
|
-
defer: true
|
|
27
|
-
}));
|
|
28
|
-
const add = addon => {
|
|
29
|
-
let newValue;
|
|
30
|
-
if (isEmptyValue(value())) {
|
|
31
|
-
newValue = clampValue(addon);
|
|
32
|
-
} else {
|
|
33
|
-
const num = Number(value());
|
|
34
|
-
newValue = Number.isNaN(num) ? null : clampValue(num + addon);
|
|
35
|
-
}
|
|
36
|
-
if (!Object.keys(props).includes('value')) {
|
|
37
|
-
setValue(newValue);
|
|
38
|
-
}
|
|
39
|
-
updatePrev(newValue);
|
|
40
|
-
};
|
|
41
|
-
const up = () => {
|
|
42
|
-
add(1);
|
|
43
|
-
};
|
|
44
|
-
const down = () => {
|
|
45
|
-
add(-1);
|
|
46
|
-
};
|
|
47
|
-
return createComponent(CommonInput, mergeProps$1(inputProps, {
|
|
48
|
-
get actions() {
|
|
49
|
-
return (() => {
|
|
50
|
-
const _el$ = _tmpl$(),
|
|
51
|
-
_el$2 = _el$.firstChild,
|
|
52
|
-
_el$3 = _el$2.nextSibling;
|
|
53
|
-
_el$2.$$click = up;
|
|
54
|
-
_el$3.$$click = down;
|
|
55
|
-
return _el$;
|
|
56
|
-
})();
|
|
57
|
-
},
|
|
58
|
-
get value() {
|
|
59
|
-
return `${value() ?? ''}`;
|
|
60
|
-
},
|
|
61
|
-
onKeyDown: e => {
|
|
62
|
-
switch (e.key) {
|
|
63
|
-
case 'ArrowUp':
|
|
64
|
-
up();
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
return;
|
|
67
|
-
case 'ArrowDown':
|
|
68
|
-
down();
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
onChange: e => {
|
|
73
|
-
const newValue = e.target.value;
|
|
74
|
-
setValue(newValue);
|
|
75
|
-
let newValueNum = Number(newValue);
|
|
76
|
-
if (Number.isNaN(newValueNum)) return;
|
|
77
|
-
if (isEmptyValue(newValue)) {
|
|
78
|
-
newValueNum = null;
|
|
79
|
-
} else {
|
|
80
|
-
newValueNum = clampValue(newValueNum);
|
|
81
|
-
}
|
|
82
|
-
updatePrev(newValueNum);
|
|
83
|
-
},
|
|
84
|
-
onBlur: e => {
|
|
85
|
-
setValue(props.value ?? prev);
|
|
86
|
-
dispatchEventHandlerUnion(props.onBlur, e);
|
|
87
|
-
}
|
|
88
|
-
}));
|
|
89
|
-
};
|
|
90
|
-
delegateEvents(["click"]);
|
|
91
|
-
|
|
92
|
-
export { InputNumber as default };
|