@canlooks/can-ui 0.0.58 → 0.0.59

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 (33) hide show
  1. package/dist/cjs/components/avatar/avatarGroup.js +1 -1
  2. package/dist/cjs/components/bottomNavigation/bottomNavigation.js +9 -8
  3. package/dist/cjs/components/breadcrumb/breadcrumb.js +8 -7
  4. package/dist/cjs/components/checkboxBaseGroup/checkboxBaseGroup.js +10 -9
  5. package/dist/cjs/components/menu/menu.js +8 -7
  6. package/dist/cjs/components/segmented/segmented.js +11 -10
  7. package/dist/cjs/components/select/select.style.js +1 -1
  8. package/dist/cjs/components/stepper/stepper.js +10 -9
  9. package/dist/cjs/components/tabs/lineIndicator.d.ts +1 -2
  10. package/dist/cjs/components/tabs/lineIndicator.js +10 -8
  11. package/dist/cjs/components/tabs/tab.js +4 -4
  12. package/dist/cjs/components/tabs/tabs.d.ts +2 -5
  13. package/dist/cjs/components/tabs/tabs.js +31 -27
  14. package/dist/cjs/components/tabs/tabs.style.js +1 -1
  15. package/dist/cjs/components/timeline/timeline.js +10 -9
  16. package/dist/cjs/components/toggleButton/toggleButton.js +6 -5
  17. package/dist/esm/components/avatar/avatarGroup.js +1 -1
  18. package/dist/esm/components/bottomNavigation/bottomNavigation.js +3 -2
  19. package/dist/esm/components/breadcrumb/breadcrumb.js +3 -2
  20. package/dist/esm/components/checkboxBaseGroup/checkboxBaseGroup.js +3 -2
  21. package/dist/esm/components/menu/menu.js +2 -1
  22. package/dist/esm/components/segmented/segmented.js +3 -2
  23. package/dist/esm/components/select/select.style.js +1 -1
  24. package/dist/esm/components/stepper/stepper.js +3 -2
  25. package/dist/esm/components/tabs/lineIndicator.d.ts +1 -2
  26. package/dist/esm/components/tabs/lineIndicator.js +10 -8
  27. package/dist/esm/components/tabs/tab.js +4 -4
  28. package/dist/esm/components/tabs/tabs.d.ts +2 -5
  29. package/dist/esm/components/tabs/tabs.js +16 -12
  30. package/dist/esm/components/tabs/tabs.style.js +1 -1
  31. package/dist/esm/components/timeline/timeline.js +2 -1
  32. package/dist/esm/components/toggleButton/toggleButton.js +2 -1
  33. package/package.json +1 -1
@@ -18,7 +18,7 @@ exports.AvatarGroup = (0, react_2.memo)(({ color, size, shape = 'circular', imgP
18
18
  const isSurplus = total > max;
19
19
  const renderItems = () => {
20
20
  if (items?.length) {
21
- return items.slice(0, isSurplus ? max - 1 : max).reverse().map((p, i) => (0, react_1.createElement)(avatar_1.Avatar, { ...commonProps, key: p.key ?? i, color: p.color, size: p.size, shape: p.shape, src: p.src, imgProps: p.imgProps }, p.children));
21
+ return items.slice(0, isSurplus ? max - 1 : max).reverse().map((p, i) => (0, react_1.createElement)(avatar_1.Avatar, { ...commonProps, ...p, key: p.key ?? i }, p.children));
22
22
  }
23
23
  return react_2.Children.toArray(props.children).slice(0, isSurplus ? max - 1 : max).reverse().map(child => {
24
24
  return (0, react_2.isValidElement)(child)
@@ -2,27 +2,28 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BottomNavigation = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
- const react_1 = require("react");
5
+ const react_1 = require("@emotion/react");
6
+ const react_2 = require("react");
6
7
  const bottomNavigation_style_1 = require("./bottomNavigation.style");
7
8
  const utils_1 = require("../../utils");
8
9
  const bottomNavigationItem_1 = require("./bottomNavigationItem");
9
- exports.BottomNavigation = (0, react_1.memo)(({ items, showLabelInactive, primaryKey = 'value', labelKey = 'label', defaultValue = 'children', value, onChange, ...props }) => {
10
+ exports.BottomNavigation = (0, react_2.memo)(({ items, showLabelInactive, primaryKey = 'value', labelKey = 'label', defaultValue = 'children', value, onChange, ...props }) => {
10
11
  const [innerValue, setInnerValue] = (0, utils_1.useControlled)(defaultValue, value, onChange);
11
12
  const renderItems = () => {
12
13
  if (items) {
13
14
  return items.map((p, i) => {
14
15
  const itemValue = p[primaryKey];
15
- return ((0, jsx_runtime_1.jsx)(bottomNavigationItem_1.BottomNavigationItem, { value: itemValue, icon: p.icon, label: p[labelKey], showLabelInactive: p.showLabelInactive ?? showLabelInactive ?? items.length <= 3, active: !(0, utils_1.isUnset)(itemValue) && innerValue.current === itemValue, onClick: e => {
16
+ return ((0, react_1.createElement)(bottomNavigationItem_1.BottomNavigationItem, { ...p, key: p.key ?? itemValue ?? i, value: itemValue, label: p[labelKey], showLabelInactive: p.showLabelInactive ?? showLabelInactive ?? items.length <= 3, active: !(0, utils_1.isUnset)(itemValue) && innerValue.current === itemValue, onClick: e => {
16
17
  p.onClick?.(e);
17
18
  setInnerValue(itemValue);
18
- } }, p.key ?? itemValue ?? i));
19
+ } }));
19
20
  });
20
21
  }
21
- showLabelInactive ??= react_1.Children.count(props.children) <= 3;
22
- return react_1.Children.map(props.children, c => {
23
- if ((0, react_1.isValidElement)(c)) {
22
+ showLabelInactive ??= react_2.Children.count(props.children) <= 3;
23
+ return react_2.Children.map(props.children, c => {
24
+ if ((0, react_2.isValidElement)(c)) {
24
25
  const { props } = c;
25
- return (0, react_1.cloneElement)(c, {
26
+ return (0, react_2.cloneElement)(c, {
26
27
  showLabelInactive: props.showLabelInactive ?? showLabelInactive,
27
28
  active: !(0, utils_1.isUnset)(props.value) && innerValue.current === props.value,
28
29
  onClick: e => {
@@ -2,32 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Breadcrumb = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
- const react_1 = require("react");
5
+ const react_1 = require("@emotion/react");
6
+ const react_2 = require("react");
6
7
  const utils_1 = require("../../utils");
7
8
  const breadcrumb_style_1 = require("./breadcrumb.style");
8
9
  const button_1 = require("../button");
9
10
  const theme_1 = require("../theme");
10
- exports.Breadcrumb = (0, react_1.memo)(({ separator = '/', readOnly, items, ...props }) => {
11
+ exports.Breadcrumb = (0, react_2.memo)(({ separator = '/', readOnly, items, ...props }) => {
11
12
  const { text } = (0, theme_1.useTheme)();
12
13
  const renderItems = () => {
13
14
  if (items) {
14
- return items.flatMap(({ icon, label, ...p }, i) => {
15
+ return items.flatMap(({ icon, ...p }, i) => {
15
16
  const isLast = i === items.length - 1;
16
17
  return [
17
- (0, jsx_runtime_1.jsx)(button_1.Button, { ref: p.ref, shape: p.shape, size: p.size, suffix: p.suffix, loading: p.loading, label: label, variant: p.variant ?? 'plain', color: p.color ?? (isLast ? text.primary : text.disabled), readOnly: p.readOnly ?? (isLast || readOnly), prefix: p.prefix ?? icon, children: p.children }, p.key ?? i),
18
+ (0, react_1.createElement)(button_1.Button, { ...p, key: p.key ?? i, variant: p.variant ?? 'plain', color: p.color ?? (isLast ? text.primary : text.disabled), readOnly: p.readOnly ?? (isLast || readOnly), prefix: p.prefix ?? icon }, p.children),
18
19
  ...isLast ? [] : [
19
20
  (0, jsx_runtime_1.jsx)("span", { className: breadcrumb_style_1.classes.separator, children: separator }, `${breadcrumb_style_1.classes.separator}_${i}`)
20
21
  ]
21
22
  ];
22
23
  });
23
24
  }
24
- const childrenArr = react_1.Children.toArray(props.children);
25
+ const childrenArr = react_2.Children.toArray(props.children);
25
26
  return childrenArr.flatMap((c, i) => {
26
27
  const isLast = i === childrenArr.length - 1;
27
28
  const ret = [];
28
- if ((0, react_1.isValidElement)(c)) {
29
+ if ((0, react_2.isValidElement)(c)) {
29
30
  const { props } = c;
30
- ret.push((0, react_1.cloneElement)(c, {
31
+ ret.push((0, react_2.cloneElement)(c, {
31
32
  variant: props.variant ?? 'plain',
32
33
  color: props.color ?? (isLast ? text.primary : text.disabled),
33
34
  readOnly: props.readOnly ?? (isLast || readOnly),
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CheckboxBaseGroup = void 0;
4
4
  exports.useCheckboxBaseGroupContext = useCheckboxBaseGroupContext;
5
5
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
6
- const react_1 = require("react");
6
+ const react_1 = require("@emotion/react");
7
+ const react_2 = require("react");
7
8
  const flex_1 = require("../flex");
8
9
  const utils_1 = require("../../utils");
9
10
  const checkboxBaseGroup_style_1 = require("./checkboxBaseGroup.style");
@@ -11,9 +12,9 @@ const checkbox_1 = require("../checkbox");
11
12
  const radio_1 = require("../radio");
12
13
  const theme_1 = require("../theme");
13
14
  const selectionContext_1 = require("../selectionContext");
14
- const CheckboxBaseGroupContext = (0, react_1.createContext)({});
15
+ const CheckboxBaseGroupContext = (0, react_2.createContext)({});
15
16
  function useCheckboxBaseGroupContext() {
16
- return (0, react_1.useContext)(CheckboxBaseGroupContext);
17
+ return (0, react_2.useContext)(CheckboxBaseGroupContext);
17
18
  }
18
19
  exports.CheckboxBaseGroup = (({ size, color, items, primaryKey = 'value', multiple, defaultValue, value, onChange, ...props }) => {
19
20
  const { spacing } = (0, theme_1.useTheme)();
@@ -23,19 +24,19 @@ exports.CheckboxBaseGroup = (({ size, color, items, primaryKey = 'value', multip
23
24
  return items.map((p, i) => {
24
25
  const Component = multiple ? checkbox_1.Checkbox : radio_1.Radio;
25
26
  const itemValue = p[primaryKey];
26
- return ((0, jsx_runtime_1.jsx)(Component, { inputProps: p.inputProps, label: p.label, indeterminate: p.indeterminate, disabled: p.disabled, readOnly: p.readOnly, size: p.size ?? size, color: p.color ?? color, checked: (0, utils_1.isSelected)(itemValue, innerValue), onChange: e => {
27
+ return ((0, react_1.createElement)(Component, { ...p, key: p.key ?? itemValue ?? i, size: p.size ?? size, color: p.color ?? color, checked: (0, utils_1.isSelected)(itemValue, innerValue), onChange: e => {
27
28
  p.onChange?.(e);
28
29
  toggleSelected(itemValue);
29
- } }, p.key ?? itemValue ?? i));
30
+ } }));
30
31
  });
31
32
  }
32
- return react_1.Children.map(props.children, c => {
33
- if (!(0, react_1.isValidElement)(c)) {
33
+ return react_2.Children.map(props.children, c => {
34
+ if (!(0, react_2.isValidElement)(c)) {
34
35
  return c;
35
36
  }
36
37
  const { props } = c;
37
38
  const itemValue = props.value;
38
- return (0, react_1.cloneElement)(c, {
39
+ return (0, react_2.cloneElement)(c, {
39
40
  size: props.size ?? size,
40
41
  color: props.color ?? color,
41
42
  checked: (0, utils_1.isSelected)(itemValue, innerValue),
@@ -46,5 +47,5 @@ exports.CheckboxBaseGroup = (({ size, color, items, primaryKey = 'value', multip
46
47
  });
47
48
  });
48
49
  };
49
- return ((0, jsx_runtime_1.jsx)(flex_1.Flex, { gap: spacing[8], ...props, className: (0, utils_1.clsx)(checkboxBaseGroup_style_1.classes.root, props.className), children: (0, jsx_runtime_1.jsx)(CheckboxBaseGroupContext, { value: (0, react_1.useMemo)(() => ({ size, color }), [size, color]), children: renderItems() }) }));
50
+ return ((0, jsx_runtime_1.jsx)(flex_1.Flex, { gap: spacing[8], ...props, className: (0, utils_1.clsx)(checkboxBaseGroup_style_1.classes.root, props.className), children: (0, jsx_runtime_1.jsx)(CheckboxBaseGroupContext, { value: (0, react_2.useMemo)(() => ({ size, color }), [size, color]), children: renderItems() }) }));
50
51
  });
@@ -3,23 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Menu = void 0;
4
4
  exports.useMenuContext = useMenuContext;
5
5
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
6
- const react_1 = require("react");
6
+ const react_1 = require("@emotion/react");
7
+ const react_2 = require("react");
7
8
  const menu_style_1 = require("./menu.style");
8
9
  const menuItem_1 = require("../menuItem");
9
10
  const utils_1 = require("../../utils");
10
11
  const theme_1 = require("../theme");
11
12
  const selectionContext_1 = require("../selectionContext");
12
- const MenuContext = (0, react_1.createContext)({});
13
+ const MenuContext = (0, react_2.createContext)({});
13
14
  function useMenuContext() {
14
15
  const theme = (0, theme_1.useTheme)();
15
- const { size = theme.size, ellipsis = true, indent = theme.spacing[8], ...context } = (0, react_1.useContext)(MenuContext);
16
+ const { size = theme.size, ellipsis = true, indent = theme.spacing[8], ...context } = (0, react_2.useContext)(MenuContext);
16
17
  return { size, ellipsis, indent, ...context };
17
18
  }
18
- exports.Menu = (0, react_1.memo)(({ items, primaryKey = 'value', labelKey = 'label', childrenKey = 'children', defaultExpanded = [], expanded, onExpandedChange, multiple, defaultValue, value, onChange,
19
+ exports.Menu = (0, react_2.memo)(({ items, primaryKey = 'value', labelKey = 'label', childrenKey = 'children', defaultExpanded = [], expanded, onExpandedChange, multiple, defaultValue, value, onChange,
19
20
  // 以下属性传递给<MenuItem/>
20
21
  size = 'large', showCheckbox, ellipsis, indent, ...props }) => {
21
22
  const [innerExpanded, setInnerExpanded] = (0, utils_1.useControlled)(defaultExpanded, expanded);
22
- const expandedSet = (0, react_1.useMemo)(() => {
23
+ const expandedSet = (0, react_2.useMemo)(() => {
23
24
  return new Set(innerExpanded.current);
24
25
  }, [innerExpanded.current]);
25
26
  const setExpanded = (key, isExpand) => {
@@ -31,9 +32,9 @@ size = 'large', showCheckbox, ellipsis, indent, ...props }) => {
31
32
  };
32
33
  const [innerValue, toggleSelected] = (0, selectionContext_1.useShallowSelection)({ multiple, defaultValue, value, onChange });
33
34
  const renderItems = (items) => {
34
- return items?.map((p, i) => (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { size: p.size, color: p.color, emphasized: p.emphasized, selected: p.selected, focused: p.focused, disabled: p.disabled, showCheckbox: p.showCheckbox, checkboxProps: p.checkboxProps, ellipsis: p.ellipsis, prefix: p.prefix, suffix: p.suffix, indent: p.indent, expandIcon: p.expandIcon, onExpandedChange: p.onExpandedChange, value: p[primaryKey], label: p[labelKey], children: renderItems(p[childrenKey]) }, p[primaryKey] ?? i));
35
+ return items?.map((p, i) => (0, react_1.createElement)(menuItem_1.MenuItem, { ...p, key: p[primaryKey] ?? i, value: p[primaryKey], label: p[labelKey] }, renderItems(p[childrenKey])));
35
36
  };
36
- return ((0, jsx_runtime_1.jsx)("div", { ...props, css: menu_style_1.style, children: (0, jsx_runtime_1.jsx)(MenuContext, { value: (0, react_1.useMemo)(() => ({
37
+ return ((0, jsx_runtime_1.jsx)("div", { ...props, css: menu_style_1.style, children: (0, jsx_runtime_1.jsx)(MenuContext, { value: (0, react_2.useMemo)(() => ({
37
38
  inMenu: true,
38
39
  expandedSet, setExpanded, multiple, selected: innerValue, toggleSelected,
39
40
  size, showCheckbox, ellipsis, indent
@@ -2,15 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Segmented = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
- const react_1 = require("react");
5
+ const react_1 = require("@emotion/react");
6
+ const react_2 = require("react");
6
7
  const segmented_style_1 = require("./segmented.style");
7
8
  const utils_1 = require("../../utils");
8
9
  const SegmentedOption_1 = require("./SegmentedOption");
9
10
  const theme_1 = require("../theme");
10
- exports.Segmented = (0, react_1.memo)(({ options, orientation = 'horizontal', size, labelKey = 'label', primaryKey = 'value', fullWidth, indicatorColor = 'background.content', defaultValue, value, onChange, readOnly, disabled, ...props }) => {
11
+ exports.Segmented = (0, react_2.memo)(({ options, orientation = 'horizontal', size, labelKey = 'label', primaryKey = 'value', fullWidth, indicatorColor = 'background.content', defaultValue, value, onChange, readOnly, disabled, ...props }) => {
11
12
  const theme = (0, theme_1.useTheme)();
12
13
  size ??= theme.size;
13
- const [animating, setAnimating] = (0, react_1.useState)(false);
14
+ const [animating, setAnimating] = (0, react_2.useState)(false);
14
15
  const [innerValue, _setInnerValue] = (0, utils_1.useControlled)(defaultValue, value, onChange);
15
16
  const setInnerValue = (value) => {
16
17
  if (!readOnly && !disabled) {
@@ -18,7 +19,7 @@ exports.Segmented = (0, react_1.memo)(({ options, orientation = 'horizontal', si
18
19
  _setInnerValue(value);
19
20
  }
20
21
  };
21
- const optionRefs = (0, react_1.useRef)(new Map());
22
+ const optionRefs = (0, react_2.useRef)(new Map());
22
23
  /**
23
24
  * 计算指示器的位置
24
25
  */
@@ -40,7 +41,7 @@ exports.Segmented = (0, react_1.memo)(({ options, orientation = 'horizontal', si
40
41
  };
41
42
  };
42
43
  const [indicatorRect, setIndicatorRect] = (0, utils_1.useDerivedState)(fitIndicatorRect, [innerValue.current]);
43
- (0, react_1.useEffect)(() => {
44
+ (0, react_2.useEffect)(() => {
44
45
  // 仅首次渲染需要计算
45
46
  setIndicatorRect(fitIndicatorRect());
46
47
  }, []);
@@ -49,21 +50,21 @@ exports.Segmented = (0, react_1.memo)(({ options, orientation = 'horizontal', si
49
50
  return options.map((p, i) => {
50
51
  const v = p[primaryKey];
51
52
  const active = !(0, utils_1.isUnset)(v) && v === innerValue.current;
52
- return ((0, jsx_runtime_1.jsx)(SegmentedOption_1.SegmentedOption, { orientation: p.orientation, prefix: p.prefix, suffix: p.suffix, disabled: p.disabled, ref: r => {
53
+ return ((0, react_1.createElement)(SegmentedOption_1.SegmentedOption, { ...p, key: p.key ?? v ?? i, ref: r => {
53
54
  r
54
55
  ? optionRefs.current.set(v, r)
55
56
  : optionRefs.current.delete(v);
56
57
  }, value: v, label: p[labelKey], onClick: e => {
57
58
  p.onClick?.(e);
58
59
  setInnerValue(v);
59
- }, "data-active": active }, p.key ?? v ?? i));
60
+ }, "data-active": active }));
60
61
  });
61
62
  }
62
- return react_1.Children.map(props.children, c => {
63
- if ((0, react_1.isValidElement)(c)) {
63
+ return react_2.Children.map(props.children, c => {
64
+ if ((0, react_2.isValidElement)(c)) {
64
65
  const { value } = c.props;
65
66
  const active = !(0, utils_1.isUnset)(value) && value === innerValue.current;
66
- return (0, react_1.cloneElement)(c, {
67
+ return (0, react_2.cloneElement)(c, {
67
68
  ref: (0, utils_1.cloneRef)(c.ref, (r) => {
68
69
  !(0, utils_1.isUnset)(value) && optionRefs.current.set(value, r);
69
70
  }),
@@ -18,7 +18,7 @@ exports.style = (0, utils_1.defineCss)(({ spacing, text, easing }) => (0, react_
18
18
  .${exports.classes.contentWrap} {
19
19
  display: flex;
20
20
  align-items: center;
21
- gap: ${spacing[1]}px;
21
+ gap: ${spacing[2]}px;
22
22
  }
23
23
 
24
24
  .${exports.classes.placeholder} {
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Stepper = void 0;
4
4
  exports.useStepperContext = useStepperContext;
5
5
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
6
- const react_1 = require("react");
6
+ const react_1 = require("@emotion/react");
7
+ const react_2 = require("react");
7
8
  const utils_1 = require("../../utils");
8
9
  const stepper_style_1 = require("./stepper.style");
9
10
  const step_1 = require("./step");
10
- const StepperContext = (0, react_1.createContext)({});
11
+ const StepperContext = (0, react_2.createContext)({});
11
12
  function useStepperContext() {
12
- return (0, react_1.useContext)(StepperContext);
13
+ return (0, react_2.useContext)(StepperContext);
13
14
  }
14
15
  exports.Stepper = (({ steps, orientation = 'horizontal', defaultValue = 0, value, onChange,
15
16
  // 以下为共享属性
@@ -19,21 +20,21 @@ size, gap = orientation === 'horizontal' ? 15 : 9, color, variant, clickable, la
19
20
  if (steps) {
20
21
  return steps.map((p, i) => {
21
22
  const isCurrentStep = i === innerValue.current;
22
- return ((0, jsx_runtime_1.jsx)(step_1.Step, { indicator: p.indicator, title: p.title, prefix: p.prefix, suffix: p.suffix, description: p.description, size: p.size, gap: p.gap, color: p.color, variant: p.variant, labelPlacement: p.labelPlacement, step: i, status: p.status ?? (isCurrentStep
23
+ return ((0, react_1.createElement)(step_1.Step, { ...p, key: p.key ?? i, step: i, status: p.status ?? (isCurrentStep
23
24
  ? status ?? 'processing'
24
25
  : i < innerValue.current
25
26
  ? 'finished'
26
27
  : 'waiting'), clickable: p.clickable ?? clickable, onClick: e => {
27
28
  p.onClick?.(e);
28
29
  (p.clickable ?? clickable) && setInnerValue(i);
29
- }, "data-orientation": orientation }, p.key ?? i));
30
+ }, "data-orientation": orientation }));
30
31
  });
31
32
  }
32
- return react_1.Children.map(props.children, (c, i) => {
33
- if ((0, react_1.isValidElement)(c)) {
33
+ return react_2.Children.map(props.children, (c, i) => {
34
+ if ((0, react_2.isValidElement)(c)) {
34
35
  const isCurrentStep = i === innerValue.current;
35
36
  const { props } = c;
36
- return (0, react_1.cloneElement)(c, {
37
+ return (0, react_2.cloneElement)(c, {
37
38
  step: props.step ?? i,
38
39
  status: props.status ?? (isCurrentStep
39
40
  ? status ?? 'processing'
@@ -53,7 +54,7 @@ size, gap = orientation === 'horizontal' ? 15 : 9, color, variant, clickable, la
53
54
  return ((0, jsx_runtime_1.jsx)("div", { ...props, css: stepper_style_1.style, className: (0, utils_1.clsx)(stepper_style_1.classes.root, props.className), "data-orientation": orientation, style: {
54
55
  gap,
55
56
  ...props.style
56
- }, children: (0, jsx_runtime_1.jsx)(StepperContext, { value: (0, react_1.useMemo)(() => ({
57
+ }, children: (0, jsx_runtime_1.jsx)(StepperContext, { value: (0, react_2.useMemo)(() => ({
57
58
  size, gap, color, variant, clickable, labelPlacement
58
59
  }), [
59
60
  size, gap, color, variant, clickable, labelPlacement
@@ -1,8 +1,7 @@
1
- import { ActiveTabRef } from './tabs';
2
1
  import { Id } from '../../types';
3
2
  export declare function LineIndicator({ value, position, getActiveTab, onTransitionEnd }: {
4
3
  value?: Id;
5
4
  position: 'top' | 'bottom' | 'left' | 'right';
6
- getActiveTab(): ActiveTabRef | undefined;
5
+ getActiveTab(): HTMLDivElement | undefined;
7
6
  onTransitionEnd(): void;
8
7
  }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -6,19 +6,21 @@ const react_1 = require("react");
6
6
  const tabs_style_1 = require("./tabs.style");
7
7
  const utils_1 = require("../../utils");
8
8
  const theme_1 = require("../theme");
9
+ const tabs_1 = require("./tabs");
9
10
  function LineIndicator({ value, position, getActiveTab, onTransitionEnd }) {
11
+ const context = (0, tabs_1.useTabsContext)();
12
+ const [color, setColor] = (0, react_1.useState)(context.color);
10
13
  const [boundingRect, setBoundingRect] = (0, react_1.useState)();
11
- const [color, setColor] = (0, react_1.useState)('primary');
12
14
  (0, react_1.useEffect)(() => {
13
- const { el, color } = getActiveTab() || {};
14
- if (!el) {
15
+ const activeTab = getActiveTab();
16
+ if (!activeTab) {
15
17
  return;
16
18
  }
17
19
  if (position === 'top' || position === 'bottom') {
18
20
  setBoundingRect({
19
- width: el.offsetWidth,
21
+ width: activeTab.offsetWidth,
20
22
  height: tabs_style_1.indicatorWidth,
21
- left: el.offsetLeft,
23
+ left: activeTab.offsetLeft,
22
24
  ...position === 'top'
23
25
  ? { bottom: 0 }
24
26
  : { top: 0 }
@@ -28,14 +30,14 @@ function LineIndicator({ value, position, getActiveTab, onTransitionEnd }) {
28
30
  // position === 'left' || position === 'right'
29
31
  setBoundingRect({
30
32
  width: tabs_style_1.indicatorWidth,
31
- height: el.offsetHeight,
32
- top: el.offsetTop,
33
+ height: activeTab.offsetHeight,
34
+ top: activeTab.offsetTop,
33
35
  ...position === 'left'
34
36
  ? { right: 0 }
35
37
  : { left: 0 }
36
38
  });
37
39
  }
38
- setColor(color);
40
+ activeTab.dataset.color && setColor(activeTab.dataset.color);
39
41
  }, [value]);
40
42
  const theme = (0, theme_1.useTheme)();
41
43
  return ((0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.indicator, onTransitionEnd: onTransitionEnd, style: {
@@ -6,14 +6,14 @@ const react_1 = require("react");
6
6
  const utils_1 = require("../../utils");
7
7
  const tabs_style_1 = require("./tabs.style");
8
8
  const tabs_1 = require("./tabs");
9
- exports.Tab = (0, react_1.memo)(({ prefix, suffix, color = 'primary', orientation, label, value, disabled, _active, ...props }) => {
10
- const colorValue = (0, utils_1.useColor)(color);
11
- const { variant, animating } = (0, tabs_1.useTabsContext)();
9
+ exports.Tab = (0, react_1.memo)(({ prefix, suffix, color, orientation, label, value, disabled, _active, ...props }) => {
10
+ const { color: contextColor, variant, animating } = (0, tabs_1.useTabsContext)();
11
+ const colorValue = (0, utils_1.useColor)(color ?? contextColor);
12
12
  return ((0, jsx_runtime_1.jsxs)("div", { ...props, className: (0, utils_1.clsx)(tabs_style_1.classes.tab, props.className), style: {
13
13
  borderColor: variant === 'line' && !animating && _active ? colorValue : void 0,
14
14
  color: _active ? colorValue : void 0,
15
15
  ...props.style
16
- }, "data-disabled": disabled, "data-orientation": orientation, "data-active": _active, onClick: e => {
16
+ }, "data-color": colorValue, "data-disabled": disabled, "data-orientation": orientation, "data-active": _active, onClick: e => {
17
17
  !disabled && props.onClick?.(e);
18
18
  }, children: [!!prefix &&
19
19
  (0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.tabPrefix, children: prefix }), (0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.label, children: label }), !!suffix &&
@@ -9,7 +9,7 @@ export interface TabsProps<T extends TabType = TabType> extends Omit<DivProps, '
9
9
  variant?: 'line' | 'card';
10
10
  color?: ColorPropsValue;
11
11
  size?: Size;
12
- /**选项卡的位置,默认为`top` */
12
+ /** 选项卡的位置,默认为`top` */
13
13
  position?: 'top' | 'bottom' | 'left' | 'right';
14
14
  justifyContent?: CSSProperties['justifyContent'];
15
15
  fullWidth?: boolean;
@@ -21,11 +21,8 @@ export interface TabsProps<T extends TabType = TabType> extends Omit<DivProps, '
21
21
  readOnly?: boolean;
22
22
  disabled?: boolean;
23
23
  }
24
- export type ActiveTabRef = {
25
- el: HTMLElement | null;
26
- color: string;
27
- };
28
24
  export declare function useTabsContext(): {
25
+ color?: ColorPropsValue;
29
26
  variant?: TabsProps["variant"];
30
27
  animating?: boolean;
31
28
  };
@@ -3,21 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Tabs = void 0;
4
4
  exports.useTabsContext = useTabsContext;
5
5
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
6
- const react_1 = require("react");
6
+ const react_1 = require("@emotion/react");
7
+ const react_2 = require("react");
7
8
  const tabs_style_1 = require("./tabs.style");
8
9
  const utils_1 = require("../../utils");
9
10
  const theme_1 = require("../theme");
10
11
  const tab_1 = require("./tab");
11
12
  const tabsEllipsis_1 = require("./tabsEllipsis");
12
13
  const lineIndicator_1 = require("./lineIndicator");
13
- const TabsContext = (0, react_1.createContext)({});
14
+ const TabsContext = (0, react_2.createContext)({});
14
15
  function useTabsContext() {
15
- return (0, react_1.useContext)(TabsContext);
16
+ return (0, react_2.useContext)(TabsContext);
16
17
  }
17
- exports.Tabs = (0, react_1.memo)(({ tabs, labelKey = 'label', primaryKey = 'value', variant = 'line', color = 'primary', size, position = 'top', justifyContent = 'flex-start', fullWidth, prefix, suffix, defaultValue, value, onChange, readOnly, disabled, ...props }) => {
18
+ exports.Tabs = (0, react_2.memo)(({ tabs, labelKey = 'label', primaryKey = 'value', variant = 'line', color = 'primary', size, position = 'top', justifyContent = 'flex-start', fullWidth, prefix, suffix, defaultValue, value, onChange, readOnly, disabled, ...props }) => {
18
19
  const theme = (0, theme_1.useTheme)();
19
20
  size ??= theme.size;
20
- const [animating, setAnimating] = (0, react_1.useState)(false); // TODO 应当考虑value受控的情况,参考anchorList组件
21
+ const [animating, setAnimating] = (0, react_2.useState)(false); // TODO 应当考虑value受控的情况,参考anchorList组件
21
22
  const [innerValue, _setInnerValue] = (0, utils_1.useControlled)(defaultValue, value, onChange);
22
23
  const setInnerValue = (value) => {
23
24
  if (!readOnly && !disabled) {
@@ -29,7 +30,7 @@ exports.Tabs = (0, react_1.memo)(({ tabs, labelKey = 'label', primaryKey = 'valu
29
30
  shouldScroll.current = true;
30
31
  setInnerValue(value);
31
32
  };
32
- const tabRefs = (0, react_1.useRef)(new Map());
33
+ const tabRefs = (0, react_2.useRef)(new Map());
33
34
  const getActiveTab = () => {
34
35
  return (0, utils_1.isUnset)(innerValue.current) ? void 0 : tabRefs.current.get(innerValue.current);
35
36
  };
@@ -38,26 +39,25 @@ exports.Tabs = (0, react_1.memo)(({ tabs, labelKey = 'label', primaryKey = 'valu
38
39
  return tabs.map((p, i) => {
39
40
  const value = p[primaryKey];
40
41
  const active = !(0, utils_1.isUnset)(value) && value === innerValue.current;
41
- return ((0, jsx_runtime_1.jsx)(tab_1.Tab, { prefix: p.prefix, suffix: p.suffix, color: p.color, orientation: p.orientation, disabled: p.disabled, ref: el => {
42
- tabRefs.current.set(value, { el, color: p.color || 'primary' });
43
- return () => {
44
- tabRefs.current.delete(value);
45
- };
42
+ return ((0, react_1.createElement)(tab_1.Tab, { ...p, key: p.key ?? value ?? i, ref: el => {
43
+ el
44
+ ? tabRefs.current.set(value, el)
45
+ : tabRefs.current.delete(value);
46
46
  }, value: value, label: p[labelKey], onClick: e => {
47
47
  p.onClick?.(e);
48
48
  setInnerValue(value);
49
- }, _active: active }, p.key ?? value ?? i));
49
+ }, _active: active }));
50
50
  });
51
51
  }
52
- return react_1.Children.map(props.children, c => {
53
- if ((0, react_1.isValidElement)(c)) {
54
- const { value, color, onClick } = c.props;
52
+ return react_2.Children.map(props.children, c => {
53
+ if ((0, react_2.isValidElement)(c)) {
54
+ const { value, onClick } = c.props;
55
55
  const active = !(0, utils_1.isUnset)(value) && value === innerValue.current;
56
- return (0, react_1.cloneElement)(c, {
56
+ return (0, react_2.cloneElement)(c, {
57
57
  ref: (0, utils_1.cloneRef)(c.ref, el => {
58
58
  if (!(0, utils_1.isUnset)(value)) {
59
59
  el
60
- ? tabRefs.current.set(value, { el, color: color || 'primary' })
60
+ ? tabRefs.current.set(value, el)
61
61
  : tabRefs.current.delete(value);
62
62
  }
63
63
  }),
@@ -75,9 +75,9 @@ exports.Tabs = (0, react_1.memo)(({ tabs, labelKey = 'label', primaryKey = 'valu
75
75
  * ----------------------------------------------------------------
76
76
  * 滚动
77
77
  */
78
- const scrollRef = (0, react_1.useRef)(null);
79
- const [shadowStart, setShadowStart] = (0, react_1.useState)(false);
80
- const [shadowEnd, setShadowEnd] = (0, react_1.useState)(false);
78
+ const scrollRef = (0, react_2.useRef)(null);
79
+ const [shadowStart, setShadowStart] = (0, react_2.useState)(false);
80
+ const [shadowEnd, setShadowEnd] = (0, react_2.useState)(false);
81
81
  const setShadow = () => {
82
82
  if (position === 'top' || position === 'bottom') {
83
83
  const { scrollLeft } = scrollRef.current;
@@ -90,7 +90,7 @@ exports.Tabs = (0, react_1.memo)(({ tabs, labelKey = 'label', primaryKey = 'valu
90
90
  setShadowEnd(scrollTop < scrollRef.current.scrollHeight - scrollRef.current.clientHeight);
91
91
  }
92
92
  };
93
- (0, react_1.useEffect)(() => {
93
+ (0, react_2.useEffect)(() => {
94
94
  const scroller = scrollRef.current;
95
95
  const onWheel = (e) => {
96
96
  scroller.scrollTo({
@@ -107,16 +107,20 @@ exports.Tabs = (0, react_1.memo)(({ tabs, labelKey = 'label', primaryKey = 'valu
107
107
  resizeObserver.disconnect();
108
108
  };
109
109
  }, [position]);
110
- const shouldScroll = (0, react_1.useRef)(true);
111
- (0, react_1.useEffect)(() => {
110
+ const shouldScroll = (0, react_2.useRef)(true);
111
+ (0, react_2.useEffect)(() => {
112
112
  if (shouldScroll.current) {
113
- getActiveTab()?.el?.scrollIntoView({ block: 'center', inline: 'center', behavior: 'smooth' });
113
+ getActiveTab()?.scrollIntoView({ block: 'center', inline: 'center', behavior: 'smooth' });
114
114
  shouldScroll.current = false;
115
115
  }
116
116
  }, [shouldScroll.current]);
117
- return ((0, jsx_runtime_1.jsxs)("div", { ...props, css: (0, tabs_style_1.useStyle)({ color: color || 'primary', variant }), className: (0, utils_1.clsx)(tabs_style_1.classes.root, props.className), "data-size": size, "data-position": position, "data-animating": animating, "data-full-width": fullWidth, "data-read-only": readOnly, "data-disabled": disabled, children: [(0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.start, "data-show": shadowStart, children: !!prefix &&
118
- (0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.prefix, children: prefix }) }), (0, jsx_runtime_1.jsx)("div", { ref: scrollRef, className: tabs_style_1.classes.scroll, onScroll: setShadow, children: (0, jsx_runtime_1.jsxs)("div", { className: tabs_style_1.classes.scrollWrap, style: { justifyContent }, children: [(0, jsx_runtime_1.jsx)(TabsContext, { value: (0, react_1.useMemo)(() => ({ variant, animating }), [variant, animating]), children: renderTabs() }), variant === 'line' &&
119
- (0, jsx_runtime_1.jsx)(lineIndicator_1.LineIndicator, { value: innerValue.current, position: position, getActiveTab: getActiveTab, onTransitionEnd: () => setAnimating(false) })] }) }), (0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.end, "data-show": shadowEnd, children: !!(suffix || shadowStart || shadowEnd) &&
117
+ return ((0, jsx_runtime_1.jsxs)("div", { ...props, css: (0, tabs_style_1.useStyle)({ color, variant }), className: (0, utils_1.clsx)(tabs_style_1.classes.root, props.className), "data-size": size, "data-position": position, "data-animating": animating, "data-full-width": fullWidth, "data-read-only": readOnly, "data-disabled": disabled, children: [(0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.start, "data-show": shadowStart, children: !!prefix &&
118
+ (0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.prefix, children: prefix }) }), (0, jsx_runtime_1.jsx)("div", { ref: scrollRef, className: tabs_style_1.classes.scroll, onScroll: setShadow, children: (0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.scrollWrap, style: { justifyContent }, children: (0, jsx_runtime_1.jsxs)(TabsContext, { value: (0, react_2.useMemo)(() => ({
119
+ color, variant, animating
120
+ }), [
121
+ color, variant, animating
122
+ ]), children: [renderTabs(), variant === 'line' &&
123
+ (0, jsx_runtime_1.jsx)(lineIndicator_1.LineIndicator, { value: innerValue.current, position: position, getActiveTab: getActiveTab, onTransitionEnd: () => setAnimating(false) })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: tabs_style_1.classes.end, "data-show": shadowEnd, children: !!(suffix || shadowStart || shadowEnd) &&
120
124
  (0, jsx_runtime_1.jsxs)("div", { className: tabs_style_1.classes.suffix, children: [(shadowStart || shadowEnd) &&
121
125
  (0, jsx_runtime_1.jsx)(tabsEllipsis_1.TabsEllipsis, { tabs: tabs, labelKey: labelKey, primaryKey: primaryKey, value: innerValue.current, onToggleSelected: setValueInEllipsis, children: props.children }), suffix] }) })] }));
122
126
  });
@@ -72,7 +72,7 @@ function useStyle({ color, variant }) {
72
72
  cursor: pointer;
73
73
 
74
74
  &:hover {
75
- color: ${colors.primary.main};
75
+ color: ${colorValue};
76
76
  }
77
77
  }
78
78
 
@@ -3,30 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Timeline = void 0;
4
4
  exports.useTimelineContext = useTimelineContext;
5
5
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
6
- const react_1 = require("react");
6
+ const react_1 = require("@emotion/react");
7
+ const react_2 = require("react");
7
8
  const timeline_style_1 = require("./timeline.style");
8
9
  const utils_1 = require("../../utils");
9
10
  const timelineItem_1 = require("./timelineItem");
10
- const TimelineContext = (0, react_1.createContext)({});
11
+ const TimelineContext = (0, react_2.createContext)({});
11
12
  function useTimelineContext() {
12
- return (0, react_1.useContext)(TimelineContext);
13
+ return (0, react_2.useContext)(TimelineContext);
13
14
  }
14
- exports.Timeline = (0, react_1.memo)(({ items,
15
+ exports.Timeline = (0, react_2.memo)(({ items,
15
16
  // 共享属性
16
17
  variant = 'outlined', labelPosition = 'end', orientation = 'vertical', color = 'primary', ...props }) => {
17
18
  const renderItems = () => {
18
19
  if (items) {
19
20
  return items.map((p, i) => {
20
- return ((0, jsx_runtime_1.jsx)(timelineItem_1.TimelineItem, { dot: p.dot, content: p.content, oppositeContent: p.oppositeContent, loading: p.loading, variant: p.variant, labelPosition: p.labelPosition, color: p.color, _index: i }, p.key ?? i));
21
+ return ((0, react_1.createElement)(timelineItem_1.TimelineItem, { ...p, key: p.key ?? i, _index: i }));
21
22
  });
22
23
  }
23
- return react_1.Children.map(props.children, (child, _index) => {
24
- if ((0, react_1.isValidElement)(child)) {
25
- return (0, react_1.cloneElement)(child, { _index });
24
+ return react_2.Children.map(props.children, (child, _index) => {
25
+ if ((0, react_2.isValidElement)(child)) {
26
+ return (0, react_2.cloneElement)(child, { _index });
26
27
  }
27
28
  return child;
28
29
  });
29
30
  };
30
- return ((0, jsx_runtime_1.jsx)("div", { ...props, css: timeline_style_1.style, className: (0, utils_1.clsx)(timeline_style_1.classes.root, props.className), "data-label-position": labelPosition, "data-orientation": orientation, children: (0, jsx_runtime_1.jsx)(TimelineContext, { value: (0, react_1.useMemo)(() => ({ variant, labelPosition, color, orientation }), [variant, labelPosition, color, orientation]), children: renderItems() }) }));
31
+ return ((0, jsx_runtime_1.jsx)("div", { ...props, css: timeline_style_1.style, className: (0, utils_1.clsx)(timeline_style_1.classes.root, props.className), "data-label-position": labelPosition, "data-orientation": orientation, children: (0, jsx_runtime_1.jsx)(TimelineContext, { value: (0, react_2.useMemo)(() => ({ variant, labelPosition, color, orientation }), [variant, labelPosition, color, orientation]), children: renderItems() }) }));
31
32
  });
32
33
  exports.Timeline.Item = timelineItem_1.TimelineItem;
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ToggleButton = void 0;
4
4
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
5
- const react_1 = require("react");
5
+ const react_1 = require("@emotion/react");
6
+ const react_2 = require("react");
6
7
  const flex_1 = require("../flex");
7
8
  const utils_1 = require("../../utils");
8
9
  const toggleButton_style_1 = require("./toggleButton.style");
@@ -35,13 +36,13 @@ exports.ToggleButton = (({ variant = 'filled', size, color = 'primary', disabled
35
36
  if (items) {
36
37
  return items.map((p, i) => {
37
38
  const itemValue = p[primaryKey];
38
- return ((0, jsx_runtime_1.jsx)(button_1.Button, { ref: p.ref, shape: p.shape, prefix: p.prefix, suffix: p.suffix, loading: p.loading, label: p.label, ...makeProps(p, itemValue, (0, utils_1.isSelected)(itemValue, innerValue)), children: p.children }, itemValue ?? i));
39
+ return ((0, react_1.createElement)(button_1.Button, { ...p, key: itemValue ?? i, ...makeProps(p, itemValue, (0, utils_1.isSelected)(itemValue, innerValue)) }, p.children));
39
40
  });
40
41
  }
41
- return react_1.Children.map(props.children, c => {
42
- if ((0, react_1.isValidElement)(c)) {
42
+ return react_2.Children.map(props.children, c => {
43
+ if ((0, react_2.isValidElement)(c)) {
43
44
  const { props } = c;
44
- return (0, react_1.cloneElement)(c, makeProps(props, props.value, (0, utils_1.isSelected)(props.value, innerValue)));
45
+ return (0, react_2.cloneElement)(c, makeProps(props, props.value, (0, utils_1.isSelected)(props.value, innerValue)));
45
46
  }
46
47
  return c;
47
48
  });
@@ -15,7 +15,7 @@ export const AvatarGroup = memo(({ color, size, shape = 'circular', imgProps, it
15
15
  const isSurplus = total > max;
16
16
  const renderItems = () => {
17
17
  if (items?.length) {
18
- return items.slice(0, isSurplus ? max - 1 : max).reverse().map((p, i) => _createElement(Avatar, { ...commonProps, key: p.key ?? i, color: p.color, size: p.size, shape: p.shape, src: p.src, imgProps: p.imgProps }, p.children));
18
+ return items.slice(0, isSurplus ? max - 1 : max).reverse().map((p, i) => _createElement(Avatar, { ...commonProps, ...p, key: p.key ?? i }, p.children));
19
19
  }
20
20
  return Children.toArray(props.children).slice(0, isSurplus ? max - 1 : max).reverse().map(child => {
21
21
  return isValidElement(child)
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, isValidElement, memo } from 'react';
3
4
  import { classes, style } from './bottomNavigation.style';
4
5
  import { clsx, isUnset, useControlled } from '../../utils';
@@ -9,10 +10,10 @@ export const BottomNavigation = memo(({ items, showLabelInactive, primaryKey = '
9
10
  if (items) {
10
11
  return items.map((p, i) => {
11
12
  const itemValue = p[primaryKey];
12
- return (_jsx(BottomNavigationItem, { value: itemValue, icon: p.icon, label: p[labelKey], showLabelInactive: p.showLabelInactive ?? showLabelInactive ?? items.length <= 3, active: !isUnset(itemValue) && innerValue.current === itemValue, onClick: e => {
13
+ return (_createElement(BottomNavigationItem, { ...p, key: p.key ?? itemValue ?? i, value: itemValue, label: p[labelKey], showLabelInactive: p.showLabelInactive ?? showLabelInactive ?? items.length <= 3, active: !isUnset(itemValue) && innerValue.current === itemValue, onClick: e => {
13
14
  p.onClick?.(e);
14
15
  setInnerValue(itemValue);
15
- } }, p.key ?? itemValue ?? i));
16
+ } }));
16
17
  });
17
18
  }
18
19
  showLabelInactive ??= Children.count(props.children) <= 3;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, isValidElement, memo } from 'react';
3
4
  import { clsx } from '../../utils';
4
5
  import { classes, style } from './breadcrumb.style';
@@ -8,10 +9,10 @@ export const Breadcrumb = memo(({ separator = '/', readOnly, items, ...props })
8
9
  const { text } = useTheme();
9
10
  const renderItems = () => {
10
11
  if (items) {
11
- return items.flatMap(({ icon, label, ...p }, i) => {
12
+ return items.flatMap(({ icon, ...p }, i) => {
12
13
  const isLast = i === items.length - 1;
13
14
  return [
14
- _jsx(Button, { ref: p.ref, shape: p.shape, size: p.size, suffix: p.suffix, loading: p.loading, label: label, variant: p.variant ?? 'plain', color: p.color ?? (isLast ? text.primary : text.disabled), readOnly: p.readOnly ?? (isLast || readOnly), prefix: p.prefix ?? icon, children: p.children }, p.key ?? i),
15
+ _createElement(Button, { ...p, key: p.key ?? i, variant: p.variant ?? 'plain', color: p.color ?? (isLast ? text.primary : text.disabled), readOnly: p.readOnly ?? (isLast || readOnly), prefix: p.prefix ?? icon }, p.children),
15
16
  ...isLast ? [] : [
16
17
  _jsx("span", { className: classes.separator, children: separator }, `${classes.separator}_${i}`)
17
18
  ]
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, createContext, isValidElement, useContext, useMemo } from 'react';
3
4
  import { Flex } from '../flex';
4
5
  import { clsx, isSelected } from '../../utils';
@@ -19,10 +20,10 @@ export const CheckboxBaseGroup = (({ size, color, items, primaryKey = 'value', m
19
20
  return items.map((p, i) => {
20
21
  const Component = multiple ? Checkbox : Radio;
21
22
  const itemValue = p[primaryKey];
22
- return (_jsx(Component, { inputProps: p.inputProps, label: p.label, indeterminate: p.indeterminate, disabled: p.disabled, readOnly: p.readOnly, size: p.size ?? size, color: p.color ?? color, checked: isSelected(itemValue, innerValue), onChange: e => {
23
+ return (_createElement(Component, { ...p, key: p.key ?? itemValue ?? i, size: p.size ?? size, color: p.color ?? color, checked: isSelected(itemValue, innerValue), onChange: e => {
23
24
  p.onChange?.(e);
24
25
  toggleSelected(itemValue);
25
- } }, p.key ?? itemValue ?? i));
26
+ } }));
26
27
  });
27
28
  }
28
29
  return Children.map(props.children, c => {
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { createContext, memo, useContext, useMemo } from 'react';
3
4
  import { style } from './menu.style';
4
5
  import { MenuItem } from '../menuItem';
@@ -27,7 +28,7 @@ size = 'large', showCheckbox, ellipsis, indent, ...props }) => {
27
28
  };
28
29
  const [innerValue, toggleSelected] = useShallowSelection({ multiple, defaultValue, value, onChange });
29
30
  const renderItems = (items) => {
30
- return items?.map((p, i) => _jsx(MenuItem, { size: p.size, color: p.color, emphasized: p.emphasized, selected: p.selected, focused: p.focused, disabled: p.disabled, showCheckbox: p.showCheckbox, checkboxProps: p.checkboxProps, ellipsis: p.ellipsis, prefix: p.prefix, suffix: p.suffix, indent: p.indent, expandIcon: p.expandIcon, onExpandedChange: p.onExpandedChange, value: p[primaryKey], label: p[labelKey], children: renderItems(p[childrenKey]) }, p[primaryKey] ?? i));
31
+ return items?.map((p, i) => _createElement(MenuItem, { ...p, key: p[primaryKey] ?? i, value: p[primaryKey], label: p[labelKey] }, renderItems(p[childrenKey])));
31
32
  };
32
33
  return (_jsx("div", { ...props, css: style, children: _jsx(MenuContext, { value: useMemo(() => ({
33
34
  inMenu: true,
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, isValidElement, memo, useEffect, useRef, useState } from 'react';
3
4
  import { classes, useStyle } from './segmented.style';
4
5
  import { clsx, cloneRef, isUnset, useControlled, useDerivedState } from '../../utils';
@@ -46,14 +47,14 @@ export const Segmented = memo(({ options, orientation = 'horizontal', size, labe
46
47
  return options.map((p, i) => {
47
48
  const v = p[primaryKey];
48
49
  const active = !isUnset(v) && v === innerValue.current;
49
- return (_jsx(SegmentedOption, { orientation: p.orientation, prefix: p.prefix, suffix: p.suffix, disabled: p.disabled, ref: r => {
50
+ return (_createElement(SegmentedOption, { ...p, key: p.key ?? v ?? i, ref: r => {
50
51
  r
51
52
  ? optionRefs.current.set(v, r)
52
53
  : optionRefs.current.delete(v);
53
54
  }, value: v, label: p[labelKey], onClick: e => {
54
55
  p.onClick?.(e);
55
56
  setInnerValue(v);
56
- }, "data-active": active }, p.key ?? v ?? i));
57
+ }, "data-active": active }));
57
58
  });
58
59
  }
59
60
  return Children.map(props.children, c => {
@@ -15,7 +15,7 @@ export const style = defineCss(({ spacing, text, easing }) => css `
15
15
  .${classes.contentWrap} {
16
16
  display: flex;
17
17
  align-items: center;
18
- gap: ${spacing[1]}px;
18
+ gap: ${spacing[2]}px;
19
19
  }
20
20
 
21
21
  .${classes.placeholder} {
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, createContext, isValidElement, useContext, useMemo } from 'react';
3
4
  import { clsx, useControlled } from '../../utils';
4
5
  import { classes, style } from './stepper.style';
@@ -15,14 +16,14 @@ size, gap = orientation === 'horizontal' ? 15 : 9, color, variant, clickable, la
15
16
  if (steps) {
16
17
  return steps.map((p, i) => {
17
18
  const isCurrentStep = i === innerValue.current;
18
- return (_jsx(Step, { indicator: p.indicator, title: p.title, prefix: p.prefix, suffix: p.suffix, description: p.description, size: p.size, gap: p.gap, color: p.color, variant: p.variant, labelPlacement: p.labelPlacement, step: i, status: p.status ?? (isCurrentStep
19
+ return (_createElement(Step, { ...p, key: p.key ?? i, step: i, status: p.status ?? (isCurrentStep
19
20
  ? status ?? 'processing'
20
21
  : i < innerValue.current
21
22
  ? 'finished'
22
23
  : 'waiting'), clickable: p.clickable ?? clickable, onClick: e => {
23
24
  p.onClick?.(e);
24
25
  (p.clickable ?? clickable) && setInnerValue(i);
25
- }, "data-orientation": orientation }, p.key ?? i));
26
+ }, "data-orientation": orientation }));
26
27
  });
27
28
  }
28
29
  return Children.map(props.children, (c, i) => {
@@ -1,8 +1,7 @@
1
- import { ActiveTabRef } from './tabs';
2
1
  import { Id } from '../../types';
3
2
  export declare function LineIndicator({ value, position, getActiveTab, onTransitionEnd }: {
4
3
  value?: Id;
5
4
  position: 'top' | 'bottom' | 'left' | 'right';
6
- getActiveTab(): ActiveTabRef | undefined;
5
+ getActiveTab(): HTMLDivElement | undefined;
7
6
  onTransitionEnd(): void;
8
7
  }): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -3,19 +3,21 @@ import { useEffect, useState } from 'react';
3
3
  import { classes, indicatorWidth } from './tabs.style';
4
4
  import { colorTransfer } from '../../utils';
5
5
  import { useTheme } from '../theme';
6
+ import { useTabsContext } from './tabs';
6
7
  export function LineIndicator({ value, position, getActiveTab, onTransitionEnd }) {
8
+ const context = useTabsContext();
9
+ const [color, setColor] = useState(context.color);
7
10
  const [boundingRect, setBoundingRect] = useState();
8
- const [color, setColor] = useState('primary');
9
11
  useEffect(() => {
10
- const { el, color } = getActiveTab() || {};
11
- if (!el) {
12
+ const activeTab = getActiveTab();
13
+ if (!activeTab) {
12
14
  return;
13
15
  }
14
16
  if (position === 'top' || position === 'bottom') {
15
17
  setBoundingRect({
16
- width: el.offsetWidth,
18
+ width: activeTab.offsetWidth,
17
19
  height: indicatorWidth,
18
- left: el.offsetLeft,
20
+ left: activeTab.offsetLeft,
19
21
  ...position === 'top'
20
22
  ? { bottom: 0 }
21
23
  : { top: 0 }
@@ -25,14 +27,14 @@ export function LineIndicator({ value, position, getActiveTab, onTransitionEnd }
25
27
  // position === 'left' || position === 'right'
26
28
  setBoundingRect({
27
29
  width: indicatorWidth,
28
- height: el.offsetHeight,
29
- top: el.offsetTop,
30
+ height: activeTab.offsetHeight,
31
+ top: activeTab.offsetTop,
30
32
  ...position === 'left'
31
33
  ? { right: 0 }
32
34
  : { left: 0 }
33
35
  });
34
36
  }
35
- setColor(color);
37
+ activeTab.dataset.color && setColor(activeTab.dataset.color);
36
38
  }, [value]);
37
39
  const theme = useTheme();
38
40
  return (_jsx("div", { className: classes.indicator, onTransitionEnd: onTransitionEnd, style: {
@@ -3,14 +3,14 @@ import { memo } from 'react';
3
3
  import { clsx, useColor } from '../../utils';
4
4
  import { classes } from './tabs.style';
5
5
  import { useTabsContext } from './tabs';
6
- export const Tab = memo(({ prefix, suffix, color = 'primary', orientation, label, value, disabled, _active, ...props }) => {
7
- const colorValue = useColor(color);
8
- const { variant, animating } = useTabsContext();
6
+ export const Tab = memo(({ prefix, suffix, color, orientation, label, value, disabled, _active, ...props }) => {
7
+ const { color: contextColor, variant, animating } = useTabsContext();
8
+ const colorValue = useColor(color ?? contextColor);
9
9
  return (_jsxs("div", { ...props, className: clsx(classes.tab, props.className), style: {
10
10
  borderColor: variant === 'line' && !animating && _active ? colorValue : void 0,
11
11
  color: _active ? colorValue : void 0,
12
12
  ...props.style
13
- }, "data-disabled": disabled, "data-orientation": orientation, "data-active": _active, onClick: e => {
13
+ }, "data-color": colorValue, "data-disabled": disabled, "data-orientation": orientation, "data-active": _active, onClick: e => {
14
14
  !disabled && props.onClick?.(e);
15
15
  }, children: [!!prefix &&
16
16
  _jsx("div", { className: classes.tabPrefix, children: prefix }), _jsx("div", { className: classes.label, children: label }), !!suffix &&
@@ -9,7 +9,7 @@ export interface TabsProps<T extends TabType = TabType> extends Omit<DivProps, '
9
9
  variant?: 'line' | 'card';
10
10
  color?: ColorPropsValue;
11
11
  size?: Size;
12
- /**选项卡的位置,默认为`top` */
12
+ /** 选项卡的位置,默认为`top` */
13
13
  position?: 'top' | 'bottom' | 'left' | 'right';
14
14
  justifyContent?: CSSProperties['justifyContent'];
15
15
  fullWidth?: boolean;
@@ -21,11 +21,8 @@ export interface TabsProps<T extends TabType = TabType> extends Omit<DivProps, '
21
21
  readOnly?: boolean;
22
22
  disabled?: boolean;
23
23
  }
24
- export type ActiveTabRef = {
25
- el: HTMLElement | null;
26
- color: string;
27
- };
28
24
  export declare function useTabsContext(): {
25
+ color?: ColorPropsValue;
29
26
  variant?: TabsProps["variant"];
30
27
  animating?: boolean;
31
28
  };
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, createContext, isValidElement, memo, useContext, useEffect, useMemo, useRef, useState } from 'react';
3
4
  import { classes, useStyle } from './tabs.style';
4
5
  import { clsx, cloneRef, isUnset, useControlled } from '../../utils';
@@ -34,26 +35,25 @@ export const Tabs = memo(({ tabs, labelKey = 'label', primaryKey = 'value', vari
34
35
  return tabs.map((p, i) => {
35
36
  const value = p[primaryKey];
36
37
  const active = !isUnset(value) && value === innerValue.current;
37
- return (_jsx(Tab, { prefix: p.prefix, suffix: p.suffix, color: p.color, orientation: p.orientation, disabled: p.disabled, ref: el => {
38
- tabRefs.current.set(value, { el, color: p.color || 'primary' });
39
- return () => {
40
- tabRefs.current.delete(value);
41
- };
38
+ return (_createElement(Tab, { ...p, key: p.key ?? value ?? i, ref: el => {
39
+ el
40
+ ? tabRefs.current.set(value, el)
41
+ : tabRefs.current.delete(value);
42
42
  }, value: value, label: p[labelKey], onClick: e => {
43
43
  p.onClick?.(e);
44
44
  setInnerValue(value);
45
- }, _active: active }, p.key ?? value ?? i));
45
+ }, _active: active }));
46
46
  });
47
47
  }
48
48
  return Children.map(props.children, c => {
49
49
  if (isValidElement(c)) {
50
- const { value, color, onClick } = c.props;
50
+ const { value, onClick } = c.props;
51
51
  const active = !isUnset(value) && value === innerValue.current;
52
52
  return cloneElement(c, {
53
53
  ref: cloneRef(c.ref, el => {
54
54
  if (!isUnset(value)) {
55
55
  el
56
- ? tabRefs.current.set(value, { el, color: color || 'primary' })
56
+ ? tabRefs.current.set(value, el)
57
57
  : tabRefs.current.delete(value);
58
58
  }
59
59
  }),
@@ -106,13 +106,17 @@ export const Tabs = memo(({ tabs, labelKey = 'label', primaryKey = 'value', vari
106
106
  const shouldScroll = useRef(true);
107
107
  useEffect(() => {
108
108
  if (shouldScroll.current) {
109
- getActiveTab()?.el?.scrollIntoView({ block: 'center', inline: 'center', behavior: 'smooth' });
109
+ getActiveTab()?.scrollIntoView({ block: 'center', inline: 'center', behavior: 'smooth' });
110
110
  shouldScroll.current = false;
111
111
  }
112
112
  }, [shouldScroll.current]);
113
- return (_jsxs("div", { ...props, css: useStyle({ color: color || 'primary', variant }), className: clsx(classes.root, props.className), "data-size": size, "data-position": position, "data-animating": animating, "data-full-width": fullWidth, "data-read-only": readOnly, "data-disabled": disabled, children: [_jsx("div", { className: classes.start, "data-show": shadowStart, children: !!prefix &&
114
- _jsx("div", { className: classes.prefix, children: prefix }) }), _jsx("div", { ref: scrollRef, className: classes.scroll, onScroll: setShadow, children: _jsxs("div", { className: classes.scrollWrap, style: { justifyContent }, children: [_jsx(TabsContext, { value: useMemo(() => ({ variant, animating }), [variant, animating]), children: renderTabs() }), variant === 'line' &&
115
- _jsx(LineIndicator, { value: innerValue.current, position: position, getActiveTab: getActiveTab, onTransitionEnd: () => setAnimating(false) })] }) }), _jsx("div", { className: classes.end, "data-show": shadowEnd, children: !!(suffix || shadowStart || shadowEnd) &&
113
+ return (_jsxs("div", { ...props, css: useStyle({ color, variant }), className: clsx(classes.root, props.className), "data-size": size, "data-position": position, "data-animating": animating, "data-full-width": fullWidth, "data-read-only": readOnly, "data-disabled": disabled, children: [_jsx("div", { className: classes.start, "data-show": shadowStart, children: !!prefix &&
114
+ _jsx("div", { className: classes.prefix, children: prefix }) }), _jsx("div", { ref: scrollRef, className: classes.scroll, onScroll: setShadow, children: _jsx("div", { className: classes.scrollWrap, style: { justifyContent }, children: _jsxs(TabsContext, { value: useMemo(() => ({
115
+ color, variant, animating
116
+ }), [
117
+ color, variant, animating
118
+ ]), children: [renderTabs(), variant === 'line' &&
119
+ _jsx(LineIndicator, { value: innerValue.current, position: position, getActiveTab: getActiveTab, onTransitionEnd: () => setAnimating(false) })] }) }) }), _jsx("div", { className: classes.end, "data-show": shadowEnd, children: !!(suffix || shadowStart || shadowEnd) &&
116
120
  _jsxs("div", { className: classes.suffix, children: [(shadowStart || shadowEnd) &&
117
121
  _jsx(TabsEllipsis, { tabs: tabs, labelKey: labelKey, primaryKey: primaryKey, value: innerValue.current, onToggleSelected: setValueInEllipsis, children: props.children }), suffix] }) })] }));
118
122
  });
@@ -68,7 +68,7 @@ export function useStyle({ color, variant }) {
68
68
  cursor: pointer;
69
69
 
70
70
  &:hover {
71
- color: ${colors.primary.main};
71
+ color: ${colorValue};
72
72
  }
73
73
  }
74
74
 
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, createContext, isValidElement, memo, useContext, useMemo } from 'react';
3
4
  import { classes, style } from './timeline.style';
4
5
  import { clsx } from '../../utils';
@@ -13,7 +14,7 @@ variant = 'outlined', labelPosition = 'end', orientation = 'vertical', color = '
13
14
  const renderItems = () => {
14
15
  if (items) {
15
16
  return items.map((p, i) => {
16
- return (_jsx(TimelineItem, { dot: p.dot, content: p.content, oppositeContent: p.oppositeContent, loading: p.loading, variant: p.variant, labelPosition: p.labelPosition, color: p.color, _index: i }, p.key ?? i));
17
+ return (_createElement(TimelineItem, { ...p, key: p.key ?? i, _index: i }));
17
18
  });
18
19
  }
19
20
  return Children.map(props.children, (child, _index) => {
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ import { createElement as _createElement } from "@emotion/react";
2
3
  import { Children, cloneElement, isValidElement } from 'react';
3
4
  import { Flex } from '../flex';
4
5
  import { clsx, isSelected } from '../../utils';
@@ -32,7 +33,7 @@ export const ToggleButton = (({ variant = 'filled', size, color = 'primary', dis
32
33
  if (items) {
33
34
  return items.map((p, i) => {
34
35
  const itemValue = p[primaryKey];
35
- return (_jsx(Button, { ref: p.ref, shape: p.shape, prefix: p.prefix, suffix: p.suffix, loading: p.loading, label: p.label, ...makeProps(p, itemValue, isSelected(itemValue, innerValue)), children: p.children }, itemValue ?? i));
36
+ return (_createElement(Button, { ...p, key: itemValue ?? i, ...makeProps(p, itemValue, isSelected(itemValue, innerValue)) }, p.children));
36
37
  });
37
38
  }
38
39
  return Children.map(props.children, c => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",