@bifrostui/react 2.0.0-alpha.15 → 2.0.0-alpha.18

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.
@@ -12,5 +12,5 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
12
12
  keepMounted?: boolean;
13
13
  } & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
14
14
  ref?: React.Ref<HTMLDivElement>;
15
- }, keyof import("@bifrostui/types").ICommonProps | "open" | "container" | "disablePortal" | "onClose" | "hideBackdrop" | "BackdropProps" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, keyof import("@bifrostui/types").ICommonProps | "open" | "onClose" | "container" | "disableScrollLock" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
16
16
  export default Modal;
package/dist/Tabs/Tab.css CHANGED
@@ -17,7 +17,6 @@
17
17
  .bui-tab-active {
18
18
  color: var(--bui-tab-active-color);
19
19
  font-weight: var(--bui-font-weight-bold);
20
- font-family: var(--bui-tab-active-font-family);
21
20
  }
22
21
  .bui-tab-disabled {
23
22
  opacity: 0.5;
@@ -43,23 +43,26 @@ const TabIndicator = ({
43
43
  registrationVersion
44
44
  }) => {
45
45
  const indicatorRef = (0, import_react.useRef)(null);
46
+ const isFirstRender = (0, import_react.useRef)(true);
46
47
  const getActiveTabElement = (0, import_utils.useEventCallback)(
47
48
  (activeValue) => {
48
49
  const tabRef = registeredTabs.current[activeValue];
49
50
  return tabRef == null ? void 0 : tabRef.current;
50
51
  }
51
52
  );
52
- const scrollIntoView = (0, import_utils.useEventCallback)((activeTab) => {
53
- const tabsEl = tabsContainerRef.current;
54
- if (!tabsEl || !activeTab) {
55
- return;
53
+ const scrollIntoView = (0, import_utils.useEventCallback)(
54
+ (activeTab, animate2 = true) => {
55
+ const tabsEl = tabsContainerRef.current;
56
+ if (!tabsEl || !activeTab) {
57
+ return;
58
+ }
59
+ (0, import_scroll.default)(
60
+ tabsEl,
61
+ activeTab.offsetLeft - (tabsEl.offsetWidth - activeTab.offsetWidth) / 2,
62
+ animate2 ? duration : 0
63
+ );
56
64
  }
57
- (0, import_scroll.default)(
58
- tabsEl,
59
- activeTab.offsetLeft - (tabsEl.offsetWidth - activeTab.offsetWidth) / 2,
60
- duration
61
- );
62
- });
65
+ );
63
66
  const animate = (0, import_utils.useEventCallback)(() => {
64
67
  const tabsEl = tabsContainerRef.current;
65
68
  if (!tabsEl)
@@ -79,7 +82,15 @@ const TabIndicator = ({
79
82
  indicator.style.visibility = "visible";
80
83
  const maxScrollDistance = containerScrollWidth - containerWidth;
81
84
  if (maxScrollDistance > 0 && !import_utils.isMini) {
82
- scrollIntoView(activeTab);
85
+ scrollIntoView(activeTab, !isFirstRender.current);
86
+ }
87
+ if (isFirstRender.current) {
88
+ isFirstRender.current = false;
89
+ requestAnimationFrame(() => {
90
+ if (indicator) {
91
+ indicator.style.transition = "transform 0.3s ease-in-out";
92
+ }
93
+ });
83
94
  }
84
95
  } else {
85
96
  indicator.style.visibility = "hidden";
@@ -103,7 +114,7 @@ const TabIndicator = ({
103
114
  ref: indicatorRef,
104
115
  className: (0, import_clsx.default)(`${rootClass}-indicator`),
105
116
  style: {
106
- transition: "transform 0.3s ease-in-out",
117
+ transition: "none",
107
118
  transform: "translate(0px, 0px)",
108
119
  visibility: "hidden"
109
120
  },
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface TabMaskProps {
3
- /** Tabs 容器的引用,用于监听滚动 */
4
- tabsContainerRef: React.RefObject<HTMLDivElement>;
5
3
  /** 位置:左侧或右侧 */
6
4
  position: 'left' | 'right';
7
5
  }
8
- declare const TabMask: React.FC<TabMaskProps>;
9
- export default TabMask;
6
+ declare const _default: React.NamedExoticComponent<TabMaskProps>;
7
+ export default _default;
@@ -32,57 +32,16 @@ __export(TabMask_exports, {
32
32
  module.exports = __toCommonJS(TabMask_exports);
33
33
  var import_react = __toESM(require("react"));
34
34
  var import_clsx = __toESM(require("clsx"));
35
- var import_utils = require("@bifrostui/utils");
36
- const rootClass = "bui-tabs";
37
- const TabMask = ({ tabsContainerRef, position }) => {
38
- const maskRef = (0, import_react.useRef)(null);
39
- const updateMaskOpacity = (0, import_react.useMemo)(
40
- () => (0, import_utils.throttle)(
41
- () => {
42
- const tabsEl = tabsContainerRef.current;
43
- const mask = maskRef.current;
44
- if (!tabsEl || !mask)
45
- return;
46
- const { scrollLeft, scrollWidth, offsetWidth } = tabsEl;
47
- let shouldShow = false;
48
- if (position === "left") {
49
- shouldShow = scrollLeft > 0;
50
- } else {
51
- const rightRange = Math.abs(
52
- scrollWidth - (scrollLeft + offsetWidth)
53
- );
54
- shouldShow = rightRange > 1;
55
- }
56
- mask.style.opacity = shouldShow ? "1" : "0";
57
- },
58
- 100,
59
- {
60
- trailing: true,
61
- leading: true
62
- }
35
+ var import_classes = require("./classes");
36
+ const TabMask = ({ position }) => /* @__PURE__ */ import_react.default.createElement(
37
+ "div",
38
+ {
39
+ className: (0, import_clsx.default)(
40
+ import_classes.tabMaskClass,
41
+ position === "left" ? import_classes.tabMaskLeftClass : import_classes.tabMaskRightClass
63
42
  ),
64
- [tabsContainerRef, position]
65
- );
66
- (0, import_react.useEffect)(() => {
67
- const tabsEl = tabsContainerRef.current;
68
- if (!tabsEl)
69
- return void 0;
70
- updateMaskOpacity();
71
- tabsEl.addEventListener("scroll", updateMaskOpacity);
72
- return () => {
73
- tabsEl.removeEventListener("scroll", updateMaskOpacity);
74
- };
75
- }, [tabsContainerRef, updateMaskOpacity]);
76
- return /* @__PURE__ */ import_react.default.createElement(
77
- "div",
78
- {
79
- ref: maskRef,
80
- className: (0, import_clsx.default)(`${rootClass}-mask`, `${rootClass}-mask-${position}`),
81
- style: {
82
- opacity: 0
83
- },
84
- "aria-hidden": "true"
85
- }
86
- );
87
- };
88
- var TabMask_default = TabMask;
43
+ "aria-hidden": "true"
44
+ }
45
+ );
46
+ TabMask.displayName = "BuiTabsMask";
47
+ var TabMask_default = /* @__PURE__ */ import_react.default.memo(TabMask);
@@ -16,7 +16,6 @@ xhs-page {
16
16
  --bui-tab-height: 100%;
17
17
  --bui-tab-padding: var(--bui-spacing-lg) var(--bui-spacing-lg) 10px;
18
18
  --bui-tab-active-color: var(--bui-color-fg-default);
19
- --bui-tab-active-font-family: var(--bui-font-family-accent, inherit);
20
19
  }
21
20
  .bui-tabs {
22
21
  position: relative;
package/dist/Tabs/Tabs.js CHANGED
@@ -1,6 +1,8 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
8
  var __getProtoOf = Object.getPrototypeOf;
@@ -18,6 +20,7 @@ var __spreadValues = (a, b) => {
18
20
  }
19
21
  return a;
20
22
  };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
24
  var __objRest = (source, exclude) => {
22
25
  var target = {};
23
26
  for (var prop in source)
@@ -100,6 +103,7 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
100
103
  {}
101
104
  );
102
105
  const [registrationVersion, setRegistrationVersion] = (0, import_react.useState)(0);
106
+ const [isScrollable, setIsScrollable] = (0, import_react.useState)(false);
103
107
  if (process.env.NODE_ENV !== "production") {
104
108
  if (tabs.length > 0 && import_react.default.Children.count(children) > 0) {
105
109
  console.warn(
@@ -144,10 +148,21 @@ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
144
148
  }
145
149
  return children;
146
150
  }, [tabs, children]);
147
- if (process.env.NODE_ENV !== "production") {
148
- console.count("Tabs render......");
149
- }
150
- return /* @__PURE__ */ import_react.default.createElement("div", __spreadValues({ ref, className: (0, import_clsx.default)(import_classes.tabsRootClass, className) }, others), /* @__PURE__ */ import_react.default.createElement(import_TabMask.default, { tabsContainerRef: tabsRef, position: "left" }), /* @__PURE__ */ import_react.default.createElement(import_TabMask.default, { tabsContainerRef: tabsRef, position: "right" }), /* @__PURE__ */ import_react.default.createElement(
151
+ (0, import_react.useEffect)(() => {
152
+ const tabsEl = tabsRef.current;
153
+ if (!tabsEl)
154
+ return;
155
+ const checkScrollable = () => {
156
+ setIsScrollable(tabsEl.scrollWidth > tabsEl.offsetWidth);
157
+ };
158
+ checkScrollable();
159
+ const resizeObserver = new ResizeObserver(checkScrollable);
160
+ resizeObserver.observe(tabsEl);
161
+ return () => {
162
+ resizeObserver.disconnect();
163
+ };
164
+ }, [registrationVersion]);
165
+ return /* @__PURE__ */ import_react.default.createElement("div", __spreadProps(__spreadValues({ className: (0, import_clsx.default)(import_classes.tabsRootClass, className) }, others), { ref }), isScrollable && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_TabMask.default, { position: "left" }), /* @__PURE__ */ import_react.default.createElement(import_TabMask.default, { position: "right" })), /* @__PURE__ */ import_react.default.createElement(
151
166
  "div",
152
167
  {
153
168
  className: `${import_classes.tabsRootClass}-tabs`,
@@ -16,7 +16,6 @@ xhs-page {
16
16
  --bui-tab-height: 100%;
17
17
  --bui-tab-padding: var(--bui-spacing-lg) var(--bui-spacing-lg) 10px;
18
18
  --bui-tab-active-color: var(--bui-color-fg-default);
19
- --bui-tab-active-font-family: var(--bui-font-family-accent, inherit);
20
19
  }
21
20
  .bui-tabs {
22
21
  position: relative;
@@ -107,7 +106,6 @@ xhs-page {
107
106
  .bui-tab-active {
108
107
  color: var(--bui-tab-active-color);
109
108
  font-weight: var(--bui-font-weight-bold);
110
- font-family: var(--bui-tab-active-font-family);
111
109
  }
112
110
  .bui-tab-disabled {
113
111
  opacity: 0.5;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { TabProps } from '../Tab.types';
3
3
  import '../Tab.less';
4
- declare const _default: React.NamedExoticComponent<TabProps<"div", {}>>;
4
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<TabProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>>;
5
5
  export default _default;
@@ -36,7 +36,7 @@ var import_utils = require("@bifrostui/utils");
36
36
  var import_TabsContext = __toESM(require("./TabsContext"));
37
37
  var import_classes = require("../classes");
38
38
  var import_Tab2 = require("../Tab.css");
39
- const Tab = (props) => {
39
+ const Tab = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
40
40
  const {
41
41
  className,
42
42
  children,
@@ -45,6 +45,8 @@ const Tab = (props) => {
45
45
  onClick,
46
46
  style
47
47
  } = props;
48
+ const innerRef = (0, import_react.useRef)(null);
49
+ const handleRef = (0, import_utils.useForkRef)(ref, innerRef);
48
50
  const isActive = (0, import_utils.useContextSelector)(
49
51
  import_TabsContext.default,
50
52
  (ctx) => ctx.value === index
@@ -85,6 +87,7 @@ const Tab = (props) => {
85
87
  "div",
86
88
  {
87
89
  id: tabId,
90
+ ref: handleRef,
88
91
  className: rootCls,
89
92
  style,
90
93
  onClick: (e) => {
@@ -96,7 +99,7 @@ const Tab = (props) => {
96
99
  },
97
100
  children
98
101
  );
99
- };
102
+ });
100
103
  Tab.displayName = "BuiTab";
101
104
  var Tab_default = /* @__PURE__ */ import_react.default.memo(Tab, (prevProps, nextProps) => {
102
105
  return prevProps.index === nextProps.index && prevProps.disabled === nextProps.disabled && prevProps.className === nextProps.className && prevProps.children === nextProps.children;
@@ -56,6 +56,9 @@ var import_taro = __toESM(require("@tarojs/taro"));
56
56
  var import_utils = require("@bifrostui/utils");
57
57
  var import_classes = require("../classes");
58
58
  var import_queryBatch = require("./utils/queryBatch");
59
+ const isValidTabValue = (value) => {
60
+ return value !== void 0 && value !== null;
61
+ };
59
62
  const TabIndicator = ({
60
63
  currentValue,
61
64
  registeredTabValues,
@@ -63,8 +66,7 @@ const TabIndicator = ({
63
66
  scrollViewId,
64
67
  registrationVersion
65
68
  }) => {
66
- const [transform, setTransform] = (0, import_react.useState)("translate(0px, 0px)");
67
- const [visibility, setVisibility] = (0, import_react.useState)("hidden");
69
+ const indicatorRef = (0, import_react.useRef)(null);
68
70
  const animationTimerRef = (0, import_react.useRef)(null);
69
71
  const positionCacheRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
70
72
  const containerInfoRef = (0, import_react.useRef)(null);
@@ -72,14 +74,21 @@ const TabIndicator = ({
72
74
  const isInitializedRef = (0, import_react.useRef)(false);
73
75
  const initRetryCountRef = (0, import_react.useRef)(0);
74
76
  const maxInitRetries = 5;
77
+ const isFirstRender = (0, import_react.useRef)(true);
78
+ const isInitializingRef = (0, import_react.useRef)(false);
79
+ const initVersionRef = (0, import_react.useRef)(0);
80
+ const isMountedRef = (0, import_react.useRef)(true);
75
81
  const updateIndicatorPosition = (0, import_utils.useEventCallback)(() => {
76
- if (!currentValue || !registeredTabValues.includes(currentValue)) {
77
- setVisibility("hidden");
82
+ const indicator = indicatorRef.current;
83
+ if (!indicator)
84
+ return;
85
+ if (!isValidTabValue(currentValue) || !registeredTabValues.includes(currentValue)) {
86
+ indicator.style.visibility = "hidden";
78
87
  return;
79
88
  }
80
89
  const cachedPosition = positionCacheRef.current.get(currentValue);
81
90
  const containerInfo = containerInfoRef.current;
82
- if (!cachedPosition || !containerInfo) {
91
+ if (!cachedPosition || !containerInfo || !isInitializedRef.current) {
83
92
  if (!isInitializedRef.current) {
84
93
  initializePositions();
85
94
  }
@@ -89,16 +98,41 @@ const TabIndicator = ({
89
98
  const activeTabWidth = cachedPosition.width;
90
99
  const indicatorWidth = indicatorWidthRef.current;
91
100
  const x = activeTabLeft + (activeTabWidth - indicatorWidth) / 2;
92
- setTransform(`translate(${x}px, 0px)`);
93
- setVisibility("visible");
101
+ indicator.style.transform = `translate(${x}px, 0px)`;
102
+ if (isFirstRender.current) {
103
+ import_taro.default.nextTick(() => {
104
+ if (!isMountedRef.current || !indicatorRef.current)
105
+ return;
106
+ indicatorRef.current.style.visibility = "visible";
107
+ import_taro.default.nextTick(() => {
108
+ if (!isMountedRef.current || !indicatorRef.current)
109
+ return;
110
+ indicatorRef.current.style.transition = "transform 0.3s ease-in-out";
111
+ });
112
+ });
113
+ isFirstRender.current = false;
114
+ } else {
115
+ indicator.style.visibility = "visible";
116
+ }
94
117
  });
95
118
  const initializePositions = (0, import_utils.useEventCallback)(() => __async(void 0, null, function* () {
119
+ if (!isMountedRef.current)
120
+ return;
121
+ if (isInitializingRef.current)
122
+ return;
123
+ isInitializingRef.current = true;
124
+ initVersionRef.current += 1;
125
+ const currentVersion = initVersionRef.current;
96
126
  try {
97
127
  const result = yield (0, import_queryBatch.batchQueryTabs)({
98
128
  scrollViewId,
99
129
  wrapperId,
100
130
  tabValues: registeredTabValues
101
131
  });
132
+ if (!isMountedRef.current)
133
+ return;
134
+ if (currentVersion !== initVersionRef.current)
135
+ return;
102
136
  const { scrollView, scrollFields, wrapper, indicator, tabs } = result;
103
137
  if (!scrollView || !wrapper || !indicator || !scrollFields) {
104
138
  if (initRetryCountRef.current < maxInitRetries) {
@@ -107,8 +141,30 @@ const TabIndicator = ({
107
141
  clearTimeout(animationTimerRef.current);
108
142
  }
109
143
  animationTimerRef.current = setTimeout(() => {
144
+ if (!isMountedRef.current)
145
+ return;
146
+ isInitializingRef.current = false;
110
147
  initializePositions();
111
148
  }, 100);
149
+ } else {
150
+ isInitializingRef.current = false;
151
+ }
152
+ return;
153
+ }
154
+ if (!indicator.width || indicator.width <= 0) {
155
+ if (initRetryCountRef.current < maxInitRetries) {
156
+ initRetryCountRef.current += 1;
157
+ if (animationTimerRef.current) {
158
+ clearTimeout(animationTimerRef.current);
159
+ }
160
+ animationTimerRef.current = setTimeout(() => {
161
+ if (!isMountedRef.current)
162
+ return;
163
+ isInitializingRef.current = false;
164
+ initializePositions();
165
+ }, 100);
166
+ } else {
167
+ isInitializingRef.current = false;
112
168
  }
113
169
  return;
114
170
  }
@@ -121,9 +177,8 @@ const TabIndicator = ({
121
177
  registeredTabValues.forEach((value, index) => {
122
178
  const tabRect = tabs[index];
123
179
  if (tabRect && tabRect.width > 0) {
124
- const relativeLeft = tabRect.left - wrapper.left;
125
180
  newCache.set(value, {
126
- left: relativeLeft,
181
+ left: tabRect.left - wrapper.left,
127
182
  width: tabRect.width
128
183
  });
129
184
  }
@@ -135,40 +190,74 @@ const TabIndicator = ({
135
190
  clearTimeout(animationTimerRef.current);
136
191
  }
137
192
  animationTimerRef.current = setTimeout(() => {
193
+ if (!isMountedRef.current)
194
+ return;
195
+ isInitializingRef.current = false;
138
196
  initializePositions();
139
197
  }, 100);
198
+ } else {
199
+ isInitializingRef.current = false;
140
200
  }
141
201
  return;
142
202
  }
203
+ if (currentVersion !== initVersionRef.current || !isMountedRef.current) {
204
+ return;
205
+ }
143
206
  initRetryCountRef.current = 0;
144
207
  positionCacheRef.current = newCache;
145
208
  isInitializedRef.current = true;
209
+ isInitializingRef.current = false;
146
210
  updateIndicatorPosition();
147
211
  } catch (error) {
148
212
  console.error("[TabIndicator] \u6279\u91CF\u67E5\u8BE2\u5931\u8D25:", error);
213
+ isInitializingRef.current = false;
214
+ if (isMountedRef.current && initRetryCountRef.current < maxInitRetries) {
215
+ initRetryCountRef.current += 1;
216
+ if (animationTimerRef.current) {
217
+ clearTimeout(animationTimerRef.current);
218
+ }
219
+ animationTimerRef.current = setTimeout(() => {
220
+ if (!isMountedRef.current)
221
+ return;
222
+ initializePositions();
223
+ }, 100);
224
+ }
149
225
  }
150
226
  }));
151
227
  (0, import_react.useEffect)(() => {
152
228
  if (registeredTabValues.length === 0) {
229
+ if (indicatorRef.current) {
230
+ indicatorRef.current.style.visibility = "hidden";
231
+ }
153
232
  return void 0;
154
233
  }
234
+ initVersionRef.current += 1;
155
235
  if (animationTimerRef.current) {
156
236
  clearTimeout(animationTimerRef.current);
237
+ animationTimerRef.current = null;
157
238
  }
158
239
  isInitializedRef.current = false;
240
+ isInitializingRef.current = false;
159
241
  initRetryCountRef.current = 0;
160
242
  import_taro.default.nextTick(() => {
243
+ if (!isMountedRef.current)
244
+ return;
161
245
  initializePositions();
162
246
  });
163
247
  return () => {
164
248
  if (animationTimerRef.current) {
165
249
  clearTimeout(animationTimerRef.current);
250
+ animationTimerRef.current = null;
166
251
  }
252
+ initVersionRef.current += 1;
253
+ isInitializingRef.current = false;
167
254
  };
168
255
  }, [registrationVersion, initializePositions]);
169
256
  (0, import_react.useEffect)(() => {
170
- if (!currentValue) {
171
- setVisibility("hidden");
257
+ if (!isValidTabValue(currentValue)) {
258
+ if (indicatorRef.current) {
259
+ indicatorRef.current.style.visibility = "hidden";
260
+ }
172
261
  return;
173
262
  }
174
263
  updateIndicatorPosition();
@@ -176,10 +265,20 @@ const TabIndicator = ({
176
265
  (0, import_react.useEffect)(() => {
177
266
  var _a, _b;
178
267
  const handleResize = () => {
268
+ if (!isMountedRef.current)
269
+ return;
270
+ initVersionRef.current += 1;
179
271
  isInitializedRef.current = false;
272
+ isInitializingRef.current = false;
180
273
  initRetryCountRef.current = 0;
181
274
  positionCacheRef.current.clear();
275
+ if (animationTimerRef.current) {
276
+ clearTimeout(animationTimerRef.current);
277
+ animationTimerRef.current = null;
278
+ }
182
279
  import_taro.default.nextTick(() => {
280
+ if (!isMountedRef.current)
281
+ return;
183
282
  initializePositions();
184
283
  });
185
284
  };
@@ -189,15 +288,26 @@ const TabIndicator = ({
189
288
  (_b2 = (_a2 = import_taro.default).offWindowResize) == null ? void 0 : _b2.call(_a2, handleResize);
190
289
  };
191
290
  }, [initializePositions]);
291
+ (0, import_react.useEffect)(() => {
292
+ isMountedRef.current = true;
293
+ return () => {
294
+ isMountedRef.current = false;
295
+ if (animationTimerRef.current) {
296
+ clearTimeout(animationTimerRef.current);
297
+ animationTimerRef.current = null;
298
+ }
299
+ };
300
+ }, []);
192
301
  return /* @__PURE__ */ import_react.default.createElement(
193
302
  "div",
194
303
  {
304
+ ref: indicatorRef,
195
305
  id: `${wrapperId}-indicator`,
196
306
  className: (0, import_clsx.default)(import_classes.tabIndicatorClass),
197
307
  style: {
198
- transition: "transform 0.3s ease-in-out",
199
- transform,
200
- visibility
308
+ transition: "none",
309
+ transform: "translate(0px, 0px)",
310
+ visibility: "hidden"
201
311
  }
202
312
  }
203
313
  );
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { TabsProps } from '../Tabs.types';
3
3
  import '../Tabs.less';
4
- declare const Tabs: React.FC<TabsProps>;
4
+ declare const Tabs: React.ForwardRefExoticComponent<Omit<TabsProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
5
  export default Tabs;
@@ -57,12 +57,12 @@ var import_components = require("@tarojs/components");
57
57
  var import_utils = require("@bifrostui/utils");
58
58
  var import_Tab = __toESM(require("./Tab"));
59
59
  var import_TabIndicator = __toESM(require("./TabIndicator"));
60
- var import_TabMask = __toESM(require("./TabMask"));
60
+ var import_TabMask = __toESM(require("../TabMask"));
61
61
  var import_TabsContext = require("./TabsContext");
62
62
  var import_classes = require("../classes");
63
63
  var import_queryBatch = require("./utils/queryBatch");
64
64
  var import_Tabs2 = require("../Tabs.css");
65
- const Tabs = (props) => {
65
+ const Tabs = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
66
66
  const {
67
67
  children,
68
68
  className,
@@ -97,8 +97,10 @@ const Tabs = (props) => {
97
97
  const [scrollLeft, setScrollLeft] = (0, import_react.useState)(0);
98
98
  const [containerWidth, setContainerWidth] = (0, import_react.useState)(0);
99
99
  const [scrollWidth, setScrollWidth] = (0, import_react.useState)(0);
100
- const scrollLeftUpdateTimerRef = import_react.default.useRef(null);
101
100
  const lastScrollLeftRef = import_react.default.useRef(0);
101
+ const isFirstScroll = import_react.default.useRef(true);
102
+ const [scrollWithAnimation, setScrollWithAnimation] = import_react.default.useState(false);
103
+ const isScrollable = scrollWidth > containerWidth;
102
104
  if (process.env.NODE_ENV !== "production") {
103
105
  if (tabs.length > 0 && import_react.default.Children.count(children) > 0) {
104
106
  console.warn(
@@ -138,14 +140,6 @@ const Tabs = (props) => {
138
140
  (e) => {
139
141
  const { scrollLeft: newScrollLeft, scrollWidth: newScrollWidth } = e.detail;
140
142
  lastScrollLeftRef.current = newScrollLeft;
141
- if (scrollLeftUpdateTimerRef.current) {
142
- clearTimeout(scrollLeftUpdateTimerRef.current);
143
- }
144
- scrollLeftUpdateTimerRef.current = setTimeout(() => {
145
- if (Math.abs(lastScrollLeftRef.current - scrollLeft) > 1) {
146
- setScrollLeft(lastScrollLeftRef.current);
147
- }
148
- }, 150);
149
143
  if (newScrollWidth && newScrollWidth !== scrollWidth) {
150
144
  setScrollWidth(newScrollWidth);
151
145
  }
@@ -188,6 +182,12 @@ const Tabs = (props) => {
188
182
  );
189
183
  setScrollLeft(finalScrollLeft);
190
184
  lastScrollLeftRef.current = finalScrollLeft;
185
+ if (isFirstScroll.current) {
186
+ import_taro.default.nextTick(() => {
187
+ setScrollWithAnimation(true);
188
+ });
189
+ isFirstScroll.current = false;
190
+ }
191
191
  }));
192
192
  import_react.default.useEffect(() => {
193
193
  if (!currentValue || registeredTabValues.length === 0) {
@@ -221,38 +221,14 @@ const Tabs = (props) => {
221
221
  }
222
222
  return children;
223
223
  }, [tabs, children]);
224
- import_react.default.useEffect(() => {
225
- return () => {
226
- if (scrollLeftUpdateTimerRef.current) {
227
- clearTimeout(scrollLeftUpdateTimerRef.current);
228
- }
229
- };
230
- }, []);
231
- return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_clsx.default)(import_classes.tabsRootClass, className), style }, /* @__PURE__ */ import_react.default.createElement(
232
- import_TabMask.default,
233
- {
234
- position: "left",
235
- scrollLeft,
236
- containerWidth,
237
- scrollWidth
238
- }
239
- ), /* @__PURE__ */ import_react.default.createElement(
240
- import_TabMask.default,
241
- {
242
- position: "right",
243
- scrollLeft,
244
- containerWidth,
245
- scrollWidth
246
- }
247
- ), /* @__PURE__ */ import_react.default.createElement(
224
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_clsx.default)(import_classes.tabsRootClass, className), style, ref }, isScrollable && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_TabMask.default, { position: "left" }), /* @__PURE__ */ import_react.default.createElement(import_TabMask.default, { position: "right" })), /* @__PURE__ */ import_react.default.createElement(
248
225
  import_components.ScrollView,
249
226
  {
250
227
  id: scrollViewId,
251
228
  className: import_classes.tabsScrollClass,
252
229
  scrollX: true,
253
- scrollWithAnimation: true,
230
+ scrollWithAnimation,
254
231
  scrollLeft,
255
- scrollAnimationDuration: "200",
256
232
  onScroll: handleScroll,
257
233
  enhanced: true,
258
234
  showScrollbar: false,
@@ -270,6 +246,6 @@ const Tabs = (props) => {
270
246
  }
271
247
  ), /* @__PURE__ */ import_react.default.createElement(import_TabsContext.TabsContextProvider, { value: contextValue }, renderedTabs))
272
248
  ));
273
- };
249
+ });
274
250
  Tabs.displayName = "BuiTabs";
275
251
  var Tabs_default = Tabs;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { DatePickerProps } from './DatePicker.types';
3
- declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps<"div", Omit<import("../Picker").PickerProps<"div", import("..").DrawerProps>, "defaultValue" | "onChange" | "value" | "onClose" | "onConfirm">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
3
+ declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps<"div", Omit<import("../Picker").PickerProps<"div", import("..").DrawerProps>, "value" | "defaultValue" | "onChange" | "onClose" | "onConfirm">>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
4
  export default DatePicker;
@@ -12,5 +12,5 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
12
12
  keepMounted?: boolean;
13
13
  } & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
14
14
  ref?: React.Ref<HTMLDivElement>;
15
- }, keyof import("@bifrostui/types").ICommonProps | "open" | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
15
+ }, "open" | "container" | keyof import("@bifrostui/types").ICommonProps | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
16
16
  export default Modal;