antd-solid 0.0.21 → 0.0.23
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 +1 -1
- package/dist/index.esm.js +2604 -1107
- package/dist/index.umd.js +1 -1
- package/es/Button/index.d.ts +5 -2
- package/es/Button/index.js +21 -8
- package/es/Checkbox/Group.js +2 -2
- package/es/Checkbox/index.js +26 -13
- package/es/CodeInput/index.js +3 -0
- package/es/Collapse/Item.js +50 -8
- package/es/Collapse/index.js +5 -3
- package/es/ColorPicker/ColorPickerInput.js +225 -210
- package/es/ColorPicker/ColorPickerSelect.js +61 -4
- package/es/ColorPicker/ColorPickerSlider.js +100 -67
- package/es/ColorPicker/index.js +66 -17
- package/es/ContextMenu/index.js +5 -1
- package/es/Cursor/index.d.ts +13 -2
- package/es/Cursor/index.js +59 -16
- package/es/Divider/index.js +12 -3
- package/es/Drawer/index.js +89 -43
- package/es/Dropdown/index.js +4 -2
- package/es/Element/index.js +2 -6
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +12 -4
- package/es/Empty/assets/EmptySvg.js +3 -3
- package/es/Empty/assets/SimpleEmptySvg.js +3 -3
- package/es/Empty/index.js +12 -4
- package/es/Form/FormItem.js +76 -47
- package/es/Fragment/index.js +3 -1
- package/es/Image/index.js +31 -11
- package/es/Input/TextArea.js +31 -5
- package/es/Input/index.d.ts +5 -0
- package/es/Input/index.js +123 -46
- package/es/InputNumber/index.js +11 -4
- package/es/Menu/InternalMenu.js +96 -38
- package/es/Message/Message.js +11 -7
- package/es/Modal/index.js +107 -55
- package/es/Modal/useModal.js +14 -5
- package/es/Modal/warning.js +14 -5
- package/es/Popconfirm/index.js +36 -24
- package/es/Popover/index.js +20 -11
- package/es/Progress/Circle.js +63 -14
- package/es/Progress/index.js +38 -14
- package/es/Radio/Button.js +20 -4
- package/es/Radio/index.js +35 -5
- package/es/RangeInput/index.js +80 -24
- package/es/Result/index.js +27 -6
- package/es/Segmented/index.js +33 -13
- package/es/Select/index.d.ts +1 -1
- package/es/Select/index.js +39 -7
- package/es/SelectInput/index.d.ts +2 -1
- package/es/SelectInput/index.js +119 -51
- package/es/Slider/index.js +84 -11
- package/es/Space/index.js +2 -2
- package/es/Spin/index.js +26 -14
- package/es/Switch/index.js +6 -4
- package/es/Table/index.js +40 -18
- package/es/Tabs/index.js +195 -91
- package/es/Timeline/index.d.ts +1 -2
- package/es/Timeline/index.js +14 -4
- package/es/Tooltip/index.d.ts +1 -1
- package/es/Tooltip/index.js +40 -20
- package/es/Transformer/index.js +123 -59
- package/es/Tree/SingleLevelTree.js +191 -30
- package/es/TreeFor/index.js +3 -3
- package/es/TreeSelect/index.js +6 -4
- package/es/Upload/index.js +38 -4
- package/es/assets/svg/ColorPickUp.js +19 -6
- package/es/assets/svg/Crosshair.js +45 -6
- package/es/assets/svg/Resize.js +19 -6
- package/es/assets/svg/Rotate.js +14 -13
- package/es/assets/svg/RotateArrow.js +15 -20
- package/es/hooks/useClickAway.js +4 -6
- package/es/index.d.ts +1 -1
- package/es/utils/setupGlobalDrag.js +13 -4
- package/package.json +12 -14
- package/es/utils/DOMRect.d.ts +0 -22
- package/es/utils/DOMRect.js +0 -41
package/es/Drawer/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, Dynamic,
|
|
1
|
+
import { delegateEvents, createComponent, Dynamic, effect, className, insert, Portal, template } from 'solid-js/web';
|
|
2
2
|
import { mergeProps, createEffect, onCleanup, createMemo, Show } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import { Transition } from 'solid-transition-group';
|
|
@@ -10,11 +10,11 @@ import DelayShow from '../DelayShow/index.js';
|
|
|
10
10
|
import createControllableValue from '../hooks/createControllableValue.js';
|
|
11
11
|
import { unwrapStringOrJSXElement } from '../utils/solid.js';
|
|
12
12
|
|
|
13
|
-
var _tmpl$ =
|
|
14
|
-
_tmpl$2 =
|
|
15
|
-
_tmpl$3 =
|
|
16
|
-
_tmpl$4 =
|
|
17
|
-
_tmpl$5 =
|
|
13
|
+
var _tmpl$ = /*#__PURE__*/template(`<div aria-label=mask>`),
|
|
14
|
+
_tmpl$2 = /*#__PURE__*/template(`<span class=i-ant-design:close-outlined>`),
|
|
15
|
+
_tmpl$3 = /*#__PURE__*/template(`<div class="w-full text-[var(--ant-color-text)] text-size-[var(--ant-font-size-lg)] [font-weight:var(--ant-font-weight-strong)] leading-[var(--ant-line-height-lg)]">`),
|
|
16
|
+
_tmpl$4 = /*#__PURE__*/template(`<div class=shrink-0>`),
|
|
17
|
+
_tmpl$5 = /*#__PURE__*/template(`<div><div class="px-[var(--ant-padding-lg)] py-[var(--ant-padding)] flex items-center [border-bottom:var(--ant-line-width)_solid_var(--ant-color-split)] empty:hidden"></div><div class="p-[--ant-drawer-body-padding] overflow-auto">`);
|
|
18
18
|
const Drawer = _props => {
|
|
19
19
|
const props = mergeProps({
|
|
20
20
|
size: '378px',
|
|
@@ -86,8 +86,17 @@ const Drawer = _props => {
|
|
|
86
86
|
},
|
|
87
87
|
get children() {
|
|
88
88
|
return createComponent(Element, {
|
|
89
|
+
ref(r$) {
|
|
90
|
+
var _ref$ = drawerRef;
|
|
91
|
+
typeof _ref$ === "function" ? _ref$(r$) : drawerRef = r$;
|
|
92
|
+
},
|
|
89
93
|
get ["class"]() {
|
|
90
|
-
return cs(props.class, '[font-size:var(--ant-font-size)] text-[var(--ant-color-text)] leading-[var(--ant-line-height)]', 'inset-0 z-1000',
|
|
94
|
+
return cs(props.class, '[font-size:var(--ant-font-size)] text-[var(--ant-color-text)] leading-[var(--ant-line-height)]', 'inset-0 z-1000', !props.mask && {
|
|
95
|
+
left: '!right-auto',
|
|
96
|
+
right: '!left-auto',
|
|
97
|
+
top: '!bottom-auto',
|
|
98
|
+
bottom: '!top-auto'
|
|
99
|
+
}[props.placement], isBody() ? 'fixed' : 'absolute');
|
|
91
100
|
},
|
|
92
101
|
get style() {
|
|
93
102
|
return {
|
|
@@ -101,45 +110,81 @@ const Drawer = _props => {
|
|
|
101
110
|
return props.mask;
|
|
102
111
|
},
|
|
103
112
|
get children() {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
left: 'ant-drawer-content-left',
|
|
108
|
-
right: 'ant-drawer-content-right',
|
|
109
|
-
top: 'ant-drawer-content-top',
|
|
110
|
-
bottom: 'ant-drawer-content-bottom'
|
|
111
|
-
}[props.placement], 'absolute bg-[--ant-color-bg-container-secondary] grid [grid-template-rows:auto_1fr]'), true), false), "width:" + (direction() === 'horizontal' ? escape(props.size, true) : escape(undefined, true)) + (";height:" + (direction() === 'vertical' ? escape(props.size, true) : escape(undefined, true))), escape(createComponent(Show, {
|
|
112
|
-
get when() {
|
|
113
|
-
return props.closeIcon;
|
|
114
|
-
},
|
|
115
|
-
get children() {
|
|
116
|
-
return createComponent(Button, {
|
|
117
|
-
type: "text",
|
|
118
|
-
size: "small",
|
|
119
|
-
"class": "shrink-0 mr-[var(--ant-margin-sm)] text-size-[var(--ant-font-size-lg)] h-[var(--ant-font-size-lg)] leading-[var(--ant-font-size-lg)] hover:!bg-transparent !text-[var(--ant-color-icon)] hover:!text-[var(--ant-color-icon-hover)] !p-0",
|
|
120
|
-
onClick: () => {
|
|
113
|
+
var _el$ = _tmpl$();
|
|
114
|
+
_el$.$$click = () => {
|
|
115
|
+
if (props.maskClosable) {
|
|
121
116
|
props.onClose?.();
|
|
122
|
-
},
|
|
123
|
-
get children() {
|
|
124
|
-
return ssr(_tmpl$2, ssrHydrationKey());
|
|
125
117
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
get when() {
|
|
130
|
-
return title();
|
|
131
|
-
},
|
|
132
|
-
get children() {
|
|
133
|
-
return ssr(_tmpl$3, ssrHydrationKey(), escape(title()));
|
|
134
|
-
}
|
|
135
|
-
})), escape(createComponent(Show, {
|
|
136
|
-
get when() {
|
|
137
|
-
return extra();
|
|
138
|
-
},
|
|
139
|
-
get children() {
|
|
140
|
-
return ssr(_tmpl$4, ssrHydrationKey(), escape(extra()));
|
|
118
|
+
};
|
|
119
|
+
effect(() => className(_el$, cs('ant-drawer-mask', 'absolute inset-0 bg-[--ant-color-bg-mask]')));
|
|
120
|
+
return _el$;
|
|
141
121
|
}
|
|
142
|
-
})
|
|
122
|
+
}), (() => {
|
|
123
|
+
var _el$2 = _tmpl$5(),
|
|
124
|
+
_el$3 = _el$2.firstChild,
|
|
125
|
+
_el$7 = _el$3.nextSibling;
|
|
126
|
+
_el$2.$$click = e => {
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
};
|
|
129
|
+
insert(_el$3, createComponent(Show, {
|
|
130
|
+
get when() {
|
|
131
|
+
return props.closeIcon;
|
|
132
|
+
},
|
|
133
|
+
get children() {
|
|
134
|
+
return createComponent(Button, {
|
|
135
|
+
type: "text",
|
|
136
|
+
size: "small",
|
|
137
|
+
"class": "shrink-0 mr-[var(--ant-margin-sm)] text-size-[var(--ant-font-size-lg)] h-[var(--ant-font-size-lg)] leading-[var(--ant-font-size-lg)] hover:!bg-transparent !text-[var(--ant-color-icon)] hover:!text-[var(--ant-color-icon-hover)] !p-0",
|
|
138
|
+
onClick: () => {
|
|
139
|
+
props.onClose?.();
|
|
140
|
+
},
|
|
141
|
+
get children() {
|
|
142
|
+
return _tmpl$2();
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}), null);
|
|
147
|
+
insert(_el$3, createComponent(Show, {
|
|
148
|
+
get when() {
|
|
149
|
+
return title();
|
|
150
|
+
},
|
|
151
|
+
get children() {
|
|
152
|
+
var _el$5 = _tmpl$3();
|
|
153
|
+
insert(_el$5, title);
|
|
154
|
+
return _el$5;
|
|
155
|
+
}
|
|
156
|
+
}), null);
|
|
157
|
+
insert(_el$3, createComponent(Show, {
|
|
158
|
+
get when() {
|
|
159
|
+
return extra();
|
|
160
|
+
},
|
|
161
|
+
get children() {
|
|
162
|
+
var _el$6 = _tmpl$4();
|
|
163
|
+
insert(_el$6, extra);
|
|
164
|
+
return _el$6;
|
|
165
|
+
}
|
|
166
|
+
}), null);
|
|
167
|
+
insert(_el$7, () => props.children);
|
|
168
|
+
effect(_p$ => {
|
|
169
|
+
var _v$ = cs('ant-drawer-content', {
|
|
170
|
+
left: 'ant-drawer-content-left',
|
|
171
|
+
right: 'ant-drawer-content-right',
|
|
172
|
+
top: 'ant-drawer-content-top',
|
|
173
|
+
bottom: 'ant-drawer-content-bottom'
|
|
174
|
+
}[props.placement], 'absolute bg-[--ant-color-bg-container-secondary] grid [grid-template-rows:auto_1fr]'),
|
|
175
|
+
_v$2 = direction() === 'horizontal' ? props.size : undefined,
|
|
176
|
+
_v$3 = direction() === 'vertical' ? props.size : undefined;
|
|
177
|
+
_v$ !== _p$.e && className(_el$2, _p$.e = _v$);
|
|
178
|
+
_v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$2.style.setProperty("width", _v$2) : _el$2.style.removeProperty("width"));
|
|
179
|
+
_v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$2.style.setProperty("height", _v$3) : _el$2.style.removeProperty("height"));
|
|
180
|
+
return _p$;
|
|
181
|
+
}, {
|
|
182
|
+
e: undefined,
|
|
183
|
+
t: undefined,
|
|
184
|
+
a: undefined
|
|
185
|
+
});
|
|
186
|
+
return _el$2;
|
|
187
|
+
})()];
|
|
143
188
|
}
|
|
144
189
|
});
|
|
145
190
|
}
|
|
@@ -168,5 +213,6 @@ const Drawer = _props => {
|
|
|
168
213
|
}
|
|
169
214
|
});
|
|
170
215
|
};
|
|
216
|
+
delegateEvents(["click"]);
|
|
171
217
|
|
|
172
218
|
export { Drawer as default };
|
package/es/Dropdown/index.js
CHANGED
package/es/Element/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent, Dynamic, mergeProps as mergeProps$1 } from 'solid-js/web';
|
|
2
|
-
import { mergeProps, useContext,
|
|
2
|
+
import { mergeProps, useContext, onMount } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import ConfigProviderContext from '../ConfigProvider/context.js';
|
|
5
5
|
|
|
@@ -12,10 +12,8 @@ function Element(_props) {
|
|
|
12
12
|
cssVariablesClass,
|
|
13
13
|
cssVariables
|
|
14
14
|
} = useContext(ConfigProviderContext);
|
|
15
|
-
const [_cssVariablesClass, setCssVariablesClass] = createSignal('');
|
|
16
15
|
onMount(() => {
|
|
17
16
|
let styleTag = document.head.querySelector(`[data-token-hash=${cssVariablesClass}]`);
|
|
18
|
-
setCssVariablesClass(cssVariablesClass);
|
|
19
17
|
if (styleTag) return;
|
|
20
18
|
styleTag = document.createElement('style');
|
|
21
19
|
styleTag.setAttribute('type', 'text/css');
|
|
@@ -36,9 +34,7 @@ function Element(_props) {
|
|
|
36
34
|
}
|
|
37
35
|
}, props, {
|
|
38
36
|
get ["class"]() {
|
|
39
|
-
return cs(
|
|
40
|
-
// ssr 水合时,如果直接使用 cssVariablesClass,不会自动更新,导致在浏览器端使用的还是服务器端的 cssVariablesClass 值
|
|
41
|
-
props.class);
|
|
37
|
+
return cs(cssVariablesClass, props.class);
|
|
42
38
|
}
|
|
43
39
|
}));
|
|
44
40
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { createComponent, insert, template } from 'solid-js/web';
|
|
2
2
|
import cs from 'classnames';
|
|
3
3
|
import EmptySvg from './assets/SimpleEmptySvg.js';
|
|
4
4
|
import Element from '../Element/index.js';
|
|
5
5
|
|
|
6
|
-
var _tmpl$ =
|
|
7
|
-
_tmpl$2 =
|
|
6
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class="mb-[var(--ant-margin-xs)] flex justify-center">`),
|
|
7
|
+
_tmpl$2 = /*#__PURE__*/template(`<div class="text-[var(--ant-color-text-description)] text-center">`);
|
|
8
8
|
const PRESENTED_IMAGE_SIMPLE = props => {
|
|
9
9
|
return createComponent(Element, {
|
|
10
10
|
get ["class"]() {
|
|
@@ -14,7 +14,15 @@ const PRESENTED_IMAGE_SIMPLE = props => {
|
|
|
14
14
|
return props.style;
|
|
15
15
|
},
|
|
16
16
|
get children() {
|
|
17
|
-
return [
|
|
17
|
+
return [(() => {
|
|
18
|
+
var _el$ = _tmpl$();
|
|
19
|
+
insert(_el$, createComponent(EmptySvg, {}));
|
|
20
|
+
return _el$;
|
|
21
|
+
})(), (() => {
|
|
22
|
+
var _el$2 = _tmpl$2();
|
|
23
|
+
insert(_el$2, () => props.description ?? '暂无数据');
|
|
24
|
+
return _el$2;
|
|
25
|
+
})()];
|
|
18
26
|
}
|
|
19
27
|
});
|
|
20
28
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { template } from 'solid-js/web';
|
|
2
2
|
|
|
3
|
-
var _tmpl$ =
|
|
4
|
-
const EmptySvg = () =>
|
|
3
|
+
var _tmpl$ = /*#__PURE__*/template(`<svg width=184 height=100 viewBox="0 0 184 152"xmlns=http://www.w3.org/2000/svg><g fill=none fill-rule=evenodd><g transform="translate(24 31.67)"><ellipse fill-opacity=.8 fill=#F5F5F7 cx=67.797 cy=106.89 rx=67.797 ry=12.668></ellipse><path d="M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z"fill=#AEB8C2></path><path d="M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z"fill=url(#linearGradient-1) transform=translate(13.56)></path><path d="M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z"fill=#F5F5F7></path><path d="M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z"fill=#DCE0E6></path></g><path d="M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z"fill=#DCE0E6></path><g transform="translate(149.65 15.383)"fill=#FFF><ellipse cx=20.654 cy=3.167 rx=2.849 ry=2.815></ellipse><path d="M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z">`);
|
|
4
|
+
const EmptySvg = () => _tmpl$();
|
|
5
5
|
|
|
6
6
|
export { EmptySvg as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { template } from 'solid-js/web';
|
|
2
2
|
|
|
3
|
-
var _tmpl$ =
|
|
4
|
-
const EmptySvg = () =>
|
|
3
|
+
var _tmpl$ = /*#__PURE__*/template(`<svg width=64 height=41 viewBox="0 0 64 41"xmlns=http://www.w3.org/2000/svg><g transform="translate(0 1)"fill=none fill-rule=evenodd><ellipse fill=#f5f5f5 cx=32 cy=33 rx=32 ry=7></ellipse><g fill-rule=nonzero stroke=#d9d9d9><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z"fill=#fafafa>`);
|
|
4
|
+
const EmptySvg = () => _tmpl$();
|
|
5
5
|
|
|
6
6
|
export { EmptySvg as default };
|
package/es/Empty/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { createComponent, insert, template } from 'solid-js/web';
|
|
2
2
|
import PRESENTED_IMAGE_SIMPLE from './PRESENTED_IMAGE_SIMPLE.js';
|
|
3
3
|
import EmptySvg from './assets/EmptySvg.js';
|
|
4
4
|
import Element from '../Element/index.js';
|
|
5
5
|
|
|
6
|
-
var _tmpl$ =
|
|
7
|
-
_tmpl$2 =
|
|
6
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class="mb-[var(--ant-margin-xs)] flex justify-center">`),
|
|
7
|
+
_tmpl$2 = /*#__PURE__*/template(`<div class="text-[var(--ant-color-text)] text-center">`);
|
|
8
8
|
const Empty = props => {
|
|
9
9
|
return createComponent(Element, {
|
|
10
10
|
get ["class"]() {
|
|
@@ -14,7 +14,15 @@ const Empty = props => {
|
|
|
14
14
|
return props.style;
|
|
15
15
|
},
|
|
16
16
|
get children() {
|
|
17
|
-
return [
|
|
17
|
+
return [(() => {
|
|
18
|
+
var _el$ = _tmpl$();
|
|
19
|
+
insert(_el$, createComponent(EmptySvg, {}));
|
|
20
|
+
return _el$;
|
|
21
|
+
})(), (() => {
|
|
22
|
+
var _el$2 = _tmpl$2();
|
|
23
|
+
insert(_el$2, () => props.description ?? '暂无数据');
|
|
24
|
+
return _el$2;
|
|
25
|
+
})()];
|
|
18
26
|
}
|
|
19
27
|
});
|
|
20
28
|
};
|
package/es/Form/FormItem.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { createComponent, use, insert, effect, className, Dynamic, memo, template } from 'solid-js/web';
|
|
2
2
|
import { useContext, createSignal, createEffect, onCleanup, on, Show } from 'solid-js';
|
|
3
3
|
import { set, unset, isNil } from 'lodash-es';
|
|
4
4
|
import { nanoid } from 'nanoid';
|
|
@@ -6,11 +6,11 @@ import cs from 'classnames';
|
|
|
6
6
|
import FormContext from './context.js';
|
|
7
7
|
import Element from '../Element/index.js';
|
|
8
8
|
|
|
9
|
-
var _tmpl$ =
|
|
10
|
-
_tmpl$2 =
|
|
11
|
-
_tmpl$3 =
|
|
12
|
-
_tmpl$4 =
|
|
13
|
-
_tmpl$5 =
|
|
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>`);
|
|
14
14
|
const FormItem = props => {
|
|
15
15
|
const {
|
|
16
16
|
formInstance,
|
|
@@ -69,48 +69,77 @@ const FormItem = props => {
|
|
|
69
69
|
return props.style;
|
|
70
70
|
},
|
|
71
71
|
get children() {
|
|
72
|
-
return [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
72
|
+
return [(() => {
|
|
73
|
+
var _el$ = _tmpl$3(),
|
|
74
|
+
_el$2 = _el$.firstChild;
|
|
75
|
+
var _ref$ = label;
|
|
76
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : label = _el$2;
|
|
77
|
+
insert(_el$2, createComponent(Show, {
|
|
78
|
+
get when() {
|
|
79
|
+
return !isNil(props.label);
|
|
80
|
+
},
|
|
81
|
+
get children() {
|
|
82
|
+
var _el$3 = _tmpl$();
|
|
83
|
+
insert(_el$3, () => props.label);
|
|
84
|
+
return _el$3;
|
|
85
|
+
}
|
|
86
|
+
}), null);
|
|
87
|
+
insert(_el$2, createComponent(Show, {
|
|
88
|
+
get when() {
|
|
89
|
+
return !isNil(props.required);
|
|
90
|
+
},
|
|
91
|
+
get children() {
|
|
92
|
+
return _tmpl$2();
|
|
93
|
+
}
|
|
94
|
+
}), null);
|
|
95
|
+
effect(_p$ => {
|
|
96
|
+
var _v$ = layout() === 'horizontal' && maxItemWidth ? `${maxItemWidth() ?? 0}px` : undefined,
|
|
97
|
+
_v$2 = cs('shrink-0 leading-32px not[:empty]:h-32px not[:empty]:pr-8px text-right [white-space:nowrap]');
|
|
98
|
+
_v$ !== _p$.e && ((_p$.e = _v$) != null ? _el$.style.setProperty("width", _v$) : _el$.style.removeProperty("width"));
|
|
99
|
+
_v$2 !== _p$.t && className(_el$2, _p$.t = _v$2);
|
|
100
|
+
return _p$;
|
|
101
|
+
}, {
|
|
102
|
+
e: undefined,
|
|
103
|
+
t: undefined
|
|
104
|
+
});
|
|
105
|
+
return _el$;
|
|
106
|
+
})(), (() => {
|
|
107
|
+
var _el$5 = _tmpl$5(),
|
|
108
|
+
_el$6 = _el$5.firstChild;
|
|
109
|
+
insert(_el$6, createComponent(Dynamic, {
|
|
110
|
+
get component() {
|
|
111
|
+
return props.component;
|
|
112
|
+
},
|
|
113
|
+
get value() {
|
|
114
|
+
return memo(() => !!props.name)() ? formInstance?.getFieldValue(props.name) : undefined;
|
|
115
|
+
},
|
|
116
|
+
get status() {
|
|
117
|
+
return errMsg() ? 'error' : undefined;
|
|
118
|
+
},
|
|
119
|
+
onChange: value => {
|
|
120
|
+
if (!isNil(props.name)) formInstance?.setFieldValue(props.name, value);
|
|
121
|
+
props.rules?.forEach(rule => {
|
|
122
|
+
rule.validate(value).then(() => {
|
|
123
|
+
setErrMsg('');
|
|
124
|
+
}).catch(err => {
|
|
125
|
+
setErrMsg(err.message);
|
|
126
|
+
});
|
|
103
127
|
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
insert(_el$5, createComponent(Show, {
|
|
131
|
+
get when() {
|
|
132
|
+
return errMsg();
|
|
133
|
+
},
|
|
134
|
+
get children() {
|
|
135
|
+
var _el$7 = _tmpl$4();
|
|
136
|
+
insert(_el$7, errMsg);
|
|
137
|
+
return _el$7;
|
|
138
|
+
}
|
|
139
|
+
}), null);
|
|
140
|
+
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"));
|
|
141
|
+
return _el$5;
|
|
142
|
+
})()];
|
|
114
143
|
}
|
|
115
144
|
});
|
|
116
145
|
}
|
package/es/Fragment/index.js
CHANGED
package/es/Image/index.js
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spread, mergeProps, effect, className, style, template } from 'solid-js/web';
|
|
2
2
|
import cs from 'classnames';
|
|
3
3
|
|
|
4
|
-
var _tmpl$ =
|
|
4
|
+
var _tmpl$ = /*#__PURE__*/template(`<div><img>`);
|
|
5
5
|
const Image = props => {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
})();
|
|
15
35
|
};
|
|
16
36
|
|
|
17
37
|
export { Image as default };
|
package/es/Input/TextArea.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { createComponent, use, spread, mergeProps, template } from 'solid-js/web';
|
|
2
2
|
import { splitProps, onMount } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import Element from '../Element/index.js';
|
|
@@ -6,16 +6,20 @@ import createControllableValue from '../hooks/createControllableValue.js';
|
|
|
6
6
|
import useComponentSize from '../hooks/useComponentSize.js';
|
|
7
7
|
import { statusClassDict } from './index.js';
|
|
8
8
|
import useFocus from '../hooks/useFocus.js';
|
|
9
|
-
import '
|
|
9
|
+
import { setRef } from '../utils/solid.js';
|
|
10
10
|
|
|
11
|
+
var _tmpl$ = /*#__PURE__*/template(`<textarea>`);
|
|
11
12
|
const TextArea = props => {
|
|
12
13
|
const size = useComponentSize(() => props.size);
|
|
13
14
|
const [_, inputProps] = splitProps(props, ['defaultValue', 'value', 'onChange', 'onPressEnter', 'onKeyDown', 'size', 'autoFocus', 'status']);
|
|
14
15
|
let inputRef;
|
|
15
16
|
const foucs = useFocus(() => inputRef);
|
|
16
17
|
onMount(() => {
|
|
17
|
-
if (props.autoFocus)
|
|
18
|
+
if (props.autoFocus) {
|
|
19
|
+
inputRef?.focus();
|
|
20
|
+
}
|
|
18
21
|
});
|
|
22
|
+
const isControlled = () => Object.keys(props).includes('value');
|
|
19
23
|
const [value, setValue] = createControllableValue(props, {
|
|
20
24
|
trigger: null
|
|
21
25
|
});
|
|
@@ -39,7 +43,12 @@ const TextArea = props => {
|
|
|
39
43
|
};
|
|
40
44
|
},
|
|
41
45
|
get children() {
|
|
42
|
-
|
|
46
|
+
var _el$ = _tmpl$();
|
|
47
|
+
use(el => {
|
|
48
|
+
setRef(props, el);
|
|
49
|
+
inputRef = el;
|
|
50
|
+
}, _el$);
|
|
51
|
+
spread(_el$, mergeProps(inputProps, {
|
|
43
52
|
get ["class"]() {
|
|
44
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', {
|
|
45
54
|
small: 'rounded-[var(--ant-border-radius-sm)]',
|
|
@@ -49,8 +58,25 @@ const TextArea = props => {
|
|
|
49
58
|
},
|
|
50
59
|
get value() {
|
|
51
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);
|
|
52
77
|
}
|
|
53
|
-
}),
|
|
78
|
+
}), false, false);
|
|
79
|
+
return _el$;
|
|
54
80
|
}
|
|
55
81
|
});
|
|
56
82
|
};
|
package/es/Input/index.d.ts
CHANGED
|
@@ -7,9 +7,13 @@ type CommonInputProps = RootStyleProps & Omit<JSX.InputHTMLAttributes<HTMLInputE
|
|
|
7
7
|
defaultValue?: string | null | undefined;
|
|
8
8
|
value?: string | null | undefined;
|
|
9
9
|
addonBefore?: JSXElement;
|
|
10
|
+
addonBeforeHTMLAttributes?: JSX.HTMLAttributes<HTMLDivElement>;
|
|
10
11
|
addonAfter?: JSXElement;
|
|
12
|
+
addonAfterHTMLAttributes?: JSX.HTMLAttributes<HTMLDivElement>;
|
|
11
13
|
prefix?: JSXElement;
|
|
14
|
+
prefixHTMLAttributes?: JSX.HTMLAttributes<HTMLDivElement>;
|
|
12
15
|
suffix?: JSXElement;
|
|
16
|
+
suffixHTMLAttributes?: JSX.HTMLAttributes<HTMLDivElement>;
|
|
13
17
|
/**
|
|
14
18
|
* 仅供 InputNumber 使用
|
|
15
19
|
*/
|
|
@@ -29,6 +33,7 @@ type CommonInputProps = RootStyleProps & Omit<JSX.InputHTMLAttributes<HTMLInputE
|
|
|
29
33
|
onChange?: JSX.InputEventHandler<HTMLInputElement, InputEvent>;
|
|
30
34
|
onPressEnter?: JSX.EventHandler<HTMLInputElement, KeyboardEvent>;
|
|
31
35
|
onKeyDown?: JSX.EventHandler<HTMLInputElement, KeyboardEvent>;
|
|
36
|
+
affixWrapperHTMLAttributes?: JSX.HTMLAttributes<HTMLDivElement>;
|
|
32
37
|
};
|
|
33
38
|
export declare const statusClassDict: {
|
|
34
39
|
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]";
|