musae 0.2.1 → 0.2.3
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/components/avatar/avatar.d.ts +0 -2
- package/dist/components/avatar/avatar.js +6 -5
- package/dist/components/avatar/group.js +1 -1
- package/dist/components/avatar/types.d.ts +3 -9
- package/dist/components/calendar/hooks.js +4 -4
- package/dist/components/checkbox/checkbox.js +3 -2
- package/dist/components/collapse/collapse.d.ts +4 -0
- package/dist/components/collapse/collapse.js +97 -0
- package/dist/components/collapse/context.d.ts +7 -0
- package/dist/components/collapse/context.js +12 -0
- package/dist/components/collapse/hooks.d.ts +12 -0
- package/dist/components/collapse/hooks.js +43 -0
- package/dist/components/collapse/index.d.ts +2 -0
- package/dist/components/collapse/item.d.ts +4 -0
- package/dist/components/collapse/item.js +144 -0
- package/dist/components/collapse/types.d.ts +87 -0
- package/dist/components/dialog/popup.js +3 -3
- package/dist/components/drawer/popup.js +15 -15
- package/dist/components/icon/icon.js +1 -1
- package/dist/components/icon/icons/index.js +1 -0
- package/dist/components/icon/icons/navigation/index.d.ts +2 -1
- package/dist/components/icon/icons/navigation/index.js +1 -0
- package/dist/components/icon/icons/navigation/unfold-more.d.ts +3 -0
- package/dist/components/icon/icons/navigation/unfold-more.js +10 -0
- package/dist/components/image/preview/operations.js +3 -3
- package/dist/components/layout/header.js +1 -1
- package/dist/components/loading/loading.d.ts +1 -1
- package/dist/components/loading/loading.js +69 -4
- package/dist/components/loading/types.d.ts +13 -0
- package/dist/components/notification/holder.js +12 -12
- package/dist/components/notification/notification.js +1 -1
- package/dist/components/popper/dropdown.js +2 -2
- package/dist/components/rate/star.js +13 -15
- package/dist/components/ripple/hooks.js +4 -1
- package/dist/components/switch/switch.js +4 -4
- package/dist/components/table/body.js +35 -3
- package/dist/components/table/context.d.ts +6 -0
- package/dist/components/table/context.js +10 -2
- package/dist/components/table/header/cell.d.ts +3 -0
- package/dist/components/table/header/cell.js +129 -0
- package/dist/components/table/{header.d.ts → header/header.d.ts} +1 -1
- package/dist/components/table/{header.js → header/header.js} +38 -11
- package/dist/components/table/hooks.d.ts +8 -21
- package/dist/components/table/hooks.js +36 -58
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.js +12 -6
- package/dist/components/table/types.d.ts +72 -4
- package/dist/components/tour/tour.js +1 -1
- package/dist/components/waterfall/hooks.d.ts +1 -2
- package/dist/components/waterfall/hooks.js +2 -8
- package/dist/components/waterfall/waterfall.js +9 -5
- package/dist/components/watermark/types.d.ts +1 -1
- package/dist/components/watermark/watermark.js +1 -1
- package/dist/hooks/use-class-names.d.ts +15 -0
- package/dist/hooks/use-expand-effect.d.ts +1 -1
- package/dist/hooks/use-expand-effect.js +12 -8
- package/dist/hooks/use-image.d.ts +11 -0
- package/dist/hooks/use-image.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/stylex.css +31 -17
- package/dist/utils/class-name.d.ts +65 -3
- package/dist/utils/class-name.js +39 -5
- package/dist/utils/styles.d.ts +1 -1
- package/package.json +6 -6
|
@@ -7,6 +7,7 @@ import { useClassNames } from '../../hooks/use-class-names.js';
|
|
|
7
7
|
import { ComponentToken, AvatarClassToken } from '../../utils/class-name.js';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import { typography } from '../theme/theme.js';
|
|
10
|
+
import { useImage } from '../../hooks/use-image.js';
|
|
10
11
|
|
|
11
12
|
const styles = {
|
|
12
13
|
avatar: props => [{
|
|
@@ -124,15 +125,12 @@ const styles = {
|
|
|
124
125
|
/**
|
|
125
126
|
* @description
|
|
126
127
|
* `Avatar`
|
|
127
|
-
*
|
|
128
|
-
* component
|
|
129
128
|
*/
|
|
130
129
|
const Avatar = forwardRef(({
|
|
131
130
|
src,
|
|
132
131
|
alt,
|
|
133
132
|
shape: _shape = "circular",
|
|
134
133
|
size: _size = "medium",
|
|
135
|
-
fallback,
|
|
136
134
|
...props$1
|
|
137
135
|
}, ref) => {
|
|
138
136
|
const theme = useTheme();
|
|
@@ -141,6 +139,9 @@ const Avatar = forwardRef(({
|
|
|
141
139
|
const size = group?.size ?? _size;
|
|
142
140
|
const shape = group?.shape ?? _shape;
|
|
143
141
|
const classNames = useClassNames(ComponentToken.Avatar);
|
|
142
|
+
const isLoaded = useImage({
|
|
143
|
+
src
|
|
144
|
+
});
|
|
144
145
|
const styled = {
|
|
145
146
|
avatar: props(typography.label[size], styles.avatar({
|
|
146
147
|
backgroundColor: theme.colors[ColorToken.PrimaryContainer],
|
|
@@ -157,13 +158,13 @@ const Avatar = forwardRef(({
|
|
|
157
158
|
className: clsx(classNames[AvatarClassToken.Avatar], styled.avatar.className),
|
|
158
159
|
style: styled.avatar.style,
|
|
159
160
|
ref: ref
|
|
160
|
-
},
|
|
161
|
+
}, isLoaded === "loaded" ? React.createElement("img", {
|
|
161
162
|
draggable: false,
|
|
162
163
|
src: src,
|
|
163
164
|
alt: alt,
|
|
164
165
|
className: styled.image.className,
|
|
165
166
|
style: styled.image.style
|
|
166
|
-
}) :
|
|
167
|
+
}) : alt?.slice(0, 2).toUpperCase());
|
|
167
168
|
});
|
|
168
169
|
|
|
169
170
|
export { Avatar as default };
|
|
@@ -14,7 +14,9 @@ export type AvatarProps = {
|
|
|
14
14
|
src?: string;
|
|
15
15
|
/**
|
|
16
16
|
* @description
|
|
17
|
-
* alt
|
|
17
|
+
* alt, (fallback usage)
|
|
18
|
+
* if user do not provide `src`, or `src` is invalid
|
|
19
|
+
* show `alt`
|
|
18
20
|
* @default void 0
|
|
19
21
|
*/
|
|
20
22
|
alt?: string;
|
|
@@ -30,14 +32,6 @@ export type AvatarProps = {
|
|
|
30
32
|
* @default "circular"
|
|
31
33
|
*/
|
|
32
34
|
shape?: Shape;
|
|
33
|
-
/**
|
|
34
|
-
* @description
|
|
35
|
-
* fallback node
|
|
36
|
-
* if user do not provide `src`, or `src` is invalid
|
|
37
|
-
* show `fallback`
|
|
38
|
-
* @default void 0
|
|
39
|
-
*/
|
|
40
|
-
fallback?: ReactNode;
|
|
41
35
|
};
|
|
42
36
|
/**
|
|
43
37
|
* @description
|
|
@@ -41,21 +41,21 @@ const styles = {
|
|
|
41
41
|
$$css: true
|
|
42
42
|
},
|
|
43
43
|
range: {
|
|
44
|
-
"::before_insetInlineStart": "musae-
|
|
44
|
+
"::before_insetInlineStart": "musae-1kfboi8",
|
|
45
45
|
"::before_left": null,
|
|
46
46
|
"::before_right": null,
|
|
47
|
-
"::before_insetInlineEnd": "musae-
|
|
47
|
+
"::before_insetInlineEnd": "musae-1x8jx26",
|
|
48
48
|
$$css: true
|
|
49
49
|
},
|
|
50
50
|
from: {
|
|
51
51
|
"::before_insetInlineStart": "musae-fbisj7",
|
|
52
52
|
"::before_left": null,
|
|
53
53
|
"::before_right": null,
|
|
54
|
-
"::before_insetInlineEnd": "musae-
|
|
54
|
+
"::before_insetInlineEnd": "musae-1x8jx26",
|
|
55
55
|
$$css: true
|
|
56
56
|
},
|
|
57
57
|
to: {
|
|
58
|
-
"::before_insetInlineStart": "musae-
|
|
58
|
+
"::before_insetInlineStart": "musae-1kfboi8",
|
|
59
59
|
"::before_left": null,
|
|
60
60
|
"::before_right": null,
|
|
61
61
|
"::before_insetInlineEnd": "musae-1gkks1t",
|
|
@@ -24,6 +24,7 @@ const styles = {
|
|
|
24
24
|
cursor: "musae-mper1u",
|
|
25
25
|
width: "musae-r8isjd",
|
|
26
26
|
height: "musae-1gfonl1",
|
|
27
|
+
position: "musae-1n2onr6",
|
|
27
28
|
"::before_content": "musae-1cpjm7i",
|
|
28
29
|
"::before_visibility": "musae-11srvyv",
|
|
29
30
|
"::before_display": "musae-1fgarty",
|
|
@@ -94,7 +95,7 @@ const styles = {
|
|
|
94
95
|
"::after_display": "musae-hkezso",
|
|
95
96
|
"::after_width": "musae-11yodxc",
|
|
96
97
|
"::after_height": "musae-ec44on",
|
|
97
|
-
"::after_transform": "musae-
|
|
98
|
+
"::after_transform": "musae-q1m6zb",
|
|
98
99
|
"::after_borderWidth": "musae-15z8w9c",
|
|
99
100
|
"::after_borderInlineWidth": null,
|
|
100
101
|
"::after_borderInlineStartWidth": null,
|
|
@@ -163,7 +164,7 @@ const Checkbox = ({
|
|
|
163
164
|
}, [_setIsChecked, contextValue, value]);
|
|
164
165
|
const styled = {
|
|
165
166
|
checkbox: {
|
|
166
|
-
className: "musae-
|
|
167
|
+
className: "musae-3nfvp2 musae-6s0dn4 musae-1ypdohk"
|
|
167
168
|
},
|
|
168
169
|
trigger: props(styles.trigger({
|
|
169
170
|
borderColor: theme.colors[ColorToken.Outline]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
3
|
+
import { ComponentToken, CollapseClassToken } from '../../utils/class-name.js';
|
|
4
|
+
import CollapseItem from './item.js';
|
|
5
|
+
import _stylex from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { useActiveKeys } from './hooks.js';
|
|
8
|
+
import { Context } from './context.js';
|
|
9
|
+
import { useTheme } from '../theme/hooks.js';
|
|
10
|
+
import { ColorToken } from '../../utils/colors.js';
|
|
11
|
+
|
|
12
|
+
const styles = {
|
|
13
|
+
collapse: props => [{
|
|
14
|
+
borderWidth: "musae-1i8jmgv",
|
|
15
|
+
borderInlineWidth: null,
|
|
16
|
+
borderInlineStartWidth: null,
|
|
17
|
+
borderLeftWidth: null,
|
|
18
|
+
borderInlineEndWidth: null,
|
|
19
|
+
borderRightWidth: null,
|
|
20
|
+
borderBlockWidth: null,
|
|
21
|
+
borderTopWidth: null,
|
|
22
|
+
borderBottomWidth: null,
|
|
23
|
+
borderStyle: "musae-1y0btm7",
|
|
24
|
+
borderInlineStyle: null,
|
|
25
|
+
borderInlineStartStyle: null,
|
|
26
|
+
borderLeftStyle: null,
|
|
27
|
+
borderInlineEndStyle: null,
|
|
28
|
+
borderRightStyle: null,
|
|
29
|
+
borderBlockStyle: null,
|
|
30
|
+
borderTopStyle: null,
|
|
31
|
+
borderBottomStyle: null,
|
|
32
|
+
borderColor: "musae-eqt46j",
|
|
33
|
+
borderInlineColor: null,
|
|
34
|
+
borderInlineStartColor: null,
|
|
35
|
+
borderLeftColor: null,
|
|
36
|
+
borderInlineEndColor: null,
|
|
37
|
+
borderRightColor: null,
|
|
38
|
+
borderBlockColor: null,
|
|
39
|
+
borderTopColor: null,
|
|
40
|
+
borderBottomColor: null,
|
|
41
|
+
borderRadius: "musae-1h268bu",
|
|
42
|
+
borderStartStartRadius: null,
|
|
43
|
+
borderStartEndRadius: null,
|
|
44
|
+
borderEndStartRadius: null,
|
|
45
|
+
borderEndEndRadius: null,
|
|
46
|
+
borderTopLeftRadius: null,
|
|
47
|
+
borderTopRightRadius: null,
|
|
48
|
+
borderBottomLeftRadius: null,
|
|
49
|
+
borderBottomRightRadius: null,
|
|
50
|
+
$$css: true
|
|
51
|
+
}, {
|
|
52
|
+
"--borderColor": props.outlineColor != null ? props.outlineColor : "initial"
|
|
53
|
+
}]
|
|
54
|
+
};
|
|
55
|
+
const Collapse = ({
|
|
56
|
+
items,
|
|
57
|
+
className,
|
|
58
|
+
defaultActiveKey,
|
|
59
|
+
activeKey,
|
|
60
|
+
onChange,
|
|
61
|
+
style,
|
|
62
|
+
accordion = false
|
|
63
|
+
}) => {
|
|
64
|
+
const classNames = useClassNames(ComponentToken.Collapse);
|
|
65
|
+
const [activeKeys, toggle] = useActiveKeys({
|
|
66
|
+
defaultActiveKey,
|
|
67
|
+
activeKey,
|
|
68
|
+
onChange,
|
|
69
|
+
accordion
|
|
70
|
+
});
|
|
71
|
+
const theme = useTheme();
|
|
72
|
+
// no need to render when items is empty
|
|
73
|
+
if (items.length === 0) return null;
|
|
74
|
+
const styled = _stylex.props(styles.collapse({
|
|
75
|
+
outlineColor: theme.colors[ColorToken.OutlineVariant]
|
|
76
|
+
}));
|
|
77
|
+
return React.createElement(Context.Provider, {
|
|
78
|
+
value: {
|
|
79
|
+
activeKeys,
|
|
80
|
+
toggle
|
|
81
|
+
}
|
|
82
|
+
}, React.createElement("div", {
|
|
83
|
+
className: clsx(classNames[CollapseClassToken.Collapse], className, styled.className),
|
|
84
|
+
style: {
|
|
85
|
+
...styled.style,
|
|
86
|
+
...style
|
|
87
|
+
}
|
|
88
|
+
}, items.map(item => {
|
|
89
|
+
return React.createElement(CollapseItem, {
|
|
90
|
+
...item,
|
|
91
|
+
value: item.key
|
|
92
|
+
});
|
|
93
|
+
})));
|
|
94
|
+
};
|
|
95
|
+
var Collapse$1 = Collapse;
|
|
96
|
+
|
|
97
|
+
export { Collapse$1 as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Key } from "react";
|
|
2
|
+
import type { Value } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* `Collapse` active key hook
|
|
6
|
+
*/
|
|
7
|
+
export declare const useActiveKeys: ({ defaultActiveKey, activeKey: _activeKey, onChange: _onChange, accordion, }: {
|
|
8
|
+
defaultActiveKey?: Value;
|
|
9
|
+
activeKey?: Value;
|
|
10
|
+
onChange?: (value: Key[]) => void;
|
|
11
|
+
accordion: boolean;
|
|
12
|
+
}) => [Set<Key>, (key: Key) => void];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useControlledState, exclude, toArray, useEvent } from '@aiszlab/relax';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* `Collapse` active key hook
|
|
7
|
+
*/
|
|
8
|
+
const useActiveKeys = ({ defaultActiveKey, activeKey: _activeKey, onChange: _onChange, accordion, }) => {
|
|
9
|
+
const [_activeKeys, _setActiveKeys] = useControlledState(_activeKey, { defaultState: defaultActiveKey });
|
|
10
|
+
const activeKeys = useMemo(() => {
|
|
11
|
+
const keys = exclude(toArray(_activeKeys), [void 0]);
|
|
12
|
+
if (accordion) {
|
|
13
|
+
return new Set(keys.slice(0, 1));
|
|
14
|
+
}
|
|
15
|
+
return new Set(keys);
|
|
16
|
+
}, [_activeKeys, accordion]);
|
|
17
|
+
const toggle = useEvent((key) => {
|
|
18
|
+
const expandedKeys = new Set(activeKeys);
|
|
19
|
+
const isExpanded = expandedKeys.has(key);
|
|
20
|
+
// `accordion` mode, just toggle `key`
|
|
21
|
+
// otherwise, normally toggle `key`
|
|
22
|
+
if (accordion) {
|
|
23
|
+
expandedKeys.clear();
|
|
24
|
+
if (!isExpanded) {
|
|
25
|
+
expandedKeys.add(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (isExpanded) {
|
|
30
|
+
expandedKeys.delete(key);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
expandedKeys.add(key);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const _expandedKeys = Array.from(expandedKeys);
|
|
37
|
+
_setActiveKeys(_expandedKeys);
|
|
38
|
+
_onChange?.(_expandedKeys);
|
|
39
|
+
});
|
|
40
|
+
return [activeKeys, toggle];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { useActiveKeys };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
3
|
+
import { ComponentToken, CollapseClassToken } from '../../utils/class-name.js';
|
|
4
|
+
import _stylex from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
5
|
+
import { useEvent } from '@aiszlab/relax';
|
|
6
|
+
import { useAnimate } from 'framer-motion';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import { Context } from './context.js';
|
|
9
|
+
import { useExpandEffect } from '../../hooks/use-expand-effect.js';
|
|
10
|
+
import { useTheme } from '../theme/hooks.js';
|
|
11
|
+
import { ColorToken } from '../../utils/colors.js';
|
|
12
|
+
import KeyboardArrowRight from '../icon/icons/hardware/keyboard-arrow-right.js';
|
|
13
|
+
|
|
14
|
+
const styles = {
|
|
15
|
+
item: {
|
|
16
|
+
default: props => [{
|
|
17
|
+
borderBottomWidth: "musae-lntmim",
|
|
18
|
+
borderBottomStyle: "musae-1q0q8m5",
|
|
19
|
+
borderBottomColor: "musae-43481e",
|
|
20
|
+
":last-of-type_borderBottomWidth": "musae-zm6erk",
|
|
21
|
+
$$css: true
|
|
22
|
+
}, {
|
|
23
|
+
"--borderBottomColor": props.outlineColor != null ? props.outlineColor : "initial"
|
|
24
|
+
}]
|
|
25
|
+
},
|
|
26
|
+
header: {
|
|
27
|
+
default: {
|
|
28
|
+
paddingInline: "musae-1xkwav8",
|
|
29
|
+
paddingStart: null,
|
|
30
|
+
paddingLeft: null,
|
|
31
|
+
paddingEnd: null,
|
|
32
|
+
paddingRight: null,
|
|
33
|
+
paddingBlock: "musae-avjae4",
|
|
34
|
+
paddingTop: null,
|
|
35
|
+
paddingBottom: null,
|
|
36
|
+
display: "musae-78zum5",
|
|
37
|
+
flexDirection: "musae-1q0g3np",
|
|
38
|
+
alignItems: "musae-6s0dn4",
|
|
39
|
+
gap: "musae-vbka3v",
|
|
40
|
+
rowGap: null,
|
|
41
|
+
columnGap: null,
|
|
42
|
+
cursor: "musae-1ypdohk",
|
|
43
|
+
$$css: true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
panel: {
|
|
47
|
+
default: {
|
|
48
|
+
height: "musae-t7dq6l",
|
|
49
|
+
$$css: true
|
|
50
|
+
},
|
|
51
|
+
hidden: {
|
|
52
|
+
display: "musae-1s85apg",
|
|
53
|
+
$$css: true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
content: {
|
|
57
|
+
default: props => [{
|
|
58
|
+
borderTopWidth: "musae-1yeim8r",
|
|
59
|
+
borderTopStyle: "musae-13fuv20",
|
|
60
|
+
borderTopColor: "musae-is9nib",
|
|
61
|
+
padding: "musae-12ldsqu",
|
|
62
|
+
paddingInline: null,
|
|
63
|
+
paddingStart: null,
|
|
64
|
+
paddingLeft: null,
|
|
65
|
+
paddingEnd: null,
|
|
66
|
+
paddingRight: null,
|
|
67
|
+
paddingBlock: null,
|
|
68
|
+
paddingTop: null,
|
|
69
|
+
paddingBottom: null,
|
|
70
|
+
$$css: true
|
|
71
|
+
}, {
|
|
72
|
+
"--borderTopColor": props.outlineColor != null ? props.outlineColor : "initial"
|
|
73
|
+
}]
|
|
74
|
+
},
|
|
75
|
+
collapser: {
|
|
76
|
+
default: {
|
|
77
|
+
willChange: "musae-1so62im",
|
|
78
|
+
transitionProperty: "musae-11xpdln",
|
|
79
|
+
transitionDuration: "musae-13dflua",
|
|
80
|
+
$$css: true
|
|
81
|
+
},
|
|
82
|
+
expanded: {
|
|
83
|
+
transform: "musae-1iffjtl",
|
|
84
|
+
$$css: true
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const CollapseItem = ({
|
|
89
|
+
children,
|
|
90
|
+
label,
|
|
91
|
+
value
|
|
92
|
+
}) => {
|
|
93
|
+
const classNames = useClassNames(ComponentToken.Collapse);
|
|
94
|
+
const {
|
|
95
|
+
activeKeys,
|
|
96
|
+
toggle
|
|
97
|
+
} = useContext(Context);
|
|
98
|
+
const isExpanded = activeKeys.has(value);
|
|
99
|
+
const [collapser, animate] = useAnimate();
|
|
100
|
+
const theme = useTheme();
|
|
101
|
+
useExpandEffect({
|
|
102
|
+
animate,
|
|
103
|
+
expanded: isExpanded,
|
|
104
|
+
target: collapser
|
|
105
|
+
});
|
|
106
|
+
const styled = {
|
|
107
|
+
item: _stylex.props(styles.item.default({
|
|
108
|
+
outlineColor: theme.colors[ColorToken.OutlineVariant]
|
|
109
|
+
})),
|
|
110
|
+
header: _stylex.props(styles.header.default),
|
|
111
|
+
panel: _stylex.props(styles.panel.default, !isExpanded && styles.panel.hidden),
|
|
112
|
+
content: _stylex.props(styles.content.default({
|
|
113
|
+
outlineColor: theme.colors[ColorToken.OutlineVariant]
|
|
114
|
+
})),
|
|
115
|
+
collapser: _stylex.props(styles.collapser.default, isExpanded && styles.collapser.expanded)
|
|
116
|
+
};
|
|
117
|
+
const onClick = useEvent(() => {
|
|
118
|
+
toggle(value);
|
|
119
|
+
});
|
|
120
|
+
return React.createElement("div", {
|
|
121
|
+
className: clsx(classNames[CollapseClassToken.Item], {
|
|
122
|
+
[classNames[CollapseClassToken.ItemActive]]: isExpanded
|
|
123
|
+
}, styled.item.className),
|
|
124
|
+
style: styled.item.style
|
|
125
|
+
}, React.createElement("div", {
|
|
126
|
+
className: clsx(classNames[CollapseClassToken.Header], styled.header.className),
|
|
127
|
+
style: styled.header.style,
|
|
128
|
+
onClick: onClick
|
|
129
|
+
}, React.createElement(KeyboardArrowRight, {
|
|
130
|
+
className: clsx(classNames[CollapseClassToken.Collapser], styled.collapser.className),
|
|
131
|
+
style: styled.collapser.style
|
|
132
|
+
}), label), React.createElement("div", {
|
|
133
|
+
ref: collapser,
|
|
134
|
+
className: clsx(classNames[CollapseClassToken.Panel], {
|
|
135
|
+
[classNames[CollapseClassToken.PanelActive]]: isExpanded
|
|
136
|
+
}, styled.panel.className),
|
|
137
|
+
style: styled.panel.style
|
|
138
|
+
}, React.createElement("div", {
|
|
139
|
+
className: clsx(classNames[CollapseClassToken.Content], styled.content.className),
|
|
140
|
+
style: styled.content.style
|
|
141
|
+
}, children)));
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export { CollapseItem as default };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Key, ReactNode } from "react";
|
|
2
|
+
import type { ComponentProps } from "../../types/element";
|
|
3
|
+
export type Value = Key | Key[];
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* `Collapse` item
|
|
7
|
+
*/
|
|
8
|
+
interface CollapseItem {
|
|
9
|
+
/**
|
|
10
|
+
* @description
|
|
11
|
+
* key
|
|
12
|
+
*/
|
|
13
|
+
key: Key;
|
|
14
|
+
/**
|
|
15
|
+
* @description
|
|
16
|
+
* label
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
/**
|
|
20
|
+
* @description
|
|
21
|
+
* children
|
|
22
|
+
*/
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @description
|
|
27
|
+
* `Collapse` props
|
|
28
|
+
*/
|
|
29
|
+
export interface CollapseProps extends ComponentProps {
|
|
30
|
+
/**
|
|
31
|
+
* @description
|
|
32
|
+
* default active key
|
|
33
|
+
* @default void 0
|
|
34
|
+
*/
|
|
35
|
+
defaultActiveKey?: Value;
|
|
36
|
+
/**
|
|
37
|
+
* @description
|
|
38
|
+
* active key
|
|
39
|
+
* @default void 0
|
|
40
|
+
*/
|
|
41
|
+
activeKey?: Value;
|
|
42
|
+
/**
|
|
43
|
+
* @description
|
|
44
|
+
* items
|
|
45
|
+
*/
|
|
46
|
+
items: CollapseItem[];
|
|
47
|
+
/**
|
|
48
|
+
* @description
|
|
49
|
+
* change handler
|
|
50
|
+
* @default void 0
|
|
51
|
+
*/
|
|
52
|
+
onChange?: (value: Key[]) => void;
|
|
53
|
+
/**
|
|
54
|
+
* @description
|
|
55
|
+
* accordion mode
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
accordion?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @description
|
|
62
|
+
* `Collapse` item props
|
|
63
|
+
*/
|
|
64
|
+
export interface CollapseItemProps extends Omit<CollapseItem, "key"> {
|
|
65
|
+
/**
|
|
66
|
+
* @description
|
|
67
|
+
* value
|
|
68
|
+
*/
|
|
69
|
+
value: Key;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @description
|
|
73
|
+
* context value
|
|
74
|
+
*/
|
|
75
|
+
export interface ContextValue {
|
|
76
|
+
/**
|
|
77
|
+
* @description
|
|
78
|
+
* active keys
|
|
79
|
+
*/
|
|
80
|
+
activeKeys: Set<Key>;
|
|
81
|
+
/**
|
|
82
|
+
* @description
|
|
83
|
+
* key toggle
|
|
84
|
+
*/
|
|
85
|
+
toggle: (key: Key) => void;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -19,8 +19,8 @@ const styles = {
|
|
|
19
19
|
},
|
|
20
20
|
overlay: props => [{
|
|
21
21
|
position: "musae-10l6tqk",
|
|
22
|
-
top: "musae-
|
|
23
|
-
left: "musae-
|
|
22
|
+
top: "musae-9oc6z4",
|
|
23
|
+
left: "musae-1tjciyl",
|
|
24
24
|
insetInlineStart: null,
|
|
25
25
|
insetInlineEnd: null,
|
|
26
26
|
width: "musae-n9wirt",
|
|
@@ -137,7 +137,7 @@ const Popup = ({
|
|
|
137
137
|
}, [open]);
|
|
138
138
|
const styled = {
|
|
139
139
|
popup: {
|
|
140
|
-
className: "musae-ixxii4 musae-
|
|
140
|
+
className: "musae-ixxii4 musae-9oc6z4 musae-1tjciyl musae-n9wirt musae-1dr59a3 musae-47corl musae-1tv1kli musae-78zum5 musae-l56j7k musae-6s0dn4"
|
|
141
141
|
},
|
|
142
142
|
overlay: props(styles.overlay({
|
|
143
143
|
backgroundColor: theme.colors[ColorToken.SurfaceDim]
|
|
@@ -14,7 +14,7 @@ import { contains } from '../../node_modules/@aiszlab/relax/dist/dom/contains.js
|
|
|
14
14
|
const styles = {
|
|
15
15
|
popup: {
|
|
16
16
|
position: "musae-ixxii4",
|
|
17
|
-
inset: "musae-
|
|
17
|
+
inset: "musae-ezip7x",
|
|
18
18
|
insetInline: null,
|
|
19
19
|
insetInlineStart: null,
|
|
20
20
|
insetInlineEnd: null,
|
|
@@ -29,7 +29,7 @@ const styles = {
|
|
|
29
29
|
},
|
|
30
30
|
overlay: props => [{
|
|
31
31
|
position: "musae-10l6tqk",
|
|
32
|
-
inset: "musae-
|
|
32
|
+
inset: "musae-ezip7x",
|
|
33
33
|
insetInline: null,
|
|
34
34
|
insetInlineStart: null,
|
|
35
35
|
insetInlineEnd: null,
|
|
@@ -61,44 +61,44 @@ const styles = {
|
|
|
61
61
|
"--transform": props.transform != null ? props.transform : "initial"
|
|
62
62
|
}],
|
|
63
63
|
right: props => [{
|
|
64
|
-
right: "musae-
|
|
64
|
+
right: "musae-15gpytn",
|
|
65
65
|
insetInlineStart: null,
|
|
66
66
|
insetInlineEnd: null,
|
|
67
|
-
top: "musae-
|
|
68
|
-
bottom: "musae-
|
|
67
|
+
top: "musae-9oc6z4",
|
|
68
|
+
bottom: "musae-1sh2tzk",
|
|
69
69
|
width: "musae-17fnjtu",
|
|
70
70
|
$$css: true
|
|
71
71
|
}, {
|
|
72
72
|
"--width": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.size)
|
|
73
73
|
}],
|
|
74
74
|
left: props => [{
|
|
75
|
-
left: "musae-
|
|
75
|
+
left: "musae-1tjciyl",
|
|
76
76
|
insetInlineStart: null,
|
|
77
77
|
insetInlineEnd: null,
|
|
78
|
-
top: "musae-
|
|
79
|
-
bottom: "musae-
|
|
78
|
+
top: "musae-9oc6z4",
|
|
79
|
+
bottom: "musae-1sh2tzk",
|
|
80
80
|
width: "musae-17fnjtu",
|
|
81
81
|
$$css: true
|
|
82
82
|
}, {
|
|
83
83
|
"--width": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.size)
|
|
84
84
|
}],
|
|
85
85
|
bottom: props => [{
|
|
86
|
-
bottom: "musae-
|
|
87
|
-
left: "musae-
|
|
86
|
+
bottom: "musae-1sh2tzk",
|
|
87
|
+
left: "musae-1tjciyl",
|
|
88
88
|
insetInlineStart: null,
|
|
89
89
|
insetInlineEnd: null,
|
|
90
|
-
right: "musae-
|
|
90
|
+
right: "musae-15gpytn",
|
|
91
91
|
height: "musae-1jwls1v",
|
|
92
92
|
$$css: true
|
|
93
93
|
}, {
|
|
94
94
|
"--height": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.size)
|
|
95
95
|
}],
|
|
96
96
|
top: props => [{
|
|
97
|
-
top: "musae-
|
|
98
|
-
left: "musae-
|
|
97
|
+
top: "musae-9oc6z4",
|
|
98
|
+
left: "musae-1tjciyl",
|
|
99
99
|
insetInlineStart: null,
|
|
100
100
|
insetInlineEnd: null,
|
|
101
|
-
right: "musae-
|
|
101
|
+
right: "musae-15gpytn",
|
|
102
102
|
height: "musae-1jwls1v",
|
|
103
103
|
$$css: true
|
|
104
104
|
}, {
|
|
@@ -187,7 +187,7 @@ const Popup = ({
|
|
|
187
187
|
}, [open]);
|
|
188
188
|
const styled = {
|
|
189
189
|
popup: {
|
|
190
|
-
className: "musae-ixxii4 musae-
|
|
190
|
+
className: "musae-ixxii4 musae-ezip7x musae-47corl musae-mn8nw1"
|
|
191
191
|
},
|
|
192
192
|
overlay: props(styles.overlay({
|
|
193
193
|
backgroundColor: theme.colors[ColorToken.SurfaceDim]
|
|
@@ -31,7 +31,7 @@ const Icon = ({
|
|
|
31
31
|
const classNames = useClassNames(ComponentToken.Icon);
|
|
32
32
|
const asProps = useMemo(() => {
|
|
33
33
|
return {
|
|
34
|
-
size: size === "small" ? 12 : size === "large" ? 20 : size ?? 16
|
|
34
|
+
size: size === "small" ? 12 : size === "large" ? 20 : size === "medium" ? 16 : size ?? 16
|
|
35
35
|
};
|
|
36
36
|
}, [size]);
|
|
37
37
|
const children = useMemo(() => {
|