antd-solid 0.0.35 → 0.0.37
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 +96 -61
- package/dist/index.umd.js +1 -1
- package/es/ColorPicker/ColorPickerInput.js +9 -9
- package/es/ColorPicker/ColorPickerSelect.js +10 -7
- package/es/ColorPicker/ColorPickerSlider.js +18 -11
- package/es/ColorPicker/context.d.ts +4 -1
- package/es/ColorPicker/index.js +22 -6
- package/es/Input/index.js +1 -1
- package/es/Tooltip/index.js +39 -30
- package/package.json +1 -1
|
@@ -52,7 +52,7 @@ const ColorPickerInput = () => {
|
|
|
52
52
|
},
|
|
53
53
|
get children() {
|
|
54
54
|
return createComponent(Input, {
|
|
55
|
-
|
|
55
|
+
rootClass: "ant-color-picker-hex-input",
|
|
56
56
|
size: "small",
|
|
57
57
|
get value() {
|
|
58
58
|
return hexInputValue();
|
|
@@ -73,7 +73,7 @@ const ColorPickerInput = () => {
|
|
|
73
73
|
get prefix() {
|
|
74
74
|
return _tmpl$3();
|
|
75
75
|
},
|
|
76
|
-
|
|
76
|
+
rootStyle: {
|
|
77
77
|
'--ant-input-font-size': '12px'
|
|
78
78
|
}
|
|
79
79
|
});
|
|
@@ -100,7 +100,7 @@ const ColorPickerInput = () => {
|
|
|
100
100
|
min: 0,
|
|
101
101
|
max: 359,
|
|
102
102
|
precision: 0,
|
|
103
|
-
|
|
103
|
+
rootStyle: InputNumberStyle
|
|
104
104
|
}), null);
|
|
105
105
|
insert(_el$2, createComponent(InputNumber, {
|
|
106
106
|
size: "small",
|
|
@@ -119,7 +119,7 @@ const ColorPickerInput = () => {
|
|
|
119
119
|
max: 100,
|
|
120
120
|
precision: 0,
|
|
121
121
|
formatter: value => `${value || 0}%`,
|
|
122
|
-
|
|
122
|
+
rootStyle: InputNumberStyle
|
|
123
123
|
}), null);
|
|
124
124
|
insert(_el$2, createComponent(InputNumber, {
|
|
125
125
|
size: "small",
|
|
@@ -138,7 +138,7 @@ const ColorPickerInput = () => {
|
|
|
138
138
|
max: 100,
|
|
139
139
|
precision: 0,
|
|
140
140
|
formatter: value => `${value || 0}%`,
|
|
141
|
-
|
|
141
|
+
rootStyle: InputNumberStyle
|
|
142
142
|
}), null);
|
|
143
143
|
return _el$2;
|
|
144
144
|
}
|
|
@@ -164,7 +164,7 @@ const ColorPickerInput = () => {
|
|
|
164
164
|
min: 0,
|
|
165
165
|
max: 255,
|
|
166
166
|
precision: 0,
|
|
167
|
-
|
|
167
|
+
rootStyle: InputNumberStyle
|
|
168
168
|
}), null);
|
|
169
169
|
insert(_el$3, createComponent(InputNumber, {
|
|
170
170
|
size: "small",
|
|
@@ -182,7 +182,7 @@ const ColorPickerInput = () => {
|
|
|
182
182
|
min: 0,
|
|
183
183
|
max: 255,
|
|
184
184
|
precision: 0,
|
|
185
|
-
|
|
185
|
+
rootStyle: InputNumberStyle
|
|
186
186
|
}), null);
|
|
187
187
|
insert(_el$3, createComponent(InputNumber, {
|
|
188
188
|
size: "small",
|
|
@@ -200,7 +200,7 @@ const ColorPickerInput = () => {
|
|
|
200
200
|
min: 0,
|
|
201
201
|
max: 255,
|
|
202
202
|
precision: 0,
|
|
203
|
-
|
|
203
|
+
rootStyle: InputNumberStyle
|
|
204
204
|
}), null);
|
|
205
205
|
return _el$3;
|
|
206
206
|
}
|
|
@@ -227,7 +227,7 @@ const ColorPickerInput = () => {
|
|
|
227
227
|
max: 100,
|
|
228
228
|
precision: 0,
|
|
229
229
|
formatter: value => `${value || 0}%`,
|
|
230
|
-
get
|
|
230
|
+
get rootStyle() {
|
|
231
231
|
return {
|
|
232
232
|
...InputNumberStyle,
|
|
233
233
|
'margin-left': 'var(--ant-margin-xxs)'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { delegateEvents, effect, template, use } from 'solid-js/web';
|
|
2
|
-
import { useContext
|
|
2
|
+
import { useContext } from 'solid-js';
|
|
3
3
|
import { clamp } from 'lodash-es';
|
|
4
4
|
import ColorPickerContext from './context.js';
|
|
5
5
|
import Color from './color.js';
|
|
@@ -8,8 +8,11 @@ import { setupGlobalDrag } from '../utils/setupGlobalDrag.js';
|
|
|
8
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">`);
|
|
9
9
|
const ColorPickerSelect = () => {
|
|
10
10
|
let ref;
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const {
|
|
12
|
+
color,
|
|
13
|
+
setColor: _setColor,
|
|
14
|
+
hsvColor
|
|
15
|
+
} = useContext(ColorPickerContext);
|
|
13
16
|
const setColor = (e, completed) => {
|
|
14
17
|
if (!ref) return;
|
|
15
18
|
const rect = ref.getBoundingClientRect();
|
|
@@ -19,10 +22,10 @@ const ColorPickerSelect = () => {
|
|
|
19
22
|
clientWidth,
|
|
20
23
|
clientHeight
|
|
21
24
|
} = ref;
|
|
22
|
-
const hsv =
|
|
25
|
+
const hsv = hsvColor().toHsv();
|
|
23
26
|
hsv.s = clamp(offsetX / clientWidth, 0, 1);
|
|
24
27
|
hsv.v = clamp(1 - offsetY / clientHeight, 0, 1);
|
|
25
|
-
|
|
28
|
+
_setColor(new Color(hsv), completed);
|
|
26
29
|
};
|
|
27
30
|
return (() => {
|
|
28
31
|
var _el$ = _tmpl$(),
|
|
@@ -43,12 +46,12 @@ const ColorPickerSelect = () => {
|
|
|
43
46
|
},
|
|
44
47
|
// eslint-disable-next-line solid/reactivity
|
|
45
48
|
() => {
|
|
46
|
-
if (isDrag)
|
|
49
|
+
if (isDrag) _setColor(color(), true);
|
|
47
50
|
});
|
|
48
51
|
};
|
|
49
52
|
_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
53
|
effect(_p$ => {
|
|
51
|
-
var _v$ =
|
|
54
|
+
var _v$ = hsvColor().toHueRgbString(),
|
|
52
55
|
_v$2 = `${color().toHsv().s * 100}%`,
|
|
53
56
|
_v$3 = `${(1 - color().toHsv().v) * 100}%`,
|
|
54
57
|
_v$4 = color().toRgbString();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { delegateEvents, insert, createComponent, memo, effect, className, template } from 'solid-js/web';
|
|
2
|
-
import { useContext,
|
|
2
|
+
import { useContext, Show } from 'solid-js';
|
|
3
3
|
import cs from 'classnames';
|
|
4
4
|
import ColorPickerContext from './context.js';
|
|
5
5
|
import Slider from '../Slider/index.js';
|
|
@@ -10,8 +10,14 @@ var _tmpl$ = /*#__PURE__*/template(`<div class="flex gap-[--ant-margin-sm] items
|
|
|
10
10
|
_tmpl$2 = /*#__PURE__*/template(`<span class="shrink-0 text-18px cursor-pointer">`),
|
|
11
11
|
_tmpl$3 = /*#__PURE__*/template(`<div tabindex=0>`);
|
|
12
12
|
const ColorPickerSlider = () => {
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const {
|
|
14
|
+
color,
|
|
15
|
+
setColor,
|
|
16
|
+
h,
|
|
17
|
+
setH,
|
|
18
|
+
hsvColor,
|
|
19
|
+
disabledAlpha
|
|
20
|
+
} = useContext(ColorPickerContext);
|
|
15
21
|
return (() => {
|
|
16
22
|
var _el$ = _tmpl$(),
|
|
17
23
|
_el$2 = _el$.firstChild,
|
|
@@ -19,18 +25,19 @@ const ColorPickerSlider = () => {
|
|
|
19
25
|
_el$4 = _el$3.firstChild;
|
|
20
26
|
insert(_el$2, createComponent(Slider, {
|
|
21
27
|
get value() {
|
|
22
|
-
return
|
|
28
|
+
return h() / 3.55;
|
|
23
29
|
},
|
|
24
30
|
onChange: v => {
|
|
25
31
|
const hsv = color().toHsv();
|
|
26
32
|
hsv.h = Math.round(v * 3.55);
|
|
27
|
-
|
|
33
|
+
setH(hsv.h);
|
|
34
|
+
setColor(new Color(hsv));
|
|
28
35
|
},
|
|
29
36
|
onChangeComplete: () => {
|
|
30
|
-
|
|
37
|
+
setColor(color(), true);
|
|
31
38
|
},
|
|
32
39
|
tooltip: false,
|
|
33
|
-
handle: () => getSliderHandle(
|
|
40
|
+
handle: () => getSliderHandle(hsvColor().toHueRgbString()),
|
|
34
41
|
style: {
|
|
35
42
|
'--ant-slider-rail-size': '8px',
|
|
36
43
|
'--ant-slider-handle-size': '10px',
|
|
@@ -45,7 +52,7 @@ const ColorPickerSlider = () => {
|
|
|
45
52
|
}), null);
|
|
46
53
|
insert(_el$2, createComponent(Show, {
|
|
47
54
|
get when() {
|
|
48
|
-
return !
|
|
55
|
+
return !disabledAlpha();
|
|
49
56
|
},
|
|
50
57
|
get children() {
|
|
51
58
|
return createComponent(Slider, {
|
|
@@ -53,10 +60,10 @@ const ColorPickerSlider = () => {
|
|
|
53
60
|
return color().a * 100;
|
|
54
61
|
},
|
|
55
62
|
onChange: v => {
|
|
56
|
-
|
|
63
|
+
setColor(color().clone().setAlpha(v / 100));
|
|
57
64
|
},
|
|
58
65
|
onChangeComplete: () => {
|
|
59
|
-
|
|
66
|
+
setColor(color(), true);
|
|
60
67
|
},
|
|
61
68
|
min: 0,
|
|
62
69
|
step: 1,
|
|
@@ -91,7 +98,7 @@ const ColorPickerSlider = () => {
|
|
|
91
98
|
if (!window.EyeDropper) return;
|
|
92
99
|
const eyeDropper = new window.EyeDropper();
|
|
93
100
|
eyeDropper.open().then(result => {
|
|
94
|
-
|
|
101
|
+
setColor(new Color(result.sRGBHex), true);
|
|
95
102
|
}).catch(console.error);
|
|
96
103
|
};
|
|
97
104
|
insert(_el$5, createComponent(ColorPickUpSvg, {}));
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { type Accessor } from 'solid-js';
|
|
1
|
+
import { type Accessor, type Setter } from 'solid-js';
|
|
2
2
|
import type Color from './color';
|
|
3
3
|
interface ColorPickerContextProps {
|
|
4
4
|
color: Accessor<Color>;
|
|
5
5
|
setColor: (color: Color, completed?: boolean) => void;
|
|
6
6
|
disabledAlpha: Accessor<boolean>;
|
|
7
|
+
h: Accessor<number>;
|
|
8
|
+
setH: Setter<number>;
|
|
9
|
+
hsvColor: Accessor<Color>;
|
|
7
10
|
}
|
|
8
11
|
declare const ColorPickerContext: import("solid-js").Context<ColorPickerContextProps | undefined>;
|
|
9
12
|
export default ColorPickerContext;
|
package/es/ColorPicker/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { delegateEvents, createComponent, insert, effect, className, template } from 'solid-js/web';
|
|
2
2
|
import cs from 'classnames';
|
|
3
|
-
import { createSignal, untrack,
|
|
3
|
+
import { createSignal, untrack, createComputed, createMemo, on, Show } from 'solid-js';
|
|
4
4
|
import Color from './color.js';
|
|
5
5
|
import Element from '../Element/index.js';
|
|
6
6
|
import Popover from '../Popover/index.js';
|
|
@@ -18,8 +18,8 @@ var _tmpl$ = /*#__PURE__*/template(`<div class="flex justify-end mb-[--ant-margi
|
|
|
18
18
|
// TODO 超出范围
|
|
19
19
|
const ColorPicker = props => {
|
|
20
20
|
const isControlled = () => Object.keys(props).includes('value');
|
|
21
|
-
const [
|
|
22
|
-
|
|
21
|
+
const [color, _setInnerColor] = createSignal(untrack(() => new Color(props.defaultValue)));
|
|
22
|
+
createComputed(() => {
|
|
23
23
|
if (isControlled()) {
|
|
24
24
|
_setInnerColor(new Color(props.value));
|
|
25
25
|
}
|
|
@@ -33,12 +33,28 @@ const ColorPicker = props => {
|
|
|
33
33
|
};
|
|
34
34
|
const [open, setOpen] = createSignal(false);
|
|
35
35
|
const size = useComponentSize(() => props.size);
|
|
36
|
-
const
|
|
36
|
+
const [h, setH] = createSignal(0);
|
|
37
|
+
const hsvColor = createMemo(() => {
|
|
38
|
+
const hsv = color().toHsv();
|
|
39
|
+
return new Color({
|
|
40
|
+
h: h(),
|
|
41
|
+
s: hsv.s,
|
|
42
|
+
v: hsv.v
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
// 只有在 hex 被修改时才更新
|
|
46
|
+
createComputed(on(() => color().toHex8String(), (hex, prev) => {
|
|
47
|
+
if (hex === prev) return;
|
|
48
|
+
setH(new Color(hex).toHsv().h);
|
|
49
|
+
}));
|
|
37
50
|
const getPopoverContent = close => createComponent(ColorPickerContext.Provider, {
|
|
38
51
|
value: {
|
|
39
|
-
color
|
|
52
|
+
color,
|
|
40
53
|
setColor,
|
|
41
|
-
disabledAlpha
|
|
54
|
+
disabledAlpha,
|
|
55
|
+
h,
|
|
56
|
+
setH,
|
|
57
|
+
hsvColor
|
|
42
58
|
},
|
|
43
59
|
get children() {
|
|
44
60
|
return [createComponent(Show, {
|
package/es/Input/index.js
CHANGED
|
@@ -49,7 +49,7 @@ function CommonInput(props) {
|
|
|
49
49
|
const {
|
|
50
50
|
compact
|
|
51
51
|
} = useContext(CompactContext);
|
|
52
|
-
const [_, inputProps] = splitProps(props, ['defaultValue', 'value', 'onChange', 'onPressEnter', 'onKeyDown', 'size', 'autoFocus', 'status', 'actions', 'addonBefore', 'addonAfter', 'prefix', 'suffix', 'allowClear']);
|
|
52
|
+
const [_, inputProps] = splitProps(props, ['defaultValue', 'value', 'onChange', 'onPressEnter', 'onKeyDown', 'size', 'autoFocus', 'status', 'actions', 'addonBefore', 'addonAfter', 'prefix', 'suffix', 'allowClear', 'rootClass', 'rootStyle']);
|
|
53
53
|
let inputRef;
|
|
54
54
|
const foucs = useFocus(() => inputRef);
|
|
55
55
|
onMount(() => {
|
package/es/Tooltip/index.js
CHANGED
|
@@ -11,8 +11,8 @@ import useHover from '../hooks/useHover.js';
|
|
|
11
11
|
import Element$1 from '../Element/index.js';
|
|
12
12
|
import TooltipContext from './context.js';
|
|
13
13
|
|
|
14
|
-
var _tmpl$ = /*#__PURE__*/template(`<div>`),
|
|
15
|
-
_tmpl$2 = /*#__PURE__*/template(`<div
|
|
14
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class="relative overflow-auto [box-shadow:--ant-box-shadow] rounded-[--ant-border-radius-lg]"><div>`),
|
|
15
|
+
_tmpl$2 = /*#__PURE__*/template(`<div>`);
|
|
16
16
|
const unwrapContent = (content, close) => {
|
|
17
17
|
return typeof content === 'function' ? content(close) : content;
|
|
18
18
|
};
|
|
@@ -312,7 +312,7 @@ const Tooltip = _props => {
|
|
|
312
312
|
switch (mainPlacement) {
|
|
313
313
|
case 'top':
|
|
314
314
|
translateY = _childrenRect.top - arrowOffset() - defaultOffset - _contentSize.height;
|
|
315
|
-
setMaxHeight(translateY);
|
|
315
|
+
setMaxHeight(translateY + _contentSize.height);
|
|
316
316
|
break;
|
|
317
317
|
case 'bottom':
|
|
318
318
|
translateY = _childrenRect.bottom + arrowOffset() + defaultOffset;
|
|
@@ -320,7 +320,7 @@ const Tooltip = _props => {
|
|
|
320
320
|
break;
|
|
321
321
|
case 'left':
|
|
322
322
|
translateX = _childrenRect.left - arrowOffset() - defaultOffset - _contentSize.width;
|
|
323
|
-
setMaxWidth(translateX);
|
|
323
|
+
setMaxWidth(translateX + _contentSize.width);
|
|
324
324
|
break;
|
|
325
325
|
case 'right':
|
|
326
326
|
translateX = _childrenRect.right + arrowOffset() + defaultOffset;
|
|
@@ -443,48 +443,58 @@ const Tooltip = _props => {
|
|
|
443
443
|
get children() {
|
|
444
444
|
return createComponent(Element$1, {
|
|
445
445
|
get ["class"]() {
|
|
446
|
-
return cs('z-1000 fixed left-0 top-0 [font-size:var(--ant-font-size)] text-[--ant-color-text] leading-[--ant-line-height]
|
|
446
|
+
return cs('z-1000 fixed left-0 top-0 [font-size:var(--ant-font-size)] text-[--ant-color-text] leading-[--ant-line-height]', open() ? 'block' : 'hidden');
|
|
447
447
|
},
|
|
448
448
|
get style() {
|
|
449
449
|
return {
|
|
450
|
-
transform: `translate(${_translateX()}px, ${_translateY()}px)
|
|
451
|
-
'max-width': typeof maxWidth() === 'number' ? `${maxWidth()}px` : undefined,
|
|
452
|
-
'max-height': typeof maxHeight() === 'number' ? `${maxHeight()}px` : undefined
|
|
450
|
+
transform: `translate(${_translateX()}px, ${_translateY()}px)`
|
|
453
451
|
};
|
|
454
452
|
},
|
|
455
453
|
onClick: e => {
|
|
456
454
|
e.stopPropagation();
|
|
457
455
|
},
|
|
458
456
|
get children() {
|
|
459
|
-
|
|
460
|
-
_el$
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
457
|
+
return [(() => {
|
|
458
|
+
var _el$ = _tmpl$(),
|
|
459
|
+
_el$2 = _el$.firstChild;
|
|
460
|
+
use(setPopupRef, _el$2);
|
|
461
|
+
spread(_el$2, mergeProps$1(() => props.contentHTMLAttributes, {
|
|
462
|
+
get ["class"]() {
|
|
463
|
+
return cs(props.contentHTMLAttributes?.class, 'px-8px py-6px translate-x-[--inner-translate-x] translate-y-[--inner-translate-y]', props.plain ? 'text-[var(--ant-color-text)] bg-[var(--ant-color-bg-container-tertiary)]' : 'text-[var(--ant-color-text-light-solid)] bg-[var(--ant-color-bg-spotlight)]');
|
|
464
|
+
}
|
|
465
|
+
}), false, true);
|
|
466
|
+
insert(_el$2, createComponent(TooltipContext.Provider, {
|
|
467
|
+
value: context,
|
|
468
|
+
get children() {
|
|
469
|
+
return unwrapContent(props.content, () => setOpen(false));
|
|
470
|
+
}
|
|
471
|
+
}));
|
|
472
|
+
effect(_p$ => {
|
|
473
|
+
var _v$ = typeof maxWidth() === 'number' ? `${maxWidth()}px` : undefined,
|
|
474
|
+
_v$2 = typeof maxHeight() === 'number' ? `${maxHeight()}px` : undefined;
|
|
475
|
+
_v$ !== _p$.e && ((_p$.e = _v$) != null ? _el$.style.setProperty("max-width", _v$) : _el$.style.removeProperty("max-width"));
|
|
476
|
+
_v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("max-height", _v$2) : _el$.style.removeProperty("max-height"));
|
|
477
|
+
return _p$;
|
|
478
|
+
}, {
|
|
479
|
+
e: undefined,
|
|
480
|
+
t: undefined
|
|
481
|
+
});
|
|
482
|
+
return _el$;
|
|
483
|
+
})(), createComponent(Show, {
|
|
474
484
|
get when() {
|
|
475
485
|
return props.arrow;
|
|
476
486
|
},
|
|
477
487
|
get children() {
|
|
478
|
-
var _el$3 = _tmpl$();
|
|
488
|
+
var _el$3 = _tmpl$2();
|
|
479
489
|
effect(_p$ => {
|
|
480
|
-
var _v$ = cs('w-8px h-8px absolute border-transparent [box-shadow:var(--ant-box-shadow)]'),
|
|
481
|
-
_v$
|
|
490
|
+
var _v$3 = cs('w-8px h-8px absolute border-transparent [box-shadow:var(--ant-box-shadow)]'),
|
|
491
|
+
_v$4 = {
|
|
482
492
|
'clip-path': 'polygon(-100% -100%, 200% -100%, 200% 200%)',
|
|
483
493
|
'background-color': props.plain ? 'var(--ant-color-bg-container-tertiary)' : 'var(--ant-color-bg-spotlight)',
|
|
484
494
|
...ARROW_STYLE_DICT[mergePlacement(reversedMainPlacement(), reversedMinorPlacement())]
|
|
485
495
|
};
|
|
486
|
-
_v$ !== _p$.e && className(_el$3, _p$.e = _v$);
|
|
487
|
-
_p$.t = style(_el$3, _v$
|
|
496
|
+
_v$3 !== _p$.e && className(_el$3, _p$.e = _v$3);
|
|
497
|
+
_p$.t = style(_el$3, _v$4, _p$.t);
|
|
488
498
|
return _p$;
|
|
489
499
|
}, {
|
|
490
500
|
e: undefined,
|
|
@@ -492,8 +502,7 @@ const Tooltip = _props => {
|
|
|
492
502
|
});
|
|
493
503
|
return _el$3;
|
|
494
504
|
}
|
|
495
|
-
})
|
|
496
|
-
return _el$;
|
|
505
|
+
})];
|
|
497
506
|
}
|
|
498
507
|
});
|
|
499
508
|
}
|