musae 0.2.0 → 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 +34 -11
- package/dist/components/avatar/group.d.ts +1 -1
- package/dist/components/avatar/group.js +32 -3
- package/dist/components/avatar/types.d.ts +10 -2
- package/dist/components/button/button.js +5 -3
- package/dist/components/calendar/calendar.d.ts +1 -1
- package/dist/components/calendar/calendar.js +10 -3
- package/dist/components/calendar/hooks.d.ts +7 -2
- package/dist/components/calendar/hooks.js +9 -4
- package/dist/components/menu/item.js +4 -7
- package/dist/components/popover/popover.d.ts +1 -1
- package/dist/components/popover/popover.js +17 -10
- 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/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +24 -13
- package/dist/components/space/space.d.ts +1 -1
- package/dist/components/space/space.js +14 -5
- package/dist/components/space/types.d.ts +10 -2
- package/dist/stylex.css +5 -3
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -38,8 +39,16 @@ const styles = {
|
|
|
38
39
|
borderBottomColor: null,
|
|
39
40
|
boxSizing: "musae-9f619",
|
|
40
41
|
display: "musae-3nfvp2",
|
|
42
|
+
backgroundColor: "musae-q1mx2j",
|
|
43
|
+
color: "musae-19dipnz",
|
|
44
|
+
alignItems: "musae-6s0dn4",
|
|
45
|
+
justifyContent: "musae-l56j7k",
|
|
46
|
+
userSelect: "musae-87ps6o",
|
|
41
47
|
$$css: true
|
|
42
|
-
},
|
|
48
|
+
}, {
|
|
49
|
+
"--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial",
|
|
50
|
+
"--color": props.color != null ? props.color : "initial"
|
|
51
|
+
}],
|
|
43
52
|
image: {
|
|
44
53
|
width: "musae-wfgd1y",
|
|
45
54
|
height: "musae-b27hse",
|
|
@@ -112,12 +121,20 @@ const styles = {
|
|
|
112
121
|
$$css: true
|
|
113
122
|
}
|
|
114
123
|
};
|
|
115
|
-
|
|
124
|
+
/**
|
|
125
|
+
* @description
|
|
126
|
+
* `Avatar`
|
|
127
|
+
*
|
|
128
|
+
* component
|
|
129
|
+
*/
|
|
130
|
+
const Avatar = forwardRef(({
|
|
116
131
|
src,
|
|
117
132
|
alt,
|
|
118
133
|
shape: _shape = "circular",
|
|
119
|
-
size: _size = "medium"
|
|
120
|
-
|
|
134
|
+
size: _size = "medium",
|
|
135
|
+
fallback,
|
|
136
|
+
...props$1
|
|
137
|
+
}, ref) => {
|
|
121
138
|
const theme = useTheme();
|
|
122
139
|
const group = useContext(Context);
|
|
123
140
|
const isInGroup = !!group;
|
|
@@ -125,7 +142,10 @@ const Avatar = ({
|
|
|
125
142
|
const shape = group?.shape ?? _shape;
|
|
126
143
|
const classNames = useClassNames(ComponentToken.Avatar);
|
|
127
144
|
const styled = {
|
|
128
|
-
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({
|
|
129
149
|
outlineColor: theme.colors[ColorToken.OnPrimary]
|
|
130
150
|
})),
|
|
131
151
|
image: {
|
|
@@ -133,14 +153,17 @@ const Avatar = ({
|
|
|
133
153
|
}
|
|
134
154
|
};
|
|
135
155
|
return React.createElement("span", {
|
|
156
|
+
...props$1,
|
|
136
157
|
className: clsx(classNames[AvatarClassToken.Avatar], styled.avatar.className),
|
|
137
|
-
style: styled.avatar.style
|
|
138
|
-
|
|
158
|
+
style: styled.avatar.style,
|
|
159
|
+
ref: ref
|
|
160
|
+
}, !!src ? React.createElement("img", {
|
|
161
|
+
draggable: false,
|
|
139
162
|
src: src,
|
|
140
163
|
alt: alt,
|
|
141
164
|
className: styled.image.className,
|
|
142
165
|
style: styled.image.style
|
|
143
|
-
}));
|
|
144
|
-
};
|
|
166
|
+
}) : fallback);
|
|
167
|
+
});
|
|
145
168
|
|
|
146
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, max }: AvatarGroupProps) => React.JSX.Element;
|
|
3
|
+
declare const Group: ({ children: _children, shape, size, max }: AvatarGroupProps) => React.JSX.Element;
|
|
4
4
|
export default Group;
|
|
@@ -1,18 +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
11
|
size = "medium",
|
|
10
12
|
max = 3
|
|
11
13
|
}) => {
|
|
12
14
|
const styled = {
|
|
13
|
-
className: "musae-3nfvp2"
|
|
15
|
+
className: "musae-3nfvp2 musae-87ps6o"
|
|
14
16
|
};
|
|
15
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]);
|
|
16
45
|
return React.createElement(Context.Provider, {
|
|
17
46
|
value: {
|
|
18
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
|
/**
|
|
@@ -30,6 +30,14 @@ export type AvatarProps = {
|
|
|
30
30
|
* @default "circular"
|
|
31
31
|
*/
|
|
32
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;
|
|
33
41
|
};
|
|
34
42
|
/**
|
|
35
43
|
* @description
|
|
@@ -70,7 +78,7 @@ export type TypedAvatar = {
|
|
|
70
78
|
* @description
|
|
71
79
|
* component self
|
|
72
80
|
*/
|
|
73
|
-
(props: AvatarProps):
|
|
81
|
+
(props: AvatarProps & RefAttributes<HTMLSpanElement>): ReactNode;
|
|
74
82
|
/**
|
|
75
83
|
* @description
|
|
76
84
|
* group
|
|
@@ -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
|
}));
|
|
@@ -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,19 +32,26 @@ 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);
|
|
@@ -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,7 +172,9 @@ const useValue = ([value, _click]) => {
|
|
|
169
172
|
* @description
|
|
170
173
|
* point at
|
|
171
174
|
*/
|
|
172
|
-
const useFocusedAt = (
|
|
175
|
+
const useFocusedAt = ({
|
|
176
|
+
focusedAt: _focusedAt
|
|
177
|
+
}) => {
|
|
173
178
|
const [focusedAt, setFocusedAt] = useControlledState(_focusedAt, {
|
|
174
179
|
defaultState: dayjs()
|
|
175
180
|
});
|
|
@@ -17,13 +17,10 @@ const styles = {
|
|
|
17
17
|
display: "musae-78zum5",
|
|
18
18
|
alignItems: "musae-6s0dn4",
|
|
19
19
|
cursor: "musae-1ypdohk",
|
|
20
|
-
|
|
21
|
-
transitionBehavior: null,
|
|
22
|
-
transitionDelay: null,
|
|
23
|
-
transitionDuration: null,
|
|
24
|
-
transitionProperty: null,
|
|
25
|
-
transitionTimingFunction: null,
|
|
20
|
+
userSelect: "musae-87ps6o",
|
|
26
21
|
willChange: "musae-1aaibe2",
|
|
22
|
+
transitionProperty: "musae-xy01e9",
|
|
23
|
+
transitionDuration: "musae-1g2r6go",
|
|
27
24
|
$$css: true
|
|
28
25
|
}
|
|
29
26
|
},
|
|
@@ -265,8 +262,8 @@ const Item = forwardRef(({
|
|
|
265
262
|
...styled.menuItem
|
|
266
263
|
}, React.createElement("div", {
|
|
267
264
|
ref: itemRef,
|
|
268
|
-
style: styled.item.style,
|
|
269
265
|
className: clsx(classNames[MenuClassToken.Item], className, styled.item.className),
|
|
266
|
+
style: styled.item.style,
|
|
270
267
|
onClick: click,
|
|
271
268
|
...hoverProps
|
|
272
269
|
}, _children.prefix, _children.label, _children.suffix), isInline && props$1.children, !isInline && !!props$1.children && React.createElement(Popper, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ChildProps, PopoverProps } from "./types";
|
|
3
|
-
declare const Popover: <P extends ChildProps<T>, T extends HTMLElement>({ triggerBy: _triggerBy, title, description,
|
|
3
|
+
declare const Popover: <P extends ChildProps<T>, T extends HTMLElement>({ triggerBy: _triggerBy, title, description, placement, className, style, children: _children, }: PopoverProps<P, T>) => React.JSX.Element;
|
|
4
4
|
export default Popover;
|
|
@@ -23,7 +23,10 @@ const Popover = ({
|
|
|
23
23
|
triggerBy: _triggerBy = "hover",
|
|
24
24
|
title,
|
|
25
25
|
description,
|
|
26
|
-
|
|
26
|
+
placement = "bottom",
|
|
27
|
+
className,
|
|
28
|
+
style,
|
|
29
|
+
children: _children
|
|
27
30
|
}) => {
|
|
28
31
|
const _ref = useRef(null);
|
|
29
32
|
const [_isOpen, {
|
|
@@ -32,7 +35,7 @@ const Popover = ({
|
|
|
32
35
|
}] = useBoolean(false);
|
|
33
36
|
const triggerBy = useMemo(() => new Set(toArray(_triggerBy)), [_triggerBy]);
|
|
34
37
|
const classNames = useClassNames(ComponentToken.Popover);
|
|
35
|
-
const childRef = useRefs(_ref,
|
|
38
|
+
const childRef = useRefs(_ref, _children.props.ref);
|
|
36
39
|
const click = useEvent(e => {
|
|
37
40
|
toggle();
|
|
38
41
|
e.stopPropagation();
|
|
@@ -41,12 +44,12 @@ const Popover = ({
|
|
|
41
44
|
turnOn();
|
|
42
45
|
});
|
|
43
46
|
const [isHovered, hoverProps] = useHover({
|
|
44
|
-
onEnter: () => chain(
|
|
45
|
-
onLeave: () => chain(
|
|
47
|
+
onEnter: () => chain(_children.props.onMouseOver, _children.props.onMouseEnter, _children.props.onPointerEnter),
|
|
48
|
+
onLeave: () => chain(_children.props.onMouseLeave, _children.props.onPointerLeave)
|
|
46
49
|
});
|
|
47
50
|
const [isFocused, focusProps] = useFocus({
|
|
48
|
-
onFocus:
|
|
49
|
-
onBlur:
|
|
51
|
+
onFocus: _children.props.onFocus,
|
|
52
|
+
onBlur: _children.props.onBlur
|
|
50
53
|
});
|
|
51
54
|
const isOpen = useMemo(() => {
|
|
52
55
|
// allow hover
|
|
@@ -57,7 +60,7 @@ const Popover = ({
|
|
|
57
60
|
return _isOpen;
|
|
58
61
|
}, [triggerBy, isHovered, _isOpen, isFocused]);
|
|
59
62
|
// @ts-ignore
|
|
60
|
-
const children = cloneElement(
|
|
63
|
+
const children = cloneElement(_children, {
|
|
61
64
|
ref: childRef,
|
|
62
65
|
...hoverProps,
|
|
63
66
|
...focusProps,
|
|
@@ -81,10 +84,14 @@ const Popover = ({
|
|
|
81
84
|
...(triggerBy.has("hover") && {
|
|
82
85
|
onPointerEnter: enterPopper,
|
|
83
86
|
onPointerLeave: leavePopper
|
|
84
|
-
})
|
|
87
|
+
}),
|
|
88
|
+
placement: placement
|
|
85
89
|
}, React.createElement("div", {
|
|
86
|
-
className: clsx(classNames[PopoverClassToken.Popover], styled.popover.className),
|
|
87
|
-
style:
|
|
90
|
+
className: clsx(classNames[PopoverClassToken.Popover], className, styled.popover.className),
|
|
91
|
+
style: {
|
|
92
|
+
...styled.popover.style,
|
|
93
|
+
...style
|
|
94
|
+
}
|
|
88
95
|
}, !!title && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
89
96
|
className: clsx(classNames[PopoverClassToken.Title], styled.title.className),
|
|
90
97
|
style: styled.title.style
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DOMAttributes, ReactElement, ReactNode, RefAttributes } from "react";
|
|
2
2
|
import type { ComponentProps } from "../../types/element";
|
|
3
|
-
|
|
3
|
+
import type { Placement } from "@floating-ui/dom";
|
|
4
|
+
export type ChildProps<T> = Pick<DOMAttributes<T>, "onMouseEnter" | "onMouseOver" | "onMouseLeave" | "onPointerEnter" | "onPointerLeave" | "onClick" | "onContextMenu" | "onFocus" | "onBlur"> & RefAttributes<T>;
|
|
4
5
|
type TriggerBy = "hover" | "focus" | "click" | "contextMenu";
|
|
5
6
|
/**
|
|
6
7
|
* @description
|
|
@@ -10,22 +11,32 @@ export type PopoverProps<P extends ChildProps<T>, T extends HTMLElement> = Compo
|
|
|
10
11
|
/**
|
|
11
12
|
* @description
|
|
12
13
|
* a trigger element.
|
|
14
|
+
* @requires
|
|
13
15
|
*/
|
|
14
16
|
children: ReactElement<P>;
|
|
15
17
|
/**
|
|
16
18
|
* @description
|
|
17
19
|
* title
|
|
20
|
+
* @default void 0
|
|
18
21
|
*/
|
|
19
22
|
title?: ReactNode;
|
|
20
23
|
/**
|
|
21
24
|
* @description
|
|
22
25
|
* description
|
|
26
|
+
* @requires
|
|
23
27
|
*/
|
|
24
28
|
description: ReactNode;
|
|
25
29
|
/**
|
|
26
30
|
* @description
|
|
27
31
|
* trigger by
|
|
32
|
+
* @default "hover"
|
|
28
33
|
*/
|
|
29
34
|
triggerBy?: TriggerBy | TriggerBy[];
|
|
35
|
+
/**
|
|
36
|
+
* @description
|
|
37
|
+
* popover placement
|
|
38
|
+
* @default "bottom"
|
|
39
|
+
*/
|
|
40
|
+
placement?: Placement;
|
|
30
41
|
};
|
|
31
42
|
export {};
|
|
@@ -3,7 +3,7 @@ import { ComponentToken, PopperClassToken } from '../../utils/class-name.js';
|
|
|
3
3
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
4
4
|
import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { isFunction
|
|
6
|
+
import { isFunction } from '@aiszlab/relax';
|
|
7
7
|
import { autoUpdate, computePosition, flip, offset, arrow } from '@floating-ui/dom';
|
|
8
8
|
import { useOffsets } from './hooks.js';
|
|
9
9
|
import { useTheme } from '../theme/hooks.js';
|
|
@@ -47,7 +47,6 @@ const styles = {
|
|
|
47
47
|
width: "musae-103s5vv",
|
|
48
48
|
height: "musae-jazk0b",
|
|
49
49
|
backgroundColor: "musae-q1mx2j",
|
|
50
|
-
top: "musae-1vwp36r",
|
|
51
50
|
transform: "musae-1158fpu",
|
|
52
51
|
$$css: true
|
|
53
52
|
}, {
|
|
@@ -58,7 +57,7 @@ const styles = {
|
|
|
58
57
|
const Dropdown = ({
|
|
59
58
|
open,
|
|
60
59
|
children,
|
|
61
|
-
placement
|
|
60
|
+
placement,
|
|
62
61
|
style,
|
|
63
62
|
className,
|
|
64
63
|
onExit,
|
|
@@ -99,14 +98,19 @@ const Dropdown = ({
|
|
|
99
98
|
}).then(({
|
|
100
99
|
x,
|
|
101
100
|
y,
|
|
102
|
-
middlewareData
|
|
101
|
+
middlewareData,
|
|
102
|
+
placement: _placement
|
|
103
103
|
}) => {
|
|
104
|
+
const [side] = _placement.split("-");
|
|
104
105
|
// set float element styles
|
|
105
106
|
floatable.current.style.translate = `${x}px ${y}px`;
|
|
106
107
|
// set arrwo styles
|
|
107
108
|
if (middlewareData.arrow && !!arrowRef.current) {
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
const offsetY = `${middlewareData.arrow.y ?? 0 - 8}px`;
|
|
110
|
+
const offsetX = `${middlewareData.arrow.x ?? 0}px`;
|
|
111
|
+
arrowRef.current.style.insetInlineStart = offsetX;
|
|
112
|
+
side === "top" && (arrowRef.current.style.insetBlockEnd = offsetY);
|
|
113
|
+
side === "bottom" && (arrowRef.current.style.insetBlockStart = offsetY);
|
|
110
114
|
}
|
|
111
115
|
}).catch(() => null);
|
|
112
116
|
});
|
|
@@ -127,8 +131,6 @@ const Dropdown = ({
|
|
|
127
131
|
(async () => {
|
|
128
132
|
if (open) {
|
|
129
133
|
floatable.current.style.display = "";
|
|
130
|
-
floatable.current.style.opacity = "0";
|
|
131
|
-
floatable.current.style.opacity = "scale(0, 0)";
|
|
132
134
|
await animate(floatable.current, {
|
|
133
135
|
opacity: 1,
|
|
134
136
|
transform: "scale(1, 1)"
|
|
@@ -147,8 +149,6 @@ const Dropdown = ({
|
|
|
147
149
|
duration: 0.2
|
|
148
150
|
}).then(() => {
|
|
149
151
|
floatable.current.style.display = "none";
|
|
150
|
-
floatable.current.style.opacity = "";
|
|
151
|
-
floatable.current.style.transform = "";
|
|
152
152
|
})]);
|
|
153
153
|
onExited?.();
|
|
154
154
|
})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { PopperProps } from "./types";
|
|
3
|
-
declare const Popper: ({ destroyable, ...props }: PopperProps) => React.JSX.Element;
|
|
3
|
+
declare const Popper: ({ destroyable, placement, ...props }: PopperProps) => React.JSX.Element;
|
|
4
4
|
export default Popper;
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import Portal from '../portal/portal.js';
|
|
3
3
|
import Dropdown from './dropdown.js';
|
|
4
4
|
|
|
5
|
-
const Popper = ({ destroyable, ...props }) => {
|
|
5
|
+
const Popper = ({ destroyable, placement = "bottom-start", ...props }) => {
|
|
6
6
|
return (React.createElement(Portal, { open: props.open, lockable: false, destroyable: destroyable },
|
|
7
|
-
React.createElement(Dropdown, { ...props })));
|
|
7
|
+
React.createElement(Dropdown, { ...props, placement: placement })));
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export { Popper as default };
|
|
@@ -61,4 +61,9 @@ export interface PopperProps extends Pick<DOMAttributes<HTMLDivElement>, "onMous
|
|
|
61
61
|
*/
|
|
62
62
|
arrow?: boolean;
|
|
63
63
|
}
|
|
64
|
-
export type DropdownProps = Omit<PopperProps, "portal"
|
|
64
|
+
export type DropdownProps = Omit<PopperProps, "portal" | "placement"> & {
|
|
65
|
+
/**
|
|
66
|
+
* {@link} `PopperProps`.`placement`
|
|
67
|
+
*/
|
|
68
|
+
placement: Placement;
|
|
69
|
+
};
|
|
@@ -22,7 +22,7 @@ const styles = {
|
|
|
22
22
|
$$css: true
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
trigger: {
|
|
26
26
|
default: props => [{
|
|
27
27
|
visibility: "musae-lshs6z",
|
|
28
28
|
height: "musae-jazk0b",
|
|
@@ -73,12 +73,9 @@ const styles = {
|
|
|
73
73
|
"::after_borderTopRightRadius": null,
|
|
74
74
|
"::after_borderBottomLeftRadius": null,
|
|
75
75
|
"::after_borderBottomRightRadius": null,
|
|
76
|
-
"::
|
|
77
|
-
"::
|
|
78
|
-
"::
|
|
79
|
-
"::after_transitionDuration": null,
|
|
80
|
-
"::after_transitionProperty": null,
|
|
81
|
-
"::after_transitionTimingFunction": null,
|
|
76
|
+
"::after_willChange": "musae-yttlx6",
|
|
77
|
+
"::after_transitionProperty": "musae-6orayw",
|
|
78
|
+
"::after_transitionDuration": "musae-t0fc71",
|
|
82
79
|
$$css: true
|
|
83
80
|
}, {
|
|
84
81
|
"--joftei": props.borderColor != null ? props.borderColor : "initial"
|
|
@@ -107,6 +104,15 @@ const styles = {
|
|
|
107
104
|
"--joftei": props.borderColor != null ? props.borderColor : "initial"
|
|
108
105
|
}],
|
|
109
106
|
disabled: props => [{
|
|
107
|
+
borderColor: "musae-eqt46j",
|
|
108
|
+
borderInlineColor: null,
|
|
109
|
+
borderInlineStartColor: null,
|
|
110
|
+
borderLeftColor: null,
|
|
111
|
+
borderInlineEndColor: null,
|
|
112
|
+
borderRightColor: null,
|
|
113
|
+
borderBlockColor: null,
|
|
114
|
+
borderTopColor: null,
|
|
115
|
+
borderBottomColor: null,
|
|
110
116
|
"::before_content": "musae-1cpjm7i",
|
|
111
117
|
"::before_position": "musae-1hmns74",
|
|
112
118
|
"::before_visibility": "musae-11srvyv",
|
|
@@ -124,8 +130,13 @@ const styles = {
|
|
|
124
130
|
"::before_borderBottomRightRadius": null,
|
|
125
131
|
$$css: true
|
|
126
132
|
}, {
|
|
133
|
+
"--borderColor": props.backgroundColor != null ? props.backgroundColor : "initial",
|
|
127
134
|
"--1lrm08k": props.backgroundColor != null ? props.backgroundColor : "initial"
|
|
128
|
-
}]
|
|
135
|
+
}],
|
|
136
|
+
unckecked: {
|
|
137
|
+
"::before": null,
|
|
138
|
+
$$css: true
|
|
139
|
+
}
|
|
129
140
|
},
|
|
130
141
|
label: {
|
|
131
142
|
default: {
|
|
@@ -176,13 +187,13 @@ const Radio = ({
|
|
|
176
187
|
}, [isChecked, contextValue, value, isDisabled]);
|
|
177
188
|
const styled = {
|
|
178
189
|
radio: props(styles.radio.default, isDisabled && styles.radio.disabled),
|
|
179
|
-
trigger: props(styles.
|
|
190
|
+
trigger: props(styles.trigger.default({
|
|
180
191
|
borderColor: theme.colors[ColorToken.Outline]
|
|
181
|
-
}), isChecked &&
|
|
182
|
-
backgroundColor: theme.colors[ColorToken.InversePrimary]
|
|
183
|
-
}) : styles.toggler.default({
|
|
192
|
+
}), isChecked && styles.trigger.checked({
|
|
184
193
|
borderColor: theme.colors[ColorToken.Primary]
|
|
185
|
-
})
|
|
194
|
+
}), isDisabled && styles.trigger.disabled({
|
|
195
|
+
backgroundColor: theme.colors[ColorToken.InversePrimary]
|
|
196
|
+
}), !isChecked && styles.trigger.unckecked),
|
|
186
197
|
label: props(typography.body.medium, styles.label.default)
|
|
187
198
|
};
|
|
188
199
|
return React.createElement("label", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { SpaceProps } from "./types";
|
|
3
|
-
declare const Space: ({ gutter, children, className, style }: SpaceProps) => React.JSX.Element;
|
|
3
|
+
declare const Space: ({ gutter, children, className, style, type }: SpaceProps) => React.JSX.Element;
|
|
4
4
|
export default Space;
|
|
@@ -6,21 +6,30 @@ import clsx from 'clsx';
|
|
|
6
6
|
const styles = {
|
|
7
7
|
space: props => [{
|
|
8
8
|
display: "musae-78zum5",
|
|
9
|
-
flexDirection: "musae-1q0g3np",
|
|
10
9
|
columnGap: "musae-4rvf3u",
|
|
11
10
|
rowGap: "musae-m8a6f2",
|
|
12
|
-
alignItems: "musae-6s0dn4",
|
|
13
11
|
$$css: true
|
|
14
12
|
}, {
|
|
15
13
|
"--columnGap": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.columnGap),
|
|
16
14
|
"--rowGap": (val => typeof val === "number" ? val + "px" : val != null ? val : "initial")(props.rowGap)
|
|
17
|
-
}]
|
|
15
|
+
}],
|
|
16
|
+
horizontal: {
|
|
17
|
+
flexDirection: "musae-1q0g3np",
|
|
18
|
+
alignItems: "musae-6s0dn4",
|
|
19
|
+
$$css: true
|
|
20
|
+
},
|
|
21
|
+
vertical: {
|
|
22
|
+
flexDirection: "musae-dt5ytf",
|
|
23
|
+
justifyContent: "musae-l56j7k",
|
|
24
|
+
$$css: true
|
|
25
|
+
}
|
|
18
26
|
};
|
|
19
27
|
const Space = ({
|
|
20
28
|
gutter = 4,
|
|
21
29
|
children,
|
|
22
30
|
className,
|
|
23
|
-
style
|
|
31
|
+
style,
|
|
32
|
+
type = "horizontal"
|
|
24
33
|
}) => {
|
|
25
34
|
const [columnGap, rowGap] = useGutters({
|
|
26
35
|
gutter
|
|
@@ -28,7 +37,7 @@ const Space = ({
|
|
|
28
37
|
const styled = props(styles.space({
|
|
29
38
|
columnGap,
|
|
30
39
|
rowGap
|
|
31
|
-
}));
|
|
40
|
+
}), styles[type]);
|
|
32
41
|
return React.createElement("div", {
|
|
33
42
|
className: clsx(className, styled.className),
|
|
34
43
|
style: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import { Gutter } from "../../hooks/use-gutters";
|
|
3
|
-
import { ComponentProps } from "../../types/element";
|
|
2
|
+
import type { Gutter } from "../../hooks/use-gutters";
|
|
3
|
+
import type { ComponentProps } from "../../types/element";
|
|
4
|
+
type Type = "horizontal" | "vertical";
|
|
4
5
|
/**
|
|
5
6
|
* @description
|
|
6
7
|
* space props
|
|
@@ -18,4 +19,11 @@ export type SpaceProps = ComponentProps & {
|
|
|
18
19
|
* @default 4
|
|
19
20
|
*/
|
|
20
21
|
gutter?: Gutter;
|
|
22
|
+
/**
|
|
23
|
+
* @description
|
|
24
|
+
* direction
|
|
25
|
+
* @default "horizontal"
|
|
26
|
+
*/
|
|
27
|
+
type?: Type;
|
|
21
28
|
};
|
|
29
|
+
export {};
|
package/dist/stylex.css
CHANGED
|
@@ -83,7 +83,6 @@
|
|
|
83
83
|
.musae-1xkwav8:not(#\#):not(#\#){padding-inline:var(--musae-oohzsl)}
|
|
84
84
|
.musae-381k9q:not(#\#):not(#\#){padding-inline:var(--musae-qk2ac7)}
|
|
85
85
|
.musae-iujutg:not(#\#):not(#\#){padding-inline:var(--musae-vk5id6)}
|
|
86
|
-
.musae-2zkx75:not(#\#):not(#\#){transition:all .1s}
|
|
87
86
|
.musae-1ng1d19:not(#\#):not(#\#){transition:all .2s}
|
|
88
87
|
.musae-nz68lp:not(#\#):not(#\#){transition:box-shadow .2s}
|
|
89
88
|
.musae-1trvaba:not(#\#):not(#\#){transition:transform .2s}
|
|
@@ -221,9 +220,11 @@ html[dir='rtl'] .musae-1yc453h:not(#\#):not(#\#):not(#\#){text-align:right}
|
|
|
221
220
|
.musae-9tu13d:not(#\#):not(#\#):not(#\#){transform:rotate(-90deg)}
|
|
222
221
|
.musae-1158fpu:not(#\#):not(#\#):not(#\#){transform:rotate(45deg)}
|
|
223
222
|
.musae-1v0jg1i:not(#\#):not(#\#):not(#\#){transform:var(--transform,revert)}
|
|
223
|
+
.musae-1g2r6go:not(#\#):not(#\#):not(#\#){transition-duration:.1s}
|
|
224
224
|
.musae-13dflua:not(#\#):not(#\#):not(#\#){transition-duration:.2s}
|
|
225
225
|
.musae-1d8287x:not(#\#):not(#\#):not(#\#){transition-duration:.3s}
|
|
226
226
|
.musae-fagghw:not(#\#):not(#\#):not(#\#){transition-property:all}
|
|
227
|
+
.musae-xy01e9:not(#\#):not(#\#):not(#\#){transition-property:background-color,border,color}
|
|
227
228
|
.musae-1ve1rmq:not(#\#):not(#\#):not(#\#){transition-property:margin-inline-start,margin-inline-end}
|
|
228
229
|
.musae-1c9o64o:not(#\#):not(#\#):not(#\#){transition-property:margin-top,transform}
|
|
229
230
|
.musae-bjh9w0:not(#\#):not(#\#):not(#\#){transition-property:padding-inline-start,padding-inline-end}
|
|
@@ -327,7 +328,6 @@ html[dir='rtl'] .musae-1yc453h:not(#\#):not(#\#):not(#\#){text-align:right}
|
|
|
327
328
|
.musae-6al1c1:not(#\#):not(#\#):not(#\#):not(#\#){right:var(--musae-oohzsl)}
|
|
328
329
|
.musae-13vifvy:not(#\#):not(#\#):not(#\#):not(#\#){top:0}
|
|
329
330
|
.musae-wa60dl:not(#\#):not(#\#):not(#\#):not(#\#){top:50%}
|
|
330
|
-
.musae-1vwp36r:not(#\#):not(#\#):not(#\#):not(#\#){top:calc(var(--musae-1l9c3uf) * -1)}
|
|
331
331
|
.musae-kwake1:not(#\#):not(#\#):not(#\#):not(#\#){top:calc(var(--musae-xrqq76) + var(--musae-15cw4i4))}
|
|
332
332
|
.musae-1qtgrog:not(#\#):not(#\#):not(#\#):not(#\#){top:var(--musae-15cw4i4)}
|
|
333
333
|
.musae-9c655z:not(#\#):not(#\#):not(#\#):not(#\#){top:var(--musae-oohzsl)}
|
|
@@ -367,7 +367,6 @@ html[dir='rtl'] .musae-1yc453h:not(#\#):not(#\#):not(#\#){text-align:right}
|
|
|
367
367
|
.musae-1lou4sy:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::before{border-width:var(--musae-1ax7z96)}
|
|
368
368
|
.musae-15z8w9c:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{border-width:var(--musae-1h5s2h0)}
|
|
369
369
|
.musae-ilzmfn:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{border-width:var(--musae-1hydgie)}
|
|
370
|
-
.musae-w0vqy:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{transition:all .2s}
|
|
371
370
|
.musae-t448kv:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::before{transition:all .2s}
|
|
372
371
|
.musae-1uowca5:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::-webkit-scrollbar{background-color:transparent}
|
|
373
372
|
.musae-27d4w3:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{background-color:var(--15iyedw,revert)}
|
|
@@ -394,8 +393,11 @@ html[dir='rtl'] .musae-1yc453h:not(#\#):not(#\#):not(#\#){text-align:right}
|
|
|
394
393
|
.musae-1hmns74:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::before{position:absolute}
|
|
395
394
|
.musae-1j6awrg:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{position:absolute}
|
|
396
395
|
.musae-1db1611:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{transform:translate(100%,-150%) rotate(45deg)}
|
|
396
|
+
.musae-t0fc71:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{transition-duration:.2s}
|
|
397
|
+
.musae-6orayw:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{transition-property:border-color,border-width}
|
|
397
398
|
.musae-170pinb:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{visibility:visible}
|
|
398
399
|
.musae-11srvyv:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::before{visibility:visible}
|
|
400
|
+
.musae-yttlx6:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::after{will-change:border-color,border-width}
|
|
399
401
|
.musae-c28cl8:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::view-transition-new(root){z-index:var(--musae-1vh8wei)}
|
|
400
402
|
.musae-ktw8en:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::view-transition-old(root){z-index:var(--musae-1vh8wei)}
|
|
401
403
|
.musae-1ly6cpr:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#)::before{z-index:var(--musae-1vh8wei)}
|