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
|
@@ -36,6 +36,7 @@ export { default as Cancel } from './navigation/cancel.js';
|
|
|
36
36
|
export { default as Close } from './navigation/close.js';
|
|
37
37
|
export { default as MoreHoriz } from './navigation/more-horiz.js';
|
|
38
38
|
export { default as Check } from './navigation/check.js';
|
|
39
|
+
export { default as UnfoldMore } from './navigation/unfold-more.js';
|
|
39
40
|
export { default as Bedtime } from './image/bedtime.js';
|
|
40
41
|
export { default as RotateLeft } from './image/rotate-left.js';
|
|
41
42
|
export { default as RotateRight } from './image/rotate-right.js';
|
|
@@ -2,4 +2,5 @@ import Cancel from "./cancel";
|
|
|
2
2
|
import MoreHoriz from "./more-horiz";
|
|
3
3
|
import Close from "./close";
|
|
4
4
|
import Check from "./check";
|
|
5
|
-
|
|
5
|
+
import UnfoldMore from "./unfold-more";
|
|
6
|
+
export { Cancel, Close, MoreHoriz, Check, UnfoldMore };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withIcon } from '../../hoc.js';
|
|
3
|
+
|
|
4
|
+
const UnfoldMore = withIcon(({ size }) => {
|
|
5
|
+
return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none" },
|
|
6
|
+
React.createElement("path", { d: "M12 5.83L15.17 9L16.58 7.59L12 3L7.41003 7.59L8.83003 9L12 5.83ZM12 18.17L8.83003 15L7.42003 16.41L12 21L16.59 16.41L15.17 15L12 18.17Z", fill: "currentColor" })));
|
|
7
|
+
});
|
|
8
|
+
var UnfoldMore$1 = UnfoldMore;
|
|
9
|
+
|
|
10
|
+
export { UnfoldMore$1 as default };
|
|
@@ -13,10 +13,10 @@ import KeyboardArrowRight from '../../icon/icons/hardware/keyboard-arrow-right.j
|
|
|
13
13
|
const styles = {
|
|
14
14
|
footer: props => [{
|
|
15
15
|
position: "musae-ixxii4",
|
|
16
|
-
left: "musae-
|
|
16
|
+
left: "musae-1tjciyl",
|
|
17
17
|
insetInlineStart: null,
|
|
18
18
|
insetInlineEnd: null,
|
|
19
|
-
right: "musae-
|
|
19
|
+
right: "musae-15gpytn",
|
|
20
20
|
bottom: "musae-1ii70tt",
|
|
21
21
|
display: "musae-78zum5",
|
|
22
22
|
flexDirection: "musae-dt5ytf",
|
|
@@ -74,7 +74,7 @@ const Operations = ({
|
|
|
74
74
|
className: "musae-1qtgrog musae-14l26ut"
|
|
75
75
|
},
|
|
76
76
|
navigations: {
|
|
77
|
-
className: "musae-ixxii4 musae-
|
|
77
|
+
className: "musae-ixxii4 musae-1tjciyl musae-15gpytn musae-wa60dl musae-gj1dgu musae-78zum5 musae-1q0g3np musae-1qughib musae-6s0dn4"
|
|
78
78
|
},
|
|
79
79
|
footer: _stylex.props(styles.footer({
|
|
80
80
|
color: theme.colors[ColorToken.OnSurface]
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
|
+
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
4
|
+
import { ComponentToken, LoadingClassToken } from '../../utils/class-name.js';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useTheme } from '../theme/hooks.js';
|
|
7
|
+
import { ColorToken } from '../../utils/colors.js';
|
|
3
8
|
|
|
4
9
|
const styles = {
|
|
5
10
|
circle: {
|
|
@@ -44,11 +49,55 @@ const styles = {
|
|
|
44
49
|
width: "musae-1ha45ep",
|
|
45
50
|
height: "musae-b4kbli",
|
|
46
51
|
$$css: true
|
|
52
|
+
},
|
|
53
|
+
loading: {
|
|
54
|
+
position: "musae-1n2onr6",
|
|
55
|
+
minWidth: "musae-h2iun8",
|
|
56
|
+
minHeight: "musae-oexrxm",
|
|
57
|
+
$$css: true
|
|
58
|
+
},
|
|
59
|
+
content: props => [{
|
|
60
|
+
opacity: "musae-byyjgo",
|
|
61
|
+
userSelect: "musae-87ps6o",
|
|
62
|
+
pointerEvents: "musae-47corl",
|
|
63
|
+
transitionProperty: "musae-19991ni",
|
|
64
|
+
transitionDuration: "musae-1d8287x",
|
|
65
|
+
zIndex: "musae-1ja2u2z",
|
|
66
|
+
"::after_content": "musae-1s928wv",
|
|
67
|
+
"::after_display": "musae-hkezso",
|
|
68
|
+
"::after_position": "musae-1j6awrg",
|
|
69
|
+
"::after_inset": "musae-1799ia1",
|
|
70
|
+
"::after_insetInline": null,
|
|
71
|
+
"::after_insetInlineStart": null,
|
|
72
|
+
"::after_insetInlineEnd": null,
|
|
73
|
+
"::after_left": null,
|
|
74
|
+
"::after_right": null,
|
|
75
|
+
"::after_insetBlock": null,
|
|
76
|
+
"::after_top": null,
|
|
77
|
+
"::after_bottom": null,
|
|
78
|
+
"::after_backgroundColor": "musae-27d4w3",
|
|
79
|
+
$$css: true
|
|
80
|
+
}, {
|
|
81
|
+
"--15iyedw": props.backgroundColor != null ? props.backgroundColor : "initial"
|
|
82
|
+
}],
|
|
83
|
+
spin: {
|
|
84
|
+
position: "musae-10l6tqk",
|
|
85
|
+
top: "musae-wa60dl",
|
|
86
|
+
insetInlineStart: "musae-budbmw",
|
|
87
|
+
left: null,
|
|
88
|
+
right: null,
|
|
89
|
+
transform: "musae-11lhmoz",
|
|
90
|
+
zIndex: "musae-1vjfegm",
|
|
91
|
+
$$css: true
|
|
47
92
|
}
|
|
48
93
|
};
|
|
49
94
|
const Loading = ({
|
|
50
|
-
size = "medium"
|
|
95
|
+
size = "medium",
|
|
96
|
+
overlay = true,
|
|
97
|
+
children
|
|
51
98
|
}) => {
|
|
99
|
+
const classNames = useClassNames(ComponentToken.Loading);
|
|
100
|
+
const theme = useTheme();
|
|
52
101
|
const circles = {
|
|
53
102
|
top: {
|
|
54
103
|
...{
|
|
@@ -83,15 +132,31 @@ const Loading = ({
|
|
|
83
132
|
r: "70"
|
|
84
133
|
}
|
|
85
134
|
};
|
|
86
|
-
|
|
135
|
+
const styled = {
|
|
136
|
+
loading: {
|
|
137
|
+
className: "musae-1n2onr6 musae-h2iun8 musae-oexrxm"
|
|
138
|
+
},
|
|
139
|
+
spin: props(styles.spin, styles[size]),
|
|
140
|
+
content: props(overlay && styles.content({
|
|
141
|
+
backgroundColor: theme.colors[ColorToken.SurfaceDim]
|
|
142
|
+
}))
|
|
143
|
+
};
|
|
144
|
+
return React.createElement("div", {
|
|
145
|
+
className: clsx(classNames[LoadingClassToken.Loading], styled.loading.className),
|
|
146
|
+
style: styled.loading.style
|
|
147
|
+
}, React.createElement("svg", {
|
|
87
148
|
viewBox: "0 0 240 240",
|
|
88
|
-
|
|
149
|
+
className: clsx(classNames[LoadingClassToken.Spin], styled.spin.className),
|
|
150
|
+
style: styled.spin.style
|
|
89
151
|
}, Array.from(Object.entries(circles)).map(([key, props]) => {
|
|
90
152
|
return React.createElement("circle", {
|
|
91
153
|
...props,
|
|
92
154
|
key: key
|
|
93
155
|
});
|
|
94
|
-
}))
|
|
156
|
+
})), React.createElement("div", {
|
|
157
|
+
className: (classNames[LoadingClassToken.Content], styled.content.className),
|
|
158
|
+
style: styled.content.style
|
|
159
|
+
}, children));
|
|
95
160
|
};
|
|
96
161
|
var Loading$1 = Loading;
|
|
97
162
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
type Size = "small" | "medium" | "large";
|
|
2
3
|
/**
|
|
3
4
|
* @author murukal
|
|
@@ -12,5 +13,17 @@ export interface LoadingProps {
|
|
|
12
13
|
* @default "medium"
|
|
13
14
|
*/
|
|
14
15
|
size?: Size;
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* overlay shown
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
overlay?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @description
|
|
24
|
+
* children
|
|
25
|
+
* @default void 0
|
|
26
|
+
*/
|
|
27
|
+
children?: ReactNode;
|
|
15
28
|
}
|
|
16
29
|
export {};
|
|
@@ -25,8 +25,8 @@ const styles = {
|
|
|
25
25
|
$$css: true
|
|
26
26
|
},
|
|
27
27
|
top: {
|
|
28
|
-
top: "musae-
|
|
29
|
-
insetInline: "musae-
|
|
28
|
+
top: "musae-9oc6z4",
|
|
29
|
+
insetInline: "musae-l33w4x",
|
|
30
30
|
insetInlineStart: null,
|
|
31
31
|
insetInlineEnd: null,
|
|
32
32
|
left: null,
|
|
@@ -35,22 +35,22 @@ const styles = {
|
|
|
35
35
|
$$css: true
|
|
36
36
|
},
|
|
37
37
|
topRight: {
|
|
38
|
-
top: "musae-
|
|
39
|
-
insetInlineEnd: "musae-
|
|
38
|
+
top: "musae-9oc6z4",
|
|
39
|
+
insetInlineEnd: "musae-hw0b42",
|
|
40
40
|
left: null,
|
|
41
41
|
right: null,
|
|
42
42
|
$$css: true
|
|
43
43
|
},
|
|
44
44
|
topLeft: {
|
|
45
|
-
top: "musae-
|
|
46
|
-
insetInlineStart: "musae-
|
|
45
|
+
top: "musae-9oc6z4",
|
|
46
|
+
insetInlineStart: "musae-1at4hj2",
|
|
47
47
|
left: null,
|
|
48
48
|
right: null,
|
|
49
49
|
$$css: true
|
|
50
50
|
},
|
|
51
51
|
bottom: {
|
|
52
|
-
bottom: "musae-
|
|
53
|
-
insetInline: "musae-
|
|
52
|
+
bottom: "musae-1sh2tzk",
|
|
53
|
+
insetInline: "musae-l33w4x",
|
|
54
54
|
insetInlineStart: null,
|
|
55
55
|
insetInlineEnd: null,
|
|
56
56
|
left: null,
|
|
@@ -59,15 +59,15 @@ const styles = {
|
|
|
59
59
|
$$css: true
|
|
60
60
|
},
|
|
61
61
|
bottomLeft: {
|
|
62
|
-
bottom: "musae-
|
|
63
|
-
insetInlineStart: "musae-
|
|
62
|
+
bottom: "musae-1sh2tzk",
|
|
63
|
+
insetInlineStart: "musae-1at4hj2",
|
|
64
64
|
left: null,
|
|
65
65
|
right: null,
|
|
66
66
|
$$css: true
|
|
67
67
|
},
|
|
68
68
|
bottomRight: {
|
|
69
|
-
bottom: "musae-
|
|
70
|
-
insetInlineEnd: "musae-
|
|
69
|
+
bottom: "musae-1sh2tzk",
|
|
70
|
+
insetInlineEnd: "musae-hw0b42",
|
|
71
71
|
left: null,
|
|
72
72
|
right: null,
|
|
73
73
|
$$css: true
|
|
@@ -16,8 +16,8 @@ const styles = {
|
|
|
16
16
|
zIndex: "musae-1axsr4t",
|
|
17
17
|
position: "musae-10l6tqk",
|
|
18
18
|
backgroundColor: "musae-q1mx2j",
|
|
19
|
-
top: "musae-
|
|
20
|
-
insetInlineStart: "musae-
|
|
19
|
+
top: "musae-9oc6z4",
|
|
20
|
+
insetInlineStart: "musae-1at4hj2",
|
|
21
21
|
left: null,
|
|
22
22
|
right: null,
|
|
23
23
|
boxShadow: "musae-ezd0au",
|
|
@@ -31,22 +31,22 @@ const styles = {
|
|
|
31
31
|
$$css: true
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
default:
|
|
34
|
+
half: {
|
|
35
|
+
default: {
|
|
36
36
|
position: "musae-10l6tqk",
|
|
37
37
|
width: "musae-1gn8jaj",
|
|
38
38
|
height: "musae-b27hse",
|
|
39
|
-
insetInlineStart: "musae-
|
|
39
|
+
insetInlineStart: "musae-1at4hj2",
|
|
40
40
|
left: null,
|
|
41
41
|
right: null,
|
|
42
|
-
top: "musae-
|
|
42
|
+
top: "musae-9oc6z4",
|
|
43
43
|
opacity: "musae-g01cxk",
|
|
44
44
|
userSelect: "musae-87ps6o",
|
|
45
45
|
overflow: "musae-b3r6kr",
|
|
46
46
|
overflowX: null,
|
|
47
47
|
overflowY: null,
|
|
48
48
|
$$css: true
|
|
49
|
-
},
|
|
49
|
+
},
|
|
50
50
|
checked: props => [{
|
|
51
51
|
opacity: "musae-1hc1fzr",
|
|
52
52
|
color: "musae-19dipnz",
|
|
@@ -55,12 +55,12 @@ const styles = {
|
|
|
55
55
|
"--color": props.color != null ? props.color : "initial"
|
|
56
56
|
}]
|
|
57
57
|
},
|
|
58
|
-
|
|
58
|
+
full: {
|
|
59
59
|
default: {
|
|
60
60
|
userSelect: "musae-87ps6o",
|
|
61
61
|
$$css: true
|
|
62
62
|
},
|
|
63
|
-
|
|
63
|
+
checked: props => [{
|
|
64
64
|
color: "musae-19dipnz",
|
|
65
65
|
$$css: true
|
|
66
66
|
}, {
|
|
@@ -104,12 +104,10 @@ const Star = ({
|
|
|
104
104
|
star: _stylex.props(styles.star.default({
|
|
105
105
|
color: theme.colors[ColorToken.SurfaceContainerHighest]
|
|
106
106
|
}), disabled && styles.star.disabled),
|
|
107
|
-
|
|
108
|
-
hoveredColor: theme.colors[ColorToken.Primary]
|
|
109
|
-
}), isHalf && styles.leading.checked({
|
|
107
|
+
half: _stylex.props(styles.half.default, isHalf && styles.half.checked({
|
|
110
108
|
color: theme.colors[ColorToken.Primary]
|
|
111
109
|
})),
|
|
112
|
-
|
|
110
|
+
full: _stylex.props(styles.full.default, isFull && styles.full.checked({
|
|
113
111
|
color: theme.colors[ColorToken.Primary]
|
|
114
112
|
}))
|
|
115
113
|
};
|
|
@@ -117,8 +115,8 @@ const Star = ({
|
|
|
117
115
|
className: clsx(classNames[RateClassToken.Star], styled.star.className),
|
|
118
116
|
style: styled.star.style
|
|
119
117
|
}, React.createElement("div", {
|
|
120
|
-
className: clsx(classNames[RateClassToken.
|
|
121
|
-
style: styled.
|
|
118
|
+
className: clsx(classNames[RateClassToken.Half], styled.half.className),
|
|
119
|
+
style: styled.half.style,
|
|
122
120
|
...(!disabled && {
|
|
123
121
|
...halfHoverProps,
|
|
124
122
|
onClick: half
|
|
@@ -126,8 +124,8 @@ const Star = ({
|
|
|
126
124
|
}, createElement(_Star, {
|
|
127
125
|
size: "large"
|
|
128
126
|
})), React.createElement("div", {
|
|
129
|
-
className: clsx(classNames[RateClassToken.
|
|
130
|
-
style: styled.
|
|
127
|
+
className: clsx(classNames[RateClassToken.Full], styled.full.className),
|
|
128
|
+
style: styled.full.style,
|
|
131
129
|
...(!disabled && {
|
|
132
130
|
...fullHoverProps,
|
|
133
131
|
onClick: full
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { useState, useCallback, useMemo } from 'react';
|
|
2
|
+
import { useIdentity } from '@aiszlab/relax';
|
|
2
3
|
|
|
3
4
|
function useRipple() {
|
|
4
5
|
const [_ripples, _setRipples] = useState(new Map());
|
|
6
|
+
const [, unique] = useIdentity();
|
|
5
7
|
const add = useCallback((event) => {
|
|
6
8
|
const trigger = event.currentTarget;
|
|
7
9
|
const size = Math.max(trigger.clientWidth, trigger.clientHeight);
|
|
8
10
|
const { x, y } = trigger.getBoundingClientRect();
|
|
9
11
|
_setRipples((prev) => {
|
|
10
|
-
return new Map(prev).set(
|
|
12
|
+
return new Map(prev).set(unique(), {
|
|
11
13
|
size,
|
|
12
14
|
x: event.clientX - x - size / 2,
|
|
13
15
|
y: event.clientY - y - size / 2,
|
|
14
16
|
});
|
|
15
17
|
});
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
19
|
}, []);
|
|
17
20
|
const clear = useCallback((key) => {
|
|
18
21
|
_setRipples((prev) => {
|
|
@@ -192,20 +192,20 @@ const styles = {
|
|
|
192
192
|
$$css: true
|
|
193
193
|
},
|
|
194
194
|
checked: {
|
|
195
|
-
marginInlineStart: "musae-
|
|
195
|
+
marginInlineStart: "musae-1tt3wx9",
|
|
196
196
|
marginLeft: null,
|
|
197
197
|
marginRight: null,
|
|
198
|
-
marginInlineEnd: "musae-
|
|
198
|
+
marginInlineEnd: "musae-fbia9g",
|
|
199
199
|
$$css: true
|
|
200
200
|
}
|
|
201
201
|
},
|
|
202
202
|
trailing: {
|
|
203
203
|
default: {
|
|
204
204
|
marginTop: "musae-ncydc0",
|
|
205
|
-
marginInlineEnd: "musae-
|
|
205
|
+
marginInlineEnd: "musae-fbia9g",
|
|
206
206
|
marginLeft: null,
|
|
207
207
|
marginRight: null,
|
|
208
|
-
marginInlineStart: "musae-
|
|
208
|
+
marginInlineStart: "musae-1tt3wx9",
|
|
209
209
|
$$css: true
|
|
210
210
|
},
|
|
211
211
|
checked: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useTable
|
|
2
|
+
import { useTable } from './context.js';
|
|
3
3
|
import { flexRender } from '@tanstack/react-table';
|
|
4
4
|
import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
5
5
|
import clsx from 'clsx';
|
|
@@ -8,6 +8,38 @@ import { useTheme } from '../theme/hooks.js';
|
|
|
8
8
|
import { ColorToken } from '../../utils/colors.js';
|
|
9
9
|
|
|
10
10
|
const styles = {
|
|
11
|
+
cell: props => [{
|
|
12
|
+
paddingInline: "musae-iujutg",
|
|
13
|
+
paddingStart: null,
|
|
14
|
+
paddingLeft: null,
|
|
15
|
+
paddingEnd: null,
|
|
16
|
+
paddingRight: null,
|
|
17
|
+
paddingBlock: "musae-avjae4",
|
|
18
|
+
paddingTop: null,
|
|
19
|
+
paddingBottom: null,
|
|
20
|
+
borderColor: "musae-eqt46j",
|
|
21
|
+
borderInlineColor: null,
|
|
22
|
+
borderInlineStartColor: null,
|
|
23
|
+
borderLeftColor: null,
|
|
24
|
+
borderInlineEndColor: null,
|
|
25
|
+
borderRightColor: null,
|
|
26
|
+
borderBlockColor: null,
|
|
27
|
+
borderTopColor: null,
|
|
28
|
+
borderBottomColor: null,
|
|
29
|
+
borderStyle: "musae-1y0btm7",
|
|
30
|
+
borderInlineStyle: null,
|
|
31
|
+
borderInlineStartStyle: null,
|
|
32
|
+
borderLeftStyle: null,
|
|
33
|
+
borderInlineEndStyle: null,
|
|
34
|
+
borderRightStyle: null,
|
|
35
|
+
borderBlockStyle: null,
|
|
36
|
+
borderTopStyle: null,
|
|
37
|
+
borderBottomStyle: null,
|
|
38
|
+
borderBottomWidth: "musae-lntmim",
|
|
39
|
+
$$css: true
|
|
40
|
+
}, {
|
|
41
|
+
"--borderColor": props.borderColor != null ? props.borderColor : "initial"
|
|
42
|
+
}],
|
|
11
43
|
bordered: {
|
|
12
44
|
borderInline: "musae-10htjfm",
|
|
13
45
|
$$css: true
|
|
@@ -20,8 +52,8 @@ const Body = props$1 => {
|
|
|
20
52
|
} = useTable();
|
|
21
53
|
const theme = useTheme();
|
|
22
54
|
if (!table) return null;
|
|
23
|
-
const styled = props(bordered && styles.bordered, typography.body.small, styles
|
|
24
|
-
|
|
55
|
+
const styled = props(bordered && styles.bordered, typography.body.small, styles.cell({
|
|
56
|
+
borderColor: theme.colors[ColorToken.OutlineVariant]
|
|
25
57
|
}));
|
|
26
58
|
return React.createElement("tbody", null, table.getRowModel().rows.map(row => React.createElement("tr", {
|
|
27
59
|
key: row.id
|
|
@@ -2,3 +2,9 @@
|
|
|
2
2
|
import type { ContextValue } from "./types";
|
|
3
3
|
declare const Context: import("react").Context<ContextValue<unknown>>;
|
|
4
4
|
export default Context;
|
|
5
|
+
/**
|
|
6
|
+
* @author murukal
|
|
7
|
+
* @description
|
|
8
|
+
* use table context hook
|
|
9
|
+
*/
|
|
10
|
+
export declare const useTable: <T>() => ContextValue<T>;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
2
|
|
|
3
3
|
const Context = createContext({
|
|
4
4
|
bordered: false,
|
|
5
5
|
});
|
|
6
|
+
/**
|
|
7
|
+
* @author murukal
|
|
8
|
+
* @description
|
|
9
|
+
* use table context hook
|
|
10
|
+
*/
|
|
11
|
+
const useTable = () => {
|
|
12
|
+
return useContext(Context);
|
|
13
|
+
};
|
|
6
14
|
|
|
7
|
-
export { Context as default };
|
|
15
|
+
export { Context as default, useTable };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { toFunction, useEvent, isUndefined } from '@aiszlab/relax';
|
|
3
|
+
import _stylex from '../../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
4
|
+
import { useTheme } from '../../theme/hooks.js';
|
|
5
|
+
import { ColorToken } from '../../../utils/colors.js';
|
|
6
|
+
import Context from '../context.js';
|
|
7
|
+
import UnfoldMore from '../../icon/icons/navigation/unfold-more.js';
|
|
8
|
+
|
|
9
|
+
const styles = {
|
|
10
|
+
cell: {
|
|
11
|
+
default: {
|
|
12
|
+
display: "musae-78zum5",
|
|
13
|
+
justifyContent: "musae-1qughib",
|
|
14
|
+
alignItems: "musae-6s0dn4",
|
|
15
|
+
$$css: true
|
|
16
|
+
},
|
|
17
|
+
handlers: props => [{
|
|
18
|
+
display: "musae-3nfvp2",
|
|
19
|
+
flexDirection: "musae-1q0g3np",
|
|
20
|
+
gap: "musae-29tp26",
|
|
21
|
+
rowGap: null,
|
|
22
|
+
columnGap: null,
|
|
23
|
+
color: "musae-19dipnz",
|
|
24
|
+
userSelect: "musae-87ps6o",
|
|
25
|
+
$$css: true
|
|
26
|
+
}, {
|
|
27
|
+
"--color": props.color != null ? props.color : "initial"
|
|
28
|
+
}]
|
|
29
|
+
},
|
|
30
|
+
sort: {
|
|
31
|
+
default: {
|
|
32
|
+
position: "musae-1n2onr6",
|
|
33
|
+
cursor: "musae-1ypdohk",
|
|
34
|
+
$$css: true
|
|
35
|
+
},
|
|
36
|
+
half: {
|
|
37
|
+
position: "musae-10l6tqk",
|
|
38
|
+
top: "musae-9oc6z4",
|
|
39
|
+
insetInlineStart: "musae-1at4hj2",
|
|
40
|
+
left: null,
|
|
41
|
+
right: null,
|
|
42
|
+
height: "musae-1cj5796",
|
|
43
|
+
overflow: "musae-b3r6kr",
|
|
44
|
+
overflowX: null,
|
|
45
|
+
overflowY: null,
|
|
46
|
+
$$css: true
|
|
47
|
+
},
|
|
48
|
+
checked: props => [{
|
|
49
|
+
color: "musae-19dipnz",
|
|
50
|
+
$$css: true
|
|
51
|
+
}, {
|
|
52
|
+
"--color": props.color != null ? props.color : "initial"
|
|
53
|
+
}]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const Cell = ({
|
|
57
|
+
sortable = false,
|
|
58
|
+
children: _children,
|
|
59
|
+
value,
|
|
60
|
+
sortDirections: _sortDirections
|
|
61
|
+
}) => {
|
|
62
|
+
const {
|
|
63
|
+
sortDescriptor,
|
|
64
|
+
onSortChange
|
|
65
|
+
} = useContext(Context);
|
|
66
|
+
const children = toFunction(_children)();
|
|
67
|
+
const theme = useTheme();
|
|
68
|
+
// convert sort directions to usable
|
|
69
|
+
const sortDirections = useMemo(() => {
|
|
70
|
+
return _sortDirections.reduce((prev, item, index) => {
|
|
71
|
+
return prev.set(item, _sortDirections[index + 1] ?? null);
|
|
72
|
+
}, new Map());
|
|
73
|
+
}, [_sortDirections]);
|
|
74
|
+
const sort = useMemo(() => {
|
|
75
|
+
if (sortDescriptor?.key === value) {
|
|
76
|
+
return sortDescriptor.direction;
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}, [sortDescriptor, value]);
|
|
80
|
+
// sort handler
|
|
81
|
+
const onSort = useEvent(() => {
|
|
82
|
+
const _direction = sortDirections.get(sort);
|
|
83
|
+
const __direction = isUndefined(_direction) ? "ascending" : _direction;
|
|
84
|
+
onSortChange?.({
|
|
85
|
+
key: value,
|
|
86
|
+
direction: __direction
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
// only children, render directly
|
|
90
|
+
if (!sortable) {
|
|
91
|
+
return children;
|
|
92
|
+
}
|
|
93
|
+
const styled = {
|
|
94
|
+
cell: _stylex.props(styles.cell.default),
|
|
95
|
+
handlers: _stylex.props(styles.cell.handlers({
|
|
96
|
+
color: theme.colors[ColorToken.SurfaceContainerHighest]
|
|
97
|
+
})),
|
|
98
|
+
sort: _stylex.props(styles.sort.default),
|
|
99
|
+
fullSort: _stylex.props(sort === "descending" && styles.sort.checked({
|
|
100
|
+
color: theme.colors[ColorToken.Primary]
|
|
101
|
+
})),
|
|
102
|
+
halfSort: _stylex.props(styles.sort.half, sort === "ascending" && styles.sort.checked({
|
|
103
|
+
color: theme.colors[ColorToken.Primary]
|
|
104
|
+
}))
|
|
105
|
+
};
|
|
106
|
+
return React.createElement("div", {
|
|
107
|
+
className: styled.cell.className,
|
|
108
|
+
style: styled.cell.style
|
|
109
|
+
}, children, React.createElement("span", {
|
|
110
|
+
className: styled.handlers.className,
|
|
111
|
+
style: styled.handlers.style
|
|
112
|
+
}, React.createElement("span", {
|
|
113
|
+
className: styled.sort.className,
|
|
114
|
+
style: styled.sort.style,
|
|
115
|
+
onClick: onSort
|
|
116
|
+
}, React.createElement("div", {
|
|
117
|
+
className: styled.fullSort.className,
|
|
118
|
+
style: styled.fullSort.style
|
|
119
|
+
}, React.createElement(UnfoldMore, {
|
|
120
|
+
size: "medium"
|
|
121
|
+
})), !!sort && React.createElement("div", {
|
|
122
|
+
className: styled.halfSort.className,
|
|
123
|
+
style: styled.halfSort.style
|
|
124
|
+
}, React.createElement(UnfoldMore, {
|
|
125
|
+
size: "medium"
|
|
126
|
+
})))));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export { Cell as default };
|