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/Form/Form.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mergeProps,
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { createComponent } from 'solid-js/web';
|
|
2
|
+
import { mergeProps, untrack, createSignal, createMemo } from 'solid-js';
|
|
3
|
+
import { createStore, produce } from 'solid-js/store';
|
|
4
|
+
import { cloneDeep, max, get, set, unset } from 'lodash-es';
|
|
5
|
+
import cs from 'classnames';
|
|
6
|
+
import FormContext from './context.js';
|
|
7
|
+
import { setRef } from '../utils/solid.js';
|
|
8
|
+
import Element from '../Element/index.js';
|
|
5
9
|
|
|
6
|
-
const _tmpl$ = /*#__PURE__*/template(`<form>`);
|
|
7
10
|
function Form(_props) {
|
|
8
11
|
const props = mergeProps({
|
|
9
12
|
layout: 'horizontal'
|
|
10
13
|
}, _props);
|
|
11
14
|
const rulesDict = {};
|
|
15
|
+
/**
|
|
16
|
+
* 用于设置错误消息方法的字典
|
|
17
|
+
*/
|
|
12
18
|
const setErrMsgDict = {};
|
|
13
|
-
const values = props.initialValues ? {
|
|
14
|
-
...props.initialValues
|
|
15
|
-
} : {};
|
|
19
|
+
const [values, setValues] = createStore(untrack(() => props.initialValues ? cloneDeep(props.initialValues) : {}));
|
|
16
20
|
const formInstance = {
|
|
17
21
|
async validateFields() {
|
|
22
|
+
const cloneValues = untrack(() => cloneDeep(values));
|
|
18
23
|
const promises = Object.entries(rulesDict).flatMap(([name, rules]) => {
|
|
19
|
-
return rules.map(async rule => await rule.validate(get(
|
|
24
|
+
return rules.map(async rule => await rule.validate(get(cloneValues, name)).catch(err => {
|
|
20
25
|
setErrMsgDict[name](err.message);
|
|
21
26
|
throw err;
|
|
22
27
|
}));
|
|
@@ -26,45 +31,56 @@ function Form(_props) {
|
|
|
26
31
|
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
27
32
|
throw {
|
|
28
33
|
errorFields: results.filter(res => res.status === 'rejected'),
|
|
29
|
-
values
|
|
34
|
+
values: cloneValues
|
|
30
35
|
};
|
|
31
36
|
}
|
|
32
|
-
return
|
|
37
|
+
return cloneValues;
|
|
38
|
+
},
|
|
39
|
+
getFieldValue(name) {
|
|
40
|
+
return get(values, name);
|
|
33
41
|
},
|
|
34
42
|
setFieldValue(name, value) {
|
|
35
|
-
|
|
43
|
+
setValues(produce(s => {
|
|
44
|
+
set(s, name, value);
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
removeFieldValue(name) {
|
|
48
|
+
setValues(produce(s => {
|
|
49
|
+
unset(s, name);
|
|
50
|
+
}));
|
|
36
51
|
}
|
|
37
52
|
};
|
|
38
|
-
|
|
39
|
-
if (typeof _props.ref === 'function') {
|
|
40
|
-
_props.ref?.(formInstance);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
53
|
+
setRef(_props, formInstance);
|
|
43
54
|
// 存储 form item 的 dom 节点宽度
|
|
44
55
|
const [itemWidthDict, setItemWidthDict] = createSignal({});
|
|
45
56
|
const maxItemWidth = createMemo(() => max(Object.values(itemWidthDict())));
|
|
46
|
-
return (
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
return createComponent(Element, {
|
|
58
|
+
tag: "form",
|
|
59
|
+
get ["class"]() {
|
|
60
|
+
return cs(props.class, '[font-size:var(--ant-font-size)] text-[var(--ant-color-text)] leading-[var(--ant-line-height)]', props.layout === 'inline' ? 'inline-flex flex-wrap' : '');
|
|
61
|
+
},
|
|
62
|
+
get style() {
|
|
63
|
+
return props.style;
|
|
64
|
+
},
|
|
65
|
+
onSubmit: e => {
|
|
49
66
|
e.preventDefault();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
},
|
|
68
|
+
get children() {
|
|
69
|
+
return createComponent(FormContext.Provider, {
|
|
70
|
+
value: {
|
|
54
71
|
formInstance,
|
|
55
72
|
rulesDict,
|
|
56
73
|
setErrMsgDict,
|
|
57
|
-
initialValues: props.initialValues,
|
|
58
74
|
setItemWidthDict,
|
|
59
|
-
maxItemWidth
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
75
|
+
maxItemWidth,
|
|
76
|
+
layout: () => props.layout
|
|
77
|
+
},
|
|
78
|
+
get children() {
|
|
79
|
+
return props.children;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
export { Form as default };
|
package/es/Form/FormItem.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type JSXElement, type
|
|
1
|
+
import { type JSXElement, type JSX, type Component } from 'solid-js';
|
|
2
2
|
import { type Schema } from 'yup';
|
|
3
3
|
export interface FormItemComponentProps<T = any> {
|
|
4
|
-
|
|
4
|
+
value?: T | undefined;
|
|
5
5
|
status?: 'error' | 'warning';
|
|
6
|
-
onChange
|
|
6
|
+
onChange: (value: T) => void;
|
|
7
7
|
}
|
|
8
8
|
export interface FormItemProps {
|
|
9
9
|
class?: string;
|
|
@@ -13,7 +13,12 @@ export interface FormItemProps {
|
|
|
13
13
|
name?: string;
|
|
14
14
|
initialValue?: any;
|
|
15
15
|
rules?: Schema[];
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 是否隐藏
|
|
18
|
+
* 和 when 的区别,只是不会显示,但值依然会存在
|
|
19
|
+
*/
|
|
20
|
+
hidden?: boolean;
|
|
21
|
+
component?: Component<FormItemComponentProps>;
|
|
17
22
|
}
|
|
18
|
-
declare const FormItem:
|
|
23
|
+
declare const FormItem: (props: FormItemProps) => JSX.Element;
|
|
19
24
|
export default FormItem;
|
package/es/Form/FormItem.js
CHANGED
|
@@ -1,49 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useContext, createSignal,
|
|
3
|
-
import {
|
|
1
|
+
import { createComponent, use, insert, effect, className, Dynamic, memo, template } from 'solid-js/web';
|
|
2
|
+
import { useContext, createSignal, createEffect, onCleanup, onMount, on, Show } from 'solid-js';
|
|
3
|
+
import { set, unset, isNil } from 'lodash-es';
|
|
4
4
|
import { nanoid } from 'nanoid';
|
|
5
5
|
import cs from 'classnames';
|
|
6
|
-
import
|
|
6
|
+
import FormContext from './context.js';
|
|
7
|
+
import Element from '../Element/index.js';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
_tmpl$2 = /*#__PURE__*/template(`<
|
|
10
|
-
_tmpl$3 = /*#__PURE__*/template(`<div class="
|
|
11
|
-
_tmpl$4 = /*#__PURE__*/template(`<div
|
|
9
|
+
var _tmpl$ = /*#__PURE__*/template(`<label class=mr-4px>`),
|
|
10
|
+
_tmpl$2 = /*#__PURE__*/template(`<span class=text-[var(--ant-color-error)]>*`),
|
|
11
|
+
_tmpl$3 = /*#__PURE__*/template(`<div class="flex items-center"><label>`),
|
|
12
|
+
_tmpl$4 = /*#__PURE__*/template(`<div class="absolute top-[100%] text-[var(--ant-color-error)]">`),
|
|
13
|
+
_tmpl$5 = /*#__PURE__*/template(`<div class="flex flex-col relative flex-grow-1"><div>`);
|
|
12
14
|
const FormItem = props => {
|
|
13
15
|
const {
|
|
14
16
|
formInstance,
|
|
15
17
|
rulesDict,
|
|
16
18
|
setErrMsgDict,
|
|
17
|
-
initialValues,
|
|
18
19
|
setItemWidthDict,
|
|
19
|
-
maxItemWidth
|
|
20
|
-
|
|
20
|
+
maxItemWidth,
|
|
21
|
+
layout
|
|
22
|
+
} = useContext(FormContext);
|
|
21
23
|
const [errMsg, setErrMsg] = createSignal('');
|
|
22
24
|
const id = nanoid();
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
createEffect(() => {
|
|
26
|
+
if (props.name && props.rules && rulesDict && setErrMsgDict) {
|
|
27
|
+
set(rulesDict, props.name, props.rules);
|
|
28
|
+
set(setErrMsgDict, props.name, setErrMsg);
|
|
29
|
+
onCleanup(() => {
|
|
30
|
+
unset(rulesDict, props.name);
|
|
31
|
+
unset(setErrMsgDict, props.name);
|
|
32
|
+
});
|
|
30
33
|
}
|
|
31
|
-
setErrMsgDict[props.name] = setErrMsg;
|
|
32
34
|
});
|
|
33
35
|
let label;
|
|
36
|
+
console.log('onMount before');
|
|
34
37
|
onMount(() => {
|
|
38
|
+
console.log('onMount', label);
|
|
39
|
+
});
|
|
40
|
+
console.log('onMount after');
|
|
41
|
+
createEffect(on(() => !props.hidden && layout() === 'horizontal', input => {
|
|
42
|
+
console.log('label', label);
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
console.log('label after', label);
|
|
45
|
+
}, 1000);
|
|
46
|
+
if (!input || !label) return;
|
|
35
47
|
const resizeObserver = new ResizeObserver(entries => {
|
|
36
48
|
const [entry] = entries;
|
|
37
49
|
// Firefox implements `borderBoxSize` as a single content rect, rather than an array
|
|
38
50
|
const borderBoxSize = Array.isArray(entry.borderBoxSize) ? entry.borderBoxSize[0] : entry.borderBoxSize;
|
|
39
|
-
setItemWidthDict(dict => ({
|
|
51
|
+
setItemWidthDict?.(dict => ({
|
|
40
52
|
...dict,
|
|
41
53
|
[id]: borderBoxSize.inlineSize
|
|
42
54
|
}));
|
|
43
55
|
});
|
|
44
56
|
resizeObserver.observe(label);
|
|
45
57
|
onCleanup(() => {
|
|
46
|
-
setItemWidthDict(dict => {
|
|
58
|
+
setItemWidthDict?.(dict => {
|
|
47
59
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
48
60
|
delete dict[id];
|
|
49
61
|
return {
|
|
@@ -52,90 +64,95 @@ const FormItem = props => {
|
|
|
52
64
|
});
|
|
53
65
|
resizeObserver.disconnect();
|
|
54
66
|
});
|
|
67
|
+
}));
|
|
68
|
+
return createComponent(Show, {
|
|
69
|
+
get when() {
|
|
70
|
+
return !props.hidden;
|
|
71
|
+
},
|
|
72
|
+
get children() {
|
|
73
|
+
return createComponent(Element, {
|
|
74
|
+
get ["class"]() {
|
|
75
|
+
return cs(props.class, 'mb-[--ant-margin-lg]', layout() === 'horizontal' && 'flex items-center', layout() === 'inline' && 'inline-flex mr-[--ant-margin-lg]');
|
|
76
|
+
},
|
|
77
|
+
get style() {
|
|
78
|
+
return props.style;
|
|
79
|
+
},
|
|
80
|
+
get children() {
|
|
81
|
+
return [(() => {
|
|
82
|
+
var _el$ = _tmpl$3(),
|
|
83
|
+
_el$2 = _el$.firstChild;
|
|
84
|
+
var _ref$ = label;
|
|
85
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : label = _el$2;
|
|
86
|
+
insert(_el$2, createComponent(Show, {
|
|
87
|
+
get when() {
|
|
88
|
+
return !isNil(props.label);
|
|
89
|
+
},
|
|
90
|
+
get children() {
|
|
91
|
+
var _el$3 = _tmpl$();
|
|
92
|
+
insert(_el$3, () => props.label);
|
|
93
|
+
return _el$3;
|
|
94
|
+
}
|
|
95
|
+
}), null);
|
|
96
|
+
insert(_el$2, createComponent(Show, {
|
|
97
|
+
get when() {
|
|
98
|
+
return !isNil(props.required);
|
|
99
|
+
},
|
|
100
|
+
get children() {
|
|
101
|
+
return _tmpl$2();
|
|
102
|
+
}
|
|
103
|
+
}), null);
|
|
104
|
+
effect(_p$ => {
|
|
105
|
+
var _v$ = layout() === 'horizontal' && maxItemWidth ? `${maxItemWidth() ?? 0}px` : undefined,
|
|
106
|
+
_v$2 = cs('shrink-0 leading-32px not[:empty]:h-32px not[:empty]:pr-8px text-right [white-space:nowrap]');
|
|
107
|
+
_v$ !== _p$.e && ((_p$.e = _v$) != null ? _el$.style.setProperty("width", _v$) : _el$.style.removeProperty("width"));
|
|
108
|
+
_v$2 !== _p$.t && className(_el$2, _p$.t = _v$2);
|
|
109
|
+
return _p$;
|
|
110
|
+
}, {
|
|
111
|
+
e: undefined,
|
|
112
|
+
t: undefined
|
|
113
|
+
});
|
|
114
|
+
return _el$;
|
|
115
|
+
})(), (() => {
|
|
116
|
+
var _el$5 = _tmpl$5(),
|
|
117
|
+
_el$6 = _el$5.firstChild;
|
|
118
|
+
insert(_el$6, createComponent(Dynamic, {
|
|
119
|
+
get component() {
|
|
120
|
+
return props.component;
|
|
121
|
+
},
|
|
122
|
+
get value() {
|
|
123
|
+
return memo(() => !!props.name)() ? formInstance?.getFieldValue(props.name) : undefined;
|
|
124
|
+
},
|
|
125
|
+
get status() {
|
|
126
|
+
return errMsg() ? 'error' : undefined;
|
|
127
|
+
},
|
|
128
|
+
onChange: value => {
|
|
129
|
+
if (!isNil(props.name)) formInstance?.setFieldValue(props.name, value);
|
|
130
|
+
props.rules?.forEach(rule => {
|
|
131
|
+
rule.validate(value).then(() => {
|
|
132
|
+
setErrMsg('');
|
|
133
|
+
}).catch(err => {
|
|
134
|
+
setErrMsg(err.message);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
insert(_el$5, createComponent(Show, {
|
|
140
|
+
get when() {
|
|
141
|
+
return errMsg();
|
|
142
|
+
},
|
|
143
|
+
get children() {
|
|
144
|
+
var _el$7 = _tmpl$4();
|
|
145
|
+
insert(_el$7, errMsg);
|
|
146
|
+
return _el$7;
|
|
147
|
+
}
|
|
148
|
+
}), null);
|
|
149
|
+
effect(() => (layout() === 'horizontal' && maxItemWidth ? `calc(100% - ${maxItemWidth() ?? 0}px)` : undefined) != null ? _el$5.style.setProperty("width", layout() === 'horizontal' && maxItemWidth ? `calc(100% - ${maxItemWidth() ?? 0}px)` : undefined) : _el$5.style.removeProperty("width"));
|
|
150
|
+
return _el$5;
|
|
151
|
+
})()];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
55
155
|
});
|
|
56
|
-
const getLabel = hidden => (() => {
|
|
57
|
-
const _el$ = _tmpl$2();
|
|
58
|
-
spread(_el$, mergeProps({
|
|
59
|
-
get ["class"]() {
|
|
60
|
-
return cs('ant-shrink-0 ant-h-32px ant-leading-32px not[:empty]:ant-pr-8px ant-text-right ant-[white-space:nowrap]', hidden && 'ant-absolute ant-opacity-0');
|
|
61
|
-
}
|
|
62
|
-
}, () => hidden ? {
|
|
63
|
-
ref: el => {
|
|
64
|
-
label = el;
|
|
65
|
-
}
|
|
66
|
-
} : {
|
|
67
|
-
style: {
|
|
68
|
-
width: `${maxItemWidth() ?? 0}px`
|
|
69
|
-
}
|
|
70
|
-
}), false, true);
|
|
71
|
-
insert(_el$, createComponent(Show, {
|
|
72
|
-
get when() {
|
|
73
|
-
return !isNil(props.required);
|
|
74
|
-
},
|
|
75
|
-
get children() {
|
|
76
|
-
return _tmpl$();
|
|
77
|
-
}
|
|
78
|
-
}), null);
|
|
79
|
-
insert(_el$, createComponent(Show, {
|
|
80
|
-
get when() {
|
|
81
|
-
return !isNil(props.label);
|
|
82
|
-
},
|
|
83
|
-
get children() {
|
|
84
|
-
const _el$3 = _tmpl$2();
|
|
85
|
-
insert(_el$3, () => props.label);
|
|
86
|
-
return _el$3;
|
|
87
|
-
}
|
|
88
|
-
}), null);
|
|
89
|
-
return _el$;
|
|
90
|
-
})();
|
|
91
|
-
return (() => {
|
|
92
|
-
const _el$4 = _tmpl$4(),
|
|
93
|
-
_el$5 = _el$4.firstChild;
|
|
94
|
-
insert(_el$4, () => getLabel(true), _el$5);
|
|
95
|
-
insert(_el$4, getLabel, _el$5);
|
|
96
|
-
insert(_el$5, createComponent(Dynamic, {
|
|
97
|
-
get component() {
|
|
98
|
-
return props.component;
|
|
99
|
-
},
|
|
100
|
-
get defaultValue() {
|
|
101
|
-
return props.initialValue ?? get(initialValues, props.name);
|
|
102
|
-
},
|
|
103
|
-
get status() {
|
|
104
|
-
return errMsg() ? 'error' : undefined;
|
|
105
|
-
},
|
|
106
|
-
onChange: value => {
|
|
107
|
-
if (!isNil(props.name)) formInstance.setFieldValue(props.name, value);
|
|
108
|
-
props.rules?.forEach(rule => {
|
|
109
|
-
rule.validate(value).then(() => {
|
|
110
|
-
setErrMsg('');
|
|
111
|
-
}).catch(err => {
|
|
112
|
-
setErrMsg(err.message);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}), null);
|
|
117
|
-
insert(_el$5, createComponent(Show, {
|
|
118
|
-
get when() {
|
|
119
|
-
return errMsg();
|
|
120
|
-
},
|
|
121
|
-
get children() {
|
|
122
|
-
const _el$6 = _tmpl$3();
|
|
123
|
-
insert(_el$6, errMsg);
|
|
124
|
-
return _el$6;
|
|
125
|
-
}
|
|
126
|
-
}), null);
|
|
127
|
-
effect(_p$ => {
|
|
128
|
-
const _v$ = cs(props.class, 'ant-flex ant-items-center ant-mb-16px'),
|
|
129
|
-
_v$2 = props.style;
|
|
130
|
-
_v$ !== _p$._v$ && className(_el$4, _p$._v$ = _v$);
|
|
131
|
-
_p$._v$2 = style(_el$4, _v$2, _p$._v$2);
|
|
132
|
-
return _p$;
|
|
133
|
-
}, {
|
|
134
|
-
_v$: undefined,
|
|
135
|
-
_v$2: undefined
|
|
136
|
-
});
|
|
137
|
-
return _el$4;
|
|
138
|
-
})();
|
|
139
156
|
};
|
|
140
157
|
|
|
141
158
|
export { FormItem as default };
|
package/es/Form/context.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type Setter, type Accessor } from 'solid-js';
|
|
2
|
-
import { type FormInstance } from './Form';
|
|
3
2
|
import { type Schema } from 'yup';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
setItemWidthDict
|
|
10
|
-
maxItemWidth
|
|
3
|
+
import { type FormProps, type FormInstance } from './Form';
|
|
4
|
+
declare const FormContext: import("solid-js").Context<{
|
|
5
|
+
formInstance?: FormInstance<{}> | undefined;
|
|
6
|
+
rulesDict?: Record<string, Schema<any, any, any, "">[]> | undefined;
|
|
7
|
+
setErrMsgDict?: Record<string, Setter<string>> | undefined;
|
|
8
|
+
setItemWidthDict?: Setter<Record<string, number>> | undefined;
|
|
9
|
+
maxItemWidth?: Accessor<number | undefined> | undefined;
|
|
10
|
+
layout: Accessor<FormProps['layout']>;
|
|
11
11
|
}>;
|
|
12
|
-
export default
|
|
12
|
+
export default FormContext;
|
package/es/Form/context.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Component } from 'solid-js';
|
|
2
|
+
import { type RootStyleProps, type StyleProps } from '../types';
|
|
3
|
+
export interface ImageProps extends RootStyleProps, StyleProps {
|
|
4
|
+
width?: string | number;
|
|
5
|
+
height?: string | number;
|
|
6
|
+
src?: string;
|
|
7
|
+
fallback?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const Image: Component<ImageProps>;
|
|
10
|
+
export default Image;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { spread, mergeProps, effect, className, style, template } from 'solid-js/web';
|
|
2
|
+
import cs from 'classnames';
|
|
3
|
+
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<div><img>`);
|
|
5
|
+
const Image = props => {
|
|
6
|
+
return (() => {
|
|
7
|
+
var _el$ = _tmpl$(),
|
|
8
|
+
_el$2 = _el$.firstChild;
|
|
9
|
+
spread(_el$2, mergeProps(props, {
|
|
10
|
+
get src() {
|
|
11
|
+
return props.src ? props.src : props.fallback;
|
|
12
|
+
},
|
|
13
|
+
"onError": e => {
|
|
14
|
+
if (props.fallback) {
|
|
15
|
+
e.currentTarget.src = props.fallback;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}), false, false);
|
|
19
|
+
effect(_p$ => {
|
|
20
|
+
var _v$ = cs(props.rootClass, 'inline-block'),
|
|
21
|
+
_v$2 = {
|
|
22
|
+
width: typeof props.width === 'string' ? props.width : undefined,
|
|
23
|
+
height: typeof props.height === 'string' ? props.height : undefined,
|
|
24
|
+
...props.rootStyle
|
|
25
|
+
};
|
|
26
|
+
_v$ !== _p$.e && className(_el$, _p$.e = _v$);
|
|
27
|
+
_p$.t = style(_el$, _v$2, _p$.t);
|
|
28
|
+
return _p$;
|
|
29
|
+
}, {
|
|
30
|
+
e: undefined,
|
|
31
|
+
t: undefined
|
|
32
|
+
});
|
|
33
|
+
return _el$;
|
|
34
|
+
})();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { Image as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type JSX, type Component, type Ref } from 'solid-js';
|
|
2
|
+
import { type RootStyleProps } from '../types';
|
|
3
|
+
export interface TextAreaProps extends RootStyleProps, Omit<JSX.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'> {
|
|
4
|
+
ref?: Ref<HTMLTextAreaElement>;
|
|
5
|
+
defaultValue?: string | null | undefined;
|
|
6
|
+
value?: string | null | undefined;
|
|
7
|
+
autoFocus?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 设置校验状态
|
|
10
|
+
*/
|
|
11
|
+
status?: 'error' | 'warning';
|
|
12
|
+
/**
|
|
13
|
+
* 设置尺寸
|
|
14
|
+
* 默认 'middle'
|
|
15
|
+
* 高度分别为 40px、32px 和 24px
|
|
16
|
+
*/
|
|
17
|
+
size?: 'small' | 'middle' | 'large';
|
|
18
|
+
onChange?: JSX.InputEventHandler<HTMLTextAreaElement, InputEvent>;
|
|
19
|
+
onPressEnter?: JSX.EventHandler<HTMLTextAreaElement, KeyboardEvent>;
|
|
20
|
+
onKeyDown?: JSX.EventHandler<HTMLTextAreaElement, KeyboardEvent>;
|
|
21
|
+
}
|
|
22
|
+
declare const TextArea: Component<TextAreaProps>;
|
|
23
|
+
export default TextArea;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createComponent, use, spread, mergeProps, template } from 'solid-js/web';
|
|
2
|
+
import { splitProps, onMount } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import Element from '../Element/index.js';
|
|
5
|
+
import createControllableValue from '../hooks/createControllableValue.js';
|
|
6
|
+
import useComponentSize from '../hooks/useComponentSize.js';
|
|
7
|
+
import { statusClassDict } from './index.js';
|
|
8
|
+
import useFocus from '../hooks/useFocus.js';
|
|
9
|
+
import { setRef } from '../utils/solid.js';
|
|
10
|
+
|
|
11
|
+
var _tmpl$ = /*#__PURE__*/template(`<textarea>`);
|
|
12
|
+
const TextArea = props => {
|
|
13
|
+
const size = useComponentSize(() => props.size);
|
|
14
|
+
const [_, inputProps] = splitProps(props, ['defaultValue', 'value', 'onChange', 'onPressEnter', 'onKeyDown', 'size', 'autoFocus', 'status']);
|
|
15
|
+
let inputRef;
|
|
16
|
+
const foucs = useFocus(() => inputRef);
|
|
17
|
+
onMount(() => {
|
|
18
|
+
if (props.autoFocus) {
|
|
19
|
+
inputRef?.focus();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const isControlled = () => Object.keys(props).includes('value');
|
|
23
|
+
const [value, setValue] = createControllableValue(props, {
|
|
24
|
+
trigger: null
|
|
25
|
+
});
|
|
26
|
+
return createComponent(Element, {
|
|
27
|
+
get ["class"]() {
|
|
28
|
+
return cs(props.rootClass, 'flex');
|
|
29
|
+
},
|
|
30
|
+
get style() {
|
|
31
|
+
return {
|
|
32
|
+
'--ant-input-padding': {
|
|
33
|
+
small: '0 7px',
|
|
34
|
+
middle: '4px 11px',
|
|
35
|
+
large: '7px 11px'
|
|
36
|
+
}[size()],
|
|
37
|
+
'--ant-input-font-size': {
|
|
38
|
+
small: 'var(--ant-font-size)',
|
|
39
|
+
middle: 'var(--ant-font-size)',
|
|
40
|
+
large: 'var(--ant-font-size-lg)'
|
|
41
|
+
}[size()],
|
|
42
|
+
...props.rootStyle
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
get children() {
|
|
46
|
+
var _el$ = _tmpl$();
|
|
47
|
+
use(el => {
|
|
48
|
+
setRef(props, el);
|
|
49
|
+
inputRef = el;
|
|
50
|
+
}, _el$);
|
|
51
|
+
spread(_el$, mergeProps(inputProps, {
|
|
52
|
+
get ["class"]() {
|
|
53
|
+
return cs('p-[--ant-input-padding] border-1px border-solid bg-[--ant-color-bg-container]', 'w-full h-full [font-size:var(--ant-input-font-size)] [outline:none] placeholder-text-[var(--ant-color-text-placeholder)]', props.disabled && 'color-[var(--ant-color-text-disabled)] cursor-not-allowed', {
|
|
54
|
+
small: 'rounded-[var(--ant-border-radius-sm)]',
|
|
55
|
+
middle: 'rounded-[var(--ant-border-radius)]',
|
|
56
|
+
large: 'rounded-[var(--ant-border-radius-lg)]'
|
|
57
|
+
}[size()], statusClassDict[props.status ?? 'default'](!!props.disabled, foucs()), props.class);
|
|
58
|
+
},
|
|
59
|
+
get value() {
|
|
60
|
+
return value() ?? '';
|
|
61
|
+
},
|
|
62
|
+
"onInput": e => {
|
|
63
|
+
setValue(e.target.value);
|
|
64
|
+
try {
|
|
65
|
+
props.onChange?.(e);
|
|
66
|
+
} finally {
|
|
67
|
+
if (isControlled() && e.target.value !== props.value) {
|
|
68
|
+
e.target.value = props.value ?? '';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"onKeyDown": e => {
|
|
73
|
+
if (e.key === 'Enter') {
|
|
74
|
+
props.onPressEnter?.(e);
|
|
75
|
+
}
|
|
76
|
+
props.onKeyDown?.(e);
|
|
77
|
+
}
|
|
78
|
+
}), false, false);
|
|
79
|
+
return _el$;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { TextArea as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { JSX, Component, JSXElement, Ref } from 'solid-js';
|
|
2
|
+
import TextArea from './TextArea';
|
|
3
|
+
import './index.scss';
|
|
4
|
+
import { type RootStyleProps } from '../types';
|
|
5
|
+
type CommonInputProps = RootStyleProps & Omit<JSX.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'prefix' | 'suffix'> & {
|
|
6
|
+
ref?: Ref<HTMLInputElement>;
|
|
7
|
+
defaultValue?: string | null | undefined;
|
|
8
|
+
value?: string | null | undefined;
|
|
9
|
+
addonBefore?: JSXElement;
|
|
10
|
+
addonAfter?: JSXElement;
|
|
11
|
+
prefix?: JSXElement;
|
|
12
|
+
suffix?: JSXElement;
|
|
13
|
+
/**
|
|
14
|
+
* 仅供 InputNumber 使用
|
|
15
|
+
*/
|
|
16
|
+
actions?: JSXElement;
|
|
17
|
+
/**
|
|
18
|
+
* 设置校验状态
|
|
19
|
+
*/
|
|
20
|
+
status?: 'error' | 'warning';
|
|
21
|
+
/**
|
|
22
|
+
* 设置尺寸
|
|
23
|
+
* 默认 'middle'
|
|
24
|
+
* 高度分别为 40px、32px 和 24px
|
|
25
|
+
*/
|
|
26
|
+
size?: 'small' | 'middle' | 'large';
|
|
27
|
+
autoFocus?: boolean;
|
|
28
|
+
allowClear?: boolean;
|
|
29
|
+
onChange?: JSX.InputEventHandler<HTMLInputElement, InputEvent>;
|
|
30
|
+
onPressEnter?: JSX.EventHandler<HTMLInputElement, KeyboardEvent>;
|
|
31
|
+
onKeyDown?: JSX.EventHandler<HTMLInputElement, KeyboardEvent>;
|
|
32
|
+
};
|
|
33
|
+
export declare const statusClassDict: {
|
|
34
|
+
default: (disabled: boolean, foucs: boolean) => "border-[--ant-color-border]" | "border-[--ant-color-primary] [box-shadow:0_0_0_2px_rgba(5,145,255,0.1)]" | "border-[--ant-color-border] hover:border-[--ant-color-primary]";
|
|
35
|
+
error: (disabled: boolean, foucs: boolean) => "border-[--ant-color-error]" | "border-[--ant-color-error] [box-shadow:0_0_0_2px_rgba(255,38,5,.06)]" | "border-[--ant-color-error] hover:border-[--ant-color-error-border-hover]";
|
|
36
|
+
warning: (disabled: boolean, foucs: boolean) => "border-[--ant-color-warning]" | "border-[--ant-color-warning] [box-shadow:0_0_0_2px_rgba(255,215,5,.1)]" | "border-[--ant-color-warning] hover:border-[--ant-color-warning-border-hover]";
|
|
37
|
+
};
|
|
38
|
+
export declare function CommonInput(props: CommonInputProps): JSX.Element;
|
|
39
|
+
export type InputProps = Omit<CommonInputProps, 'actions' | 'textarea'>;
|
|
40
|
+
declare const Input: Component<InputProps> & {
|
|
41
|
+
TextArea: typeof TextArea;
|
|
42
|
+
};
|
|
43
|
+
export type { TextAreaProps } from './TextArea';
|
|
44
|
+
export default Input;
|