antd-solid 0.0.11 → 0.0.13
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 +10 -73
- package/dist/index.esm.js +7802 -2378
- package/dist/index.umd.js +1 -1
- package/es/Alert/index.d.ts +10 -0
- package/es/Alert/index.js +26 -0
- package/es/Button/index.d.ts +32 -0
- package/es/Button/index.js +123 -0
- package/es/Button/index.scss.js +6 -0
- package/es/Checkbox/Group.d.ts +19 -0
- package/es/Checkbox/Group.js +49 -0
- package/es/Checkbox/index.d.ts +15 -0
- package/es/Checkbox/index.js +60 -0
- package/es/CodeInput/index.d.ts +18 -0
- package/es/CodeInput/index.js +72 -0
- package/es/Collapse/Item.d.ts +46 -0
- package/es/Collapse/Item.js +130 -0
- package/es/Collapse/context.d.ts +5 -0
- package/es/Collapse/context.js +8 -0
- package/es/Collapse/index.d.ts +25 -10
- package/es/Collapse/index.js +95 -74
- package/es/Collapse/utils.d.ts +8 -0
- package/es/Collapse/utils.js +35 -0
- package/es/ColorPicker/ColorPickerInput.d.ts +3 -0
- package/es/ColorPicker/ColorPickerInput.js +250 -0
- package/es/ColorPicker/ColorPickerSelect.d.ts +3 -0
- package/es/ColorPicker/ColorPickerSelect.js +71 -0
- package/es/ColorPicker/ColorPickerSlider.d.ts +3 -0
- package/es/ColorPicker/ColorPickerSlider.js +115 -0
- package/es/ColorPicker/color.d.ts +24 -0
- package/es/ColorPicker/color.js +63 -0
- package/es/ColorPicker/context.d.ts +9 -0
- package/es/ColorPicker/context.js +5 -0
- package/es/ColorPicker/index.d.ts +31 -0
- package/es/ColorPicker/index.js +139 -0
- package/es/Command/context.d.ts +9 -0
- package/es/Command/context.js +11 -0
- package/es/Command/createCommand.d.ts +17 -0
- package/es/Command/createCommand.js +112 -0
- package/es/Command/index.d.ts +7 -0
- package/es/Command/index.js +9 -0
- package/es/Command/useCommandProps.d.ts +13 -0
- package/es/Command/useCommandProps.js +28 -0
- package/es/Compact/CompactContextIsolator.d.ts +3 -0
- package/es/Compact/CompactContextIsolator.js +15 -0
- package/es/Compact/context.d.ts +4 -0
- package/es/Compact/context.js +7 -0
- package/es/Compact/index.d.ts +14 -0
- package/es/Compact/index.js +32 -0
- package/es/Compact/index.scss.js +6 -0
- package/es/ConfigProvider/context.d.ts +11 -0
- package/es/ConfigProvider/context.js +15 -0
- package/es/ConfigProvider/dark/colorAlgorithm.d.ts +2 -0
- package/es/ConfigProvider/dark/colorAlgorithm.js +9 -0
- package/es/ConfigProvider/dark/colors.d.ts +3 -0
- package/es/ConfigProvider/dark/colors.js +47 -0
- package/es/ConfigProvider/dark/index.d.ts +2 -0
- package/es/ConfigProvider/dark/index.js +11 -0
- package/es/ConfigProvider/index.d.ts +32 -0
- package/es/ConfigProvider/index.js +44 -0
- package/es/ConfigProvider/light/colorAlgorithm.d.ts +2 -0
- package/es/ConfigProvider/light/colorAlgorithm.js +9 -0
- package/es/ConfigProvider/light/colors.d.ts +3 -0
- package/es/ConfigProvider/light/colors.js +45 -0
- package/es/ConfigProvider/light/index.d.ts +2 -0
- package/es/ConfigProvider/light/index.js +11 -0
- package/es/ConfigProvider/seed.d.ts +3 -0
- package/es/ConfigProvider/seed.js +22 -0
- package/es/ConfigProvider/types/index.d.ts +594 -0
- package/es/ConfigProvider/types/index.js +1 -0
- package/es/ConfigProvider/utils/genColorMapToken.d.ts +7 -0
- package/es/ConfigProvider/utils/genColorMapToken.js +85 -0
- package/es/ConfigProvider/utils/getAlphaColor.d.ts +2 -0
- package/es/ConfigProvider/utils/getAlphaColor.js +44 -0
- package/es/ConfigProvider/utils/index.d.ts +3 -0
- package/es/ConfigProvider/utils/index.js +181 -0
- package/es/ContextMenu/index.d.ts +8 -0
- package/es/ContextMenu/index.js +99 -0
- package/es/Cursor/index.d.ts +6 -0
- package/es/Cursor/index.js +71 -0
- package/es/DelayShow/index.d.ts +16 -0
- package/es/DelayShow/index.js +27 -0
- package/es/Divider/index.d.ts +17 -0
- package/es/Divider/index.js +71 -0
- package/es/Drawer/index.d.ts +20 -16
- package/es/Drawer/index.js +162 -112
- package/es/Drawer/index.scss.js +1 -1
- package/es/Dropdown/index.d.ts +16 -0
- package/es/Dropdown/index.js +47 -0
- package/es/Element/index.d.ts +10 -0
- package/es/Element/index.js +42 -0
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.d.ts +2 -1
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +25 -9
- package/es/Empty/assets/EmptySvg.js +1 -1
- package/es/Empty/assets/SimpleEmptySvg.js +1 -1
- package/es/Empty/index.d.ts +9 -3
- package/es/Empty/index.js +24 -9
- package/es/Form/Form.d.ts +8 -5
- package/es/Form/Form.js +50 -34
- package/es/Form/FormItem.d.ts +10 -5
- package/es/Form/FormItem.js +121 -104
- package/es/Form/context.d.ts +9 -9
- package/es/Form/context.js +4 -2
- package/es/Fragment/index.d.ts +4 -0
- package/es/Fragment/index.js +7 -0
- package/es/Image/index.d.ts +10 -0
- package/es/Image/index.js +37 -0
- package/es/Input/TextArea.d.ts +23 -0
- package/es/Input/TextArea.js +84 -0
- package/es/Input/index.d.ts +44 -0
- package/es/Input/index.js +213 -0
- package/es/Input/index.scss.js +6 -0
- package/es/InputNumber/index.d.ts +30 -0
- package/es/InputNumber/index.js +122 -0
- package/es/{InputNumber.test.js → InputNumber/index.test.js} +2 -1
- package/es/Menu/InternalMenu.d.ts +22 -0
- package/es/Menu/InternalMenu.js +196 -0
- package/es/Menu/index.d.ts +75 -0
- package/es/Menu/index.js +64 -0
- package/es/Message/Message.d.ts +9 -0
- package/es/Message/Message.js +34 -0
- package/es/Message/index.d.ts +12 -0
- package/es/Message/index.js +80 -0
- package/es/Message/index.scss.js +6 -0
- package/es/Message/useMessage.d.ts +6 -0
- package/es/Message/useMessage.js +54 -0
- package/es/Modal/index.d.ts +73 -0
- package/es/Modal/index.js +237 -0
- package/es/Modal/index.scss.js +6 -0
- package/es/Modal/useModal.d.ts +5 -0
- package/es/Modal/useModal.js +51 -0
- package/es/Modal/warning.d.ts +5 -0
- package/es/Modal/warning.js +43 -0
- package/es/{Popconfirm.d.ts → Popconfirm/index.d.ts} +2 -2
- package/es/Popconfirm/index.js +62 -0
- package/es/{Popover.d.ts → Popover/index.d.ts} +2 -2
- package/es/{Popover.js → Popover/index.js} +7 -12
- package/es/Progress/Circle.d.ts +16 -0
- package/es/Progress/Circle.js +122 -0
- package/es/Progress/index.d.ts +6 -4
- package/es/Progress/index.js +75 -60
- package/es/Radio/Button.d.ts +7 -0
- package/es/Radio/Button.js +72 -0
- package/es/Radio/Group.d.ts +18 -0
- package/es/Radio/Group.js +57 -0
- package/es/Radio/index.d.ts +14 -0
- package/es/Radio/index.js +68 -0
- package/es/RangeInput/index.d.ts +23 -0
- package/es/RangeInput/index.js +208 -0
- package/es/Result/index.js +49 -0
- package/es/Segmented/index.d.ts +10 -7
- package/es/Segmented/index.js +54 -53
- package/es/Select/index.d.ts +17 -0
- package/es/Select/index.js +75 -0
- package/es/SelectInput/index.d.ts +39 -0
- package/es/SelectInput/index.js +245 -0
- package/es/Slider/index.d.ts +47 -0
- package/es/Slider/index.js +177 -0
- package/es/Space/index.d.ts +13 -0
- package/es/Space/index.js +16 -0
- package/es/Spin/index.d.ts +19 -0
- package/es/Spin/index.js +82 -0
- package/es/{Switch.d.ts → Switch/index.d.ts} +9 -0
- package/es/Switch/index.js +41 -0
- package/es/{Table.d.ts → Table/index.d.ts} +6 -2
- package/es/Table/index.js +71 -0
- package/es/Tabs/index.d.ts +49 -0
- package/es/Tabs/index.js +256 -0
- package/es/Timeline/index.js +31 -0
- package/es/Tooltip/context.d.ts +5 -0
- package/es/Tooltip/context.js +5 -0
- package/es/Tooltip/index.d.ts +64 -0
- package/es/Tooltip/index.js +499 -0
- package/es/Transformer/index.d.ts +88 -0
- package/es/Transformer/index.js +882 -0
- package/es/Tree/SingleLevelTree.d.ts +28 -0
- package/es/Tree/SingleLevelTree.js +299 -0
- package/es/Tree/index.d.ts +83 -0
- package/es/Tree/index.js +197 -0
- package/es/TreeFor/index.d.ts +31 -0
- package/es/TreeFor/index.js +80 -0
- package/es/TreeSelect/index.d.ts +26 -0
- package/es/TreeSelect/index.js +98 -0
- package/es/Upload/index.d.ts +64 -0
- package/es/Upload/index.js +112 -0
- package/es/assets/svg/ColorPickUp.d.ts +4 -0
- package/es/assets/svg/ColorPickUp.js +25 -0
- package/es/assets/svg/Crosshair.d.ts +7 -0
- package/es/assets/svg/Crosshair.js +51 -0
- package/es/assets/svg/Resize.d.ts +4 -0
- package/es/assets/svg/Resize.js +25 -0
- package/es/assets/svg/Rotate.d.ts +4 -0
- package/es/assets/svg/Rotate.js +20 -0
- package/es/assets/svg/RotateArrow.d.ts +4 -0
- package/es/assets/svg/RotateArrow.js +21 -0
- package/es/assets/svg/common.d.ts +2 -0
- package/es/assets/svg/common.js +9 -0
- package/es/hooks/createControllableValue.d.ts +1 -1
- package/es/hooks/createControllableValue.js +16 -17
- package/es/hooks/createTransition.d.ts +6 -2
- package/es/hooks/createTransition.js +12 -8
- package/es/hooks/useClickAway.d.ts +1 -1
- package/es/hooks/useClickAway.js +4 -3
- package/es/hooks/useComponentSize.d.ts +3 -0
- package/es/hooks/useComponentSize.js +12 -0
- package/es/hooks/useCounter.d.ts +12 -0
- package/es/hooks/useCounter.js +30 -0
- package/es/hooks/useFocus.d.ts +2 -0
- package/es/hooks/useFocus.js +24 -0
- package/es/hooks/useHover.d.ts +2 -0
- package/es/hooks/useHover.js +33 -0
- package/es/hooks/useLocale.d.ts +1 -0
- package/es/hooks/useLocale.js +11 -0
- package/es/hooks/useMouse.d.ts +1 -0
- package/es/hooks/useMouse.js +18 -0
- package/es/hooks/useScroll.d.ts +2 -0
- package/es/hooks/useScroll.js +29 -0
- package/es/hooks/useSize.d.ts +8 -2
- package/es/hooks/useSize.js +25 -13
- package/es/hooks/useVirtualList.d.ts +14 -0
- package/es/hooks/useVirtualList.js +45 -0
- package/es/index.d.ts +59 -8
- package/es/index.js +53 -23
- package/es/locale/en_US.d.ts +3 -0
- package/es/locale/en_US.js +9 -0
- package/es/locale/index.d.ts +5 -0
- package/es/locale/index.js +1 -0
- package/es/locale/zh_CN.d.ts +3 -0
- package/es/locale/zh_CN.js +9 -0
- package/es/types/index.d.ts +11 -2
- package/es/utils/animation.d.ts +6 -0
- package/es/utils/animation.js +20 -0
- package/es/utils/array.d.ts +2 -1
- package/es/utils/array.js +5 -1
- package/es/utils/domPoint.d.ts +7 -0
- package/es/utils/domPoint.js +11 -0
- package/es/utils/math.d.ts +17 -0
- package/es/utils/math.js +25 -0
- package/es/utils/number.d.ts +1 -0
- package/es/utils/number.js +14 -0
- package/es/utils/setupGlobalDrag.d.ts +10 -0
- package/es/utils/setupGlobalDrag.js +38 -0
- package/es/utils/solid.d.ts +2 -2
- package/es/utils/solid.js +7 -8
- package/package.json +10 -11
- package/es/Button.d.ts +0 -19
- package/es/Button.js +0 -73
- package/es/ColorPicker.d.ts +0 -8
- package/es/ColorPicker.js +0 -6
- package/es/Compact.d.ts +0 -12
- package/es/Compact.js +0 -17
- package/es/DatePicker.d.ts +0 -19
- package/es/DatePicker.js +0 -9
- package/es/Image.d.ts +0 -9
- package/es/Image.js +0 -22
- package/es/Input.d.ts +0 -29
- package/es/Input.js +0 -144
- package/es/InputNumber.d.ts +0 -11
- package/es/InputNumber.js +0 -92
- package/es/Modal.d.ts +0 -48
- package/es/Modal.js +0 -209
- package/es/Popconfirm.js +0 -64
- package/es/Radio.d.ts +0 -27
- package/es/Radio.js +0 -93
- package/es/Result.js +0 -29
- package/es/Select.d.ts +0 -16
- package/es/Select.js +0 -113
- package/es/Skeleton.d.ts +0 -9
- package/es/Skeleton.js +0 -9
- package/es/Spin.d.ts +0 -9
- package/es/Spin.js +0 -22
- package/es/Switch.js +0 -30
- package/es/Table.js +0 -57
- package/es/Tabs.d.ts +0 -17
- package/es/Tabs.js +0 -117
- package/es/Timeline.js +0 -30
- package/es/Tooltip.d.ts +0 -34
- package/es/Tooltip.js +0 -302
- package/es/Tree.d.ts +0 -28
- package/es/Tree.js +0 -198
- package/es/Upload.d.ts +0 -11
- package/es/Upload.js +0 -6
- package/es/hooks/createUpdateEffect.d.ts +0 -5
- package/es/hooks/createUpdateEffect.js +0 -12
- package/es/utils/EventEmitter.d.ts +0 -7
- package/es/utils/EventEmitter.js +0 -13
- package/es/utils/ReactToSolid.d.ts +0 -8
- package/es/utils/ReactToSolid.js +0 -30
- package/es/utils/SolidToReact.d.ts +0 -8
- package/es/utils/SolidToReact.js +0 -23
- package/es/utils/component.d.ts +0 -31
- package/es/utils/component.js +0 -68
- package/es/utils/zh_CN.d.ts +0 -2
- package/es/utils/zh_CN.js +0 -236
- package/src/Button.tsx +0 -128
- package/src/Collapse/index.tsx +0 -86
- package/src/ColorPicker.tsx +0 -11
- package/src/Compact.tsx +0 -15
- package/src/DatePicker.tsx +0 -30
- package/src/Drawer/index.scss +0 -53
- package/src/Drawer/index.tsx +0 -212
- package/src/Empty/PRESENTED_IMAGE_SIMPLE.tsx +0 -15
- package/src/Empty/assets/EmptySvg.tsx +0 -43
- package/src/Empty/assets/SimpleEmptySvg.tsx +0 -16
- package/src/Empty/index.tsx +0 -20
- package/src/Form/Form.tsx +0 -94
- package/src/Form/FormItem.tsx +0 -141
- package/src/Form/context.ts +0 -16
- package/src/Form/index.ts +0 -13
- package/src/Image.tsx +0 -29
- package/src/Input.tsx +0 -202
- package/src/InputNumber.test.tsx +0 -46
- package/src/InputNumber.tsx +0 -125
- package/src/Modal.tsx +0 -220
- package/src/Popconfirm.tsx +0 -75
- package/src/Popover.tsx +0 -30
- package/src/Progress/index.tsx +0 -73
- package/src/Radio.tsx +0 -142
- package/src/Result.tsx +0 -38
- package/src/Segmented/index.tsx +0 -95
- package/src/Select.tsx +0 -128
- package/src/Skeleton.tsx +0 -14
- package/src/Spin.tsx +0 -23
- package/src/Switch.tsx +0 -34
- package/src/Table.tsx +0 -53
- package/src/Tabs.tsx +0 -131
- package/src/Timeline.tsx +0 -33
- package/src/Tooltip.tsx +0 -340
- package/src/Tree.tsx +0 -246
- package/src/Upload.tsx +0 -10
- package/src/hooks/createControllableValue.ts +0 -68
- package/src/hooks/createTransition.ts +0 -52
- package/src/hooks/createUpdateEffect.ts +0 -16
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useClickAway.ts +0 -18
- package/src/hooks/useSize.ts +0 -26
- package/src/index.ts +0 -47
- package/src/types/index.ts +0 -5
- package/src/utils/EventEmitter.ts +0 -15
- package/src/utils/ReactToSolid.tsx +0 -38
- package/src/utils/SolidToReact.tsx +0 -27
- package/src/utils/array.ts +0 -21
- package/src/utils/component.tsx +0 -85
- package/src/utils/solid.ts +0 -61
- package/src/utils/zh_CN.ts +0 -236
- /package/es/{InputNumber.test.d.ts → InputNumber/index.test.d.ts} +0 -0
- /package/es/{Result.d.ts → Result/index.d.ts} +0 -0
- /package/es/{Timeline.d.ts → Timeline/index.d.ts} +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { delegateEvents, insert, createComponent, memo, effect, className, template } from 'solid-js/web';
|
|
2
|
+
import { useContext, createMemo, Show } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import ColorPickerContext from './context.js';
|
|
5
|
+
import Slider from '../Slider/index.js';
|
|
6
|
+
import Color from './color.js';
|
|
7
|
+
import ColorPickUpSvg from '../assets/svg/ColorPickUp.js';
|
|
8
|
+
|
|
9
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class="flex gap-[--ant-margin-sm] items-center"><div class="flex flex-col gap-[--ant-margin-sm] w-full"></div><div class="shrink-0 w-28px h-28px rounded-[--ant-border-radius-sm]"><div class="w-full h-full rounded-inherit">`),
|
|
10
|
+
_tmpl$2 = /*#__PURE__*/template(`<span class="shrink-0 text-18px cursor-pointer">`),
|
|
11
|
+
_tmpl$3 = /*#__PURE__*/template(`<div tabindex=0>`);
|
|
12
|
+
const ColorPickerSlider = () => {
|
|
13
|
+
const context = useContext(ColorPickerContext);
|
|
14
|
+
const color = createMemo(() => context?.color() ?? new Color());
|
|
15
|
+
return (() => {
|
|
16
|
+
var _el$ = _tmpl$(),
|
|
17
|
+
_el$2 = _el$.firstChild,
|
|
18
|
+
_el$3 = _el$2.nextSibling,
|
|
19
|
+
_el$4 = _el$3.firstChild;
|
|
20
|
+
insert(_el$2, createComponent(Slider, {
|
|
21
|
+
get value() {
|
|
22
|
+
return color().toHsv().h / 3.55;
|
|
23
|
+
},
|
|
24
|
+
onChange: v => {
|
|
25
|
+
const hsv = color().toHsv();
|
|
26
|
+
hsv.h = Math.round(v * 3.55);
|
|
27
|
+
context?.setColor(new Color(hsv));
|
|
28
|
+
},
|
|
29
|
+
onChangeComplete: () => {
|
|
30
|
+
context?.setColor(color(), true);
|
|
31
|
+
},
|
|
32
|
+
tooltip: false,
|
|
33
|
+
handle: () => getSliderHandle(color().toHueRgbString()),
|
|
34
|
+
style: {
|
|
35
|
+
'--ant-slider-rail-size': '8px',
|
|
36
|
+
'--ant-slider-handle-size': '10px',
|
|
37
|
+
'--ant-slider-rail-bg': 'linear-gradient(90deg, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)',
|
|
38
|
+
'--ant-slider-rail-hover-bg': 'var(--ant-slider-rail-bg)',
|
|
39
|
+
'--ant-slider-track-bg': 'transparent',
|
|
40
|
+
'--ant-slider-track-hover-bg': 'transparent'
|
|
41
|
+
},
|
|
42
|
+
railBgStyle: {
|
|
43
|
+
'box-shadow': 'inset 0 0 1px 0 var(--ant-color-text-quaternary)'
|
|
44
|
+
}
|
|
45
|
+
}), null);
|
|
46
|
+
insert(_el$2, createComponent(Show, {
|
|
47
|
+
get when() {
|
|
48
|
+
return !context?.disabledAlpha();
|
|
49
|
+
},
|
|
50
|
+
get children() {
|
|
51
|
+
return createComponent(Slider, {
|
|
52
|
+
get value() {
|
|
53
|
+
return color().a * 100;
|
|
54
|
+
},
|
|
55
|
+
onChange: v => {
|
|
56
|
+
context?.setColor(color().clone().setAlpha(v / 100));
|
|
57
|
+
},
|
|
58
|
+
onChangeComplete: () => {
|
|
59
|
+
context?.setColor(color(), true);
|
|
60
|
+
},
|
|
61
|
+
min: 0,
|
|
62
|
+
step: 1,
|
|
63
|
+
tooltip: false,
|
|
64
|
+
handle: () => getSliderHandle(color().toRgbString()),
|
|
65
|
+
get style() {
|
|
66
|
+
return {
|
|
67
|
+
'--ant-slider-rail-size': '8px',
|
|
68
|
+
'--ant-slider-handle-size': '10px',
|
|
69
|
+
'--ant-slider-rail-bg': `linear-gradient(90deg, ${color().clone().setAlpha(0).toRgbString()} 0%, ${color().toHexString()} 100%)`,
|
|
70
|
+
'--ant-slider-rail-hover-bg': 'var(--ant-slider-rail-bg)',
|
|
71
|
+
'--ant-slider-track-bg': 'transparent',
|
|
72
|
+
'--ant-slider-track-hover-bg': 'transparent',
|
|
73
|
+
'background-image': 'conic-gradient(var(--ant-color-fill-secondary) 0 25%, transparent 0 50%, var(--ant-color-fill-secondary) 0 75%, transparent 0)',
|
|
74
|
+
'background-size': '8px 8px'
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
railBgStyle: {
|
|
78
|
+
'box-shadow': 'inset 0 0 1px 0 var(--ant-color-text-quaternary)'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}), null);
|
|
83
|
+
_el$3.style.setProperty("background-image", "conic-gradient(var(--ant-color-fill-secondary) 0 25%, transparent 0 50%, var(--ant-color-fill-secondary) 0 75%, transparent 0)");
|
|
84
|
+
_el$3.style.setProperty("background-size", "50% 50%");
|
|
85
|
+
_el$3.style.setProperty("box-shadow", "inset 0 0 1px 0 var(--ant-color-text-quaternary)");
|
|
86
|
+
insert(_el$, (() => {
|
|
87
|
+
var _c$ = memo(() => !!window.EyeDropper);
|
|
88
|
+
return () => _c$() && (() => {
|
|
89
|
+
var _el$5 = _tmpl$2();
|
|
90
|
+
_el$5.$$click = () => {
|
|
91
|
+
if (!window.EyeDropper) return;
|
|
92
|
+
const eyeDropper = new window.EyeDropper();
|
|
93
|
+
eyeDropper.open().then(result => {
|
|
94
|
+
context?.setColor(new Color(result.sRGBHex), true);
|
|
95
|
+
}).catch(console.error);
|
|
96
|
+
};
|
|
97
|
+
insert(_el$5, createComponent(ColorPickUpSvg, {}));
|
|
98
|
+
return _el$5;
|
|
99
|
+
})();
|
|
100
|
+
})(), null);
|
|
101
|
+
effect(() => color().toRgbString() != null ? _el$4.style.setProperty("background-color", color().toRgbString()) : _el$4.style.removeProperty("background-color"));
|
|
102
|
+
return _el$;
|
|
103
|
+
})();
|
|
104
|
+
};
|
|
105
|
+
const getSliderHandle = bgColor => {
|
|
106
|
+
return (() => {
|
|
107
|
+
var _el$6 = _tmpl$3();
|
|
108
|
+
bgColor != null ? _el$6.style.setProperty("background", bgColor) : _el$6.style.removeProperty("background");
|
|
109
|
+
effect(() => className(_el$6, cs('box-border w-[--ant-slider-handle-size] h-[--ant-slider-handle-size] rounded-1/2 border-solid border-2px border-[--ant-color-bg-container-secondary] cursor-pointer', '[box-shadow:inset_0_0_1px_0_var(--ant-color-text-quaternary),0_0_0_1px_var(--ant-color-fill-secondary)]', 'focus:[box-shadow:inset_0_0_1px_0_var(--ant-color-text-quaternary),0_0_0_1px_var(--ant-color-primary-active)]')));
|
|
110
|
+
return _el$6;
|
|
111
|
+
})();
|
|
112
|
+
};
|
|
113
|
+
delegateEvents(["click"]);
|
|
114
|
+
|
|
115
|
+
export { ColorPickerSlider as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TinyColor, type TinyColorOptions, type RGB, type RGBA, type HSL, type HSLA, type HSV, type HSVA, type CMYK, type Numberify } from '@ctrl/tinycolor';
|
|
2
|
+
export type ColorInput = string | number | null | undefined | RGB | RGBA | HSL | HSLA | HSV | HSVA | CMYK | Color;
|
|
3
|
+
/**
|
|
4
|
+
* 扩展 TinyColor
|
|
5
|
+
* 用于在 HSV 格式下,当 s 或者 v 为 0 时,正常保存 h 值
|
|
6
|
+
*/
|
|
7
|
+
declare class Color extends TinyColor {
|
|
8
|
+
/** Hue */
|
|
9
|
+
private readonly h;
|
|
10
|
+
/** Saturation */
|
|
11
|
+
private readonly s;
|
|
12
|
+
/** Value */
|
|
13
|
+
private readonly v;
|
|
14
|
+
constructor(color?: ColorInput, opts?: Partial<TinyColorOptions>);
|
|
15
|
+
toHsv(): Numberify<HSVA>;
|
|
16
|
+
toHsvString(): string;
|
|
17
|
+
/**
|
|
18
|
+
* 获取色相对应的颜色 rgb 字符串
|
|
19
|
+
* @returns string
|
|
20
|
+
*/
|
|
21
|
+
toHueRgbString(): string;
|
|
22
|
+
clone(): Color;
|
|
23
|
+
}
|
|
24
|
+
export default Color;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TinyColor, stringInputToObject, isValidCSSUnit } from '@ctrl/tinycolor';
|
|
2
|
+
import { isNil } from 'lodash-es';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 扩展 TinyColor
|
|
6
|
+
* 用于在 HSV 格式下,当 s 或者 v 为 0 时,正常保存 h 值
|
|
7
|
+
*/
|
|
8
|
+
class Color extends TinyColor {
|
|
9
|
+
/** Hue */
|
|
10
|
+
h = 0;
|
|
11
|
+
/** Saturation */
|
|
12
|
+
s = 0;
|
|
13
|
+
/** Value */
|
|
14
|
+
v = 0;
|
|
15
|
+
constructor(color, opts) {
|
|
16
|
+
color = isNil(color) ? undefined : color;
|
|
17
|
+
color = color instanceof Color ? color.toHsv() : color;
|
|
18
|
+
super(color, opts);
|
|
19
|
+
if (typeof color === 'string') {
|
|
20
|
+
color = stringInputToObject(color);
|
|
21
|
+
}
|
|
22
|
+
if (typeof color === 'object') {
|
|
23
|
+
if (isHsv(color)) {
|
|
24
|
+
this.h = Number(color.h);
|
|
25
|
+
this.s = Number(color.s);
|
|
26
|
+
this.v = Number(color.v);
|
|
27
|
+
this.a = isHsva(color) ? color.a : 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
toHsv() {
|
|
32
|
+
const hsv = super.toHsv();
|
|
33
|
+
if (this.equals(new TinyColor('black'))) {
|
|
34
|
+
hsv.h = this.h;
|
|
35
|
+
hsv.s = this.s;
|
|
36
|
+
hsv.v = this.v;
|
|
37
|
+
}
|
|
38
|
+
return hsv;
|
|
39
|
+
}
|
|
40
|
+
toHsvString() {
|
|
41
|
+
const hsv = this.toHsv();
|
|
42
|
+
return `hsva(${hsv.h}, ${hsv.s}, ${hsv.v}, ${hsv.a})`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 获取色相对应的颜色 rgb 字符串
|
|
46
|
+
* @returns string
|
|
47
|
+
*/
|
|
48
|
+
toHueRgbString() {
|
|
49
|
+
const hsv = this.toHsv();
|
|
50
|
+
return new Color(`hsv(${hsv.h}, 1, 1)`).toRgbString();
|
|
51
|
+
}
|
|
52
|
+
clone() {
|
|
53
|
+
return new Color(this);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function isHsv(color) {
|
|
57
|
+
return !isNil(color) && typeof color === 'object' && isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v);
|
|
58
|
+
}
|
|
59
|
+
function isHsva(color) {
|
|
60
|
+
return isHsv(color) && isValidCSSUnit(color.a);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { Color as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
import type Color from './color';
|
|
3
|
+
interface ColorPickerContextProps {
|
|
4
|
+
color: Accessor<Color>;
|
|
5
|
+
setColor: (color: Color, completed?: boolean) => void;
|
|
6
|
+
disabledAlpha: Accessor<boolean>;
|
|
7
|
+
}
|
|
8
|
+
declare const ColorPickerContext: import("solid-js").Context<ColorPickerContextProps | undefined>;
|
|
9
|
+
export default ColorPickerContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Component } from 'solid-js';
|
|
2
|
+
import { type PopoverProps } from '../Popover';
|
|
3
|
+
import { type ComponentSize } from '../types';
|
|
4
|
+
export interface ColorPickerProps extends Pick<PopoverProps, 'placement'> {
|
|
5
|
+
defaultValue?: string | null;
|
|
6
|
+
value?: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* @param value Hex 格式
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
onChange?: (value: string | null) => void;
|
|
12
|
+
/**
|
|
13
|
+
* 颜色选择完成的回调,通过 onChangeComplete 对 value 受控时拖拽不会改变展示颜色
|
|
14
|
+
* @param value Hex 格式
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
onChangeComplete?: (value: string | null) => void;
|
|
18
|
+
allowClear?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 禁止透明度
|
|
22
|
+
*/
|
|
23
|
+
disabledAlpha?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 大小,提供 large middle 和 small 三种大小
|
|
26
|
+
* 默认 'middle'
|
|
27
|
+
*/
|
|
28
|
+
size?: ComponentSize;
|
|
29
|
+
}
|
|
30
|
+
declare const ColorPicker: Component<ColorPickerProps>;
|
|
31
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { delegateEvents, createComponent, insert, effect, className, template } from 'solid-js/web';
|
|
2
|
+
import cs from 'classnames';
|
|
3
|
+
import { createSignal, untrack, createRenderEffect, createMemo, Show } from 'solid-js';
|
|
4
|
+
import Color from './color.js';
|
|
5
|
+
import Element from '../Element/index.js';
|
|
6
|
+
import Popover from '../Popover/index.js';
|
|
7
|
+
import ColorPickerSelect from './ColorPickerSelect.js';
|
|
8
|
+
import ColorPickerContext from './context.js';
|
|
9
|
+
import ColorPickerSlider from './ColorPickerSlider.js';
|
|
10
|
+
import ColorPickerInput from './ColorPickerInput.js';
|
|
11
|
+
import useComponentSize from '../hooks/useComponentSize.js';
|
|
12
|
+
|
|
13
|
+
var _tmpl$ = /*#__PURE__*/template(`<div class="flex justify-end mb-[--ant-margin-xs]"><div class="w-24px h-24px rounded-[--ant-border-radius-sm] relative overflow-hidden border-1px border-solid border-[--ant-color-split] cursor-pointer hover:border-[--ant-color-border]"><div class="absolute top-1/2 left-1/2 -translate-1/2 w-200% h-2px bg-[--ant-color-error] rotate-135deg">`),
|
|
14
|
+
_tmpl$2 = /*#__PURE__*/template(`<div class="w-234px flex flex-col gap-[--ant-margin-sm]">`),
|
|
15
|
+
_tmpl$3 = /*#__PURE__*/template(`<div><div class="w-full h-full">`),
|
|
16
|
+
_tmpl$4 = /*#__PURE__*/template(`<div>`),
|
|
17
|
+
_tmpl$5 = /*#__PURE__*/template(`<div><div class="absolute top-1/2 left-1/2 -translate-1/2 w-200% h-2px bg-[--ant-color-error] rotate-135deg">`);
|
|
18
|
+
// TODO 超出范围
|
|
19
|
+
const ColorPicker = props => {
|
|
20
|
+
const isControlled = () => Object.keys(props).includes('value');
|
|
21
|
+
const [innerColor, _setInnerColor] = createSignal(untrack(() => new Color(props.defaultValue)));
|
|
22
|
+
createRenderEffect(() => {
|
|
23
|
+
if (isControlled()) {
|
|
24
|
+
_setInnerColor(new Color(props.value));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const disabledAlpha = createMemo(() => !!props.disabledAlpha);
|
|
28
|
+
const setColor = (value, completed) => {
|
|
29
|
+
_setInnerColor(value);
|
|
30
|
+
const valueStr = value.isValid ? disabledAlpha() || value.a === 1 ? value.toHexString() : value.toHex8String() : null;
|
|
31
|
+
props.onChange?.(valueStr);
|
|
32
|
+
if (completed) props.onChangeComplete?.(valueStr);
|
|
33
|
+
};
|
|
34
|
+
const [open, setOpen] = createSignal(false);
|
|
35
|
+
const size = useComponentSize(() => props.size);
|
|
36
|
+
const color = createMemo(() => isControlled() ? new Color(props.value) : innerColor());
|
|
37
|
+
const getPopoverContent = close => createComponent(ColorPickerContext.Provider, {
|
|
38
|
+
value: {
|
|
39
|
+
color: innerColor,
|
|
40
|
+
setColor,
|
|
41
|
+
disabledAlpha
|
|
42
|
+
},
|
|
43
|
+
get children() {
|
|
44
|
+
return [createComponent(Show, {
|
|
45
|
+
get when() {
|
|
46
|
+
return props.allowClear;
|
|
47
|
+
},
|
|
48
|
+
get children() {
|
|
49
|
+
var _el$ = _tmpl$(),
|
|
50
|
+
_el$2 = _el$.firstChild;
|
|
51
|
+
_el$2.$$click = () => {
|
|
52
|
+
setColor(new Color());
|
|
53
|
+
close();
|
|
54
|
+
};
|
|
55
|
+
return _el$;
|
|
56
|
+
}
|
|
57
|
+
}), (() => {
|
|
58
|
+
var _el$3 = _tmpl$2();
|
|
59
|
+
insert(_el$3, createComponent(ColorPickerSelect, {}), null);
|
|
60
|
+
insert(_el$3, createComponent(ColorPickerSlider, {}), null);
|
|
61
|
+
insert(_el$3, createComponent(ColorPickerInput, {}), null);
|
|
62
|
+
return _el$3;
|
|
63
|
+
})()];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return createComponent(Popover, {
|
|
67
|
+
get open() {
|
|
68
|
+
return open();
|
|
69
|
+
},
|
|
70
|
+
onOpenChange: setOpen,
|
|
71
|
+
get trigger() {
|
|
72
|
+
return props.disabled ? false : 'click';
|
|
73
|
+
},
|
|
74
|
+
content: getPopoverContent,
|
|
75
|
+
get placement() {
|
|
76
|
+
return props.placement ?? 'bottomLeft';
|
|
77
|
+
},
|
|
78
|
+
get children() {
|
|
79
|
+
return createComponent(Element, {
|
|
80
|
+
get ["class"]() {
|
|
81
|
+
return cs('inline-block', props.disabled && 'cursor-not-allowed');
|
|
82
|
+
},
|
|
83
|
+
get children() {
|
|
84
|
+
var _el$4 = _tmpl$4();
|
|
85
|
+
_el$4.style.setProperty("--border-width", "1px");
|
|
86
|
+
insert(_el$4, createComponent(Show, {
|
|
87
|
+
get when() {
|
|
88
|
+
return color().isValid;
|
|
89
|
+
},
|
|
90
|
+
get fallback() {
|
|
91
|
+
return (() => {
|
|
92
|
+
var _el$7 = _tmpl$5();
|
|
93
|
+
effect(() => className(_el$7, cs('w-[--inner-size] h-[--inner-size] rounded-[--ant-border-radius-sm] relative overflow-hidden border-1px border-solid border-[--ant-color-split]')));
|
|
94
|
+
return _el$7;
|
|
95
|
+
})();
|
|
96
|
+
},
|
|
97
|
+
get children() {
|
|
98
|
+
var _el$5 = _tmpl$3(),
|
|
99
|
+
_el$6 = _el$5.firstChild;
|
|
100
|
+
_el$5.style.setProperty("box-shadow", "inset 0 0 1px 0 var(--ant-color-text-quaternary)");
|
|
101
|
+
_el$5.style.setProperty("background-image", "conic-gradient(var(--ant-color-fill-secondary) 0 25%, transparent 0 50%, var(--ant-color-fill-secondary) 0 75%, transparent 0)");
|
|
102
|
+
_el$5.style.setProperty("background-size", "50% 50%");
|
|
103
|
+
_el$6.style.setProperty("box-shadow", "inset 0 0 0 var(--ant-line-width) var(--ant-color-fill-secondary)");
|
|
104
|
+
effect(_p$ => {
|
|
105
|
+
var _v$ = cs('w-[--inner-size] h-[--inner-size] rounded-[--ant-border-radius-sm] overflow-hidden'),
|
|
106
|
+
_v$2 = color().toRgbString();
|
|
107
|
+
_v$ !== _p$.e && className(_el$5, _p$.e = _v$);
|
|
108
|
+
_v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$6.style.setProperty("background-color", _v$2) : _el$6.style.removeProperty("background-color"));
|
|
109
|
+
return _p$;
|
|
110
|
+
}, {
|
|
111
|
+
e: undefined,
|
|
112
|
+
t: undefined
|
|
113
|
+
});
|
|
114
|
+
return _el$5;
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
effect(_p$ => {
|
|
118
|
+
var _v$3 = cs('p-[calc(var(--ant-padding-xxs)-var(--border-width))] border-width-[--border-width] border-[--ant-color-border] border-solid rounded-[--ant-border-radius] cursor-pointer hover:border-[--ant-color-primary-hover]', open() && '!border-[--ant-color-primary-active]', props.disabled ? 'pointer-events-none bg-[--ant-color-bg-container-disabled]' : 'bg-[--ant-color-bg-elevated]'),
|
|
119
|
+
_v$4 = {
|
|
120
|
+
small: '16px',
|
|
121
|
+
middle: '24px',
|
|
122
|
+
large: '32px'
|
|
123
|
+
}[size()];
|
|
124
|
+
_v$3 !== _p$.e && className(_el$4, _p$.e = _v$3);
|
|
125
|
+
_v$4 !== _p$.t && ((_p$.t = _v$4) != null ? _el$4.style.setProperty("--inner-size", _v$4) : _el$4.style.removeProperty("--inner-size"));
|
|
126
|
+
return _p$;
|
|
127
|
+
}, {
|
|
128
|
+
e: undefined,
|
|
129
|
+
t: undefined
|
|
130
|
+
});
|
|
131
|
+
return _el$4;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
delegateEvents(["click"]);
|
|
138
|
+
|
|
139
|
+
export { ColorPicker as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
declare const CommandContext: import("solid-js").Context<{
|
|
3
|
+
open: Accessor<boolean>;
|
|
4
|
+
onOk: (value: any) => void;
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
dispose: () => void;
|
|
7
|
+
onAutoDispose: () => void;
|
|
8
|
+
}>;
|
|
9
|
+
export default CommandContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type JSXElement, type Component } from 'solid-js';
|
|
2
|
+
export interface BaseCommandIntance<P extends {} | undefined = undefined, R = void, S = P extends undefined ? () => Promise<R> : (props: P) => Promise<R>> {
|
|
3
|
+
show: S;
|
|
4
|
+
hide: () => void;
|
|
5
|
+
dispose: () => void;
|
|
6
|
+
isOpen: () => boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* createCommand
|
|
10
|
+
* @param component
|
|
11
|
+
* @param contextHolder 如果为 true,则会返回 getContextHolder
|
|
12
|
+
*/
|
|
13
|
+
declare function createCommand<P extends {} = {}, R = void>(component: Component<P>): BaseCommandIntance<P, R>;
|
|
14
|
+
declare function createCommand<P extends {} = {}, R = void>(component: Component<P>, contextHolder: true): BaseCommandIntance<P, R> & {
|
|
15
|
+
getContextHolder: () => JSXElement;
|
|
16
|
+
};
|
|
17
|
+
export default createCommand;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createComponent, Dynamic, mergeProps, render } from 'solid-js/web';
|
|
2
|
+
import { createSignal, untrack, Show, createRenderEffect } from 'solid-js';
|
|
3
|
+
import CommandContext from './context.js';
|
|
4
|
+
import DelayShow from '../DelayShow/index.js';
|
|
5
|
+
|
|
6
|
+
function createCommand(component, contextHolder) {
|
|
7
|
+
const [open, _setOpen] = createSignal(false);
|
|
8
|
+
const [forceDestroy, setForceDestroy] = createSignal(false);
|
|
9
|
+
const setOpen = value => {
|
|
10
|
+
if (value) setForceDestroy(false);
|
|
11
|
+
_setOpen(value);
|
|
12
|
+
};
|
|
13
|
+
const [props, setProps] = createSignal();
|
|
14
|
+
let resolve;
|
|
15
|
+
let reject;
|
|
16
|
+
let disposeRef;
|
|
17
|
+
const dispose = () => {
|
|
18
|
+
_setOpen(false);
|
|
19
|
+
setForceDestroy(true);
|
|
20
|
+
disposeRef?.();
|
|
21
|
+
disposeRef = undefined;
|
|
22
|
+
};
|
|
23
|
+
const hide = () => {
|
|
24
|
+
setOpen(false);
|
|
25
|
+
};
|
|
26
|
+
const onOk = value => {
|
|
27
|
+
hide();
|
|
28
|
+
resolve(value);
|
|
29
|
+
};
|
|
30
|
+
const onCancel = () => {
|
|
31
|
+
hide();
|
|
32
|
+
reject();
|
|
33
|
+
};
|
|
34
|
+
const isOpen = () => untrack(open);
|
|
35
|
+
// 监听关闭事件,自动销毁
|
|
36
|
+
const onAutoDispose = () => {
|
|
37
|
+
createRenderEffect(() => {
|
|
38
|
+
if (!open()) dispose();
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const getContextHolder = () => createComponent(DelayShow, {
|
|
42
|
+
get when() {
|
|
43
|
+
return open();
|
|
44
|
+
},
|
|
45
|
+
get children() {
|
|
46
|
+
return createComponent(Show, {
|
|
47
|
+
get when() {
|
|
48
|
+
return !forceDestroy();
|
|
49
|
+
},
|
|
50
|
+
get children() {
|
|
51
|
+
return createComponent(CommandContext.Provider, {
|
|
52
|
+
value: {
|
|
53
|
+
open,
|
|
54
|
+
onOk,
|
|
55
|
+
onCancel,
|
|
56
|
+
dispose,
|
|
57
|
+
onAutoDispose
|
|
58
|
+
},
|
|
59
|
+
get children() {
|
|
60
|
+
return createComponent(Dynamic, mergeProps({
|
|
61
|
+
component: component
|
|
62
|
+
}, props));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (contextHolder) {
|
|
70
|
+
const show = async _props => {
|
|
71
|
+
setProps(_props);
|
|
72
|
+
setOpen(true);
|
|
73
|
+
return await new Promise((_resolve, _reject) => {
|
|
74
|
+
resolve = _resolve;
|
|
75
|
+
reject = _reject;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
show,
|
|
80
|
+
hide,
|
|
81
|
+
dispose,
|
|
82
|
+
isOpen,
|
|
83
|
+
getContextHolder
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const show = async _props => {
|
|
87
|
+
setProps(_props);
|
|
88
|
+
const alreadyOpen = isOpen();
|
|
89
|
+
setOpen(true);
|
|
90
|
+
return await new Promise((_resolve, _reject) => {
|
|
91
|
+
if (!alreadyOpen) {
|
|
92
|
+
const div = document.createElement('div');
|
|
93
|
+
document.body.appendChild(div);
|
|
94
|
+
const renderDispose = render(getContextHolder, div);
|
|
95
|
+
disposeRef = () => {
|
|
96
|
+
renderDispose();
|
|
97
|
+
document.body.removeChild(div);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
resolve = _resolve;
|
|
101
|
+
reject = _reject;
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
show,
|
|
106
|
+
hide,
|
|
107
|
+
dispose,
|
|
108
|
+
isOpen
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { createCommand as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare function useCommandProps<T = void>(): {
|
|
2
|
+
open: import("solid-js").Accessor<boolean>;
|
|
3
|
+
onOk: (value: T) => void;
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
dispose: () => void;
|
|
6
|
+
onAutoDispose: () => void;
|
|
7
|
+
getProps: () => {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onOk: () => void;
|
|
10
|
+
onCancel: () => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export default useCommandProps;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useContext } from 'solid-js';
|
|
2
|
+
import CommandContext from './context.js';
|
|
3
|
+
|
|
4
|
+
function useCommandProps() {
|
|
5
|
+
const {
|
|
6
|
+
open,
|
|
7
|
+
onOk,
|
|
8
|
+
onCancel,
|
|
9
|
+
dispose,
|
|
10
|
+
onAutoDispose
|
|
11
|
+
} = useContext(CommandContext);
|
|
12
|
+
return {
|
|
13
|
+
open,
|
|
14
|
+
onOk: onOk,
|
|
15
|
+
onCancel,
|
|
16
|
+
dispose,
|
|
17
|
+
onAutoDispose,
|
|
18
|
+
getProps: () => {
|
|
19
|
+
return {
|
|
20
|
+
open: open(),
|
|
21
|
+
onOk: onOk,
|
|
22
|
+
onCancel
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { useCommandProps as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createComponent } from 'solid-js/web';
|
|
2
|
+
import CompactContext from './context.js';
|
|
3
|
+
|
|
4
|
+
const CompactContextIsolator = props => {
|
|
5
|
+
return createComponent(CompactContext.Provider, {
|
|
6
|
+
value: {
|
|
7
|
+
compact: false
|
|
8
|
+
},
|
|
9
|
+
get children() {
|
|
10
|
+
return props.children;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { CompactContextIsolator as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type JSX, type ParentProps } from 'solid-js';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
interface CompactProps extends ParentProps {
|
|
4
|
+
block?: boolean;
|
|
5
|
+
class?: string;
|
|
6
|
+
style?: JSX.CSSProperties;
|
|
7
|
+
/**
|
|
8
|
+
* 指定排列方向
|
|
9
|
+
* 默认 'horizontal'
|
|
10
|
+
*/
|
|
11
|
+
direction?: 'horizontal' | 'vertical';
|
|
12
|
+
}
|
|
13
|
+
declare function Compact(_props: CompactProps): JSX.Element;
|
|
14
|
+
export default Compact;
|