musae 0.2.5 → 0.2.6
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/README.md +4 -2
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/components/breadcrumb/item.js +1 -1
- package/dist/components/button/button.js +2 -1
- package/dist/components/calendar/calendar.js +1 -1
- package/dist/components/calendar/hooks.js +5 -5
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +6 -4
- package/dist/components/checkbox/index.d.ts +1 -1
- package/dist/components/checkbox/types.d.ts +9 -3
- package/dist/components/clock/column.js +1 -1
- package/dist/components/collapse/collapse.js +1 -1
- package/dist/components/collapse/item.js +2 -2
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/dialog/popup.js +5 -5
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/popup.js +17 -17
- package/dist/components/empty/empty.js +1 -1
- package/dist/components/form/field/field.js +1 -1
- package/dist/components/form/field/layout.js +1 -1
- package/dist/components/grid/col.js +1 -1
- package/dist/components/grid/row.js +1 -1
- package/dist/components/icon/icon.js +1 -1
- package/dist/components/image/image.js +3 -2
- package/dist/components/image/preview/operations.js +4 -4
- package/dist/components/image/preview/preview.js +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/layout/header.js +2 -2
- package/dist/components/layout/layout.js +1 -1
- package/dist/components/loading/loading.js +2 -2
- package/dist/components/menu/group.js +16 -2
- package/dist/components/menu/hooks.js +1 -1
- package/dist/components/menu/item.js +1 -1
- package/dist/components/menu/menu.js +3 -1
- package/dist/components/notification/holder.js +13 -13
- package/dist/components/notification/notification.js +3 -3
- package/dist/components/picker/picker.js +1 -1
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/popper/dropdown.js +3 -3
- package/dist/components/progress/circular.js +1 -1
- package/dist/components/progress/linear.js +1 -1
- package/dist/components/radio/radio.js +1 -1
- package/dist/components/rate/rate.js +1 -1
- package/dist/components/rate/star.js +3 -3
- package/dist/components/ripple/ripple.js +1 -1
- package/dist/components/select/selector.js +1 -1
- package/dist/components/space/space.js +1 -1
- package/dist/components/steps/item.js +48 -2
- package/dist/components/steps/steps.js +1 -1
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.js +22 -22
- package/dist/components/table/body.js +1 -1
- package/dist/components/table/header/cell.js +3 -3
- package/dist/components/table/header/header.js +2 -2
- package/dist/components/tabs/hooks.d.ts +40 -0
- package/dist/components/tabs/hooks.js +98 -0
- package/dist/components/tabs/navigation.d.ts +4 -0
- package/dist/components/tabs/navigation.js +159 -0
- package/dist/components/tabs/panels.d.ts +4 -0
- package/dist/components/tabs/panels.js +78 -0
- package/dist/components/tabs/tab.d.ts +4 -0
- package/dist/components/tabs/tab.js +19 -0
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +24 -94
- package/dist/components/tabs/types.d.ts +50 -9
- package/dist/components/tag/tag.js +1 -1
- package/dist/components/theme/hooks.js +3 -3
- package/dist/components/time-picker/panel.js +1 -1
- package/dist/components/time-picker/time-picker.js +1 -1
- package/dist/components/timeline/item.d.ts +1 -1
- package/dist/components/timeline/item.js +87 -115
- package/dist/components/timeline/timeline.js +5 -3
- package/dist/components/timeline/types.d.ts +6 -0
- package/dist/components/tour/tour.js +2 -2
- package/dist/components/tree/context.js +2 -0
- package/dist/components/tree/hooks.d.ts +13 -2
- package/dist/components/tree/hooks.js +19 -2
- package/dist/components/tree/list.js +3 -3
- package/dist/components/tree/node.d.ts +1 -1
- package/dist/components/tree/node.js +24 -14
- package/dist/components/tree/tree.d.ts +1 -1
- package/dist/components/tree/tree.js +13 -9
- package/dist/components/tree/types.d.ts +18 -23
- package/dist/components/waterfall/sequential.js +4 -1
- package/dist/components/waterfall/waterfall.js +6 -3
- package/dist/hooks/use-class-names.d.ts +10 -0
- package/dist/stylex.css +41 -25
- package/dist/utils/class-name.d.ts +38 -7
- package/dist/utils/class-name.js +30 -8
- package/package.json +10 -8
- package/dist/components/tabs/item.d.ts +0 -4
- package/dist/components/tabs/item.js +0 -22
- /package/dist/node_modules/.pnpm/{@aiszlab_relax@1.2.55_react-dom@18.3.1_react@18.3.1 → @aiszlab_relax@1.2.56_react-dom@18.3.1_react@18.3.1}/node_modules/@aiszlab/relax/dist/dom/contains.js +0 -0
- /package/dist/node_modules/.pnpm/{@stylexjs_stylex@0.6.1 → @stylexjs_stylex@0.7.4}/node_modules/@stylexjs/stylex/lib/es/stylex.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
3
|
import { Context } from './context.js';
|
|
4
4
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
5
5
|
import { ComponentToken, TimelineClassToken } from '../../utils/class-name.js';
|
|
@@ -9,10 +9,9 @@ import { ColorToken } from '../../utils/colors.js';
|
|
|
9
9
|
|
|
10
10
|
const styles = {
|
|
11
11
|
item: {
|
|
12
|
-
default:
|
|
12
|
+
default: {
|
|
13
13
|
display: "musae-rvj5dj",
|
|
14
14
|
justifyContent: "musae-1nhvcw1",
|
|
15
|
-
alignItems: "musae-6s0dn4",
|
|
16
15
|
gap: "musae-ik99ff",
|
|
17
16
|
rowGap: null,
|
|
18
17
|
columnGap: null,
|
|
@@ -20,117 +19,68 @@ const styles = {
|
|
|
20
19
|
overflowX: null,
|
|
21
20
|
overflowY: null,
|
|
22
21
|
paddingBottom: "musae-1244622",
|
|
23
|
-
backgroundColor: "musae-q1mx2j",
|
|
24
22
|
$$css: true
|
|
25
|
-
},
|
|
26
|
-
"--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial"
|
|
27
|
-
}],
|
|
23
|
+
},
|
|
28
24
|
right: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
gridTemplateAreas: null,
|
|
32
|
-
gridTemplateColumns: null,
|
|
33
|
-
gridTemplateRows: null,
|
|
34
|
-
gridAutoRows: null,
|
|
35
|
-
gridAutoColumns: null,
|
|
36
|
-
gridAutoFlow: null,
|
|
25
|
+
gridTemplateColumns: "musae-1pmbctz",
|
|
26
|
+
gridTemplateAreas: "musae-znaemz",
|
|
37
27
|
$$css: true
|
|
38
28
|
},
|
|
39
29
|
left: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
gridTemplateAreas: null,
|
|
43
|
-
gridTemplateColumns: null,
|
|
44
|
-
gridTemplateRows: null,
|
|
45
|
-
gridAutoRows: null,
|
|
46
|
-
gridAutoColumns: null,
|
|
47
|
-
gridAutoFlow: null,
|
|
48
|
-
$$css: true
|
|
49
|
-
},
|
|
50
|
-
alternate: {
|
|
51
|
-
grid: "musae-1pk7hnv",
|
|
52
|
-
gridTemplate: null,
|
|
53
|
-
gridTemplateAreas: null,
|
|
54
|
-
gridTemplateColumns: null,
|
|
55
|
-
gridTemplateRows: null,
|
|
56
|
-
gridAutoRows: null,
|
|
57
|
-
gridAutoColumns: null,
|
|
58
|
-
gridAutoFlow: null,
|
|
59
|
-
":nth-of-type(2n)_grid": "musae-33een3",
|
|
60
|
-
":nth-of-type(2n)_gridTemplate": null,
|
|
61
|
-
":nth-of-type(2n)_gridTemplateAreas": null,
|
|
62
|
-
":nth-of-type(2n)_gridTemplateColumns": null,
|
|
63
|
-
":nth-of-type(2n)_gridTemplateRows": null,
|
|
64
|
-
":nth-of-type(2n)_gridAutoRows": null,
|
|
65
|
-
":nth-of-type(2n)_gridAutoColumns": null,
|
|
66
|
-
":nth-of-type(2n)_gridAutoFlow": null,
|
|
30
|
+
gridTemplateColumns: "musae-52fmzj",
|
|
31
|
+
gridTemplateAreas: "musae-196jfb2",
|
|
67
32
|
$$css: true
|
|
68
33
|
}
|
|
69
34
|
},
|
|
70
35
|
labeled: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
gridTemplate: null,
|
|
74
|
-
gridTemplateAreas: null,
|
|
75
|
-
gridTemplateColumns: null,
|
|
76
|
-
gridTemplateRows: null,
|
|
77
|
-
gridAutoRows: null,
|
|
78
|
-
gridAutoColumns: null,
|
|
79
|
-
gridAutoFlow: null,
|
|
36
|
+
default: {
|
|
37
|
+
gridTemplateColumns: "musae-134kloy",
|
|
80
38
|
$$css: true
|
|
81
39
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
gridTemplate: null,
|
|
85
|
-
gridTemplateAreas: null,
|
|
86
|
-
gridTemplateColumns: null,
|
|
87
|
-
gridTemplateRows: null,
|
|
88
|
-
gridAutoRows: null,
|
|
89
|
-
gridAutoColumns: null,
|
|
90
|
-
gridAutoFlow: null,
|
|
40
|
+
right: {
|
|
41
|
+
gridTemplateAreas: "musae-1y7mvjm",
|
|
91
42
|
$$css: true
|
|
92
43
|
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
gridTemplate: null,
|
|
96
|
-
gridTemplateAreas: null,
|
|
97
|
-
gridTemplateColumns: null,
|
|
98
|
-
gridTemplateRows: null,
|
|
99
|
-
gridAutoRows: null,
|
|
100
|
-
gridAutoColumns: null,
|
|
101
|
-
gridAutoFlow: null,
|
|
102
|
-
":nth-of-type(2n)_grid": "musae-dv7uk4",
|
|
103
|
-
":nth-of-type(2n)_gridTemplate": null,
|
|
104
|
-
":nth-of-type(2n)_gridTemplateAreas": null,
|
|
105
|
-
":nth-of-type(2n)_gridTemplateColumns": null,
|
|
106
|
-
":nth-of-type(2n)_gridTemplateRows": null,
|
|
107
|
-
":nth-of-type(2n)_gridAutoRows": null,
|
|
108
|
-
":nth-of-type(2n)_gridAutoColumns": null,
|
|
109
|
-
":nth-of-type(2n)_gridAutoFlow": null,
|
|
44
|
+
left: {
|
|
45
|
+
gridTemplateAreas: "musae-hurxv4",
|
|
110
46
|
$$css: true
|
|
111
47
|
}
|
|
112
48
|
},
|
|
113
|
-
|
|
49
|
+
leading: {
|
|
114
50
|
default: {
|
|
115
|
-
|
|
51
|
+
alignSelf: "musae-qcrz7y",
|
|
52
|
+
gridArea: "musae-1kxrqrs",
|
|
116
53
|
gridRow: null,
|
|
117
54
|
gridRowStart: null,
|
|
118
55
|
gridRowEnd: null,
|
|
119
56
|
gridColumn: null,
|
|
120
57
|
gridColumnStart: null,
|
|
121
58
|
gridColumnEnd: null,
|
|
59
|
+
position: "musae-1n2onr6",
|
|
60
|
+
display: "musae-78zum5",
|
|
61
|
+
justifyContent: "musae-l56j7k",
|
|
62
|
+
alignItems: "musae-6s0dn4",
|
|
63
|
+
width: "musae-145rzd9",
|
|
64
|
+
height: "musae-lry4nc",
|
|
122
65
|
$$css: true
|
|
123
|
-
}
|
|
66
|
+
},
|
|
67
|
+
tail: props => [{
|
|
68
|
+
"::after_content": "musae-1s928wv",
|
|
69
|
+
"::after_position": "musae-1j6awrg",
|
|
70
|
+
"::after_height": "musae-p59mhh",
|
|
71
|
+
"::after_width": "musae-etvar1",
|
|
72
|
+
"::after_backgroundColor": "musae-27d4w3",
|
|
73
|
+
"::after_top": "musae-1srwf7z",
|
|
74
|
+
"::after_insetInlineStart": "musae-xsadbs",
|
|
75
|
+
"::after_left": null,
|
|
76
|
+
"::after_right": null,
|
|
77
|
+
$$css: true
|
|
78
|
+
}, {
|
|
79
|
+
"--15iyedw": props.color != null ? props.color : "initial"
|
|
80
|
+
}]
|
|
124
81
|
},
|
|
125
|
-
|
|
82
|
+
dot: {
|
|
126
83
|
default: props => [{
|
|
127
|
-
gridArea: "musae-1kxrqrs",
|
|
128
|
-
gridRow: null,
|
|
129
|
-
gridRowStart: null,
|
|
130
|
-
gridRowEnd: null,
|
|
131
|
-
gridColumn: null,
|
|
132
|
-
gridColumnStart: null,
|
|
133
|
-
gridColumnEnd: null,
|
|
134
84
|
width: "musae-jz7u3w",
|
|
135
85
|
height: "musae-1k820er",
|
|
136
86
|
borderRadius: "musae-iipnba",
|
|
@@ -146,24 +96,28 @@ const styles = {
|
|
|
146
96
|
$$css: true
|
|
147
97
|
}, {
|
|
148
98
|
"--backgroundColor": props.color != null ? props.color : "initial"
|
|
149
|
-
}],
|
|
150
|
-
vertical: props => [{
|
|
151
|
-
position: "musae-1n2onr6",
|
|
152
|
-
"::after_content": "musae-1s928wv",
|
|
153
|
-
"::after_position": "musae-1j6awrg",
|
|
154
|
-
"::after_height": "musae-p59mhh",
|
|
155
|
-
"::after_width": "musae-etvar1",
|
|
156
|
-
"::after_backgroundColor": "musae-27d4w3",
|
|
157
|
-
"::after_marginTop": "musae-dulvvp",
|
|
158
|
-
"::after_top": "musae-1srwf7z",
|
|
159
|
-
"::after_insetInlineStart": "musae-xsadbs",
|
|
160
|
-
"::after_left": null,
|
|
161
|
-
"::after_right": null,
|
|
162
|
-
$$css: true
|
|
163
|
-
}, {
|
|
164
|
-
"--15iyedw": props.color != null ? props.color : "initial"
|
|
165
99
|
}]
|
|
166
100
|
},
|
|
101
|
+
label: {
|
|
102
|
+
default: {
|
|
103
|
+
gridArea: "musae-xwd7sb",
|
|
104
|
+
gridRow: null,
|
|
105
|
+
gridRowStart: null,
|
|
106
|
+
gridRowEnd: null,
|
|
107
|
+
gridColumn: null,
|
|
108
|
+
gridColumnStart: null,
|
|
109
|
+
gridColumnEnd: null,
|
|
110
|
+
$$css: true
|
|
111
|
+
},
|
|
112
|
+
right: {
|
|
113
|
+
justifySelf: "musae-15bdqvn",
|
|
114
|
+
$$css: true
|
|
115
|
+
},
|
|
116
|
+
left: {
|
|
117
|
+
justifySelf: "musae-wldb3t",
|
|
118
|
+
$$css: true
|
|
119
|
+
}
|
|
120
|
+
},
|
|
167
121
|
description: {
|
|
168
122
|
default: {
|
|
169
123
|
gridArea: "musae-19tbii3",
|
|
@@ -174,33 +128,48 @@ const styles = {
|
|
|
174
128
|
gridColumnStart: null,
|
|
175
129
|
gridColumnEnd: null,
|
|
176
130
|
$$css: true
|
|
131
|
+
},
|
|
132
|
+
right: {
|
|
133
|
+
justifySelf: "musae-wldb3t",
|
|
134
|
+
$$css: true
|
|
135
|
+
},
|
|
136
|
+
left: {
|
|
137
|
+
justifySelf: "musae-15bdqvn",
|
|
138
|
+
$$css: true
|
|
177
139
|
}
|
|
178
140
|
}
|
|
179
141
|
};
|
|
180
142
|
const Item = ({
|
|
181
143
|
description,
|
|
182
144
|
label,
|
|
183
|
-
value
|
|
145
|
+
value,
|
|
146
|
+
dot
|
|
184
147
|
}) => {
|
|
185
148
|
const classNames = useClassNames(ComponentToken.Timeline);
|
|
186
149
|
const {
|
|
187
|
-
mode,
|
|
150
|
+
mode: _mode,
|
|
188
151
|
max
|
|
189
152
|
} = useContext(Context);
|
|
190
153
|
const theme = useTheme();
|
|
191
154
|
const isLabeled = !!label;
|
|
192
155
|
const isMax = max === value;
|
|
156
|
+
// convert alternate mode to normal mode
|
|
157
|
+
const mode = useMemo(() => {
|
|
158
|
+
if (_mode === "alternate") {
|
|
159
|
+
return value % 2 === 1 ? "right" : "left";
|
|
160
|
+
}
|
|
161
|
+
return _mode;
|
|
162
|
+
}, [_mode, value]);
|
|
193
163
|
const styled = {
|
|
194
|
-
item: _stylex.props(styles.item.default
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
label: _stylex.props(styles.label.default),
|
|
198
|
-
leading: _stylex.props(styles.leading.default({
|
|
164
|
+
item: _stylex.props(styles.item.default, styles.item[mode], isLabeled && styles.labeled.default, isLabeled && styles.labeled[mode]),
|
|
165
|
+
label: _stylex.props(styles.label.default, styles.label[mode]),
|
|
166
|
+
leading: _stylex.props(styles.leading.default, !isMax && styles.leading.tail({
|
|
199
167
|
color: theme.colors[ColorToken.Primary]
|
|
200
|
-
}),
|
|
168
|
+
})),
|
|
169
|
+
dot: _stylex.props(styles.dot.default({
|
|
201
170
|
color: theme.colors[ColorToken.Primary]
|
|
202
171
|
})),
|
|
203
|
-
description: _stylex.props(styles.description.default)
|
|
172
|
+
description: _stylex.props(styles.description.default, styles.description[mode])
|
|
204
173
|
};
|
|
205
174
|
return React.createElement("li", {
|
|
206
175
|
className: clsx(classNames[TimelineClassToken.Item], styled.item.className),
|
|
@@ -211,7 +180,10 @@ const Item = ({
|
|
|
211
180
|
}, label), React.createElement("div", {
|
|
212
181
|
className: styled.leading.className,
|
|
213
182
|
style: styled.leading.style
|
|
214
|
-
}
|
|
183
|
+
}, dot ?? React.createElement("span", {
|
|
184
|
+
className: styled.dot.className,
|
|
185
|
+
style: styled.dot.style
|
|
186
|
+
})), React.createElement("div", {
|
|
215
187
|
className: styled.description.className,
|
|
216
188
|
style: styled.description.style
|
|
217
189
|
}, description));
|
|
@@ -13,10 +13,11 @@ const Timeline = ({
|
|
|
13
13
|
className: "musae-78zum5 musae-dt5ytf"
|
|
14
14
|
};
|
|
15
15
|
const classNames = useClassNames(ComponentToken.Timeline);
|
|
16
|
+
const total = items.length;
|
|
16
17
|
const contextValue = useMemo(() => ({
|
|
17
18
|
mode,
|
|
18
|
-
max:
|
|
19
|
-
}), [mode,
|
|
19
|
+
max: total - 1
|
|
20
|
+
}), [mode, total]);
|
|
20
21
|
return React.createElement(Context.Provider, {
|
|
21
22
|
value: contextValue
|
|
22
23
|
}, React.createElement("ol", {
|
|
@@ -27,7 +28,8 @@ const Timeline = ({
|
|
|
27
28
|
key: index,
|
|
28
29
|
value: index,
|
|
29
30
|
label: item.label,
|
|
30
|
-
description: item.description
|
|
31
|
+
description: item.description,
|
|
32
|
+
dot: item.dot
|
|
31
33
|
});
|
|
32
34
|
})));
|
|
33
35
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Portal from '../portal/portal.js';
|
|
3
3
|
import Popper from '../popper/popper.js';
|
|
4
|
-
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
4
|
+
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
5
5
|
import Button from '../button/button.js';
|
|
6
6
|
import { useTheme } from '../theme/hooks.js';
|
|
7
7
|
import { ColorToken } from '../../utils/colors.js';
|
|
@@ -17,7 +17,7 @@ import { useGutters } from '../../hooks/use-gutters.js';
|
|
|
17
17
|
const styles = {
|
|
18
18
|
overlay: props => [{
|
|
19
19
|
position: "musae-10l6tqk",
|
|
20
|
-
inset: "musae-
|
|
20
|
+
inset: "musae-10a8y8t",
|
|
21
21
|
insetInline: null,
|
|
22
22
|
insetInlineStart: null,
|
|
23
23
|
insetInlineEnd: null,
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { Key } from "react";
|
|
1
2
|
import type { TreeProps } from "./types";
|
|
2
3
|
/**
|
|
3
4
|
* @description
|
|
4
5
|
* expanded keys
|
|
5
6
|
*/
|
|
6
7
|
export declare const useExpandedKeys: ([expandedKeys, onExpand]: [TreeProps["expandedKeys"], TreeProps["onExpand"]]) => {
|
|
7
|
-
expandedKeys: Set<
|
|
8
|
-
toggle: (key:
|
|
8
|
+
expandedKeys: Set<Key>;
|
|
9
|
+
toggle: (key: Key) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @description
|
|
13
|
+
* selected keys
|
|
14
|
+
*/
|
|
15
|
+
export declare const useSelectedKeys: ({ selectedKeys: _selectedKeys }: {
|
|
16
|
+
selectedKeys?: Key[];
|
|
17
|
+
}) => {
|
|
18
|
+
selectedKeys: Set<Key>;
|
|
19
|
+
toggle: (key: Key) => void;
|
|
9
20
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useControlledState } from '@aiszlab/relax';
|
|
1
|
+
import { useControlledState, useEvent } from '@aiszlab/relax';
|
|
2
2
|
import { useMemo, useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -23,5 +23,22 @@ const useExpandedKeys = ([expandedKeys, onExpand]) => {
|
|
|
23
23
|
toggle,
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* selected keys
|
|
29
|
+
*/
|
|
30
|
+
const useSelectedKeys = ({ selectedKeys: _selectedKeys }) => {
|
|
31
|
+
const [selectedKeys, setSelectedKeys] = useControlledState(_selectedKeys);
|
|
32
|
+
const __selectedKeys = useMemo(() => new Set(selectedKeys), [selectedKeys]);
|
|
33
|
+
const toggle = useEvent((key) => {
|
|
34
|
+
setSelectedKeys(() => {
|
|
35
|
+
return Array.from([key]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
selectedKeys: __selectedKeys,
|
|
40
|
+
toggle,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
26
43
|
|
|
27
|
-
export { useExpandedKeys };
|
|
44
|
+
export { useExpandedKeys, useSelectedKeys };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
1
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import Node from './node.js';
|
|
4
4
|
import clsx from 'clsx';
|
|
@@ -30,7 +30,7 @@ const List = ({
|
|
|
30
30
|
const [scope, animate] = useAnimate();
|
|
31
31
|
const {
|
|
32
32
|
expandedKeys,
|
|
33
|
-
|
|
33
|
+
onExpand
|
|
34
34
|
} = useContext(Context);
|
|
35
35
|
const classNames = useClassNames(ComponentToken.Tree);
|
|
36
36
|
useExpandEffect({
|
|
@@ -57,7 +57,7 @@ const List = ({
|
|
|
57
57
|
return React.createElement(Node, {
|
|
58
58
|
key: node.key,
|
|
59
59
|
value: node.key,
|
|
60
|
-
|
|
60
|
+
onExpand: onExpand,
|
|
61
61
|
title: node.title,
|
|
62
62
|
level: level
|
|
63
63
|
}, children.length > 0 && React.createElement(List, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TreeNodeProps } from "./types";
|
|
3
|
-
declare const Node: ({ value, children, level,
|
|
3
|
+
declare const Node: ({ value, children, level, onExpand, ...props }: TreeNodeProps) => React.JSX.Element;
|
|
4
4
|
export default Node;
|
|
@@ -3,10 +3,11 @@ import { useClassNames } from '../../hooks/use-class-names.js';
|
|
|
3
3
|
import { ComponentToken, TreeClassToken } from '../../utils/class-name.js';
|
|
4
4
|
import Context from './context.js';
|
|
5
5
|
import { Checkbox } from '../checkbox/index.js';
|
|
6
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
6
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import { useTheme } from '../theme/hooks.js';
|
|
9
9
|
import { ColorToken } from '../../utils/colors.js';
|
|
10
|
+
import { useEvent } from '@aiszlab/relax';
|
|
10
11
|
import KeyboardArrowRight from '../icon/icons/hardware/keyboard-arrow-right.js';
|
|
11
12
|
|
|
12
13
|
const styles = {
|
|
@@ -72,27 +73,28 @@ const Node = ({
|
|
|
72
73
|
value,
|
|
73
74
|
children,
|
|
74
75
|
level,
|
|
75
|
-
|
|
76
|
+
onExpand,
|
|
76
77
|
...props$1
|
|
77
78
|
}) => {
|
|
78
79
|
const classNames = useClassNames(ComponentToken.Tree);
|
|
79
80
|
const {
|
|
80
81
|
checkedKeys,
|
|
81
|
-
|
|
82
|
-
expandedKeys
|
|
82
|
+
onCheck,
|
|
83
|
+
expandedKeys,
|
|
84
|
+
onSelect,
|
|
85
|
+
selectedKeys,
|
|
86
|
+
selectable
|
|
83
87
|
} = useContext(Context);
|
|
84
88
|
const isChecked = checkedKeys.has(value);
|
|
85
89
|
const isExpanded = expandedKeys.has(value);
|
|
90
|
+
const isSelected = selectedKeys.has(value);
|
|
86
91
|
const theme = useTheme();
|
|
87
|
-
const check = () => {
|
|
88
|
-
_check?.(value);
|
|
89
|
-
};
|
|
90
92
|
const styled = {
|
|
91
93
|
node: props(styles.node({
|
|
92
94
|
level
|
|
93
95
|
})),
|
|
94
96
|
title: props(styles.title({
|
|
95
|
-
isSelected
|
|
97
|
+
isSelected,
|
|
96
98
|
backgroundColor: theme.colors[ColorToken.SurfaceContainer],
|
|
97
99
|
hoveredBackgroundColor: theme.colors[ColorToken.SurfaceContainer],
|
|
98
100
|
color: theme.colors[ColorToken.Primary]
|
|
@@ -101,9 +103,17 @@ const Node = ({
|
|
|
101
103
|
isExpanded
|
|
102
104
|
}))
|
|
103
105
|
};
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
};
|
|
106
|
+
const check = useEvent(() => {
|
|
107
|
+
onCheck?.(value);
|
|
108
|
+
});
|
|
109
|
+
const expand = useEvent(() => {
|
|
110
|
+
onExpand?.(value);
|
|
111
|
+
});
|
|
112
|
+
const select = useEvent(() => {
|
|
113
|
+
// no action when `selectable` is false
|
|
114
|
+
if (!selectable) return;
|
|
115
|
+
onSelect?.(value);
|
|
116
|
+
});
|
|
107
117
|
return React.createElement("li", {
|
|
108
118
|
className: classNames[TreeClassToken.Holder]
|
|
109
119
|
}, React.createElement("div", {
|
|
@@ -112,15 +122,15 @@ const Node = ({
|
|
|
112
122
|
}, React.createElement("span", {
|
|
113
123
|
className: clsx(classNames[TreeClassToken.Expander], styled.expander.className),
|
|
114
124
|
style: styled.expander.style,
|
|
115
|
-
onClick:
|
|
125
|
+
onClick: expand
|
|
116
126
|
}, !!children && React.createElement(KeyboardArrowRight, null)), React.createElement(Checkbox, {
|
|
117
127
|
className: clsx(classNames[TreeClassToken.Checkbox]),
|
|
118
128
|
checked: isChecked,
|
|
119
|
-
|
|
129
|
+
onChange: check
|
|
120
130
|
}), React.createElement("span", {
|
|
121
131
|
className: clsx(classNames[TreeClassToken.Title], styled.title.className),
|
|
122
132
|
style: styled.title.style,
|
|
123
|
-
onClick:
|
|
133
|
+
onClick: select
|
|
124
134
|
}, props$1.title)), children);
|
|
125
135
|
};
|
|
126
136
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TreeProps } from "./types";
|
|
3
|
-
declare const Tree: ({ expandedKeys: _expandedKeys, onExpand, className, style,
|
|
3
|
+
declare const Tree: ({ expandedKeys: _expandedKeys, onExpand, className, style, nodes, selectable, selectedKeys: _selectedKeys, }: TreeProps) => React.JSX.Element;
|
|
4
4
|
export default Tree;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import List from './list.js';
|
|
3
3
|
import Context from './context.js';
|
|
4
|
-
import {
|
|
5
|
-
import { useExpandedKeys } from './hooks.js';
|
|
4
|
+
import { useTogglable } from '@aiszlab/relax';
|
|
5
|
+
import { useExpandedKeys, useSelectedKeys } from './hooks.js';
|
|
6
6
|
|
|
7
|
-
const Tree = ({ expandedKeys: _expandedKeys, onExpand, className, style,
|
|
8
|
-
const { toggledKeys: checkedKeys, toggle: check } =
|
|
9
|
-
const {
|
|
7
|
+
const Tree = ({ expandedKeys: _expandedKeys, onExpand, className, style, nodes, selectable = true, selectedKeys: _selectedKeys, }) => {
|
|
8
|
+
const { toggledKeys: checkedKeys, toggle: check } = useTogglable(nodes);
|
|
9
|
+
const { expandedKeys, toggle: expand } = useExpandedKeys([_expandedKeys, onExpand]);
|
|
10
|
+
const { selectedKeys, toggle: select } = useSelectedKeys({ selectedKeys: _selectedKeys });
|
|
10
11
|
const contextValue = useMemo(() => {
|
|
11
12
|
return {
|
|
12
13
|
checkedKeys,
|
|
13
|
-
check,
|
|
14
|
+
onCheck: check,
|
|
14
15
|
expandedKeys,
|
|
15
|
-
|
|
16
|
+
onExpand: expand,
|
|
17
|
+
selectedKeys,
|
|
18
|
+
onSelect: select,
|
|
19
|
+
selectable,
|
|
16
20
|
};
|
|
17
|
-
}, [check, checkedKeys,
|
|
21
|
+
}, [check, checkedKeys, expand, expandedKeys, select, selectedKeys, selectable]);
|
|
18
22
|
return (React.createElement(Context.Provider, { value: contextValue },
|
|
19
|
-
React.createElement(List, { nodes:
|
|
23
|
+
React.createElement(List, { nodes: nodes, className: className, style: style })));
|
|
20
24
|
};
|
|
21
25
|
var Tree$1 = Tree;
|
|
22
26
|
|
|
@@ -44,6 +44,18 @@ export type TreeProps = ComponentProps & {
|
|
|
44
44
|
* @default void 0
|
|
45
45
|
*/
|
|
46
46
|
onExpand?: (keys: Key[]) => void;
|
|
47
|
+
/**
|
|
48
|
+
* @description
|
|
49
|
+
* selectable
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
selectable?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @description
|
|
55
|
+
* selected keys
|
|
56
|
+
* @default void 0
|
|
57
|
+
*/
|
|
58
|
+
selectedKeys?: Key[];
|
|
47
59
|
};
|
|
48
60
|
/**
|
|
49
61
|
* @description
|
|
@@ -64,7 +76,7 @@ export type TreeNodeProps = WithLevel<Omit<TreeNode, "children" | "key">> & {
|
|
|
64
76
|
* @description
|
|
65
77
|
* expand handler
|
|
66
78
|
*/
|
|
67
|
-
|
|
79
|
+
onExpand?: (key: Key) => void;
|
|
68
80
|
};
|
|
69
81
|
/**
|
|
70
82
|
* @description
|
|
@@ -87,31 +99,14 @@ export type TreeListProps = ComponentProps & {
|
|
|
87
99
|
*/
|
|
88
100
|
level?: number;
|
|
89
101
|
};
|
|
90
|
-
/**
|
|
91
|
-
* @description
|
|
92
|
-
* context value
|
|
93
|
-
*/
|
|
94
102
|
export type ContextValue = {
|
|
95
|
-
/**
|
|
96
|
-
* @description
|
|
97
|
-
* checked keys
|
|
98
|
-
*/
|
|
99
103
|
checkedKeys: Set<Key>;
|
|
100
|
-
|
|
101
|
-
* @description
|
|
102
|
-
* check
|
|
103
|
-
*/
|
|
104
|
-
check?: (key: Key) => void;
|
|
105
|
-
/**
|
|
106
|
-
* @description
|
|
107
|
-
* expandedKeys
|
|
108
|
-
*/
|
|
104
|
+
onCheck?: (key: Key) => void;
|
|
109
105
|
expandedKeys: Set<Key>;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
toggle?: (key: Key) => void;
|
|
106
|
+
onExpand?: (key: Key) => void;
|
|
107
|
+
selectedKeys: Set<Key>;
|
|
108
|
+
onSelect?: (key: Key) => void;
|
|
109
|
+
selectable: boolean;
|
|
115
110
|
};
|
|
116
111
|
/**
|
|
117
112
|
* @description
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
2
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
3
|
|
|
4
4
|
const styles = {
|
|
5
5
|
column: props => [{
|
|
@@ -10,6 +10,9 @@ const styles = {
|
|
|
10
10
|
display: "musae-78zum5",
|
|
11
11
|
flexDirection: "musae-dt5ytf",
|
|
12
12
|
rowGap: "musae-m8a6f2",
|
|
13
|
+
overflow: "musae-ysyzu8",
|
|
14
|
+
overflowX: null,
|
|
15
|
+
overflowY: null,
|
|
13
16
|
$$css: true
|
|
14
17
|
}, {
|
|
15
18
|
"--rowGap": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.rowGap)
|