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,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { SwitchProps } from "./types";
3
- declare const Switch: ({ value, style, className, icon, checkedChildren, uncheckedChildren, disabled, }: SwitchProps) => React.JSX.Element;
3
+ declare const Switch: ({ value, style, className, icon, checkedChildren, uncheckedChildren, disabled, onChange, }: SwitchProps) => React.JSX.Element;
4
4
  export default Switch;
@@ -1,6 +1,6 @@
1
- import React, { useCallback } from 'react';
2
- import { useControlledState } from '@aiszlab/relax';
3
- import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
1
+ import React from 'react';
2
+ import { useControlledState, useEvent } from '@aiszlab/relax';
3
+ import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
4
4
  import { useTheme } from '../theme/hooks.js';
5
5
  import { ColorToken } from '../../utils/colors.js';
6
6
  import clsx from 'clsx';
@@ -14,16 +14,13 @@ const styles = {
14
14
  switch: {
15
15
  default: props => [{
16
16
  minWidth: "musae-1049mhy",
17
+ width: "musae-eq5yr9",
17
18
  height: "musae-hfcj97",
18
19
  display: "musae-78zum5",
19
20
  alignItems: "musae-6s0dn4",
20
21
  position: "musae-1n2onr6",
21
- transition: "musae-1ng1d19",
22
- transitionBehavior: null,
23
- transitionDelay: null,
24
- transitionDuration: null,
25
- transitionProperty: null,
26
- transitionTimingFunction: null,
22
+ transitionProperty: "musae-fagghw",
23
+ transitionDuration: "musae-13dflua",
27
24
  borderRadius: "musae-iipnba",
28
25
  borderStartStartRadius: null,
29
26
  borderStartEndRadius: null,
@@ -173,7 +170,7 @@ const styles = {
173
170
  $$css: true
174
171
  },
175
172
  child: {
176
- minHeight: "musae-jk1msx",
173
+ height: "musae-b27hse",
177
174
  display: "musae-78zum5",
178
175
  flexDirection: "musae-1q0g3np",
179
176
  alignItems: "musae-6s0dn4",
@@ -192,20 +189,20 @@ const styles = {
192
189
  $$css: true
193
190
  },
194
191
  checked: {
195
- marginInlineStart: "musae-1tt3wx9",
192
+ marginInlineStart: "musae-1lziwak",
196
193
  marginLeft: null,
197
194
  marginRight: null,
198
- marginInlineEnd: "musae-fbia9g",
195
+ marginInlineEnd: "musae-14z9mp",
199
196
  $$css: true
200
197
  }
201
198
  },
202
199
  trailing: {
203
200
  default: {
204
- marginTop: "musae-ncydc0",
205
- marginInlineEnd: "musae-fbia9g",
201
+ marginTop: "musae-lpx92y",
202
+ marginInlineEnd: "musae-14z9mp",
206
203
  marginLeft: null,
207
204
  marginRight: null,
208
- marginInlineStart: "musae-1tt3wx9",
205
+ marginInlineStart: "musae-1lziwak",
209
206
  $$css: true
210
207
  },
211
208
  checked: {
@@ -224,14 +221,17 @@ const Switch = ({
224
221
  icon = false,
225
222
  checkedChildren,
226
223
  uncheckedChildren,
227
- disabled = false
224
+ disabled = false,
225
+ onChange
228
226
  }) => {
229
227
  const classNames = useClassNames(ComponentToken.Switch);
230
228
  const [isChecked, setIsChecked] = useControlledState(value);
231
229
  const theme = useTheme();
232
- const toggle = useCallback(() => {
233
- setIsChecked(_isChecked => !_isChecked);
234
- }, [setIsChecked]);
230
+ const toggle = useEvent(() => {
231
+ const _isChecked = !isChecked;
232
+ setIsChecked(_isChecked);
233
+ onChange?.(_isChecked);
234
+ });
235
235
  const styled = {
236
236
  switch: props(styles.switch.default({
237
237
  borderColor: theme.colors[ColorToken.Outline],
@@ -284,13 +284,13 @@ const Switch = ({
284
284
  className: clsx(classNames[SwitchClassToken.Slider], styled.slider.className),
285
285
  style: styled.slider.style
286
286
  }, icon && (isChecked ? React.createElement(Check, null) : React.createElement(Close, null))), React.createElement("span", {
287
- className: styled.supporting.className,
287
+ className: clsx(classNames[SwitchClassToken.Supporting], styled.supporting.className),
288
288
  style: styled.supporting.style
289
289
  }, React.createElement("span", {
290
- className: styled.leading.className,
290
+ className: clsx(classNames[SwitchClassToken.Leading], styled.leading.className),
291
291
  style: styled.leading.style
292
292
  }, checkedChildren), React.createElement("span", {
293
- className: styled.trailing.className,
293
+ className: clsx(classNames[SwitchClassToken.Trailing], styled.trailing.className),
294
294
  style: styled.trailing.style
295
295
  }, uncheckedChildren)));
296
296
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useTable } from './context.js';
3
3
  import { flexRender } from '@tanstack/react-table';
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 clsx from 'clsx';
6
6
  import { typography } from '../theme/theme.js';
7
7
  import { useTheme } from '../theme/hooks.js';
@@ -1,6 +1,6 @@
1
1
  import React, { useContext, useMemo } from 'react';
2
2
  import { toFunction, useEvent, isUndefined } from '@aiszlab/relax';
3
- import _stylex from '../../../node_modules/.pnpm/@stylexjs_stylex@0.6.1/node_modules/@stylexjs/stylex/lib/es/stylex.js';
3
+ import _stylex from '../../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
4
4
  import { useTheme } from '../../theme/hooks.js';
5
5
  import { ColorToken } from '../../../utils/colors.js';
6
6
  import Context from '../context.js';
@@ -35,8 +35,8 @@ const styles = {
35
35
  },
36
36
  half: {
37
37
  position: "musae-10l6tqk",
38
- top: "musae-9oc6z4",
39
- insetInlineStart: "musae-1at4hj2",
38
+ top: "musae-13vifvy",
39
+ insetInlineStart: "musae-1o0tod",
40
40
  left: null,
41
41
  right: null,
42
42
  height: "musae-1cj5796",
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useTable } from '../context.js';
3
3
  import { flexRender } from '@tanstack/react-table';
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 clsx from 'clsx';
7
7
  import { ColorToken } from '../../../utils/colors.js';
@@ -52,7 +52,7 @@ const styles = {
52
52
  ":not(:last-of-type)::after_height": "musae-1su0kt9",
53
53
  ":not(:last-of-type)::after_backgroundColor": "musae-9cqmhv",
54
54
  ":not(:last-of-type)::after_transform": "musae-1kmnipp",
55
- ":not(:last-of-type)::after_insetInlineEnd": "musae-1sd0t5p",
55
+ ":not(:last-of-type)::after_insetInlineEnd": "musae-192i3sz",
56
56
  ":not(:last-of-type)::after_left": null,
57
57
  ":not(:last-of-type)::after_right": null,
58
58
  $$css: true
@@ -0,0 +1,40 @@
1
+ import { type Key, type RefObject } from "react";
2
+ import type { TabItem } from "./types";
3
+ /**
4
+ * @description
5
+ * use tab context
6
+ */
7
+ export declare const useTabsContext: () => import("./types").ContextValue;
8
+ /**
9
+ * @description
10
+ * tabs
11
+ */
12
+ export declare const useTabs: ({ activeKey: _activeKey, items, defaultActiveKey, }: {
13
+ activeKey?: Key;
14
+ items: TabItem[];
15
+ defaultActiveKey?: Key;
16
+ }) => {
17
+ activeKey: string | number | bigint | undefined;
18
+ activatedKeys: Set<Key>;
19
+ changeActiveKey: (key: Key) => void;
20
+ };
21
+ /**
22
+ * @description
23
+ * count dom ele size
24
+ */
25
+ export declare const useNavigation: () => {
26
+ navigatorRef: RefObject<HTMLDivElement>;
27
+ tabsRef: RefObject<HTMLDivElement>;
28
+ scroll: (delta: number) => void;
29
+ offset: number;
30
+ isLeadingOverflow: boolean;
31
+ isTrailingOverflow: boolean;
32
+ };
33
+ /**
34
+ * @description
35
+ * use navigator scroll
36
+ */
37
+ export declare const useNavigatorScroll: ({ navigatorRef, scroll, }: {
38
+ navigatorRef: RefObject<HTMLDivElement>;
39
+ scroll: (delta: number) => void;
40
+ }) => void;
@@ -0,0 +1,98 @@
1
+ import { useControlledState, isUndefined, useEvent, clamp } from '@aiszlab/relax';
2
+ import { useState, useContext, useRef, useLayoutEffect, useMemo, useEffect } from 'react';
3
+ import Context from './context.js';
4
+
5
+ /**
6
+ * @description
7
+ * use tab context
8
+ */
9
+ const useTabsContext = () => {
10
+ return useContext(Context) ?? { items: [], activeKey: void 0 };
11
+ };
12
+ /**
13
+ * @description
14
+ * tabs
15
+ */
16
+ const useTabs = ({ activeKey: _activeKey, items, defaultActiveKey, }) => {
17
+ const [activeKey, setActiveKey] = useControlledState(_activeKey, {
18
+ defaultState: defaultActiveKey ?? items.at(0)?.key,
19
+ });
20
+ const [activatedKeys, setActivatedKeys] = useState(() => {
21
+ return new Set(isUndefined(activeKey) ? [] : [activeKey]);
22
+ });
23
+ const changeActiveKey = useEvent((key) => {
24
+ setActiveKey(key);
25
+ setActivatedKeys((prev) => new Set(prev).add(key));
26
+ });
27
+ return {
28
+ activeKey,
29
+ activatedKeys,
30
+ changeActiveKey,
31
+ };
32
+ };
33
+ /**
34
+ * @description
35
+ * count dom ele size
36
+ */
37
+ const useNavigation = () => {
38
+ const navigatorRef = useRef(null);
39
+ const tabsRef = useRef(null);
40
+ const [offset, setOffset] = useState(0);
41
+ // navigator size
42
+ const [navigatorSize, setNavigatorSize] = useState(0);
43
+ // tabs size
44
+ const [tabsSize, setTabsSize] = useState(0);
45
+ useLayoutEffect(() => {
46
+ const _navigatorSize = navigatorRef.current?.getBoundingClientRect().width ?? 0;
47
+ const _tabsSize = tabsRef.current?.getBoundingClientRect().width ?? 0;
48
+ setNavigatorSize(_navigatorSize);
49
+ setTabsSize(_tabsSize);
50
+ }, []);
51
+ const { maxOffset, minOffset } = useMemo(() => {
52
+ return {
53
+ maxOffset: Math.max(0, tabsSize - navigatorSize),
54
+ minOffset: 0,
55
+ };
56
+ }, [navigatorSize, tabsSize]);
57
+ const { isLeadingOverflow, isTrailingOverflow } = useMemo(() => {
58
+ return {
59
+ isLeadingOverflow: offset > minOffset,
60
+ isTrailingOverflow: offset < maxOffset,
61
+ };
62
+ }, [minOffset, maxOffset, offset]);
63
+ const scroll = useEvent((delta) => {
64
+ setOffset((prev) => {
65
+ return clamp(prev + delta, minOffset, maxOffset);
66
+ });
67
+ });
68
+ return {
69
+ navigatorRef,
70
+ tabsRef,
71
+ scroll,
72
+ offset,
73
+ isLeadingOverflow,
74
+ isTrailingOverflow,
75
+ };
76
+ };
77
+ /**
78
+ * @description
79
+ * use navigator scroll
80
+ */
81
+ const useNavigatorScroll = ({ navigatorRef, scroll, }) => {
82
+ // mouse wheel
83
+ const onWheel = useEvent((event) => {
84
+ event.preventDefault();
85
+ const { deltaY } = event;
86
+ scroll(deltaY);
87
+ });
88
+ useEffect(() => {
89
+ const navigator = navigatorRef.current;
90
+ navigator?.addEventListener("wheel", onWheel);
91
+ return () => {
92
+ navigator?.removeEventListener("wheel", onWheel);
93
+ };
94
+ // eslint-disable-next-line react-hooks/exhaustive-deps
95
+ }, []);
96
+ };
97
+
98
+ export { useNavigation, useNavigatorScroll, useTabs, useTabsContext };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type NavigationProps } from "./types";
3
+ declare const Navigation: ({ onChange }: NavigationProps) => React.JSX.Element;
4
+ export default Navigation;
@@ -0,0 +1,159 @@
1
+ import clsx from 'clsx';
2
+ import React, { useRef, useEffect } from 'react';
3
+ import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
4
+ import { useClassNames } from '../../hooks/use-class-names.js';
5
+ import { ComponentToken, TabsClassToken } from '../../utils/class-name.js';
6
+ import Tab from './tab.js';
7
+ import { useAnimate } from 'framer-motion';
8
+ import { isUndefined } from '@aiszlab/relax';
9
+ import { useTheme } from '../theme/hooks.js';
10
+ import { ColorToken } from '../../utils/colors.js';
11
+ import { useTabsContext, useNavigation, useNavigatorScroll } from './hooks.js';
12
+
13
+ const styles = {
14
+ navigation: {
15
+ default: props => [{
16
+ borderBottomColor: "musae-43481e",
17
+ borderBottomWidth: "musae-lntmim",
18
+ borderBottomStyle: "musae-1q0q8m5",
19
+ $$css: true
20
+ }, {
21
+ "--borderBottomColor": props.outlineColor != null ? props.outlineColor : "initial"
22
+ }]
23
+ },
24
+ navigator: {
25
+ default: {
26
+ position: "musae-1n2onr6",
27
+ overflow: "musae-b3r6kr",
28
+ overflowX: null,
29
+ overflowY: null,
30
+ $$css: true
31
+ },
32
+ leading: {
33
+ "::before_content": "musae-1cpjm7i",
34
+ "::before_position": "musae-1hmns74",
35
+ "::before_insetBlock": "musae-1nc033x",
36
+ "::before_top": null,
37
+ "::before_bottom": null,
38
+ "::before_insetInlineStart": "musae-1682cnc",
39
+ "::before_left": null,
40
+ "::before_right": null,
41
+ "::before_pointerEvents": "musae-kk1bqk",
42
+ "::before_width": "musae-bk3rzz",
43
+ "::before_boxShadow": "musae-91zhsk",
44
+ $$css: true
45
+ },
46
+ trailing: {
47
+ "::after_content": "musae-1s928wv",
48
+ "::after_position": "musae-1j6awrg",
49
+ "::after_insetBlock": "musae-d54j2p",
50
+ "::after_top": null,
51
+ "::after_bottom": null,
52
+ "::after_insetInlineEnd": "musae-1unh1gc",
53
+ "::after_left": null,
54
+ "::after_right": null,
55
+ "::after_pointerEvents": "musae-2q1x1w",
56
+ "::after_width": "musae-g1t9zo",
57
+ "::after_boxShadow": "musae-15cyge6",
58
+ $$css: true
59
+ }
60
+ },
61
+ list: {
62
+ default: props => [{
63
+ display: "musae-78zum5",
64
+ width: "musae-eq5yr9",
65
+ transform: "musae-1v0jg1i",
66
+ $$css: true
67
+ }, {
68
+ "--transform": `translateX(-${props.offset}px)` != null ? `translateX(-${props.offset}px)` : "initial"
69
+ }]
70
+ },
71
+ indicator: {
72
+ default: props => [{
73
+ height: "musae-kzsoxx",
74
+ backgroundColor: "musae-q1mx2j",
75
+ position: "musae-10l6tqk",
76
+ bottom: "musae-8wmlod",
77
+ $$css: true
78
+ }, {
79
+ "--backgroundColor": props.color != null ? props.color : "initial"
80
+ }]
81
+ }
82
+ };
83
+ const Navigation = ({
84
+ onChange
85
+ }) => {
86
+ const {
87
+ activeKey,
88
+ items
89
+ } = useTabsContext();
90
+ const classNames = useClassNames(ComponentToken.Tabs);
91
+ const [indicatorRef, animateIndicator] = useAnimate();
92
+ const tabRefs = useRef(new Map());
93
+ const theme = useTheme();
94
+ const {
95
+ navigatorRef,
96
+ tabsRef,
97
+ scroll,
98
+ offset,
99
+ isLeadingOverflow,
100
+ isTrailingOverflow
101
+ } = useNavigation();
102
+ // control tabs scroll
103
+ useNavigatorScroll({
104
+ navigatorRef,
105
+ scroll
106
+ });
107
+ const styled = {
108
+ navigation: _stylex.props(styles.navigation.default({
109
+ outlineColor: theme.colors[ColorToken.Outline]
110
+ })),
111
+ navigator: _stylex.props(styles.navigator.default, isLeadingOverflow && styles.navigator.leading, isTrailingOverflow && styles.navigator.trailing),
112
+ list: _stylex.props(styles.list.default({
113
+ offset
114
+ })),
115
+ indicator: _stylex.props(styles.indicator.default({
116
+ color: theme.colors[ColorToken.Primary]
117
+ }))
118
+ };
119
+ // repaint indicator when activeKey changed
120
+ // animate indicator to correct position & width
121
+ useEffect(() => {
122
+ if (isUndefined(activeKey)) return;
123
+ const tab = tabRefs.current.get(activeKey);
124
+ animateIndicator(indicatorRef.current, {
125
+ left: tab?.offsetLeft,
126
+ width: tab?.clientWidth
127
+ });
128
+ // eslint-disable-next-line react-hooks/exhaustive-deps
129
+ }, [activeKey]);
130
+ return React.createElement("div", {
131
+ role: "tablist",
132
+ className: clsx(classNames[TabsClassToken.TabsNavigation], styled.navigation.className),
133
+ style: styled.navigation.style
134
+ }, React.createElement("div", {
135
+ ref: navigatorRef,
136
+ className: clsx(classNames[TabsClassToken.TabsNavigator], styled.navigator.className),
137
+ style: styled.navigator.style
138
+ }, React.createElement("div", {
139
+ ref: tabsRef,
140
+ className: clsx(classNames[TabsClassToken.TabList], styled.list.className),
141
+ style: styled.list.style
142
+ }, items.map(item => {
143
+ return React.createElement(Tab, {
144
+ key: item.key,
145
+ value: item.key,
146
+ label: item.label,
147
+ onClick: onChange,
148
+ ref: _tab => {
149
+ tabRefs.current.set(item.key, _tab);
150
+ }
151
+ });
152
+ }), React.createElement("div", {
153
+ ref: indicatorRef,
154
+ className: clsx(classNames[TabsClassToken.Indicator], styled.indicator.className),
155
+ style: styled.indicator.style
156
+ }))), React.createElement("div", null));
157
+ };
158
+
159
+ export { Navigation as default };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type PanelsProps } from "./types";
3
+ declare const Panels: ({ forceRender, destroyable, activatedKeys }: PanelsProps) => React.JSX.Element;
4
+ export default Panels;
@@ -0,0 +1,78 @@
1
+ import React, { useMemo } from 'react';
2
+ import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.js';
3
+ import { useClassNames } from '../../hooks/use-class-names.js';
4
+ import { ComponentToken, TabsClassToken } from '../../utils/class-name.js';
5
+ import clsx from 'clsx';
6
+ import { isUndefined, isVoid } from '@aiszlab/relax';
7
+ import { useTabsContext } from './hooks.js';
8
+
9
+ const styles = {
10
+ panels: {
11
+ default: {
12
+ marginTop: "musae-u5ntsc",
13
+ $$css: true
14
+ }
15
+ },
16
+ panel: {
17
+ default: {
18
+ $$css: true
19
+ },
20
+ active: {
21
+ display: null,
22
+ $$css: true
23
+ },
24
+ hidden: {
25
+ display: "musae-1s85apg",
26
+ $$css: true
27
+ }
28
+ }
29
+ };
30
+ const Panels = ({
31
+ forceRender,
32
+ destroyable,
33
+ activatedKeys
34
+ }) => {
35
+ const {
36
+ items,
37
+ activeKey
38
+ } = useTabsContext();
39
+ const classNames = useClassNames(ComponentToken.Tabs);
40
+ const styled = {
41
+ panels: _stylex.props(styles.panels.default),
42
+ panel: {
43
+ active: _stylex.props(styles.panel.default, styles.panel.active),
44
+ hidden: _stylex.props(styles.panel.default, styles.panel.hidden)
45
+ }
46
+ };
47
+ const panels = useMemo(() => {
48
+ if (isUndefined(activeKey)) {
49
+ return [];
50
+ }
51
+ if (destroyable) {
52
+ return [[activeKey, items.find(item => item.key === activeKey)?.children]];
53
+ }
54
+ if (forceRender) {
55
+ return items.map(item => [item.key, item.children]);
56
+ }
57
+ return items.map(item => [item.key, activatedKeys.has(item.key) ? item.children : null]);
58
+ }, [destroyable, forceRender, items, activeKey, activatedKeys]);
59
+ return React.createElement("div", {
60
+ className: clsx(classNames[TabsClassToken.Panels], styled.panels.className),
61
+ style: styled.panels.style
62
+ }, panels.map(([key, children]) => {
63
+ const {
64
+ className,
65
+ style
66
+ } = key === activeKey ? styled.panel.active : styled.panel.hidden;
67
+ if (isVoid(children)) {
68
+ return null;
69
+ }
70
+ return React.createElement("div", {
71
+ key: key,
72
+ className: clsx(classNames[TabsClassToken.Panel], className),
73
+ style: style
74
+ }, children);
75
+ }));
76
+ };
77
+
78
+ export { Panels as default };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { TabItemProps } from "./types";
3
+ declare const Tab: React.ForwardRefExoticComponent<TabItemProps & React.RefAttributes<HTMLButtonElement>>;
4
+ export default Tab;
@@ -0,0 +1,19 @@
1
+ import React, { forwardRef, useContext, useCallback } from 'react';
2
+ import Button from '../button/button.js';
3
+ import Context from './context.js';
4
+ import { useClassNames } from '../../hooks/use-class-names.js';
5
+ import { ComponentToken, TabsClassToken } from '../../utils/class-name.js';
6
+
7
+ const Tab = forwardRef(({ value, onClick, label }, ref) => {
8
+ const { activeKey } = useContext(Context) ?? {};
9
+ const isActive = activeKey === value;
10
+ const classNames = useClassNames(ComponentToken.Tabs);
11
+ const click = useCallback(() => {
12
+ onClick(value);
13
+ }, [onClick, value]);
14
+ return (React.createElement(Button, { variant: "text", color: isActive ? "primary" : "secondary", ref: ref, onClick: click, className: classNames[TabsClassToken.Tab], ripple: false, style: {
15
+ borderRadius: "10% 10% 0 0",
16
+ } }, label));
17
+ });
18
+
19
+ export { Tab as default };
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { TabsProps } from "./types";
3
- declare const Tabs: ({ items, className, style, ...props }: TabsProps) => React.JSX.Element | null;
3
+ declare const Tabs: ({ items, className, style, activeKey: _activeKey, defaultActiveKey, forceRender, destroyable, }: TabsProps) => React.JSX.Element | null;
4
4
  export default Tabs;