musae 0.2.2 → 0.2.4

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 (137) hide show
  1. package/README.md +1 -1
  2. package/dist/components/avatar/avatar.js +1 -1
  3. package/dist/components/avatar/context.d.ts +0 -1
  4. package/dist/components/breadcrumb/breadcrumb.js +1 -1
  5. package/dist/components/breadcrumb/item.js +1 -1
  6. package/dist/components/button/button.js +1 -1
  7. package/dist/components/button-toggle/context.d.ts +0 -1
  8. package/dist/components/calendar/calendar.js +1 -1
  9. package/dist/components/calendar/hooks.js +1 -1
  10. package/dist/components/cascader/hooks.d.ts +1 -8
  11. package/dist/components/cascader/utils.d.ts +0 -1
  12. package/dist/components/checkbox/checkbox.js +4 -3
  13. package/dist/components/checkbox/context.d.ts +0 -1
  14. package/dist/components/checkbox/index.d.ts +0 -1
  15. package/dist/components/clock/column.js +1 -1
  16. package/dist/components/collapse/collapse.d.ts +4 -0
  17. package/dist/components/collapse/collapse.js +97 -0
  18. package/dist/components/collapse/context.d.ts +6 -0
  19. package/dist/components/collapse/context.js +12 -0
  20. package/dist/components/collapse/hooks.d.ts +12 -0
  21. package/dist/components/collapse/hooks.js +43 -0
  22. package/dist/components/collapse/index.d.ts +2 -0
  23. package/dist/components/collapse/item.d.ts +4 -0
  24. package/dist/components/collapse/item.js +144 -0
  25. package/dist/components/collapse/types.d.ts +87 -0
  26. package/dist/components/config/context.d.ts +0 -1
  27. package/dist/components/date-picker/date-picker.js +1 -1
  28. package/dist/components/date-picker/hooks.d.ts +1 -5
  29. package/dist/components/date-range-picker/hooks.d.ts +1 -5
  30. package/dist/components/dialog/hooks.d.ts +1 -5
  31. package/dist/components/dialog/popup.js +2 -2
  32. package/dist/components/divider/divider.js +1 -1
  33. package/dist/components/drawer/popup.js +2 -2
  34. package/dist/components/empty/empty.js +1 -1
  35. package/dist/components/form/context.d.ts +0 -1
  36. package/dist/components/form/field/field.d.ts +1 -1
  37. package/dist/components/form/field/field.js +8 -7
  38. package/dist/components/form/field/layout.js +1 -1
  39. package/dist/components/grid/col.js +1 -1
  40. package/dist/components/grid/index.d.ts +0 -1
  41. package/dist/components/grid/row.js +1 -1
  42. package/dist/components/icon/icon.js +2 -2
  43. package/dist/components/icon/icons/index.js +1 -0
  44. package/dist/components/icon/icons/navigation/index.d.ts +2 -1
  45. package/dist/components/icon/icons/navigation/index.js +1 -0
  46. package/dist/components/icon/icons/navigation/unfold-more.d.ts +3 -0
  47. package/dist/components/icon/icons/navigation/unfold-more.js +10 -0
  48. package/dist/components/image/index.d.ts +0 -1
  49. package/dist/components/image/preview/context.d.ts +0 -1
  50. package/dist/components/image/preview/operations.js +1 -1
  51. package/dist/components/image/preview/preview.js +1 -1
  52. package/dist/components/input/input.d.ts +20 -20
  53. package/dist/components/input/input.js +3 -11
  54. package/dist/components/layout/header.js +1 -1
  55. package/dist/components/layout/layout.js +1 -1
  56. package/dist/components/layout/main.d.ts +0 -1
  57. package/dist/components/loading/loading.d.ts +1 -1
  58. package/dist/components/loading/loading.js +70 -5
  59. package/dist/components/loading/types.d.ts +13 -0
  60. package/dist/components/menu/context.d.ts +0 -1
  61. package/dist/components/menu/group.d.ts +2 -2
  62. package/dist/components/menu/group.js +1 -1
  63. package/dist/components/menu/hooks.js +1 -1
  64. package/dist/components/menu/item.d.ts +1 -1
  65. package/dist/components/menu/item.js +1 -1
  66. package/dist/components/notification/holder.js +1 -1
  67. package/dist/components/notification/notification.js +1 -1
  68. package/dist/components/pagination/hooks.d.ts +2 -3
  69. package/dist/components/picker/context.d.ts +0 -1
  70. package/dist/components/picker/picker.js +1 -1
  71. package/dist/components/popover/popover.js +1 -1
  72. package/dist/components/popper/dropdown.js +1 -1
  73. package/dist/components/popper/hooks.d.ts +3 -3
  74. package/dist/components/progress/circular.js +1 -1
  75. package/dist/components/progress/hooks.d.ts +0 -1
  76. package/dist/components/progress/linear.js +1 -1
  77. package/dist/components/radio/context.d.ts +0 -1
  78. package/dist/components/radio/radio.js +22 -13
  79. package/dist/components/rate/rate.js +1 -1
  80. package/dist/components/rate/star.js +12 -14
  81. package/dist/components/ripple/hooks.js +4 -1
  82. package/dist/components/ripple/ripple.js +1 -1
  83. package/dist/components/select/selector.js +1 -1
  84. package/dist/components/select/utils.d.ts +0 -1
  85. package/dist/components/space/space.js +1 -1
  86. package/dist/components/steps/context.d.ts +0 -1
  87. package/dist/components/steps/item.js +1 -1
  88. package/dist/components/steps/steps.js +1 -1
  89. package/dist/components/switch/switch.js +1 -1
  90. package/dist/components/table/body.js +36 -4
  91. package/dist/components/table/context.d.ts +6 -1
  92. package/dist/components/table/context.js +10 -2
  93. package/dist/components/table/header/cell.d.ts +3 -0
  94. package/dist/components/table/header/cell.js +129 -0
  95. package/dist/components/table/{header.d.ts → header/header.d.ts} +1 -1
  96. package/dist/components/table/{header.js → header/header.js} +37 -10
  97. package/dist/components/table/hooks.d.ts +8 -21
  98. package/dist/components/table/hooks.js +36 -58
  99. package/dist/components/table/table.d.ts +1 -1
  100. package/dist/components/table/table.js +12 -6
  101. package/dist/components/table/types.d.ts +72 -4
  102. package/dist/components/tabs/context.d.ts +0 -1
  103. package/dist/components/tabs/item.js +3 -1
  104. package/dist/components/tabs/tabs.js +1 -1
  105. package/dist/components/tag/tag.js +1 -1
  106. package/dist/components/theme/hooks.d.ts +1 -2
  107. package/dist/components/time-picker/panel.js +1 -1
  108. package/dist/components/time-picker/time-picker.js +1 -1
  109. package/dist/components/timeline/context.d.ts +0 -1
  110. package/dist/components/timeline/item.js +1 -1
  111. package/dist/components/tour/tour.js +1 -1
  112. package/dist/components/tree/context.d.ts +0 -1
  113. package/dist/components/tree/hooks.d.ts +0 -1
  114. package/dist/components/tree/list.js +1 -1
  115. package/dist/components/tree/node.js +1 -1
  116. package/dist/components/upload/types.d.ts +8 -6
  117. package/dist/components/upload/upload.d.ts +1 -1
  118. package/dist/components/upload/upload.js +11 -4
  119. package/dist/components/upload/uploadeds.js +8 -3
  120. package/dist/components/waterfall/hooks.d.ts +1 -3
  121. package/dist/components/waterfall/hooks.js +2 -8
  122. package/dist/components/waterfall/sequential.js +1 -1
  123. package/dist/components/waterfall/waterfall.js +10 -6
  124. package/dist/components/watermark/types.d.ts +1 -1
  125. package/dist/components/watermark/watermark.js +1 -1
  126. package/dist/hooks/use-class-names.d.ts +15 -0
  127. package/dist/hooks/use-expand-effect.d.ts +1 -1
  128. package/dist/hooks/use-expand-effect.js +12 -8
  129. package/dist/index.d.ts +1 -0
  130. package/dist/index.js +1 -0
  131. package/dist/stylex.css +22 -7
  132. package/dist/utils/class-name.d.ts +42 -184
  133. package/dist/utils/class-name.js +39 -5
  134. package/dist/utils/styles.d.ts +1 -1
  135. package/package.json +15 -15
  136. /package/dist/node_modules/{@aiszlab → .pnpm/@aiszlab_relax@1.2.55_react-dom@18.3.1_react@18.3.1/node_modules/@aiszlab}/relax/dist/dom/contains.js +0 -0
  137. /package/dist/node_modules/{@stylexjs → .pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs}/stylex/lib/es/stylex.js +0 -0
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  ```bash
15
15
  npm install musae
16
- ## yarn add musae
16
+ ## pnpm i musae
17
17
  ```
18
18
 
19
19
  ## 🔨 Usage
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useContext } from 'react';
2
- import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
2
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type ContextValue } from "./types";
3
2
  /**
4
3
  * @description
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
2
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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/@stylexjs/stylex/lib/es/stylex.js';
2
+ import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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/@stylexjs/stylex/lib/es/stylex.js';
4
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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';
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const Context: import("react").Context<{}>;
@@ -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/@stylexjs/stylex/lib/es/stylex.js';
5
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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/@stylexjs/stylex/lib/es/stylex.js';
8
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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';
@@ -6,14 +6,7 @@ import type { Option } from "../../types/option";
6
6
  * @description
7
7
  * cascader value
8
8
  */
9
- export declare const useValue: ([valueInProps, readableOptions, readablePaths, mode, close, setAdditionalMenusItems]: [
10
- CascaderProps["value"],
11
- ReadableOptions,
12
- ReadablePaths,
13
- CascaderProps["mode"],
14
- close: VoidFunction,
15
- Dispatch<SetStateAction<MenuItem[][]>>
16
- ]) => {
9
+ export declare const useValue: ([valueInProps, readableOptions, readablePaths, mode, close, setAdditionalMenusItems]: [CascaderProps["value"], ReadableOptions, ReadablePaths, CascaderProps["mode"], close: VoidFunction, Dispatch<SetStateAction<MenuItem[][]>>]) => {
17
10
  values: Map<number, Required<Pick<Option, "value" | "label">>[]>;
18
11
  onChange: (id: number) => void;
19
12
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { KeyOrOption, Optionable, ReadBy, ReadableOption, ReadableOptions, ReadablePaths, Value, ValueOrValues } from "./types";
3
2
  import type { MenuItem } from "../menu";
4
3
  /**
@@ -4,7 +4,7 @@ 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/@stylexjs/stylex/lib/es/stylex.js';
7
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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';
@@ -24,6 +24,7 @@ const styles = {
24
24
  cursor: "musae-mper1u",
25
25
  width: "musae-r8isjd",
26
26
  height: "musae-1gfonl1",
27
+ position: "musae-1n2onr6",
27
28
  "::before_content": "musae-1cpjm7i",
28
29
  "::before_visibility": "musae-11srvyv",
29
30
  "::before_display": "musae-1fgarty",
@@ -94,7 +95,7 @@ const styles = {
94
95
  "::after_display": "musae-hkezso",
95
96
  "::after_width": "musae-11yodxc",
96
97
  "::after_height": "musae-ec44on",
97
- "::after_transform": "musae-1db1611",
98
+ "::after_transform": "musae-q1m6zb",
98
99
  "::after_borderWidth": "musae-15z8w9c",
99
100
  "::after_borderInlineWidth": null,
100
101
  "::after_borderInlineStartWidth": null,
@@ -163,7 +164,7 @@ const Checkbox = ({
163
164
  }, [_setIsChecked, contextValue, value]);
164
165
  const styled = {
165
166
  checkbox: {
166
- className: "musae-78zum5 musae-6s0dn4 musae-1ypdohk"
167
+ className: "musae-3nfvp2 musae-6s0dn4 musae-1ypdohk"
167
168
  },
168
169
  trigger: props(styles.trigger({
169
170
  borderColor: theme.colors[ColorToken.Outline]
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ContextValue } from "./types";
3
2
  declare const Context: import("react").Context<ContextValue | null>;
4
3
  export default Context;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Checkbox: (({ value, className, style, children, ...props }: import("./types").CheckboxProps) => import("react").JSX.Element) & {
3
2
  Group: (props: import("./types").CheckboxGroupProps) => import("react").JSX.Element;
4
3
  };
@@ -4,7 +4,7 @@ import Menu from '../menu/menu.js';
4
4
  import { useClassNames } from '../../hooks/use-class-names.js';
5
5
  import { ComponentToken, ClockClassToken } from '../../utils/class-name.js';
6
6
  import { isVoid } from '@aiszlab/relax';
7
- import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
7
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/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 clsx from 'clsx';
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { CollapseProps } from "./types";
3
+ declare const Collapse: ({ items, className, defaultActiveKey, activeKey, onChange, style, accordion, }: CollapseProps) => React.JSX.Element | null;
4
+ export default Collapse;
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import { useClassNames } from '../../hooks/use-class-names.js';
3
+ import { ComponentToken, CollapseClassToken } from '../../utils/class-name.js';
4
+ import CollapseItem from './item.js';
5
+ import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
6
+ import clsx from 'clsx';
7
+ import { useActiveKeys } from './hooks.js';
8
+ import { Context } from './context.js';
9
+ import { useTheme } from '../theme/hooks.js';
10
+ import { ColorToken } from '../../utils/colors.js';
11
+
12
+ const styles = {
13
+ collapse: props => [{
14
+ borderWidth: "musae-1i8jmgv",
15
+ borderInlineWidth: null,
16
+ borderInlineStartWidth: null,
17
+ borderLeftWidth: null,
18
+ borderInlineEndWidth: null,
19
+ borderRightWidth: null,
20
+ borderBlockWidth: null,
21
+ borderTopWidth: null,
22
+ borderBottomWidth: null,
23
+ borderStyle: "musae-1y0btm7",
24
+ borderInlineStyle: null,
25
+ borderInlineStartStyle: null,
26
+ borderLeftStyle: null,
27
+ borderInlineEndStyle: null,
28
+ borderRightStyle: null,
29
+ borderBlockStyle: null,
30
+ borderTopStyle: null,
31
+ borderBottomStyle: null,
32
+ borderColor: "musae-eqt46j",
33
+ borderInlineColor: null,
34
+ borderInlineStartColor: null,
35
+ borderLeftColor: null,
36
+ borderInlineEndColor: null,
37
+ borderRightColor: null,
38
+ borderBlockColor: null,
39
+ borderTopColor: null,
40
+ borderBottomColor: null,
41
+ borderRadius: "musae-1h268bu",
42
+ borderStartStartRadius: null,
43
+ borderStartEndRadius: null,
44
+ borderEndStartRadius: null,
45
+ borderEndEndRadius: null,
46
+ borderTopLeftRadius: null,
47
+ borderTopRightRadius: null,
48
+ borderBottomLeftRadius: null,
49
+ borderBottomRightRadius: null,
50
+ $$css: true
51
+ }, {
52
+ "--borderColor": props.outlineColor != null ? props.outlineColor : "initial"
53
+ }]
54
+ };
55
+ const Collapse = ({
56
+ items,
57
+ className,
58
+ defaultActiveKey,
59
+ activeKey,
60
+ onChange,
61
+ style,
62
+ accordion = false
63
+ }) => {
64
+ const classNames = useClassNames(ComponentToken.Collapse);
65
+ const [activeKeys, toggle] = useActiveKeys({
66
+ defaultActiveKey,
67
+ activeKey,
68
+ onChange,
69
+ accordion
70
+ });
71
+ const theme = useTheme();
72
+ // no need to render when items is empty
73
+ if (items.length === 0) return null;
74
+ const styled = _stylex.props(styles.collapse({
75
+ outlineColor: theme.colors[ColorToken.OutlineVariant]
76
+ }));
77
+ return React.createElement(Context.Provider, {
78
+ value: {
79
+ activeKeys,
80
+ toggle
81
+ }
82
+ }, React.createElement("div", {
83
+ className: clsx(classNames[CollapseClassToken.Collapse], className, styled.className),
84
+ style: {
85
+ ...styled.style,
86
+ ...style
87
+ }
88
+ }, items.map(item => {
89
+ return React.createElement(CollapseItem, {
90
+ ...item,
91
+ value: item.key
92
+ });
93
+ })));
94
+ };
95
+ var Collapse$1 = Collapse;
96
+
97
+ export { Collapse$1 as default };
@@ -0,0 +1,6 @@
1
+ import type { ContextValue } from "./types";
2
+ /**
3
+ * @description
4
+ * `Collapse` Context
5
+ */
6
+ export declare const Context: import("react").Context<ContextValue>;
@@ -0,0 +1,12 @@
1
+ import { createContext } from 'react';
2
+
3
+ /**
4
+ * @description
5
+ * `Collapse` Context
6
+ */
7
+ const Context = createContext({
8
+ activeKeys: new Set(),
9
+ toggle: () => { },
10
+ });
11
+
12
+ export { Context };
@@ -0,0 +1,12 @@
1
+ import { type Key } from "react";
2
+ import type { Value } from "./types";
3
+ /**
4
+ * @description
5
+ * `Collapse` active key hook
6
+ */
7
+ export declare const useActiveKeys: ({ defaultActiveKey, activeKey: _activeKey, onChange: _onChange, accordion, }: {
8
+ defaultActiveKey?: Value;
9
+ activeKey?: Value;
10
+ onChange?: (value: Key[]) => void;
11
+ accordion: boolean;
12
+ }) => [Set<Key>, (key: Key) => void];
@@ -0,0 +1,43 @@
1
+ import { useControlledState, exclude, toArray, useEvent } from '@aiszlab/relax';
2
+ import { useMemo } from 'react';
3
+
4
+ /**
5
+ * @description
6
+ * `Collapse` active key hook
7
+ */
8
+ const useActiveKeys = ({ defaultActiveKey, activeKey: _activeKey, onChange: _onChange, accordion, }) => {
9
+ const [_activeKeys, _setActiveKeys] = useControlledState(_activeKey, { defaultState: defaultActiveKey });
10
+ const activeKeys = useMemo(() => {
11
+ const keys = exclude(toArray(_activeKeys), [void 0]);
12
+ if (accordion) {
13
+ return new Set(keys.slice(0, 1));
14
+ }
15
+ return new Set(keys);
16
+ }, [_activeKeys, accordion]);
17
+ const toggle = useEvent((key) => {
18
+ const expandedKeys = new Set(activeKeys);
19
+ const isExpanded = expandedKeys.has(key);
20
+ // `accordion` mode, just toggle `key`
21
+ // otherwise, normally toggle `key`
22
+ if (accordion) {
23
+ expandedKeys.clear();
24
+ if (!isExpanded) {
25
+ expandedKeys.add(key);
26
+ }
27
+ }
28
+ else {
29
+ if (isExpanded) {
30
+ expandedKeys.delete(key);
31
+ }
32
+ else {
33
+ expandedKeys.add(key);
34
+ }
35
+ }
36
+ const _expandedKeys = Array.from(expandedKeys);
37
+ _setActiveKeys(_expandedKeys);
38
+ _onChange?.(_expandedKeys);
39
+ });
40
+ return [activeKeys, toggle];
41
+ };
42
+
43
+ export { useActiveKeys };
@@ -0,0 +1,2 @@
1
+ import Collapse from "./collapse";
2
+ export { Collapse };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { CollapseItemProps } from "./types";
3
+ declare const CollapseItem: ({ children, label, value }: CollapseItemProps) => React.JSX.Element;
4
+ export default CollapseItem;
@@ -0,0 +1,144 @@
1
+ import React, { useContext } from 'react';
2
+ import { useClassNames } from '../../hooks/use-class-names.js';
3
+ import { ComponentToken, CollapseClassToken } from '../../utils/class-name.js';
4
+ import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
5
+ import { useEvent } from '@aiszlab/relax';
6
+ import { useAnimate } from 'framer-motion';
7
+ import clsx from 'clsx';
8
+ import { Context } from './context.js';
9
+ import { useExpandEffect } from '../../hooks/use-expand-effect.js';
10
+ import { useTheme } from '../theme/hooks.js';
11
+ import { ColorToken } from '../../utils/colors.js';
12
+ import KeyboardArrowRight from '../icon/icons/hardware/keyboard-arrow-right.js';
13
+
14
+ const styles = {
15
+ item: {
16
+ default: props => [{
17
+ borderBottomWidth: "musae-lntmim",
18
+ borderBottomStyle: "musae-1q0q8m5",
19
+ borderBottomColor: "musae-43481e",
20
+ ":last-of-type_borderBottomWidth": "musae-zm6erk",
21
+ $$css: true
22
+ }, {
23
+ "--borderBottomColor": props.outlineColor != null ? props.outlineColor : "initial"
24
+ }]
25
+ },
26
+ header: {
27
+ default: {
28
+ paddingInline: "musae-1xkwav8",
29
+ paddingStart: null,
30
+ paddingLeft: null,
31
+ paddingEnd: null,
32
+ paddingRight: null,
33
+ paddingBlock: "musae-avjae4",
34
+ paddingTop: null,
35
+ paddingBottom: null,
36
+ display: "musae-78zum5",
37
+ flexDirection: "musae-1q0g3np",
38
+ alignItems: "musae-6s0dn4",
39
+ gap: "musae-vbka3v",
40
+ rowGap: null,
41
+ columnGap: null,
42
+ cursor: "musae-1ypdohk",
43
+ $$css: true
44
+ }
45
+ },
46
+ panel: {
47
+ default: {
48
+ height: "musae-t7dq6l",
49
+ $$css: true
50
+ },
51
+ hidden: {
52
+ display: "musae-1s85apg",
53
+ $$css: true
54
+ }
55
+ },
56
+ content: {
57
+ default: props => [{
58
+ borderTopWidth: "musae-1yeim8r",
59
+ borderTopStyle: "musae-13fuv20",
60
+ borderTopColor: "musae-is9nib",
61
+ padding: "musae-12ldsqu",
62
+ paddingInline: null,
63
+ paddingStart: null,
64
+ paddingLeft: null,
65
+ paddingEnd: null,
66
+ paddingRight: null,
67
+ paddingBlock: null,
68
+ paddingTop: null,
69
+ paddingBottom: null,
70
+ $$css: true
71
+ }, {
72
+ "--borderTopColor": props.outlineColor != null ? props.outlineColor : "initial"
73
+ }]
74
+ },
75
+ collapser: {
76
+ default: {
77
+ willChange: "musae-1so62im",
78
+ transitionProperty: "musae-11xpdln",
79
+ transitionDuration: "musae-13dflua",
80
+ $$css: true
81
+ },
82
+ expanded: {
83
+ transform: "musae-1iffjtl",
84
+ $$css: true
85
+ }
86
+ }
87
+ };
88
+ const CollapseItem = ({
89
+ children,
90
+ label,
91
+ value
92
+ }) => {
93
+ const classNames = useClassNames(ComponentToken.Collapse);
94
+ const {
95
+ activeKeys,
96
+ toggle
97
+ } = useContext(Context);
98
+ const isExpanded = activeKeys.has(value);
99
+ const [collapser, animate] = useAnimate();
100
+ const theme = useTheme();
101
+ useExpandEffect({
102
+ animate,
103
+ expanded: isExpanded,
104
+ target: collapser
105
+ });
106
+ const styled = {
107
+ item: _stylex.props(styles.item.default({
108
+ outlineColor: theme.colors[ColorToken.OutlineVariant]
109
+ })),
110
+ header: _stylex.props(styles.header.default),
111
+ panel: _stylex.props(styles.panel.default, !isExpanded && styles.panel.hidden),
112
+ content: _stylex.props(styles.content.default({
113
+ outlineColor: theme.colors[ColorToken.OutlineVariant]
114
+ })),
115
+ collapser: _stylex.props(styles.collapser.default, isExpanded && styles.collapser.expanded)
116
+ };
117
+ const onClick = useEvent(() => {
118
+ toggle(value);
119
+ });
120
+ return React.createElement("div", {
121
+ className: clsx(classNames[CollapseClassToken.Item], {
122
+ [classNames[CollapseClassToken.ItemActive]]: isExpanded
123
+ }, styled.item.className),
124
+ style: styled.item.style
125
+ }, React.createElement("div", {
126
+ className: clsx(classNames[CollapseClassToken.Header], styled.header.className),
127
+ style: styled.header.style,
128
+ onClick: onClick
129
+ }, React.createElement(KeyboardArrowRight, {
130
+ className: clsx(classNames[CollapseClassToken.Collapser], styled.collapser.className),
131
+ style: styled.collapser.style
132
+ }), label), React.createElement("div", {
133
+ ref: collapser,
134
+ className: clsx(classNames[CollapseClassToken.Panel], {
135
+ [classNames[CollapseClassToken.PanelActive]]: isExpanded
136
+ }, styled.panel.className),
137
+ style: styled.panel.style
138
+ }, React.createElement("div", {
139
+ className: clsx(classNames[CollapseClassToken.Content], styled.content.className),
140
+ style: styled.content.style
141
+ }, children)));
142
+ };
143
+
144
+ export { CollapseItem as default };
@@ -0,0 +1,87 @@
1
+ import type { Key, ReactNode } from "react";
2
+ import type { ComponentProps } from "../../types/element";
3
+ export type Value = Key | Key[];
4
+ /**
5
+ * @description
6
+ * `Collapse` item
7
+ */
8
+ interface CollapseItem {
9
+ /**
10
+ * @description
11
+ * key
12
+ */
13
+ key: Key;
14
+ /**
15
+ * @description
16
+ * label
17
+ */
18
+ label: string;
19
+ /**
20
+ * @description
21
+ * children
22
+ */
23
+ children: ReactNode;
24
+ }
25
+ /**
26
+ * @description
27
+ * `Collapse` props
28
+ */
29
+ export interface CollapseProps extends ComponentProps {
30
+ /**
31
+ * @description
32
+ * default active key
33
+ * @default void 0
34
+ */
35
+ defaultActiveKey?: Value;
36
+ /**
37
+ * @description
38
+ * active key
39
+ * @default void 0
40
+ */
41
+ activeKey?: Value;
42
+ /**
43
+ * @description
44
+ * items
45
+ */
46
+ items: CollapseItem[];
47
+ /**
48
+ * @description
49
+ * change handler
50
+ * @default void 0
51
+ */
52
+ onChange?: (value: Key[]) => void;
53
+ /**
54
+ * @description
55
+ * accordion mode
56
+ * @default false
57
+ */
58
+ accordion?: boolean;
59
+ }
60
+ /**
61
+ * @description
62
+ * `Collapse` item props
63
+ */
64
+ export interface CollapseItemProps extends Omit<CollapseItem, "key"> {
65
+ /**
66
+ * @description
67
+ * value
68
+ */
69
+ value: Key;
70
+ }
71
+ /**
72
+ * @description
73
+ * context value
74
+ */
75
+ export interface ContextValue {
76
+ /**
77
+ * @description
78
+ * active keys
79
+ */
80
+ activeKeys: Set<Key>;
81
+ /**
82
+ * @description
83
+ * key toggle
84
+ */
85
+ toggle: (key: Key) => void;
86
+ }
87
+ export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ContextValue } from "./types";
3
2
  declare const Context: import("react").Context<ContextValue>;
4
3
  export default Context;
@@ -4,7 +4,7 @@ import Calendar from '../calendar/calendar.js';
4
4
  import { useValue } from './hooks.js';
5
5
  import { useClassNames } from '../../hooks/use-class-names.js';
6
6
  import { ComponentToken, DatePickerClassToken } from '../../utils/class-name.js';
7
- import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
7
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
8
8
  import clsx from 'clsx';
9
9
  import { styles } from '../input/input.js';
10
10
 
@@ -5,11 +5,7 @@ import { PickerRef } from "../picker";
5
5
  * @description
6
6
  * value
7
7
  */
8
- export declare const useValue: ([_value, _change, _ref]: [
9
- DatePickerProps["value"],
10
- DatePickerProps["onChange"],
11
- RefObject<PickerRef>
12
- ]) => {
8
+ export declare const useValue: ([_value, _change, _ref]: [DatePickerProps["value"], DatePickerProps["onChange"], RefObject<PickerRef>]) => {
13
9
  value: import("dayjs").Dayjs | undefined;
14
10
  onChange: (value: import("dayjs").Dayjs) => void;
15
11
  };
@@ -7,11 +7,7 @@ import { PickerRef } from "../picker";
7
7
  * @description
8
8
  * value
9
9
  */
10
- export declare const useValue: ([_value, _change, ref]: [
11
- DateRangePickerProps["value"],
12
- DateRangePickerProps["onChange"],
13
- RefObject<PickerRef>
14
- ]) => {
10
+ export declare const useValue: ([_value, _change, ref]: [DateRangePickerProps["value"], DateRangePickerProps["onChange"], RefObject<PickerRef>]) => {
15
11
  value: [Partialable<Dayjs>, Partialable<Dayjs>];
16
12
  onChange: (_value: Dayjs) => void;
17
13
  };
@@ -4,8 +4,4 @@ import type { PopupProps } from "./types";
4
4
  * @description
5
5
  * footer
6
6
  */
7
- export declare const useFooter: ([footer, onConfirm, onClose]: [
8
- footer: PopupProps["footer"],
9
- onConfirm: PopupProps["onConfirm"],
10
- onClose: PopupProps["onClose"]
11
- ]) => string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element;
7
+ export declare const useFooter: ([footer, onConfirm, onClose]: [footer: PopupProps["footer"], onConfirm: PopupProps["onConfirm"], onClose: PopupProps["onClose"]]) => string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element;
@@ -3,13 +3,13 @@ import { useFooter } from './hooks.js';
3
3
  import { useAnimate } from 'framer-motion';
4
4
  import { ComponentToken, DialogClassToken } from '../../utils/class-name.js';
5
5
  import { useClassNames } from '../../hooks/use-class-names.js';
6
- import { props } from '../../node_modules/@stylexjs/stylex/lib/es/stylex.js';
6
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
7
7
  import { useTheme } from '../theme/hooks.js';
8
8
  import { ColorToken } from '../../utils/colors.js';
9
9
  import { typography } from '../theme/theme.js';
10
10
  import clsx from 'clsx';
11
11
  import { useDismissable } from '../../hooks/use-dismissable.js';
12
- import { contains } from '../../node_modules/@aiszlab/relax/dist/dom/contains.js';
12
+ import { contains } from '../../node_modules/.pnpm/@aiszlab_relax@1.2.55_react-dom@18.3.1_react@18.3.1/node_modules/@aiszlab/relax/dist/dom/contains.js';
13
13
 
14
14
  const styles = {
15
15
  header: {