@bifrostui/react 1.4.5-beta.3 → 1.4.6

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 (118) hide show
  1. package/dist/ActionSheet/ActionSheet.css +2 -2
  2. package/dist/ActionSheet/ActionSheetItem.js +8 -3
  3. package/dist/Avatar/Avatar.js +8 -3
  4. package/dist/Avatar/AvatarGroup.js +6 -2
  5. package/dist/Badge/Badge.js +8 -3
  6. package/dist/Button/Button.css +78 -77
  7. package/dist/Button/Button.d.ts +1 -1
  8. package/dist/Button/Button.js +10 -4
  9. package/dist/Button/Button.types.d.ts +7 -8
  10. package/dist/Calendar/Calendar.js +14 -6
  11. package/dist/Card/Card.css +1 -1
  12. package/dist/Card/CardContent.css +2 -1
  13. package/dist/Card/CardFooter.css +4 -2
  14. package/dist/Card/CardHeader.css +5 -4
  15. package/dist/Checkbox/Checkbox.js +6 -2
  16. package/dist/Checkbox/CheckboxGroup.js +7 -4
  17. package/dist/CollapsePanel/CollapsePanelItem.js +46 -45
  18. package/dist/Countdown/Countdown.js +12 -5
  19. package/dist/Divider/Divider.js +5 -8
  20. package/dist/Drawer/Drawer.js +10 -4
  21. package/dist/Fade/Fade.js +56 -52
  22. package/dist/IconButton/IconButton.js +12 -5
  23. package/dist/Image/Image.js +119 -112
  24. package/dist/Input/Input.js +10 -4
  25. package/dist/List/List.js +8 -3
  26. package/dist/List/ListItem.js +44 -42
  27. package/dist/List/ListItemContent.js +4 -1
  28. package/dist/List/ListItemExtra.js +4 -9
  29. package/dist/List/ListItemFooter.js +4 -9
  30. package/dist/List/ListItemHeader.js +4 -9
  31. package/dist/Loading/Loading.js +4 -13
  32. package/dist/Modal/Modal.js +6 -0
  33. package/dist/Modal/Modal.miniapp.js +10 -4
  34. package/dist/NavBar/NavBar.js +1 -0
  35. package/dist/Popover/Popover.css +5 -5
  36. package/dist/Radio/Radio.css +1 -0
  37. package/dist/Radio/Radio.js +6 -2
  38. package/dist/Radio/RadioGroup.js +3 -0
  39. package/dist/Rating/Rating.js +18 -8
  40. package/dist/Select/Select.js +8 -4
  41. package/dist/Skeleton/Skeleton.js +9 -5
  42. package/dist/Slide/Slide.js +74 -69
  43. package/dist/Slider/Slider.js +14 -6
  44. package/dist/Steps/Step.js +82 -81
  45. package/dist/Steps/Steps.d.ts +1 -1
  46. package/dist/Steps/Steps.js +60 -57
  47. package/dist/Switch/Switch.js +78 -75
  48. package/dist/TabBar/TabBar.js +8 -3
  49. package/dist/Tabs/Tab.css +16 -10
  50. package/dist/Tabs/Tab.js +7 -15
  51. package/dist/Tabs/Tabs.css +22 -13
  52. package/dist/Tabs/Tabs.js +42 -26
  53. package/dist/Tabs/Tabs.types.d.ts +10 -0
  54. package/dist/Tag/Tag.css +1 -1
  55. package/dist/Tag/Tag.js +6 -2
  56. package/dist/TextArea/TextArea.js +12 -5
  57. package/dist/Tooltip/Tooltip.css +5 -5
  58. package/dist/Transition/TransitionCore.js +8 -3
  59. package/es/ActionSheet/ActionSheet.css +2 -2
  60. package/es/ActionSheet/ActionSheetItem.js +8 -3
  61. package/es/Avatar/Avatar.js +8 -3
  62. package/es/Avatar/AvatarGroup.js +6 -2
  63. package/es/Badge/Badge.js +8 -3
  64. package/es/Button/Button.css +78 -77
  65. package/es/Button/Button.d.ts +1 -1
  66. package/es/Button/Button.js +9 -3
  67. package/es/Button/Button.types.d.ts +7 -8
  68. package/es/Calendar/Calendar.js +14 -6
  69. package/es/Card/Card.css +1 -1
  70. package/es/Card/CardContent.css +2 -1
  71. package/es/Card/CardFooter.css +4 -2
  72. package/es/Card/CardHeader.css +5 -4
  73. package/es/Checkbox/Checkbox.js +6 -2
  74. package/es/Checkbox/CheckboxGroup.js +7 -4
  75. package/es/CollapsePanel/CollapsePanelItem.js +46 -45
  76. package/es/Countdown/Countdown.js +12 -5
  77. package/es/Divider/Divider.js +5 -8
  78. package/es/Drawer/Drawer.js +10 -4
  79. package/es/Fade/Fade.js +56 -52
  80. package/es/IconButton/IconButton.js +12 -5
  81. package/es/Image/Image.js +119 -112
  82. package/es/Input/Input.js +10 -4
  83. package/es/List/List.js +8 -3
  84. package/es/List/ListItem.js +44 -42
  85. package/es/List/ListItemContent.js +4 -1
  86. package/es/List/ListItemExtra.js +4 -9
  87. package/es/List/ListItemFooter.js +4 -9
  88. package/es/List/ListItemHeader.js +4 -9
  89. package/es/Loading/Loading.js +4 -13
  90. package/es/Modal/Modal.js +6 -0
  91. package/es/Modal/Modal.miniapp.d.ts +1 -1
  92. package/es/Modal/Modal.miniapp.js +10 -4
  93. package/es/NavBar/NavBar.js +1 -0
  94. package/es/Popover/Popover.css +5 -5
  95. package/es/Radio/Radio.css +1 -0
  96. package/es/Radio/Radio.js +6 -2
  97. package/es/Radio/RadioGroup.js +3 -0
  98. package/es/Rating/Rating.js +18 -8
  99. package/es/Select/Select.js +8 -4
  100. package/es/Skeleton/Skeleton.js +9 -5
  101. package/es/Slide/Slide.js +74 -69
  102. package/es/Slider/Slider.js +14 -6
  103. package/es/Steps/Step.js +82 -81
  104. package/es/Steps/Steps.d.ts +1 -1
  105. package/es/Steps/Steps.js +60 -57
  106. package/es/Switch/Switch.js +78 -75
  107. package/es/TabBar/TabBar.js +8 -3
  108. package/es/Tabs/Tab.css +16 -10
  109. package/es/Tabs/Tab.js +7 -15
  110. package/es/Tabs/Tabs.css +22 -13
  111. package/es/Tabs/Tabs.js +55 -28
  112. package/es/Tabs/Tabs.types.d.ts +10 -0
  113. package/es/Tag/Tag.css +1 -1
  114. package/es/Tag/Tag.js +6 -2
  115. package/es/TextArea/TextArea.js +12 -5
  116. package/es/Tooltip/Tooltip.css +5 -5
  117. package/es/Transition/TransitionCore.js +8 -3
  118. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { StepsProps } from './Steps.types';
3
2
  import './Steps.less';
3
+ import { StepsProps } from './Steps.types';
4
4
  declare const Steps: React.ForwardRefExoticComponent<Omit<StepsProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
5
  export default Steps;
@@ -59,65 +59,68 @@ module.exports = __toCommonJS(Steps_exports);
59
59
  var import_utils = require("@bifrostui/utils");
60
60
  var import_clsx = __toESM(require("clsx"));
61
61
  var import_react = __toESM(require("react"));
62
+ var import_Steps = require("./Steps.css");
62
63
  var import_StepsContext = require("./StepsContext");
63
- var import_Steps2 = require("./Steps.css");
64
64
  const prefixCls = "bui-steps";
65
- const Steps = (0, import_react.forwardRef)(
66
- (_a, ref) => {
67
- var _b = _a, {
68
- className,
69
- children,
70
- direction = "vertical",
71
- current = 0,
72
- labelPlacement = "horizontal",
73
- onChange
74
- } = _b, others = __objRest(_b, [
75
- "className",
76
- "children",
77
- "direction",
78
- "current",
79
- "labelPlacement",
80
- "onChange"
81
- ]);
82
- const renderStep = () => {
83
- return (0, import_utils.toArray)(children).map((child, index) => {
84
- const childProps = __spreadValues({
85
- key: index
86
- }, child.props);
87
- if (!child.props.status) {
88
- if (index === current) {
89
- childProps.status = "active";
90
- } else if (index < current) {
91
- childProps.status = "finish";
92
- } else {
93
- childProps.status = "wait";
94
- }
65
+ const Steps = (0, import_react.forwardRef)((props, ref) => {
66
+ const _a = props, {
67
+ className,
68
+ children,
69
+ direction,
70
+ current,
71
+ labelPlacement,
72
+ onChange
73
+ } = _a, others = __objRest(_a, [
74
+ "className",
75
+ "children",
76
+ "direction",
77
+ "current",
78
+ "labelPlacement",
79
+ "onChange"
80
+ ]);
81
+ const renderStep = () => {
82
+ return (0, import_utils.toArray)(children).map((child, index) => {
83
+ const childProps = __spreadValues({
84
+ key: index
85
+ }, child.props);
86
+ if (!child.props.status) {
87
+ if (index === current) {
88
+ childProps.status = "active";
89
+ } else if (index < current) {
90
+ childProps.status = "finish";
91
+ } else {
92
+ childProps.status = "wait";
95
93
  }
96
- return (0, import_react.cloneElement)(child, childProps);
97
- });
98
- };
99
- return /* @__PURE__ */ import_react.default.createElement(
100
- import_StepsContext.StepsContextProvider,
101
- {
102
- value: {
103
- direction,
104
- current,
105
- labelPlacement,
106
- onChange
107
- }
108
- },
109
- /* @__PURE__ */ import_react.default.createElement(
110
- "div",
111
- __spreadValues({
112
- className: (0, import_clsx.default)(prefixCls, className, {
113
- [`${prefixCls}-${direction}`]: direction
114
- }),
115
- ref
116
- }, others),
117
- renderStep()
118
- )
119
- );
120
- }
121
- );
94
+ }
95
+ return (0, import_react.cloneElement)(child, childProps);
96
+ });
97
+ };
98
+ return /* @__PURE__ */ import_react.default.createElement(
99
+ import_StepsContext.StepsContextProvider,
100
+ {
101
+ value: {
102
+ direction,
103
+ current,
104
+ labelPlacement,
105
+ onChange
106
+ }
107
+ },
108
+ /* @__PURE__ */ import_react.default.createElement(
109
+ "div",
110
+ __spreadValues({
111
+ className: (0, import_clsx.default)(prefixCls, className, {
112
+ [`${prefixCls}-${direction}`]: direction
113
+ }),
114
+ ref
115
+ }, others),
116
+ renderStep()
117
+ )
118
+ );
119
+ });
122
120
  Steps.displayName = "Steps";
121
+ Steps.defaultProps = {
122
+ current: 0,
123
+ direction: "vertical",
124
+ labelPlacement: "horizontal"
125
+ };
123
126
  var Steps_default = Steps;
@@ -64,80 +64,83 @@ var import_clsx = __toESM(require("clsx"));
64
64
  var import_react = __toESM(require("react"));
65
65
  var import_Switch2 = require("./Switch.css");
66
66
  const prefixCls = "bui-switch";
67
- const Switch = (0, import_react.forwardRef)(
68
- (_a, ref) => {
69
- var _b = _a, {
70
- className,
71
- checked,
72
- defaultChecked,
73
- inputProps,
74
- inputRef,
75
- name,
76
- checkedChildren,
77
- unCheckedChildren,
78
- disabled = false,
79
- size = "medium",
80
- color = "primary",
81
- onChange
82
- } = _b, others = __objRest(_b, [
83
- "className",
84
- "checked",
85
- "defaultChecked",
86
- "inputProps",
87
- "inputRef",
88
- "name",
89
- "checkedChildren",
90
- "unCheckedChildren",
91
- "disabled",
92
- "size",
93
- "color",
94
- "onChange"
95
- ]);
96
- const [switchChecked, triggerChange] = (0, import_utils.useValue)({
97
- value: checked,
98
- defaultValue: !!defaultChecked
99
- });
100
- const changeAction = (e, isChecked) => {
101
- triggerChange(e, isChecked);
102
- onChange == null ? void 0 : onChange(e, { checked: isChecked });
103
- };
104
- const handleChange = (e) => {
105
- var _a2;
106
- const isChecked = !switchChecked;
107
- changeAction(e, isChecked);
108
- (_a2 = inputProps == null ? void 0 : inputProps.onChange) == null ? void 0 : _a2.call(inputProps, e);
109
- };
110
- return /* @__PURE__ */ import_react.default.createElement(
111
- "div",
112
- __spreadValues({
113
- ref,
114
- className: (0, import_clsx.default)(
115
- `${prefixCls}`,
116
- `${prefixCls}-${size}`,
117
- `${prefixCls}-${color}`,
118
- {
119
- [`${prefixCls}-checked`]: switchChecked,
120
- [`${prefixCls}-disabled`]: disabled
121
- },
122
- className
123
- )
124
- }, others),
125
- /* @__PURE__ */ import_react.default.createElement(
126
- "input",
127
- __spreadProps(__spreadValues({
128
- ref: inputRef,
129
- type: "checkbox",
130
- name,
131
- checked: switchChecked,
132
- disabled
133
- }, inputProps), {
134
- onChange: handleChange,
135
- className: (0, import_clsx.default)(`${prefixCls}-input`, inputProps == null ? void 0 : inputProps.className)
136
- })
137
- ),
138
- (checkedChildren || unCheckedChildren) && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-inner` }, switchChecked ? checkedChildren : unCheckedChildren)
139
- );
140
- }
141
- );
67
+ const Switch = (0, import_react.forwardRef)((props, ref) => {
68
+ const _a = props, {
69
+ className,
70
+ checked,
71
+ defaultChecked,
72
+ inputProps,
73
+ inputRef,
74
+ name,
75
+ checkedChildren,
76
+ unCheckedChildren,
77
+ disabled,
78
+ size,
79
+ color,
80
+ onChange
81
+ } = _a, others = __objRest(_a, [
82
+ "className",
83
+ "checked",
84
+ "defaultChecked",
85
+ "inputProps",
86
+ "inputRef",
87
+ "name",
88
+ "checkedChildren",
89
+ "unCheckedChildren",
90
+ "disabled",
91
+ "size",
92
+ "color",
93
+ "onChange"
94
+ ]);
95
+ const [switchChecked, triggerChange] = (0, import_utils.useValue)({
96
+ value: checked,
97
+ defaultValue: !!defaultChecked
98
+ });
99
+ const changeAction = (e, isChecked) => {
100
+ triggerChange(e, isChecked);
101
+ onChange == null ? void 0 : onChange(e, { checked: isChecked });
102
+ };
103
+ const handleChange = (e) => {
104
+ var _a2;
105
+ const isChecked = !switchChecked;
106
+ changeAction(e, isChecked);
107
+ (_a2 = inputProps == null ? void 0 : inputProps.onChange) == null ? void 0 : _a2.call(inputProps, e);
108
+ };
109
+ return /* @__PURE__ */ import_react.default.createElement(
110
+ "div",
111
+ __spreadValues({
112
+ ref,
113
+ className: (0, import_clsx.default)(
114
+ `${prefixCls}`,
115
+ `${prefixCls}-${size}`,
116
+ `${prefixCls}-${color}`,
117
+ {
118
+ [`${prefixCls}-checked`]: switchChecked,
119
+ [`${prefixCls}-disabled`]: disabled
120
+ },
121
+ className
122
+ )
123
+ }, others),
124
+ /* @__PURE__ */ import_react.default.createElement(
125
+ "input",
126
+ __spreadProps(__spreadValues({
127
+ ref: inputRef,
128
+ type: "checkbox",
129
+ name,
130
+ checked: switchChecked,
131
+ disabled
132
+ }, inputProps), {
133
+ onChange: handleChange,
134
+ className: (0, import_clsx.default)(`${prefixCls}-input`, inputProps == null ? void 0 : inputProps.className)
135
+ })
136
+ ),
137
+ (checkedChildren || unCheckedChildren) && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-inner` }, switchChecked ? checkedChildren : unCheckedChildren)
138
+ );
139
+ });
142
140
  Switch.displayName = "BuiSwitch";
141
+ Switch.defaultProps = {
142
+ disabled: false,
143
+ size: "medium",
144
+ color: "primary"
145
+ };
143
146
  var Switch_default = Switch;
@@ -63,9 +63,9 @@ var import_TabBar = require("./TabBar.css");
63
63
  const prefixCls = "bui-tab-bar";
64
64
  const TabBar = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
65
65
  const _a = props || {}, {
66
- current = 0,
67
- activeColor = "primary",
68
- color = "default",
66
+ current,
67
+ activeColor,
68
+ color,
69
69
  children,
70
70
  className,
71
71
  onChange
@@ -97,4 +97,9 @@ const TabBar = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
97
97
  );
98
98
  });
99
99
  TabBar.displayName = "BuiTabBar";
100
+ TabBar.defaultProps = {
101
+ activeColor: "primary",
102
+ color: "default",
103
+ current: 0
104
+ };
100
105
  var TabBar_default = TabBar;
package/dist/Tabs/Tab.css CHANGED
@@ -4,25 +4,31 @@
4
4
  justify-content: center;
5
5
  white-space: nowrap;
6
6
  width: min-content;
7
- height: 100%;
7
+ height: var(--tab-height);
8
8
  box-sizing: border-box;
9
9
  position: relative;
10
10
  cursor: pointer;
11
- font-size: var(--bui-tabs-font-size);
11
+ font-size: var(--font-size);
12
12
  line-height: var(--bui-line-height);
13
- color: var(--bui-tabs-color);
14
- padding: var(--bui-tab-padding);
15
- font-family: var(--bui-tabs-font-family);
13
+ color: var(--color);
14
+ padding: var(--tab-padding);
15
+ font-family: var(--bui-font-family);
16
16
  }
17
17
  .bui-tab-active {
18
- --bui-tabs-font-family: var(--bui-font-family-accent, inherit);
19
- --bui-tabs-color: var(--bui-color-fg-default);
20
- font-weight: 600;
18
+ font-size: var(--font-size);
19
+ line-height: var(--bui-line-height);
20
+ font-weight: var(--bui-font-weight-medium);
21
+ color: var(--active-color);
22
+ }
23
+ .bui-tab-center {
24
+ flex: 1 0 0;
25
+ margin: 0 auto;
21
26
  }
22
27
  .bui-tab-miniapp-active {
23
- --bui-tabs-color: var(--bui-color-fg-default);
28
+ font-size: var(--font-size);
24
29
  line-height: 1.5;
25
30
  font-weight: var(--bui-font-weight-medium);
31
+ color: var(--active-color);
26
32
  position: relative;
27
33
  }
28
34
  .bui-tab-miniapp-active-line {
@@ -40,7 +46,7 @@
40
46
  opacity: 0.5;
41
47
  pointer-events: none;
42
48
  }
43
- .bui-indicator-invisible {
49
+ .bui-tabline-invisible {
44
50
  visibility: hidden;
45
51
  background-color: transparent;
46
52
  }
package/dist/Tabs/Tab.js CHANGED
@@ -66,27 +66,16 @@ var import_TabsContext = __toESM(require("./TabsContext"));
66
66
  var import_Tab2 = require("./Tab.css");
67
67
  const prefixCls = "bui-tab";
68
68
  const Tab = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
69
- const _a = props, {
70
- className,
71
- children,
72
- index,
73
- disabled = false,
74
- onClick
75
- } = _a, others = __objRest(_a, [
76
- "className",
77
- "children",
78
- "index",
79
- "disabled",
80
- "onClick"
81
- ]);
69
+ const _a = props, { className, children, index, disabled, onClick } = _a, others = __objRest(_a, ["className", "children", "index", "disabled", "onClick"]);
82
70
  const tabsContext = import_react.default.useContext(import_TabsContext.default);
83
- const { value, triggerChange } = tabsContext;
71
+ const { value, align, triggerChange } = tabsContext;
84
72
  return /* @__PURE__ */ import_react.default.createElement(
85
73
  "div",
86
74
  __spreadProps(__spreadValues({
87
75
  ref,
88
76
  className: (0, import_clsx.default)(
89
77
  prefixCls,
78
+ align !== "start" && `${prefixCls}-${align}`,
90
79
  {
91
80
  [`${prefixCls}-active`]: !import_utils.isMini && index === value,
92
81
  [`${prefixCls}-miniapp-active`]: import_utils.isMini && index === value,
@@ -108,11 +97,14 @@ const Tab = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
108
97
  "div",
109
98
  {
110
99
  className: (0, import_clsx.default)(`${prefixCls}-miniapp-active-line`, {
111
- "bui-indicator-invisible": index !== value
100
+ "bui-tabline-invisible": index !== value
112
101
  })
113
102
  }
114
103
  )
115
104
  );
116
105
  });
117
106
  Tab.displayName = "BuiTab";
107
+ Tab.defaultProps = {
108
+ disabled: false
109
+ };
118
110
  var Tab_default = Tab;
@@ -1,10 +1,20 @@
1
1
  .bui-tabs {
2
+ --height: var(--bui-tabs-height, 39px);
3
+ --color: var(--bui-tabs-color, var(--bui-color-fg-subtle));
4
+ --active-color: var(--bui-tabs-active-color, var(--bui-color-fg-default));
5
+ --line-color: var(--bui-tabs-line-color, var(--bui-color-primary));
6
+ --line-height: var(--bui-tabs-line-height, 3PX);
7
+ --line-width: var(--bui-tabs-line-width, 18px);
8
+ --mask-width: var(--bui-tabs-mask-width, 12px);
9
+ --mask-height: var(--bui-tabs-mask-height, 100%);
10
+ --tab-height: var(--bui-tab-height, 100%);
11
+ --tab-padding: var(--bui-tab-padding, var(--bui-spacing-lg) var(--bui-spacing-lg) 10px);
12
+ --font-size: var(--bui-tab-font-size, var(--bui-text-size-1));
2
13
  position: relative;
3
- font-family: var(--bui-tabs-font-family);
4
- font-weight: var(--bui-tabs-font-weight);
14
+ font-family: var(--bui-font-family);
5
15
  }
6
16
  .bui-tabs-tabs {
7
- height: var(--bui-tabs-height);
17
+ height: var(--height);
8
18
  display: flex;
9
19
  flex-wrap: nowrap;
10
20
  justify-content: flex-start;
@@ -16,15 +26,14 @@
16
26
  .bui-tabs-tabs::-webkit-scrollbar {
17
27
  display: none;
18
28
  }
19
- .bui-tabs-indicator {
29
+ .bui-tabs-tabline {
20
30
  position: absolute;
21
- width: var(--bui-tabs-indicator-width);
22
- bottom: var(--bui-tabs-indicator-bottom);
23
- height: var(--bui-tabs-indicator-height);
31
+ width: var(--line-width);
32
+ bottom: 0;
33
+ height: var(--line-height);
24
34
  color: var(--bui-color-primary);
25
- background: var(--bui-tabs-indicator-bg);
26
- border-radius: var(--bui-tabs-indicator-border-radius);
27
- box-shadow: var(--bui-tabs-indicator-box-shadow);
35
+ background: var(--line-color);
36
+ border-radius: var(--bui-shape-radius-label);
28
37
  }
29
38
  .bui-tabs-content {
30
39
  padding: var(--bui-spacing-lg);
@@ -34,8 +43,8 @@
34
43
  top: 0;
35
44
  bottom: 0;
36
45
  z-index: 1;
37
- width: 12px;
38
- height: 100%;
46
+ width: var(--mask-width);
47
+ height: var(--mask-height);
39
48
  pointer-events: none;
40
49
  }
41
50
  .bui-tabs-mask-left {
@@ -54,7 +63,7 @@
54
63
  var(--bui-color-bg-view),
55
64
  rgba(255, 255, 255, 0));
56
65
  }
57
- .bui-indicator-invisible {
66
+ .bui-tabline-invisible {
58
67
  visibility: hidden;
59
68
  background-color: transparent;
60
69
  }
package/dist/Tabs/Tabs.js CHANGED
@@ -65,22 +65,24 @@ var import_bound = __toESM(require("./utils/bound"));
65
65
  var import_Tabs2 = require("./Tabs.css");
66
66
  const prefixCls = "bui-tabs";
67
67
  const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
68
- const _a = props, { children, className, value, tabs = [], onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "onChange"]);
68
+ const _a = props, { children, className, value, tabs, align, onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "align", "onChange"]);
69
+ const [active, setActive] = (0, import_react.useState)("");
69
70
  const tabsRef = (0, import_react.useRef)(null);
70
71
  const activeLineRef = (0, import_react.useRef)(null);
71
- const [indicatorData, setIndicatorData] = (0, import_react.useState)({
72
+ const [lineData, setLineData] = (0, import_react.useState)({
72
73
  x: 0,
74
+ transitionInUse: false,
73
75
  hasActiveTab: false
74
76
  });
75
77
  const [maskData, setMaskData] = (0, import_react.useState)({
76
78
  leftMaskOpacity: 0,
77
79
  rightMaskOpacity: 0
78
80
  });
79
- const animate = (0, import_utils.useEventCallback)(() => {
81
+ const animate = ({ transitionInUse }) => {
80
82
  const container = tabsRef.current;
81
83
  if (!container)
82
84
  return;
83
- const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === value);
85
+ const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === active);
84
86
  const activeLine = activeLineRef.current;
85
87
  if (!activeLine)
86
88
  return;
@@ -111,8 +113,9 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
111
113
  activeLineWidth = activeLine.offsetWidth;
112
114
  x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
113
115
  }
114
- setIndicatorData({
116
+ setLineData({
115
117
  x,
118
+ transitionInUse,
116
119
  hasActiveTab: !!activeTab
117
120
  });
118
121
  const maxScrollDistance = containerScrollWidth - containerWidth;
@@ -126,7 +129,26 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
126
129
  if (tabsRef.current) {
127
130
  tabsRef.current.scrollLeft = nextScrollLeft;
128
131
  }
129
- });
132
+ };
133
+ (0, import_react.useEffect)(() => {
134
+ setActive(value);
135
+ }, [value]);
136
+ (0, import_react.useLayoutEffect)(() => {
137
+ animate({ transitionInUse: false });
138
+ }, []);
139
+ (0, import_react.useEffect)(() => {
140
+ const handleResize = (0, import_utils.debounce)(() => {
141
+ animate({ transitionInUse: true });
142
+ updateMask();
143
+ }, 100);
144
+ window.addEventListener("resize", handleResize);
145
+ return () => {
146
+ window.removeEventListener("resize", handleResize);
147
+ };
148
+ }, [active]);
149
+ (0, import_utils.useDidMountEffect)(() => {
150
+ animate({ transitionInUse: true });
151
+ }, [active, tabs, children]);
130
152
  const updateMask = (0, import_react.useMemo)(
131
153
  () => (0, import_utils.throttle)(
132
154
  () => {
@@ -149,20 +171,7 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
149
171
  ),
150
172
  []
151
173
  );
152
- (0, import_react.useEffect)(() => {
153
- animate();
154
- }, [value]);
155
- (0, import_react.useEffect)(() => {
156
- const handleResize = (0, import_utils.debounce)(() => {
157
- animate();
158
- updateMask();
159
- }, 100);
160
- window.addEventListener("resize", handleResize);
161
- return () => {
162
- window.removeEventListener("resize", handleResize);
163
- };
164
- }, []);
165
- (0, import_react.useEffect)(() => {
174
+ (0, import_react.useLayoutEffect)(() => {
166
175
  updateMask();
167
176
  }, []);
168
177
  const handleClick = (e, item) => {
@@ -172,13 +181,16 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
172
181
  if (index === void 0 || index === null) {
173
182
  return;
174
183
  }
184
+ if (active !== value) {
185
+ setActive(index);
186
+ }
175
187
  if (index !== value) {
176
188
  onChange == null ? void 0 : onChange(e, { index });
177
189
  }
178
190
  };
179
191
  const providerValue = (0, import_react.useMemo)(() => {
180
- return { value, triggerChange: handleClick };
181
- }, [value, children, handleClick]);
192
+ return { value, align, triggerChange: handleClick };
193
+ }, [value, align, children, handleClick]);
182
194
  return /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({ ref, className: (0, import_clsx.default)(prefixCls, className) }, others), /* @__PURE__ */ import_react.default.createElement(
183
195
  "div",
184
196
  {
@@ -199,12 +211,12 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
199
211
  "div",
200
212
  {
201
213
  ref: activeLineRef,
202
- className: (0, import_clsx.default)(`${prefixCls}-indicator`, {
203
- "bui-indicator-invisible": import_utils.isMini || !indicatorData.hasActiveTab
214
+ className: (0, import_clsx.default)(`${prefixCls}-tabline`, {
215
+ "bui-tabline-invisible": import_utils.isMini || !lineData.hasActiveTab
204
216
  }),
205
217
  style: {
206
- transition: "transform 0.3s ease-in-out",
207
- transform: `translate3d(${indicatorData.x}px, 0px, 0px)`
218
+ transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
219
+ transform: `translate3d(${lineData.x}px, 0px, 0px)`
208
220
  }
209
221
  }
210
222
  ), /* @__PURE__ */ import_react.default.createElement(import_TabsContext.TabsContextProvider, { value: providerValue }, !!tabs.length && tabs.map((item) => {
@@ -220,4 +232,8 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
220
232
  }), children)));
221
233
  });
222
234
  Tabs.displayName = "BuiTabs";
235
+ Tabs.defaultProps = {
236
+ align: "center",
237
+ tabs: []
238
+ };
223
239
  var Tabs_default = Tabs;
@@ -3,6 +3,9 @@ import React, { SyntheticEvent } from 'react';
3
3
  export interface TabHeaderItem {
4
4
  title: React.ReactNode;
5
5
  index: string;
6
+ /**
7
+ * 是否禁止点击
8
+ */
6
9
  disabled?: boolean;
7
10
  }
8
11
  export interface ITabsChangeData {
@@ -11,8 +14,11 @@ export interface ITabsChangeData {
11
14
  }
12
15
  export type TabChangeEvent = (e?: SyntheticEvent, data?: ITabsChangeData) => void;
13
16
  export interface ITabItem {
17
+ /** 面板标题 */
14
18
  title: React.ReactNode;
19
+ /** 面板的索引值 */
15
20
  index: string;
21
+ /** 面板是否禁用 */
16
22
  disabled?: boolean;
17
23
  }
18
24
  export type ITabAlign = 'start' | 'center';
@@ -26,6 +32,10 @@ export type TabsProps<D extends React.ElementType = 'div', P = {}> = OverridePro
26
32
  * 切换面板的数据
27
33
  */
28
34
  tabs?: ITabItem[];
35
+ /**
36
+ * 对齐方式,默认为center
37
+ */
38
+ align?: ITabAlign;
29
39
  /**
30
40
  * 切换面板的回调
31
41
  */
package/dist/Tag/Tag.css CHANGED
@@ -47,7 +47,7 @@
47
47
  border: 1px solid var(--bui-color-border-danger);
48
48
  }
49
49
  .bui-tag-outlined.bui-tag-vip {
50
- color: var(--bui-color-primary);
50
+ color: var(--bui-color-red);
51
51
  border: 1px solid var(--bui-color-border-primary);
52
52
  }
53
53
  .bui-tag-contained {