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
package/src/Tabs.tsx
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Component,
|
|
3
|
-
For,
|
|
4
|
-
createSelector,
|
|
5
|
-
createSignal,
|
|
6
|
-
onMount,
|
|
7
|
-
untrack,
|
|
8
|
-
type JSX,
|
|
9
|
-
onCleanup,
|
|
10
|
-
mergeProps,
|
|
11
|
-
Switch,
|
|
12
|
-
Match,
|
|
13
|
-
} from 'solid-js'
|
|
14
|
-
import cs from 'classnames'
|
|
15
|
-
import Segmented from './Segmented'
|
|
16
|
-
import { type StringOrJSXElement } from './types'
|
|
17
|
-
import { unwrapStringOrJSXElement } from './utils/solid'
|
|
18
|
-
|
|
19
|
-
export interface Tab {
|
|
20
|
-
key: string
|
|
21
|
-
label: StringOrJSXElement
|
|
22
|
-
children?: StringOrJSXElement
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface TabsProps {
|
|
26
|
-
type?: 'line' | 'segment'
|
|
27
|
-
class?: string
|
|
28
|
-
navClass?: string
|
|
29
|
-
navItemClass?: string
|
|
30
|
-
contentClass?: string
|
|
31
|
-
items: Tab[]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Tabs: Component<TabsProps> = _props => {
|
|
35
|
-
const props = mergeProps(
|
|
36
|
-
{
|
|
37
|
-
type: 'line',
|
|
38
|
-
} as TabsProps,
|
|
39
|
-
_props,
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
const [selectedItem, setSelectedItem] = createSignal<Tab | undefined>(
|
|
43
|
-
untrack(() => props.items[0]),
|
|
44
|
-
)
|
|
45
|
-
const isSelectedItem = createSelector(() => selectedItem()?.key)
|
|
46
|
-
const [selectedBarStyle, setSelectedBarStyle] = createSignal<JSX.CSSProperties>({
|
|
47
|
-
left: '0px',
|
|
48
|
-
width: '0px',
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
let nav: HTMLDivElement | undefined
|
|
52
|
-
const updateSelectedBarStyle = () => {
|
|
53
|
-
if (!nav) return
|
|
54
|
-
|
|
55
|
-
const el = nav.querySelector<HTMLElement>(':scope > .selected')
|
|
56
|
-
if (!el) return
|
|
57
|
-
|
|
58
|
-
setSelectedBarStyle({
|
|
59
|
-
left: `${el.offsetLeft}px`,
|
|
60
|
-
width: `${el.clientWidth}px`,
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
onMount(() => {
|
|
64
|
-
if (!nav) return
|
|
65
|
-
|
|
66
|
-
updateSelectedBarStyle()
|
|
67
|
-
|
|
68
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
69
|
-
updateSelectedBarStyle()
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
resizeObserver.observe(nav)
|
|
73
|
-
onCleanup(() => {
|
|
74
|
-
resizeObserver.disconnect()
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<div class={props.class}>
|
|
80
|
-
<Switch>
|
|
81
|
-
<Match when={props.type === 'line'}>
|
|
82
|
-
<div
|
|
83
|
-
ref={nav!}
|
|
84
|
-
class={cs(
|
|
85
|
-
'ant-mb-16px ant-flex ant-gap-32px ant-[border-bottom:solid_1px_rgba(5,5,5,0.1)] ant-relative',
|
|
86
|
-
props.navClass,
|
|
87
|
-
)}
|
|
88
|
-
>
|
|
89
|
-
<For each={props.items}>
|
|
90
|
-
{item => (
|
|
91
|
-
<div
|
|
92
|
-
class={cs(
|
|
93
|
-
'ant-py-12px ant-cursor-pointer',
|
|
94
|
-
props.navItemClass,
|
|
95
|
-
isSelectedItem(item.key) && 'ant-text-[var(--primary-color)] selected',
|
|
96
|
-
)}
|
|
97
|
-
onClick={() => {
|
|
98
|
-
setSelectedItem(item)
|
|
99
|
-
updateSelectedBarStyle()
|
|
100
|
-
}}
|
|
101
|
-
>
|
|
102
|
-
{unwrapStringOrJSXElement(item.label)}
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
105
|
-
</For>
|
|
106
|
-
|
|
107
|
-
<div
|
|
108
|
-
role={'selected-bar' as any}
|
|
109
|
-
class="ant-absolute ant-bottom-0 ant-bg-[var(--primary-color)] ant-h-2px ant-transition-left"
|
|
110
|
-
style={selectedBarStyle()}
|
|
111
|
-
/>
|
|
112
|
-
</div>
|
|
113
|
-
</Match>
|
|
114
|
-
<Match when={props.type === 'segment'}>
|
|
115
|
-
<Segmented
|
|
116
|
-
block
|
|
117
|
-
options={props.items.map(item => ({
|
|
118
|
-
label: item.label,
|
|
119
|
-
value: item.key,
|
|
120
|
-
onClick: () => setSelectedItem(item),
|
|
121
|
-
}))}
|
|
122
|
-
/>
|
|
123
|
-
</Match>
|
|
124
|
-
</Switch>
|
|
125
|
-
|
|
126
|
-
<div class={props.contentClass}>{unwrapStringOrJSXElement(selectedItem()?.children)}</div>
|
|
127
|
-
</div>
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export default Tabs
|
package/src/Timeline.tsx
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type Accessor, type Component, For, type JSXElement } from 'solid-js'
|
|
2
|
-
import { type TimelineItemProps as TimelineItemAntdProps } from 'antd'
|
|
3
|
-
|
|
4
|
-
interface TimelineItemProps extends Omit<TimelineItemAntdProps, 'children' | 'dot' | 'label'> {
|
|
5
|
-
dot?: JSXElement
|
|
6
|
-
label?: JSXElement
|
|
7
|
-
children?: Accessor<JSXElement>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface TimelineProps {
|
|
11
|
-
class?: string
|
|
12
|
-
items: TimelineItemProps[]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const Timeline: Component<TimelineProps> = props => {
|
|
16
|
-
return (
|
|
17
|
-
<div class="ant-flex ant-flex-col ant-gap-[16px]">
|
|
18
|
-
<For each={props.items}>
|
|
19
|
-
{(item, i) => (
|
|
20
|
-
<div class="ant-flex ant-relative">
|
|
21
|
-
{i() !== props.items.length - 1 && (
|
|
22
|
-
<div class="ant-absolute ant-top-[8px] ant-bottom-[-24px] ant-left-[4px] ant-w-[2px] ant-bg-[rgba(5,5,5,.06)]" />
|
|
23
|
-
)}
|
|
24
|
-
<div class="ant-w-[10px] ant-h-[10px] ant-border-solid ant-border-width-[3px] ant-border-[var(--primary-color)] ant-bg-white ant-rounded-[50%] ant-mt-[8px]" />
|
|
25
|
-
<div class="ant-ml-[8px]">{item.children?.()}</div>
|
|
26
|
-
</div>
|
|
27
|
-
)}
|
|
28
|
-
</For>
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default Timeline
|
package/src/Tooltip.tsx
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import { compact } from 'lodash-es'
|
|
2
|
-
import {
|
|
3
|
-
type Component,
|
|
4
|
-
type JSXElement,
|
|
5
|
-
type JSX,
|
|
6
|
-
children,
|
|
7
|
-
createEffect,
|
|
8
|
-
Show,
|
|
9
|
-
mergeProps,
|
|
10
|
-
onCleanup,
|
|
11
|
-
createMemo,
|
|
12
|
-
createSignal,
|
|
13
|
-
} from 'solid-js'
|
|
14
|
-
import { Portal } from 'solid-js/web'
|
|
15
|
-
import cs from 'classnames'
|
|
16
|
-
import createControllableValue from './hooks/createControllableValue'
|
|
17
|
-
import { useClickAway } from './hooks'
|
|
18
|
-
import { toArray } from './utils/array'
|
|
19
|
-
|
|
20
|
-
type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu'
|
|
21
|
-
type TooltipPlacement =
|
|
22
|
-
| 'top'
|
|
23
|
-
| 'left'
|
|
24
|
-
| 'right'
|
|
25
|
-
| 'bottom'
|
|
26
|
-
| 'topLeft'
|
|
27
|
-
| 'topRight'
|
|
28
|
-
| 'bottomLeft'
|
|
29
|
-
| 'bottomRight'
|
|
30
|
-
| 'leftTop'
|
|
31
|
-
| 'leftBottom'
|
|
32
|
-
| 'rightTop'
|
|
33
|
-
| 'rightBottom'
|
|
34
|
-
|
|
35
|
-
export interface TooltipProps {
|
|
36
|
-
/**
|
|
37
|
-
* 默认: hover
|
|
38
|
-
*/
|
|
39
|
-
trigger?: ActionType | ActionType[]
|
|
40
|
-
/**
|
|
41
|
-
* 默认: top
|
|
42
|
-
*/
|
|
43
|
-
placement?: TooltipPlacement
|
|
44
|
-
contentStyle?: JSX.CSSProperties
|
|
45
|
-
content?: JSXElement | ((close: () => void) => JSXElement)
|
|
46
|
-
children?: JSXElement
|
|
47
|
-
open?: boolean
|
|
48
|
-
onOpenChange?: (open: boolean) => void
|
|
49
|
-
/**
|
|
50
|
-
* 默认: dark
|
|
51
|
-
*/
|
|
52
|
-
mode?: 'dark' | 'light'
|
|
53
|
-
/**
|
|
54
|
-
* 默认: true
|
|
55
|
-
*/
|
|
56
|
-
arrow?: boolean | { pointAtCenter: boolean }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const Content: Component<{
|
|
60
|
-
content: TooltipProps['content']
|
|
61
|
-
close: () => void
|
|
62
|
-
}> = props => {
|
|
63
|
-
return (
|
|
64
|
-
<Show when={typeof props.content === 'function'} fallback={props.content as JSXElement}>
|
|
65
|
-
{typeof props.content === 'function' && props.content(props.close)}
|
|
66
|
-
</Show>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const Tooltip: Component<TooltipProps> = _props => {
|
|
71
|
-
const props = mergeProps(
|
|
72
|
-
{
|
|
73
|
-
trigger: 'hover',
|
|
74
|
-
placement: 'top',
|
|
75
|
-
mode: 'dark',
|
|
76
|
-
arrow: true,
|
|
77
|
-
},
|
|
78
|
-
_props,
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
const resolvedChildren = children(() => _props.children)
|
|
82
|
-
let content: HTMLDivElement
|
|
83
|
-
const [open, setOpen] = createControllableValue(_props, {
|
|
84
|
-
defaultValue: false,
|
|
85
|
-
valuePropName: 'open',
|
|
86
|
-
trigger: 'onOpenChange',
|
|
87
|
-
})
|
|
88
|
-
const reverseOpen = () => setOpen(v => !v)
|
|
89
|
-
|
|
90
|
-
createEffect(() => {
|
|
91
|
-
const _children = resolvedChildren() as Element
|
|
92
|
-
toArray(props.trigger).forEach(trigger => {
|
|
93
|
-
switch (trigger) {
|
|
94
|
-
case 'hover':
|
|
95
|
-
_children.addEventListener('mouseenter', reverseOpen)
|
|
96
|
-
_children.addEventListener('mouseleave', reverseOpen)
|
|
97
|
-
onCleanup(() => {
|
|
98
|
-
_children.removeEventListener('mouseenter', reverseOpen)
|
|
99
|
-
_children.removeEventListener('mouseleave', reverseOpen)
|
|
100
|
-
})
|
|
101
|
-
break
|
|
102
|
-
case 'click':
|
|
103
|
-
_children.addEventListener('click', reverseOpen)
|
|
104
|
-
onCleanup(() => {
|
|
105
|
-
_children.removeEventListener('click', reverseOpen)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
useClickAway(
|
|
109
|
-
() => setOpen(false),
|
|
110
|
-
() => compact([content, _children]),
|
|
111
|
-
)
|
|
112
|
-
break
|
|
113
|
-
case 'focus':
|
|
114
|
-
_children.addEventListener('focus', reverseOpen)
|
|
115
|
-
_children.addEventListener('blur', reverseOpen)
|
|
116
|
-
onCleanup(() => {
|
|
117
|
-
_children.removeEventListener('focus', reverseOpen)
|
|
118
|
-
_children.removeEventListener('blur', reverseOpen)
|
|
119
|
-
})
|
|
120
|
-
break
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
const [childrenRect, setChildrenRect] = createSignal(new DOMRect())
|
|
126
|
-
createEffect(() => {
|
|
127
|
-
if (open()) {
|
|
128
|
-
const _children = resolvedChildren() as Element
|
|
129
|
-
setChildrenRect(_children.getBoundingClientRect())
|
|
130
|
-
}
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
const arrowOffset = createMemo(() => (props.arrow ? 8 : 0))
|
|
134
|
-
const contentPositionStyle = createMemo(() => {
|
|
135
|
-
switch (props.placement) {
|
|
136
|
-
case 'top':
|
|
137
|
-
return {
|
|
138
|
-
top: `${childrenRect().top - arrowOffset()}px`,
|
|
139
|
-
left: `${childrenRect().left + childrenRect().width / 2}px`,
|
|
140
|
-
transform: 'translate(-50%, -100%)',
|
|
141
|
-
} as JSX.CSSProperties
|
|
142
|
-
case 'topLeft':
|
|
143
|
-
return {
|
|
144
|
-
top: `${childrenRect().top - arrowOffset()}px`,
|
|
145
|
-
left: `${childrenRect().left}px`,
|
|
146
|
-
transform: 'translate(0, -100%)',
|
|
147
|
-
} as JSX.CSSProperties
|
|
148
|
-
case 'topRight':
|
|
149
|
-
return {
|
|
150
|
-
top: `${childrenRect().top - arrowOffset()}px`,
|
|
151
|
-
left: `${childrenRect().right}px`,
|
|
152
|
-
transform: 'translate(-100%, -100%)',
|
|
153
|
-
} as JSX.CSSProperties
|
|
154
|
-
case 'bottom':
|
|
155
|
-
return {
|
|
156
|
-
top: `${childrenRect().bottom + arrowOffset()}px`,
|
|
157
|
-
left: `${childrenRect().left + childrenRect().width / 2}px`,
|
|
158
|
-
transform: 'translate(-50%, 0)',
|
|
159
|
-
} as JSX.CSSProperties
|
|
160
|
-
case 'bottomLeft':
|
|
161
|
-
return {
|
|
162
|
-
top: `${childrenRect().bottom + arrowOffset()}px`,
|
|
163
|
-
left: `${childrenRect().left}px`,
|
|
164
|
-
} as JSX.CSSProperties
|
|
165
|
-
case 'bottomRight':
|
|
166
|
-
return {
|
|
167
|
-
top: `${childrenRect().bottom + arrowOffset()}px`,
|
|
168
|
-
left: `${childrenRect().right}px`,
|
|
169
|
-
transform: 'translate(-100%, 0)',
|
|
170
|
-
} as JSX.CSSProperties
|
|
171
|
-
case 'left':
|
|
172
|
-
return {
|
|
173
|
-
top: `${childrenRect().top + childrenRect().height / 2}px`,
|
|
174
|
-
left: `${childrenRect().left - arrowOffset()}px`,
|
|
175
|
-
transform: 'translate(-100%, -50%)',
|
|
176
|
-
} as JSX.CSSProperties
|
|
177
|
-
case 'leftTop':
|
|
178
|
-
return {
|
|
179
|
-
top: `${childrenRect().top}px`,
|
|
180
|
-
left: `${childrenRect().left - arrowOffset()}px`,
|
|
181
|
-
transform: 'translate(-100%)',
|
|
182
|
-
} as JSX.CSSProperties
|
|
183
|
-
case 'leftBottom':
|
|
184
|
-
return {
|
|
185
|
-
top: `${childrenRect().bottom}px`,
|
|
186
|
-
left: `${childrenRect().left - arrowOffset()}px`,
|
|
187
|
-
transform: 'translate(-100%, -100%)',
|
|
188
|
-
} as JSX.CSSProperties
|
|
189
|
-
case 'right':
|
|
190
|
-
return {
|
|
191
|
-
top: `${childrenRect().top + childrenRect().height / 2}px`,
|
|
192
|
-
left: `${childrenRect().right + arrowOffset()}px`,
|
|
193
|
-
transform: 'translate(0, -50%)',
|
|
194
|
-
} as JSX.CSSProperties
|
|
195
|
-
case 'rightTop':
|
|
196
|
-
return {
|
|
197
|
-
top: `${childrenRect().top}px`,
|
|
198
|
-
left: `${childrenRect().right + arrowOffset()}px`,
|
|
199
|
-
} as JSX.CSSProperties
|
|
200
|
-
case 'rightBottom':
|
|
201
|
-
return {
|
|
202
|
-
top: `${childrenRect().bottom}px`,
|
|
203
|
-
left: `${childrenRect().right + arrowOffset()}px`,
|
|
204
|
-
transform: 'translate(0, -100%)',
|
|
205
|
-
} as JSX.CSSProperties
|
|
206
|
-
}
|
|
207
|
-
})
|
|
208
|
-
const arrowStyle = createMemo(() => {
|
|
209
|
-
switch (props.placement) {
|
|
210
|
-
case 'top':
|
|
211
|
-
return {
|
|
212
|
-
'border-top-color': 'var(--color)',
|
|
213
|
-
top: '100%',
|
|
214
|
-
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
215
|
-
left: '50%',
|
|
216
|
-
transform: 'translateX(-50%)',
|
|
217
|
-
} as JSX.CSSProperties
|
|
218
|
-
case 'topLeft':
|
|
219
|
-
return {
|
|
220
|
-
'border-top-color': 'var(--color)',
|
|
221
|
-
top: '100%',
|
|
222
|
-
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
223
|
-
left: '8px',
|
|
224
|
-
} as JSX.CSSProperties
|
|
225
|
-
case 'topRight':
|
|
226
|
-
return {
|
|
227
|
-
'border-top-color': 'var(--color)',
|
|
228
|
-
top: '100%',
|
|
229
|
-
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
230
|
-
right: '8px',
|
|
231
|
-
} as JSX.CSSProperties
|
|
232
|
-
case 'bottom':
|
|
233
|
-
return {
|
|
234
|
-
'border-bottom-color': 'var(--color)',
|
|
235
|
-
bottom: '100%',
|
|
236
|
-
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
237
|
-
left: '50%',
|
|
238
|
-
transform: 'translateX(-50%)',
|
|
239
|
-
} as JSX.CSSProperties
|
|
240
|
-
case 'bottomLeft':
|
|
241
|
-
return {
|
|
242
|
-
'border-bottom-color': 'var(--color)',
|
|
243
|
-
bottom: '100%',
|
|
244
|
-
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
245
|
-
left: '8px',
|
|
246
|
-
} as JSX.CSSProperties
|
|
247
|
-
case 'bottomRight':
|
|
248
|
-
return {
|
|
249
|
-
'border-bottom-color': 'var(--color)',
|
|
250
|
-
bottom: '100%',
|
|
251
|
-
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
252
|
-
right: '8px',
|
|
253
|
-
} as JSX.CSSProperties
|
|
254
|
-
case 'left':
|
|
255
|
-
return {
|
|
256
|
-
'border-left-color': 'var(--color)',
|
|
257
|
-
top: '50%',
|
|
258
|
-
right: 0,
|
|
259
|
-
transform: 'translate(100%, -50%)',
|
|
260
|
-
} as JSX.CSSProperties
|
|
261
|
-
case 'leftTop':
|
|
262
|
-
return {
|
|
263
|
-
'border-left-color': 'var(--color)',
|
|
264
|
-
top: '8px',
|
|
265
|
-
right: 0,
|
|
266
|
-
transform: 'translate(100%, 0)',
|
|
267
|
-
} as JSX.CSSProperties
|
|
268
|
-
case 'leftBottom':
|
|
269
|
-
return {
|
|
270
|
-
'border-left-color': 'var(--color)',
|
|
271
|
-
bottom: '8px',
|
|
272
|
-
right: 0,
|
|
273
|
-
transform: 'translate(100%, 0)',
|
|
274
|
-
} as JSX.CSSProperties
|
|
275
|
-
case 'right':
|
|
276
|
-
return {
|
|
277
|
-
'border-right-color': 'var(--color)',
|
|
278
|
-
top: '50%',
|
|
279
|
-
left: 0,
|
|
280
|
-
transform: 'translate(-100%, -50%)',
|
|
281
|
-
} as JSX.CSSProperties
|
|
282
|
-
case 'rightTop':
|
|
283
|
-
return {
|
|
284
|
-
'border-right-color': 'var(--color)',
|
|
285
|
-
top: '8px',
|
|
286
|
-
left: 0,
|
|
287
|
-
transform: 'translate(-100%, 0)',
|
|
288
|
-
} as JSX.CSSProperties
|
|
289
|
-
case 'rightBottom':
|
|
290
|
-
return {
|
|
291
|
-
'border-right-color': 'var(--color)',
|
|
292
|
-
bottom: '8px',
|
|
293
|
-
left: 0,
|
|
294
|
-
transform: 'translate(-100%, 0)',
|
|
295
|
-
} as JSX.CSSProperties
|
|
296
|
-
}
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
return (
|
|
300
|
-
<>
|
|
301
|
-
{resolvedChildren()}
|
|
302
|
-
|
|
303
|
-
<Show when={open()}>
|
|
304
|
-
<Portal>
|
|
305
|
-
{/* Portal 存在缺陷,onClick 依然会沿着 solid 的组件树向上传播,因此需要 stopPropagation */}
|
|
306
|
-
<div
|
|
307
|
-
ref={content!}
|
|
308
|
-
class={cs(
|
|
309
|
-
'ant-z-1000 ant-fixed ant-absolute ant-px-8px ant-py-6px ant-rounded-8px ant-box-content ant-[box-shadow:0_6px_16px_0_rgba(0,0,0,0.08),0_3px_6px_-4px_rgba(0,0,0,0.12),0_9px_28px_8px_rgba(0,0,0,0.05)]',
|
|
310
|
-
props.mode === 'dark' ? 'ant-bg-[rgba(0,0,0,0.85)] ant-text-white' : 'ant-bg-white',
|
|
311
|
-
)}
|
|
312
|
-
style={{
|
|
313
|
-
...contentPositionStyle(),
|
|
314
|
-
...props.contentStyle,
|
|
315
|
-
}}
|
|
316
|
-
onClick={e => {
|
|
317
|
-
e.stopPropagation()
|
|
318
|
-
}}
|
|
319
|
-
>
|
|
320
|
-
<Content content={props.content} close={() => setOpen(false)} />
|
|
321
|
-
|
|
322
|
-
<Show when={props.arrow}>
|
|
323
|
-
<div
|
|
324
|
-
class={cs(
|
|
325
|
-
'ant-w-8px ant-h-8px ant-absolute ant-border-solid ant-border-4px ant-border-transparent',
|
|
326
|
-
)}
|
|
327
|
-
style={{
|
|
328
|
-
'--color': props.mode === 'dark' ? 'rgba(0,0,0,0.85)' : 'white',
|
|
329
|
-
...arrowStyle(),
|
|
330
|
-
}}
|
|
331
|
-
/>
|
|
332
|
-
</Show>
|
|
333
|
-
</div>
|
|
334
|
-
</Portal>
|
|
335
|
-
</Show>
|
|
336
|
-
</>
|
|
337
|
-
)
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export default Tooltip
|