musae 0.1.48 → 0.2.1
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 +7 -1
- package/dist/components/avatar/avatar.js +40 -14
- package/dist/components/avatar/group.d.ts +1 -1
- package/dist/components/avatar/group.js +34 -4
- package/dist/components/avatar/types.d.ts +22 -6
- package/dist/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/components/breadcrumb/item.js +1 -1
- package/dist/components/breadcrumb/types.d.ts +9 -3
- package/dist/components/button/button.js +5 -3
- package/dist/components/button/types.d.ts +12 -15
- package/dist/components/calendar/calendar.d.ts +1 -1
- package/dist/components/calendar/calendar.js +18 -5
- package/dist/components/calendar/hooks.d.ts +7 -2
- package/dist/components/calendar/hooks.js +14 -9
- package/dist/components/calendar/types.d.ts +3 -0
- package/dist/components/cascader/cascader.d.ts +1 -1
- package/dist/components/cascader/cascader.js +3 -1
- package/dist/components/cascader/hooks.d.ts +3 -2
- package/dist/components/cascader/types.d.ts +6 -1
- package/dist/components/cascader/utils.js +2 -2
- package/dist/components/checkbox/types.d.ts +5 -0
- package/dist/components/clock/clock.d.ts +1 -1
- package/dist/components/clock/types.d.ts +2 -0
- package/dist/components/countable/types.d.ts +0 -2
- package/dist/components/date-picker/types.d.ts +2 -0
- package/dist/components/date-range-picker/types.d.ts +2 -0
- package/dist/components/dialog/dialog.d.ts +1 -1
- package/dist/components/dialog/dialog.js +2 -2
- package/dist/components/dialog/popup.js +1 -1
- package/dist/components/dialog/types.d.ts +15 -6
- package/dist/components/divider/types.d.ts +3 -0
- package/dist/components/drawer/types.d.ts +11 -7
- package/dist/components/form/types.d.ts +7 -0
- package/dist/components/grid/types.d.ts +8 -0
- package/dist/components/image/types.d.ts +3 -0
- package/dist/components/input/input.js +2 -2
- package/dist/components/input/types.d.ts +12 -12
- package/dist/components/loading/types.d.ts +1 -0
- package/dist/components/menu/group.d.ts +1 -1
- package/dist/components/menu/group.js +2 -3
- package/dist/components/menu/item.js +4 -7
- package/dist/components/menu/menu.js +10 -6
- package/dist/components/menu/types.d.ts +32 -15
- package/dist/components/otp-input/otp-input.js +4 -2
- package/dist/components/otp-input/types.d.ts +2 -1
- package/dist/components/pagination/types.d.ts +4 -0
- package/dist/components/popover/popover.d.ts +1 -1
- package/dist/components/popover/popover.js +17 -12
- package/dist/components/popover/types.d.ts +12 -1
- package/dist/components/popper/dropdown.js +10 -10
- package/dist/components/popper/popper.d.ts +1 -1
- package/dist/components/popper/popper.js +2 -2
- package/dist/components/popper/types.d.ts +6 -1
- package/dist/components/portal/portal.d.ts +2 -2
- package/dist/components/progress/progress.d.ts +1 -1
- package/dist/components/radio/group.d.ts +1 -1
- package/dist/components/radio/group.js +4 -4
- package/dist/components/radio/radio.d.ts +2 -2
- package/dist/components/radio/radio.js +144 -125
- package/dist/components/radio/types.d.ts +7 -0
- package/dist/components/rate/types.d.ts +4 -0
- package/dist/components/select/hooks.d.ts +2 -1
- package/dist/components/select/hooks.js +1 -3
- package/dist/components/select/select.js +1 -1
- package/dist/components/select/types.d.ts +8 -0
- package/dist/components/space/space.d.ts +1 -1
- package/dist/components/space/space.js +14 -5
- package/dist/components/space/types.d.ts +12 -2
- package/dist/components/steps/types.d.ts +5 -2
- package/dist/components/switch/switch.js +3 -0
- package/dist/components/switch/types.d.ts +6 -0
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.js +2 -1
- package/dist/components/table/types.d.ts +3 -0
- package/dist/components/tabs/types.d.ts +8 -1
- package/dist/components/tag/tag.js +1 -1
- package/dist/components/tag/types.d.ts +4 -0
- package/dist/components/time-picker/types.d.ts +2 -0
- package/dist/components/timeline/types.d.ts +4 -0
- package/dist/components/tooltip/types.d.ts +6 -4
- package/dist/components/tour/hooks.d.ts +3 -3
- package/dist/components/tour/types.d.ts +10 -2
- package/dist/components/tree/types.d.ts +3 -0
- package/dist/components/waterfall/types.d.ts +4 -0
- package/dist/components/watermark/types.d.ts +8 -5
- package/dist/stylex.css +8 -5
- package/dist/types/option.d.ts +3 -0
- package/package.json +4 -4
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { AvatarProps } from "./types";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* `Avatar`
|
|
6
|
+
*
|
|
7
|
+
* component
|
|
8
|
+
*/
|
|
9
|
+
declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>;
|
|
4
10
|
export default Avatar;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { forwardRef, useContext } from 'react';
|
|
2
2
|
import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
3
|
import { Context } from './context.js';
|
|
4
4
|
import { useTheme } from '../theme/hooks.js';
|
|
@@ -6,9 +6,10 @@ import { ColorToken } from '../../utils/colors.js';
|
|
|
6
6
|
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
|
+
import { typography } from '../theme/theme.js';
|
|
9
10
|
|
|
10
11
|
const styles = {
|
|
11
|
-
avatar: {
|
|
12
|
+
avatar: props => [{
|
|
12
13
|
borderWidth: "musae-1i8jmgv",
|
|
13
14
|
borderInlineWidth: null,
|
|
14
15
|
borderInlineStartWidth: null,
|
|
@@ -37,8 +38,17 @@ const styles = {
|
|
|
37
38
|
borderTopColor: null,
|
|
38
39
|
borderBottomColor: null,
|
|
39
40
|
boxSizing: "musae-9f619",
|
|
41
|
+
display: "musae-3nfvp2",
|
|
42
|
+
backgroundColor: "musae-q1mx2j",
|
|
43
|
+
color: "musae-19dipnz",
|
|
44
|
+
alignItems: "musae-6s0dn4",
|
|
45
|
+
justifyContent: "musae-l56j7k",
|
|
46
|
+
userSelect: "musae-87ps6o",
|
|
40
47
|
$$css: true
|
|
41
|
-
},
|
|
48
|
+
}, {
|
|
49
|
+
"--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial",
|
|
50
|
+
"--color": props.color != null ? props.color : "initial"
|
|
51
|
+
}],
|
|
42
52
|
image: {
|
|
43
53
|
width: "musae-wfgd1y",
|
|
44
54
|
height: "musae-b27hse",
|
|
@@ -111,19 +121,31 @@ const styles = {
|
|
|
111
121
|
$$css: true
|
|
112
122
|
}
|
|
113
123
|
};
|
|
114
|
-
|
|
124
|
+
/**
|
|
125
|
+
* @description
|
|
126
|
+
* `Avatar`
|
|
127
|
+
*
|
|
128
|
+
* component
|
|
129
|
+
*/
|
|
130
|
+
const Avatar = forwardRef(({
|
|
115
131
|
src,
|
|
116
132
|
alt,
|
|
133
|
+
shape: _shape = "circular",
|
|
134
|
+
size: _size = "medium",
|
|
135
|
+
fallback,
|
|
117
136
|
...props$1
|
|
118
|
-
}) => {
|
|
137
|
+
}, ref) => {
|
|
119
138
|
const theme = useTheme();
|
|
120
139
|
const group = useContext(Context);
|
|
121
140
|
const isInGroup = !!group;
|
|
122
|
-
const size = group?.size ??
|
|
123
|
-
const shape = group?.shape ??
|
|
141
|
+
const size = group?.size ?? _size;
|
|
142
|
+
const shape = group?.shape ?? _shape;
|
|
124
143
|
const classNames = useClassNames(ComponentToken.Avatar);
|
|
125
144
|
const styled = {
|
|
126
|
-
avatar: props(
|
|
145
|
+
avatar: props(typography.label[size], styles.avatar({
|
|
146
|
+
backgroundColor: theme.colors[ColorToken.PrimaryContainer],
|
|
147
|
+
color: theme.colors[ColorToken.Primary]
|
|
148
|
+
}), styles[size], styles[shape], isInGroup && styles.overlapping({
|
|
127
149
|
outlineColor: theme.colors[ColorToken.OnPrimary]
|
|
128
150
|
})),
|
|
129
151
|
image: {
|
|
@@ -131,13 +153,17 @@ const Avatar = ({
|
|
|
131
153
|
}
|
|
132
154
|
};
|
|
133
155
|
return React.createElement("span", {
|
|
156
|
+
...props$1,
|
|
134
157
|
className: clsx(classNames[AvatarClassToken.Avatar], styled.avatar.className),
|
|
135
|
-
style: styled.avatar.style
|
|
136
|
-
|
|
137
|
-
|
|
158
|
+
style: styled.avatar.style,
|
|
159
|
+
ref: ref
|
|
160
|
+
}, !!src ? React.createElement("img", {
|
|
161
|
+
draggable: false,
|
|
138
162
|
src: src,
|
|
139
|
-
alt: alt
|
|
140
|
-
|
|
141
|
-
|
|
163
|
+
alt: alt,
|
|
164
|
+
className: styled.image.className,
|
|
165
|
+
style: styled.image.style
|
|
166
|
+
}) : fallback);
|
|
167
|
+
});
|
|
142
168
|
|
|
143
169
|
export { Avatar as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type AvatarGroupProps } from "./types";
|
|
3
|
-
declare const Group: ({ children, shape, size }: AvatarGroupProps) => React.JSX.Element;
|
|
3
|
+
declare const Group: ({ children: _children, shape, size, max }: AvatarGroupProps) => React.JSX.Element;
|
|
4
4
|
export default Group;
|
|
@@ -1,17 +1,47 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo, Children, cloneElement } from 'react';
|
|
2
2
|
import { Context } from './context.js';
|
|
3
3
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
4
4
|
import { ComponentToken, AvatarClassToken } from '../../utils/class-name.js';
|
|
5
|
+
import Popover from '../popover/popover.js';
|
|
6
|
+
import Avatar from './avatar.js';
|
|
5
7
|
|
|
6
8
|
const Group = ({
|
|
7
|
-
children,
|
|
9
|
+
children: _children,
|
|
8
10
|
shape = "circular",
|
|
9
|
-
size = "medium"
|
|
11
|
+
size = "medium",
|
|
12
|
+
max = 3
|
|
10
13
|
}) => {
|
|
11
14
|
const styled = {
|
|
12
|
-
className: "musae-3nfvp2"
|
|
15
|
+
className: "musae-3nfvp2 musae-87ps6o"
|
|
13
16
|
};
|
|
14
17
|
const classNames = useClassNames(ComponentToken.Avatar);
|
|
18
|
+
const children = useMemo(() => {
|
|
19
|
+
const __children = Children.toArray(_children);
|
|
20
|
+
const [visible, hidden] = __children.reduce((prev, child, index) => {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
const element = cloneElement(child, {
|
|
23
|
+
key: `avatars-${index}`
|
|
24
|
+
});
|
|
25
|
+
// great than max, hide current node
|
|
26
|
+
if (index >= max) {
|
|
27
|
+
prev[1].push(element);
|
|
28
|
+
} else {
|
|
29
|
+
prev[0].push(element);
|
|
30
|
+
}
|
|
31
|
+
return prev;
|
|
32
|
+
}, [[], []]);
|
|
33
|
+
// got hidden nodes, show ellipse node
|
|
34
|
+
if (hidden.length > 0) {
|
|
35
|
+
visible.push(React.createElement(Popover, {
|
|
36
|
+
description: React.createElement(Group, null, hidden),
|
|
37
|
+
key: "avatars-hidden",
|
|
38
|
+
placement: "top"
|
|
39
|
+
}, React.createElement(Avatar, {
|
|
40
|
+
fallback: `+${hidden.length}`
|
|
41
|
+
})));
|
|
42
|
+
}
|
|
43
|
+
return visible;
|
|
44
|
+
}, [_children, max]);
|
|
15
45
|
return React.createElement(Context.Provider, {
|
|
16
46
|
value: {
|
|
17
47
|
shape,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
1
|
+
import type { ReactNode, RefAttributes } from "react";
|
|
2
2
|
type Size = "small" | "medium" | "large";
|
|
3
3
|
type Shape = "circular" | "squared";
|
|
4
4
|
/**
|
|
@@ -9,23 +9,35 @@ export type AvatarProps = {
|
|
|
9
9
|
/**
|
|
10
10
|
* @description
|
|
11
11
|
* src
|
|
12
|
+
* @default void 0
|
|
12
13
|
*/
|
|
13
14
|
src?: string;
|
|
14
15
|
/**
|
|
15
16
|
* @description
|
|
16
17
|
* alt
|
|
18
|
+
* @default void 0
|
|
17
19
|
*/
|
|
18
20
|
alt?: string;
|
|
19
21
|
/**
|
|
20
22
|
* @description
|
|
21
23
|
* size
|
|
24
|
+
* @default "medium"
|
|
22
25
|
*/
|
|
23
26
|
size?: Size;
|
|
24
27
|
/**
|
|
25
28
|
* @description
|
|
26
29
|
* shape
|
|
30
|
+
* @default "circular"
|
|
27
31
|
*/
|
|
28
32
|
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;
|
|
29
41
|
};
|
|
30
42
|
/**
|
|
31
43
|
* @description
|
|
@@ -35,23 +47,27 @@ export type AvatarGroupProps = {
|
|
|
35
47
|
/**
|
|
36
48
|
* @description
|
|
37
49
|
* children
|
|
50
|
+
* @requires
|
|
38
51
|
*/
|
|
39
52
|
children: ReactNode;
|
|
40
53
|
/**
|
|
41
54
|
* @description
|
|
42
55
|
* max
|
|
56
|
+
* @default 3
|
|
43
57
|
*/
|
|
44
58
|
max?: number;
|
|
45
59
|
/**
|
|
46
60
|
* @description
|
|
47
|
-
*
|
|
61
|
+
* size
|
|
62
|
+
* @default "circular"
|
|
48
63
|
*/
|
|
49
|
-
|
|
64
|
+
size?: Size;
|
|
50
65
|
/**
|
|
51
66
|
* @description
|
|
52
|
-
*
|
|
67
|
+
* shape
|
|
68
|
+
* @default "circular"
|
|
53
69
|
*/
|
|
54
|
-
|
|
70
|
+
shape?: Shape;
|
|
55
71
|
};
|
|
56
72
|
/**
|
|
57
73
|
* @description
|
|
@@ -62,7 +78,7 @@ export type TypedAvatar = {
|
|
|
62
78
|
* @description
|
|
63
79
|
* component self
|
|
64
80
|
*/
|
|
65
|
-
(props: AvatarProps):
|
|
81
|
+
(props: AvatarProps & RefAttributes<HTMLSpanElement>): ReactNode;
|
|
66
82
|
/**
|
|
67
83
|
* @description
|
|
68
84
|
* group
|
|
@@ -8,12 +8,14 @@ export type BreadcrumbItem = {
|
|
|
8
8
|
/**
|
|
9
9
|
* @description
|
|
10
10
|
* item display label
|
|
11
|
+
* @requires
|
|
11
12
|
*/
|
|
12
13
|
label: ReactNode;
|
|
13
14
|
/**
|
|
14
15
|
* @description
|
|
15
16
|
* item href link
|
|
16
17
|
* if link is not provided, item will display as a label
|
|
18
|
+
* @default void 0
|
|
17
19
|
*/
|
|
18
20
|
href?: string;
|
|
19
21
|
};
|
|
@@ -25,13 +27,15 @@ export type BreadcrumbProps = ComponentProps & {
|
|
|
25
27
|
/**
|
|
26
28
|
* @description
|
|
27
29
|
* breadcrumb items
|
|
30
|
+
* @default []
|
|
28
31
|
*/
|
|
29
|
-
items
|
|
32
|
+
items?: BreadcrumbItem[];
|
|
30
33
|
/**
|
|
31
34
|
* @description
|
|
32
35
|
* separator
|
|
36
|
+
* @default "/"
|
|
33
37
|
*/
|
|
34
|
-
separator?: ReactNode
|
|
38
|
+
separator?: Exclude<ReactNode, undefined | null>;
|
|
35
39
|
};
|
|
36
40
|
/**
|
|
37
41
|
* @description
|
|
@@ -41,11 +45,13 @@ export type BreadcrumbItemProps = BreadcrumbItem & {
|
|
|
41
45
|
/**
|
|
42
46
|
* @description
|
|
43
47
|
* max
|
|
48
|
+
* @requires
|
|
44
49
|
*/
|
|
45
50
|
max: boolean;
|
|
46
51
|
/**
|
|
47
52
|
* @description
|
|
48
53
|
* separator
|
|
54
|
+
* @requires
|
|
49
55
|
*/
|
|
50
|
-
separator
|
|
56
|
+
separator: Exclude<ReactNode, undefined | null>;
|
|
51
57
|
};
|
|
@@ -227,7 +227,9 @@ const Button = forwardRef(({
|
|
|
227
227
|
onPointerEnter,
|
|
228
228
|
onPointerLeave,
|
|
229
229
|
type = "button",
|
|
230
|
-
|
|
230
|
+
onClick: _onClick,
|
|
231
|
+
prefix,
|
|
232
|
+
suffix
|
|
231
233
|
}, ref) => {
|
|
232
234
|
const classNames = useClassNames(ComponentToken.Button);
|
|
233
235
|
const theme = useTheme();
|
|
@@ -236,7 +238,7 @@ const Button = forwardRef(({
|
|
|
236
238
|
clear,
|
|
237
239
|
ripples
|
|
238
240
|
} = useButton({
|
|
239
|
-
onClick:
|
|
241
|
+
onClick: _onClick
|
|
240
242
|
});
|
|
241
243
|
const styled = {
|
|
242
244
|
button: props(styles.button, typography.label[size],
|
|
@@ -274,7 +276,7 @@ const Button = forwardRef(({
|
|
|
274
276
|
onPointerEnter: onPointerEnter,
|
|
275
277
|
onPointerLeave: onPointerLeave,
|
|
276
278
|
type: type
|
|
277
|
-
},
|
|
279
|
+
}, prefix, children, suffix, ripple && React.createElement(Ripple, {
|
|
278
280
|
ripples: ripples,
|
|
279
281
|
onClear: clear
|
|
280
282
|
}));
|
|
@@ -14,54 +14,45 @@ export interface ButtonProps extends Partial<Pick<ButtonHTMLAttributes<HTMLButto
|
|
|
14
14
|
/**
|
|
15
15
|
* @description
|
|
16
16
|
* variant
|
|
17
|
-
*
|
|
18
17
|
* @default "filled"
|
|
19
18
|
*/
|
|
20
19
|
variant?: Variant;
|
|
21
20
|
/**
|
|
22
21
|
* @description
|
|
23
22
|
* color: only support preset colors
|
|
24
|
-
*
|
|
25
23
|
* @default "primary"
|
|
26
24
|
*/
|
|
27
25
|
color?: Color;
|
|
28
26
|
/**
|
|
29
27
|
* @description
|
|
30
28
|
* shape
|
|
31
|
-
*
|
|
32
29
|
* @default "rounded"
|
|
33
30
|
*/
|
|
34
31
|
shape?: Shape;
|
|
35
32
|
/**
|
|
36
33
|
* @description
|
|
37
|
-
*
|
|
34
|
+
* size
|
|
35
|
+
* @default "medium"
|
|
38
36
|
*/
|
|
39
|
-
|
|
37
|
+
size?: Size;
|
|
40
38
|
/**
|
|
41
39
|
* @description
|
|
42
40
|
* children
|
|
41
|
+
* @default void 0
|
|
43
42
|
*/
|
|
44
43
|
children?: ReactNode;
|
|
45
|
-
/**
|
|
46
|
-
* @description
|
|
47
|
-
* size
|
|
48
|
-
*
|
|
49
|
-
* @default "medium"
|
|
50
|
-
*/
|
|
51
|
-
size?: Size;
|
|
52
44
|
/**
|
|
53
45
|
* @description
|
|
54
46
|
* disabled
|
|
55
|
-
*
|
|
56
47
|
* @default false
|
|
57
48
|
*/
|
|
58
49
|
disabled?: boolean;
|
|
59
50
|
/**
|
|
60
51
|
* @description
|
|
61
52
|
* prefix react node
|
|
62
|
-
*
|
|
63
53
|
* @template
|
|
64
54
|
* icon or prefix signal
|
|
55
|
+
* @default void 0
|
|
65
56
|
*/
|
|
66
57
|
prefix?: ReactNode;
|
|
67
58
|
/**
|
|
@@ -69,14 +60,20 @@ export interface ButtonProps extends Partial<Pick<ButtonHTMLAttributes<HTMLButto
|
|
|
69
60
|
* suffix react node
|
|
70
61
|
* @template
|
|
71
62
|
* icon or suffix signal
|
|
63
|
+
* @default void 0
|
|
72
64
|
*/
|
|
73
65
|
suffix?: ReactNode;
|
|
74
66
|
/**
|
|
75
67
|
* @description
|
|
76
68
|
* if false, without a ripple
|
|
77
|
-
*
|
|
78
69
|
* @default true
|
|
79
70
|
*/
|
|
80
71
|
ripple?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* @description
|
|
74
|
+
* click handler
|
|
75
|
+
* @default void 0
|
|
76
|
+
*/
|
|
77
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
81
78
|
}
|
|
82
79
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { CalendarProps } from "./types";
|
|
3
|
-
declare const Calendar: ({ className, style,
|
|
3
|
+
declare const Calendar: ({ className, style, value, onClick: _onClick, focusedAt: _focusedAt }: CalendarProps) => React.JSX.Element;
|
|
4
4
|
export default Calendar;
|
|
@@ -32,24 +32,34 @@ const styles = {
|
|
|
32
32
|
const Calendar = ({
|
|
33
33
|
className,
|
|
34
34
|
style,
|
|
35
|
-
|
|
35
|
+
value,
|
|
36
|
+
onClick: _onClick,
|
|
37
|
+
focusedAt: _focusedAt
|
|
36
38
|
}) => {
|
|
37
39
|
const {
|
|
38
40
|
timespan,
|
|
39
41
|
onClick
|
|
40
|
-
} = useValue(
|
|
42
|
+
} = useValue({
|
|
43
|
+
onClick: _onClick,
|
|
44
|
+
value
|
|
45
|
+
});
|
|
41
46
|
const {
|
|
42
47
|
focusedAt,
|
|
43
48
|
toPrevYear,
|
|
44
49
|
toPrevMonth,
|
|
45
50
|
toNextYear,
|
|
46
51
|
toNextMonth
|
|
47
|
-
} = useFocusedAt(
|
|
52
|
+
} = useFocusedAt({
|
|
53
|
+
focusedAt: _focusedAt
|
|
54
|
+
});
|
|
48
55
|
const dateCells = useDateCells([timespan, focusedAt, onClick]);
|
|
49
56
|
const headCells = useHeadCells();
|
|
50
57
|
const classNames = useClassNames(ComponentToken.Calendar);
|
|
51
58
|
const theme = useTheme();
|
|
52
59
|
const styled = {
|
|
60
|
+
calendar: {
|
|
61
|
+
className: "musae-eq5yr9"
|
|
62
|
+
},
|
|
53
63
|
header: props(typography.label.large, styles.header({
|
|
54
64
|
color: theme.colors[ColorToken.OnSurfaceVariant]
|
|
55
65
|
})),
|
|
@@ -58,8 +68,11 @@ const Calendar = ({
|
|
|
58
68
|
}
|
|
59
69
|
};
|
|
60
70
|
return React.createElement("div", {
|
|
61
|
-
className: className,
|
|
62
|
-
style:
|
|
71
|
+
className: clsx(styled.calendar.className, className),
|
|
72
|
+
style: {
|
|
73
|
+
...styled.calendar.style,
|
|
74
|
+
...style
|
|
75
|
+
}
|
|
63
76
|
}, React.createElement("header", {
|
|
64
77
|
className: clsx(classNames[CalendarClassToken.Header], styled.header.className),
|
|
65
78
|
style: styled.header.style
|
|
@@ -16,7 +16,10 @@ export declare const useDateCells: ([timespan, focusedAt, click]: [Timespan, Day
|
|
|
16
16
|
* @description
|
|
17
17
|
* time span
|
|
18
18
|
*/
|
|
19
|
-
export declare const useValue: (
|
|
19
|
+
export declare const useValue: ({ onClick: _click, value, }: {
|
|
20
|
+
value: CalendarProps["value"];
|
|
21
|
+
onClick: CalendarProps["onClick"];
|
|
22
|
+
}) => {
|
|
20
23
|
timespan: Timespan;
|
|
21
24
|
onClick: (_value: Dayjs) => void;
|
|
22
25
|
};
|
|
@@ -24,7 +27,9 @@ export declare const useValue: ([value, _click]: [CalendarProps["value"], Calend
|
|
|
24
27
|
* @description
|
|
25
28
|
* point at
|
|
26
29
|
*/
|
|
27
|
-
export declare const useFocusedAt: (
|
|
30
|
+
export declare const useFocusedAt: ({ focusedAt: _focusedAt }: {
|
|
31
|
+
focusedAt: CalendarProps["focusedAt"];
|
|
32
|
+
}) => {
|
|
28
33
|
focusedAt: dayjs.Dayjs;
|
|
29
34
|
toNextYear: () => void;
|
|
30
35
|
toPrevYear: () => void;
|
|
@@ -2,7 +2,7 @@ import dayjs from 'dayjs';
|
|
|
2
2
|
import React, { useMemo, useCallback } from 'react';
|
|
3
3
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
4
4
|
import { ComponentToken, CalendarClassToken } from '../../utils/class-name.js';
|
|
5
|
-
import {
|
|
5
|
+
import { toArray, useControlledState } from '@aiszlab/relax';
|
|
6
6
|
import { Timespan } from '../../utils/timespan.js';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
@@ -147,14 +147,17 @@ const useDateCells = ([timespan, focusedAt, click]) => {
|
|
|
147
147
|
* @description
|
|
148
148
|
* time span
|
|
149
149
|
*/
|
|
150
|
-
const useValue = (
|
|
150
|
+
const useValue = ({
|
|
151
|
+
onClick: _click,
|
|
152
|
+
value
|
|
153
|
+
}) => {
|
|
151
154
|
/// change handler
|
|
152
155
|
const onClick = useCallback(_value => {
|
|
153
156
|
_click?.(_value);
|
|
154
157
|
}, [_click]);
|
|
155
158
|
/// time span
|
|
156
159
|
const timespan = useMemo(() => {
|
|
157
|
-
const [from, to] =
|
|
160
|
+
const [from, to] = toArray(value);
|
|
158
161
|
return new Timespan({
|
|
159
162
|
from,
|
|
160
163
|
to
|
|
@@ -169,25 +172,27 @@ const useValue = ([value, _click]) => {
|
|
|
169
172
|
* @description
|
|
170
173
|
* point at
|
|
171
174
|
*/
|
|
172
|
-
const useFocusedAt = (
|
|
173
|
-
|
|
175
|
+
const useFocusedAt = ({
|
|
176
|
+
focusedAt: _focusedAt
|
|
177
|
+
}) => {
|
|
178
|
+
const [focusedAt, setFocusedAt] = useControlledState(_focusedAt, {
|
|
174
179
|
defaultState: dayjs()
|
|
175
180
|
});
|
|
176
181
|
/// next year
|
|
177
182
|
const toNextYear = useCallback(() => {
|
|
178
|
-
setFocusedAt(
|
|
183
|
+
setFocusedAt(__focusedAt => __focusedAt.add(1, "year"));
|
|
179
184
|
}, [setFocusedAt]);
|
|
180
185
|
/// prev year
|
|
181
186
|
const toPrevYear = useCallback(() => {
|
|
182
|
-
setFocusedAt(
|
|
187
|
+
setFocusedAt(__focusedAt => __focusedAt.subtract(1, "year"));
|
|
183
188
|
}, [setFocusedAt]);
|
|
184
189
|
/// next month
|
|
185
190
|
const toNextMonth = useCallback(() => {
|
|
186
|
-
setFocusedAt(
|
|
191
|
+
setFocusedAt(__focusedAt => __focusedAt.add(1, "month"));
|
|
187
192
|
}, [setFocusedAt]);
|
|
188
193
|
/// prev month
|
|
189
194
|
const toPrevMonth = useCallback(() => {
|
|
190
|
-
setFocusedAt(
|
|
195
|
+
setFocusedAt(__focusedAt => __focusedAt.subtract(1, "month"));
|
|
191
196
|
}, [setFocusedAt]);
|
|
192
197
|
return {
|
|
193
198
|
focusedAt,
|
|
@@ -9,16 +9,19 @@ export type CalendarProps = ComponentProps & {
|
|
|
9
9
|
/**
|
|
10
10
|
* @description
|
|
11
11
|
* value
|
|
12
|
+
* @default void 0
|
|
12
13
|
*/
|
|
13
14
|
value?: Dayjs | [Partialable<Dayjs>, Partialable<Dayjs>];
|
|
14
15
|
/**
|
|
15
16
|
* @description
|
|
16
17
|
* focused at
|
|
18
|
+
* @default void 0
|
|
17
19
|
*/
|
|
18
20
|
focusedAt?: Dayjs;
|
|
19
21
|
/**
|
|
20
22
|
* @description
|
|
21
23
|
* click date handler
|
|
24
|
+
* @default void 0
|
|
22
25
|
*/
|
|
23
26
|
onClick?: (value: Dayjs) => void;
|
|
24
27
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { CascaderProps } from "./types";
|
|
3
|
-
declare const Cascader: ({ mode, separator, ...props }: CascaderProps) => React.JSX.Element;
|
|
3
|
+
declare const Cascader: ({ mode, separator, options, complex, ...props }: CascaderProps) => React.JSX.Element;
|
|
4
4
|
export default Cascader;
|
|
@@ -10,6 +10,8 @@ import clsx from 'clsx';
|
|
|
10
10
|
const Cascader = ({
|
|
11
11
|
mode,
|
|
12
12
|
separator = "/",
|
|
13
|
+
options = [],
|
|
14
|
+
complex = false,
|
|
13
15
|
...props
|
|
14
16
|
}) => {
|
|
15
17
|
const ref = useRef(null);
|
|
@@ -21,7 +23,7 @@ const Cascader = ({
|
|
|
21
23
|
additionalMenusItems,
|
|
22
24
|
presetedMenuItems,
|
|
23
25
|
setAdditionalMenusItems
|
|
24
|
-
} = useOptions([
|
|
26
|
+
} = useOptions([options]);
|
|
25
27
|
const {
|
|
26
28
|
values,
|
|
27
29
|
onChange
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Dispatch, type SetStateAction } from "react";
|
|
2
2
|
import { type MenuItem } from "../menu";
|
|
3
3
|
import type { CascaderProps, ReadableOptions, ReadablePaths } from "./types";
|
|
4
|
+
import type { Option } from "../../types/option";
|
|
4
5
|
/**
|
|
5
6
|
* @description
|
|
6
7
|
* cascader value
|
|
@@ -13,14 +14,14 @@ export declare const useValue: ([valueInProps, readableOptions, readablePaths, m
|
|
|
13
14
|
close: VoidFunction,
|
|
14
15
|
Dispatch<SetStateAction<MenuItem[][]>>
|
|
15
16
|
]) => {
|
|
16
|
-
values: Map<number, Required<Pick<
|
|
17
|
+
values: Map<number, Required<Pick<Option, "value" | "label">>[]>;
|
|
17
18
|
onChange: (id: number) => void;
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
21
|
* @description
|
|
21
22
|
* options
|
|
22
23
|
*/
|
|
23
|
-
export declare const useOptions: ([options]: [options:
|
|
24
|
+
export declare const useOptions: ([options]: [options: Option[]]) => {
|
|
24
25
|
presetedMenuItems: MenuItem[];
|
|
25
26
|
additionalMenusItems: MenuItem[][];
|
|
26
27
|
readableOptions: ReadableOptions;
|