musae 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/components/breadcrumb/item.js +1 -1
- package/dist/components/button/button.js +14 -16
- package/dist/components/calendar/calendar.js +1 -1
- package/dist/components/calendar/hooks.js +5 -5
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +205 -143
- package/dist/components/checkbox/group.d.ts +1 -1
- package/dist/components/checkbox/group.js +20 -19
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/checkbox/types.d.ts +31 -4
- package/dist/components/clock/column.js +1 -1
- package/dist/components/collapse/collapse.js +1 -1
- package/dist/components/collapse/item.js +15 -9
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/dialog/popup.js +5 -5
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/drawer.js +1 -1
- package/dist/components/drawer/popup.js +17 -17
- package/dist/components/empty/empty.js +1 -1
- package/dist/components/floating-action-button/floatable.d.ts +4 -0
- package/dist/components/floating-action-button/floatable.js +83 -0
- package/dist/components/floating-action-button/floating-action-button.d.ts +4 -0
- package/dist/components/floating-action-button/floating-action-button.js +26 -0
- package/dist/components/floating-action-button/index.d.ts +2 -0
- package/dist/components/floating-action-button/types.d.ts +44 -0
- package/dist/components/form/field/error.d.ts +2 -2
- package/dist/components/form/field/error.js +36 -22
- package/dist/components/form/field/field.js +6 -21
- package/dist/components/form/field/layout.js +1 -1
- package/dist/components/grid/col.js +1 -1
- package/dist/components/grid/row.js +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/icon.js +5 -3
- package/dist/components/icon/types.d.ts +6 -1
- package/dist/components/image/image.js +3 -2
- package/dist/components/image/preview/operations.js +5 -5
- package/dist/components/image/preview/preview.js +1 -1
- package/dist/components/input/input.d.ts +6 -6
- package/dist/components/input/input.js +9 -15
- package/dist/components/layout/header.js +2 -2
- package/dist/components/layout/layout.js +1 -1
- package/dist/components/loading/loading.js +2 -2
- package/dist/components/menu/group.js +29 -9
- package/dist/components/menu/hooks.js +1 -1
- package/dist/components/menu/item.js +1 -1
- package/dist/components/menu/menu.js +3 -1
- package/dist/components/notification/holder.js +14 -15
- package/dist/components/notification/notification.js +3 -3
- package/dist/components/otp-input/otp-input.js +1 -1
- package/dist/components/pagination/hooks.d.ts +4 -2
- package/dist/components/pagination/hooks.js +9 -4
- package/dist/components/pagination/item.js +6 -8
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/pagination/pagination.js +37 -9
- package/dist/components/pagination/types.d.ts +6 -0
- package/dist/components/picker/picker.js +2 -2
- package/dist/components/popover/popover.js +1 -1
- package/dist/components/popper/dropdown.js +3 -3
- package/dist/components/popper/popper.js +1 -1
- package/dist/components/portal/portal.js +6 -2
- package/dist/components/portal/types.d.ts +6 -0
- package/dist/components/progress/circular.js +1 -1
- package/dist/components/progress/linear.js +1 -1
- package/dist/components/radio/radio.js +1 -1
- package/dist/components/rate/rate.js +1 -1
- package/dist/components/rate/star.js +3 -3
- package/dist/components/ripple/ripple.js +1 -1
- package/dist/components/select/hooks.d.ts +1 -1
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.js +5 -5
- package/dist/components/select/selector.d.ts +3 -6
- package/dist/components/select/selector.js +16 -10
- package/dist/components/select/types.d.ts +3 -1
- package/dist/components/space/space.js +1 -1
- package/dist/components/steps/item.d.ts +1 -1
- package/dist/components/steps/item.js +77 -16
- package/dist/components/steps/steps.d.ts +1 -1
- package/dist/components/steps/steps.js +6 -4
- package/dist/components/steps/types.d.ts +15 -0
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.js +22 -22
- package/dist/components/table/body.js +1 -1
- package/dist/components/table/header/cell.js +3 -3
- package/dist/components/table/header/header.js +2 -2
- package/dist/components/tabs/hooks.d.ts +40 -0
- package/dist/components/tabs/hooks.js +98 -0
- package/dist/components/tabs/navigation.d.ts +4 -0
- package/dist/components/tabs/navigation.js +159 -0
- package/dist/components/tabs/panels.d.ts +4 -0
- package/dist/components/tabs/panels.js +78 -0
- package/dist/components/tabs/tab.d.ts +4 -0
- package/dist/components/tabs/tab.js +19 -0
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +24 -94
- package/dist/components/tabs/types.d.ts +50 -9
- package/dist/components/tag/tag.js +1 -1
- package/dist/components/theme/hooks.js +3 -3
- package/dist/components/theme/tokens.stylex.d.ts +1 -0
- package/dist/components/time-picker/panel.js +1 -1
- package/dist/components/time-picker/time-picker.js +1 -1
- package/dist/components/timeline/item.d.ts +1 -1
- package/dist/components/timeline/item.js +107 -119
- package/dist/components/timeline/timeline.d.ts +1 -1
- package/dist/components/timeline/timeline.js +8 -4
- package/dist/components/timeline/types.d.ts +16 -0
- package/dist/components/tour/tour.js +4 -3
- package/dist/components/transfer/context.d.ts +6 -0
- package/dist/components/transfer/context.js +11 -0
- package/dist/components/transfer/hooks.d.ts +19 -0
- package/dist/components/transfer/hooks.js +49 -0
- package/dist/components/transfer/index.d.ts +2 -0
- package/dist/components/transfer/item.d.ts +4 -0
- package/dist/components/transfer/item.js +25 -0
- package/dist/components/transfer/list.d.ts +4 -0
- package/dist/components/transfer/list.js +122 -0
- package/dist/components/transfer/transfer.d.ts +4 -0
- package/dist/components/transfer/transfer.js +82 -0
- package/dist/components/transfer/types.d.ts +83 -0
- package/dist/components/tree/context.js +2 -0
- package/dist/components/tree/hooks.d.ts +13 -2
- package/dist/components/tree/hooks.js +19 -2
- package/dist/components/tree/list.js +16 -9
- package/dist/components/tree/node.d.ts +1 -1
- package/dist/components/tree/node.js +24 -14
- package/dist/components/tree/tree.d.ts +1 -1
- package/dist/components/tree/tree.js +13 -9
- package/dist/components/tree/types.d.ts +18 -23
- package/dist/components/waterfall/sequential.js +4 -1
- package/dist/components/waterfall/waterfall.js +6 -3
- package/dist/hooks/use-class-names.d.ts +27 -1
- package/dist/hooks/use-container.d.ts +11 -0
- package/dist/hooks/use-container.js +23 -0
- package/dist/hooks/use-expandable.d.ts +11 -0
- package/dist/hooks/use-expandable.js +37 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/stylex.css +61 -40
- package/dist/utils/class-name.d.ts +96 -16
- package/dist/utils/class-name.js +69 -13
- package/package.json +21 -11
- package/dist/components/tabs/item.d.ts +0 -4
- package/dist/components/tabs/item.js +0 -22
- package/dist/hooks/use-expand-effect.d.ts +0 -12
- package/dist/hooks/use-expand-effect.js +0 -34
- /package/dist/node_modules/.pnpm/{@aiszlab_relax@1.2.55_react-dom@18.3.1_react@18.3.1 → @aiszlab_relax@1.2.59_react-dom@18.3.1_react@18.3.1__react@18.3.1}/node_modules/@aiszlab/relax/dist/dom/contains.js +0 -0
- /package/dist/node_modules/.pnpm/{@stylexjs_stylex@0.6.1 → @stylexjs_stylex@0.7.5}/node_modules/@stylexjs/stylex/lib/es/stylex.js +0 -0
package/README.md
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
- 📦 A set of high-quality React components out of the box.
|
|
7
7
|
- 🛡 Written in TypeScript with predictable static types.
|
|
8
8
|
- ⚙️ Whole package of design resources and development tools.
|
|
9
|
-
- 🌍 Internationalization support for dozens of languages.
|
|
10
9
|
- 🎨 Powerful theme customization based on CSS-in-JS.
|
|
11
10
|
|
|
12
11
|
## 📦 Install
|
|
13
12
|
|
|
14
13
|
```bash
|
|
15
14
|
npm install musae
|
|
16
|
-
## pnpm
|
|
15
|
+
## pnpm add musae
|
|
16
|
+
## yarn add musae
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## 🔨 Usage
|
|
@@ -23,4 +23,6 @@ import React from "react";
|
|
|
23
23
|
import { Button } from "musae";
|
|
24
24
|
|
|
25
25
|
const App = () => <Button>PRESS ME</Button>;
|
|
26
|
+
|
|
27
|
+
export default App;
|
|
26
28
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, useContext } from 'react';
|
|
2
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
2
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
3
|
import { Context } from './context.js';
|
|
4
4
|
import { useTheme } from '../theme/hooks.js';
|
|
5
5
|
import { ColorToken } from '../../utils/colors.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
2
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
3
|
import { typography } from '../theme/theme.js';
|
|
4
4
|
import { useTheme } from '../theme/hooks.js';
|
|
5
5
|
import { ColorToken } from '../../utils/colors.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
2
|
+
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
3
3
|
import { useTheme } from '../theme/hooks.js';
|
|
4
4
|
import { ColorToken } from '../../utils/colors.js';
|
|
5
5
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { ComponentToken, ButtonClassToken } from '../../utils/class-name.js';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
4
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
5
5
|
import { useTheme } from '../theme/hooks.js';
|
|
6
6
|
import { useButton } from './hooks.js';
|
|
7
7
|
import Ripple from '../ripple/ripple.js';
|
|
@@ -25,46 +25,44 @@ const styles = {
|
|
|
25
25
|
transitionProperty: "musae-fagghw",
|
|
26
26
|
transitionDuration: "musae-1d8287x",
|
|
27
27
|
willChange: "musae-19v51jg",
|
|
28
|
+
flexShrink: "musae-2lah0s",
|
|
28
29
|
$$css: true
|
|
29
30
|
},
|
|
30
31
|
small: {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
paddingBlock: "musae-hwhe2e",
|
|
33
|
+
paddingTop: null,
|
|
34
|
+
paddingBottom: null,
|
|
35
|
+
paddingInline: "musae-sslq2m",
|
|
33
36
|
paddingStart: null,
|
|
34
37
|
paddingLeft: null,
|
|
35
38
|
paddingEnd: null,
|
|
36
39
|
paddingRight: null,
|
|
37
|
-
paddingBlock: null,
|
|
38
|
-
paddingTop: null,
|
|
39
|
-
paddingBottom: null,
|
|
40
40
|
minHeight: "musae-1sal0kv",
|
|
41
41
|
minWidth: "musae-trrjuf",
|
|
42
42
|
$$css: true
|
|
43
43
|
},
|
|
44
44
|
medium: {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
paddingBlock: "musae-mcngwa",
|
|
46
|
+
paddingTop: null,
|
|
47
|
+
paddingBottom: null,
|
|
48
|
+
paddingInline: "musae-12vixxq",
|
|
47
49
|
paddingStart: null,
|
|
48
50
|
paddingLeft: null,
|
|
49
51
|
paddingEnd: null,
|
|
50
52
|
paddingRight: null,
|
|
51
|
-
paddingBlock: null,
|
|
52
|
-
paddingTop: null,
|
|
53
|
-
paddingBottom: null,
|
|
54
53
|
minHeight: "musae-1infgec",
|
|
55
54
|
minWidth: "musae-ba7gwn",
|
|
56
55
|
$$css: true
|
|
57
56
|
},
|
|
58
57
|
large: {
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
paddingBlock: "musae-avjae4",
|
|
59
|
+
paddingTop: null,
|
|
60
|
+
paddingBottom: null,
|
|
61
|
+
paddingInline: "musae-1mmg125",
|
|
61
62
|
paddingStart: null,
|
|
62
63
|
paddingLeft: null,
|
|
63
64
|
paddingEnd: null,
|
|
64
65
|
paddingRight: null,
|
|
65
|
-
paddingBlock: null,
|
|
66
|
-
paddingTop: null,
|
|
67
|
-
paddingBottom: null,
|
|
68
66
|
minHeight: "musae-1ee7i9g",
|
|
69
67
|
minWidth: "musae-1049mhy",
|
|
70
68
|
$$css: true
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { useValue, useFocusedAt, useDateCells, useHeadCells } from './hooks.js';
|
|
3
3
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
4
4
|
import { ComponentToken, CalendarClassToken } from '../../utils/class-name.js';
|
|
5
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
5
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
6
6
|
import { typography } from '../theme/theme.js';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import Button from '../button/button.js';
|
|
@@ -5,7 +5,7 @@ import { ComponentToken, CalendarClassToken } from '../../utils/class-name.js';
|
|
|
5
5
|
import { toArray, useControlledState } from '@aiszlab/relax';
|
|
6
6
|
import { Timespan } from '../../utils/timespan.js';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
8
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
9
9
|
import { typography } from '../theme/theme.js';
|
|
10
10
|
import { useTheme } from '../theme/hooks.js';
|
|
11
11
|
import { ColorToken } from '../../utils/colors.js';
|
|
@@ -41,21 +41,21 @@ const styles = {
|
|
|
41
41
|
$$css: true
|
|
42
42
|
},
|
|
43
43
|
range: {
|
|
44
|
-
"::before_insetInlineStart": "musae-
|
|
44
|
+
"::before_insetInlineStart": "musae-1682cnc",
|
|
45
45
|
"::before_left": null,
|
|
46
46
|
"::before_right": null,
|
|
47
|
-
"::before_insetInlineEnd": "musae-
|
|
47
|
+
"::before_insetInlineEnd": "musae-typ5od",
|
|
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-typ5od",
|
|
55
55
|
$$css: true
|
|
56
56
|
},
|
|
57
57
|
to: {
|
|
58
|
-
"::before_insetInlineStart": "musae-
|
|
58
|
+
"::before_insetInlineStart": "musae-1682cnc",
|
|
59
59
|
"::before_left": null,
|
|
60
60
|
"::before_right": null,
|
|
61
61
|
"::before_insetInlineEnd": "musae-1gkks1t",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { CheckboxProps } from "./types";
|
|
3
|
-
declare const Checkbox: ({ value, className, style, children,
|
|
3
|
+
declare const Checkbox: ({ value, className, style, children, onChange, disabled, checked }: CheckboxProps) => React.JSX.Element;
|
|
4
4
|
export default Checkbox;
|
|
@@ -1,141 +1,188 @@
|
|
|
1
|
-
import React, { useContext, useMemo
|
|
2
|
-
import { useControlledState } from '@aiszlab/relax';
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
|
+
import { useControlledState, useEvent } from '@aiszlab/relax';
|
|
3
3
|
import Context from './context.js';
|
|
4
4
|
import { useClassNames } from '../../hooks/use-class-names.js';
|
|
5
5
|
import { ComponentToken, CheckboxClassToken } from '../../utils/class-name.js';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.
|
|
7
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
|
|
8
8
|
import { useTheme } from '../theme/hooks.js';
|
|
9
9
|
import { ColorToken } from '../../utils/colors.js';
|
|
10
10
|
import { typography } from '../theme/theme.js';
|
|
11
11
|
|
|
12
12
|
const styles = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
13
|
+
checkbox: {
|
|
14
|
+
default: {
|
|
15
|
+
display: "musae-3nfvp2",
|
|
16
|
+
alignItems: "musae-6s0dn4",
|
|
17
|
+
cursor: "musae-1ypdohk",
|
|
18
|
+
$$css: true
|
|
19
|
+
},
|
|
20
|
+
disabled: {
|
|
21
|
+
opacity: "musae-v8jbu9",
|
|
22
|
+
cursor: "musae-1h6gzvc",
|
|
23
|
+
$$css: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
trigger: {
|
|
27
|
+
default: props => [{
|
|
28
|
+
margin: "musae-ieb5ut",
|
|
29
|
+
marginInline: null,
|
|
30
|
+
marginInlineStart: null,
|
|
31
|
+
marginLeft: null,
|
|
32
|
+
marginInlineEnd: null,
|
|
33
|
+
marginRight: null,
|
|
34
|
+
marginBlock: null,
|
|
35
|
+
marginTop: null,
|
|
36
|
+
marginBottom: null,
|
|
37
|
+
visibility: "musae-lshs6z",
|
|
38
|
+
cursor: "musae-mper1u",
|
|
39
|
+
width: "musae-r8isjd",
|
|
40
|
+
height: "musae-1gfonl1",
|
|
41
|
+
position: "musae-1n2onr6",
|
|
42
|
+
"::before_content": "musae-1cpjm7i",
|
|
43
|
+
"::before_visibility": "musae-11srvyv",
|
|
44
|
+
"::before_display": "musae-1fgarty",
|
|
45
|
+
"::before_boxSizing": "musae-tql2tq",
|
|
46
|
+
"::before_width": "musae-1el3b87",
|
|
47
|
+
"::before_height": "musae-1prtdg5",
|
|
48
|
+
"::before_borderRadius": "musae-10eoie5",
|
|
49
|
+
"::before_borderStartStartRadius": null,
|
|
50
|
+
"::before_borderStartEndRadius": null,
|
|
51
|
+
"::before_borderEndStartRadius": null,
|
|
52
|
+
"::before_borderEndEndRadius": null,
|
|
53
|
+
"::before_borderTopLeftRadius": null,
|
|
54
|
+
"::before_borderTopRightRadius": null,
|
|
55
|
+
"::before_borderBottomLeftRadius": null,
|
|
56
|
+
"::before_borderBottomRightRadius": null,
|
|
57
|
+
"::before_transition": "musae-t448kv",
|
|
58
|
+
"::before_transitionBehavior": null,
|
|
59
|
+
"::before_transitionDelay": null,
|
|
60
|
+
"::before_transitionDuration": null,
|
|
61
|
+
"::before_transitionProperty": null,
|
|
62
|
+
"::before_transitionTimingFunction": null,
|
|
63
|
+
"::before_borderWidth": "musae-1lou4sy",
|
|
64
|
+
"::before_borderInlineWidth": null,
|
|
65
|
+
"::before_borderInlineStartWidth": null,
|
|
66
|
+
"::before_borderLeftWidth": null,
|
|
67
|
+
"::before_borderInlineEndWidth": null,
|
|
68
|
+
"::before_borderRightWidth": null,
|
|
69
|
+
"::before_borderBlockWidth": null,
|
|
70
|
+
"::before_borderTopWidth": null,
|
|
71
|
+
"::before_borderBottomWidth": null,
|
|
72
|
+
"::before_borderStyle": "musae-1fo1fc9",
|
|
73
|
+
"::before_borderInlineStyle": null,
|
|
74
|
+
"::before_borderInlineStartStyle": null,
|
|
75
|
+
"::before_borderLeftStyle": null,
|
|
76
|
+
"::before_borderInlineEndStyle": null,
|
|
77
|
+
"::before_borderRightStyle": null,
|
|
78
|
+
"::before_borderBlockStyle": null,
|
|
79
|
+
"::before_borderTopStyle": null,
|
|
80
|
+
"::before_borderBottomStyle": null,
|
|
81
|
+
"::before_borderColor": "musae-123gkgz",
|
|
82
|
+
"::before_borderInlineColor": null,
|
|
83
|
+
"::before_borderInlineStartColor": null,
|
|
84
|
+
"::before_borderLeftColor": null,
|
|
85
|
+
"::before_borderInlineEndColor": null,
|
|
86
|
+
"::before_borderRightColor": null,
|
|
87
|
+
"::before_borderBlockColor": null,
|
|
88
|
+
"::before_borderTopColor": null,
|
|
89
|
+
"::before_borderBottomColor": null,
|
|
90
|
+
$$css: true
|
|
91
|
+
}, {
|
|
92
|
+
"--1il6zln": props.borderColor != null ? props.borderColor : "initial"
|
|
93
|
+
}],
|
|
94
|
+
checked: props => [{
|
|
95
|
+
"::before_backgroundColor": "musae-rr6jkh",
|
|
96
|
+
"::before_borderColor": "musae-123gkgz",
|
|
97
|
+
"::before_borderInlineColor": null,
|
|
98
|
+
"::before_borderInlineStartColor": null,
|
|
99
|
+
"::before_borderLeftColor": null,
|
|
100
|
+
"::before_borderInlineEndColor": null,
|
|
101
|
+
"::before_borderRightColor": null,
|
|
102
|
+
"::before_borderBlockColor": null,
|
|
103
|
+
"::before_borderTopColor": null,
|
|
104
|
+
"::before_borderBottomColor": null,
|
|
105
|
+
"::after_content": "musae-1s928wv",
|
|
106
|
+
"::after_visibility": "musae-170pinb",
|
|
107
|
+
"::after_boxSizing": "musae-x38sju",
|
|
108
|
+
"::after_position": "musae-1j6awrg",
|
|
109
|
+
"::after_display": "musae-hkezso",
|
|
110
|
+
"::after_width": "musae-11yodxc",
|
|
111
|
+
"::after_height": "musae-ec44on",
|
|
112
|
+
"::after_transform": "musae-q1m6zb",
|
|
113
|
+
"::after_borderWidth": "musae-15z8w9c",
|
|
114
|
+
"::after_borderInlineWidth": null,
|
|
115
|
+
"::after_borderInlineStartWidth": null,
|
|
116
|
+
"::after_borderLeftWidth": "musae-1p9jk5k",
|
|
117
|
+
"::after_borderInlineEndWidth": null,
|
|
118
|
+
"::after_borderRightWidth": null,
|
|
119
|
+
"::after_borderBlockWidth": null,
|
|
120
|
+
"::after_borderTopWidth": "musae-1dn9wut",
|
|
121
|
+
"::after_borderBottomWidth": null,
|
|
122
|
+
"::after_borderStyle": "musae-86avzo",
|
|
123
|
+
"::after_borderInlineStyle": null,
|
|
124
|
+
"::after_borderInlineStartStyle": null,
|
|
125
|
+
"::after_borderLeftStyle": null,
|
|
126
|
+
"::after_borderInlineEndStyle": null,
|
|
127
|
+
"::after_borderRightStyle": null,
|
|
128
|
+
"::after_borderBlockStyle": null,
|
|
129
|
+
"::after_borderTopStyle": null,
|
|
130
|
+
"::after_borderBottomStyle": null,
|
|
131
|
+
"::after_borderColor": "musae-3yd8hb",
|
|
132
|
+
"::after_borderInlineColor": null,
|
|
133
|
+
"::after_borderInlineStartColor": null,
|
|
134
|
+
"::after_borderLeftColor": null,
|
|
135
|
+
"::after_borderInlineEndColor": null,
|
|
136
|
+
"::after_borderRightColor": null,
|
|
137
|
+
"::after_borderBlockColor": null,
|
|
138
|
+
"::after_borderTopColor": null,
|
|
139
|
+
"::after_borderBottomColor": null,
|
|
140
|
+
$$css: true
|
|
141
|
+
}, {
|
|
142
|
+
"--1lrm08k": props.backgroundColor != null ? props.backgroundColor : "initial",
|
|
143
|
+
"--1il6zln": props.backgroundColor != null ? props.backgroundColor : "initial",
|
|
144
|
+
"--joftei": props.color != null ? props.color : "initial"
|
|
145
|
+
}],
|
|
146
|
+
disabled: props => [{
|
|
147
|
+
"::before_backgroundColor": "musae-rr6jkh",
|
|
148
|
+
"::before_borderColor": "musae-123gkgz",
|
|
149
|
+
"::before_borderInlineColor": null,
|
|
150
|
+
"::before_borderInlineStartColor": null,
|
|
151
|
+
"::before_borderLeftColor": null,
|
|
152
|
+
"::before_borderInlineEndColor": null,
|
|
153
|
+
"::before_borderRightColor": null,
|
|
154
|
+
"::before_borderBlockColor": null,
|
|
155
|
+
"::before_borderTopColor": null,
|
|
156
|
+
"::before_borderBottomColor": null,
|
|
157
|
+
"::after_borderColor": "musae-3yd8hb",
|
|
158
|
+
"::after_borderInlineColor": null,
|
|
159
|
+
"::after_borderInlineStartColor": null,
|
|
160
|
+
"::after_borderLeftColor": null,
|
|
161
|
+
"::after_borderInlineEndColor": null,
|
|
162
|
+
"::after_borderRightColor": null,
|
|
163
|
+
"::after_borderBlockColor": null,
|
|
164
|
+
"::after_borderTopColor": null,
|
|
165
|
+
"::after_borderBottomColor": null,
|
|
166
|
+
$$css: true
|
|
167
|
+
}, {
|
|
168
|
+
"--1lrm08k": props.backgroundColor != null ? props.backgroundColor : "initial",
|
|
169
|
+
"--1il6zln": props.backgroundColor != null ? props.backgroundColor : "initial",
|
|
170
|
+
"--joftei": props.color != null ? props.color : "initial"
|
|
171
|
+
}],
|
|
172
|
+
unchecked: {
|
|
173
|
+
"::before_backgroundColor": null,
|
|
174
|
+
$$css: true
|
|
175
|
+
}
|
|
176
|
+
},
|
|
132
177
|
label: {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
178
|
+
default: {
|
|
179
|
+
paddingInline: "musae-sslq2m",
|
|
180
|
+
paddingStart: null,
|
|
181
|
+
paddingLeft: null,
|
|
182
|
+
paddingEnd: null,
|
|
183
|
+
paddingRight: null,
|
|
184
|
+
$$css: true
|
|
185
|
+
}
|
|
139
186
|
}
|
|
140
187
|
};
|
|
141
188
|
const Checkbox = ({
|
|
@@ -143,36 +190,50 @@ const Checkbox = ({
|
|
|
143
190
|
className,
|
|
144
191
|
style,
|
|
145
192
|
children,
|
|
146
|
-
|
|
193
|
+
onChange,
|
|
194
|
+
disabled = false,
|
|
195
|
+
checked
|
|
147
196
|
}) => {
|
|
148
197
|
const contextValue = useContext(Context);
|
|
149
198
|
const classNames = useClassNames(ComponentToken.Checkbox);
|
|
150
199
|
const theme = useTheme();
|
|
151
|
-
const
|
|
200
|
+
const isDisabled = useMemo(() => {
|
|
201
|
+
return contextValue?.disabled ?? disabled;
|
|
202
|
+
}, [contextValue, disabled]);
|
|
203
|
+
const [_isChecked, _setIsChecked] = useControlledState(checked, {
|
|
152
204
|
defaultState: false
|
|
153
205
|
});
|
|
154
206
|
/// check current checkbox is checked
|
|
155
207
|
/// if there is context value, use context value
|
|
156
208
|
/// else use controlled state
|
|
157
|
-
const isChecked = useMemo(() =>
|
|
209
|
+
const isChecked = useMemo(() => {
|
|
210
|
+
if (!contextValue || !value) {
|
|
211
|
+
return _isChecked;
|
|
212
|
+
}
|
|
213
|
+
return contextValue.value.has(value);
|
|
214
|
+
}, [_isChecked, contextValue, value]);
|
|
158
215
|
/// change handler
|
|
159
216
|
/// if there is context value, just notify context
|
|
160
217
|
/// else change the controlled state
|
|
161
|
-
const change =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
218
|
+
const change = useEvent(event => {
|
|
219
|
+
if (isDisabled) return;
|
|
220
|
+
const checked = event.target.checked;
|
|
221
|
+
!!value && contextValue?.change(value, checked);
|
|
222
|
+
_setIsChecked(checked);
|
|
223
|
+
onChange?.(event);
|
|
224
|
+
});
|
|
165
225
|
const styled = {
|
|
166
|
-
checkbox:
|
|
167
|
-
|
|
168
|
-
},
|
|
169
|
-
trigger: props(styles.trigger({
|
|
226
|
+
checkbox: props(styles.checkbox.default, isDisabled && styles.checkbox.disabled),
|
|
227
|
+
trigger: props(styles.trigger.default({
|
|
170
228
|
borderColor: theme.colors[ColorToken.Outline]
|
|
171
|
-
}), isChecked && styles.checked({
|
|
229
|
+
}), isChecked && styles.trigger.checked({
|
|
172
230
|
backgroundColor: theme.colors[ColorToken.Primary],
|
|
173
|
-
|
|
174
|
-
})
|
|
175
|
-
|
|
231
|
+
color: theme.colors[ColorToken.OnPrimary]
|
|
232
|
+
}), isDisabled && styles.trigger.disabled({
|
|
233
|
+
backgroundColor: theme.colors[ColorToken.OnSurface],
|
|
234
|
+
color: theme.colors[ColorToken.OnPrimary]
|
|
235
|
+
}), !isChecked && styles.trigger.unchecked),
|
|
236
|
+
label: props(styles.label.default, typography.label.small)
|
|
176
237
|
};
|
|
177
238
|
return React.createElement("label", {
|
|
178
239
|
className: clsx(styled.checkbox.className, className, classNames[CheckboxClassToken.Checkbox]),
|
|
@@ -186,6 +247,7 @@ const Checkbox = ({
|
|
|
186
247
|
style: styled.trigger.style,
|
|
187
248
|
checked: isChecked,
|
|
188
249
|
"aria-checked": isChecked,
|
|
250
|
+
disabled: isDisabled,
|
|
189
251
|
onChange: change
|
|
190
252
|
}), children && React.createElement("span", {
|
|
191
253
|
className: styled.label.className,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { CheckboxGroupProps } from "./types";
|
|
3
|
-
declare const Group: (
|
|
3
|
+
declare const Group: ({ value: controlledValue, children, onChange, disabled }: CheckboxGroupProps) => React.JSX.Element;
|
|
4
4
|
export default Group;
|
|
@@ -2,32 +2,33 @@ import Context from './context.js';
|
|
|
2
2
|
import React, { useMemo, useCallback } from 'react';
|
|
3
3
|
import { useControlledState } from '@aiszlab/relax';
|
|
4
4
|
|
|
5
|
-
const Group = (
|
|
6
|
-
const [_value,
|
|
5
|
+
const Group = ({ value: controlledValue, children, onChange, disabled = false }) => {
|
|
6
|
+
const [_value, setValue] = useControlledState(controlledValue, {
|
|
7
7
|
defaultState: [],
|
|
8
8
|
});
|
|
9
9
|
const value = useMemo(() => new Set(_value), [_value]);
|
|
10
|
-
|
|
11
|
-
const change = useCallback((
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
const
|
|
10
|
+
// change handler
|
|
11
|
+
const change = useCallback((key, isChecked) => {
|
|
12
|
+
const checkedKeys = new Set(value);
|
|
13
|
+
if (isChecked) {
|
|
14
|
+
checkedKeys.add(key);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
checkedKeys.delete(key);
|
|
18
|
+
}
|
|
19
|
+
const _checkedKeys = Array.from(checkedKeys);
|
|
20
|
+
onChange?.(_checkedKeys);
|
|
21
|
+
setValue(_checkedKeys);
|
|
22
|
+
}, [setValue, value]);
|
|
23
|
+
// context value
|
|
24
|
+
const contextValue = useMemo(() => {
|
|
25
25
|
return {
|
|
26
26
|
value,
|
|
27
27
|
change,
|
|
28
|
+
disabled,
|
|
28
29
|
};
|
|
29
|
-
}, [value, change]);
|
|
30
|
-
return React.createElement(Context.Provider, { value:
|
|
30
|
+
}, [value, change, disabled]);
|
|
31
|
+
return React.createElement(Context.Provider, { value: contextValue }, children);
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
export { Group as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const Checkbox: (({ value, className, style, children,
|
|
2
|
-
Group: (
|
|
1
|
+
export declare const Checkbox: (({ value, className, style, children, onChange, disabled, checked }: import("./types").CheckboxProps) => import("react").JSX.Element) & {
|
|
2
|
+
Group: ({ value: controlledValue, children, onChange, disabled }: import("./types").CheckboxGroupProps) => import("react").JSX.Element;
|
|
3
3
|
};
|