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,4 +1,4 @@
1
- import { ssr, ssrHydrationKey, escape, createComponent } from 'solid-js/web';
1
+ import { insert, createComponent, template } from 'solid-js/web';
2
2
  import { useContext, createMemo, createSignal, createRenderEffect, Switch, Match, Show } from 'solid-js';
3
3
  import ColorPickerContext from './context.js';
4
4
  import Select from '../Select/index.js';
@@ -6,9 +6,9 @@ import Input from '../Input/index.js';
6
6
  import InputNumber from '../InputNumber/index.js';
7
7
  import Color from './color.js';
8
8
 
9
- var _tmpl$ = ["<div", " class=\"flex grow-1 gap-[var(--ant-margin-xxs)]\"><!--$-->", "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></div>"],
10
- _tmpl$2 = ["<div", " class=\"flex\"><!--$-->", "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></div>"],
11
- _tmpl$3 = ["<span", " class=\"text-[--ant-color-text-placeholder]\">#</span>"];
9
+ var _tmpl$ = /*#__PURE__*/template(`<div class="flex grow-1 gap-[var(--ant-margin-xxs)]">`),
10
+ _tmpl$2 = /*#__PURE__*/template(`<div class=flex>`),
11
+ _tmpl$3 = /*#__PURE__*/template(`<span class=text-[--ant-color-text-placeholder]>#`);
12
12
  const ColorPickerInput = () => {
13
13
  const context = useContext(ColorPickerContext);
14
14
  const color = createMemo(() => context?.color() ?? new Color());
@@ -17,212 +17,226 @@ const ColorPickerInput = () => {
17
17
  createRenderEffect(() => {
18
18
  setHexInputValue(color().toHex());
19
19
  });
20
- return ssr(_tmpl$2, ssrHydrationKey(), escape(createComponent(Select, {
21
- get value() {
22
- return type();
23
- },
24
- onChange: setType,
25
- options: [{
26
- label: 'HEX',
27
- value: 'HEX'
28
- }, {
29
- label: 'HSV',
30
- value: 'HSV'
31
- }, {
32
- label: 'RGB',
33
- value: 'RGB'
34
- }],
35
- size: "small",
36
- variant: "borderless",
37
- style: {
38
- 'margin-right': 'var(--ant-margin-xs)',
39
- '--ant-select-font-size': '12px',
40
- '--ant-select-input-padding': '0',
41
- '--ant-select-input-addon-after-padding': '0 0 0 var(--ant-padding-xxs)',
42
- '--ant-select-popup-match-width': '60px'
43
- }
44
- })), escape(createComponent(Switch, {
45
- get children() {
46
- return [createComponent(Match, {
47
- get when() {
48
- return type() === 'HEX';
49
- },
50
- get children() {
51
- return createComponent(Input, {
52
- size: "small",
53
- get value() {
54
- return hexInputValue();
55
- },
56
- onChange: e => {
57
- const value = e.target.value.replace(/[^a-zA-Z0-9]/g, '');
58
- if (value.length > 6) return;
59
- setHexInputValue(value);
60
- if (value.length !== 6) return;
61
- const c = new Color(value);
62
- if (!c.isValid) return;
63
- context?.setColor(new Color(value).setAlpha(color().a));
64
- },
65
- onBlur: () => {
66
- setHexInputValue(color().toHex());
67
- context?.setColor(color(), true);
68
- },
69
- get prefix() {
70
- return ssr(_tmpl$3, ssrHydrationKey());
71
- },
72
- style: {
73
- '--ant-input-font-size': '12px'
74
- }
75
- });
76
- }
77
- }), createComponent(Match, {
78
- get when() {
79
- return type() === 'HSV';
80
- },
81
- get children() {
82
- return ssr(_tmpl$, ssrHydrationKey(), escape(createComponent(InputNumber, {
83
- size: "small",
84
- get value() {
85
- return Math.round(color().toHsv().h);
86
- },
87
- onChange: value => {
88
- const hsv = color().toHsv();
89
- hsv.h = value ?? 0;
90
- context?.setColor(new Color(hsv));
91
- },
92
- onBlur: () => {
93
- context?.setColor(color(), true);
94
- },
95
- min: 0,
96
- max: 359,
97
- precision: 0,
98
- style: InputNumberStyle
99
- })), escape(createComponent(InputNumber, {
100
- size: "small",
101
- get value() {
102
- return Math.round(color().toHsv().s * 100);
103
- },
104
- onChange: value => {
105
- const hsv = color().toHsv();
106
- hsv.s = (value ?? 0) / 100;
107
- context?.setColor(new Color(hsv));
108
- },
109
- onBlur: () => {
110
- context?.setColor(color(), true);
111
- },
112
- min: 0,
113
- max: 100,
114
- precision: 0,
115
- formatter: value => `${value || 0}%`,
116
- style: InputNumberStyle
117
- })), escape(createComponent(InputNumber, {
118
- size: "small",
119
- get value() {
120
- return Math.round(color().toHsv().v * 100);
121
- },
122
- onChange: value => {
123
- const hsv = color().toHsv();
124
- hsv.v = (value ?? 0) / 100;
125
- context?.setColor(new Color(hsv));
126
- },
127
- onBlur: () => {
128
- context?.setColor(color(), true);
129
- },
130
- min: 0,
131
- max: 100,
132
- precision: 0,
133
- formatter: value => `${value || 0}%`,
134
- style: InputNumberStyle
135
- })));
136
- }
137
- }), createComponent(Match, {
138
- get when() {
139
- return type() === 'RGB';
140
- },
141
- get children() {
142
- return ssr(_tmpl$, ssrHydrationKey(), escape(createComponent(InputNumber, {
143
- size: "small",
144
- get value() {
145
- return Math.round(color().r);
146
- },
147
- onChange: value => {
148
- const rgb = color().toRgb();
149
- rgb.r = value ?? 0;
150
- context?.setColor(new Color(rgb));
151
- },
152
- onBlur: () => {
153
- context?.setColor(color(), true);
154
- },
155
- min: 0,
156
- max: 255,
157
- precision: 0,
158
- style: InputNumberStyle
159
- })), escape(createComponent(InputNumber, {
160
- size: "small",
161
- get value() {
162
- return Math.round(color().g);
163
- },
164
- onChange: value => {
165
- const rgb = color().toRgb();
166
- rgb.g = value ?? 0;
167
- context?.setColor(new Color(rgb));
168
- },
169
- onBlur: () => {
170
- context?.setColor(color(), true);
171
- },
172
- min: 0,
173
- max: 255,
174
- precision: 0,
175
- style: InputNumberStyle
176
- })), escape(createComponent(InputNumber, {
177
- size: "small",
178
- get value() {
179
- return Math.round(color().b);
180
- },
181
- onChange: value => {
182
- const rgb = color().toRgb();
183
- rgb.b = value ?? 0;
184
- context?.setColor(new Color(rgb));
185
- },
186
- onBlur: () => {
187
- context?.setColor(color(), true);
188
- },
189
- min: 0,
190
- max: 255,
191
- precision: 0,
192
- style: InputNumberStyle
193
- })));
194
- }
195
- })];
196
- }
197
- })), escape(createComponent(Show, {
198
- get when() {
199
- return !context?.disabledAlpha();
200
- },
201
- get children() {
202
- return createComponent(InputNumber, {
203
- get value() {
204
- return Math.round(color().a * 100);
205
- },
206
- onChange: value => {
207
- context?.setColor(color().clone().setAlpha((value ?? 0) / 100));
208
- },
209
- onBlur: () => {
210
- context?.setColor(color(), true);
211
- },
212
- size: "small",
213
- min: 0,
214
- max: 100,
215
- precision: 0,
216
- formatter: value => `${value || 0}%`,
217
- get style() {
218
- return {
219
- ...InputNumberStyle,
220
- 'margin-left': 'var(--ant-margin-xxs)'
221
- };
222
- }
223
- });
224
- }
225
- })));
20
+ return (() => {
21
+ var _el$ = _tmpl$2();
22
+ insert(_el$, createComponent(Select, {
23
+ get value() {
24
+ return type();
25
+ },
26
+ onChange: setType,
27
+ options: [{
28
+ label: 'HEX',
29
+ value: 'HEX'
30
+ }, {
31
+ label: 'HSV',
32
+ value: 'HSV'
33
+ }, {
34
+ label: 'RGB',
35
+ value: 'RGB'
36
+ }],
37
+ size: "small",
38
+ variant: "borderless",
39
+ style: {
40
+ 'margin-right': 'var(--ant-margin-xs)',
41
+ '--ant-select-font-size': '12px',
42
+ '--ant-select-input-padding': '0',
43
+ '--ant-select-input-addon-after-padding': '0 0 0 var(--ant-padding-xxs)',
44
+ '--ant-select-popup-match-width': '60px'
45
+ }
46
+ }), null);
47
+ insert(_el$, createComponent(Switch, {
48
+ get children() {
49
+ return [createComponent(Match, {
50
+ get when() {
51
+ return type() === 'HEX';
52
+ },
53
+ get children() {
54
+ return createComponent(Input, {
55
+ size: "small",
56
+ get value() {
57
+ return hexInputValue();
58
+ },
59
+ onChange: e => {
60
+ const value = e.target.value.replace(/[^a-zA-Z0-9]/g, '');
61
+ if (value.length > 6) return;
62
+ setHexInputValue(value);
63
+ if (value.length !== 6) return;
64
+ const c = new Color(value);
65
+ if (!c.isValid) return;
66
+ context?.setColor(new Color(value).setAlpha(color().a));
67
+ },
68
+ onBlur: () => {
69
+ setHexInputValue(color().toHex());
70
+ context?.setColor(color(), true);
71
+ },
72
+ get prefix() {
73
+ return _tmpl$3();
74
+ },
75
+ style: {
76
+ '--ant-input-font-size': '12px'
77
+ }
78
+ });
79
+ }
80
+ }), createComponent(Match, {
81
+ get when() {
82
+ return type() === 'HSV';
83
+ },
84
+ get children() {
85
+ var _el$2 = _tmpl$();
86
+ insert(_el$2, createComponent(InputNumber, {
87
+ size: "small",
88
+ get value() {
89
+ return Math.round(color().toHsv().h);
90
+ },
91
+ onChange: value => {
92
+ const hsv = color().toHsv();
93
+ hsv.h = value ?? 0;
94
+ context?.setColor(new Color(hsv));
95
+ },
96
+ onBlur: () => {
97
+ context?.setColor(color(), true);
98
+ },
99
+ min: 0,
100
+ max: 359,
101
+ precision: 0,
102
+ style: InputNumberStyle
103
+ }), null);
104
+ insert(_el$2, createComponent(InputNumber, {
105
+ size: "small",
106
+ get value() {
107
+ return Math.round(color().toHsv().s * 100);
108
+ },
109
+ onChange: value => {
110
+ const hsv = color().toHsv();
111
+ hsv.s = (value ?? 0) / 100;
112
+ context?.setColor(new Color(hsv));
113
+ },
114
+ onBlur: () => {
115
+ context?.setColor(color(), true);
116
+ },
117
+ min: 0,
118
+ max: 100,
119
+ precision: 0,
120
+ formatter: value => `${value || 0}%`,
121
+ style: InputNumberStyle
122
+ }), null);
123
+ insert(_el$2, createComponent(InputNumber, {
124
+ size: "small",
125
+ get value() {
126
+ return Math.round(color().toHsv().v * 100);
127
+ },
128
+ onChange: value => {
129
+ const hsv = color().toHsv();
130
+ hsv.v = (value ?? 0) / 100;
131
+ context?.setColor(new Color(hsv));
132
+ },
133
+ onBlur: () => {
134
+ context?.setColor(color(), true);
135
+ },
136
+ min: 0,
137
+ max: 100,
138
+ precision: 0,
139
+ formatter: value => `${value || 0}%`,
140
+ style: InputNumberStyle
141
+ }), null);
142
+ return _el$2;
143
+ }
144
+ }), createComponent(Match, {
145
+ get when() {
146
+ return type() === 'RGB';
147
+ },
148
+ get children() {
149
+ var _el$3 = _tmpl$();
150
+ insert(_el$3, createComponent(InputNumber, {
151
+ size: "small",
152
+ get value() {
153
+ return Math.round(color().r);
154
+ },
155
+ onChange: value => {
156
+ const rgb = color().toRgb();
157
+ rgb.r = value ?? 0;
158
+ context?.setColor(new Color(rgb));
159
+ },
160
+ onBlur: () => {
161
+ context?.setColor(color(), true);
162
+ },
163
+ min: 0,
164
+ max: 255,
165
+ precision: 0,
166
+ style: InputNumberStyle
167
+ }), null);
168
+ insert(_el$3, createComponent(InputNumber, {
169
+ size: "small",
170
+ get value() {
171
+ return Math.round(color().g);
172
+ },
173
+ onChange: value => {
174
+ const rgb = color().toRgb();
175
+ rgb.g = value ?? 0;
176
+ context?.setColor(new Color(rgb));
177
+ },
178
+ onBlur: () => {
179
+ context?.setColor(color(), true);
180
+ },
181
+ min: 0,
182
+ max: 255,
183
+ precision: 0,
184
+ style: InputNumberStyle
185
+ }), null);
186
+ insert(_el$3, createComponent(InputNumber, {
187
+ size: "small",
188
+ get value() {
189
+ return Math.round(color().b);
190
+ },
191
+ onChange: value => {
192
+ const rgb = color().toRgb();
193
+ rgb.b = value ?? 0;
194
+ context?.setColor(new Color(rgb));
195
+ },
196
+ onBlur: () => {
197
+ context?.setColor(color(), true);
198
+ },
199
+ min: 0,
200
+ max: 255,
201
+ precision: 0,
202
+ style: InputNumberStyle
203
+ }), null);
204
+ return _el$3;
205
+ }
206
+ })];
207
+ }
208
+ }), null);
209
+ insert(_el$, createComponent(Show, {
210
+ get when() {
211
+ return !context?.disabledAlpha();
212
+ },
213
+ get children() {
214
+ return createComponent(InputNumber, {
215
+ get value() {
216
+ return Math.round(color().a * 100);
217
+ },
218
+ onChange: value => {
219
+ context?.setColor(color().clone().setAlpha((value ?? 0) / 100));
220
+ },
221
+ onBlur: () => {
222
+ context?.setColor(color(), true);
223
+ },
224
+ size: "small",
225
+ min: 0,
226
+ max: 100,
227
+ precision: 0,
228
+ formatter: value => `${value || 0}%`,
229
+ get style() {
230
+ return {
231
+ ...InputNumberStyle,
232
+ 'margin-left': 'var(--ant-margin-xxs)'
233
+ };
234
+ }
235
+ });
236
+ }
237
+ }), null);
238
+ return _el$;
239
+ })();
226
240
  };
227
241
  const InputNumberStyle = {
228
242
  width: '43px',
@@ -1,14 +1,71 @@
1
- import { ssr, ssrHydrationKey, escape } from 'solid-js/web';
1
+ import { delegateEvents, effect, template, use } from 'solid-js/web';
2
2
  import { useContext, createMemo } from 'solid-js';
3
- import 'lodash-es';
3
+ import { clamp } from 'lodash-es';
4
4
  import ColorPickerContext from './context.js';
5
5
  import Color from './color.js';
6
+ import { setupGlobalDrag } from '../utils/setupGlobalDrag.js';
6
7
 
7
- var _tmpl$ = ["<div", " class=\"h-160px rounded-[--ant-border-radius-sm] cursor-pointer relative overflow-hidden\" style=\"", "\"><div class=\"absolute border-2px border-solid border-[--ant-color-bg-container] rounded-1/2 w-16px h-16px -translate-1/2\" style=\"", "\"></div></div>"];
8
+ var _tmpl$ = /*#__PURE__*/template(`<div class="h-160px rounded-[--ant-border-radius-sm] cursor-pointer relative overflow-hidden"><div class="absolute border-2px border-solid border-[--ant-color-bg-container] rounded-1/2 w-16px h-16px -translate-1/2">`);
8
9
  const ColorPickerSelect = () => {
10
+ let ref;
9
11
  const context = useContext(ColorPickerContext);
10
12
  const color = createMemo(() => context?.color() ?? new Color());
11
- return ssr(_tmpl$, ssrHydrationKey(), "background-color:" + escape(color().toHueRgbString(), true) + (";background-image:" + "linear-gradient(0deg, rgb(0, 0, 0), transparent), linear-gradient(90deg, rgb(255, 255, 255), rgba(255, 255, 255, 0))"), "left:" + `${escape(color().toHsv().s, true) * 100}%` + (";top:" + `${(1 - escape(color().toHsv().v, true)) * 100}%`) + (";background:" + escape(color().toRgbString(), true)) + (";box-shadow:" + "inset 0 0 1px 0 var(--ant-color-text-quaternary), 0 0 0 1px var(--ant-color-fill-secondary)"));
13
+ const setColor = (e, completed) => {
14
+ if (!ref) return;
15
+ const rect = ref.getBoundingClientRect();
16
+ const offsetX = e.clientX - rect.x;
17
+ const offsetY = e.clientY - rect.y;
18
+ const {
19
+ clientWidth,
20
+ clientHeight
21
+ } = ref;
22
+ const hsv = color().toHsv();
23
+ hsv.s = clamp(offsetX / clientWidth, 0, 1);
24
+ hsv.v = clamp(1 - offsetY / clientHeight, 0, 1);
25
+ context?.setColor(new Color(hsv), completed);
26
+ };
27
+ return (() => {
28
+ var _el$ = _tmpl$(),
29
+ _el$2 = _el$.firstChild;
30
+ _el$.$$click = e => {
31
+ setColor(e, true);
32
+ };
33
+ var _ref$ = ref;
34
+ typeof _ref$ === "function" ? use(_ref$, _el$) : ref = _el$;
35
+ _el$.style.setProperty("background-image", "linear-gradient(0deg, rgb(0, 0, 0), transparent), linear-gradient(90deg, rgb(255, 255, 255), rgba(255, 255, 255, 0))");
36
+ _el$2.$$mousedown = () => {
37
+ let isDrag = false;
38
+ setupGlobalDrag(
39
+ // eslint-disable-next-line solid/reactivity
40
+ e => {
41
+ setColor(e);
42
+ isDrag = true;
43
+ },
44
+ // eslint-disable-next-line solid/reactivity
45
+ () => {
46
+ if (isDrag) context?.setColor(color(), true);
47
+ });
48
+ };
49
+ _el$2.style.setProperty("box-shadow", "inset 0 0 1px 0 var(--ant-color-text-quaternary), 0 0 0 1px var(--ant-color-fill-secondary)");
50
+ effect(_p$ => {
51
+ var _v$ = color().toHueRgbString(),
52
+ _v$2 = `${color().toHsv().s * 100}%`,
53
+ _v$3 = `${(1 - color().toHsv().v) * 100}%`,
54
+ _v$4 = color().toRgbString();
55
+ _v$ !== _p$.e && ((_p$.e = _v$) != null ? _el$.style.setProperty("background-color", _v$) : _el$.style.removeProperty("background-color"));
56
+ _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$2.style.setProperty("left", _v$2) : _el$2.style.removeProperty("left"));
57
+ _v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$2.style.setProperty("top", _v$3) : _el$2.style.removeProperty("top"));
58
+ _v$4 !== _p$.o && ((_p$.o = _v$4) != null ? _el$2.style.setProperty("background", _v$4) : _el$2.style.removeProperty("background"));
59
+ return _p$;
60
+ }, {
61
+ e: undefined,
62
+ t: undefined,
63
+ a: undefined,
64
+ o: undefined
65
+ });
66
+ return _el$;
67
+ })();
12
68
  };
69
+ delegateEvents(["click", "mousedown"]);
13
70
 
14
71
  export { ColorPickerSelect as default };