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/Radio/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { delegateEvents, createComponent, effect, className, insert, template } from 'solid-js/web';
|
|
2
2
|
import { Show } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import createControllableValue from '../hooks/createControllableValue.js';
|
|
5
5
|
import Button from './Button.js';
|
|
6
6
|
import Group from './Group.js';
|
|
7
|
+
import { wave } from '../utils/animation.js';
|
|
7
8
|
import Element from '../Element/index.js';
|
|
8
9
|
|
|
9
|
-
var _tmpl$ =
|
|
10
|
-
_tmpl$2 =
|
|
10
|
+
var _tmpl$ = /*#__PURE__*/template(`<span><input class="m-0 hidden"type=radio><span>`),
|
|
11
|
+
_tmpl$2 = /*#__PURE__*/template(`<span class=px-8px>`);
|
|
11
12
|
const Radio = props => {
|
|
12
13
|
const [checked, setChecked] = createControllableValue(props, {
|
|
13
14
|
defaultValue: false,
|
|
@@ -21,12 +22,40 @@ const Radio = props => {
|
|
|
21
22
|
return cs('inline-flex cursor-pointer inline-flex items-center', props.disabled && 'text-[var(--ant-color-text-disabled)] cursor-not-allowed');
|
|
22
23
|
},
|
|
23
24
|
get children() {
|
|
24
|
-
return [
|
|
25
|
+
return [(() => {
|
|
26
|
+
var _el$ = _tmpl$(),
|
|
27
|
+
_el$2 = _el$.firstChild,
|
|
28
|
+
_el$3 = _el$2.nextSibling;
|
|
29
|
+
_el$.$$click = e => {
|
|
30
|
+
wave(e.currentTarget, 'var(--ant-color-primary)');
|
|
31
|
+
};
|
|
32
|
+
_el$2.$$input = e => {
|
|
33
|
+
setChecked(e.target.checked);
|
|
34
|
+
props.onChange?.(e);
|
|
35
|
+
};
|
|
36
|
+
effect(_p$ => {
|
|
37
|
+
var _v$ = cs('relative w-16px h-16px rounded-50%'),
|
|
38
|
+
_v$2 = props.disabled,
|
|
39
|
+
_v$3 = cs('absolute inset-0 rounded-inherit [border:1px_solid_var(--ant-color-border)] bg-[var(--ant-color-bg-container)]', checked() && (props.disabled ? 'flex justify-center items-center before:content-empty before:block before:w-8px before:h-8px before:bg-[var(--ant-radio-dot-color-disabled)] before:rounded-50%' : '[border:5px_solid_var(--ant-color-primary)]'), props.disabled && 'bg-[var(--ant-color-bg-container-disabled)]');
|
|
40
|
+
_v$ !== _p$.e && className(_el$, _p$.e = _v$);
|
|
41
|
+
_v$2 !== _p$.t && (_el$2.disabled = _p$.t = _v$2);
|
|
42
|
+
_v$3 !== _p$.a && className(_el$3, _p$.a = _v$3);
|
|
43
|
+
return _p$;
|
|
44
|
+
}, {
|
|
45
|
+
e: undefined,
|
|
46
|
+
t: undefined,
|
|
47
|
+
a: undefined
|
|
48
|
+
});
|
|
49
|
+
effect(() => _el$2.checked = checked());
|
|
50
|
+
return _el$;
|
|
51
|
+
})(), createComponent(Show, {
|
|
25
52
|
get when() {
|
|
26
53
|
return props.children;
|
|
27
54
|
},
|
|
28
55
|
get children() {
|
|
29
|
-
|
|
56
|
+
var _el$4 = _tmpl$2();
|
|
57
|
+
insert(_el$4, () => props.children);
|
|
58
|
+
return _el$4;
|
|
30
59
|
}
|
|
31
60
|
})];
|
|
32
61
|
}
|
|
@@ -34,5 +63,6 @@ const Radio = props => {
|
|
|
34
63
|
};
|
|
35
64
|
Radio.Button = Button;
|
|
36
65
|
Radio.Group = Group;
|
|
66
|
+
delegateEvents(["click", "input"]);
|
|
37
67
|
|
|
38
68
|
export { Radio as default };
|
package/es/RangeInput/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { delegateEvents, createComponent, use, insert, effect, setAttribute, className, style, template } from 'solid-js/web';
|
|
2
2
|
import { useContext, createSignal, createEffect, on, createMemo, Show } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import { compact, isNil } from 'lodash-es';
|
|
@@ -8,11 +8,11 @@ import useClickAway from '../hooks/useClickAway.js';
|
|
|
8
8
|
import Element from '../Element/index.js';
|
|
9
9
|
import CompactContext from '../Compact/context.js';
|
|
10
10
|
|
|
11
|
-
var _tmpl$ =
|
|
12
|
-
_tmpl$2 =
|
|
13
|
-
_tmpl$3 =
|
|
14
|
-
_tmpl$4 =
|
|
15
|
-
_tmpl$5 =
|
|
11
|
+
var _tmpl$ = /*#__PURE__*/template(`<span class="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)]">`),
|
|
12
|
+
_tmpl$2 = /*#__PURE__*/template(`<div tabindex=0><div class=truncate></div><span class="i-ant-design:swap-right-outlined w-32px"></span><div class=truncate></div><div aria-label=active-bar class="h-1px bg-[var(--ant-color-primary)] absolute bottom-0 transition-left"></div><div class="absolute top-0 bottom-0 right-11px flex items-center">`),
|
|
13
|
+
_tmpl$3 = /*#__PURE__*/template(`<div class="w-200px max-h-400px overflow-auto">`),
|
|
14
|
+
_tmpl$4 = /*#__PURE__*/template(`<input class="h-30px [outline:none] bg-inherit placeholder-text-[var(--ant-color-text-placeholder)]"readonly>`),
|
|
15
|
+
_tmpl$5 = /*#__PURE__*/template(`<span class="i-ant-design:down-outlined text-[var(--ant-color-text-quaternary)]">`);
|
|
16
16
|
const statusClassDict = {
|
|
17
17
|
default: (disabled, focus) => cs('[border:1px_solid_var(--ant-color-border)]', !disabled && 'hover:border-[var(--ant-color-primary)] focus-within:border-[var(--ant-color-primary)] focus-within:[box-shadow:0_0_0_2px_var(--ant-control-outline)]', focus && 'border-[var(--ant-color-primary)] [box-shadow:0_0_0_2px_var(--ant-control-outline)]'),
|
|
18
18
|
error: (disabled, focus) => cs('[border:1px_solid_var(--ant-color-error)]', !disabled && 'hover:border-[var(--ant-color-error-border-hover)] focus-within:[box-shadow:0_0_0_2px_rgba(255,38,5,.06)]', focus && '[box-shadow:0_0_0_2px_rgba(255,38,5,.06)]'),
|
|
@@ -102,53 +102,109 @@ function RangeInput(props) {
|
|
|
102
102
|
trigger: false,
|
|
103
103
|
placement: "bottomLeft",
|
|
104
104
|
arrow: false,
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
contentHTMLAttributes: {
|
|
106
|
+
style: {
|
|
107
|
+
padding: 0
|
|
108
|
+
}
|
|
107
109
|
},
|
|
108
|
-
content: () =>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
content: () => (() => {
|
|
111
|
+
var _el$8 = _tmpl$3();
|
|
112
|
+
var _ref$4 = tooltipContent;
|
|
113
|
+
typeof _ref$4 === "function" ? use(_ref$4, _el$8) : tooltipContent = _el$8;
|
|
114
|
+
insert(_el$8, () => props.content({
|
|
115
|
+
currentFocusType,
|
|
116
|
+
tempValue,
|
|
117
|
+
setSingleValue
|
|
118
|
+
}));
|
|
119
|
+
effect(() => `${width()}px` != null ? _el$8.style.setProperty("width", `${width()}px`) : _el$8.style.removeProperty("width"));
|
|
120
|
+
return _el$8;
|
|
121
|
+
})(),
|
|
113
122
|
get children() {
|
|
114
|
-
|
|
123
|
+
var _el$ = _tmpl$2(),
|
|
124
|
+
_el$2 = _el$.firstChild,
|
|
125
|
+
_el$3 = _el$2.nextSibling,
|
|
126
|
+
_el$4 = _el$3.nextSibling,
|
|
127
|
+
_el$5 = _el$4.nextSibling,
|
|
128
|
+
_el$6 = _el$5.nextSibling;
|
|
129
|
+
_el$.addEventListener("mouseleave", () => setHover(false));
|
|
130
|
+
_el$.addEventListener("mouseenter", () => setHover(true));
|
|
131
|
+
_el$.$$click = e => {
|
|
132
|
+
setOpen(true);
|
|
133
|
+
setWidth(e.currentTarget.offsetWidth);
|
|
134
|
+
setCurrentFocusType(e.target !== endDom ? 'start' : 'end');
|
|
135
|
+
};
|
|
136
|
+
var _ref$ = container;
|
|
137
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : container = _el$;
|
|
138
|
+
var _ref$2 = startDom;
|
|
139
|
+
typeof _ref$2 === "function" ? use(_ref$2, _el$2) : startDom = _el$2;
|
|
140
|
+
insert(_el$2, createComponent(Show, {
|
|
115
141
|
get when() {
|
|
116
142
|
return !isNil(tempValue()[0]);
|
|
117
143
|
},
|
|
118
144
|
get fallback() {
|
|
119
|
-
return
|
|
145
|
+
return (() => {
|
|
146
|
+
var _el$9 = _tmpl$4();
|
|
147
|
+
effect(() => setAttribute(_el$9, "placeholder", props.placeholder?.[0]));
|
|
148
|
+
return _el$9;
|
|
149
|
+
})();
|
|
120
150
|
},
|
|
121
151
|
get children() {
|
|
122
152
|
return optionLabelRender(tempValue()[0]);
|
|
123
153
|
}
|
|
124
|
-
}))
|
|
154
|
+
}));
|
|
155
|
+
var _ref$3 = endDom;
|
|
156
|
+
typeof _ref$3 === "function" ? use(_ref$3, _el$4) : endDom = _el$4;
|
|
157
|
+
insert(_el$4, createComponent(Show, {
|
|
125
158
|
get when() {
|
|
126
159
|
return !isNil(tempValue()[1]);
|
|
127
160
|
},
|
|
128
161
|
get fallback() {
|
|
129
|
-
return
|
|
162
|
+
return (() => {
|
|
163
|
+
var _el$10 = _tmpl$4();
|
|
164
|
+
effect(() => setAttribute(_el$10, "placeholder", props.placeholder?.[1]));
|
|
165
|
+
return _el$10;
|
|
166
|
+
})();
|
|
130
167
|
},
|
|
131
168
|
get children() {
|
|
132
169
|
return optionLabelRender(tempValue()[1]);
|
|
133
170
|
}
|
|
134
|
-
}))
|
|
135
|
-
|
|
136
|
-
...activeBarStyle()
|
|
137
|
-
}), escape(createComponent(Show, {
|
|
171
|
+
}));
|
|
172
|
+
insert(_el$6, createComponent(Show, {
|
|
138
173
|
get when() {
|
|
139
174
|
return showClearBtn();
|
|
140
175
|
},
|
|
141
176
|
get fallback() {
|
|
142
|
-
return
|
|
177
|
+
return _tmpl$5();
|
|
143
178
|
},
|
|
144
179
|
get children() {
|
|
145
|
-
|
|
180
|
+
var _el$7 = _tmpl$();
|
|
181
|
+
_el$7.$$click = e => {
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
setValue([]);
|
|
184
|
+
setOpen(false);
|
|
185
|
+
};
|
|
186
|
+
return _el$7;
|
|
146
187
|
}
|
|
147
|
-
}))
|
|
188
|
+
}));
|
|
189
|
+
effect(_p$ => {
|
|
190
|
+
var _v$ = cs('relative min-h-32px pr-25px rounded-inherit grid [grid-template-columns:1fr_auto_1fr] items-center', tempValue().length && props.multiple ? 'pl-4px' : 'pl-11px', props.multiple && 'py-1px', props.disabled && '[pointer-events:none] bg-[var(--ant-color-bg-container-disabled)] color-[var(--ant-color-text-disabled)]', statusClassDict[props.status ?? 'default'](!!props.disabled, open())),
|
|
191
|
+
_v$2 = {
|
|
192
|
+
display: open() ? 'block' : 'none',
|
|
193
|
+
...activeBarStyle()
|
|
194
|
+
};
|
|
195
|
+
_v$ !== _p$.e && className(_el$, _p$.e = _v$);
|
|
196
|
+
_p$.t = style(_el$5, _v$2, _p$.t);
|
|
197
|
+
return _p$;
|
|
198
|
+
}, {
|
|
199
|
+
e: undefined,
|
|
200
|
+
t: undefined
|
|
201
|
+
});
|
|
202
|
+
return _el$;
|
|
148
203
|
}
|
|
149
204
|
});
|
|
150
205
|
}
|
|
151
206
|
});
|
|
152
207
|
}
|
|
208
|
+
delegateEvents(["click"]);
|
|
153
209
|
|
|
154
210
|
export { RangeInput as default };
|
package/es/Result/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { createComponent, effect, className, insert, template } from 'solid-js/web';
|
|
2
2
|
import { mergeProps } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import Element from '../Element/index.js';
|
|
5
5
|
|
|
6
|
-
var _tmpl$ =
|
|
7
|
-
_tmpl$2 =
|
|
8
|
-
_tmpl$3 =
|
|
9
|
-
_tmpl$4 =
|
|
6
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class=mb-24px><span>`),
|
|
7
|
+
_tmpl$2 = /*#__PURE__*/template(`<div class="my-8px text-[--ant-color-text-heading] text-24px">`),
|
|
8
|
+
_tmpl$3 = /*#__PURE__*/template(`<div class="text-[--ant-color-text-description] text-14px">`),
|
|
9
|
+
_tmpl$4 = /*#__PURE__*/template(`<div class=mt-24px>`);
|
|
10
10
|
const statusIconMap = {
|
|
11
11
|
success: '!text-[--ant-color-success] i-ant-design:check-circle-filled',
|
|
12
12
|
info: '!text-[--ant-color-primary] i-ant-design:exclamation-circle-filled',
|
|
@@ -20,7 +20,28 @@ const Result = _props => {
|
|
|
20
20
|
return createComponent(Element, {
|
|
21
21
|
"class": "text-center px-32px py-48px [font-size:var(--ant-font-size)] text-[--ant-color-text] leading-[--ant-line-height]",
|
|
22
22
|
get children() {
|
|
23
|
-
return [
|
|
23
|
+
return [(() => {
|
|
24
|
+
var _el$ = _tmpl$(),
|
|
25
|
+
_el$2 = _el$.firstChild;
|
|
26
|
+
effect(() => className(_el$2, cs(statusIconMap[props.status], 'text-72px')));
|
|
27
|
+
return _el$;
|
|
28
|
+
})(), (() => {
|
|
29
|
+
var _el$3 = _tmpl$2();
|
|
30
|
+
insert(_el$3, () => props.title);
|
|
31
|
+
return _el$3;
|
|
32
|
+
})(), (() => {
|
|
33
|
+
var _el$4 = _tmpl$3();
|
|
34
|
+
insert(_el$4, () => props.subTitle);
|
|
35
|
+
return _el$4;
|
|
36
|
+
})(), (() => {
|
|
37
|
+
var _el$5 = _tmpl$4();
|
|
38
|
+
insert(_el$5, () => props.extra);
|
|
39
|
+
return _el$5;
|
|
40
|
+
})(), (() => {
|
|
41
|
+
var _el$6 = _tmpl$4();
|
|
42
|
+
insert(_el$6, () => props.children);
|
|
43
|
+
return _el$6;
|
|
44
|
+
})()];
|
|
24
45
|
}
|
|
25
46
|
});
|
|
26
47
|
};
|
package/es/Segmented/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent,
|
|
1
|
+
import { delegateEvents, createComponent, insert, effect, className, template } from 'solid-js/web';
|
|
2
2
|
import { createSelector, For, Show } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import createControllableValue from '../hooks/createControllableValue.js';
|
|
@@ -6,7 +6,7 @@ import { unwrapStringOrJSXElement } from '../utils/solid.js';
|
|
|
6
6
|
import Element from '../Element/index.js';
|
|
7
7
|
import useComponentSize from '../hooks/useComponentSize.js';
|
|
8
8
|
|
|
9
|
-
var _tmpl$ =
|
|
9
|
+
var _tmpl$ = /*#__PURE__*/template(`<div><div>`);
|
|
10
10
|
const unWarpValue = value => typeof value === 'object' ? value.value : value;
|
|
11
11
|
const Segmented = props => {
|
|
12
12
|
const [value, setValue] = createControllableValue(props, {
|
|
@@ -34,20 +34,40 @@ const Segmented = props => {
|
|
|
34
34
|
get each() {
|
|
35
35
|
return props.options;
|
|
36
36
|
},
|
|
37
|
-
children: item =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
children: item => (() => {
|
|
38
|
+
var _el$ = _tmpl$(),
|
|
39
|
+
_el$2 = _el$.firstChild;
|
|
40
|
+
_el$2.$$click = e => {
|
|
41
|
+
setValue(unWarpValue(item));
|
|
42
|
+
typeof item === 'object' && item.onClick?.(e);
|
|
43
|
+
};
|
|
44
|
+
insert(_el$2, createComponent(Show, {
|
|
45
|
+
when: typeof item !== 'object',
|
|
46
|
+
get fallback() {
|
|
47
|
+
return typeof item === 'object' && unwrapStringOrJSXElement(item.label);
|
|
48
|
+
},
|
|
49
|
+
children: item
|
|
50
|
+
}));
|
|
51
|
+
effect(_p$ => {
|
|
52
|
+
var _v$ = cs('ant-segmented-item', props.block && 'basis-0 grow-1', isDisabledValue(item) && 'cursor-not-allowed'),
|
|
53
|
+
_v$2 = cs('rounded-[var(--ant-border-radius-sm)] px-[var(--ant-padding-sm)] cursor-pointer [white-space:nowrap]', isSelected(unWarpValue(item)) && 'bg-[var(--ant-segmented-item-selected-bg)]', isDisabledValue(item) ? '[pointer-events:none] text-[var(--ant-color-text-disabled)]' : isSelected(unWarpValue(item)) ? 'shadow-[var(--ant-box-shadow-tertiary)] text-[var(--ant-segmented-item-selected-color)]' : 'text-[var(--ant-segmented-item-color)] hover:text-[var(--ant-segmented-item-hover-color)] hover:bg-[var(--ant-segmented-item-hover-bg)] active:bg-[var(--ant-segmented-item-active-bg)]', props.block && 'flex justify-center', {
|
|
54
|
+
small: 'leading-20px',
|
|
55
|
+
middle: 'leading-28px',
|
|
56
|
+
large: 'leading-36px'
|
|
57
|
+
}[size()]);
|
|
58
|
+
_v$ !== _p$.e && className(_el$, _p$.e = _v$);
|
|
59
|
+
_v$2 !== _p$.t && className(_el$2, _p$.t = _v$2);
|
|
60
|
+
return _p$;
|
|
61
|
+
}, {
|
|
62
|
+
e: undefined,
|
|
63
|
+
t: undefined
|
|
64
|
+
});
|
|
65
|
+
return _el$;
|
|
66
|
+
})()
|
|
48
67
|
});
|
|
49
68
|
}
|
|
50
69
|
});
|
|
51
70
|
};
|
|
71
|
+
delegateEvents(["click"]);
|
|
52
72
|
|
|
53
73
|
export { Segmented as default };
|
package/es/Select/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface SelectOption<T = Key> {
|
|
|
6
6
|
value: T;
|
|
7
7
|
class?: string;
|
|
8
8
|
}
|
|
9
|
-
export interface SelectProps<T = Key> extends Pick<SelectInputProps<T>, 'multiple' | 'allowClear' | 'class' | 'style' | 'disabled' | 'placeholder' | 'status' | 'size' | 'variant' | 'suffixIcon' | 'placement' | 'getPopupContainer' | 'defaultOpen' | 'open' | 'onOpenChange'> {
|
|
9
|
+
export interface SelectProps<T = Key> extends Pick<SelectInputProps<T>, 'ref' | 'multiple' | 'allowClear' | 'class' | 'style' | 'disabled' | 'placeholder' | 'status' | 'size' | 'variant' | 'suffixIcon' | 'placement' | 'getPopupContainer' | 'defaultOpen' | 'open' | 'onOpenChange'> {
|
|
10
10
|
defaultValue?: T | T[] | null;
|
|
11
11
|
value?: T | T[] | null;
|
|
12
12
|
onChange?: (value: T | T[] | undefined) => void;
|
package/es/Select/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, mergeProps,
|
|
1
|
+
import { delegateEvents, createComponent, mergeProps, insert, effect, className, setAttribute, template } from 'solid-js/web';
|
|
2
2
|
import { splitProps, createMemo, createSelector, Show, For } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import { isEmpty } from 'lodash-es';
|
|
@@ -8,15 +8,18 @@ import SelectInput from '../SelectInput/index.js';
|
|
|
8
8
|
import Empty from '../Empty/index.js';
|
|
9
9
|
import { unwrapStringOrJSXElement } from '../utils/solid.js';
|
|
10
10
|
|
|
11
|
-
var _tmpl$ =
|
|
12
|
-
_tmpl$2 =
|
|
11
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class=p-2px>`),
|
|
12
|
+
_tmpl$2 = /*#__PURE__*/template(`<div>`);
|
|
13
13
|
function Select(props) {
|
|
14
|
-
const [selectInputProps] = splitProps(props, ['multiple', 'allowClear', 'class', 'style', 'disabled', 'placeholder', 'status', 'size', 'variant', 'suffixIcon', 'placement', 'getPopupContainer']);
|
|
14
|
+
const [selectInputProps] = splitProps(props, ['ref', 'multiple', 'allowClear', 'class', 'style', 'disabled', 'placeholder', 'status', 'size', 'variant', 'suffixIcon', 'placement', 'getPopupContainer', 'defaultOpen', 'open', 'onOpenChange']);
|
|
15
15
|
const [value, setValue] = createControllableValue(props);
|
|
16
16
|
const valueArr = createMemo(() => toArray(value(), false));
|
|
17
17
|
const selectedValue = createSelector(() => new Map(valueArr().map(v => [v, true])), (a, b) => b.has(a));
|
|
18
18
|
const optionDict = createMemo(() => new Map(props.options?.map(o => [o.value, o])));
|
|
19
19
|
return createComponent(SelectInput, mergeProps(selectInputProps, {
|
|
20
|
+
get ["class"]() {
|
|
21
|
+
return cs('ant-select', selectInputProps.class);
|
|
22
|
+
},
|
|
20
23
|
labelRender: v => props.labelRender ? props.labelRender(optionDict().get(v), v) : unwrapStringOrJSXElement(optionDict().get(v)?.label) ?? v,
|
|
21
24
|
get value() {
|
|
22
25
|
return valueArr();
|
|
@@ -32,15 +35,44 @@ function Select(props) {
|
|
|
32
35
|
return createComponent(Empty.PRESENTED_IMAGE_SIMPLE, {});
|
|
33
36
|
},
|
|
34
37
|
get children() {
|
|
35
|
-
|
|
38
|
+
var _el$ = _tmpl$();
|
|
39
|
+
insert(_el$, createComponent(For, {
|
|
36
40
|
get each() {
|
|
37
41
|
return props.options;
|
|
38
42
|
},
|
|
39
|
-
children: item =>
|
|
40
|
-
|
|
43
|
+
children: item => (() => {
|
|
44
|
+
var _el$2 = _tmpl$2();
|
|
45
|
+
_el$2.$$click = () => {
|
|
46
|
+
if (!props.multiple) {
|
|
47
|
+
setValue(item.value);
|
|
48
|
+
close();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (valueArr().includes(item.value)) {
|
|
52
|
+
setValue(valueArr().filter(v => v !== item.value));
|
|
53
|
+
} else {
|
|
54
|
+
setValue([...valueArr(), item.value]);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
insert(_el$2, () => unwrapStringOrJSXElement(item.label));
|
|
58
|
+
effect(_p$ => {
|
|
59
|
+
var _v$ = cs('ant-select-item', 'ellipsis box-content px-12px py-5px min-h-22px leading-22px hover:bg-[var(--ant-select-option-active-bg)] cursor-pointer rounded-[var(--ant-border-radius-sm)]', selectedValue(item.value) ? '!bg-[var(--ant-select-option-selected-bg)]' : '', item.class),
|
|
60
|
+
_v$2 = typeof item.label === 'string' || typeof item.label === 'number' ? item.label.toString() : undefined;
|
|
61
|
+
_v$ !== _p$.e && className(_el$2, _p$.e = _v$);
|
|
62
|
+
_v$2 !== _p$.t && setAttribute(_el$2, "title", _p$.t = _v$2);
|
|
63
|
+
return _p$;
|
|
64
|
+
}, {
|
|
65
|
+
e: undefined,
|
|
66
|
+
t: undefined
|
|
67
|
+
});
|
|
68
|
+
return _el$2;
|
|
69
|
+
})()
|
|
70
|
+
}));
|
|
71
|
+
return _el$;
|
|
41
72
|
}
|
|
42
73
|
})
|
|
43
74
|
}));
|
|
44
75
|
}
|
|
76
|
+
delegateEvents(["click"]);
|
|
45
77
|
|
|
46
78
|
export { Select as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type JSXElement, type JSX } from 'solid-js';
|
|
1
|
+
import { type JSXElement, type JSX, type Ref } from 'solid-js';
|
|
2
2
|
import { type TooltipProps } from '../Tooltip';
|
|
3
3
|
export interface SelectInputProps<T> extends Pick<TooltipProps, 'getPopupContainer' | 'defaultOpen' | 'open' | 'onOpenChange'> {
|
|
4
|
+
ref?: Ref<HTMLDivElement>;
|
|
4
5
|
multiple?: boolean;
|
|
5
6
|
defaultValue?: T[] | null;
|
|
6
7
|
value?: T[] | null;
|