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
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import Portal from '../portal/portal.js';
3
3
  import Popper from '../popper/popper.js';
4
- import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
4
+ import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
5
5
  import Button from '../button/button.js';
6
6
  import { useTheme } from '../theme/hooks.js';
7
7
  import { ColorToken } from '../../utils/colors.js';
@@ -17,7 +17,7 @@ import { useGutters } from '../../hooks/use-gutters.js';
17
17
  const styles = {
18
18
  overlay: props => [{
19
19
  position: "musae-10l6tqk",
20
- inset: "musae-ezip7x",
20
+ inset: "musae-10a8y8t",
21
21
  insetInline: null,
22
22
  insetInlineStart: null,
23
23
  insetInlineEnd: null,
@@ -107,7 +107,8 @@ const Tour = ({
107
107
  };
108
108
  return React.createElement(React.Fragment, null, React.createElement(Portal, {
109
109
  open: overlay && open,
110
- destroyable: true
110
+ destroyable: true,
111
+ lockable: true
111
112
  }, React.createElement("div", {
112
113
  className: clsx(classNames[TourClassToken.Overlay], styled.overlay.className),
113
114
  style: styled.overlay.style
@@ -0,0 +1,6 @@
1
+ import { ContextValue } from "./types";
2
+ /**
3
+ * @description
4
+ * transfer context
5
+ */
6
+ export declare const Context: import("react").Context<ContextValue>;
@@ -0,0 +1,11 @@
1
+ import { createContext } from 'react';
2
+
3
+ /**
4
+ * @description
5
+ * transfer context
6
+ */
7
+ const Context = createContext({
8
+ disabled: false,
9
+ });
10
+
11
+ export { Context };
@@ -0,0 +1,19 @@
1
+ import { type Key } from "react";
2
+ import type { TransferOption } from "./types";
3
+ /**
4
+ * @description
5
+ * options
6
+ */
7
+ export declare const useTransfer: (props: {
8
+ options: TransferOption[];
9
+ value?: Key[];
10
+ }) => {
11
+ transferred: Map<Key, TransferOption>;
12
+ untransferred: Map<Key, TransferOption>;
13
+ transfer: () => void;
14
+ untransfer: () => void;
15
+ transferKeys: Key[];
16
+ untransferKeys: Key[];
17
+ setTransferKeys: import("react").Dispatch<import("react").SetStateAction<Key[]>>;
18
+ setUntransferKeys: import("react").Dispatch<import("react").SetStateAction<Key[]>>;
19
+ };
@@ -0,0 +1,49 @@
1
+ import { useState, useMemo, useCallback } from 'react';
2
+ import { useControlledState } from '@aiszlab/relax';
3
+
4
+ /**
5
+ * @description
6
+ * options
7
+ */
8
+ const useTransfer = (props) => {
9
+ const [value, setValue] = useControlledState(props.value);
10
+ const [transferKeys, setTransferKeys] = useState([]);
11
+ const [untransferKeys, setUntransferKeys] = useState([]);
12
+ const options = useMemo(() => {
13
+ return props.options.reduce((prev, item) => prev.set(item.value, item), new Map());
14
+ }, [props.options]);
15
+ const [transferred, untransferred] = useMemo(() => {
16
+ return (value ?? []).reduce(([transferred, untransferred], key) => {
17
+ if (untransferred.has(key)) {
18
+ transferred.set(key, untransferred.get(key));
19
+ untransferred.delete(key);
20
+ }
21
+ return [transferred, untransferred];
22
+ }, [new Map(), new Map(options)]);
23
+ }, [options, value]);
24
+ const transfer = useCallback(() => {
25
+ setValue((prev = []) => [...prev, ...transferKeys]);
26
+ setTransferKeys([]);
27
+ }, [transferKeys]);
28
+ const untransfer = useCallback(() => {
29
+ setValue((prev = []) => {
30
+ return Array.from(untransferKeys.reduce((checkedKeys, unchecked) => {
31
+ checkedKeys.delete(unchecked);
32
+ return checkedKeys;
33
+ }, new Set(prev)));
34
+ });
35
+ setUntransferKeys([]);
36
+ }, [untransferKeys]);
37
+ return {
38
+ transferred,
39
+ untransferred,
40
+ transfer,
41
+ untransfer,
42
+ transferKeys,
43
+ untransferKeys,
44
+ setTransferKeys,
45
+ setUntransferKeys,
46
+ };
47
+ };
48
+
49
+ export { useTransfer };
@@ -0,0 +1,2 @@
1
+ import Transfer from "./transfer";
2
+ export { Transfer };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { TransferItemProps } from "./types";
3
+ declare const Item: ({ value, label }: TransferItemProps) => React.JSX.Element;
4
+ export default Item;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { Checkbox } from '../checkbox/index.js';
3
+ import { useClassNames } from '../../hooks/use-class-names.js';
4
+ import { ComponentToken, TransferClassToken } from '../../utils/class-name.js';
5
+ import clsx from 'clsx';
6
+
7
+ const Item = ({
8
+ value,
9
+ label
10
+ }) => {
11
+ const classNames = useClassNames(ComponentToken.Transfer);
12
+ const styled = {
13
+ item: {
14
+ className: "musae-78zum5 musae-6s0dn4 musae-gj1dgu musae-ovjknk musae-vbka3v"
15
+ }
16
+ };
17
+ return React.createElement("li", {
18
+ className: clsx(classNames[TransferClassToken.Item], styled.item.className),
19
+ style: styled.item.style
20
+ }, React.createElement(Checkbox, {
21
+ value: value
22
+ }), label);
23
+ };
24
+
25
+ export { Item as default };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { TransferListProps } from "./types";
3
+ declare const List: ({ options, title, onChange, value }: TransferListProps) => React.JSX.Element;
4
+ export default List;
@@ -0,0 +1,122 @@
1
+ import React, { useContext } from 'react';
2
+ import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
3
+ import { useTheme } from '../theme/hooks.js';
4
+ import { ColorToken } from '../../utils/colors.js';
5
+ import Item from './item.js';
6
+ import { Checkbox } from '../checkbox/index.js';
7
+ import { Context } from './context.js';
8
+ import { useClassNames } from '../../hooks/use-class-names.js';
9
+ import { ComponentToken, TransferClassToken } from '../../utils/class-name.js';
10
+ import clsx from 'clsx';
11
+ import { typography } from '../theme/theme.js';
12
+
13
+ const styles = {
14
+ list: props => [{
15
+ width: "musae-fx4e2q",
16
+ height: "musae-1ajdkb8",
17
+ borderWidth: "musae-1i8jmgv",
18
+ borderInlineWidth: null,
19
+ borderInlineStartWidth: null,
20
+ borderLeftWidth: null,
21
+ borderInlineEndWidth: null,
22
+ borderRightWidth: null,
23
+ borderBlockWidth: null,
24
+ borderTopWidth: null,
25
+ borderBottomWidth: null,
26
+ borderColor: "musae-eqt46j",
27
+ borderInlineColor: null,
28
+ borderInlineStartColor: null,
29
+ borderLeftColor: null,
30
+ borderInlineEndColor: null,
31
+ borderRightColor: null,
32
+ borderBlockColor: null,
33
+ borderTopColor: null,
34
+ borderBottomColor: null,
35
+ borderStyle: "musae-1y0btm7",
36
+ borderInlineStyle: null,
37
+ borderInlineStartStyle: null,
38
+ borderLeftStyle: null,
39
+ borderInlineEndStyle: null,
40
+ borderRightStyle: null,
41
+ borderBlockStyle: null,
42
+ borderTopStyle: null,
43
+ borderBottomStyle: null,
44
+ borderRadius: "musae-1h268bu",
45
+ borderStartStartRadius: null,
46
+ borderStartEndRadius: null,
47
+ borderEndStartRadius: null,
48
+ borderEndEndRadius: null,
49
+ borderTopLeftRadius: null,
50
+ borderTopRightRadius: null,
51
+ borderBottomLeftRadius: null,
52
+ borderBottomRightRadius: null,
53
+ $$css: true
54
+ }, {
55
+ "--borderColor": props.outlineColor != null ? props.outlineColor : "initial"
56
+ }],
57
+ header: props => [{
58
+ display: "musae-78zum5",
59
+ alignItems: "musae-6s0dn4",
60
+ paddingBlock: "musae-mcngwa",
61
+ paddingTop: null,
62
+ paddingBottom: null,
63
+ paddingInline: "musae-gj1dgu",
64
+ paddingStart: null,
65
+ paddingLeft: null,
66
+ paddingEnd: null,
67
+ paddingRight: null,
68
+ borderBottomWidth: "musae-lntmim",
69
+ borderBottomColor: "musae-43481e",
70
+ borderBottomStyle: "musae-1q0q8m5",
71
+ $$css: true
72
+ }, {
73
+ "--borderBottomColor": props.outlineColor != null ? props.outlineColor : "initial"
74
+ }]
75
+ };
76
+ const List = ({
77
+ options,
78
+ title,
79
+ onChange,
80
+ value
81
+ }) => {
82
+ const theme = useTheme();
83
+ const {
84
+ disabled
85
+ } = useContext(Context);
86
+ const classNames = useClassNames(ComponentToken.Transfer);
87
+ const styled = {
88
+ list: _stylex.props(styles.list({
89
+ outlineColor: theme.colors[ColorToken.Outline]
90
+ })),
91
+ header: _stylex.props(styles.header({
92
+ outlineColor: theme.colors[ColorToken.Outline]
93
+ }), typography.body.medium),
94
+ title: {
95
+ className: "musae-b3r6kr musae-p4054r musae-1isitws"
96
+ }
97
+ };
98
+ return React.createElement("div", {
99
+ className: clsx(classNames[TransferClassToken.List], styled.list.className),
100
+ style: styled.list.style
101
+ }, React.createElement("div", {
102
+ className: clsx(classNames[TransferClassToken.Header], styled.header.className),
103
+ style: styled.header.style
104
+ }, React.createElement("span", null, options.length, "\u9879"), React.createElement("span", {
105
+ className: clsx(classNames[TransferClassToken.Title], styled.title.className),
106
+ style: styled.title.style
107
+ }, title)), React.createElement(Checkbox.Group, {
108
+ value: value,
109
+ onChange: onChange,
110
+ disabled: disabled
111
+ }, React.createElement("ul", {
112
+ className: classNames[TransferClassToken.Body]
113
+ }, options.map(option => {
114
+ return React.createElement(Item, {
115
+ key: option.value,
116
+ label: option.label,
117
+ value: option.value
118
+ });
119
+ }))));
120
+ };
121
+
122
+ export { List as default };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { TransferProps } from "./types";
3
+ declare const Transfer: ({ options, value, titles, disabled, className, style }: TransferProps) => React.JSX.Element;
4
+ export default Transfer;
@@ -0,0 +1,82 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useTransfer } from './hooks.js';
3
+ import List from './list.js';
4
+ import Button from '../button/button.js';
5
+ import { Context } from './context.js';
6
+ import { useClassNames } from '../../hooks/use-class-names.js';
7
+ import { ComponentToken, TransferClassToken } from '../../utils/class-name.js';
8
+ import clsx from 'clsx';
9
+ import KeyboardArrowRight from '../icon/icons/hardware/keyboard-arrow-right.js';
10
+ import KeyboardArrowLeft from '../icon/icons/hardware/keyboard-arrow-left.js';
11
+
12
+ const Transfer = ({
13
+ options,
14
+ value,
15
+ titles = [null, null],
16
+ disabled = false,
17
+ className,
18
+ style
19
+ }) => {
20
+ const {
21
+ transferred,
22
+ untransferred,
23
+ transfer,
24
+ untransfer,
25
+ transferKeys,
26
+ untransferKeys,
27
+ setTransferKeys,
28
+ setUntransferKeys
29
+ } = useTransfer({
30
+ options,
31
+ value
32
+ });
33
+ const classNames = useClassNames(ComponentToken.Transfer);
34
+ const styled = {
35
+ transfer: {
36
+ className: "musae-78zum5 musae-1q0g3np musae-6s0dn4 musae-vbka3v"
37
+ },
38
+ operation: {
39
+ className: "musae-78zum5 musae-dt5ytf musae-vbka3v"
40
+ }
41
+ };
42
+ const contextValue = useMemo(() => {
43
+ return {
44
+ disabled
45
+ };
46
+ }, [disabled]);
47
+ return React.createElement(Context.Provider, {
48
+ value: contextValue
49
+ }, React.createElement("div", {
50
+ className: clsx(classNames[TransferClassToken.Transfer], className, styled.transfer.className),
51
+ style: {
52
+ ...styled.transfer.style,
53
+ ...style
54
+ }
55
+ }, React.createElement(List, {
56
+ options: Array.from(untransferred.values()),
57
+ title: titles[0],
58
+ value: transferKeys,
59
+ onChange: setTransferKeys
60
+ }), React.createElement("div", {
61
+ className: clsx(classNames[TransferClassToken.Operation], styled.operation.className),
62
+ style: styled.operation.style
63
+ }, React.createElement(Button, {
64
+ shape: "circular",
65
+ size: "small",
66
+ onClick: transfer,
67
+ disabled: disabled || transferKeys.length === 0
68
+ }, React.createElement(KeyboardArrowRight, null)), React.createElement(Button, {
69
+ shape: "circular",
70
+ size: "small",
71
+ onClick: untransfer,
72
+ disabled: disabled || untransferKeys.length === 0
73
+ }, React.createElement(KeyboardArrowLeft, null))), React.createElement(List, {
74
+ options: Array.from(transferred.values()),
75
+ title: titles[1],
76
+ value: untransferKeys,
77
+ onChange: setUntransferKeys
78
+ })));
79
+ };
80
+ var Transfer$1 = Transfer;
81
+
82
+ export { Transfer$1 as default };
@@ -0,0 +1,83 @@
1
+ import type { Key, ReactNode } from "react";
2
+ import type { Option } from "../../types/option";
3
+ import { ComponentProps } from "../../types/element";
4
+ export type TransferOption = Omit<Option, "children">;
5
+ /**
6
+ * @description
7
+ * transfer props
8
+ */
9
+ export type TransferProps = ComponentProps & {
10
+ /**
11
+ * @description
12
+ * options
13
+ */
14
+ options: TransferOption[];
15
+ /**
16
+ * @description
17
+ * value
18
+ */
19
+ value?: Key[];
20
+ /**
21
+ * @description
22
+ * titles
23
+ */
24
+ titles?: [ReactNode, ReactNode];
25
+ /**
26
+ * @description
27
+ * disabled
28
+ */
29
+ disabled?: boolean;
30
+ };
31
+ /**
32
+ * @description
33
+ * transfer list props
34
+ */
35
+ export type TransferListProps = {
36
+ /**
37
+ * @description
38
+ * value
39
+ */
40
+ value: Key[];
41
+ /**
42
+ * @description
43
+ * options
44
+ */
45
+ options: TransferOption[];
46
+ /**
47
+ * @description
48
+ * title
49
+ */
50
+ title?: ReactNode;
51
+ /**
52
+ * @description
53
+ * change handler
54
+ */
55
+ onChange: (keys: Key[]) => void;
56
+ };
57
+ /**
58
+ * @description
59
+ * transfer item props
60
+ */
61
+ export type TransferItemProps = {
62
+ /**
63
+ * @description
64
+ * value
65
+ */
66
+ value: Key;
67
+ /**
68
+ * @description
69
+ * label
70
+ */
71
+ label: ReactNode;
72
+ };
73
+ /**
74
+ * @description
75
+ * context value
76
+ */
77
+ export type ContextValue = {
78
+ /**
79
+ * @description
80
+ * disabled
81
+ */
82
+ disabled: boolean;
83
+ };
@@ -3,6 +3,8 @@ import { createContext } from 'react';
3
3
  const Context = createContext({
4
4
  checkedKeys: new Set(),
5
5
  expandedKeys: new Set(),
6
+ selectedKeys: new Set(),
7
+ selectable: true,
6
8
  });
7
9
 
8
10
  export { Context as default };
@@ -1,9 +1,20 @@
1
+ import { Key } from "react";
1
2
  import type { TreeProps } from "./types";
2
3
  /**
3
4
  * @description
4
5
  * expanded keys
5
6
  */
6
7
  export declare const useExpandedKeys: ([expandedKeys, onExpand]: [TreeProps["expandedKeys"], TreeProps["onExpand"]]) => {
7
- expandedKeys: Set<import("react").Key>;
8
- toggle: (key: import("react").Key) => void;
8
+ expandedKeys: Set<Key>;
9
+ toggle: (key: Key) => void;
10
+ };
11
+ /**
12
+ * @description
13
+ * selected keys
14
+ */
15
+ export declare const useSelectedKeys: ({ selectedKeys: _selectedKeys }: {
16
+ selectedKeys?: Key[];
17
+ }) => {
18
+ selectedKeys: Set<Key>;
19
+ toggle: (key: Key) => void;
9
20
  };
@@ -1,4 +1,4 @@
1
- import { useControlledState } from '@aiszlab/relax';
1
+ import { useControlledState, useEvent } from '@aiszlab/relax';
2
2
  import { useMemo, useCallback } from 'react';
3
3
 
4
4
  /**
@@ -23,5 +23,22 @@ const useExpandedKeys = ([expandedKeys, onExpand]) => {
23
23
  toggle,
24
24
  };
25
25
  };
26
+ /**
27
+ * @description
28
+ * selected keys
29
+ */
30
+ const useSelectedKeys = ({ selectedKeys: _selectedKeys }) => {
31
+ const [selectedKeys, setSelectedKeys] = useControlledState(_selectedKeys);
32
+ const __selectedKeys = useMemo(() => new Set(selectedKeys), [selectedKeys]);
33
+ const toggle = useEvent((key) => {
34
+ setSelectedKeys(() => {
35
+ return Array.from([key]);
36
+ });
37
+ });
38
+ return {
39
+ selectedKeys: __selectedKeys,
40
+ toggle,
41
+ };
42
+ };
26
43
 
27
- export { useExpandedKeys };
44
+ export { useExpandedKeys, useSelectedKeys };
@@ -1,4 +1,4 @@
1
- import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
1
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
2
2
  import React, { useContext } from 'react';
3
3
  import Node from './node.js';
4
4
  import clsx from 'clsx';
@@ -6,7 +6,8 @@ import { useAnimate } from 'framer-motion';
6
6
  import Context from './context.js';
7
7
  import { useClassNames } from '../../hooks/use-class-names.js';
8
8
  import { ComponentToken, TreeClassToken } from '../../utils/class-name.js';
9
- import { useExpandEffect } from '../../hooks/use-expand-effect.js';
9
+ import { useExpandable } from '../../hooks/use-expandable.js';
10
+ import { useUpdateEffect } from '@aiszlab/relax';
10
11
 
11
12
  const styles = {
12
13
  list: {
@@ -30,14 +31,20 @@ const List = ({
30
31
  const [scope, animate] = useAnimate();
31
32
  const {
32
33
  expandedKeys,
33
- toggle
34
+ onExpand
34
35
  } = useContext(Context);
35
36
  const classNames = useClassNames(ComponentToken.Tree);
36
- useExpandEffect({
37
- animate,
38
- target: scope,
39
- expanded
40
- });
37
+ const {
38
+ expand,
39
+ collapse
40
+ } = useExpandable();
41
+ useUpdateEffect(async () => {
42
+ if (expanded) {
43
+ await expand([scope, animate]);
44
+ return;
45
+ }
46
+ await collapse([scope, animate]);
47
+ }, [expanded]);
41
48
  const styled = props(styles.list, !expanded && styles.hidden);
42
49
  return React.createElement("ul", {
43
50
  className: clsx({
@@ -57,7 +64,7 @@ const List = ({
57
64
  return React.createElement(Node, {
58
65
  key: node.key,
59
66
  value: node.key,
60
- onToggle: toggle,
67
+ onExpand: onExpand,
61
68
  title: node.title,
62
69
  level: level
63
70
  }, children.length > 0 && React.createElement(List, {
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { TreeNodeProps } from "./types";
3
- declare const Node: ({ value, children, level, onToggle, ...props }: TreeNodeProps) => React.JSX.Element;
3
+ declare const Node: ({ value, children, level, onExpand, ...props }: TreeNodeProps) => React.JSX.Element;
4
4
  export default Node;
@@ -3,10 +3,11 @@ import { useClassNames } from '../../hooks/use-class-names.js';
3
3
  import { ComponentToken, TreeClassToken } from '../../utils/class-name.js';
4
4
  import Context from './context.js';
5
5
  import { Checkbox } from '../checkbox/index.js';
6
- import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
6
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
7
7
  import clsx from 'clsx';
8
8
  import { useTheme } from '../theme/hooks.js';
9
9
  import { ColorToken } from '../../utils/colors.js';
10
+ import { useEvent } from '@aiszlab/relax';
10
11
  import KeyboardArrowRight from '../icon/icons/hardware/keyboard-arrow-right.js';
11
12
 
12
13
  const styles = {
@@ -72,27 +73,28 @@ const Node = ({
72
73
  value,
73
74
  children,
74
75
  level,
75
- onToggle,
76
+ onExpand,
76
77
  ...props$1
77
78
  }) => {
78
79
  const classNames = useClassNames(ComponentToken.Tree);
79
80
  const {
80
81
  checkedKeys,
81
- check: _check,
82
- expandedKeys
82
+ onCheck,
83
+ expandedKeys,
84
+ onSelect,
85
+ selectedKeys,
86
+ selectable
83
87
  } = useContext(Context);
84
88
  const isChecked = checkedKeys.has(value);
85
89
  const isExpanded = expandedKeys.has(value);
90
+ const isSelected = selectedKeys.has(value);
86
91
  const theme = useTheme();
87
- const check = () => {
88
- _check?.(value);
89
- };
90
92
  const styled = {
91
93
  node: props(styles.node({
92
94
  level
93
95
  })),
94
96
  title: props(styles.title({
95
- isSelected: false,
97
+ isSelected,
96
98
  backgroundColor: theme.colors[ColorToken.SurfaceContainer],
97
99
  hoveredBackgroundColor: theme.colors[ColorToken.SurfaceContainer],
98
100
  color: theme.colors[ColorToken.Primary]
@@ -101,9 +103,17 @@ const Node = ({
101
103
  isExpanded
102
104
  }))
103
105
  };
104
- const toggle = () => {
105
- onToggle?.(value);
106
- };
106
+ const check = useEvent(() => {
107
+ onCheck?.(value);
108
+ });
109
+ const expand = useEvent(() => {
110
+ onExpand?.(value);
111
+ });
112
+ const select = useEvent(() => {
113
+ // no action when `selectable` is false
114
+ if (!selectable) return;
115
+ onSelect?.(value);
116
+ });
107
117
  return React.createElement("li", {
108
118
  className: classNames[TreeClassToken.Holder]
109
119
  }, React.createElement("div", {
@@ -112,15 +122,15 @@ const Node = ({
112
122
  }, React.createElement("span", {
113
123
  className: clsx(classNames[TreeClassToken.Expander], styled.expander.className),
114
124
  style: styled.expander.style,
115
- onClick: toggle
125
+ onClick: expand
116
126
  }, !!children && React.createElement(KeyboardArrowRight, null)), React.createElement(Checkbox, {
117
127
  className: clsx(classNames[TreeClassToken.Checkbox]),
118
128
  checked: isChecked,
119
- value: ""
129
+ onChange: check
120
130
  }), React.createElement("span", {
121
131
  className: clsx(classNames[TreeClassToken.Title], styled.title.className),
122
132
  style: styled.title.style,
123
- onClick: check
133
+ onClick: select
124
134
  }, props$1.title)), children);
125
135
  };
126
136
 
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { TreeProps } from "./types";
3
- declare const Tree: ({ expandedKeys: _expandedKeys, onExpand, className, style, ...props }: TreeProps) => React.JSX.Element;
3
+ declare const Tree: ({ expandedKeys: _expandedKeys, onExpand, className, style, nodes, selectable, selectedKeys: _selectedKeys, }: TreeProps) => React.JSX.Element;
4
4
  export default Tree;