antd-solid 0.0.20 → 0.0.22

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.
Files changed (66) hide show
  1. package/css/index.css +1 -1
  2. package/dist/index.esm.js +2508 -1078
  3. package/dist/index.umd.js +1 -1
  4. package/es/Button/index.js +25 -7
  5. package/es/Checkbox/Group.js +2 -2
  6. package/es/Checkbox/index.js +26 -13
  7. package/es/CodeInput/index.js +3 -0
  8. package/es/Collapse/Item.js +50 -8
  9. package/es/Collapse/index.js +5 -3
  10. package/es/ColorPicker/ColorPickerInput.js +224 -210
  11. package/es/ColorPicker/ColorPickerSelect.js +61 -4
  12. package/es/ColorPicker/ColorPickerSlider.js +100 -67
  13. package/es/ColorPicker/index.js +62 -16
  14. package/es/ContextMenu/index.js +5 -1
  15. package/es/Cursor/index.js +15 -3
  16. package/es/Divider/index.js +12 -3
  17. package/es/Drawer/index.js +83 -42
  18. package/es/Element/index.js +2 -6
  19. package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +12 -4
  20. package/es/Empty/assets/EmptySvg.js +3 -3
  21. package/es/Empty/assets/SimpleEmptySvg.js +3 -3
  22. package/es/Empty/index.js +12 -4
  23. package/es/Form/FormItem.js +76 -47
  24. package/es/Fragment/index.js +3 -1
  25. package/es/Image/index.js +31 -11
  26. package/es/Input/TextArea.js +31 -5
  27. package/es/Input/index.js +103 -46
  28. package/es/InputNumber/index.js +11 -4
  29. package/es/Menu/InternalMenu.js +93 -37
  30. package/es/Message/Message.js +11 -7
  31. package/es/Modal/index.js +107 -55
  32. package/es/Modal/useModal.js +14 -5
  33. package/es/Modal/warning.js +14 -5
  34. package/es/Popconfirm/index.js +36 -24
  35. package/es/Popover/index.js +20 -11
  36. package/es/Progress/Circle.js +63 -14
  37. package/es/Progress/index.js +38 -14
  38. package/es/Radio/Button.js +20 -4
  39. package/es/Radio/index.js +35 -5
  40. package/es/RangeInput/index.js +76 -22
  41. package/es/Result/index.js +27 -6
  42. package/es/Segmented/index.js +33 -13
  43. package/es/Select/index.js +35 -6
  44. package/es/SelectInput/index.js +112 -48
  45. package/es/Slider/index.js +84 -11
  46. package/es/Space/index.js +2 -2
  47. package/es/Spin/index.js +26 -14
  48. package/es/Switch/index.js +6 -4
  49. package/es/Table/index.js +40 -18
  50. package/es/Tabs/index.js +195 -91
  51. package/es/Timeline/index.js +14 -4
  52. package/es/Tooltip/index.js +48 -20
  53. package/es/Transformer/index.js +123 -59
  54. package/es/Tree/SingleLevelTree.js +191 -30
  55. package/es/TreeFor/index.js +3 -3
  56. package/es/TreeSelect/index.js +6 -4
  57. package/es/Upload/index.js +38 -4
  58. package/es/assets/svg/ColorPickUp.js +19 -6
  59. package/es/assets/svg/Crosshair.js +45 -6
  60. package/es/assets/svg/Resize.js +19 -6
  61. package/es/assets/svg/Rotate.js +14 -13
  62. package/es/assets/svg/RotateArrow.js +15 -20
  63. package/es/hooks/useClickAway.js +4 -6
  64. package/package.json +2 -2
  65. package/es/utils/DOMRect.d.ts +0 -22
  66. package/es/utils/DOMRect.js +0 -41
@@ -1,6 +1,6 @@
1
- import { ssr, ssrHydrationKey } from 'solid-js/web';
1
+ import { template } from 'solid-js/web';
2
2
 
3
- var _tmpl$ = ["<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\"></path></g></g></svg>"];
4
- const EmptySvg = () => ssr(_tmpl$, ssrHydrationKey());
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 { ssr, ssrHydrationKey } from 'solid-js/web';
1
+ import { template } from 'solid-js/web';
2
2
 
3
- var _tmpl$ = ["<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\"></path></g></g></svg>"];
4
- const EmptySvg = () => ssr(_tmpl$, ssrHydrationKey());
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, ssr, ssrHydrationKey, escape } from 'solid-js/web';
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$ = ["<div", " class=\"mb-[var(--ant-margin-xs)] flex justify-center\">", "</div>"],
7
- _tmpl$2 = ["<div", " class=\"text-[var(--ant-color-text)] text-center\">", "</div>"];
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 [ssr(_tmpl$, ssrHydrationKey(), escape(createComponent(EmptySvg, {}))), ssr(_tmpl$2, ssrHydrationKey(), escape(props.description) ?? '暂无数据')];
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,4 +1,4 @@
1
- import { createComponent, ssr, ssrHydrationKey, escape, ssrAttribute, Dynamic } from 'solid-js/web';
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$ = ["<label", " class=\"mr-4px\">", "</label>"],
10
- _tmpl$2 = ["<span", " class=\"text-[var(--ant-color-error)]\">*</span>"],
11
- _tmpl$3 = ["<div", " class=\"flex items-center\" style=\"", "\"><label", "><!--$-->", "<!--/--><!--$-->", "<!--/--></label></div>"],
12
- _tmpl$4 = ["<div", " class=\"absolute top-[100%] text-[var(--ant-color-error)]\">", "</div>"],
13
- _tmpl$5 = ["<div", " class=\"flex flex-col relative flex-grow-1\" style=\"", "\"><div>", "</div><!--$-->", "<!--/--></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>`);
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 [ssr(_tmpl$3, ssrHydrationKey(), "width:" + (layout() === 'horizontal' && maxItemWidth ? `${escape(maxItemWidth(), true) ?? 0}px` : escape(undefined, true)), ssrAttribute("class", escape(cs('shrink-0 leading-32px not[:empty]:h-32px not[:empty]:pr-8px text-right [white-space:nowrap]'), true), false), escape(createComponent(Show, {
73
- get when() {
74
- return !isNil(props.label);
75
- },
76
- get children() {
77
- return ssr(_tmpl$, ssrHydrationKey(), escape(props.label));
78
- }
79
- })), escape(createComponent(Show, {
80
- get when() {
81
- return !isNil(props.required);
82
- },
83
- get children() {
84
- return ssr(_tmpl$2, ssrHydrationKey());
85
- }
86
- }))), ssr(_tmpl$5, ssrHydrationKey(), "width:" + (layout() === 'horizontal' && maxItemWidth ? `calc(100% - ${escape(maxItemWidth(), true) ?? 0}px)` : escape(undefined, true)), escape(createComponent(Dynamic, {
87
- get component() {
88
- return props.component;
89
- },
90
- get value() {
91
- return props.name ? formInstance?.getFieldValue(props.name) : undefined;
92
- },
93
- get status() {
94
- return errMsg() ? 'error' : undefined;
95
- },
96
- onChange: value => {
97
- if (!isNil(props.name)) formInstance?.setFieldValue(props.name, value);
98
- props.rules?.forEach(rule => {
99
- rule.validate(value).then(() => {
100
- setErrMsg('');
101
- }).catch(err => {
102
- setErrMsg(err.message);
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
- })), escape(createComponent(Show, {
107
- get when() {
108
- return errMsg();
109
- },
110
- get children() {
111
- return ssr(_tmpl$4, ssrHydrationKey(), escape(errMsg()));
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
  }
@@ -1,5 +1,7 @@
1
+ import { memo } from 'solid-js/web';
2
+
1
3
  const Fragment = props => {
2
- return props.children;
4
+ return memo(() => props.children);
3
5
  };
4
6
 
5
7
  export { Fragment as default };
package/es/Image/index.js CHANGED
@@ -1,17 +1,37 @@
1
- import { ssr, ssrHydrationKey, ssrAttribute, escape, ssrStyle, ssrElement, mergeProps } from 'solid-js/web';
1
+ import { spread, mergeProps, effect, className, style, template } from 'solid-js/web';
2
2
  import cs from 'classnames';
3
3
 
4
- var _tmpl$ = ["<div", " style=\"", "\">", "</div>"];
4
+ var _tmpl$ = /*#__PURE__*/template(`<div><img>`);
5
5
  const Image = props => {
6
- return ssr(_tmpl$, ssrHydrationKey() + ssrAttribute("class", escape(cs(props.rootClass, 'inline-block'), true), false), ssrStyle({
7
- width: typeof props.width === 'string' ? props.width : undefined,
8
- height: typeof props.height === 'string' ? props.height : undefined,
9
- ...props.rootStyle
10
- }), ssrElement("img", mergeProps(props, {
11
- get src() {
12
- return props.src ? props.src : props.fallback;
13
- }
14
- }), undefined, false));
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 };
@@ -1,4 +1,4 @@
1
- import { createComponent, ssrElement, mergeProps } from 'solid-js/web';
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 'lodash-es';
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
- return ssrElement("textarea", mergeProps(inputProps, {
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
- }), undefined, true);
78
+ }), false, false);
79
+ return _el$;
54
80
  }
55
81
  });
56
82
  };
package/es/Input/index.js CHANGED
@@ -1,8 +1,9 @@
1
- import { createComponent, ssr, ssrHydrationKey, ssrAttribute, escape, ssrElement, mergeProps } from 'solid-js/web';
1
+ import { delegateEvents, createComponent, insert, effect, className, use, spread, mergeProps, template } from 'solid-js/web';
2
2
  import { isNil, omit } from 'lodash-es';
3
3
  import { useContext, splitProps, onMount, createMemo, Show } from 'solid-js';
4
4
  import cs from 'classnames';
5
5
  import createControllableValue from '../hooks/createControllableValue.js';
6
+ import { setRef } from '../utils/solid.js';
6
7
  import Element from '../Element/index.js';
7
8
  import TextArea from './TextArea.js';
8
9
  import useComponentSize from '../hooks/useComponentSize.js';
@@ -10,12 +11,12 @@ import './index.scss.js';
10
11
  import useFocus from '../hooks/useFocus.js';
11
12
  import CompactContext from '../Compact/context.js';
12
13
 
13
- var _tmpl$ = ["<div", ">", "</div>"],
14
- _tmpl$2 = ["<div", " class=\"mr-4px\">", "</div>"],
15
- _tmpl$3 = ["<span", " class=\"ml-4px i-ant-design:close-circle-filled cursor-pointer text-[var(--ant-color-text-quaternary)] hover:text-[var(--ant-color-text-tertiary)] active:text-[var(--ant-color-text)]\"></span>"],
16
- _tmpl$4 = ["<div", " class=\"ml-4px\">", "</div>"],
17
- _tmpl$5 = ["<div", " class=\"[display:var(--actions-display)] absolute top-0 bottom-0 right-0 h-[calc(100%-2px)] translate-y-1px -translate-x-1px\">", "</div>"],
18
- _tmpl$6 = ["<div", "><!--$-->", "<!--/-->", "<!--$-->", "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></div>"];
14
+ var _tmpl$ = /*#__PURE__*/template(`<div>`),
15
+ _tmpl$2 = /*#__PURE__*/template(`<div class=mr-4px>`),
16
+ _tmpl$3 = /*#__PURE__*/template(`<span class="ml-4px i-ant-design:close-circle-filled cursor-pointer text-[var(--ant-color-text-quaternary)] hover:text-[var(--ant-color-text-tertiary)] active:text-[var(--ant-color-text)]">`),
17
+ _tmpl$4 = /*#__PURE__*/template(`<div class=ml-4px>`),
18
+ _tmpl$5 = /*#__PURE__*/template(`<div class="[display:var(--actions-display)] absolute top-0 bottom-0 right-0 h-[calc(100%-2px)] translate-y-1px -translate-x-1px">`),
19
+ _tmpl$6 = /*#__PURE__*/template(`<div><input>`);
19
20
  const statusClassDict = {
20
21
  default: (disabled, foucs) => {
21
22
  if (disabled) {
@@ -54,8 +55,11 @@ function CommonInput(props) {
54
55
  let inputRef;
55
56
  const foucs = useFocus(() => inputRef);
56
57
  onMount(() => {
57
- if (props.autoFocus) ;
58
+ if (props.autoFocus) {
59
+ inputRef?.focus();
60
+ }
58
61
  });
62
+ const isControlled = () => Object.keys(props).includes('value');
59
63
  const [value, setValue] = createControllableValue(props, {
60
64
  trigger: null
61
65
  });
@@ -100,49 +104,101 @@ function CommonInput(props) {
100
104
  return !isNil(addonBefore());
101
105
  },
102
106
  get children() {
103
- return ssr(_tmpl$, ssrHydrationKey() + ssrAttribute("class", escape(cs('ant-input-addon', 'shrink-0 flex justify-center items-center px-11px bg-[rgba(0,0,0,.02)] [border:1px_solid_var(--ant-color-border)] border-r-0'), true), false), escape(addonBefore()));
104
- }
105
- }), ssr(_tmpl$6, ssrHydrationKey() + ssrAttribute("class", escape(cs('ant-input-affix-wrapper', 'flex items-center w-full relative p:hover-child[input]:border-[--ant-color-primary] bg-[--ant-color-bg-container] p-[--ant-input-padding] border-1px border-solid', ['[--actions-display:none]', !props.disabled && 'hover:[--actions-display:block]'], statusClassDict[props.status ?? 'default'](!!props.disabled, foucs())), true), false), escape(createComponent(Show, {
106
- get when() {
107
- return !isNil(prefix());
108
- },
109
- get children() {
110
- return ssr(_tmpl$2, ssrHydrationKey(), escape(prefix()));
111
- }
112
- })), ssrElement("input", mergeProps(inputProps, {
113
- get ["class"]() {
114
- return cs('w-full h-full [font-size:var(--ant-input-font-size)] [outline:none] placeholder-text-[var(--ant-color-text-placeholder)] bg-transparent', props.disabled && 'color-[var(--ant-color-text-disabled)] cursor-not-allowed', props.class);
115
- },
116
- get value() {
117
- return value() ?? '';
118
- }
119
- }), undefined, false), escape(createComponent(Show, {
120
- get when() {
121
- return showClearBtn();
122
- },
123
- get children() {
124
- return ssr(_tmpl$3, ssrHydrationKey());
125
- }
126
- })), escape(createComponent(Show, {
127
- get when() {
128
- return !isNil(suffix());
129
- },
130
- get children() {
131
- return ssr(_tmpl$4, ssrHydrationKey(), escape(suffix()));
132
- }
133
- })), escape(createComponent(Show, {
134
- get when() {
135
- return !isNil(actions());
136
- },
137
- get children() {
138
- return ssr(_tmpl$5, ssrHydrationKey(), escape(actions()));
107
+ var _el$ = _tmpl$();
108
+ insert(_el$, addonBefore);
109
+ effect(() => className(_el$, cs('ant-input-addon', 'shrink-0 flex justify-center items-center px-11px bg-[rgba(0,0,0,.02)] [border:1px_solid_var(--ant-color-border)] border-r-0')));
110
+ return _el$;
139
111
  }
140
- }))), createComponent(Show, {
112
+ }), (() => {
113
+ var _el$2 = _tmpl$6(),
114
+ _el$4 = _el$2.firstChild;
115
+ insert(_el$2, createComponent(Show, {
116
+ get when() {
117
+ return !isNil(prefix());
118
+ },
119
+ get children() {
120
+ var _el$3 = _tmpl$2();
121
+ insert(_el$3, prefix);
122
+ return _el$3;
123
+ }
124
+ }), _el$4);
125
+ use(el => {
126
+ setRef(props, el);
127
+ inputRef = el;
128
+ }, _el$4);
129
+ spread(_el$4, mergeProps(inputProps, {
130
+ get ["class"]() {
131
+ return cs('w-full h-full [font-size:var(--ant-input-font-size)] [outline:none] placeholder-text-[var(--ant-color-text-placeholder)] bg-transparent', props.disabled && 'color-[var(--ant-color-text-disabled)] cursor-not-allowed', props.class);
132
+ },
133
+ get value() {
134
+ return value() ?? '';
135
+ },
136
+ "onInput": e => {
137
+ setValue(e.target.value);
138
+ try {
139
+ props.onChange?.(e);
140
+ } finally {
141
+ if (isControlled() && e.target.value !== props.value) {
142
+ e.target.value = props.value ?? '';
143
+ }
144
+ }
145
+ },
146
+ "onKeyDown": e => {
147
+ if (e.key === 'Enter') {
148
+ props.onPressEnter?.(e);
149
+ }
150
+ props.onKeyDown?.(e);
151
+ }
152
+ }), false, false);
153
+ insert(_el$2, createComponent(Show, {
154
+ get when() {
155
+ return showClearBtn();
156
+ },
157
+ get children() {
158
+ var _el$5 = _tmpl$3();
159
+ _el$5.$$click = e => {
160
+ e.stopPropagation();
161
+ inputRef.value = '';
162
+ const inputEvent = new InputEvent('input', {
163
+ bubbles: true
164
+ });
165
+ inputRef.dispatchEvent(inputEvent);
166
+ inputRef?.focus();
167
+ };
168
+ return _el$5;
169
+ }
170
+ }), null);
171
+ insert(_el$2, createComponent(Show, {
172
+ get when() {
173
+ return !isNil(suffix());
174
+ },
175
+ get children() {
176
+ var _el$6 = _tmpl$4();
177
+ insert(_el$6, suffix);
178
+ return _el$6;
179
+ }
180
+ }), null);
181
+ insert(_el$2, createComponent(Show, {
182
+ get when() {
183
+ return !isNil(actions());
184
+ },
185
+ get children() {
186
+ var _el$7 = _tmpl$5();
187
+ insert(_el$7, actions);
188
+ return _el$7;
189
+ }
190
+ }), null);
191
+ effect(() => className(_el$2, cs('ant-input-affix-wrapper', 'flex items-center w-full relative p:hover-child[input]:border-[--ant-color-primary] bg-[--ant-color-bg-container] p-[--ant-input-padding] border-1px border-solid', ['[--actions-display:none]', !props.disabled && 'hover:[--actions-display:block]'], statusClassDict[props.status ?? 'default'](!!props.disabled, foucs()))));
192
+ return _el$2;
193
+ })(), createComponent(Show, {
141
194
  get when() {
142
195
  return !isNil(addonAfter());
143
196
  },
144
197
  get children() {
145
- return ssr(_tmpl$, ssrHydrationKey() + ssrAttribute("class", escape(cs('ant-input-addon', 'shrink-0 flex justify-center items-center px-11px bg-[rgba(0,0,0,.02)] [border:1px_solid_var(--ant-color-border)] border-l-0'), true), false), escape(addonAfter()));
198
+ var _el$8 = _tmpl$();
199
+ insert(_el$8, addonAfter);
200
+ effect(() => className(_el$8, cs('ant-input-addon', 'shrink-0 flex justify-center items-center px-11px bg-[rgba(0,0,0,.02)] [border:1px_solid_var(--ant-color-border)] border-l-0')));
201
+ return _el$8;
146
202
  }
147
203
  })];
148
204
  }
@@ -152,5 +208,6 @@ const Input = props => {
152
208
  return createComponent(CommonInput, mergeProps(() => omit(props, ['actions'])));
153
209
  };
154
210
  Input.TextArea = TextArea;
211
+ delegateEvents(["click"]);
155
212
 
156
213
  export { CommonInput, Input as default, statusClassDict };
@@ -1,13 +1,12 @@
1
- import { createComponent, mergeProps as mergeProps$1, ssr, ssrHydrationKey, ssrAttribute, escape } from 'solid-js/web';
1
+ import { delegateEvents, createComponent, mergeProps as mergeProps$1, memo, template } from 'solid-js/web';
2
2
  import { mergeProps, splitProps, createSignal, untrack, createMemo, createRenderEffect, on } from 'solid-js';
3
3
  import { isNumber, isNil, clamp, floor } from 'lodash-es';
4
4
  import NP from 'number-precision';
5
5
  import { CommonInput } from '../Input/index.js';
6
6
  import { dispatchEventHandlerUnion } from '../utils/solid.js';
7
7
 
8
- var _tmpl$ = ["<div", " class=\"flex flex-col h-full w-[--ant-input-number-handle-width] [border-left:1px_solid_var(--ant-color-border)] bg-[--ant-color-bg-container]\"><div", "><div class=\"i-ant-design:up-outlined\"></div></div><div class=\"", "\"><div class=\"i-ant-design:down-outlined\"></div></div></div>"];
8
+ var _tmpl$ = /*#__PURE__*/template(`<div class="flex flex-col h-full w-[--ant-input-number-handle-width] [border-left:1px_solid_var(--ant-color-border)] bg-[--ant-color-bg-container]"><div class="text-12px flex justify-center items-center h-1/2 cursor-pointer opacity-70 hover:h-100% hover:text-[var(--ant-color-primary)] transition-color transition-height transition-duration-500"><div class=i-ant-design:up-outlined></div></div><div class="[border-top:1px_solid_var(--ant-color-border)] text-12px flex justify-center items-center h-1/2 cursor-pointer opacity-70 hover:h-100% hover:text-[var(--ant-color-primary)] transition-color transition-height transition-duration-500"><div class=i-ant-design:down-outlined>`);
9
9
  const isEmptyValue = value => isNil(value) || value === '';
10
- const actionBtnClass = 'text-12px flex justify-center items-center h-1/2 cursor-pointer opacity-70 hover:h-100% hover:text-[var(--ant-color-primary)] transition-color transition-height transition-duration-500';
11
10
  const InputNumber = _props => {
12
11
  const props = mergeProps({
13
12
  min: -Infinity,
@@ -76,7 +75,14 @@ const InputNumber = _props => {
76
75
  };
77
76
  },
78
77
  get actions() {
79
- return props.controls ? ssr(_tmpl$, ssrHydrationKey(), ssrAttribute("class", escape(actionBtnClass, true), false), `[border-top:1px_solid_var(--ant-color-border)] ${escape(actionBtnClass, true)}`) : undefined;
78
+ return memo(() => !!props.controls)() ? (() => {
79
+ var _el$ = _tmpl$(),
80
+ _el$2 = _el$.firstChild,
81
+ _el$3 = _el$2.nextSibling;
82
+ _el$2.$$click = up;
83
+ _el$3.$$click = down;
84
+ return _el$;
85
+ })() : undefined;
80
86
  },
81
87
  get value() {
82
88
  return `${(focusing() ? value() : displayValue()) ?? ''}`;
@@ -111,5 +117,6 @@ const InputNumber = _props => {
111
117
  }
112
118
  }));
113
119
  };
120
+ delegateEvents(["click"]);
114
121
 
115
122
  export { InputNumber as default };