antd-solid 0.0.7 → 0.0.9
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/dist/index.esm.js +0 -13
- package/dist/index.umd.js +1 -1
- package/es/Button.d.ts +19 -0
- package/es/Button.js +73 -0
- package/es/Collapse/index.d.ts +16 -0
- package/es/Collapse/index.js +87 -0
- package/es/ColorPicker.d.ts +8 -0
- package/es/ColorPicker.js +6 -0
- package/es/Compact.d.ts +12 -0
- package/es/Compact.js +17 -0
- package/es/DatePicker.d.ts +19 -0
- package/es/DatePicker.js +9 -0
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.d.ts +3 -0
- package/es/Empty/PRESENTED_IMAGE_SIMPLE.js +14 -0
- package/es/Empty/assets/EmptySvg.d.ts +2 -0
- package/es/Empty/assets/EmptySvg.js +6 -0
- package/es/Empty/assets/SimpleEmptySvg.d.ts +2 -0
- package/es/Empty/assets/SimpleEmptySvg.js +6 -0
- package/es/Empty/index.d.ts +5 -0
- package/es/Empty/index.js +16 -0
- package/es/Image.d.ts +9 -0
- package/es/Image.js +22 -0
- package/es/Input.d.ts +29 -0
- package/es/Input.js +144 -0
- package/es/InputNumber.d.ts +11 -0
- package/es/InputNumber.js +92 -0
- package/es/InputNumber.test.d.ts +1 -0
- package/es/InputNumber.test.js +42 -0
- package/es/Modal.d.ts +47 -0
- package/es/Modal.js +195 -0
- package/es/Popconfirm.d.ts +21 -0
- package/es/Popconfirm.js +64 -0
- package/es/Popover.d.ts +7 -0
- package/es/Popover.js +36 -0
- package/es/Progress.d.ts +7 -0
- package/es/Progress.js +6 -0
- package/es/Radio.d.ts +27 -0
- package/es/Radio.js +89 -0
- package/es/Result.d.ts +10 -0
- package/es/Result.js +29 -0
- package/es/Segmented/index.d.ts +21 -0
- package/es/Segmented/index.js +72 -0
- package/es/Select.d.ts +16 -0
- package/es/Select.js +113 -0
- package/es/Skeleton.d.ts +9 -0
- package/es/Skeleton.js +9 -0
- package/es/Spin.d.ts +9 -0
- package/es/Spin.js +22 -0
- package/es/Switch.d.ts +8 -0
- package/es/Switch.js +30 -0
- package/es/Table.d.ts +11 -0
- package/es/Table.js +57 -0
- package/es/Tabs.d.ts +17 -0
- package/es/Tabs.js +117 -0
- package/es/Timeline.d.ts +13 -0
- package/es/Timeline.js +30 -0
- package/es/Tooltip.d.ts +34 -0
- package/es/Tooltip.js +302 -0
- package/es/Tree.d.ts +28 -0
- package/es/Tree.js +198 -0
- package/es/Upload.d.ts +11 -0
- package/es/Upload.js +6 -0
- package/es/form/Form.d.ts +18 -0
- package/es/form/Form.js +70 -0
- package/es/form/FormItem.d.ts +19 -0
- package/es/form/FormItem.js +141 -0
- package/es/form/context.d.ts +12 -0
- package/es/form/context.js +5 -0
- package/es/form/index.d.ts +8 -0
- package/es/form/index.js +7 -0
- package/es/hooks/createControllableValue.d.ts +16 -0
- package/es/hooks/createControllableValue.js +41 -0
- package/es/hooks/createUpdateEffect.d.ts +5 -0
- package/es/hooks/createUpdateEffect.js +12 -0
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/index.js +2 -0
- package/es/hooks/useClickAway.d.ts +2 -0
- package/es/hooks/useClickAway.js +17 -0
- package/es/hooks/useSize.d.ts +5 -0
- package/es/hooks/useSize.js +22 -0
- package/es/index.d.ts +42 -0
- package/es/index.js +29 -0
- package/es/types/index.d.ts +3 -0
- package/es/types/index.js +1 -0
- package/es/utils/EventEmitter.d.ts +7 -0
- package/es/utils/EventEmitter.js +13 -0
- package/es/utils/ReactToSolid.d.ts +8 -0
- package/es/utils/ReactToSolid.js +30 -0
- package/es/utils/SolidToReact.d.ts +8 -0
- package/es/utils/SolidToReact.js +23 -0
- package/es/utils/array.d.ts +15 -0
- package/es/utils/array.js +19 -0
- package/es/utils/component.d.ts +31 -0
- package/es/utils/component.js +68 -0
- package/es/utils/solid.d.ts +15 -0
- package/es/utils/solid.js +32 -0
- package/es/utils/zh_CN.d.ts +2 -0
- package/es/utils/zh_CN.js +236 -0
- package/package.json +6 -4
- package/src/DatePicker.tsx +20 -12
- package/src/Tooltip.tsx +0 -15
- /package/{dist → css}/index.css +0 -0
package/es/Table.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { insert, createComponent, template } from 'solid-js/web';
|
|
2
|
+
import Empty from './Empty/index.js';
|
|
3
|
+
import { For, Show } from 'solid-js';
|
|
4
|
+
|
|
5
|
+
const _tmpl$ = /*#__PURE__*/template(`<div><table class="ant-w-full"><thead><tr></tr></thead><tbody>`),
|
|
6
|
+
_tmpl$2 = /*#__PURE__*/template(`<th class="ant-p-16px ant-bg-[var(--light-bg-color)] ant-font-bold ant-[border-bottom:1px_solid_var(--secondary-border-color)] ant-text-left">`),
|
|
7
|
+
_tmpl$3 = /*#__PURE__*/template(`<tr class="hover:ant-bg-[var(--light-bg-color)]">`),
|
|
8
|
+
_tmpl$4 = /*#__PURE__*/template(`<td class="ant-p-16px ant-[border-bottom:1px_solid_var(--secondary-border-color)]">`);
|
|
9
|
+
const Table = props => {
|
|
10
|
+
return (() => {
|
|
11
|
+
const _el$ = _tmpl$(),
|
|
12
|
+
_el$2 = _el$.firstChild,
|
|
13
|
+
_el$3 = _el$2.firstChild,
|
|
14
|
+
_el$4 = _el$3.firstChild,
|
|
15
|
+
_el$5 = _el$3.nextSibling;
|
|
16
|
+
insert(_el$4, createComponent(For, {
|
|
17
|
+
get each() {
|
|
18
|
+
return props.columns;
|
|
19
|
+
},
|
|
20
|
+
children: item => (() => {
|
|
21
|
+
const _el$6 = _tmpl$2();
|
|
22
|
+
insert(_el$6, () => item.title);
|
|
23
|
+
return _el$6;
|
|
24
|
+
})()
|
|
25
|
+
}));
|
|
26
|
+
insert(_el$5, createComponent(For, {
|
|
27
|
+
get each() {
|
|
28
|
+
return props.dataSource;
|
|
29
|
+
},
|
|
30
|
+
children: row => (() => {
|
|
31
|
+
const _el$7 = _tmpl$3();
|
|
32
|
+
insert(_el$7, createComponent(For, {
|
|
33
|
+
get each() {
|
|
34
|
+
return props.columns;
|
|
35
|
+
},
|
|
36
|
+
children: item => (() => {
|
|
37
|
+
const _el$8 = _tmpl$4();
|
|
38
|
+
insert(_el$8, () => item.render(row));
|
|
39
|
+
return _el$8;
|
|
40
|
+
})()
|
|
41
|
+
}));
|
|
42
|
+
return _el$7;
|
|
43
|
+
})()
|
|
44
|
+
}));
|
|
45
|
+
insert(_el$, createComponent(Show, {
|
|
46
|
+
get when() {
|
|
47
|
+
return !props.dataSource.length;
|
|
48
|
+
},
|
|
49
|
+
get children() {
|
|
50
|
+
return createComponent(Empty.PRESENTED_IMAGE_SIMPLE, {});
|
|
51
|
+
}
|
|
52
|
+
}), null);
|
|
53
|
+
return _el$;
|
|
54
|
+
})();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { Table as default };
|
package/es/Tabs.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Component } from 'solid-js';
|
|
2
|
+
import { type StringOrJSXElement } from './types';
|
|
3
|
+
export interface Tab {
|
|
4
|
+
key: string;
|
|
5
|
+
label: StringOrJSXElement;
|
|
6
|
+
children?: StringOrJSXElement;
|
|
7
|
+
}
|
|
8
|
+
export interface TabsProps {
|
|
9
|
+
type?: 'line' | 'segment';
|
|
10
|
+
class?: string;
|
|
11
|
+
navClass?: string;
|
|
12
|
+
navItemClass?: string;
|
|
13
|
+
contentClass?: string;
|
|
14
|
+
items: Tab[];
|
|
15
|
+
}
|
|
16
|
+
declare const Tabs: Component<TabsProps>;
|
|
17
|
+
export default Tabs;
|
package/es/Tabs.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { delegateEvents, insert, createComponent, effect, className, style, template, use } from 'solid-js/web';
|
|
2
|
+
import { mergeProps, createSignal, untrack, createSelector, onMount, Switch, Match, For, onCleanup } from 'solid-js';
|
|
3
|
+
import cs from 'classnames';
|
|
4
|
+
import Segmented from './Segmented/index.js';
|
|
5
|
+
import { unwrapStringOrJSXElement } from './utils/solid.js';
|
|
6
|
+
|
|
7
|
+
const _tmpl$ = /*#__PURE__*/template(`<div><div role="selected-bar" class="ant-absolute ant-bottom-0 ant-bg-[var(--primary-color)] ant-h-2px ant-transition-left">`),
|
|
8
|
+
_tmpl$2 = /*#__PURE__*/template(`<div><div>`),
|
|
9
|
+
_tmpl$3 = /*#__PURE__*/template(`<div>`);
|
|
10
|
+
const Tabs = _props => {
|
|
11
|
+
const props = mergeProps({
|
|
12
|
+
type: 'line'
|
|
13
|
+
}, _props);
|
|
14
|
+
const [selectedItem, setSelectedItem] = createSignal(untrack(() => props.items[0]));
|
|
15
|
+
const isSelectedItem = createSelector(() => selectedItem()?.key);
|
|
16
|
+
const [selectedBarStyle, setSelectedBarStyle] = createSignal({
|
|
17
|
+
left: '0px',
|
|
18
|
+
width: '0px'
|
|
19
|
+
});
|
|
20
|
+
let nav;
|
|
21
|
+
const updateSelectedBarStyle = () => {
|
|
22
|
+
if (!nav) return;
|
|
23
|
+
const el = nav.querySelector(':scope > .selected');
|
|
24
|
+
if (!el) return;
|
|
25
|
+
setSelectedBarStyle({
|
|
26
|
+
left: `${el.offsetLeft}px`,
|
|
27
|
+
width: `${el.clientWidth}px`
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
onMount(() => {
|
|
31
|
+
if (!nav) return;
|
|
32
|
+
updateSelectedBarStyle();
|
|
33
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
34
|
+
updateSelectedBarStyle();
|
|
35
|
+
});
|
|
36
|
+
resizeObserver.observe(nav);
|
|
37
|
+
onCleanup(() => {
|
|
38
|
+
resizeObserver.disconnect();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
return (() => {
|
|
42
|
+
const _el$ = _tmpl$2(),
|
|
43
|
+
_el$4 = _el$.firstChild;
|
|
44
|
+
insert(_el$, createComponent(Switch, {
|
|
45
|
+
get children() {
|
|
46
|
+
return [createComponent(Match, {
|
|
47
|
+
get when() {
|
|
48
|
+
return props.type === 'line';
|
|
49
|
+
},
|
|
50
|
+
get children() {
|
|
51
|
+
const _el$2 = _tmpl$(),
|
|
52
|
+
_el$3 = _el$2.firstChild;
|
|
53
|
+
const _ref$ = nav;
|
|
54
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : nav = _el$2;
|
|
55
|
+
insert(_el$2, createComponent(For, {
|
|
56
|
+
get each() {
|
|
57
|
+
return props.items;
|
|
58
|
+
},
|
|
59
|
+
children: item => (() => {
|
|
60
|
+
const _el$5 = _tmpl$3();
|
|
61
|
+
_el$5.$$click = () => {
|
|
62
|
+
setSelectedItem(item);
|
|
63
|
+
updateSelectedBarStyle();
|
|
64
|
+
};
|
|
65
|
+
insert(_el$5, () => unwrapStringOrJSXElement(item.label));
|
|
66
|
+
effect(() => className(_el$5, cs('ant-py-12px ant-cursor-pointer', props.navItemClass, isSelectedItem(item.key) && 'ant-text-[var(--primary-color)] selected')));
|
|
67
|
+
return _el$5;
|
|
68
|
+
})()
|
|
69
|
+
}), _el$3);
|
|
70
|
+
effect(_p$ => {
|
|
71
|
+
const _v$ = cs('ant-mb-16px ant-flex ant-gap-32px ant-[border-bottom:solid_1px_rgba(5,5,5,0.1)] ant-relative', props.navClass),
|
|
72
|
+
_v$2 = selectedBarStyle();
|
|
73
|
+
_v$ !== _p$._v$ && className(_el$2, _p$._v$ = _v$);
|
|
74
|
+
_p$._v$2 = style(_el$3, _v$2, _p$._v$2);
|
|
75
|
+
return _p$;
|
|
76
|
+
}, {
|
|
77
|
+
_v$: undefined,
|
|
78
|
+
_v$2: undefined
|
|
79
|
+
});
|
|
80
|
+
return _el$2;
|
|
81
|
+
}
|
|
82
|
+
}), createComponent(Match, {
|
|
83
|
+
get when() {
|
|
84
|
+
return props.type === 'segment';
|
|
85
|
+
},
|
|
86
|
+
get children() {
|
|
87
|
+
return createComponent(Segmented, {
|
|
88
|
+
block: true,
|
|
89
|
+
get options() {
|
|
90
|
+
return props.items.map(item => ({
|
|
91
|
+
label: item.label,
|
|
92
|
+
value: item.key,
|
|
93
|
+
onClick: () => setSelectedItem(item)
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
})];
|
|
99
|
+
}
|
|
100
|
+
}), _el$4);
|
|
101
|
+
insert(_el$4, () => unwrapStringOrJSXElement(selectedItem()?.children));
|
|
102
|
+
effect(_p$ => {
|
|
103
|
+
const _v$3 = props.class,
|
|
104
|
+
_v$4 = props.contentClass;
|
|
105
|
+
_v$3 !== _p$._v$3 && className(_el$, _p$._v$3 = _v$3);
|
|
106
|
+
_v$4 !== _p$._v$4 && className(_el$4, _p$._v$4 = _v$4);
|
|
107
|
+
return _p$;
|
|
108
|
+
}, {
|
|
109
|
+
_v$3: undefined,
|
|
110
|
+
_v$4: undefined
|
|
111
|
+
});
|
|
112
|
+
return _el$;
|
|
113
|
+
})();
|
|
114
|
+
};
|
|
115
|
+
delegateEvents(["click"]);
|
|
116
|
+
|
|
117
|
+
export { Tabs as default };
|
package/es/Timeline.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Accessor, type Component, type JSXElement } from 'solid-js';
|
|
2
|
+
import { type TimelineItemProps as TimelineItemAntdProps } from 'antd';
|
|
3
|
+
interface TimelineItemProps extends Omit<TimelineItemAntdProps, 'children' | 'dot' | 'label'> {
|
|
4
|
+
dot?: JSXElement;
|
|
5
|
+
label?: JSXElement;
|
|
6
|
+
children?: Accessor<JSXElement>;
|
|
7
|
+
}
|
|
8
|
+
interface TimelineProps {
|
|
9
|
+
class?: string;
|
|
10
|
+
items: TimelineItemProps[];
|
|
11
|
+
}
|
|
12
|
+
declare const Timeline: Component<TimelineProps>;
|
|
13
|
+
export default Timeline;
|
package/es/Timeline.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { insert, createComponent, memo, template } from 'solid-js/web';
|
|
2
|
+
import { For } from 'solid-js';
|
|
3
|
+
|
|
4
|
+
const _tmpl$ = /*#__PURE__*/template(`<div class="ant-flex ant-flex-col ant-gap-[16px]">`),
|
|
5
|
+
_tmpl$2 = /*#__PURE__*/template(`<div class="ant-flex ant-relative"><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]"></div><div class="ant-ml-[8px]">`),
|
|
6
|
+
_tmpl$3 = /*#__PURE__*/template(`<div class="ant-absolute ant-top-[8px] ant-bottom-[-24px] ant-left-[4px] ant-w-[2px] ant-bg-[rgba(5,5,5,.06)]">`);
|
|
7
|
+
const Timeline = props => {
|
|
8
|
+
return (() => {
|
|
9
|
+
const _el$ = _tmpl$();
|
|
10
|
+
insert(_el$, createComponent(For, {
|
|
11
|
+
get each() {
|
|
12
|
+
return props.items;
|
|
13
|
+
},
|
|
14
|
+
children: (item, i) => (() => {
|
|
15
|
+
const _el$2 = _tmpl$2(),
|
|
16
|
+
_el$3 = _el$2.firstChild,
|
|
17
|
+
_el$4 = _el$3.nextSibling;
|
|
18
|
+
insert(_el$2, (() => {
|
|
19
|
+
const _c$ = memo(() => i() !== props.items.length - 1);
|
|
20
|
+
return () => _c$() && _tmpl$3();
|
|
21
|
+
})(), _el$3);
|
|
22
|
+
insert(_el$4, () => item.children?.());
|
|
23
|
+
return _el$2;
|
|
24
|
+
})()
|
|
25
|
+
}));
|
|
26
|
+
return _el$;
|
|
27
|
+
})();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { Timeline as default };
|
package/es/Tooltip.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Component, type JSXElement, type JSX } from 'solid-js';
|
|
2
|
+
type ActionType = 'hover' | 'focus' | 'click' | 'contextMenu';
|
|
3
|
+
type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
4
|
+
export interface TooltipProps {
|
|
5
|
+
/**
|
|
6
|
+
* 默认: hover
|
|
7
|
+
*/
|
|
8
|
+
trigger?: ActionType | ActionType[];
|
|
9
|
+
/**
|
|
10
|
+
* 默认: top
|
|
11
|
+
*/
|
|
12
|
+
placement?: TooltipPlacement;
|
|
13
|
+
contentStyle?: JSX.CSSProperties;
|
|
14
|
+
content?: JSXElement | ((close: () => void) => JSXElement);
|
|
15
|
+
children?: JSXElement;
|
|
16
|
+
open?: boolean;
|
|
17
|
+
onOpenChange?: (open: boolean) => void;
|
|
18
|
+
/**
|
|
19
|
+
* 默认: dark
|
|
20
|
+
*/
|
|
21
|
+
mode?: 'dark' | 'light';
|
|
22
|
+
/**
|
|
23
|
+
* 默认: true
|
|
24
|
+
*/
|
|
25
|
+
arrow?: boolean | {
|
|
26
|
+
pointAtCenter: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare const Content: Component<{
|
|
30
|
+
content: TooltipProps['content'];
|
|
31
|
+
close: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
declare const Tooltip: Component<TooltipProps>;
|
|
34
|
+
export default Tooltip;
|
package/es/Tooltip.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { delegateEvents, createComponent, memo, Portal, use, insert, effect, className, style, template } from 'solid-js/web';
|
|
2
|
+
import { compact } from 'lodash-es';
|
|
3
|
+
import { Show, mergeProps, children, createEffect, onCleanup, createSignal, createMemo } from 'solid-js';
|
|
4
|
+
import cs from 'classnames';
|
|
5
|
+
import createControllableValue from './hooks/createControllableValue.js';
|
|
6
|
+
import useClickAway from './hooks/useClickAway.js';
|
|
7
|
+
import { toArray } from './utils/array.js';
|
|
8
|
+
|
|
9
|
+
const _tmpl$ = /*#__PURE__*/template(`<div>`);
|
|
10
|
+
const Content = props => {
|
|
11
|
+
return createComponent(Show, {
|
|
12
|
+
get when() {
|
|
13
|
+
return typeof props.content === 'function';
|
|
14
|
+
},
|
|
15
|
+
get fallback() {
|
|
16
|
+
return props.content;
|
|
17
|
+
},
|
|
18
|
+
get children() {
|
|
19
|
+
return memo(() => typeof props.content === 'function')() && props.content(props.close);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const Tooltip = _props => {
|
|
24
|
+
const props = mergeProps({
|
|
25
|
+
trigger: 'hover',
|
|
26
|
+
placement: 'top',
|
|
27
|
+
mode: 'dark',
|
|
28
|
+
arrow: true
|
|
29
|
+
}, _props);
|
|
30
|
+
const resolvedChildren = children(() => _props.children);
|
|
31
|
+
let content;
|
|
32
|
+
const [open, setOpen] = createControllableValue(_props, {
|
|
33
|
+
defaultValue: false,
|
|
34
|
+
valuePropName: 'open',
|
|
35
|
+
trigger: 'onOpenChange'
|
|
36
|
+
});
|
|
37
|
+
const reverseOpen = () => setOpen(v => !v);
|
|
38
|
+
createEffect(() => {
|
|
39
|
+
const _children = resolvedChildren();
|
|
40
|
+
toArray(props.trigger).forEach(trigger => {
|
|
41
|
+
switch (trigger) {
|
|
42
|
+
case 'hover':
|
|
43
|
+
_children.addEventListener('mouseenter', reverseOpen);
|
|
44
|
+
_children.addEventListener('mouseleave', reverseOpen);
|
|
45
|
+
onCleanup(() => {
|
|
46
|
+
_children.removeEventListener('mouseenter', reverseOpen);
|
|
47
|
+
_children.removeEventListener('mouseleave', reverseOpen);
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
case 'click':
|
|
51
|
+
_children.addEventListener('click', reverseOpen);
|
|
52
|
+
onCleanup(() => {
|
|
53
|
+
_children.removeEventListener('click', reverseOpen);
|
|
54
|
+
});
|
|
55
|
+
useClickAway(() => setOpen(false), () => compact([content, _children]));
|
|
56
|
+
break;
|
|
57
|
+
case 'focus':
|
|
58
|
+
_children.addEventListener('focus', reverseOpen);
|
|
59
|
+
_children.addEventListener('blur', reverseOpen);
|
|
60
|
+
onCleanup(() => {
|
|
61
|
+
_children.removeEventListener('focus', reverseOpen);
|
|
62
|
+
_children.removeEventListener('blur', reverseOpen);
|
|
63
|
+
});
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
const [childrenRect, setChildrenRect] = createSignal(new DOMRect());
|
|
69
|
+
createEffect(() => {
|
|
70
|
+
if (open()) {
|
|
71
|
+
const _children = resolvedChildren();
|
|
72
|
+
setChildrenRect(_children.getBoundingClientRect());
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const arrowOffset = createMemo(() => props.arrow ? 8 : 0);
|
|
76
|
+
const contentPositionStyle = createMemo(() => {
|
|
77
|
+
switch (props.placement) {
|
|
78
|
+
case 'top':
|
|
79
|
+
return {
|
|
80
|
+
top: `${childrenRect().top - arrowOffset()}px`,
|
|
81
|
+
left: `${childrenRect().left + childrenRect().width / 2}px`,
|
|
82
|
+
transform: 'translate(-50%, -100%)'
|
|
83
|
+
};
|
|
84
|
+
case 'topLeft':
|
|
85
|
+
return {
|
|
86
|
+
top: `${childrenRect().top - arrowOffset()}px`,
|
|
87
|
+
left: `${childrenRect().left}px`,
|
|
88
|
+
transform: 'translate(0, -100%)'
|
|
89
|
+
};
|
|
90
|
+
case 'topRight':
|
|
91
|
+
return {
|
|
92
|
+
top: `${childrenRect().top - arrowOffset()}px`,
|
|
93
|
+
left: `${childrenRect().right}px`,
|
|
94
|
+
transform: 'translate(-100%, -100%)'
|
|
95
|
+
};
|
|
96
|
+
case 'bottom':
|
|
97
|
+
return {
|
|
98
|
+
top: `${childrenRect().bottom + arrowOffset()}px`,
|
|
99
|
+
left: `${childrenRect().left + childrenRect().width / 2}px`,
|
|
100
|
+
transform: 'translate(-50%, 0)'
|
|
101
|
+
};
|
|
102
|
+
case 'bottomLeft':
|
|
103
|
+
return {
|
|
104
|
+
top: `${childrenRect().bottom + arrowOffset()}px`,
|
|
105
|
+
left: `${childrenRect().left}px`
|
|
106
|
+
};
|
|
107
|
+
case 'bottomRight':
|
|
108
|
+
return {
|
|
109
|
+
top: `${childrenRect().bottom + arrowOffset()}px`,
|
|
110
|
+
left: `${childrenRect().right}px`,
|
|
111
|
+
transform: 'translate(-100%, 0)'
|
|
112
|
+
};
|
|
113
|
+
case 'left':
|
|
114
|
+
return {
|
|
115
|
+
top: `${childrenRect().top + childrenRect().height / 2}px`,
|
|
116
|
+
left: `${childrenRect().left - arrowOffset()}px`,
|
|
117
|
+
transform: 'translate(-100%, -50%)'
|
|
118
|
+
};
|
|
119
|
+
case 'leftTop':
|
|
120
|
+
return {
|
|
121
|
+
top: `${childrenRect().top}px`,
|
|
122
|
+
left: `${childrenRect().left - arrowOffset()}px`,
|
|
123
|
+
transform: 'translate(-100%)'
|
|
124
|
+
};
|
|
125
|
+
case 'leftBottom':
|
|
126
|
+
return {
|
|
127
|
+
top: `${childrenRect().bottom}px`,
|
|
128
|
+
left: `${childrenRect().left - arrowOffset()}px`,
|
|
129
|
+
transform: 'translate(-100%, -100%)'
|
|
130
|
+
};
|
|
131
|
+
case 'right':
|
|
132
|
+
return {
|
|
133
|
+
top: `${childrenRect().top + childrenRect().height / 2}px`,
|
|
134
|
+
left: `${childrenRect().right + arrowOffset()}px`,
|
|
135
|
+
transform: 'translate(0, -50%)'
|
|
136
|
+
};
|
|
137
|
+
case 'rightTop':
|
|
138
|
+
return {
|
|
139
|
+
top: `${childrenRect().top}px`,
|
|
140
|
+
left: `${childrenRect().right + arrowOffset()}px`
|
|
141
|
+
};
|
|
142
|
+
case 'rightBottom':
|
|
143
|
+
return {
|
|
144
|
+
top: `${childrenRect().bottom}px`,
|
|
145
|
+
left: `${childrenRect().right + arrowOffset()}px`,
|
|
146
|
+
transform: 'translate(0, -100%)'
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const arrowStyle = createMemo(() => {
|
|
151
|
+
switch (props.placement) {
|
|
152
|
+
case 'top':
|
|
153
|
+
return {
|
|
154
|
+
'border-top-color': 'var(--color)',
|
|
155
|
+
top: '100%',
|
|
156
|
+
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
157
|
+
left: '50%',
|
|
158
|
+
transform: 'translateX(-50%)'
|
|
159
|
+
};
|
|
160
|
+
case 'topLeft':
|
|
161
|
+
return {
|
|
162
|
+
'border-top-color': 'var(--color)',
|
|
163
|
+
top: '100%',
|
|
164
|
+
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
165
|
+
left: '8px'
|
|
166
|
+
};
|
|
167
|
+
case 'topRight':
|
|
168
|
+
return {
|
|
169
|
+
'border-top-color': 'var(--color)',
|
|
170
|
+
top: '100%',
|
|
171
|
+
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
172
|
+
right: '8px'
|
|
173
|
+
};
|
|
174
|
+
case 'bottom':
|
|
175
|
+
return {
|
|
176
|
+
'border-bottom-color': 'var(--color)',
|
|
177
|
+
bottom: '100%',
|
|
178
|
+
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
179
|
+
left: '50%',
|
|
180
|
+
transform: 'translateX(-50%)'
|
|
181
|
+
};
|
|
182
|
+
case 'bottomLeft':
|
|
183
|
+
return {
|
|
184
|
+
'border-bottom-color': 'var(--color)',
|
|
185
|
+
bottom: '100%',
|
|
186
|
+
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
187
|
+
left: '8px'
|
|
188
|
+
};
|
|
189
|
+
case 'bottomRight':
|
|
190
|
+
return {
|
|
191
|
+
'border-bottom-color': 'var(--color)',
|
|
192
|
+
bottom: '100%',
|
|
193
|
+
filter: 'drop-shadow(3px 2px 2px rgba(0, 0, 0, 0.08))',
|
|
194
|
+
right: '8px'
|
|
195
|
+
};
|
|
196
|
+
case 'left':
|
|
197
|
+
return {
|
|
198
|
+
'border-left-color': 'var(--color)',
|
|
199
|
+
top: '50%',
|
|
200
|
+
right: 0,
|
|
201
|
+
transform: 'translate(100%, -50%)'
|
|
202
|
+
};
|
|
203
|
+
case 'leftTop':
|
|
204
|
+
return {
|
|
205
|
+
'border-left-color': 'var(--color)',
|
|
206
|
+
top: '8px',
|
|
207
|
+
right: 0,
|
|
208
|
+
transform: 'translate(100%, 0)'
|
|
209
|
+
};
|
|
210
|
+
case 'leftBottom':
|
|
211
|
+
return {
|
|
212
|
+
'border-left-color': 'var(--color)',
|
|
213
|
+
bottom: '8px',
|
|
214
|
+
right: 0,
|
|
215
|
+
transform: 'translate(100%, 0)'
|
|
216
|
+
};
|
|
217
|
+
case 'right':
|
|
218
|
+
return {
|
|
219
|
+
'border-right-color': 'var(--color)',
|
|
220
|
+
top: '50%',
|
|
221
|
+
left: 0,
|
|
222
|
+
transform: 'translate(-100%, -50%)'
|
|
223
|
+
};
|
|
224
|
+
case 'rightTop':
|
|
225
|
+
return {
|
|
226
|
+
'border-right-color': 'var(--color)',
|
|
227
|
+
top: '8px',
|
|
228
|
+
left: 0,
|
|
229
|
+
transform: 'translate(-100%, 0)'
|
|
230
|
+
};
|
|
231
|
+
case 'rightBottom':
|
|
232
|
+
return {
|
|
233
|
+
'border-right-color': 'var(--color)',
|
|
234
|
+
bottom: '8px',
|
|
235
|
+
left: 0,
|
|
236
|
+
transform: 'translate(-100%, 0)'
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
return [memo(resolvedChildren), createComponent(Show, {
|
|
241
|
+
get when() {
|
|
242
|
+
return open();
|
|
243
|
+
},
|
|
244
|
+
get children() {
|
|
245
|
+
return createComponent(Portal, {
|
|
246
|
+
get children() {
|
|
247
|
+
const _el$ = _tmpl$();
|
|
248
|
+
_el$.$$click = e => {
|
|
249
|
+
e.stopPropagation();
|
|
250
|
+
};
|
|
251
|
+
const _ref$ = content;
|
|
252
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : content = _el$;
|
|
253
|
+
insert(_el$, createComponent(Content, {
|
|
254
|
+
get content() {
|
|
255
|
+
return props.content;
|
|
256
|
+
},
|
|
257
|
+
close: () => setOpen(false)
|
|
258
|
+
}), null);
|
|
259
|
+
insert(_el$, createComponent(Show, {
|
|
260
|
+
get when() {
|
|
261
|
+
return props.arrow;
|
|
262
|
+
},
|
|
263
|
+
get children() {
|
|
264
|
+
const _el$2 = _tmpl$();
|
|
265
|
+
effect(_p$ => {
|
|
266
|
+
const _v$ = cs('ant-w-8px ant-h-8px ant-absolute ant-border-solid ant-border-4px ant-border-transparent'),
|
|
267
|
+
_v$2 = {
|
|
268
|
+
'--color': props.mode === 'dark' ? 'rgba(0,0,0,0.85)' : 'white',
|
|
269
|
+
...arrowStyle()
|
|
270
|
+
};
|
|
271
|
+
_v$ !== _p$._v$ && className(_el$2, _p$._v$ = _v$);
|
|
272
|
+
_p$._v$2 = style(_el$2, _v$2, _p$._v$2);
|
|
273
|
+
return _p$;
|
|
274
|
+
}, {
|
|
275
|
+
_v$: undefined,
|
|
276
|
+
_v$2: undefined
|
|
277
|
+
});
|
|
278
|
+
return _el$2;
|
|
279
|
+
}
|
|
280
|
+
}), null);
|
|
281
|
+
effect(_p$ => {
|
|
282
|
+
const _v$3 = cs('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)]', props.mode === 'dark' ? 'ant-bg-[rgba(0,0,0,0.85)] ant-text-white' : 'ant-bg-white'),
|
|
283
|
+
_v$4 = {
|
|
284
|
+
...contentPositionStyle(),
|
|
285
|
+
...props.contentStyle
|
|
286
|
+
};
|
|
287
|
+
_v$3 !== _p$._v$3 && className(_el$, _p$._v$3 = _v$3);
|
|
288
|
+
_p$._v$4 = style(_el$, _v$4, _p$._v$4);
|
|
289
|
+
return _p$;
|
|
290
|
+
}, {
|
|
291
|
+
_v$3: undefined,
|
|
292
|
+
_v$4: undefined
|
|
293
|
+
});
|
|
294
|
+
return _el$;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
})];
|
|
299
|
+
};
|
|
300
|
+
delegateEvents(["click"]);
|
|
301
|
+
|
|
302
|
+
export { Content, Tooltip as default };
|
package/es/Tree.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type JSXElement } from 'solid-js';
|
|
2
|
+
export interface TreeProps<T extends {} = {}> {
|
|
3
|
+
class?: string;
|
|
4
|
+
defaultSelectedNodes?: T[];
|
|
5
|
+
treeData?: T[];
|
|
6
|
+
/**
|
|
7
|
+
* 是否节点占据一行
|
|
8
|
+
*/
|
|
9
|
+
blockNode?: boolean;
|
|
10
|
+
defaultExpandAll?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 设置节点可拖拽
|
|
13
|
+
*/
|
|
14
|
+
draggable?: boolean;
|
|
15
|
+
titleRender: (node: T, info: {
|
|
16
|
+
indexes: number[];
|
|
17
|
+
}) => JSXElement;
|
|
18
|
+
children: (node: T) => T[] | undefined;
|
|
19
|
+
onSelect?: (node: T) => void;
|
|
20
|
+
onDrop?: (info: {
|
|
21
|
+
dragNode: T;
|
|
22
|
+
targetNode: T;
|
|
23
|
+
dragIndexes: number[];
|
|
24
|
+
targetIndexes: number[];
|
|
25
|
+
}) => void;
|
|
26
|
+
}
|
|
27
|
+
declare function Tree<T extends {} = {}>(props: TreeProps<T>): import("solid-js").JSX.Element;
|
|
28
|
+
export default Tree;
|