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
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React, { useRef, useEffect } from 'react';
|
|
3
|
+
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
4
|
+
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
5
|
+
import { ComponentToken, TabsClassToken } from '../../utils/class-name.js';
|
|
6
|
+
import Tab from './tab.js';
|
|
7
|
+
import { useAnimate } from 'framer-motion';
|
|
8
|
+
import { isUndefined } from '@aiszlab/relax';
|
|
9
|
+
import { useTheme } from '../theme/hooks.js';
|
|
10
|
+
import { ColorToken } from '../../utils/colors.js';
|
|
11
|
+
import { useTabsContext, useNavigation, useNavigatorScroll } from './hooks.js';
|
|
12
|
+
|
|
13
|
+
const styles = {
|
|
14
|
+
navigation: {
|
|
15
|
+
default: props => [{
|
|
16
|
+
borderBottomColor: "musae-43481e",
|
|
17
|
+
borderBottomWidth: "musae-lntmim",
|
|
18
|
+
borderBottomStyle: "musae-1q0q8m5",
|
|
19
|
+
$$css: true
|
|
20
|
+
}, {
|
|
21
|
+
"--borderBottomColor": props.outlineColor != null ? props.outlineColor : "initial"
|
|
22
|
+
}]
|
|
23
|
+
},
|
|
24
|
+
navigator: {
|
|
25
|
+
default: {
|
|
26
|
+
position: "musae-1n2onr6",
|
|
27
|
+
overflow: "musae-b3r6kr",
|
|
28
|
+
overflowX: null,
|
|
29
|
+
overflowY: null,
|
|
30
|
+
$$css: true
|
|
31
|
+
},
|
|
32
|
+
leading: {
|
|
33
|
+
"::before_content": "musae-1cpjm7i",
|
|
34
|
+
"::before_position": "musae-1hmns74",
|
|
35
|
+
"::before_insetBlock": "musae-1nc033x",
|
|
36
|
+
"::before_top": null,
|
|
37
|
+
"::before_bottom": null,
|
|
38
|
+
"::before_insetInlineStart": "musae-1682cnc",
|
|
39
|
+
"::before_left": null,
|
|
40
|
+
"::before_right": null,
|
|
41
|
+
"::before_pointerEvents": "musae-kk1bqk",
|
|
42
|
+
"::before_width": "musae-bk3rzz",
|
|
43
|
+
"::before_boxShadow": "musae-91zhsk",
|
|
44
|
+
$$css: true
|
|
45
|
+
},
|
|
46
|
+
trailing: {
|
|
47
|
+
"::after_content": "musae-1s928wv",
|
|
48
|
+
"::after_position": "musae-1j6awrg",
|
|
49
|
+
"::after_insetBlock": "musae-d54j2p",
|
|
50
|
+
"::after_top": null,
|
|
51
|
+
"::after_bottom": null,
|
|
52
|
+
"::after_insetInlineEnd": "musae-1unh1gc",
|
|
53
|
+
"::after_left": null,
|
|
54
|
+
"::after_right": null,
|
|
55
|
+
"::after_pointerEvents": "musae-2q1x1w",
|
|
56
|
+
"::after_width": "musae-g1t9zo",
|
|
57
|
+
"::after_boxShadow": "musae-15cyge6",
|
|
58
|
+
$$css: true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
list: {
|
|
62
|
+
default: props => [{
|
|
63
|
+
display: "musae-78zum5",
|
|
64
|
+
width: "musae-eq5yr9",
|
|
65
|
+
transform: "musae-1v0jg1i",
|
|
66
|
+
$$css: true
|
|
67
|
+
}, {
|
|
68
|
+
"--transform": `translateX(-${props.offset}px)` != null ? `translateX(-${props.offset}px)` : "initial"
|
|
69
|
+
}]
|
|
70
|
+
},
|
|
71
|
+
indicator: {
|
|
72
|
+
default: props => [{
|
|
73
|
+
height: "musae-kzsoxx",
|
|
74
|
+
backgroundColor: "musae-q1mx2j",
|
|
75
|
+
position: "musae-10l6tqk",
|
|
76
|
+
bottom: "musae-8wmlod",
|
|
77
|
+
$$css: true
|
|
78
|
+
}, {
|
|
79
|
+
"--backgroundColor": props.color != null ? props.color : "initial"
|
|
80
|
+
}]
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const Navigation = ({
|
|
84
|
+
onChange
|
|
85
|
+
}) => {
|
|
86
|
+
const {
|
|
87
|
+
activeKey,
|
|
88
|
+
items
|
|
89
|
+
} = useTabsContext();
|
|
90
|
+
const classNames = useClassNames(ComponentToken.Tabs);
|
|
91
|
+
const [indicatorRef, animateIndicator] = useAnimate();
|
|
92
|
+
const tabRefs = useRef(new Map());
|
|
93
|
+
const theme = useTheme();
|
|
94
|
+
const {
|
|
95
|
+
navigatorRef,
|
|
96
|
+
tabsRef,
|
|
97
|
+
scroll,
|
|
98
|
+
offset,
|
|
99
|
+
isLeadingOverflow,
|
|
100
|
+
isTrailingOverflow
|
|
101
|
+
} = useNavigation();
|
|
102
|
+
// control tabs scroll
|
|
103
|
+
useNavigatorScroll({
|
|
104
|
+
navigatorRef,
|
|
105
|
+
scroll
|
|
106
|
+
});
|
|
107
|
+
const styled = {
|
|
108
|
+
navigation: _stylex.props(styles.navigation.default({
|
|
109
|
+
outlineColor: theme.colors[ColorToken.Outline]
|
|
110
|
+
})),
|
|
111
|
+
navigator: _stylex.props(styles.navigator.default, isLeadingOverflow && styles.navigator.leading, isTrailingOverflow && styles.navigator.trailing),
|
|
112
|
+
list: _stylex.props(styles.list.default({
|
|
113
|
+
offset
|
|
114
|
+
})),
|
|
115
|
+
indicator: _stylex.props(styles.indicator.default({
|
|
116
|
+
color: theme.colors[ColorToken.Primary]
|
|
117
|
+
}))
|
|
118
|
+
};
|
|
119
|
+
// repaint indicator when activeKey changed
|
|
120
|
+
// animate indicator to correct position & width
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (isUndefined(activeKey)) return;
|
|
123
|
+
const tab = tabRefs.current.get(activeKey);
|
|
124
|
+
animateIndicator(indicatorRef.current, {
|
|
125
|
+
left: tab?.offsetLeft,
|
|
126
|
+
width: tab?.clientWidth
|
|
127
|
+
});
|
|
128
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
+
}, [activeKey]);
|
|
130
|
+
return React.createElement("div", {
|
|
131
|
+
role: "tablist",
|
|
132
|
+
className: clsx(classNames[TabsClassToken.TabsNavigation], styled.navigation.className),
|
|
133
|
+
style: styled.navigation.style
|
|
134
|
+
}, React.createElement("div", {
|
|
135
|
+
ref: navigatorRef,
|
|
136
|
+
className: clsx(classNames[TabsClassToken.TabsNavigator], styled.navigator.className),
|
|
137
|
+
style: styled.navigator.style
|
|
138
|
+
}, React.createElement("div", {
|
|
139
|
+
ref: tabsRef,
|
|
140
|
+
className: clsx(classNames[TabsClassToken.TabList], styled.list.className),
|
|
141
|
+
style: styled.list.style
|
|
142
|
+
}, items.map(item => {
|
|
143
|
+
return React.createElement(Tab, {
|
|
144
|
+
key: item.key,
|
|
145
|
+
value: item.key,
|
|
146
|
+
label: item.label,
|
|
147
|
+
onClick: onChange,
|
|
148
|
+
ref: _tab => {
|
|
149
|
+
tabRefs.current.set(item.key, _tab);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}), React.createElement("div", {
|
|
153
|
+
ref: indicatorRef,
|
|
154
|
+
className: clsx(classNames[TabsClassToken.Indicator], styled.indicator.className),
|
|
155
|
+
style: styled.indicator.style
|
|
156
|
+
}))), React.createElement("div", null));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export { Navigation as default };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
|
+
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
4
|
+
import { ComponentToken, TabsClassToken } from '../../utils/class-name.js';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { isUndefined, isVoid } from '@aiszlab/relax';
|
|
7
|
+
import { useTabsContext } from './hooks.js';
|
|
8
|
+
|
|
9
|
+
const styles = {
|
|
10
|
+
panels: {
|
|
11
|
+
default: {
|
|
12
|
+
marginTop: "musae-u5ntsc",
|
|
13
|
+
$$css: true
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
panel: {
|
|
17
|
+
default: {
|
|
18
|
+
$$css: true
|
|
19
|
+
},
|
|
20
|
+
active: {
|
|
21
|
+
display: null,
|
|
22
|
+
$$css: true
|
|
23
|
+
},
|
|
24
|
+
hidden: {
|
|
25
|
+
display: "musae-1s85apg",
|
|
26
|
+
$$css: true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const Panels = ({
|
|
31
|
+
forceRender,
|
|
32
|
+
destroyable,
|
|
33
|
+
activatedKeys
|
|
34
|
+
}) => {
|
|
35
|
+
const {
|
|
36
|
+
items,
|
|
37
|
+
activeKey
|
|
38
|
+
} = useTabsContext();
|
|
39
|
+
const classNames = useClassNames(ComponentToken.Tabs);
|
|
40
|
+
const styled = {
|
|
41
|
+
panels: _stylex.props(styles.panels.default),
|
|
42
|
+
panel: {
|
|
43
|
+
active: _stylex.props(styles.panel.default, styles.panel.active),
|
|
44
|
+
hidden: _stylex.props(styles.panel.default, styles.panel.hidden)
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const panels = useMemo(() => {
|
|
48
|
+
if (isUndefined(activeKey)) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
if (destroyable) {
|
|
52
|
+
return [[activeKey, items.find(item => item.key === activeKey)?.children]];
|
|
53
|
+
}
|
|
54
|
+
if (forceRender) {
|
|
55
|
+
return items.map(item => [item.key, item.children]);
|
|
56
|
+
}
|
|
57
|
+
return items.map(item => [item.key, activatedKeys.has(item.key) ? item.children : null]);
|
|
58
|
+
}, [destroyable, forceRender, items, activeKey, activatedKeys]);
|
|
59
|
+
return React.createElement("div", {
|
|
60
|
+
className: clsx(classNames[TabsClassToken.Panels], styled.panels.className),
|
|
61
|
+
style: styled.panels.style
|
|
62
|
+
}, panels.map(([key, children]) => {
|
|
63
|
+
const {
|
|
64
|
+
className,
|
|
65
|
+
style
|
|
66
|
+
} = key === activeKey ? styled.panel.active : styled.panel.hidden;
|
|
67
|
+
if (isVoid(children)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return React.createElement("div", {
|
|
71
|
+
key: key,
|
|
72
|
+
className: clsx(classNames[TabsClassToken.Panel], className),
|
|
73
|
+
style: style
|
|
74
|
+
}, children);
|
|
75
|
+
}));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export { Panels as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { forwardRef, useContext, useCallback } from 'react';
|
|
2
|
+
import Button from '../button/button.js';
|
|
3
|
+
import Context from './context.js';
|
|
4
|
+
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
5
|
+
import { ComponentToken, TabsClassToken } from '../../utils/class-name.js';
|
|
6
|
+
|
|
7
|
+
const Tab = forwardRef(({ value, onClick, label }, ref) => {
|
|
8
|
+
const { activeKey } = useContext(Context) ?? {};
|
|
9
|
+
const isActive = activeKey === value;
|
|
10
|
+
const classNames = useClassNames(ComponentToken.Tabs);
|
|
11
|
+
const click = useCallback(() => {
|
|
12
|
+
onClick(value);
|
|
13
|
+
}, [onClick, value]);
|
|
14
|
+
return (React.createElement(Button, { variant: "text", color: isActive ? "primary" : "secondary", ref: ref, onClick: click, className: classNames[TabsClassToken.Tab], ripple: false, style: {
|
|
15
|
+
borderRadius: "10% 10% 0 0",
|
|
16
|
+
} }, label));
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { Tab as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TabsProps } from "./types";
|
|
3
|
-
declare const Tabs: ({ items, className, style,
|
|
3
|
+
declare const Tabs: ({ items, className, style, activeKey: _activeKey, defaultActiveKey, forceRender, destroyable, }: TabsProps) => React.JSX.Element | null;
|
|
4
4
|
export default Tabs;
|
|
@@ -1,103 +1,33 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { useControlledState, useMounted } from '@aiszlab/relax';
|
|
3
|
-
import { useAnimate } from 'framer-motion';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
4
2
|
import Context from './context.js';
|
|
5
|
-
import Item from './item.js';
|
|
6
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
7
|
-
import { useTheme } from '../theme/hooks.js';
|
|
8
|
-
import { ColorToken } from '../../utils/colors.js';
|
|
9
3
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
10
4
|
import { ComponentToken, TabsClassToken } from '../../utils/class-name.js';
|
|
11
5
|
import clsx from 'clsx';
|
|
6
|
+
import { useTabs } from './hooks.js';
|
|
7
|
+
import Panels from './panels.js';
|
|
8
|
+
import Navigation from './navigation.js';
|
|
12
9
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
borderBottomStyle: "musae-1q0q8m5",
|
|
19
|
-
position: "musae-1n2onr6",
|
|
20
|
-
$$css: true
|
|
21
|
-
}, {
|
|
22
|
-
"--borderBottomColor": props.outline != null ? props.outline : "initial"
|
|
23
|
-
}],
|
|
24
|
-
indicator: props => [{
|
|
25
|
-
height: "musae-kzsoxx",
|
|
26
|
-
backgroundColor: "musae-q1mx2j",
|
|
27
|
-
position: "musae-10l6tqk",
|
|
28
|
-
bottom: "musae-8wmlod",
|
|
29
|
-
$$css: true
|
|
30
|
-
}, {
|
|
31
|
-
"--backgroundColor": props.color != null ? props.color : "initial"
|
|
32
|
-
}]
|
|
33
|
-
};
|
|
34
|
-
const Tabs = ({
|
|
35
|
-
items = [],
|
|
36
|
-
className,
|
|
37
|
-
style,
|
|
38
|
-
...props$1
|
|
39
|
-
}) => {
|
|
40
|
-
const [_activeKey, _setActiveKey] = useControlledState(props$1.activeKey, {
|
|
41
|
-
defaultState: items.at(0)?.key
|
|
42
|
-
});
|
|
43
|
-
const [indicatorScope, animateIndicatorScope] = useAnimate();
|
|
44
|
-
const tabItemRefs = useRef(new Map());
|
|
45
|
-
const theme = useTheme();
|
|
46
|
-
const classNames = useClassNames(ComponentToken.Tabs);
|
|
47
|
-
useMounted(() => {
|
|
48
|
-
animateIndicatorScope(indicatorScope.current, {
|
|
49
|
-
width: tabItemRefs.current.get(_activeKey)?.clientWidth
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
/// context value
|
|
53
|
-
const contextValue = useMemo(() => {
|
|
54
|
-
return {
|
|
55
|
-
activeKey: _activeKey,
|
|
56
|
-
setItem: (key, itemRef) => {
|
|
57
|
-
tabItemRefs.current.set(key, itemRef);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}, [_activeKey]);
|
|
61
|
-
const onItemClick = useCallback(key => {
|
|
62
|
-
const _activeTabItem = tabItemRefs.current.get(key);
|
|
63
|
-
// move indicator to active tab item
|
|
64
|
-
animateIndicatorScope(indicatorScope.current, {
|
|
65
|
-
left: _activeTabItem?.offsetLeft,
|
|
66
|
-
width: _activeTabItem?.clientWidth
|
|
67
|
-
});
|
|
68
|
-
_setActiveKey(key);
|
|
69
|
-
}, [_setActiveKey, animateIndicatorScope, indicatorScope]);
|
|
70
|
-
/// if there is not any item, return null
|
|
71
|
-
if (items.length === 0) return null;
|
|
72
|
-
const styled = {
|
|
73
|
-
tabs: props(styles.tabs({
|
|
74
|
-
outline: theme.colors[ColorToken.Outline]
|
|
75
|
-
})),
|
|
76
|
-
indicator: props(styles.indicator({
|
|
77
|
-
color: theme.colors[ColorToken.Primary]
|
|
78
|
-
}))
|
|
79
|
-
};
|
|
80
|
-
return React.createElement(Context.Provider, {
|
|
81
|
-
value: contextValue
|
|
82
|
-
}, React.createElement("div", {
|
|
83
|
-
role: "tablist",
|
|
84
|
-
className: clsx(classNames[TabsClassToken.Tabs], className, styled.tabs.className),
|
|
85
|
-
style: {
|
|
86
|
-
...styled.tabs.style,
|
|
87
|
-
...style
|
|
88
|
-
}
|
|
89
|
-
}, items.map(tabItem => {
|
|
90
|
-
return React.createElement(Item, {
|
|
91
|
-
key: tabItem.key,
|
|
92
|
-
value: tabItem.key,
|
|
93
|
-
label: tabItem.label,
|
|
94
|
-
onClick: onItemClick
|
|
10
|
+
const Tabs = ({ items = [], className, style, activeKey: _activeKey, defaultActiveKey, forceRender = false, destroyable = false, }) => {
|
|
11
|
+
const { activeKey, activatedKeys, changeActiveKey } = useTabs({
|
|
12
|
+
items,
|
|
13
|
+
activeKey: _activeKey,
|
|
14
|
+
defaultActiveKey,
|
|
95
15
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
16
|
+
const classNames = useClassNames(ComponentToken.Tabs);
|
|
17
|
+
/// context value
|
|
18
|
+
const contextValue = useMemo(() => {
|
|
19
|
+
return {
|
|
20
|
+
activeKey,
|
|
21
|
+
items,
|
|
22
|
+
};
|
|
23
|
+
}, [activeKey, items]);
|
|
24
|
+
// if there is not any item, return null
|
|
25
|
+
if (items.length === 0)
|
|
26
|
+
return null;
|
|
27
|
+
return (React.createElement(Context.Provider, { value: contextValue },
|
|
28
|
+
React.createElement("div", { className: clsx(classNames[TabsClassToken.Tabs], className), style: style },
|
|
29
|
+
React.createElement(Navigation, { onChange: changeActiveKey }),
|
|
30
|
+
React.createElement(Panels, { activatedKeys: activatedKeys, destroyable: destroyable, forceRender: forceRender }))));
|
|
101
31
|
};
|
|
102
32
|
var Tabs$1 = Tabs;
|
|
103
33
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Key, ReactNode } from "react";
|
|
2
|
+
import type { ComponentProps } from "../../types/element";
|
|
2
3
|
export interface TabsProps extends ComponentProps {
|
|
3
4
|
/**
|
|
4
5
|
* @description
|
|
@@ -11,7 +12,25 @@ export interface TabsProps extends ComponentProps {
|
|
|
11
12
|
* activeKey
|
|
12
13
|
* @default void 0
|
|
13
14
|
*/
|
|
14
|
-
activeKey?:
|
|
15
|
+
activeKey?: Key;
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* default active key
|
|
19
|
+
* @default void 0
|
|
20
|
+
*/
|
|
21
|
+
defaultActiveKey?: Key;
|
|
22
|
+
/**
|
|
23
|
+
* @description
|
|
24
|
+
* forceRender
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
forceRender?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @description
|
|
30
|
+
* destroyable
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
destroyable?: boolean;
|
|
15
34
|
}
|
|
16
35
|
export interface TabItemProps {
|
|
17
36
|
/**
|
|
@@ -19,7 +38,7 @@ export interface TabItemProps {
|
|
|
19
38
|
* value
|
|
20
39
|
* @requires
|
|
21
40
|
*/
|
|
22
|
-
value:
|
|
41
|
+
value: Key;
|
|
23
42
|
/**
|
|
24
43
|
* @description
|
|
25
44
|
* label
|
|
@@ -31,7 +50,7 @@ export interface TabItemProps {
|
|
|
31
50
|
* on tab item click
|
|
32
51
|
* @requires
|
|
33
52
|
*/
|
|
34
|
-
onClick: (key:
|
|
53
|
+
onClick: (key: Key) => void;
|
|
35
54
|
}
|
|
36
55
|
export type TabItem = {
|
|
37
56
|
/**
|
|
@@ -39,23 +58,45 @@ export type TabItem = {
|
|
|
39
58
|
* key
|
|
40
59
|
* @requires
|
|
41
60
|
*/
|
|
42
|
-
key:
|
|
61
|
+
key: Key;
|
|
43
62
|
/**
|
|
44
63
|
* @description
|
|
45
64
|
* label
|
|
46
65
|
* @requires
|
|
47
66
|
*/
|
|
48
67
|
label: string;
|
|
68
|
+
/**
|
|
69
|
+
* @description
|
|
70
|
+
* children
|
|
71
|
+
* @default void 0
|
|
72
|
+
*/
|
|
73
|
+
children?: ReactNode;
|
|
49
74
|
};
|
|
50
75
|
export interface ContextValue {
|
|
51
76
|
/**
|
|
52
77
|
* @description
|
|
53
|
-
*
|
|
78
|
+
* active key
|
|
54
79
|
*/
|
|
55
|
-
|
|
80
|
+
activeKey?: Key;
|
|
56
81
|
/**
|
|
57
82
|
* @description
|
|
58
|
-
*
|
|
83
|
+
* items
|
|
59
84
|
*/
|
|
60
|
-
|
|
85
|
+
items: TabItem[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @description
|
|
89
|
+
* panels props
|
|
90
|
+
*/
|
|
91
|
+
export interface PanelsProps {
|
|
92
|
+
forceRender: boolean;
|
|
93
|
+
destroyable: boolean;
|
|
94
|
+
activatedKeys: Set<Key>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @description
|
|
98
|
+
* navigation props
|
|
99
|
+
*/
|
|
100
|
+
export interface NavigationProps {
|
|
101
|
+
onChange: (key: Key) => void;
|
|
61
102
|
}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
4
4
|
import { ComponentToken, TagClassToken } from '../../utils/class-name.js';
|
|
5
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
5
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
6
6
|
import { useTheme } from '../theme/hooks.js';
|
|
7
7
|
import { typography } from '../theme/theme.js';
|
|
8
8
|
import { ColorToken } from '../../utils/colors.js';
|
|
@@ -137,10 +137,10 @@ const useSwitchable = ({
|
|
|
137
137
|
className: "musae-ynce87 musae-15342hd musae-goest1 musae-1sgbmat"
|
|
138
138
|
},
|
|
139
139
|
light: {
|
|
140
|
-
className: "musae-9xs3e7 musae-c28cl8"
|
|
140
|
+
className: "musae-19aimcq musae-9xs3e7 musae-c28cl8"
|
|
141
141
|
},
|
|
142
142
|
dark: {
|
|
143
|
-
className: "musae-ktw8en musae-qotmtd"
|
|
143
|
+
className: "musae-ntwwlm musae-ktw8en musae-qotmtd"
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
const _toggle = useCallback(() => {
|
|
@@ -150,7 +150,7 @@ const useSwitchable = ({
|
|
|
150
150
|
const _isDark = _mode === "dark";
|
|
151
151
|
document.documentElement.classList.remove(...toClassList((_isDark ? styled.light : styled.dark).className));
|
|
152
152
|
document.documentElement.classList.add(...toClassList(styled[_mode].className));
|
|
153
|
-
document.documentElement.
|
|
153
|
+
document.documentElement.style.backgroundColor = _isDark ? theme.palette.neutral[0] : theme.palette.neutral[100];
|
|
154
154
|
});
|
|
155
155
|
useMounted(() => {
|
|
156
156
|
// set default class names
|
|
@@ -4,7 +4,7 @@ import { useClassNames } from '../../hooks/use-class-names.js';
|
|
|
4
4
|
import { ComponentToken, TimePickerClassToken } from '../../utils/class-name.js';
|
|
5
5
|
import Button from '../button/button.js';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
7
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
8
8
|
import { useTheme } from '../theme/hooks.js';
|
|
9
9
|
import { ColorToken } from '../../utils/colors.js';
|
|
10
10
|
import clsx from 'clsx';
|
|
@@ -5,7 +5,7 @@ import { useClassNames } from '../../hooks/use-class-names.js';
|
|
|
5
5
|
import { ComponentToken, TimePickerClassToken } from '../../utils/class-name.js';
|
|
6
6
|
import Panel from './panel.js';
|
|
7
7
|
import { useValue } from './hooks.js';
|
|
8
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
8
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.4/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
9
9
|
import { useEvent } from '@aiszlab/relax';
|
|
10
10
|
import { styles } from '../input/input.js';
|
|
11
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TimelineItemProps } from "./types";
|
|
3
|
-
declare const Item: ({ description, label, value }: TimelineItemProps) => React.JSX.Element;
|
|
3
|
+
declare const Item: ({ description, label, value, dot }: TimelineItemProps) => React.JSX.Element;
|
|
4
4
|
export default Item;
|