@bifrostui/react 2.0.0-beta.10 → 2.0.0-beta.12

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 (213) hide show
  1. package/dist/Calendar/Calendar.js +5 -1
  2. package/dist/Calendar/Calendar.types.d.ts +5 -0
  3. package/dist/Collapse/Collapse.css +0 -1
  4. package/dist/Collapse/Collapse.d.ts +1 -1
  5. package/dist/Collapse/Collapse.js +11 -8
  6. package/dist/Collapse/Collapse.miniapp.d.ts +5 -0
  7. package/dist/Collapse/Collapse.miniapp.js +177 -0
  8. package/dist/CollapsePanel/CollapsePanel.css +4 -2
  9. package/dist/DatePicker/DatePicker.d.ts +4 -0
  10. package/dist/DatePicker/DatePicker.js +335 -0
  11. package/dist/DatePicker/DatePicker.types.d.ts +36 -0
  12. package/dist/DatePicker/DatePicker.types.js +15 -0
  13. package/dist/DatePicker/constants.d.ts +9 -0
  14. package/dist/DatePicker/constants.js +37 -0
  15. package/dist/DatePicker/index.d.ts +3 -0
  16. package/dist/DatePicker/index.js +44 -0
  17. package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  18. package/dist/DesktopDatePicker/DesktopDatePicker.js +280 -0
  19. package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  20. package/dist/DesktopDatePicker/DesktopDatePicker.types.js +15 -0
  21. package/dist/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  22. package/dist/DesktopDatePicker/index.css +61 -0
  23. package/dist/DesktopDatePicker/index.d.ts +2 -0
  24. package/dist/DesktopDatePicker/index.js +41 -0
  25. package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  26. package/dist/DesktopDatePicker/useGetDatePickerContent.js +343 -0
  27. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  28. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +322 -0
  29. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  30. package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +15 -0
  31. package/dist/DesktopDateTimePicker/index.css +66 -0
  32. package/dist/DesktopDateTimePicker/index.d.ts +2 -0
  33. package/dist/DesktopDateTimePicker/index.js +41 -0
  34. package/dist/DesktopPicker/DesktopPicker.d.ts +5 -0
  35. package/dist/DesktopPicker/DesktopPicker.js +243 -0
  36. package/dist/DesktopPicker/DesktopPicker.types.d.ts +61 -0
  37. package/dist/DesktopPicker/DesktopPicker.types.js +15 -0
  38. package/dist/DesktopPicker/index.css +39 -0
  39. package/dist/DesktopPicker/index.d.ts +2 -0
  40. package/dist/DesktopPicker/index.js +41 -0
  41. package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  42. package/dist/{Tabs/utils/bound.js → DesktopPicker/utils/calcAfterMounted.js} +7 -14
  43. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  44. package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +38 -0
  45. package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  46. package/dist/DesktopTimePicker/DesktopTimePicker.js +288 -0
  47. package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  48. package/dist/DesktopTimePicker/DesktopTimePicker.types.js +15 -0
  49. package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  50. package/dist/DesktopTimePicker/DesktopTimePickerList.js +111 -0
  51. package/dist/DesktopTimePicker/index.css +170 -0
  52. package/dist/DesktopTimePicker/index.d.ts +2 -0
  53. package/dist/DesktopTimePicker/index.js +41 -0
  54. package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  55. package/dist/DesktopTimePicker/useGetTimePickerContent.js +249 -0
  56. package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  57. package/dist/DesktopTimePicker/utils/scrollUtil.js +27 -0
  58. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  59. package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +51 -0
  60. package/dist/DesktopTimePicker/utils/utils.d.ts +28 -0
  61. package/dist/DesktopTimePicker/utils/utils.js +408 -0
  62. package/dist/Dialog/Dialog.types.d.ts +5 -0
  63. package/dist/Dialog/FunctionalDialog.js +13 -2
  64. package/dist/Input/Input.css +0 -2
  65. package/dist/Modal/Modal.miniapp.d.ts +1 -1
  66. package/dist/Picker/Picker.css +5 -0
  67. package/dist/Picker/Picker.js +27 -5
  68. package/dist/Picker/Picker.types.d.ts +15 -2
  69. package/dist/Picker/PickerPanel.css +4 -0
  70. package/dist/Picker/PickerPanel.js +7 -6
  71. package/dist/Popover/Popover.js +70 -27
  72. package/dist/Portal/Portal.miniapp.js +7 -4
  73. package/dist/ScrollView/ScrollView.js +24 -11
  74. package/dist/ScrollView/ScrollView.types.d.ts +0 -1
  75. package/dist/Select/Select.css +1 -4
  76. package/dist/Select/Select.js +62 -37
  77. package/dist/Slider/Slider.js +13 -5
  78. package/dist/SwipeAction/SwipeAction.css +79 -0
  79. package/dist/SwipeAction/SwipeAction.d.ts +5 -0
  80. package/dist/SwipeAction/SwipeAction.js +349 -0
  81. package/dist/SwipeAction/SwipeAction.types.d.ts +75 -0
  82. package/dist/SwipeAction/SwipeAction.types.js +15 -0
  83. package/dist/SwipeAction/SwipeActionContext.d.ts +4 -0
  84. package/dist/SwipeAction/SwipeActionContext.js +30 -0
  85. package/dist/SwipeAction/SwipeActionItem.css +31 -0
  86. package/dist/SwipeAction/SwipeActionItem.d.ts +5 -0
  87. package/dist/SwipeAction/SwipeActionItem.js +105 -0
  88. package/dist/SwipeAction/constants.d.ts +9 -0
  89. package/dist/SwipeAction/constants.js +39 -0
  90. package/dist/SwipeAction/index.d.ts +5 -0
  91. package/dist/SwipeAction/index.js +50 -0
  92. package/dist/TabBar/TabBarItem.js +2 -2
  93. package/dist/Tabs/Tabs.js +29 -14
  94. package/dist/Tabs/utils/scroll.d.ts +2 -0
  95. package/dist/Tabs/utils/scroll.js +55 -0
  96. package/dist/Toast/FunctionalToast.js +13 -2
  97. package/dist/Toast/Toast.css +0 -1
  98. package/dist/Toast/Toast.types.d.ts +5 -0
  99. package/dist/Tooltip/Tooltip.js +70 -27
  100. package/dist/index.d.ts +6 -0
  101. package/dist/index.js +13 -1
  102. package/dist/locales/base.d.ts +11 -0
  103. package/dist/locales/en-US.js +24 -0
  104. package/dist/locales/zh-CN.js +24 -0
  105. package/dist/locales/zh-TW.js +24 -0
  106. package/es/Calendar/Calendar.js +5 -1
  107. package/es/Calendar/Calendar.types.d.ts +5 -0
  108. package/es/Collapse/Collapse.css +0 -1
  109. package/es/Collapse/Collapse.d.ts +1 -1
  110. package/es/Collapse/Collapse.js +11 -8
  111. package/es/Collapse/Collapse.miniapp.d.ts +5 -0
  112. package/es/Collapse/Collapse.miniapp.js +157 -0
  113. package/es/CollapsePanel/CollapsePanel.css +4 -2
  114. package/es/DatePicker/DatePicker.d.ts +4 -0
  115. package/es/DatePicker/DatePicker.js +308 -0
  116. package/es/DatePicker/DatePicker.types.d.ts +36 -0
  117. package/es/DatePicker/DatePicker.types.js +1 -0
  118. package/es/DatePicker/constants.d.ts +9 -0
  119. package/es/DatePicker/constants.js +14 -0
  120. package/es/DatePicker/index.d.ts +3 -0
  121. package/es/DatePicker/index.js +8 -0
  122. package/es/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
  123. package/es/DesktopDatePicker/DesktopDatePicker.js +253 -0
  124. package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
  125. package/es/DesktopDatePicker/DesktopDatePicker.types.js +1 -0
  126. package/es/DesktopDatePicker/deskTopPickerContainer.css +100 -0
  127. package/es/DesktopDatePicker/index.css +61 -0
  128. package/es/DesktopDatePicker/index.d.ts +2 -0
  129. package/es/DesktopDatePicker/index.js +6 -0
  130. package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
  131. package/es/DesktopDatePicker/useGetDatePickerContent.js +316 -0
  132. package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
  133. package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +295 -0
  134. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
  135. package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +1 -0
  136. package/es/DesktopDateTimePicker/index.css +66 -0
  137. package/es/DesktopDateTimePicker/index.d.ts +2 -0
  138. package/es/DesktopDateTimePicker/index.js +9 -0
  139. package/es/DesktopPicker/DesktopPicker.d.ts +5 -0
  140. package/es/DesktopPicker/DesktopPicker.js +226 -0
  141. package/es/DesktopPicker/DesktopPicker.types.d.ts +61 -0
  142. package/es/DesktopPicker/DesktopPicker.types.js +1 -0
  143. package/es/DesktopPicker/index.css +39 -0
  144. package/es/DesktopPicker/index.d.ts +2 -0
  145. package/es/DesktopPicker/index.js +6 -0
  146. package/es/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
  147. package/es/DesktopPicker/utils/calcAfterMounted.js +6 -0
  148. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
  149. package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +9 -0
  150. package/es/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
  151. package/es/DesktopTimePicker/DesktopTimePicker.js +261 -0
  152. package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
  153. package/es/DesktopTimePicker/DesktopTimePicker.types.js +1 -0
  154. package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
  155. package/es/DesktopTimePicker/DesktopTimePickerList.js +84 -0
  156. package/es/DesktopTimePicker/index.css +170 -0
  157. package/es/DesktopTimePicker/index.d.ts +2 -0
  158. package/es/DesktopTimePicker/index.js +6 -0
  159. package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
  160. package/es/DesktopTimePicker/useGetTimePickerContent.js +226 -0
  161. package/es/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
  162. package/es/DesktopTimePicker/utils/scrollUtil.js +8 -0
  163. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
  164. package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +22 -0
  165. package/es/DesktopTimePicker/utils/utils.d.ts +28 -0
  166. package/es/DesktopTimePicker/utils/utils.js +365 -0
  167. package/es/Dialog/Dialog.types.d.ts +5 -0
  168. package/es/Dialog/FunctionalDialog.js +14 -3
  169. package/es/Input/Input.css +0 -2
  170. package/es/Picker/Picker.css +5 -0
  171. package/es/Picker/Picker.js +27 -5
  172. package/es/Picker/Picker.types.d.ts +15 -2
  173. package/es/Picker/PickerPanel.css +4 -0
  174. package/es/Picker/PickerPanel.js +7 -6
  175. package/es/Popover/Popover.js +73 -29
  176. package/es/Portal/Portal.miniapp.js +8 -5
  177. package/es/ScrollView/ScrollView.js +24 -11
  178. package/es/ScrollView/ScrollView.types.d.ts +0 -1
  179. package/es/Select/Select.css +1 -4
  180. package/es/Select/Select.js +62 -38
  181. package/es/Slider/Slider.js +16 -6
  182. package/es/SwipeAction/SwipeAction.css +79 -0
  183. package/es/SwipeAction/SwipeAction.d.ts +5 -0
  184. package/es/SwipeAction/SwipeAction.js +334 -0
  185. package/es/SwipeAction/SwipeAction.types.d.ts +75 -0
  186. package/es/SwipeAction/SwipeAction.types.js +1 -0
  187. package/es/SwipeAction/SwipeActionContext.d.ts +4 -0
  188. package/es/SwipeAction/SwipeActionContext.js +11 -0
  189. package/es/SwipeAction/SwipeActionItem.css +31 -0
  190. package/es/SwipeAction/SwipeActionItem.d.ts +5 -0
  191. package/es/SwipeAction/SwipeActionItem.js +78 -0
  192. package/es/SwipeAction/constants.d.ts +9 -0
  193. package/es/SwipeAction/constants.js +15 -0
  194. package/es/SwipeAction/index.d.ts +5 -0
  195. package/es/SwipeAction/index.js +12 -0
  196. package/es/TabBar/TabBarItem.js +1 -1
  197. package/es/Tabs/Tabs.js +29 -14
  198. package/es/Tabs/utils/scroll.d.ts +2 -0
  199. package/es/Tabs/utils/scroll.js +36 -0
  200. package/es/Toast/FunctionalToast.js +14 -3
  201. package/es/Toast/Toast.css +0 -1
  202. package/es/Toast/Toast.types.d.ts +5 -0
  203. package/es/Tooltip/Tooltip.js +73 -29
  204. package/es/index.d.ts +6 -0
  205. package/es/index.js +6 -0
  206. package/es/locales/base.d.ts +11 -0
  207. package/es/locales/en-US.js +24 -0
  208. package/es/locales/zh-CN.js +24 -0
  209. package/es/locales/zh-TW.js +24 -0
  210. package/package.json +5 -5
  211. package/dist/Tabs/utils/bound.d.ts +0 -1
  212. package/es/Tabs/utils/bound.d.ts +0 -1
  213. package/es/Tabs/utils/bound.js +0 -13
@@ -51,6 +51,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
51
51
  mod
52
52
  ));
53
53
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
54
+ var __async = (__this, __arguments, generator) => {
55
+ return new Promise((resolve, reject) => {
56
+ var fulfilled = (value) => {
57
+ try {
58
+ step(generator.next(value));
59
+ } catch (e) {
60
+ reject(e);
61
+ }
62
+ };
63
+ var rejected = (value) => {
64
+ try {
65
+ step(generator.throw(value));
66
+ } catch (e) {
67
+ reject(e);
68
+ }
69
+ };
70
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
71
+ step((generator = generator.apply(__this, __arguments)).next());
72
+ });
73
+ };
54
74
  var Popover_exports = {};
55
75
  __export(Popover_exports, {
56
76
  default: () => Popover_default
@@ -73,9 +93,9 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
73
93
  offsetSpacing = 0,
74
94
  placement = "top",
75
95
  trigger = "click",
76
- onOpenChange,
77
96
  open,
78
- hideArrow
97
+ hideArrow,
98
+ onOpenChange
79
99
  } = _a, others = __objRest(_a, [
80
100
  "className",
81
101
  "style",
@@ -86,9 +106,9 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
86
106
  "offsetSpacing",
87
107
  "placement",
88
108
  "trigger",
89
- "onOpenChange",
90
109
  "open",
91
- "hideArrow"
110
+ "hideArrow",
111
+ "onOpenChange"
92
112
  ]);
93
113
  const controlByUser = typeof open !== "undefined";
94
114
  const { direction, location = "center" } = (0, import_utils.parsePlacement)(placement);
@@ -96,11 +116,18 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
96
116
  const [openStatus, setOpenStatus] = (0, import_react.useState)(defaultOpen);
97
117
  const [arrowDirection, setArrowDirection] = (0, import_react.useState)(direction);
98
118
  const [arrowLocation, setArrowLocation] = (0, import_react.useState)(location);
99
- const [tooltyles, setTooltyles] = (0, import_react.useState)({});
100
- const ttId = (0, import_utils.useUniqueId)();
119
+ const [toolStyles, setToolStyles] = (0, import_react.useState)({});
120
+ const tipRef = (0, import_react.useRef)(null);
121
+ const nodeRef = (0, import_utils.useForkRef)(ref, tipRef);
122
+ const clearRef = (status) => {
123
+ if (status === false) {
124
+ tipRef.current = null;
125
+ }
126
+ };
101
127
  const changeOpenStatus = (event, status) => {
102
128
  if (controlByUser)
103
129
  return;
130
+ clearRef(status);
104
131
  setOpenStatus(status);
105
132
  onOpenChange == null ? void 0 : onOpenChange(event, { open: status });
106
133
  };
@@ -119,23 +146,33 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
119
146
  if (!controlByUser)
120
147
  return;
121
148
  setOpenStatus(open);
149
+ clearRef(open);
122
150
  }, [open]);
151
+ (0, import_react.useEffect)(() => {
152
+ if (!openStatus) {
153
+ setToolStyles({
154
+ visibility: "hidden"
155
+ });
156
+ }
157
+ }, [openStatus]);
123
158
  const clickEventHandler = (event) => {
124
159
  if (trigger === "hover" || (trigger == null ? void 0 : trigger.length) === 1 && (trigger == null ? void 0 : trigger[0]) === "hover")
125
160
  return;
126
161
  hidePopover(event);
127
162
  };
128
- const onRootElementMouted = (0, import_utils.throttle)(() => {
163
+ const onRootElementMouted = (0, import_utils.throttle)(() => __async(void 0, null, function* () {
164
+ if (!tipRef.current)
165
+ return;
129
166
  const {
130
167
  direction: newParsedDirection,
131
168
  location: newParsedLocation = "center"
132
169
  } = (0, import_utils.parsePlacement)(placement);
133
- const result = (0, import_utils.getStylesAndLocation)({
170
+ const result = yield (0, import_utils.getStylesAndLocation)({
134
171
  childrenRef,
135
172
  arrowDirection: newParsedDirection,
136
173
  arrowLocation: newParsedLocation,
137
174
  offsetSpacing,
138
- selector: `[data-id="tt_${ttId}"]`
175
+ tipRef
139
176
  });
140
177
  if (!result)
141
178
  return;
@@ -146,26 +183,32 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
146
183
  if (newArrowLocation !== arrowLocation) {
147
184
  setArrowLocation(newArrowLocation);
148
185
  }
149
- setTooltyles(styles);
150
- }, 100);
151
- const bindEvent = () => {
152
- if (!controlByUser) {
153
- document.addEventListener("click", clickEventHandler);
154
- }
155
- window.addEventListener("resize", onRootElementMouted);
156
- };
157
- const unbindEvent = () => {
158
- if (!controlByUser) {
159
- document.removeEventListener("click", clickEventHandler);
160
- }
161
- window.removeEventListener("resize", onRootElementMouted);
162
- };
186
+ setToolStyles(styles);
187
+ }), 100);
163
188
  (0, import_react.useEffect)(() => {
189
+ const bindEvent = () => {
190
+ if (!tipRef.current)
191
+ return;
192
+ if (!controlByUser) {
193
+ document.addEventListener("click", clickEventHandler);
194
+ }
195
+ if (!import_utils.isMini) {
196
+ window.addEventListener("resize", onRootElementMouted);
197
+ }
198
+ };
199
+ const unbindEvent = () => {
200
+ if (!controlByUser) {
201
+ document.removeEventListener("click", clickEventHandler);
202
+ }
203
+ if (!import_utils.isMini) {
204
+ window.removeEventListener("resize", onRootElementMouted);
205
+ }
206
+ };
164
207
  bindEvent();
165
208
  return () => {
166
209
  unbindEvent();
167
210
  };
168
- }, []);
211
+ }, [openStatus]);
169
212
  if (!title && !content)
170
213
  return null;
171
214
  let triggerEventOption;
@@ -180,14 +223,14 @@ const Popover = /* @__PURE__ */ import_react.default.forwardRef((props, ref) =>
180
223
  const childrenOptions = __spreadValues({
181
224
  ref: childrenRef
182
225
  }, triggerEventOption);
183
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, open || openStatus ? /* @__PURE__ */ import_react.default.createElement(import_Portal.default, { onRootElementMouted, ref }, /* @__PURE__ */ import_react.default.createElement(
226
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, open || openStatus ? /* @__PURE__ */ import_react.default.createElement(import_Portal.default, { onRootElementMouted }, /* @__PURE__ */ import_react.default.createElement(
184
227
  "div",
185
228
  __spreadValues({
186
229
  className: (0, import_clsx.default)(prefixCls, className, `popover-${arrowDirection}`, {
187
230
  "bui-popover-arrow-hide": hideArrow
188
231
  }),
189
- "data-id": `tt_${ttId}`,
190
- style: __spreadValues(__spreadValues({}, style), tooltyles)
232
+ style: __spreadValues(__spreadValues({}, style), toolStyles),
233
+ ref: nodeRef
191
234
  }, others),
192
235
  !hideArrow ? /* @__PURE__ */ import_react.default.createElement(
193
236
  "div",
@@ -53,7 +53,9 @@ var import_react = __toESM(require("react"));
53
53
  var import_PortalCore = __toESM(require("./PortalCore"));
54
54
  const Portal = (0, import_react.forwardRef)((props, ref) => {
55
55
  const { disablePortal } = props;
56
- const rootWrapperElement = (0, import_react.useMemo)(() => {
56
+ const [rootWrapperElement, setRootWrapperElement] = (0, import_react.useState)();
57
+ (0, import_react.useEffect)(() => {
58
+ let root;
57
59
  if (!disablePortal) {
58
60
  const currentPages = import_taro.default.getCurrentPages() || [];
59
61
  const currentPage = currentPages[currentPages.length - 1];
@@ -65,11 +67,12 @@ const Portal = (0, import_react.forwardRef)((props, ref) => {
65
67
  const view = document.createElement("view");
66
68
  view.id = portalId;
67
69
  rootElement == null ? void 0 : rootElement.appendChild(view);
68
- return view;
70
+ root = view;
71
+ } else {
72
+ root = portalWrapperElement;
69
73
  }
70
- return portalWrapperElement;
71
74
  }
72
- return void 0;
75
+ setRootWrapperElement(root);
73
76
  }, []);
74
77
  return /* @__PURE__ */ import_react.default.createElement(import_PortalCore.default, __spreadProps(__spreadValues({}, props), { ref, rootElement: rootWrapperElement }));
75
78
  });
@@ -34,12 +34,14 @@ var import_utils = require("@bifrostui/utils");
34
34
  var import_clsx = __toESM(require("clsx"));
35
35
  var import_react = __toESM(require("react"));
36
36
  var import_ScrollView = require("./ScrollView.css");
37
- function easeOutScroll(from, to, callback) {
37
+ function easeOutScroll(from, to, callback, dur) {
38
+ if (dur <= 0) {
39
+ dur = 500;
40
+ }
38
41
  if (from === to || typeof from !== "number") {
39
42
  return;
40
43
  }
41
44
  const change = to - from;
42
- const dur = 500;
43
45
  const sTime = +/* @__PURE__ */ new Date();
44
46
  function linear(t, b, c, d) {
45
47
  return c * t / d + b;
@@ -74,7 +76,8 @@ const ScrollView = (0, import_react.forwardRef)(
74
76
  scrollIntoView,
75
77
  onTouchMove: propsOnTouchMove,
76
78
  scrollIntoViewAlignment,
77
- children
79
+ children,
80
+ scrollAnimationDuration = 500
78
81
  } = props;
79
82
  const container = (0, import_react.useRef)(null);
80
83
  const handleRef = (0, import_utils.useForkRef)(ref, container);
@@ -84,10 +87,15 @@ const ScrollView = (0, import_react.forwardRef)(
84
87
  if (top === void 0)
85
88
  return;
86
89
  if (isAnimation) {
87
- easeOutScroll(container.current.scrollTop, top, (pos) => {
88
- if (container.current)
89
- container.current.scrollTop = pos;
90
- });
90
+ easeOutScroll(
91
+ container.current.scrollTop,
92
+ top,
93
+ (pos) => {
94
+ if (container.current)
95
+ container.current.scrollTop = pos;
96
+ },
97
+ scrollAnimationDuration
98
+ );
91
99
  } else if (container.current)
92
100
  container.current.scrollTop = top;
93
101
  }, []);
@@ -95,10 +103,15 @@ const ScrollView = (0, import_react.forwardRef)(
95
103
  if (left === void 0)
96
104
  return;
97
105
  if (isAnimation) {
98
- easeOutScroll(container.current.scrollLeft, left, (pos) => {
99
- if (container.current)
100
- container.current.scrollLeft = pos;
101
- });
106
+ easeOutScroll(
107
+ container.current.scrollLeft,
108
+ left,
109
+ (pos) => {
110
+ if (container.current)
111
+ container.current.scrollLeft = pos;
112
+ },
113
+ scrollAnimationDuration
114
+ );
102
115
  } else if (container.current)
103
116
  container.current.scrollLeft = left;
104
117
  }, []);
@@ -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 {
@@ -54,6 +54,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
54
54
  mod
55
55
  ));
56
56
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
57
+ var __async = (__this, __arguments, generator) => {
58
+ return new Promise((resolve, reject) => {
59
+ var fulfilled = (value) => {
60
+ try {
61
+ step(generator.next(value));
62
+ } catch (e) {
63
+ reject(e);
64
+ }
65
+ };
66
+ var rejected = (value) => {
67
+ try {
68
+ step(generator.throw(value));
69
+ } catch (e) {
70
+ reject(e);
71
+ }
72
+ };
73
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
74
+ step((generator = generator.apply(__this, __arguments)).next());
75
+ });
76
+ };
57
77
  var Select_exports = {};
58
78
  __export(Select_exports, {
59
79
  default: () => Select_default
@@ -123,38 +143,36 @@ const Select = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
123
143
  const isOpen = open !== void 0 ? open : internalOpen;
124
144
  const locatorRef = (0, import_react.useRef)(null);
125
145
  const rootRef = (0, import_utils.useForkRef)(ref, locatorRef);
126
- const ttId = (0, import_utils.useUniqueId)();
127
- const dataId = `${prefixCls}-tt-${ttId}`;
128
- const updateOptionStyle = (0, import_utils.throttle)(() => {
146
+ const optionContainerRef = (0, import_react.useRef)(null);
147
+ const optionMainRef = (0, import_react.useRef)(null);
148
+ const updateOptionStyle = () => __async(void 0, null, function* () {
129
149
  const curScrollRoot = scrollContainer();
130
- if (!import_utils.isMini && curScrollRoot) {
131
- const result = (0, import_utils.getStylesAndLocation)({
132
- scrollRoot: curScrollRoot,
133
- childrenRef: locatorRef,
134
- arrowDirection: defaultPlacement,
135
- arrowLocation: "none",
136
- selector: `[data-id="${dataId}"]`,
137
- offsetSpacing: 0
138
- });
139
- if (!result)
140
- return;
141
- const { styles, childrenStyle, newArrowDirection } = result;
142
- setPlacement(newArrowDirection);
143
- setOptionStyle(__spreadProps(__spreadValues({}, styles), { width: childrenStyle.width }));
144
- }
145
- }, 100);
146
- const changeOpen = (newOpen) => {
150
+ const result = yield (0, import_utils.getStylesAndLocation)({
151
+ scrollRoot: curScrollRoot,
152
+ childrenRef: locatorRef,
153
+ tipRef: optionContainerRef,
154
+ arrowDirection: defaultPlacement,
155
+ arrowLocation: "none",
156
+ offsetSpacing: 0
157
+ });
158
+ if (!result)
159
+ return;
160
+ const { styles, childrenStyle, newArrowDirection } = result;
161
+ optionMainRef.current.style.transition = "none";
162
+ optionMainRef.current.style.transform = `translateY(${newArrowDirection === "bottom" ? "-100%" : "100%"})`;
163
+ setPlacement(newArrowDirection);
164
+ setOptionStyle(__spreadProps(__spreadValues({}, styles), { width: childrenStyle == null ? void 0 : childrenStyle.width }));
165
+ });
166
+ const changeOpen = (newOpen) => __async(void 0, null, function* () {
147
167
  if (newOpen) {
148
- updateOptionStyle();
149
- setTimeout(() => {
150
- setInternalOpen(newOpen);
151
- onOpen == null ? void 0 : onOpen();
152
- }, 100);
168
+ yield updateOptionStyle();
169
+ setInternalOpen(newOpen);
170
+ onOpen == null ? void 0 : onOpen();
153
171
  } else {
154
172
  onClose == null ? void 0 : onClose();
155
173
  setInternalOpen(newOpen);
156
174
  }
157
- };
175
+ });
158
176
  const handleSelectClick = (e) => {
159
177
  if (disabled)
160
178
  return;
@@ -179,10 +197,11 @@ const Select = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
179
197
  [selectValue, onChange, setRenderValue]
180
198
  );
181
199
  (0, import_react.useEffect)(() => {
200
+ const resizeCb = (0, import_utils.throttle)(updateOptionStyle, 100);
182
201
  if (!import_utils.isMini) {
183
- window.addEventListener("resize", updateOptionStyle);
202
+ window.addEventListener("resize", resizeCb);
184
203
  return () => {
185
- window.removeEventListener("resize", updateOptionStyle);
204
+ window.removeEventListener("resize", resizeCb);
186
205
  };
187
206
  }
188
207
  }, []);
@@ -200,8 +219,8 @@ const Select = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
200
219
  {
201
220
  in: isOpen,
202
221
  timeout: {
203
- enter: 150,
204
- exit: 150
222
+ enter: 167,
223
+ exit: 167
205
224
  }
206
225
  },
207
226
  /* @__PURE__ */ import_react.default.createElement(
@@ -215,7 +234,7 @@ const Select = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
215
234
  [`${prefixCls}-option-container-hide`]: !isOpen
216
235
  }
217
236
  ),
218
- "data-id": dataId,
237
+ ref: optionContainerRef,
219
238
  style: optionStyle
220
239
  },
221
240
  /* @__PURE__ */ import_react.default.createElement(
@@ -224,11 +243,18 @@ const Select = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
224
243
  in: isOpen,
225
244
  direction: placement === "bottom" ? "down" : "up",
226
245
  timeout: {
227
- enter: 150,
228
- exit: 150
246
+ enter: 167,
247
+ exit: 167
229
248
  }
230
249
  },
231
- /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_clsx.default)(`${prefixCls}-option-main`) }, children)
250
+ /* @__PURE__ */ import_react.default.createElement(
251
+ "div",
252
+ {
253
+ className: (0, import_clsx.default)(`${prefixCls}-option-main`),
254
+ ref: optionMainRef
255
+ },
256
+ children
257
+ )
232
258
  )
233
259
  )
234
260
  );
@@ -256,9 +282,8 @@ const Select = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
256
282
  [inputProps == null ? void 0 : inputProps.className]: inputProps == null ? void 0 : inputProps.className
257
283
  })
258
284
  })
259
- ), icon || defaultIcon),
260
- import_utils.isMini && renderOptions()
261
- ), !import_utils.isMini && /* @__PURE__ */ import_react.default.createElement(import_Portal.default, { onRootElementMouted: updateOptionStyle }, renderOptions()), /* @__PURE__ */ import_react.default.createElement(
285
+ ), icon || defaultIcon)
286
+ ), /* @__PURE__ */ import_react.default.createElement(import_Portal.default, { onRootElementMouted: updateOptionStyle }, renderOptions()), /* @__PURE__ */ import_react.default.createElement(
262
287
  import_Backdrop.default,
263
288
  __spreadProps(__spreadValues({
264
289
  open: isOpen,
@@ -128,7 +128,6 @@ const Slider = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
128
128
  const value = shouldProtection ? latestVal.current : valueProp;
129
129
  const [rootRef, setRootRef] = (0, import_react.useState)(null);
130
130
  const handleRef = (0, import_utils.useForkRef)(ref, setRootRef);
131
- (0, import_utils.useTouchEmulator)(rootRef);
132
131
  const sliderRect = (0, import_react.useRef)();
133
132
  const touchStartPageX = (0, import_react.useRef)();
134
133
  const touchStartLeft = (0, import_react.useRef)();
@@ -199,9 +198,7 @@ const Slider = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
199
198
  return;
200
199
  beforeMoveValue.current = internalValue;
201
200
  tooltipRef.current = internalValue;
202
- if (!sliderRect.current.width) {
203
- getLineWidth();
204
- }
201
+ getLineWidth();
205
202
  const currentTarget = import_utils.isMini ? e.mpEvent.currentTarget : e.currentTarget;
206
203
  touchStartPageX.current = e.touches[0].pageX;
207
204
  touchStartLeft.current = currentTarget == null ? void 0 : currentTarget.offsetLeft;
@@ -260,6 +257,16 @@ const Slider = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
260
257
  setFrontTooltipVisible(false);
261
258
  setEndTooltipVisible(false);
262
259
  };
260
+ const onMouseUp = (e) => {
261
+ (0, import_utils.emulateTouchEnd)(e);
262
+ document.removeEventListener("mousemove", import_utils.emulateTouchMove);
263
+ document.removeEventListener("mouseup", onMouseUp);
264
+ };
265
+ const onMouseDown = (e) => {
266
+ (0, import_utils.emulateTouchStart)(e);
267
+ document.addEventListener("mousemove", import_utils.emulateTouchMove);
268
+ document.addEventListener("mouseup", onMouseUp);
269
+ };
263
270
  const renderButton = (index) => {
264
271
  const valuenow = internalValue[index];
265
272
  return /* @__PURE__ */ import_react.default.createElement(
@@ -282,7 +289,8 @@ const Slider = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
282
289
  },
283
290
  onTouchMove,
284
291
  onTouchEnd,
285
- onTouchCancel: onTouchEnd
292
+ onTouchCancel: onTouchEnd,
293
+ onMouseDown
286
294
  },
287
295
  index === SLIDER_BUTTON.FRONT ? startIcon || defaultIcon : endIcon || defaultIcon
288
296
  );
@@ -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;