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.
Files changed (150) hide show
  1. package/README.md +4 -2
  2. package/dist/components/avatar/avatar.js +1 -1
  3. package/dist/components/breadcrumb/breadcrumb.js +1 -1
  4. package/dist/components/breadcrumb/item.js +1 -1
  5. package/dist/components/button/button.js +14 -16
  6. package/dist/components/calendar/calendar.js +1 -1
  7. package/dist/components/calendar/hooks.js +5 -5
  8. package/dist/components/checkbox/checkbox.d.ts +1 -1
  9. package/dist/components/checkbox/checkbox.js +205 -143
  10. package/dist/components/checkbox/group.d.ts +1 -1
  11. package/dist/components/checkbox/group.js +20 -19
  12. package/dist/components/checkbox/index.d.ts +2 -2
  13. package/dist/components/checkbox/types.d.ts +31 -4
  14. package/dist/components/clock/column.js +1 -1
  15. package/dist/components/collapse/collapse.js +1 -1
  16. package/dist/components/collapse/item.js +15 -9
  17. package/dist/components/date-picker/date-picker.js +1 -1
  18. package/dist/components/dialog/dialog.js +1 -1
  19. package/dist/components/dialog/popup.js +5 -5
  20. package/dist/components/divider/divider.js +1 -1
  21. package/dist/components/drawer/drawer.js +1 -1
  22. package/dist/components/drawer/popup.js +17 -17
  23. package/dist/components/empty/empty.js +1 -1
  24. package/dist/components/floating-action-button/floatable.d.ts +4 -0
  25. package/dist/components/floating-action-button/floatable.js +83 -0
  26. package/dist/components/floating-action-button/floating-action-button.d.ts +4 -0
  27. package/dist/components/floating-action-button/floating-action-button.js +26 -0
  28. package/dist/components/floating-action-button/index.d.ts +2 -0
  29. package/dist/components/floating-action-button/types.d.ts +44 -0
  30. package/dist/components/form/field/error.d.ts +2 -2
  31. package/dist/components/form/field/error.js +36 -22
  32. package/dist/components/form/field/field.js +6 -21
  33. package/dist/components/form/field/layout.js +1 -1
  34. package/dist/components/grid/col.js +1 -1
  35. package/dist/components/grid/row.js +1 -1
  36. package/dist/components/icon/icon.d.ts +1 -1
  37. package/dist/components/icon/icon.js +5 -3
  38. package/dist/components/icon/types.d.ts +6 -1
  39. package/dist/components/image/image.js +3 -2
  40. package/dist/components/image/preview/operations.js +5 -5
  41. package/dist/components/image/preview/preview.js +1 -1
  42. package/dist/components/input/input.d.ts +6 -6
  43. package/dist/components/input/input.js +9 -15
  44. package/dist/components/layout/header.js +2 -2
  45. package/dist/components/layout/layout.js +1 -1
  46. package/dist/components/loading/loading.js +2 -2
  47. package/dist/components/menu/group.js +29 -9
  48. package/dist/components/menu/hooks.js +1 -1
  49. package/dist/components/menu/item.js +1 -1
  50. package/dist/components/menu/menu.js +3 -1
  51. package/dist/components/notification/holder.js +14 -15
  52. package/dist/components/notification/notification.js +3 -3
  53. package/dist/components/otp-input/otp-input.js +1 -1
  54. package/dist/components/pagination/hooks.d.ts +4 -2
  55. package/dist/components/pagination/hooks.js +9 -4
  56. package/dist/components/pagination/item.js +6 -8
  57. package/dist/components/pagination/pagination.d.ts +1 -1
  58. package/dist/components/pagination/pagination.js +37 -9
  59. package/dist/components/pagination/types.d.ts +6 -0
  60. package/dist/components/picker/picker.js +2 -2
  61. package/dist/components/popover/popover.js +1 -1
  62. package/dist/components/popper/dropdown.js +3 -3
  63. package/dist/components/popper/popper.js +1 -1
  64. package/dist/components/portal/portal.js +6 -2
  65. package/dist/components/portal/types.d.ts +6 -0
  66. package/dist/components/progress/circular.js +1 -1
  67. package/dist/components/progress/linear.js +1 -1
  68. package/dist/components/radio/radio.js +1 -1
  69. package/dist/components/rate/rate.js +1 -1
  70. package/dist/components/rate/star.js +3 -3
  71. package/dist/components/ripple/ripple.js +1 -1
  72. package/dist/components/select/hooks.d.ts +1 -1
  73. package/dist/components/select/select.d.ts +1 -1
  74. package/dist/components/select/select.js +5 -5
  75. package/dist/components/select/selector.d.ts +3 -6
  76. package/dist/components/select/selector.js +16 -10
  77. package/dist/components/select/types.d.ts +3 -1
  78. package/dist/components/space/space.js +1 -1
  79. package/dist/components/steps/item.d.ts +1 -1
  80. package/dist/components/steps/item.js +77 -16
  81. package/dist/components/steps/steps.d.ts +1 -1
  82. package/dist/components/steps/steps.js +6 -4
  83. package/dist/components/steps/types.d.ts +15 -0
  84. package/dist/components/switch/switch.d.ts +1 -1
  85. package/dist/components/switch/switch.js +22 -22
  86. package/dist/components/table/body.js +1 -1
  87. package/dist/components/table/header/cell.js +3 -3
  88. package/dist/components/table/header/header.js +2 -2
  89. package/dist/components/tabs/hooks.d.ts +40 -0
  90. package/dist/components/tabs/hooks.js +98 -0
  91. package/dist/components/tabs/navigation.d.ts +4 -0
  92. package/dist/components/tabs/navigation.js +159 -0
  93. package/dist/components/tabs/panels.d.ts +4 -0
  94. package/dist/components/tabs/panels.js +78 -0
  95. package/dist/components/tabs/tab.d.ts +4 -0
  96. package/dist/components/tabs/tab.js +19 -0
  97. package/dist/components/tabs/tabs.d.ts +1 -1
  98. package/dist/components/tabs/tabs.js +24 -94
  99. package/dist/components/tabs/types.d.ts +50 -9
  100. package/dist/components/tag/tag.js +1 -1
  101. package/dist/components/theme/hooks.js +3 -3
  102. package/dist/components/theme/tokens.stylex.d.ts +1 -0
  103. package/dist/components/time-picker/panel.js +1 -1
  104. package/dist/components/time-picker/time-picker.js +1 -1
  105. package/dist/components/timeline/item.d.ts +1 -1
  106. package/dist/components/timeline/item.js +107 -119
  107. package/dist/components/timeline/timeline.d.ts +1 -1
  108. package/dist/components/timeline/timeline.js +8 -4
  109. package/dist/components/timeline/types.d.ts +16 -0
  110. package/dist/components/tour/tour.js +4 -3
  111. package/dist/components/transfer/context.d.ts +6 -0
  112. package/dist/components/transfer/context.js +11 -0
  113. package/dist/components/transfer/hooks.d.ts +19 -0
  114. package/dist/components/transfer/hooks.js +49 -0
  115. package/dist/components/transfer/index.d.ts +2 -0
  116. package/dist/components/transfer/item.d.ts +4 -0
  117. package/dist/components/transfer/item.js +25 -0
  118. package/dist/components/transfer/list.d.ts +4 -0
  119. package/dist/components/transfer/list.js +122 -0
  120. package/dist/components/transfer/transfer.d.ts +4 -0
  121. package/dist/components/transfer/transfer.js +82 -0
  122. package/dist/components/transfer/types.d.ts +83 -0
  123. package/dist/components/tree/context.js +2 -0
  124. package/dist/components/tree/hooks.d.ts +13 -2
  125. package/dist/components/tree/hooks.js +19 -2
  126. package/dist/components/tree/list.js +16 -9
  127. package/dist/components/tree/node.d.ts +1 -1
  128. package/dist/components/tree/node.js +24 -14
  129. package/dist/components/tree/tree.d.ts +1 -1
  130. package/dist/components/tree/tree.js +13 -9
  131. package/dist/components/tree/types.d.ts +18 -23
  132. package/dist/components/waterfall/sequential.js +4 -1
  133. package/dist/components/waterfall/waterfall.js +6 -3
  134. package/dist/hooks/use-class-names.d.ts +27 -1
  135. package/dist/hooks/use-container.d.ts +11 -0
  136. package/dist/hooks/use-container.js +23 -0
  137. package/dist/hooks/use-expandable.d.ts +11 -0
  138. package/dist/hooks/use-expandable.js +37 -0
  139. package/dist/index.d.ts +2 -0
  140. package/dist/index.js +2 -0
  141. package/dist/stylex.css +61 -40
  142. package/dist/utils/class-name.d.ts +96 -16
  143. package/dist/utils/class-name.js +69 -13
  144. package/package.json +21 -11
  145. package/dist/components/tabs/item.d.ts +0 -4
  146. package/dist/components/tabs/item.js +0 -22
  147. package/dist/hooks/use-expand-effect.d.ts +0 -12
  148. package/dist/hooks/use-expand-effect.js +0 -34
  149. /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
  150. /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 i musae
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.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
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.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
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.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
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.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
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
- padding: "musae-aubp7",
32
- paddingInline: null,
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
- padding: "musae-wygk8u",
46
- paddingInline: null,
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
- padding: "musae-1f5cgw",
60
- paddingInline: null,
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.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
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.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
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-1kfboi8",
44
+ "::before_insetInlineStart": "musae-1682cnc",
45
45
  "::before_left": null,
46
46
  "::before_right": null,
47
- "::before_insetInlineEnd": "musae-1x8jx26",
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-1x8jx26",
54
+ "::before_insetInlineEnd": "musae-typ5od",
55
55
  $$css: true
56
56
  },
57
57
  to: {
58
- "::before_insetInlineStart": "musae-1kfboi8",
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, ...props }: CheckboxProps) => React.JSX.Element;
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, useCallback } from 'react';
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.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
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
- trigger: props => [{
14
- margin: "musae-ieb5ut",
15
- marginInline: null,
16
- marginInlineStart: null,
17
- marginLeft: null,
18
- marginInlineEnd: null,
19
- marginRight: null,
20
- marginBlock: null,
21
- marginTop: null,
22
- marginBottom: null,
23
- visibility: "musae-lshs6z",
24
- cursor: "musae-mper1u",
25
- width: "musae-r8isjd",
26
- height: "musae-1gfonl1",
27
- position: "musae-1n2onr6",
28
- "::before_content": "musae-1cpjm7i",
29
- "::before_visibility": "musae-11srvyv",
30
- "::before_display": "musae-1fgarty",
31
- "::before_boxSizing": "musae-tql2tq",
32
- "::before_width": "musae-1el3b87",
33
- "::before_height": "musae-1prtdg5",
34
- "::before_borderRadius": "musae-10eoie5",
35
- "::before_borderStartStartRadius": null,
36
- "::before_borderStartEndRadius": null,
37
- "::before_borderEndStartRadius": null,
38
- "::before_borderEndEndRadius": null,
39
- "::before_borderTopLeftRadius": null,
40
- "::before_borderTopRightRadius": null,
41
- "::before_borderBottomLeftRadius": null,
42
- "::before_borderBottomRightRadius": null,
43
- "::before_transition": "musae-t448kv",
44
- "::before_transitionBehavior": null,
45
- "::before_transitionDelay": null,
46
- "::before_transitionDuration": null,
47
- "::before_transitionProperty": null,
48
- "::before_transitionTimingFunction": null,
49
- "::before_borderWidth": "musae-1lou4sy",
50
- "::before_borderInlineWidth": null,
51
- "::before_borderInlineStartWidth": null,
52
- "::before_borderLeftWidth": null,
53
- "::before_borderInlineEndWidth": null,
54
- "::before_borderRightWidth": null,
55
- "::before_borderBlockWidth": null,
56
- "::before_borderTopWidth": null,
57
- "::before_borderBottomWidth": null,
58
- "::before_borderStyle": "musae-1fo1fc9",
59
- "::before_borderInlineStyle": null,
60
- "::before_borderInlineStartStyle": null,
61
- "::before_borderLeftStyle": null,
62
- "::before_borderInlineEndStyle": null,
63
- "::before_borderRightStyle": null,
64
- "::before_borderBlockStyle": null,
65
- "::before_borderTopStyle": null,
66
- "::before_borderBottomStyle": null,
67
- "::before_borderColor": "musae-123gkgz",
68
- "::before_borderInlineColor": null,
69
- "::before_borderInlineStartColor": null,
70
- "::before_borderLeftColor": null,
71
- "::before_borderInlineEndColor": null,
72
- "::before_borderRightColor": null,
73
- "::before_borderBlockColor": null,
74
- "::before_borderTopColor": null,
75
- "::before_borderBottomColor": null,
76
- $$css: true
77
- }, {
78
- "--1il6zln": props.borderColor != null ? props.borderColor : "initial"
79
- }],
80
- checked: props => [{
81
- "::before_backgroundColor": "musae-rr6jkh",
82
- "::before_borderColor": "musae-123gkgz",
83
- "::before_borderInlineColor": null,
84
- "::before_borderInlineStartColor": null,
85
- "::before_borderLeftColor": null,
86
- "::before_borderInlineEndColor": null,
87
- "::before_borderRightColor": null,
88
- "::before_borderBlockColor": null,
89
- "::before_borderTopColor": null,
90
- "::before_borderBottomColor": null,
91
- "::after_content": "musae-1s928wv",
92
- "::after_visibility": "musae-170pinb",
93
- "::after_boxSizing": "musae-x38sju",
94
- "::after_position": "musae-1j6awrg",
95
- "::after_display": "musae-hkezso",
96
- "::after_width": "musae-11yodxc",
97
- "::after_height": "musae-ec44on",
98
- "::after_transform": "musae-q1m6zb",
99
- "::after_borderWidth": "musae-15z8w9c",
100
- "::after_borderInlineWidth": null,
101
- "::after_borderInlineStartWidth": null,
102
- "::after_borderLeftWidth": "musae-1p9jk5k",
103
- "::after_borderInlineEndWidth": null,
104
- "::after_borderRightWidth": null,
105
- "::after_borderBlockWidth": null,
106
- "::after_borderTopWidth": "musae-1dn9wut",
107
- "::after_borderBottomWidth": null,
108
- "::after_borderStyle": "musae-86avzo",
109
- "::after_borderInlineStyle": null,
110
- "::after_borderInlineStartStyle": null,
111
- "::after_borderLeftStyle": null,
112
- "::after_borderInlineEndStyle": null,
113
- "::after_borderRightStyle": null,
114
- "::after_borderBlockStyle": null,
115
- "::after_borderTopStyle": null,
116
- "::after_borderBottomStyle": null,
117
- "::after_borderColor": "musae-3yd8hb",
118
- "::after_borderInlineColor": null,
119
- "::after_borderInlineStartColor": null,
120
- "::after_borderLeftColor": null,
121
- "::after_borderInlineEndColor": null,
122
- "::after_borderRightColor": null,
123
- "::after_borderBlockColor": null,
124
- "::after_borderTopColor": null,
125
- "::after_borderBottomColor": null,
126
- $$css: true
127
- }, {
128
- "--1lrm08k": props.backgroundColor != null ? props.backgroundColor : "initial",
129
- "--1il6zln": props.backgroundColor != null ? props.backgroundColor : "initial",
130
- "--joftei": props.triggerColor != null ? props.triggerColor : "initial"
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
- paddingInline: "musae-sslq2m",
134
- paddingStart: null,
135
- paddingLeft: null,
136
- paddingEnd: null,
137
- paddingRight: null,
138
- $$css: true
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
- ...props$1
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 [_isChecked, _setIsChecked] = useControlledState(props$1.checked, {
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(() => contextValue ? contextValue.value.has(value) : _isChecked, [_isChecked, contextValue, value]);
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 = useCallback(event => {
162
- contextValue?.change(value);
163
- _setIsChecked(event.target.checked);
164
- }, [_setIsChecked, contextValue, value]);
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
- className: "musae-3nfvp2 musae-6s0dn4 musae-1ypdohk"
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
- triggerColor: theme.colors[ColorToken.OnPrimary]
174
- })),
175
- label: props(typography.label.small, styles.label)
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: (props: CheckboxGroupProps) => React.JSX.Element;
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 = (props) => {
6
- const [_value, _setValue] = useControlledState(props.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
- /// change handler
11
- const change = useCallback((value) => {
12
- _setValue((prev) => {
13
- const next = new Set(prev);
14
- if (next.has(value)) {
15
- next.delete(value);
16
- }
17
- else {
18
- next.add(value);
19
- }
20
- return Array.from(next);
21
- });
22
- }, [_setValue]);
23
- /// context value
24
- const _contextValue = useMemo(() => {
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: _contextValue }, props.children);
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, ...props }: import("./types").CheckboxProps) => import("react").JSX.Element) & {
2
- Group: (props: import("./types").CheckboxGroupProps) => import("react").JSX.Element;
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
  };