@bifrostui/react 1.4.5-beta.3 → 1.4.5

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
package/es/Tabs/Tabs.js CHANGED
@@ -26,31 +26,44 @@ var __objRest = (source, exclude) => {
26
26
  }
27
27
  return target;
28
28
  };
29
- import { debounce, isMini, throttle, useEventCallback } from "@bifrostui/utils";
29
+ import {
30
+ debounce,
31
+ isMini,
32
+ throttle,
33
+ useDidMountEffect
34
+ } from "@bifrostui/utils";
30
35
  import clsx from "clsx";
31
- import React, { useEffect, useMemo, useRef, useState } from "react";
36
+ import React, {
37
+ useEffect,
38
+ useLayoutEffect,
39
+ useMemo,
40
+ useRef,
41
+ useState
42
+ } from "react";
32
43
  import Tab from "./Tab";
33
44
  import { TabsContextProvider } from "./TabsContext";
34
45
  import bound from "./utils/bound";
35
46
  import "./Tabs.css";
36
47
  const prefixCls = "bui-tabs";
37
48
  const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
38
- const _a = props, { children, className, value, tabs = [], onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "onChange"]);
49
+ const _a = props, { children, className, value, tabs, align, onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "align", "onChange"]);
50
+ const [active, setActive] = useState("");
39
51
  const tabsRef = useRef(null);
40
52
  const activeLineRef = useRef(null);
41
- const [indicatorData, setIndicatorData] = useState({
53
+ const [lineData, setLineData] = useState({
42
54
  x: 0,
55
+ transitionInUse: false,
43
56
  hasActiveTab: false
44
57
  });
45
58
  const [maskData, setMaskData] = useState({
46
59
  leftMaskOpacity: 0,
47
60
  rightMaskOpacity: 0
48
61
  });
49
- const animate = useEventCallback(() => {
62
+ const animate = ({ transitionInUse }) => {
50
63
  const container = tabsRef.current;
51
64
  if (!container)
52
65
  return;
53
- const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === value);
66
+ const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === active);
54
67
  const activeLine = activeLineRef.current;
55
68
  if (!activeLine)
56
69
  return;
@@ -81,8 +94,9 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
81
94
  activeLineWidth = activeLine.offsetWidth;
82
95
  x = activeTabLeft + (activeTabWidth - activeLineWidth) / 2;
83
96
  }
84
- setIndicatorData({
97
+ setLineData({
85
98
  x,
99
+ transitionInUse,
86
100
  hasActiveTab: !!activeTab
87
101
  });
88
102
  const maxScrollDistance = containerScrollWidth - containerWidth;
@@ -96,7 +110,26 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
96
110
  if (tabsRef.current) {
97
111
  tabsRef.current.scrollLeft = nextScrollLeft;
98
112
  }
99
- });
113
+ };
114
+ useEffect(() => {
115
+ setActive(value);
116
+ }, [value]);
117
+ useLayoutEffect(() => {
118
+ animate({ transitionInUse: false });
119
+ }, []);
120
+ useEffect(() => {
121
+ const handleResize = debounce(() => {
122
+ animate({ transitionInUse: true });
123
+ updateMask();
124
+ }, 100);
125
+ window.addEventListener("resize", handleResize);
126
+ return () => {
127
+ window.removeEventListener("resize", handleResize);
128
+ };
129
+ }, [active]);
130
+ useDidMountEffect(() => {
131
+ animate({ transitionInUse: true });
132
+ }, [active, tabs, children]);
100
133
  const updateMask = useMemo(
101
134
  () => throttle(
102
135
  () => {
@@ -119,20 +152,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
119
152
  ),
120
153
  []
121
154
  );
122
- useEffect(() => {
123
- animate();
124
- }, [value]);
125
- useEffect(() => {
126
- const handleResize = debounce(() => {
127
- animate();
128
- updateMask();
129
- }, 100);
130
- window.addEventListener("resize", handleResize);
131
- return () => {
132
- window.removeEventListener("resize", handleResize);
133
- };
134
- }, []);
135
- useEffect(() => {
155
+ useLayoutEffect(() => {
136
156
  updateMask();
137
157
  }, []);
138
158
  const handleClick = (e, item) => {
@@ -142,13 +162,16 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
142
162
  if (index === void 0 || index === null) {
143
163
  return;
144
164
  }
165
+ if (active !== value) {
166
+ setActive(index);
167
+ }
145
168
  if (index !== value) {
146
169
  onChange == null ? void 0 : onChange(e, { index });
147
170
  }
148
171
  };
149
172
  const providerValue = useMemo(() => {
150
- return { value, triggerChange: handleClick };
151
- }, [value, children, handleClick]);
173
+ return { value, align, triggerChange: handleClick };
174
+ }, [value, align, children, handleClick]);
152
175
  return /* @__PURE__ */ React.createElement("div", __spreadValues({ ref, className: clsx(prefixCls, className) }, others), /* @__PURE__ */ React.createElement(
153
176
  "div",
154
177
  {
@@ -169,12 +192,12 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
169
192
  "div",
170
193
  {
171
194
  ref: activeLineRef,
172
- className: clsx(`${prefixCls}-indicator`, {
173
- "bui-indicator-invisible": isMini || !indicatorData.hasActiveTab
195
+ className: clsx(`${prefixCls}-tabline`, {
196
+ "bui-tabline-invisible": isMini || !lineData.hasActiveTab
174
197
  }),
175
198
  style: {
176
- transition: "transform 0.3s ease-in-out",
177
- transform: `translate3d(${indicatorData.x}px, 0px, 0px)`
199
+ transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
200
+ transform: `translate3d(${lineData.x}px, 0px, 0px)`
178
201
  }
179
202
  }
180
203
  ), /* @__PURE__ */ React.createElement(TabsContextProvider, { value: providerValue }, !!tabs.length && tabs.map((item) => {
@@ -190,6 +213,10 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
190
213
  }), children)));
191
214
  });
192
215
  Tabs.displayName = "BuiTabs";
216
+ Tabs.defaultProps = {
217
+ align: "center",
218
+ tabs: []
219
+ };
193
220
  var Tabs_default = Tabs;
194
221
  export {
195
222
  Tabs_default as default
@@ -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/es/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 {
package/es/Tag/Tag.js CHANGED
@@ -47,9 +47,9 @@ const Tag = /* @__PURE__ */ React.forwardRef((props, ref) => {
47
47
  const _a = props, {
48
48
  className,
49
49
  style,
50
- color = "default",
50
+ color,
51
51
  htmlColor,
52
- variant = "outlined",
52
+ variant,
53
53
  onClick,
54
54
  children
55
55
  } = _a, others = __objRest(_a, [
@@ -98,6 +98,10 @@ const Tag = /* @__PURE__ */ React.forwardRef((props, ref) => {
98
98
  );
99
99
  });
100
100
  Tag.displayName = "BuiTag";
101
+ Tag.defaultProps = {
102
+ variant: "outlined",
103
+ color: "default"
104
+ };
101
105
  var Tag_default = Tag;
102
106
  export {
103
107
  Tag_default as default
@@ -40,17 +40,17 @@ const TextArea = /* @__PURE__ */ React.forwardRef(
40
40
  const _a = props, {
41
41
  className,
42
42
  value,
43
- defaultValue = "",
43
+ defaultValue,
44
44
  textareaProps,
45
45
  textareaRef,
46
46
  name,
47
47
  placeholder,
48
48
  disabled,
49
- rows = DEFAULT_ROWS,
49
+ rows,
50
50
  maxLength,
51
- autoSize = false,
52
- autoFocus = false,
53
- showCount = false,
51
+ autoSize,
52
+ autoFocus,
53
+ showCount,
54
54
  onChange
55
55
  } = _a, others = __objRest(_a, [
56
56
  "className",
@@ -175,6 +175,13 @@ const TextArea = /* @__PURE__ */ React.forwardRef(
175
175
  }
176
176
  );
177
177
  TextArea.displayName = "BuiTextArea";
178
+ TextArea.defaultProps = {
179
+ defaultValue: "",
180
+ rows: DEFAULT_ROWS,
181
+ autoSize: false,
182
+ autoFocus: false,
183
+ showCount: false
184
+ };
178
185
  var TextArea_default = TextArea;
179
186
  export {
180
187
  TextArea_default as default
@@ -1,6 +1,6 @@
1
1
  .bui-tooltip {
2
2
  --arrow-size: var(--bui-tooltip-arrow-size, 8PX);
3
- --location-position: var(--bui-tooltip-location-position, 8PX);
3
+ --localtion-position: var(--bui-tooltip-localtion-position, 8PX);
4
4
  --max-width: var(--bui-tooltip-max-width, 350px);
5
5
  --content-min-width: var(--bui-tooltip-content-min-width, 30px);
6
6
  --content-min-height: var(--bui-tooltip-content-min-height, 32px);
@@ -17,16 +17,16 @@
17
17
  position: absolute;
18
18
  }
19
19
  .bui-tooltip .bui-tooltip-arrow.location-left {
20
- left: var(--location-position);
20
+ left: var(--localtion-position);
21
21
  }
22
22
  .bui-tooltip .bui-tooltip-arrow.location-right {
23
- right: var(--location-position);
23
+ right: var(--localtion-position);
24
24
  }
25
25
  .bui-tooltip .bui-tooltip-arrow.location-top {
26
- top: var(--location-position);
26
+ top: var(--localtion-position);
27
27
  }
28
28
  .bui-tooltip .bui-tooltip-arrow.location-bottom {
29
- bottom: var(--location-position);
29
+ bottom: var(--localtion-position);
30
30
  }
31
31
  .bui-tooltip.tooltip-top .location-center,
32
32
  .bui-tooltip.tooltip-bottom .location-center {
@@ -59,8 +59,8 @@ const TransitionCore = forwardRef(
59
59
  children,
60
60
  mountOnEnter,
61
61
  unmountOnExit,
62
- enter = true,
63
- exit = true,
62
+ enter,
63
+ exit,
64
64
  timeout: _timeout,
65
65
  delay: _delay,
66
66
  onEnter,
@@ -69,7 +69,7 @@ const TransitionCore = forwardRef(
69
69
  onExit,
70
70
  onExiting,
71
71
  onExited,
72
- nextTick = setTimeout
72
+ nextTick
73
73
  } = _a, childProps = __objRest(_a, [
74
74
  "appear",
75
75
  "in",
@@ -224,6 +224,11 @@ const TransitionCore = forwardRef(
224
224
  }
225
225
  );
226
226
  TransitionCore.displayName = "BuiTransitionCore";
227
+ TransitionCore.defaultProps = {
228
+ enter: true,
229
+ exit: true,
230
+ nextTick: setTimeout
231
+ };
227
232
  var TransitionCore_default = TransitionCore;
228
233
  export {
229
234
  TransitionCore_default as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifrostui/react",
3
- "version": "1.4.5-beta.3",
3
+ "version": "1.4.5",
4
4
  "description": "React components for building mobile application",
5
5
  "homepage": "http://bui.taopiaopiao.com",
6
6
  "license": "MIT",
@@ -30,13 +30,13 @@
30
30
  "glob": "11.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "clsx": "^2.1.1",
33
+ "clsx": "^1.2.1",
34
34
  "dayjs": "^1.11.7",
35
35
  "swiper": "^8.1.5",
36
- "@bifrostui/icons": "1.4.5-beta.3",
37
- "@bifrostui/types": "1.4.5-beta.3",
38
- "@bifrostui/utils": "1.4.5-beta.3",
39
- "@bifrostui/styles": "1.4.5-beta.3"
36
+ "@bifrostui/utils": "1.4.5",
37
+ "@bifrostui/icons": "1.4.5",
38
+ "@bifrostui/styles": "1.4.5",
39
+ "@bifrostui/types": "1.4.5"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@tarojs/components": "^3.0.0",