@bifrostui/react 1.4.7-beta.0 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/Calendar/Calendar.js +1 -5
  2. package/dist/Calendar/Calendar.types.d.ts +0 -5
  3. package/dist/Collapse/Collapse.css +1 -0
  4. package/dist/Collapse/Collapse.d.ts +1 -1
  5. package/dist/Collapse/Collapse.js +8 -11
  6. package/dist/CollapsePanel/CollapsePanel.css +2 -4
  7. package/dist/Dialog/FunctionalDialog.js +1 -1
  8. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  9. package/dist/Picker/Picker.css +0 -5
  10. package/dist/Picker/Picker.js +5 -27
  11. package/dist/Picker/Picker.types.d.ts +2 -15
  12. package/dist/Picker/PickerPanel.css +0 -4
  13. package/dist/Picker/PickerPanel.js +6 -7
  14. package/dist/Popover/Popover.js +27 -70
  15. package/dist/Portal/Portal.miniapp.js +4 -7
  16. package/dist/ScrollView/ScrollView.js +11 -24
  17. package/dist/ScrollView/ScrollView.types.d.ts +1 -0
  18. package/dist/Select/Select.css +4 -1
  19. package/dist/Select/Select.js +40 -63
  20. package/dist/Slider/Slider.js +5 -13
  21. package/dist/Tabs/Tab.js +4 -13
  22. package/dist/Tabs/Tabs.js +15 -30
  23. package/dist/Tabs/utils/bound.d.ts +1 -0
  24. package/dist/{DesktopPicker/utils/calcAfterMounted.js → Tabs/utils/bound.js} +14 -7
  25. package/dist/Toast/FunctionalToast.js +1 -1
  26. package/dist/Toast/Toast.css +1 -0
  27. package/dist/Tooltip/Tooltip.js +27 -70
  28. package/dist/index.d.ts +0 -6
  29. package/dist/index.js +1 -13
  30. package/dist/locales/base.d.ts +0 -11
  31. package/dist/locales/en-US.js +0 -24
  32. package/dist/locales/zh-CN.js +0 -24
  33. package/dist/locales/zh-TW.js +0 -24
  34. package/es/Calendar/Calendar.js +1 -5
  35. package/es/Calendar/Calendar.types.d.ts +0 -5
  36. package/es/Collapse/Collapse.css +1 -0
  37. package/es/Collapse/Collapse.d.ts +1 -1
  38. package/es/Collapse/Collapse.js +8 -11
  39. package/es/CollapsePanel/CollapsePanel.css +2 -4
  40. package/es/Dialog/FunctionalDialog.js +2 -2
  41. package/es/Picker/Picker.css +0 -5
  42. package/es/Picker/Picker.js +5 -27
  43. package/es/Picker/Picker.types.d.ts +2 -15
  44. package/es/Picker/PickerPanel.css +0 -4
  45. package/es/Picker/PickerPanel.js +6 -7
  46. package/es/Popover/Popover.js +29 -73
  47. package/es/Portal/Portal.miniapp.js +5 -8
  48. package/es/ScrollView/ScrollView.js +11 -24
  49. package/es/ScrollView/ScrollView.types.d.ts +1 -0
  50. package/es/Select/Select.css +4 -1
  51. package/es/Select/Select.js +41 -63
  52. package/es/Slider/Slider.js +6 -16
  53. package/es/Tabs/Tab.js +4 -13
  54. package/es/Tabs/Tabs.js +15 -30
  55. package/es/Tabs/utils/bound.d.ts +1 -0
  56. package/es/Tabs/utils/bound.js +13 -0
  57. package/es/Toast/FunctionalToast.js +2 -2
  58. package/es/Toast/Toast.css +1 -0
  59. package/es/Tooltip/Tooltip.js +29 -73
  60. package/es/index.d.ts +0 -6
  61. package/es/index.js +0 -6
  62. package/es/locales/base.d.ts +0 -11
  63. package/es/locales/en-US.js +0 -24
  64. package/es/locales/zh-CN.js +0 -24
  65. package/es/locales/zh-TW.js +0 -24
  66. package/package.json +5 -5
  67. package/dist/Collapse/Collapse.miniapp.d.ts +0 -5
  68. package/dist/Collapse/Collapse.miniapp.js +0 -177
  69. package/dist/DatePicker/DatePicker.d.ts +0 -4
  70. package/dist/DatePicker/DatePicker.js +0 -335
  71. package/dist/DatePicker/DatePicker.types.d.ts +0 -43
  72. package/dist/DatePicker/DatePicker.types.js +0 -35
  73. package/dist/DatePicker/index.d.ts +0 -2
  74. package/dist/DatePicker/index.js +0 -41
  75. package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +0 -5
  76. package/dist/DesktopDatePicker/DesktopDatePicker.js +0 -280
  77. package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +0 -163
  78. package/dist/DesktopDatePicker/DesktopDatePicker.types.js +0 -15
  79. package/dist/DesktopDatePicker/deskTopPickerContainer.css +0 -100
  80. package/dist/DesktopDatePicker/index.css +0 -61
  81. package/dist/DesktopDatePicker/index.d.ts +0 -2
  82. package/dist/DesktopDatePicker/index.js +0 -41
  83. package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +0 -6
  84. package/dist/DesktopDatePicker/useGetDatePickerContent.js +0 -343
  85. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +0 -5
  86. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -322
  87. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +0 -163
  88. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +0 -15
  89. package/dist/DesktopDateTimePicker/index.css +0 -66
  90. package/dist/DesktopDateTimePicker/index.d.ts +0 -2
  91. package/dist/DesktopDateTimePicker/index.js +0 -41
  92. package/dist/DesktopPicker/DesktopPicker.d.ts +0 -5
  93. package/dist/DesktopPicker/DesktopPicker.js +0 -238
  94. package/dist/DesktopPicker/DesktopPicker.types.d.ts +0 -57
  95. package/dist/DesktopPicker/DesktopPicker.types.js +0 -15
  96. package/dist/DesktopPicker/index.css +0 -37
  97. package/dist/DesktopPicker/index.d.ts +0 -2
  98. package/dist/DesktopPicker/index.js +0 -41
  99. package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +0 -2
  100. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +0 -2
  101. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +0 -38
  102. package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +0 -5
  103. package/dist/DesktopTimePicker/DesktopTimePicker.js +0 -288
  104. package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +0 -182
  105. package/dist/DesktopTimePicker/DesktopTimePicker.types.js +0 -15
  106. package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +0 -4
  107. package/dist/DesktopTimePicker/DesktopTimePickerList.js +0 -111
  108. package/dist/DesktopTimePicker/index.css +0 -170
  109. package/dist/DesktopTimePicker/index.d.ts +0 -2
  110. package/dist/DesktopTimePicker/index.js +0 -41
  111. package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +0 -6
  112. package/dist/DesktopTimePicker/useGetTimePickerContent.js +0 -246
  113. package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +0 -2
  114. package/dist/DesktopTimePicker/utils/scrollUtil.js +0 -27
  115. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +0 -2
  116. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +0 -51
  117. package/dist/DesktopTimePicker/utils/utils.d.ts +0 -28
  118. package/dist/DesktopTimePicker/utils/utils.js +0 -408
  119. package/dist/SwipeAction/SwipeAction.css +0 -79
  120. package/dist/SwipeAction/SwipeAction.d.ts +0 -5
  121. package/dist/SwipeAction/SwipeAction.js +0 -349
  122. package/dist/SwipeAction/SwipeAction.types.d.ts +0 -83
  123. package/dist/SwipeAction/SwipeAction.types.js +0 -39
  124. package/dist/SwipeAction/SwipeActionContext.d.ts +0 -4
  125. package/dist/SwipeAction/SwipeActionContext.js +0 -30
  126. package/dist/SwipeAction/SwipeActionItem.css +0 -31
  127. package/dist/SwipeAction/SwipeActionItem.d.ts +0 -5
  128. package/dist/SwipeAction/SwipeActionItem.js +0 -105
  129. package/dist/SwipeAction/index.d.ts +0 -4
  130. package/dist/SwipeAction/index.js +0 -45
  131. package/dist/Tabs/utils/scroll.d.ts +0 -2
  132. package/dist/Tabs/utils/scroll.js +0 -55
  133. package/es/Collapse/Collapse.miniapp.d.ts +0 -5
  134. package/es/Collapse/Collapse.miniapp.js +0 -157
  135. package/es/DatePicker/DatePicker.d.ts +0 -4
  136. package/es/DatePicker/DatePicker.js +0 -310
  137. package/es/DatePicker/DatePicker.types.d.ts +0 -43
  138. package/es/DatePicker/DatePicker.types.js +0 -1
  139. package/es/DatePicker/index.d.ts +0 -2
  140. package/es/DatePicker/index.js +0 -6
  141. package/es/DesktopDatePicker/DesktopDatePicker.d.ts +0 -5
  142. package/es/DesktopDatePicker/DesktopDatePicker.js +0 -253
  143. package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +0 -163
  144. package/es/DesktopDatePicker/DesktopDatePicker.types.js +0 -1
  145. package/es/DesktopDatePicker/deskTopPickerContainer.css +0 -100
  146. package/es/DesktopDatePicker/index.css +0 -61
  147. package/es/DesktopDatePicker/index.d.ts +0 -2
  148. package/es/DesktopDatePicker/index.js +0 -6
  149. package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +0 -6
  150. package/es/DesktopDatePicker/useGetDatePickerContent.js +0 -316
  151. package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +0 -5
  152. package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -295
  153. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +0 -163
  154. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +0 -1
  155. package/es/DesktopDateTimePicker/index.css +0 -66
  156. package/es/DesktopDateTimePicker/index.d.ts +0 -2
  157. package/es/DesktopDateTimePicker/index.js +0 -9
  158. package/es/DesktopPicker/DesktopPicker.d.ts +0 -5
  159. package/es/DesktopPicker/DesktopPicker.js +0 -221
  160. package/es/DesktopPicker/DesktopPicker.types.d.ts +0 -57
  161. package/es/DesktopPicker/DesktopPicker.types.js +0 -1
  162. package/es/DesktopPicker/index.css +0 -37
  163. package/es/DesktopPicker/index.d.ts +0 -2
  164. package/es/DesktopPicker/index.js +0 -6
  165. package/es/DesktopPicker/utils/calcAfterMounted.d.ts +0 -2
  166. package/es/DesktopPicker/utils/calcAfterMounted.js +0 -6
  167. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +0 -2
  168. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +0 -9
  169. package/es/DesktopTimePicker/DesktopTimePicker.d.ts +0 -5
  170. package/es/DesktopTimePicker/DesktopTimePicker.js +0 -261
  171. package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +0 -182
  172. package/es/DesktopTimePicker/DesktopTimePicker.types.js +0 -1
  173. package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +0 -4
  174. package/es/DesktopTimePicker/DesktopTimePickerList.js +0 -84
  175. package/es/DesktopTimePicker/index.css +0 -170
  176. package/es/DesktopTimePicker/index.d.ts +0 -2
  177. package/es/DesktopTimePicker/index.js +0 -6
  178. package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +0 -6
  179. package/es/DesktopTimePicker/useGetTimePickerContent.js +0 -223
  180. package/es/DesktopTimePicker/utils/scrollUtil.d.ts +0 -2
  181. package/es/DesktopTimePicker/utils/scrollUtil.js +0 -8
  182. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +0 -2
  183. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +0 -22
  184. package/es/DesktopTimePicker/utils/utils.d.ts +0 -28
  185. package/es/DesktopTimePicker/utils/utils.js +0 -365
  186. package/es/SwipeAction/SwipeAction.css +0 -79
  187. package/es/SwipeAction/SwipeAction.d.ts +0 -5
  188. package/es/SwipeAction/SwipeAction.js +0 -337
  189. package/es/SwipeAction/SwipeAction.types.d.ts +0 -83
  190. package/es/SwipeAction/SwipeAction.types.js +0 -1
  191. package/es/SwipeAction/SwipeActionContext.d.ts +0 -4
  192. package/es/SwipeAction/SwipeActionContext.js +0 -11
  193. package/es/SwipeAction/SwipeActionItem.css +0 -31
  194. package/es/SwipeAction/SwipeActionItem.d.ts +0 -5
  195. package/es/SwipeAction/SwipeActionItem.js +0 -78
  196. package/es/SwipeAction/index.d.ts +0 -4
  197. package/es/SwipeAction/index.js +0 -9
  198. package/es/Tabs/utils/scroll.d.ts +0 -2
  199. package/es/Tabs/utils/scroll.js +0 -36
@@ -18,13 +18,11 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import Taro from "@tarojs/taro";
21
- import React, { forwardRef, useEffect, useState } from "react";
21
+ import React, { forwardRef, useMemo } from "react";
22
22
  import PortalCore from "./PortalCore";
23
23
  const Portal = forwardRef((props, ref) => {
24
24
  const { disablePortal } = props;
25
- const [rootWrapperElement, setRootWrapperElement] = useState();
26
- useEffect(() => {
27
- let root;
25
+ const rootWrapperElement = useMemo(() => {
28
26
  if (!disablePortal) {
29
27
  const currentPages = Taro.getCurrentPages() || [];
30
28
  const currentPage = currentPages[currentPages.length - 1];
@@ -36,12 +34,11 @@ const Portal = forwardRef((props, ref) => {
36
34
  const view = document.createElement("view");
37
35
  view.id = portalId;
38
36
  rootElement == null ? void 0 : rootElement.appendChild(view);
39
- root = view;
40
- } else {
41
- root = portalWrapperElement;
37
+ return view;
42
38
  }
39
+ return portalWrapperElement;
43
40
  }
44
- setRootWrapperElement(root);
41
+ return void 0;
45
42
  }, []);
46
43
  return /* @__PURE__ */ React.createElement(PortalCore, __spreadProps(__spreadValues({}, props), { ref, rootElement: rootWrapperElement }));
47
44
  });
@@ -2,14 +2,12 @@ import { useForkRef } from "@bifrostui/utils";
2
2
  import clsx from "clsx";
3
3
  import React, { forwardRef, useCallback, useEffect, useRef } from "react";
4
4
  import "./ScrollView.css";
5
- function easeOutScroll(from, to, callback, dur) {
6
- if (dur <= 0) {
7
- dur = 500;
8
- }
5
+ function easeOutScroll(from, to, callback) {
9
6
  if (from === to || typeof from !== "number") {
10
7
  return;
11
8
  }
12
9
  const change = to - from;
10
+ const dur = 500;
13
11
  const sTime = +/* @__PURE__ */ new Date();
14
12
  function linear(t, b, c, d) {
15
13
  return c * t / d + b;
@@ -44,8 +42,7 @@ const ScrollView = forwardRef(
44
42
  scrollIntoView,
45
43
  onTouchMove: propsOnTouchMove,
46
44
  scrollIntoViewAlignment,
47
- children,
48
- scrollAnimationDuration = 500
45
+ children
49
46
  } = props;
50
47
  const container = useRef(null);
51
48
  const handleRef = useForkRef(ref, container);
@@ -55,15 +52,10 @@ const ScrollView = forwardRef(
55
52
  if (top === void 0)
56
53
  return;
57
54
  if (isAnimation) {
58
- easeOutScroll(
59
- container.current.scrollTop,
60
- top,
61
- (pos) => {
62
- if (container.current)
63
- container.current.scrollTop = pos;
64
- },
65
- scrollAnimationDuration
66
- );
55
+ easeOutScroll(container.current.scrollTop, top, (pos) => {
56
+ if (container.current)
57
+ container.current.scrollTop = pos;
58
+ });
67
59
  } else if (container.current)
68
60
  container.current.scrollTop = top;
69
61
  }, []);
@@ -71,15 +63,10 @@ const ScrollView = forwardRef(
71
63
  if (left === void 0)
72
64
  return;
73
65
  if (isAnimation) {
74
- easeOutScroll(
75
- container.current.scrollLeft,
76
- left,
77
- (pos) => {
78
- if (container.current)
79
- container.current.scrollLeft = pos;
80
- },
81
- scrollAnimationDuration
82
- );
66
+ easeOutScroll(container.current.scrollLeft, left, (pos) => {
67
+ if (container.current)
68
+ container.current.scrollLeft = pos;
69
+ });
83
70
  } else if (container.current)
84
71
  container.current.scrollLeft = left;
85
72
  }, []);
@@ -138,6 +138,7 @@ export type ScrollViewProps<D extends React.ElementType = 'div', P = {}> = Overr
138
138
  */
139
139
  fastDeceleration?: boolean;
140
140
  /** 当 scroll-with-animation设置为 true 时,可以设置 scroll-animation-duration 来控制动画的执行时间,单位 ms。
141
+ * 仅小程序可用
141
142
  */
142
143
  scrollAnimationDuration?: number;
143
144
  /** 纵向滚动时,当滚动到顶部或底部时,强制禁止触发页面滚动,仍然只触发 scroll-view 自身的滚动。
@@ -48,9 +48,13 @@
48
48
  .bui-select-option-container {
49
49
  position: absolute;
50
50
  box-sizing: border-box;
51
+ top: 100%;
52
+ left: 0;
53
+ width: 100%;
51
54
  font-size: var(--bui-select-font-size, var(--bui-title-size-3));
52
55
  z-index: var(--bui-z-index-tooltip);
53
56
  border-radius: 3px;
57
+ background-color: var(--bui-color-bg-view);
54
58
  padding: 2px;
55
59
  overflow: hidden;
56
60
  }
@@ -67,7 +71,6 @@
67
71
  border-radius: 3px;
68
72
  padding: var(--bui-select-option-container-padding, 3px 0);
69
73
  box-shadow: 0 0 0 2px var(--bui-color-bg-default);
70
- background-color: var(--bui-color-bg-view);
71
74
  overflow: hidden;
72
75
  }
73
76
  .bui-select-option {
@@ -29,32 +29,13 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
32
  import { CaretDownIcon, CaretUpIcon } from "@bifrostui/icons";
53
33
  import {
54
34
  getStylesAndLocation,
55
35
  isMini,
56
36
  throttle,
57
37
  useForkRef,
38
+ useUniqueId,
58
39
  useValue
59
40
  } from "@bifrostui/utils";
60
41
  import clsx from "clsx";
@@ -117,36 +98,38 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
117
98
  const isOpen = open !== void 0 ? open : internalOpen;
118
99
  const locatorRef = useRef(null);
119
100
  const rootRef = useForkRef(ref, locatorRef);
120
- const optionContainerRef = useRef(null);
121
- const optionMainRef = useRef(null);
122
- const updateOptionStyle = () => __async(void 0, null, function* () {
101
+ const ttId = useUniqueId();
102
+ const dataId = `${prefixCls}-tt-${ttId}`;
103
+ const updateOptionStyle = throttle(() => {
123
104
  const curScrollRoot = scrollContainer();
124
- const result = yield getStylesAndLocation({
125
- scrollRoot: curScrollRoot,
126
- childrenRef: locatorRef,
127
- tipRef: optionContainerRef,
128
- arrowDirection: defaultPlacement,
129
- arrowLocation: "none",
130
- offsetSpacing: 0
131
- });
132
- if (!result)
133
- return;
134
- const { styles, childrenStyle, newArrowDirection } = result;
135
- optionMainRef.current.style.transition = "none";
136
- optionMainRef.current.style.transform = `translateY(${newArrowDirection === "bottom" ? "-100%" : "100%"})`;
137
- setPlacement(newArrowDirection);
138
- setOptionStyle(__spreadProps(__spreadValues({}, styles), { width: childrenStyle == null ? void 0 : childrenStyle.width }));
139
- });
140
- const changeOpen = (newOpen) => __async(void 0, null, function* () {
105
+ if (!isMini && curScrollRoot) {
106
+ const result = getStylesAndLocation({
107
+ scrollRoot: curScrollRoot,
108
+ childrenRef: locatorRef,
109
+ arrowDirection: defaultPlacement,
110
+ arrowLocation: "none",
111
+ selector: `[data-id="${dataId}"]`,
112
+ offsetSpacing: 0
113
+ });
114
+ if (!result)
115
+ return;
116
+ const { styles, childrenStyle, newArrowDirection } = result;
117
+ setPlacement(newArrowDirection);
118
+ setOptionStyle(__spreadProps(__spreadValues({}, styles), { width: childrenStyle.width }));
119
+ }
120
+ }, 100);
121
+ const changeOpen = (newOpen) => {
141
122
  if (newOpen) {
142
- yield updateOptionStyle();
143
- setInternalOpen(newOpen);
144
- onOpen == null ? void 0 : onOpen();
123
+ updateOptionStyle();
124
+ setTimeout(() => {
125
+ setInternalOpen(newOpen);
126
+ onOpen == null ? void 0 : onOpen();
127
+ }, 100);
145
128
  } else {
146
129
  onClose == null ? void 0 : onClose();
147
130
  setInternalOpen(newOpen);
148
131
  }
149
- });
132
+ };
150
133
  const handleSelectClick = (e) => {
151
134
  if (disabled)
152
135
  return;
@@ -171,11 +154,10 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
171
154
  [selectValue, onChange, setRenderValue]
172
155
  );
173
156
  useEffect(() => {
174
- const resizeCb = throttle(updateOptionStyle, 100);
175
157
  if (!isMini) {
176
- window.addEventListener("resize", resizeCb);
158
+ window.addEventListener("resize", updateOptionStyle);
177
159
  return () => {
178
- window.removeEventListener("resize", resizeCb);
160
+ window.removeEventListener("resize", updateOptionStyle);
179
161
  };
180
162
  }
181
163
  }, []);
@@ -193,8 +175,8 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
193
175
  {
194
176
  in: isOpen,
195
177
  timeout: {
196
- enter: 167,
197
- exit: 167
178
+ enter: 150,
179
+ exit: 150
198
180
  }
199
181
  },
200
182
  /* @__PURE__ */ React.createElement(
@@ -208,7 +190,7 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
208
190
  [`${prefixCls}-option-container-hide`]: !isOpen
209
191
  }
210
192
  ),
211
- ref: optionContainerRef,
193
+ "data-id": dataId,
212
194
  style: optionStyle
213
195
  },
214
196
  /* @__PURE__ */ React.createElement(
@@ -217,18 +199,11 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
217
199
  in: isOpen,
218
200
  direction: placement === "bottom" ? "down" : "up",
219
201
  timeout: {
220
- enter: 167,
221
- exit: 167
202
+ enter: 150,
203
+ exit: 150
222
204
  }
223
205
  },
224
- /* @__PURE__ */ React.createElement(
225
- "div",
226
- {
227
- className: clsx(`${prefixCls}-option-main`),
228
- ref: optionMainRef
229
- },
230
- children
231
- )
206
+ /* @__PURE__ */ React.createElement("div", { className: clsx(`${prefixCls}-option-main`) }, children)
232
207
  )
233
208
  )
234
209
  );
@@ -256,8 +231,9 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
256
231
  [inputProps == null ? void 0 : inputProps.className]: inputProps == null ? void 0 : inputProps.className
257
232
  })
258
233
  })
259
- ), icon || defaultIcon)
260
- ), /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted: updateOptionStyle }, renderOptions()), /* @__PURE__ */ React.createElement(
234
+ ), icon || defaultIcon),
235
+ isMini && renderOptions()
236
+ ), !isMini && /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted: updateOptionStyle }, renderOptions()), /* @__PURE__ */ React.createElement(
261
237
  Backdrop,
262
238
  __spreadProps(__spreadValues({
263
239
  open: isOpen,
@@ -274,7 +250,9 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
274
250
  Select.displayName = "BuiSelect";
275
251
  Select.defaultProps = {
276
252
  defaultValue: "",
277
- scrollContainer: () => null
253
+ scrollContainer: () => {
254
+ return isMini ? null : document.body;
255
+ }
278
256
  };
279
257
  var Select_default = Select;
280
258
  export {
@@ -50,9 +50,7 @@ import { GripperBarVerticalIcon } from "@bifrostui/icons";
50
50
  import {
51
51
  isMini,
52
52
  useForkRef,
53
- emulateTouchStart,
54
- emulateTouchMove,
55
- emulateTouchEnd,
53
+ useTouchEmulator,
56
54
  useValue,
57
55
  getBoundingClientRect
58
56
  } from "@bifrostui/utils";
@@ -112,6 +110,7 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
112
110
  const value = shouldProtection ? latestVal.current : valueProp;
113
111
  const [rootRef, setRootRef] = useState(null);
114
112
  const handleRef = useForkRef(ref, setRootRef);
113
+ useTouchEmulator(rootRef);
115
114
  const sliderRect = useRef();
116
115
  const touchStartPageX = useRef();
117
116
  const touchStartLeft = useRef();
@@ -182,7 +181,9 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
182
181
  return;
183
182
  beforeMoveValue.current = internalValue;
184
183
  tooltipRef.current = internalValue;
185
- getLineWidth();
184
+ if (!sliderRect.current.width) {
185
+ getLineWidth();
186
+ }
186
187
  const currentTarget = isMini ? e.mpEvent.currentTarget : e.currentTarget;
187
188
  touchStartPageX.current = e.touches[0].pageX;
188
189
  touchStartLeft.current = currentTarget == null ? void 0 : currentTarget.offsetLeft;
@@ -241,16 +242,6 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
241
242
  setFrontTooltipVisible(false);
242
243
  setEndTooltipVisible(false);
243
244
  };
244
- const onMouseUp = (e) => {
245
- emulateTouchEnd(e);
246
- document.removeEventListener("mousemove", emulateTouchMove);
247
- document.removeEventListener("mouseup", onMouseUp);
248
- };
249
- const onMouseDown = (e) => {
250
- emulateTouchStart(e);
251
- document.addEventListener("mousemove", emulateTouchMove);
252
- document.addEventListener("mouseup", onMouseUp);
253
- };
254
245
  const renderButton = (index) => {
255
246
  const valuenow = internalValue[index];
256
247
  return /* @__PURE__ */ React.createElement(
@@ -273,8 +264,7 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
273
264
  },
274
265
  onTouchMove,
275
266
  onTouchEnd,
276
- onTouchCancel: onTouchEnd,
277
- onMouseDown
267
+ onTouchCancel: onTouchEnd
278
268
  },
279
269
  index === SLIDER_BUTTON.FRONT ? startIcon || defaultIcon : endIcon || defaultIcon
280
270
  );
package/es/Tabs/Tab.js CHANGED
@@ -36,19 +36,7 @@ import TabsContext from "./TabsContext";
36
36
  import "./Tab.css";
37
37
  const prefixCls = "bui-tab";
38
38
  const Tab = /* @__PURE__ */ React.forwardRef((props, ref) => {
39
- const _a = props, {
40
- className,
41
- children,
42
- index,
43
- disabled = false,
44
- onClick
45
- } = _a, others = __objRest(_a, [
46
- "className",
47
- "children",
48
- "index",
49
- "disabled",
50
- "onClick"
51
- ]);
39
+ const _a = props, { className, children, index, disabled, onClick } = _a, others = __objRest(_a, ["className", "children", "index", "disabled", "onClick"]);
52
40
  const tabsContext = React.useContext(TabsContext);
53
41
  const { value, align, triggerChange } = tabsContext;
54
42
  return /* @__PURE__ */ React.createElement(
@@ -86,6 +74,9 @@ const Tab = /* @__PURE__ */ React.forwardRef((props, ref) => {
86
74
  );
87
75
  });
88
76
  Tab.displayName = "BuiTab";
77
+ Tab.defaultProps = {
78
+ disabled: false
79
+ };
89
80
  var Tab_default = Tab;
90
81
  export {
91
82
  Tab_default as default
package/es/Tabs/Tabs.js CHANGED
@@ -42,10 +42,9 @@ import React, {
42
42
  } from "react";
43
43
  import Tab from "./Tab";
44
44
  import { TabsContextProvider } from "./TabsContext";
45
- import scrollLeftTo from "./utils/scroll";
45
+ import bound from "./utils/bound";
46
46
  import "./Tabs.css";
47
47
  const prefixCls = "bui-tabs";
48
- const duration = 300;
49
48
  const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
50
49
  const _a = props, { children, className, value, tabs, align, onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "align", "onChange"]);
51
50
  const [active, setActive] = useState("");
@@ -60,11 +59,14 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
60
59
  leftMaskOpacity: 0,
61
60
  rightMaskOpacity: 0
62
61
  });
63
- const getActiveTabElement = () => {
62
+ const animate = ({ transitionInUse }) => {
64
63
  const container = tabsRef.current;
65
64
  if (!container)
66
- return void 0;
65
+ return;
67
66
  const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === active);
67
+ const activeLine = activeLineRef.current;
68
+ if (!activeLine)
69
+ return;
68
70
  let activeTab;
69
71
  if (tabs.length) {
70
72
  activeTab = activeIndex > -1 ? container.childNodes[activeIndex + 1] : void 0;
@@ -78,25 +80,6 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
78
80
  return [...child.classList].includes("bui-tab-active");
79
81
  });
80
82
  }
81
- return activeTab;
82
- };
83
- const scrollIntoView = () => {
84
- const tabsContainer = tabsRef.current;
85
- const activeTab = getActiveTabElement();
86
- if (!tabsContainer || !activeTab) {
87
- return;
88
- }
89
- const to = activeTab.offsetLeft - (tabsContainer.offsetWidth - activeTab.offsetWidth) / 2;
90
- scrollLeftTo(tabsContainer, to, duration);
91
- };
92
- const animate = ({ transitionInUse }) => {
93
- const container = tabsRef.current;
94
- if (!container)
95
- return;
96
- const activeLine = activeLineRef.current;
97
- if (!activeLine)
98
- return;
99
- const activeTab = getActiveTabElement();
100
83
  let activeTabLeft = 0;
101
84
  let activeTabWidth = 0;
102
85
  let containerWidth = 0;
@@ -119,8 +102,13 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
119
102
  const maxScrollDistance = containerScrollWidth - containerWidth;
120
103
  if (maxScrollDistance <= 0 || !activeTab)
121
104
  return;
122
- if (!isMini) {
123
- scrollIntoView();
105
+ const nextScrollLeft = bound(
106
+ activeTabLeft - (containerWidth - activeTabWidth) / 2,
107
+ 0,
108
+ containerScrollWidth - containerWidth
109
+ );
110
+ if (tabsRef.current) {
111
+ tabsRef.current.scrollLeft = nextScrollLeft;
124
112
  }
125
113
  };
126
114
  useEffect(() => {
@@ -150,10 +138,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
150
138
  return;
151
139
  const scrollLeft = container == null ? void 0 : container.scrollLeft;
152
140
  const showLeftMask = scrollLeft > 0;
153
- const rightRange = Math.abs(
154
- container.scrollWidth - (scrollLeft + container.offsetWidth)
155
- );
156
- const showRightMask = rightRange > 1;
141
+ const showRightMask = scrollLeft + container.offsetWidth < container.scrollWidth;
157
142
  setMaskData({
158
143
  leftMaskOpacity: showLeftMask ? 1 : 0,
159
144
  rightMaskOpacity: showRightMask ? 1 : 0
@@ -211,7 +196,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
211
196
  "bui-tabline-invisible": isMini || !lineData.hasActiveTab
212
197
  }),
213
198
  style: {
214
- transition: lineData.transitionInUse ? `transform ${duration / 1e3}s ease` : void 0,
199
+ transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
215
200
  transform: `translate3d(${lineData.x}px, 0px, 0px)`
216
201
  }
217
202
  }
@@ -0,0 +1 @@
1
+ export default function bound(position: number, min: number | undefined, max: number | undefined): number;
@@ -0,0 +1,13 @@
1
+ function bound(position, min, max) {
2
+ let ret = position;
3
+ if (min !== void 0) {
4
+ ret = Math.max(position, min);
5
+ }
6
+ if (max !== void 0) {
7
+ ret = Math.min(ret, max);
8
+ }
9
+ return ret;
10
+ }
11
+ export {
12
+ bound as default
13
+ };
@@ -29,7 +29,7 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { render, unmount, getRootContainer } from "@bifrostui/utils";
32
+ import { render, unmount, getRootElement } from "@bifrostui/utils";
33
33
  import React, { useCallback, useEffect, useState } from "react";
34
34
  import ToastView from "./Toast";
35
35
  let toastCloses = [];
@@ -70,7 +70,7 @@ const functionalToast = (props) => {
70
70
  rootWrapper.style[property] = styles[property];
71
71
  });
72
72
  }
73
- const rootElement = getRootContainer();
73
+ const rootElement = getRootElement();
74
74
  rootElement.appendChild(rootWrapper);
75
75
  const ToastComponent = () => {
76
76
  const _a = options, { duration, allowMultiple, onClose } = _a, others = __objRest(_a, ["duration", "allowMultiple", "onClose"]);
@@ -13,6 +13,7 @@
13
13
  position: fixed;
14
14
  left: 50%;
15
15
  z-index: var(--bui-z-index-toast);
16
+ width: fit-content;
16
17
  min-width: var(--min-width);
17
18
  max-width: var(--max-width);
18
19
  padding: var(--padding);