@bifrostui/react 1.4.5 → 1.4.7-beta.0

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 (231) hide show
  1. package/dist/Calendar/Calendar.js +5 -1
  2. package/dist/Calendar/Calendar.types.d.ts +5 -0
  3. package/dist/CitySelector/CitySelectorCore.js +3 -3
  4. package/dist/Collapse/Collapse.css +0 -1
  5. package/dist/Collapse/Collapse.d.ts +1 -1
  6. package/dist/Collapse/Collapse.js +11 -8
  7. package/dist/Collapse/Collapse.miniapp.d.ts +5 -0
  8. package/dist/Collapse/Collapse.miniapp.js +177 -0
  9. package/dist/CollapsePanel/CollapsePanel.css +4 -2
  10. package/dist/DatePicker/DatePicker.d.ts +4 -0
  11. package/dist/DatePicker/DatePicker.js +335 -0
  12. package/dist/DatePicker/DatePicker.types.d.ts +43 -0
  13. package/dist/DatePicker/DatePicker.types.js +35 -0
  14. package/dist/DatePicker/index.d.ts +2 -0
  15. package/dist/DatePicker/index.js +41 -0
  16. package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  17. package/dist/DesktopDatePicker/DesktopDatePicker.js +280 -0
  18. package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  19. package/dist/DesktopDatePicker/DesktopDatePicker.types.js +15 -0
  20. package/dist/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  21. package/dist/DesktopDatePicker/index.css +61 -0
  22. package/dist/DesktopDatePicker/index.d.ts +2 -0
  23. package/dist/DesktopDatePicker/index.js +41 -0
  24. package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  25. package/dist/DesktopDatePicker/useGetDatePickerContent.js +343 -0
  26. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  27. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +322 -0
  28. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  29. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +15 -0
  30. package/dist/DesktopDateTimePicker/index.css +66 -0
  31. package/dist/DesktopDateTimePicker/index.d.ts +2 -0
  32. package/dist/DesktopDateTimePicker/index.js +41 -0
  33. package/dist/DesktopPicker/DesktopPicker.d.ts +5 -0
  34. package/dist/DesktopPicker/DesktopPicker.js +238 -0
  35. package/dist/DesktopPicker/DesktopPicker.types.d.ts +57 -0
  36. package/dist/DesktopPicker/DesktopPicker.types.js +15 -0
  37. package/dist/DesktopPicker/index.css +37 -0
  38. package/dist/DesktopPicker/index.d.ts +2 -0
  39. package/dist/DesktopPicker/index.js +41 -0
  40. package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  41. package/dist/{Tabs/utils/bound.js → DesktopPicker/utils/calcAfterMounted.js} +7 -14
  42. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  43. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +38 -0
  44. package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  45. package/dist/DesktopTimePicker/DesktopTimePicker.js +288 -0
  46. package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  47. package/dist/DesktopTimePicker/DesktopTimePicker.types.js +15 -0
  48. package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  49. package/dist/DesktopTimePicker/DesktopTimePickerList.js +111 -0
  50. package/dist/DesktopTimePicker/index.css +170 -0
  51. package/dist/DesktopTimePicker/index.d.ts +2 -0
  52. package/dist/DesktopTimePicker/index.js +41 -0
  53. package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  54. package/dist/DesktopTimePicker/useGetTimePickerContent.js +246 -0
  55. package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  56. package/dist/DesktopTimePicker/utils/scrollUtil.js +27 -0
  57. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  58. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +51 -0
  59. package/dist/DesktopTimePicker/utils/utils.d.ts +28 -0
  60. package/dist/DesktopTimePicker/utils/utils.js +408 -0
  61. package/dist/Dialog/FunctionalDialog.js +1 -1
  62. package/dist/ItemSelector/ItemSelector.css +120 -0
  63. package/dist/ItemSelector/ItemSelector.d.ts +4 -0
  64. package/dist/ItemSelector/ItemSelector.js +84 -0
  65. package/dist/ItemSelector/ItemSelector.miniapp.d.ts +5 -0
  66. package/dist/ItemSelector/ItemSelector.miniapp.js +125 -0
  67. package/dist/ItemSelector/ItemSelector.types.d.ts +40 -0
  68. package/dist/ItemSelector/ItemSelector.types.js +15 -0
  69. package/dist/ItemSelector/ItemSelectorCore.d.ts +5 -0
  70. package/dist/ItemSelector/ItemSelectorCore.js +217 -0
  71. package/dist/ItemSelector/Selector/index.css +11 -0
  72. package/dist/ItemSelector/Selector/index.d.ts +9 -0
  73. package/dist/ItemSelector/Selector/index.js +48 -0
  74. package/dist/ItemSelector/index.d.ts +2 -0
  75. package/dist/ItemSelector/index.js +41 -0
  76. package/dist/ItemSelector/miniapp.css +4 -0
  77. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  78. package/dist/Picker/Picker.css +5 -0
  79. package/dist/Picker/Picker.js +27 -5
  80. package/dist/Picker/Picker.types.d.ts +15 -2
  81. package/dist/Picker/PickerPanel.css +4 -0
  82. package/dist/Picker/PickerPanel.js +7 -6
  83. package/dist/Popover/Popover.js +70 -27
  84. package/dist/Portal/Portal.miniapp.js +7 -4
  85. package/dist/ScrollView/ScrollView.js +24 -11
  86. package/dist/ScrollView/ScrollView.types.d.ts +0 -1
  87. package/dist/Select/Select.css +1 -4
  88. package/dist/Select/Select.js +63 -40
  89. package/dist/Slider/Slider.js +13 -5
  90. package/dist/SwipeAction/SwipeAction.css +79 -0
  91. package/dist/SwipeAction/SwipeAction.d.ts +5 -0
  92. package/dist/SwipeAction/SwipeAction.js +349 -0
  93. package/dist/SwipeAction/SwipeAction.types.d.ts +83 -0
  94. package/dist/SwipeAction/SwipeAction.types.js +39 -0
  95. package/dist/SwipeAction/SwipeActionContext.d.ts +4 -0
  96. package/dist/SwipeAction/SwipeActionContext.js +30 -0
  97. package/dist/SwipeAction/SwipeActionItem.css +31 -0
  98. package/dist/SwipeAction/SwipeActionItem.d.ts +5 -0
  99. package/dist/SwipeAction/SwipeActionItem.js +105 -0
  100. package/dist/SwipeAction/index.d.ts +4 -0
  101. package/dist/SwipeAction/index.js +45 -0
  102. package/dist/Tabs/Tab.js +13 -4
  103. package/dist/Tabs/Tabs.js +30 -15
  104. package/dist/Tabs/utils/scroll.d.ts +2 -0
  105. package/dist/Tabs/utils/scroll.js +55 -0
  106. package/dist/Toast/FunctionalToast.js +1 -1
  107. package/dist/Toast/Toast.css +0 -1
  108. package/dist/Tooltip/Tooltip.js +70 -27
  109. package/dist/index.d.ts +7 -0
  110. package/dist/index.js +15 -1
  111. package/dist/locales/base.d.ts +11 -0
  112. package/dist/locales/en-US.js +24 -0
  113. package/dist/locales/zh-CN.js +24 -0
  114. package/dist/locales/zh-TW.js +24 -0
  115. package/es/Calendar/Calendar.js +5 -1
  116. package/es/Calendar/Calendar.types.d.ts +5 -0
  117. package/es/CitySelector/CitySelectorCore.js +3 -3
  118. package/es/Collapse/Collapse.css +0 -1
  119. package/es/Collapse/Collapse.d.ts +1 -1
  120. package/es/Collapse/Collapse.js +11 -8
  121. package/es/Collapse/Collapse.miniapp.d.ts +5 -0
  122. package/es/Collapse/Collapse.miniapp.js +157 -0
  123. package/es/CollapsePanel/CollapsePanel.css +4 -2
  124. package/es/DatePicker/DatePicker.d.ts +4 -0
  125. package/es/DatePicker/DatePicker.js +310 -0
  126. package/es/DatePicker/DatePicker.types.d.ts +43 -0
  127. package/es/DatePicker/DatePicker.types.js +1 -0
  128. package/es/DatePicker/index.d.ts +2 -0
  129. package/es/DatePicker/index.js +6 -0
  130. package/es/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  131. package/es/DesktopDatePicker/DesktopDatePicker.js +253 -0
  132. package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  133. package/es/DesktopDatePicker/DesktopDatePicker.types.js +1 -0
  134. package/es/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  135. package/es/DesktopDatePicker/index.css +61 -0
  136. package/es/DesktopDatePicker/index.d.ts +2 -0
  137. package/es/DesktopDatePicker/index.js +6 -0
  138. package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  139. package/es/DesktopDatePicker/useGetDatePickerContent.js +316 -0
  140. package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  141. package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +295 -0
  142. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  143. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +1 -0
  144. package/es/DesktopDateTimePicker/index.css +66 -0
  145. package/es/DesktopDateTimePicker/index.d.ts +2 -0
  146. package/es/DesktopDateTimePicker/index.js +9 -0
  147. package/es/DesktopPicker/DesktopPicker.d.ts +5 -0
  148. package/es/DesktopPicker/DesktopPicker.js +221 -0
  149. package/es/DesktopPicker/DesktopPicker.types.d.ts +57 -0
  150. package/es/DesktopPicker/DesktopPicker.types.js +1 -0
  151. package/es/DesktopPicker/index.css +37 -0
  152. package/es/DesktopPicker/index.d.ts +2 -0
  153. package/es/DesktopPicker/index.js +6 -0
  154. package/es/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  155. package/es/DesktopPicker/utils/calcAfterMounted.js +6 -0
  156. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  157. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +9 -0
  158. package/es/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  159. package/es/DesktopTimePicker/DesktopTimePicker.js +261 -0
  160. package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  161. package/es/DesktopTimePicker/DesktopTimePicker.types.js +1 -0
  162. package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  163. package/es/DesktopTimePicker/DesktopTimePickerList.js +84 -0
  164. package/es/DesktopTimePicker/index.css +170 -0
  165. package/es/DesktopTimePicker/index.d.ts +2 -0
  166. package/es/DesktopTimePicker/index.js +6 -0
  167. package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  168. package/es/DesktopTimePicker/useGetTimePickerContent.js +223 -0
  169. package/es/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  170. package/es/DesktopTimePicker/utils/scrollUtil.js +8 -0
  171. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  172. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +22 -0
  173. package/es/DesktopTimePicker/utils/utils.d.ts +28 -0
  174. package/es/DesktopTimePicker/utils/utils.js +365 -0
  175. package/es/Dialog/FunctionalDialog.js +2 -2
  176. package/es/ItemSelector/ItemSelector.css +120 -0
  177. package/es/ItemSelector/ItemSelector.d.ts +4 -0
  178. package/es/ItemSelector/ItemSelector.js +57 -0
  179. package/es/ItemSelector/ItemSelector.miniapp.d.ts +5 -0
  180. package/es/ItemSelector/ItemSelector.miniapp.js +98 -0
  181. package/es/ItemSelector/ItemSelector.types.d.ts +40 -0
  182. package/es/ItemSelector/ItemSelector.types.js +1 -0
  183. package/es/ItemSelector/ItemSelectorCore.d.ts +5 -0
  184. package/es/ItemSelector/ItemSelectorCore.js +190 -0
  185. package/es/ItemSelector/Selector/index.css +11 -0
  186. package/es/ItemSelector/Selector/index.d.ts +9 -0
  187. package/es/ItemSelector/Selector/index.js +19 -0
  188. package/es/ItemSelector/index.d.ts +2 -0
  189. package/es/ItemSelector/index.js +6 -0
  190. package/es/ItemSelector/miniapp.css +4 -0
  191. package/es/Picker/Picker.css +5 -0
  192. package/es/Picker/Picker.js +27 -5
  193. package/es/Picker/Picker.types.d.ts +15 -2
  194. package/es/Picker/PickerPanel.css +4 -0
  195. package/es/Picker/PickerPanel.js +7 -6
  196. package/es/Popover/Popover.js +73 -29
  197. package/es/Portal/Portal.miniapp.js +8 -5
  198. package/es/ScrollView/ScrollView.js +24 -11
  199. package/es/ScrollView/ScrollView.types.d.ts +0 -1
  200. package/es/Select/Select.css +1 -4
  201. package/es/Select/Select.js +63 -41
  202. package/es/Slider/Slider.js +16 -6
  203. package/es/SwipeAction/SwipeAction.css +79 -0
  204. package/es/SwipeAction/SwipeAction.d.ts +5 -0
  205. package/es/SwipeAction/SwipeAction.js +337 -0
  206. package/es/SwipeAction/SwipeAction.types.d.ts +83 -0
  207. package/es/SwipeAction/SwipeAction.types.js +1 -0
  208. package/es/SwipeAction/SwipeActionContext.d.ts +4 -0
  209. package/es/SwipeAction/SwipeActionContext.js +11 -0
  210. package/es/SwipeAction/SwipeActionItem.css +31 -0
  211. package/es/SwipeAction/SwipeActionItem.d.ts +5 -0
  212. package/es/SwipeAction/SwipeActionItem.js +78 -0
  213. package/es/SwipeAction/index.d.ts +4 -0
  214. package/es/SwipeAction/index.js +9 -0
  215. package/es/Tabs/Tab.js +13 -4
  216. package/es/Tabs/Tabs.js +30 -15
  217. package/es/Tabs/utils/scroll.d.ts +2 -0
  218. package/es/Tabs/utils/scroll.js +36 -0
  219. package/es/Toast/FunctionalToast.js +2 -2
  220. package/es/Toast/Toast.css +0 -1
  221. package/es/Tooltip/Tooltip.js +73 -29
  222. package/es/index.d.ts +7 -0
  223. package/es/index.js +7 -0
  224. package/es/locales/base.d.ts +11 -0
  225. package/es/locales/en-US.js +24 -0
  226. package/es/locales/zh-CN.js +24 -0
  227. package/es/locales/zh-TW.js +24 -0
  228. package/package.json +5 -5
  229. package/dist/Tabs/utils/bound.d.ts +0 -1
  230. package/es/Tabs/utils/bound.d.ts +0 -1
  231. package/es/Tabs/utils/bound.js +0 -13
@@ -26,14 +26,35 @@ var __objRest = (source, exclude) => {
26
26
  }
27
27
  return target;
28
28
  };
29
+ var __async = (__this, __arguments, generator) => {
30
+ return new Promise((resolve, reject) => {
31
+ var fulfilled = (value) => {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var rejected = (value) => {
39
+ try {
40
+ step(generator.throw(value));
41
+ } catch (e) {
42
+ reject(e);
43
+ }
44
+ };
45
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
+ step((generator = generator.apply(__this, __arguments)).next());
47
+ });
48
+ };
29
49
  import clsx from "clsx";
30
50
  import React, { useState, useRef, useEffect } from "react";
31
51
  import {
32
52
  getStylesAndLocation,
33
53
  triggerEventTransform,
34
54
  parsePlacement,
35
- useUniqueId,
36
- throttle
55
+ throttle,
56
+ useForkRef,
57
+ isMini
37
58
  } from "@bifrostui/utils";
38
59
  import Portal from "../Portal";
39
60
  import "./Popover.css";
@@ -49,9 +70,9 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
49
70
  offsetSpacing = 0,
50
71
  placement = "top",
51
72
  trigger = "click",
52
- onOpenChange,
53
73
  open,
54
- hideArrow
74
+ hideArrow,
75
+ onOpenChange
55
76
  } = _a, others = __objRest(_a, [
56
77
  "className",
57
78
  "style",
@@ -62,9 +83,9 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
62
83
  "offsetSpacing",
63
84
  "placement",
64
85
  "trigger",
65
- "onOpenChange",
66
86
  "open",
67
- "hideArrow"
87
+ "hideArrow",
88
+ "onOpenChange"
68
89
  ]);
69
90
  const controlByUser = typeof open !== "undefined";
70
91
  const { direction, location = "center" } = parsePlacement(placement);
@@ -72,11 +93,18 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
72
93
  const [openStatus, setOpenStatus] = useState(defaultOpen);
73
94
  const [arrowDirection, setArrowDirection] = useState(direction);
74
95
  const [arrowLocation, setArrowLocation] = useState(location);
75
- const [tooltyles, setTooltyles] = useState({});
76
- const ttId = useUniqueId();
96
+ const [toolStyles, setToolStyles] = useState({});
97
+ const tipRef = useRef(null);
98
+ const nodeRef = useForkRef(ref, tipRef);
99
+ const clearRef = (status) => {
100
+ if (status === false) {
101
+ tipRef.current = null;
102
+ }
103
+ };
77
104
  const changeOpenStatus = (event, status) => {
78
105
  if (controlByUser)
79
106
  return;
107
+ clearRef(status);
80
108
  setOpenStatus(status);
81
109
  onOpenChange == null ? void 0 : onOpenChange(event, { open: status });
82
110
  };
@@ -95,23 +123,33 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
95
123
  if (!controlByUser)
96
124
  return;
97
125
  setOpenStatus(open);
126
+ clearRef(open);
98
127
  }, [open]);
128
+ useEffect(() => {
129
+ if (!openStatus) {
130
+ setToolStyles({
131
+ visibility: "hidden"
132
+ });
133
+ }
134
+ }, [openStatus]);
99
135
  const clickEventHandler = (event) => {
100
136
  if (trigger === "hover" || (trigger == null ? void 0 : trigger.length) === 1 && (trigger == null ? void 0 : trigger[0]) === "hover")
101
137
  return;
102
138
  hidePopover(event);
103
139
  };
104
- const onRootElementMouted = throttle(() => {
140
+ const onRootElementMouted = throttle(() => __async(void 0, null, function* () {
141
+ if (!tipRef.current)
142
+ return;
105
143
  const {
106
144
  direction: newParsedDirection,
107
145
  location: newParsedLocation = "center"
108
146
  } = parsePlacement(placement);
109
- const result = getStylesAndLocation({
147
+ const result = yield getStylesAndLocation({
110
148
  childrenRef,
111
149
  arrowDirection: newParsedDirection,
112
150
  arrowLocation: newParsedLocation,
113
151
  offsetSpacing,
114
- selector: `[data-id="tt_${ttId}"]`
152
+ tipRef
115
153
  });
116
154
  if (!result)
117
155
  return;
@@ -122,26 +160,32 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
122
160
  if (newArrowLocation !== arrowLocation) {
123
161
  setArrowLocation(newArrowLocation);
124
162
  }
125
- setTooltyles(styles);
126
- }, 100);
127
- const bindEvent = () => {
128
- if (!controlByUser) {
129
- document.addEventListener("click", clickEventHandler);
130
- }
131
- window.addEventListener("resize", onRootElementMouted);
132
- };
133
- const unbindEvent = () => {
134
- if (!controlByUser) {
135
- document.removeEventListener("click", clickEventHandler);
136
- }
137
- window.removeEventListener("resize", onRootElementMouted);
138
- };
163
+ setToolStyles(styles);
164
+ }), 100);
139
165
  useEffect(() => {
166
+ const bindEvent = () => {
167
+ if (!tipRef.current)
168
+ return;
169
+ if (!controlByUser) {
170
+ document.addEventListener("click", clickEventHandler);
171
+ }
172
+ if (!isMini) {
173
+ window.addEventListener("resize", onRootElementMouted);
174
+ }
175
+ };
176
+ const unbindEvent = () => {
177
+ if (!controlByUser) {
178
+ document.removeEventListener("click", clickEventHandler);
179
+ }
180
+ if (!isMini) {
181
+ window.removeEventListener("resize", onRootElementMouted);
182
+ }
183
+ };
140
184
  bindEvent();
141
185
  return () => {
142
186
  unbindEvent();
143
187
  };
144
- }, []);
188
+ }, [openStatus]);
145
189
  if (!title && !content)
146
190
  return null;
147
191
  let triggerEventOption;
@@ -156,14 +200,14 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
156
200
  const childrenOptions = __spreadValues({
157
201
  ref: childrenRef
158
202
  }, triggerEventOption);
159
- return /* @__PURE__ */ React.createElement(React.Fragment, null, open || openStatus ? /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted, ref }, /* @__PURE__ */ React.createElement(
203
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, open || openStatus ? /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted }, /* @__PURE__ */ React.createElement(
160
204
  "div",
161
205
  __spreadValues({
162
206
  className: clsx(prefixCls, className, `popover-${arrowDirection}`, {
163
207
  "bui-popover-arrow-hide": hideArrow
164
208
  }),
165
- "data-id": `tt_${ttId}`,
166
- style: __spreadValues(__spreadValues({}, style), tooltyles)
209
+ style: __spreadValues(__spreadValues({}, style), toolStyles),
210
+ ref: nodeRef
167
211
  }, others),
168
212
  !hideArrow ? /* @__PURE__ */ React.createElement(
169
213
  "div",
@@ -18,11 +18,13 @@ 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, useMemo } from "react";
21
+ import React, { forwardRef, useEffect, useState } from "react";
22
22
  import PortalCore from "./PortalCore";
23
23
  const Portal = forwardRef((props, ref) => {
24
24
  const { disablePortal } = props;
25
- const rootWrapperElement = useMemo(() => {
25
+ const [rootWrapperElement, setRootWrapperElement] = useState();
26
+ useEffect(() => {
27
+ let root;
26
28
  if (!disablePortal) {
27
29
  const currentPages = Taro.getCurrentPages() || [];
28
30
  const currentPage = currentPages[currentPages.length - 1];
@@ -34,11 +36,12 @@ const Portal = forwardRef((props, ref) => {
34
36
  const view = document.createElement("view");
35
37
  view.id = portalId;
36
38
  rootElement == null ? void 0 : rootElement.appendChild(view);
37
- return view;
39
+ root = view;
40
+ } else {
41
+ root = portalWrapperElement;
38
42
  }
39
- return portalWrapperElement;
40
43
  }
41
- return void 0;
44
+ setRootWrapperElement(root);
42
45
  }, []);
43
46
  return /* @__PURE__ */ React.createElement(PortalCore, __spreadProps(__spreadValues({}, props), { ref, rootElement: rootWrapperElement }));
44
47
  });
@@ -2,12 +2,14 @@ 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) {
5
+ function easeOutScroll(from, to, callback, dur) {
6
+ if (dur <= 0) {
7
+ dur = 500;
8
+ }
6
9
  if (from === to || typeof from !== "number") {
7
10
  return;
8
11
  }
9
12
  const change = to - from;
10
- const dur = 500;
11
13
  const sTime = +/* @__PURE__ */ new Date();
12
14
  function linear(t, b, c, d) {
13
15
  return c * t / d + b;
@@ -42,7 +44,8 @@ const ScrollView = forwardRef(
42
44
  scrollIntoView,
43
45
  onTouchMove: propsOnTouchMove,
44
46
  scrollIntoViewAlignment,
45
- children
47
+ children,
48
+ scrollAnimationDuration = 500
46
49
  } = props;
47
50
  const container = useRef(null);
48
51
  const handleRef = useForkRef(ref, container);
@@ -52,10 +55,15 @@ const ScrollView = forwardRef(
52
55
  if (top === void 0)
53
56
  return;
54
57
  if (isAnimation) {
55
- easeOutScroll(container.current.scrollTop, top, (pos) => {
56
- if (container.current)
57
- container.current.scrollTop = pos;
58
- });
58
+ easeOutScroll(
59
+ container.current.scrollTop,
60
+ top,
61
+ (pos) => {
62
+ if (container.current)
63
+ container.current.scrollTop = pos;
64
+ },
65
+ scrollAnimationDuration
66
+ );
59
67
  } else if (container.current)
60
68
  container.current.scrollTop = top;
61
69
  }, []);
@@ -63,10 +71,15 @@ const ScrollView = forwardRef(
63
71
  if (left === void 0)
64
72
  return;
65
73
  if (isAnimation) {
66
- easeOutScroll(container.current.scrollLeft, left, (pos) => {
67
- if (container.current)
68
- container.current.scrollLeft = pos;
69
- });
74
+ easeOutScroll(
75
+ container.current.scrollLeft,
76
+ left,
77
+ (pos) => {
78
+ if (container.current)
79
+ container.current.scrollLeft = pos;
80
+ },
81
+ scrollAnimationDuration
82
+ );
70
83
  } else if (container.current)
71
84
  container.current.scrollLeft = left;
72
85
  }, []);
@@ -138,7 +138,6 @@ 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
- * 仅小程序可用
142
141
  */
143
142
  scrollAnimationDuration?: number;
144
143
  /** 纵向滚动时,当滚动到顶部或底部时,强制禁止触发页面滚动,仍然只触发 scroll-view 自身的滚动。
@@ -48,13 +48,9 @@
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%;
54
51
  font-size: var(--bui-select-font-size, var(--bui-title-size-3));
55
52
  z-index: var(--bui-z-index-tooltip);
56
53
  border-radius: 3px;
57
- background-color: var(--bui-color-bg-view);
58
54
  padding: 2px;
59
55
  overflow: hidden;
60
56
  }
@@ -71,6 +67,7 @@
71
67
  border-radius: 3px;
72
68
  padding: var(--bui-select-option-container-padding, 3px 0);
73
69
  box-shadow: 0 0 0 2px var(--bui-color-bg-default);
70
+ background-color: var(--bui-color-bg-view);
74
71
  overflow: hidden;
75
72
  }
76
73
  .bui-select-option {
@@ -29,13 +29,32 @@ 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
+ };
32
52
  import { CaretDownIcon, CaretUpIcon } from "@bifrostui/icons";
33
53
  import {
34
54
  getStylesAndLocation,
35
55
  isMini,
36
56
  throttle,
37
57
  useForkRef,
38
- useUniqueId,
39
58
  useValue
40
59
  } from "@bifrostui/utils";
41
60
  import clsx from "clsx";
@@ -98,38 +117,36 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
98
117
  const isOpen = open !== void 0 ? open : internalOpen;
99
118
  const locatorRef = useRef(null);
100
119
  const rootRef = useForkRef(ref, locatorRef);
101
- const ttId = useUniqueId();
102
- const dataId = `${prefixCls}-tt-${ttId}`;
103
- const updateOptionStyle = throttle(() => {
120
+ const optionContainerRef = useRef(null);
121
+ const optionMainRef = useRef(null);
122
+ const updateOptionStyle = () => __async(void 0, null, function* () {
104
123
  const curScrollRoot = scrollContainer();
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) => {
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* () {
122
141
  if (newOpen) {
123
- updateOptionStyle();
124
- setTimeout(() => {
125
- setInternalOpen(newOpen);
126
- onOpen == null ? void 0 : onOpen();
127
- }, 100);
142
+ yield updateOptionStyle();
143
+ setInternalOpen(newOpen);
144
+ onOpen == null ? void 0 : onOpen();
128
145
  } else {
129
146
  onClose == null ? void 0 : onClose();
130
147
  setInternalOpen(newOpen);
131
148
  }
132
- };
149
+ });
133
150
  const handleSelectClick = (e) => {
134
151
  if (disabled)
135
152
  return;
@@ -154,10 +171,11 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
154
171
  [selectValue, onChange, setRenderValue]
155
172
  );
156
173
  useEffect(() => {
174
+ const resizeCb = throttle(updateOptionStyle, 100);
157
175
  if (!isMini) {
158
- window.addEventListener("resize", updateOptionStyle);
176
+ window.addEventListener("resize", resizeCb);
159
177
  return () => {
160
- window.removeEventListener("resize", updateOptionStyle);
178
+ window.removeEventListener("resize", resizeCb);
161
179
  };
162
180
  }
163
181
  }, []);
@@ -175,8 +193,8 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
175
193
  {
176
194
  in: isOpen,
177
195
  timeout: {
178
- enter: 150,
179
- exit: 150
196
+ enter: 167,
197
+ exit: 167
180
198
  }
181
199
  },
182
200
  /* @__PURE__ */ React.createElement(
@@ -190,7 +208,7 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
190
208
  [`${prefixCls}-option-container-hide`]: !isOpen
191
209
  }
192
210
  ),
193
- "data-id": dataId,
211
+ ref: optionContainerRef,
194
212
  style: optionStyle
195
213
  },
196
214
  /* @__PURE__ */ React.createElement(
@@ -199,11 +217,18 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
199
217
  in: isOpen,
200
218
  direction: placement === "bottom" ? "down" : "up",
201
219
  timeout: {
202
- enter: 150,
203
- exit: 150
220
+ enter: 167,
221
+ exit: 167
204
222
  }
205
223
  },
206
- /* @__PURE__ */ React.createElement("div", { className: clsx(`${prefixCls}-option-main`) }, children)
224
+ /* @__PURE__ */ React.createElement(
225
+ "div",
226
+ {
227
+ className: clsx(`${prefixCls}-option-main`),
228
+ ref: optionMainRef
229
+ },
230
+ children
231
+ )
207
232
  )
208
233
  )
209
234
  );
@@ -231,9 +256,8 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
231
256
  [inputProps == null ? void 0 : inputProps.className]: inputProps == null ? void 0 : inputProps.className
232
257
  })
233
258
  })
234
- ), icon || defaultIcon),
235
- isMini && renderOptions()
236
- ), !isMini && /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted: updateOptionStyle }, renderOptions()), /* @__PURE__ */ React.createElement(
259
+ ), icon || defaultIcon)
260
+ ), /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted: updateOptionStyle }, renderOptions()), /* @__PURE__ */ React.createElement(
237
261
  Backdrop,
238
262
  __spreadProps(__spreadValues({
239
263
  open: isOpen,
@@ -250,9 +274,7 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
250
274
  Select.displayName = "BuiSelect";
251
275
  Select.defaultProps = {
252
276
  defaultValue: "",
253
- scrollContainer: () => {
254
- return isMini ? null : document.body;
255
- }
277
+ scrollContainer: () => null
256
278
  };
257
279
  var Select_default = Select;
258
280
  export {
@@ -50,7 +50,9 @@ import { GripperBarVerticalIcon } from "@bifrostui/icons";
50
50
  import {
51
51
  isMini,
52
52
  useForkRef,
53
- useTouchEmulator,
53
+ emulateTouchStart,
54
+ emulateTouchMove,
55
+ emulateTouchEnd,
54
56
  useValue,
55
57
  getBoundingClientRect
56
58
  } from "@bifrostui/utils";
@@ -110,7 +112,6 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
110
112
  const value = shouldProtection ? latestVal.current : valueProp;
111
113
  const [rootRef, setRootRef] = useState(null);
112
114
  const handleRef = useForkRef(ref, setRootRef);
113
- useTouchEmulator(rootRef);
114
115
  const sliderRect = useRef();
115
116
  const touchStartPageX = useRef();
116
117
  const touchStartLeft = useRef();
@@ -181,9 +182,7 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
181
182
  return;
182
183
  beforeMoveValue.current = internalValue;
183
184
  tooltipRef.current = internalValue;
184
- if (!sliderRect.current.width) {
185
- getLineWidth();
186
- }
185
+ getLineWidth();
187
186
  const currentTarget = isMini ? e.mpEvent.currentTarget : e.currentTarget;
188
187
  touchStartPageX.current = e.touches[0].pageX;
189
188
  touchStartLeft.current = currentTarget == null ? void 0 : currentTarget.offsetLeft;
@@ -242,6 +241,16 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
242
241
  setFrontTooltipVisible(false);
243
242
  setEndTooltipVisible(false);
244
243
  };
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
+ };
245
254
  const renderButton = (index) => {
246
255
  const valuenow = internalValue[index];
247
256
  return /* @__PURE__ */ React.createElement(
@@ -264,7 +273,8 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
264
273
  },
265
274
  onTouchMove,
266
275
  onTouchEnd,
267
- onTouchCancel: onTouchEnd
276
+ onTouchCancel: onTouchEnd,
277
+ onMouseDown
268
278
  },
269
279
  index === SLIDER_BUTTON.FRONT ? startIcon || defaultIcon : endIcon || defaultIcon
270
280
  );
@@ -0,0 +1,79 @@
1
+ :root,
2
+ page,
3
+ xhs-page {
4
+ --bui-swipe-action-container-padding: 10px;
5
+ --bui-swipe-action-container-color: var(--bui-color-black);
6
+ }
7
+ .bui-swipe-action {
8
+ background: var(--bui-color-bg-view);
9
+ font-family: var(--bui-font-family);
10
+ overflow: hidden;
11
+ touch-action: pan-x;
12
+ }
13
+ .bui-swipe-action-track {
14
+ position: relative;
15
+ transition: transform 200ms ease;
16
+ }
17
+ .bui-swipe-action-actions {
18
+ position: absolute;
19
+ top: 0;
20
+ display: flex;
21
+ width: auto;
22
+ white-space: nowrap;
23
+ }
24
+ .bui-swipe-action-actions-right {
25
+ left: 100%;
26
+ height: 100%;
27
+ cursor: pointer;
28
+ margin-left: 1px;
29
+ user-select: none;
30
+ display: flex;
31
+ align-items: center;
32
+ box-sizing: content-box;
33
+ }
34
+ .bui-swipe-action-actions-left {
35
+ margin-right: 1px;
36
+ right: 100%;
37
+ height: 100%;
38
+ cursor: pointer;
39
+ box-sizing: content-box;
40
+ user-select: none;
41
+ display: flex;
42
+ align-items: center;
43
+ }
44
+ .bui-swipe-action-button {
45
+ padding: 0 15px;
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ height: 100%;
50
+ width: 100%;
51
+ color: #fff;
52
+ box-sizing: content-box;
53
+ white-space: nowrap;
54
+ }
55
+ .bui-swipe-action-content-container {
56
+ overflow: hidden;
57
+ position: relative;
58
+ cursor: grab;
59
+ user-select: none;
60
+ padding: var(--bui-swipe-action-container-padding);
61
+ color: var(--bui-swipe-action-container-color);
62
+ }
63
+ .bui-swipe-action-content-container:active {
64
+ cursor: grabbing;
65
+ }
66
+ .bui-swipe-action-content-mask {
67
+ position: absolute;
68
+ left: 0;
69
+ top: 0;
70
+ width: 100%;
71
+ height: 100%;
72
+ }
73
+ .bui-swipe-action-action {
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: center;
77
+ padding: 0 10px;
78
+ height: 100%;
79
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { SwipeActionProps, SwipeActionRef } from './SwipeAction.types';
3
+ import './SwipeAction.less';
4
+ declare const SwipeAction: React.ForwardRefExoticComponent<Omit<SwipeActionProps<"div", {}>, "ref"> & React.RefAttributes<SwipeActionRef>>;
5
+ export default SwipeAction;