musae 0.2.5 → 0.2.7
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 +14 -16
- 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 +205 -143
- package/dist/components/checkbox/group.d.ts +1 -1
- package/dist/components/checkbox/group.js +20 -19
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/checkbox/types.d.ts +31 -4
- package/dist/components/clock/column.js +1 -1
- package/dist/components/collapse/collapse.js +1 -1
- package/dist/components/collapse/item.js +15 -9
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/dialog/popup.js +5 -5
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.js +1 -1
- package/dist/components/drawer/popup.js +17 -17
- package/dist/components/empty/empty.js +1 -1
- package/dist/components/floating-action-button/floatable.d.ts +4 -0
- package/dist/components/floating-action-button/floatable.js +83 -0
- package/dist/components/floating-action-button/floating-action-button.d.ts +4 -0
- package/dist/components/floating-action-button/floating-action-button.js +26 -0
- package/dist/components/floating-action-button/index.d.ts +2 -0
- package/dist/components/floating-action-button/types.d.ts +44 -0
- package/dist/components/form/field/error.d.ts +2 -2
- package/dist/components/form/field/error.js +36 -22
- package/dist/components/form/field/field.js +6 -21
- 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.d.ts +1 -1
- package/dist/components/icon/icon.js +5 -3
- package/dist/components/icon/types.d.ts +6 -1
- package/dist/components/image/image.js +3 -2
- package/dist/components/image/preview/operations.js +5 -5
- package/dist/components/image/preview/preview.js +1 -1
- package/dist/components/input/input.d.ts +6 -6
- package/dist/components/input/input.js +9 -15
- 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 +29 -9
- 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 +14 -15
- package/dist/components/notification/notification.js +3 -3
- package/dist/components/otp-input/otp-input.js +1 -1
- package/dist/components/pagination/hooks.d.ts +4 -2
- package/dist/components/pagination/hooks.js +9 -4
- package/dist/components/pagination/item.js +6 -8
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/pagination/pagination.js +37 -9
- package/dist/components/pagination/types.d.ts +6 -0
- package/dist/components/picker/picker.js +2 -2
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/popper/dropdown.js +3 -3
- package/dist/components/popper/popper.js +1 -1
- package/dist/components/portal/portal.js +6 -2
- package/dist/components/portal/types.d.ts +6 -0
- 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/hooks.d.ts +1 -1
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.js +5 -5
- package/dist/components/select/selector.d.ts +3 -6
- package/dist/components/select/selector.js +16 -10
- package/dist/components/select/types.d.ts +3 -1
- package/dist/components/space/space.js +1 -1
- package/dist/components/steps/item.d.ts +1 -1
- package/dist/components/steps/item.js +77 -16
- package/dist/components/steps/steps.d.ts +1 -1
- package/dist/components/steps/steps.js +6 -4
- package/dist/components/steps/types.d.ts +15 -0
- 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/theme/tokens.stylex.d.ts +1 -0
- 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 +107 -119
- package/dist/components/timeline/timeline.d.ts +1 -1
- package/dist/components/timeline/timeline.js +8 -4
- package/dist/components/timeline/types.d.ts +16 -0
- package/dist/components/tour/tour.js +4 -3
- package/dist/components/transfer/context.d.ts +6 -0
- package/dist/components/transfer/context.js +11 -0
- package/dist/components/transfer/hooks.d.ts +19 -0
- package/dist/components/transfer/hooks.js +49 -0
- package/dist/components/transfer/index.d.ts +2 -0
- package/dist/components/transfer/item.d.ts +4 -0
- package/dist/components/transfer/item.js +25 -0
- package/dist/components/transfer/list.d.ts +4 -0
- package/dist/components/transfer/list.js +122 -0
- package/dist/components/transfer/transfer.d.ts +4 -0
- package/dist/components/transfer/transfer.js +82 -0
- package/dist/components/transfer/types.d.ts +83 -0
- 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 +16 -9
- 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 +27 -1
- package/dist/hooks/use-container.d.ts +11 -0
- package/dist/hooks/use-container.js +23 -0
- package/dist/hooks/use-expandable.d.ts +11 -0
- package/dist/hooks/use-expandable.js +37 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/stylex.css +61 -40
- package/dist/utils/class-name.d.ts +96 -16
- package/dist/utils/class-name.js +69 -13
- package/package.json +21 -11
- package/dist/components/tabs/item.d.ts +0 -4
- package/dist/components/tabs/item.js +0 -22
- package/dist/hooks/use-expand-effect.d.ts +0 -12
- package/dist/hooks/use-expand-effect.js +0 -34
- /package/dist/node_modules/.pnpm/{@aiszlab_relax@1.2.55_react-dom@18.3.1_react@18.3.1 → @aiszlab_relax@1.2.59_react-dom@18.3.1_react@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.5}/node_modules/@stylexjs/stylex/lib/es/stylex.js +0 -0
|
@@ -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.5/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.5/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.5/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;
|
|
@@ -1,6 +1,7 @@
|
|
|
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.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
3
|
import { Context } from './context.js';
|
|
4
|
+
import { sizes } from '../theme/tokens.stylex.js';
|
|
4
5
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
5
6
|
import { ComponentToken, TimelineClassToken } from '../../utils/class-name.js';
|
|
6
7
|
import clsx from 'clsx';
|
|
@@ -9,10 +10,9 @@ import { ColorToken } from '../../utils/colors.js';
|
|
|
9
10
|
|
|
10
11
|
const styles = {
|
|
11
12
|
item: {
|
|
12
|
-
default:
|
|
13
|
+
default: {
|
|
13
14
|
display: "musae-rvj5dj",
|
|
14
15
|
justifyContent: "musae-1nhvcw1",
|
|
15
|
-
alignItems: "musae-6s0dn4",
|
|
16
16
|
gap: "musae-ik99ff",
|
|
17
17
|
rowGap: null,
|
|
18
18
|
columnGap: null,
|
|
@@ -20,117 +20,76 @@ const styles = {
|
|
|
20
20
|
overflowX: null,
|
|
21
21
|
overflowY: null,
|
|
22
22
|
paddingBottom: "musae-1244622",
|
|
23
|
-
backgroundColor: "musae-q1mx2j",
|
|
24
23
|
$$css: true
|
|
25
|
-
},
|
|
26
|
-
"--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial"
|
|
27
|
-
}],
|
|
24
|
+
},
|
|
28
25
|
right: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
gridTemplateAreas: null,
|
|
32
|
-
gridTemplateColumns: null,
|
|
33
|
-
gridTemplateRows: null,
|
|
34
|
-
gridAutoRows: null,
|
|
35
|
-
gridAutoColumns: null,
|
|
36
|
-
gridAutoFlow: null,
|
|
26
|
+
gridTemplateColumns: "musae-1pmbctz",
|
|
27
|
+
gridTemplateAreas: "musae-znaemz",
|
|
37
28
|
$$css: true
|
|
38
29
|
},
|
|
39
30
|
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,
|
|
31
|
+
gridTemplateColumns: "musae-52fmzj",
|
|
32
|
+
gridTemplateAreas: "musae-196jfb2",
|
|
67
33
|
$$css: true
|
|
68
34
|
}
|
|
69
35
|
},
|
|
70
36
|
labeled: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
gridTemplate: null,
|
|
74
|
-
gridTemplateAreas: null,
|
|
75
|
-
gridTemplateColumns: null,
|
|
76
|
-
gridTemplateRows: null,
|
|
77
|
-
gridAutoRows: null,
|
|
78
|
-
gridAutoColumns: null,
|
|
79
|
-
gridAutoFlow: null,
|
|
37
|
+
default: {
|
|
38
|
+
gridTemplateColumns: "musae-134kloy",
|
|
80
39
|
$$css: true
|
|
81
40
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
gridTemplate: null,
|
|
85
|
-
gridTemplateAreas: null,
|
|
86
|
-
gridTemplateColumns: null,
|
|
87
|
-
gridTemplateRows: null,
|
|
88
|
-
gridAutoRows: null,
|
|
89
|
-
gridAutoColumns: null,
|
|
90
|
-
gridAutoFlow: null,
|
|
41
|
+
right: {
|
|
42
|
+
gridTemplateAreas: "musae-1y7mvjm",
|
|
91
43
|
$$css: true
|
|
92
44
|
},
|
|
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,
|
|
45
|
+
left: {
|
|
46
|
+
gridTemplateAreas: "musae-hurxv4",
|
|
110
47
|
$$css: true
|
|
111
48
|
}
|
|
112
49
|
},
|
|
113
|
-
|
|
50
|
+
leading: {
|
|
114
51
|
default: {
|
|
115
|
-
gridArea: "musae-
|
|
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
|
+
alignSelf: "musae-qcrz7y",
|
|
122
60
|
$$css: true
|
|
123
|
-
}
|
|
61
|
+
},
|
|
62
|
+
tail: props => [{
|
|
63
|
+
position: "musae-1n2onr6",
|
|
64
|
+
"::after_content": "musae-1s928wv",
|
|
65
|
+
"::after_position": "musae-1j6awrg",
|
|
66
|
+
"::after_height": "musae-p59mhh",
|
|
67
|
+
"::after_width": "musae-etvar1",
|
|
68
|
+
"::after_backgroundColor": "musae-27d4w3",
|
|
69
|
+
"::after_top": "musae-1srwf7z",
|
|
70
|
+
"::after_insetInlineStart": "musae-xsadbs",
|
|
71
|
+
"::after_left": null,
|
|
72
|
+
"::after_right": null,
|
|
73
|
+
$$css: true
|
|
74
|
+
}, {
|
|
75
|
+
"--15iyedw": props.color != null ? props.color : "initial"
|
|
76
|
+
}]
|
|
124
77
|
},
|
|
125
|
-
|
|
78
|
+
sign: {
|
|
79
|
+
default: props => [{
|
|
80
|
+
display: "musae-78zum5",
|
|
81
|
+
justifyContent: "musae-l56j7k",
|
|
82
|
+
alignItems: "musae-6s0dn4",
|
|
83
|
+
width: "musae-17fnjtu",
|
|
84
|
+
height: "musae-1jwls1v",
|
|
85
|
+
$$css: true
|
|
86
|
+
}, {
|
|
87
|
+
"--width": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.size ?? sizes.xsmall),
|
|
88
|
+
"--height": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.size ?? sizes.xsmall)
|
|
89
|
+
}]
|
|
90
|
+
},
|
|
91
|
+
dot: {
|
|
126
92
|
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
93
|
width: "musae-jz7u3w",
|
|
135
94
|
height: "musae-1k820er",
|
|
136
95
|
borderRadius: "musae-iipnba",
|
|
@@ -146,24 +105,28 @@ const styles = {
|
|
|
146
105
|
$$css: true
|
|
147
106
|
}, {
|
|
148
107
|
"--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
108
|
}]
|
|
166
109
|
},
|
|
110
|
+
label: {
|
|
111
|
+
default: {
|
|
112
|
+
gridArea: "musae-xwd7sb",
|
|
113
|
+
gridRow: null,
|
|
114
|
+
gridRowStart: null,
|
|
115
|
+
gridRowEnd: null,
|
|
116
|
+
gridColumn: null,
|
|
117
|
+
gridColumnStart: null,
|
|
118
|
+
gridColumnEnd: null,
|
|
119
|
+
$$css: true
|
|
120
|
+
},
|
|
121
|
+
right: {
|
|
122
|
+
justifySelf: "musae-15bdqvn",
|
|
123
|
+
$$css: true
|
|
124
|
+
},
|
|
125
|
+
left: {
|
|
126
|
+
justifySelf: "musae-wldb3t",
|
|
127
|
+
$$css: true
|
|
128
|
+
}
|
|
129
|
+
},
|
|
167
130
|
description: {
|
|
168
131
|
default: {
|
|
169
132
|
gridArea: "musae-19tbii3",
|
|
@@ -174,45 +137,70 @@ const styles = {
|
|
|
174
137
|
gridColumnStart: null,
|
|
175
138
|
gridColumnEnd: null,
|
|
176
139
|
$$css: true
|
|
140
|
+
},
|
|
141
|
+
right: {
|
|
142
|
+
justifySelf: "musae-wldb3t",
|
|
143
|
+
$$css: true
|
|
144
|
+
},
|
|
145
|
+
left: {
|
|
146
|
+
justifySelf: "musae-15bdqvn",
|
|
147
|
+
$$css: true
|
|
177
148
|
}
|
|
178
149
|
}
|
|
179
150
|
};
|
|
180
151
|
const Item = ({
|
|
181
152
|
description,
|
|
182
153
|
label,
|
|
183
|
-
value
|
|
154
|
+
value,
|
|
155
|
+
dot
|
|
184
156
|
}) => {
|
|
185
157
|
const classNames = useClassNames(ComponentToken.Timeline);
|
|
186
158
|
const {
|
|
187
|
-
mode,
|
|
188
|
-
max
|
|
159
|
+
mode: _mode,
|
|
160
|
+
max,
|
|
161
|
+
size
|
|
189
162
|
} = useContext(Context);
|
|
190
163
|
const theme = useTheme();
|
|
191
164
|
const isLabeled = !!label;
|
|
192
165
|
const isMax = max === value;
|
|
166
|
+
// convert alternate mode to normal mode
|
|
167
|
+
const mode = useMemo(() => {
|
|
168
|
+
if (_mode === "alternate") {
|
|
169
|
+
return value % 2 === 1 ? "right" : "left";
|
|
170
|
+
}
|
|
171
|
+
return _mode;
|
|
172
|
+
}, [_mode, value]);
|
|
193
173
|
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({
|
|
174
|
+
item: _stylex.props(styles.item.default, styles.item[mode], isLabeled && styles.labeled.default, isLabeled && styles.labeled[mode]),
|
|
175
|
+
label: _stylex.props(styles.label.default, styles.label[mode]),
|
|
176
|
+
leading: _stylex.props(styles.leading.default, !isMax && styles.leading.tail({
|
|
199
177
|
color: theme.colors[ColorToken.Primary]
|
|
200
|
-
}),
|
|
178
|
+
})),
|
|
179
|
+
sign: _stylex.props(styles.sign.default({
|
|
180
|
+
size
|
|
181
|
+
})),
|
|
182
|
+
dot: _stylex.props(styles.dot.default({
|
|
201
183
|
color: theme.colors[ColorToken.Primary]
|
|
202
184
|
})),
|
|
203
|
-
description: _stylex.props(styles.description.default)
|
|
185
|
+
description: _stylex.props(styles.description.default, styles.description[mode])
|
|
204
186
|
};
|
|
205
187
|
return React.createElement("li", {
|
|
206
188
|
className: clsx(classNames[TimelineClassToken.Item], styled.item.className),
|
|
207
189
|
style: styled.item.style
|
|
208
190
|
}, isLabeled && React.createElement("div", {
|
|
209
|
-
className: styled.label.className,
|
|
191
|
+
className: clsx(classNames[TimelineClassToken.Label], styled.label.className),
|
|
210
192
|
style: styled.label.style
|
|
211
193
|
}, label), React.createElement("div", {
|
|
212
|
-
className: styled.leading.className,
|
|
194
|
+
className: clsx(classNames[TimelineClassToken.Leading], styled.leading.className),
|
|
213
195
|
style: styled.leading.style
|
|
214
|
-
}
|
|
215
|
-
className: styled.
|
|
196
|
+
}, React.createElement("div", {
|
|
197
|
+
className: clsx(classNames[TimelineClassToken.Sign], styled.sign.className),
|
|
198
|
+
style: styled.sign.style
|
|
199
|
+
}, dot ?? React.createElement("span", {
|
|
200
|
+
className: clsx(classNames[TimelineClassToken.Dot], styled.dot.className),
|
|
201
|
+
style: styled.dot.style
|
|
202
|
+
}))), React.createElement("div", {
|
|
203
|
+
className: clsx(classNames[TimelineClassToken.Description], styled.description.className),
|
|
216
204
|
style: styled.description.style
|
|
217
205
|
}, description));
|
|
218
206
|
};
|
|
@@ -7,16 +7,19 @@ import clsx from 'clsx';
|
|
|
7
7
|
|
|
8
8
|
const Timeline = ({
|
|
9
9
|
items,
|
|
10
|
-
mode = "right"
|
|
10
|
+
mode = "right",
|
|
11
|
+
size
|
|
11
12
|
}) => {
|
|
12
13
|
const styled = {
|
|
13
14
|
className: "musae-78zum5 musae-dt5ytf"
|
|
14
15
|
};
|
|
15
16
|
const classNames = useClassNames(ComponentToken.Timeline);
|
|
17
|
+
const total = items.length;
|
|
16
18
|
const contextValue = useMemo(() => ({
|
|
17
19
|
mode,
|
|
18
|
-
max:
|
|
19
|
-
|
|
20
|
+
max: total - 1,
|
|
21
|
+
size
|
|
22
|
+
}), [mode, total, size]);
|
|
20
23
|
return React.createElement(Context.Provider, {
|
|
21
24
|
value: contextValue
|
|
22
25
|
}, React.createElement("ol", {
|
|
@@ -27,7 +30,8 @@ const Timeline = ({
|
|
|
27
30
|
key: index,
|
|
28
31
|
value: index,
|
|
29
32
|
label: item.label,
|
|
30
|
-
description: item.description
|
|
33
|
+
description: item.description,
|
|
34
|
+
dot: item.dot
|
|
31
35
|
});
|
|
32
36
|
})));
|
|
33
37
|
};
|
|
@@ -17,6 +17,12 @@ export type TimelineItem = {
|
|
|
17
17
|
* @requires
|
|
18
18
|
*/
|
|
19
19
|
description: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* @description
|
|
22
|
+
* dot render slot
|
|
23
|
+
* @default void 0
|
|
24
|
+
*/
|
|
25
|
+
dot?: ReactNode;
|
|
20
26
|
};
|
|
21
27
|
/**
|
|
22
28
|
* @description
|
|
@@ -35,6 +41,11 @@ export type TimelineProps = {
|
|
|
35
41
|
* @default "right"
|
|
36
42
|
*/
|
|
37
43
|
mode?: Mode;
|
|
44
|
+
/**
|
|
45
|
+
* @description
|
|
46
|
+
* size
|
|
47
|
+
*/
|
|
48
|
+
size?: number;
|
|
38
49
|
};
|
|
39
50
|
/**
|
|
40
51
|
* @description
|
|
@@ -62,5 +73,10 @@ export type ContextValue = {
|
|
|
62
73
|
* max
|
|
63
74
|
*/
|
|
64
75
|
max: number;
|
|
76
|
+
/**
|
|
77
|
+
* @description
|
|
78
|
+
* size
|
|
79
|
+
*/
|
|
80
|
+
size?: number;
|
|
65
81
|
};
|
|
66
82
|
export {};
|