@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
@@ -1,349 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target[prop] = source[prop];
30
- }
31
- return target;
32
- };
33
- var __export = (target, all) => {
34
- for (var name in all)
35
- __defProp(target, name, { get: all[name], enumerable: true });
36
- };
37
- var __copyProps = (to, from, except, desc) => {
38
- if (from && typeof from === "object" || typeof from === "function") {
39
- for (let key of __getOwnPropNames(from))
40
- if (!__hasOwnProp.call(to, key) && key !== except)
41
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
42
- }
43
- return to;
44
- };
45
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
46
- // If the importer is in node compatibility mode or this is not an ESM
47
- // file that has been converted to a CommonJS file using a Babel-
48
- // compatible transform (i.e. "__esModule" has not been set), then set
49
- // "default" to the CommonJS "module.exports" for node compatibility.
50
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
51
- mod
52
- ));
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
- };
74
- var SwipeAction_exports = {};
75
- __export(SwipeAction_exports, {
76
- default: () => SwipeAction_default
77
- });
78
- module.exports = __toCommonJS(SwipeAction_exports);
79
- var import_react = __toESM(require("react"));
80
- var import_clsx = __toESM(require("clsx"));
81
- var import_utils = require("@bifrostui/utils");
82
- var import_SwipeActionContext = __toESM(require("./SwipeActionContext"));
83
- var import_SwipeAction = require("./SwipeAction.types");
84
- var import_SwipeAction2 = require("./SwipeAction.css");
85
- const classPrefix = "bui-swipe-action";
86
- const SwipeAction = /* @__PURE__ */ import_react.default.forwardRef(
87
- (props, ref) => {
88
- const _a = props, {
89
- className,
90
- children,
91
- rightActions,
92
- leftActions,
93
- disabled,
94
- closeOnClickActionItem = true,
95
- closeOnClickContainer = false,
96
- onActionsReveal
97
- } = _a, others = __objRest(_a, [
98
- "className",
99
- "children",
100
- "rightActions",
101
- "leftActions",
102
- "disabled",
103
- "closeOnClickActionItem",
104
- "closeOnClickContainer",
105
- "onActionsReveal"
106
- ]);
107
- const touch = (0, import_utils.useTouch)();
108
- const rootRef = (0, import_react.useRef)(null);
109
- const leftRef = (0, import_react.useRef)(null);
110
- const rightRef = (0, import_react.useRef)(null);
111
- const contentRef = (0, import_react.useRef)(null);
112
- const [translateX, setTranslateX] = (0, import_react.useState)(0);
113
- const [isOpen, setIsOpen] = (0, import_react.useState)(false);
114
- const startingX = (0, import_react.useRef)(0);
115
- const currentX = (0, import_react.useRef)(0);
116
- const isDragging = (0, import_react.useRef)(false);
117
- let pretranslateX = 0;
118
- let dragPhase = import_SwipeAction.DragPhaseEnum.START;
119
- const dragThreshold = 5;
120
- const leftWidthCache = (0, import_react.useRef)(0);
121
- const rightWidthCache = (0, import_react.useRef)(0);
122
- const getWidth = (_ref) => {
123
- if (!_ref.current)
124
- return Promise.resolve(0);
125
- return new Promise((resolve) => {
126
- if (import_utils.isMini) {
127
- (0, import_utils.getBoundingClientRect)(_ref.current).then((rect) => {
128
- if (rect) {
129
- resolve(rect.width || 0);
130
- }
131
- });
132
- } else {
133
- resolve(_ref.current.offsetWidth);
134
- }
135
- });
136
- };
137
- const getLefRefWidth = () => __async(void 0, null, function* () {
138
- if (leftRef.current && leftActions && !leftWidthCache.current) {
139
- leftWidthCache.current = yield getWidth(leftRef);
140
- }
141
- return leftWidthCache.current;
142
- });
143
- const getRightRefWidth = () => __async(void 0, null, function* () {
144
- if (rightRef.current && rightActions && !rightWidthCache.current) {
145
- rightWidthCache.current = yield getWidth(rightRef);
146
- }
147
- return rightWidthCache.current;
148
- });
149
- const initRefWidth = () => {
150
- getLefRefWidth();
151
- getRightRefWidth();
152
- };
153
- const handleTouchStart = (e) => {
154
- dragPhase = import_SwipeAction.DragPhaseEnum.START;
155
- const isMaskEle = e.target.id === "content-mask";
156
- if (isDragging.current || disabled || isMaskEle)
157
- return;
158
- touch.start(e);
159
- isDragging.current = true;
160
- startingX.current = touch.deltaX.current - translateX;
161
- };
162
- const handleTouchMove = (0, import_utils.throttle)(
163
- (e) => __async(void 0, null, function* () {
164
- if (!isDragging.current || disabled)
165
- return;
166
- if (dragPhase === import_SwipeAction.DragPhaseEnum.START) {
167
- dragPhase = import_SwipeAction.DragPhaseEnum.MOVE;
168
- }
169
- touch.move(e);
170
- currentX.current = touch.deltaX.current - startingX.current;
171
- if (Math.abs(currentX.current) < dragThreshold)
172
- return;
173
- const leftWidth = yield getLefRefWidth();
174
- const rightWidth = yield getRightRefWidth();
175
- currentX.current = Math.max(
176
- -rightWidth,
177
- Math.min(leftWidth, currentX.current)
178
- );
179
- setTranslateX(currentX.current);
180
- }),
181
- 100
182
- );
183
- const emitActionsReveal = (targetX, stop = false) => {
184
- const isSpecial = targetX === pretranslateX && targetX !== 0;
185
- if (targetX === pretranslateX && !isSpecial || stop)
186
- return;
187
- let resStr = null;
188
- const shouldOpen = targetX > 0 && pretranslateX <= 0 || targetX < 0 && pretranslateX >= 0 || isSpecial;
189
- if (shouldOpen) {
190
- if (targetX > 0) {
191
- resStr = import_SwipeAction.SideTypeEnum.LEFT;
192
- } else if (targetX < 0) {
193
- resStr = import_SwipeAction.SideTypeEnum.RIGHT;
194
- }
195
- setIsOpen(true);
196
- } else {
197
- setIsOpen(false);
198
- }
199
- if (resStr) {
200
- onActionsReveal == null ? void 0 : onActionsReveal({ side: resStr });
201
- }
202
- };
203
- const handleTouchEnd = (e) => __async(void 0, null, function* () {
204
- if (!isDragging.current)
205
- return;
206
- if (dragPhase === import_SwipeAction.DragPhaseEnum.MOVE) {
207
- dragPhase = import_SwipeAction.DragPhaseEnum.END;
208
- }
209
- const leftWidth = yield getLefRefWidth();
210
- const rightWidth = yield getRightRefWidth();
211
- const threshold = 0.5;
212
- let targetX = 0;
213
- isDragging.current = false;
214
- if (Math.abs(currentX.current) < dragThreshold)
215
- return;
216
- if (currentX.current > leftWidth * threshold) {
217
- targetX = leftWidth;
218
- } else if (currentX.current < -rightWidth * threshold) {
219
- targetX = -rightWidth;
220
- }
221
- if (dragPhase === import_SwipeAction.DragPhaseEnum.END || import_utils.isMini) {
222
- emitActionsReveal(targetX);
223
- console.log("handleTouchEnd\uFF1A", targetX, e);
224
- setTranslateX(targetX);
225
- pretranslateX = targetX;
226
- }
227
- currentX.current = 0;
228
- });
229
- const close = () => {
230
- setTranslateX(0);
231
- pretranslateX = 0;
232
- setIsOpen(false);
233
- };
234
- (0, import_react.useEffect)(() => {
235
- initRefWidth();
236
- if (!contentRef.current)
237
- return;
238
- const removeTouchEmulator = (0, import_utils.touchEmulator)(contentRef.current);
239
- return () => {
240
- removeTouchEmulator();
241
- };
242
- }, []);
243
- (0, import_react.useEffect)(() => {
244
- var _a2, _b, _c, _d;
245
- (_a2 = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _a2.addEventListener("touchstart", handleTouchStart);
246
- (_b = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _b.addEventListener("touchmove", handleTouchMove);
247
- (_c = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _c.addEventListener("touchend", handleTouchEnd);
248
- (_d = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _d.addEventListener("touchcancel", handleTouchEnd);
249
- if (!import_utils.isMini && document) {
250
- document.addEventListener("mouseup", handleTouchEnd);
251
- }
252
- return () => {
253
- var _a3, _b2, _c2, _d2;
254
- (_a3 = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _a3.removeEventListener(
255
- "touchstart",
256
- handleTouchStart
257
- );
258
- (_b2 = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _b2.removeEventListener("touchmove", handleTouchMove);
259
- (_c2 = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _c2.removeEventListener("touchend", handleTouchEnd);
260
- (_d2 = contentRef == null ? void 0 : contentRef.current) == null ? void 0 : _d2.removeEventListener("touchcancel", handleTouchEnd);
261
- if (!import_utils.isMini && document) {
262
- document.removeEventListener("mouseup", handleTouchEnd);
263
- }
264
- };
265
- }, []);
266
- (0, import_react.useImperativeHandle)(ref, () => ({
267
- show: (params) => __async(void 0, null, function* () {
268
- let targetX = 0;
269
- if (params && params.side === import_SwipeAction.SideTypeEnum.RIGHT) {
270
- targetX = -(yield getRightRefWidth());
271
- } else {
272
- targetX = yield getLefRefWidth();
273
- }
274
- setTranslateX(targetX);
275
- pretranslateX = targetX;
276
- emitActionsReveal(targetX);
277
- }),
278
- close,
279
- // 获取当前是否打开
280
- open: isOpen,
281
- ref: rootRef.current
282
- }));
283
- const outClickHandle = (e) => {
284
- e.preventDefault();
285
- e.stopPropagation();
286
- if (translateX !== 0 && closeOnClickContainer) {
287
- close();
288
- }
289
- };
290
- const SwipeActionContext = (0, import_react.useMemo)(
291
- () => ({ closeOnClickActionItem, close }),
292
- [closeOnClickActionItem]
293
- );
294
- return /* @__PURE__ */ import_react.default.createElement(import_SwipeActionContext.default.Provider, { value: SwipeActionContext }, /* @__PURE__ */ import_react.default.createElement(
295
- "div",
296
- __spreadValues({
297
- className: (0, import_clsx.default)(`${classPrefix}`, className),
298
- ref: rootRef
299
- }, others),
300
- /* @__PURE__ */ import_react.default.createElement(
301
- "div",
302
- {
303
- className: `${classPrefix}-track`,
304
- style: {
305
- transform: `translate3d(${translateX}px, 0, 0)`
306
- }
307
- },
308
- /* @__PURE__ */ import_react.default.createElement(
309
- "div",
310
- {
311
- className: `${classPrefix}-actions ${classPrefix}-actions-left`,
312
- ref: leftRef
313
- },
314
- leftActions
315
- ),
316
- /* @__PURE__ */ import_react.default.createElement(
317
- "div",
318
- {
319
- className: `${classPrefix}-content-container`,
320
- ref: contentRef,
321
- onTouchStart: handleTouchStart,
322
- onTouchMove: handleTouchMove,
323
- onTouchEnd: handleTouchEnd,
324
- onTouchCancel: handleTouchEnd
325
- },
326
- isOpen && closeOnClickContainer && /* @__PURE__ */ import_react.default.createElement(
327
- "div",
328
- {
329
- className: `${classPrefix}-content-mask`,
330
- id: "content-mask",
331
- onClick: outClickHandle
332
- }
333
- ),
334
- children
335
- ),
336
- /* @__PURE__ */ import_react.default.createElement(
337
- "div",
338
- {
339
- className: `${classPrefix}-actions ${classPrefix}-actions-right`,
340
- ref: rightRef
341
- },
342
- rightActions
343
- )
344
- )
345
- ));
346
- }
347
- );
348
- SwipeAction.displayName = "BuiSwipeAction";
349
- var SwipeAction_default = SwipeAction;
@@ -1,83 +0,0 @@
1
- import { OverrideProps, ThemeColor } from '@bifrostui/types';
2
- import React from 'react';
3
- export type SwipeActionProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
4
- props: P & {
5
- /**
6
- * 右侧的操作按钮列表区域
7
- */
8
- rightActions?: React.ReactNode;
9
- /**
10
- * 左侧的操作按钮列表区域
11
- */
12
- leftActions?: React.ReactNode;
13
- /**
14
- * 是否在点击按钮区自动归位
15
- */
16
- closeOnClickActionItem?: boolean;
17
- /**
18
- * 是否在点击其他区域时自动归位
19
- */
20
- closeOnClickContainer?: boolean;
21
- /**
22
- * 操作按钮展开时触发
23
- */
24
- onActionsReveal?: (params: RevealParams) => void;
25
- /**
26
- * 是否禁用拖动
27
- */
28
- disabled?: boolean;
29
- };
30
- defaultComponent: D;
31
- }, D>;
32
- interface RevealParams {
33
- side: SideTypeEnum | '';
34
- }
35
- export type SwipeActionItemProps<D extends React.ElementType = 'div', P = {}> = OverrideProps<{
36
- props: P & {
37
- /**
38
- * 颜色风格
39
- */
40
- color?: ThemeColor | 'vip';
41
- /**
42
- * id
43
- */
44
- id?: string | number;
45
- /**
46
- * 点击事件
47
- */
48
- onClick?: (e: React.SyntheticEvent, item: {
49
- id: string | number;
50
- color: ThemeColor | 'vip';
51
- text: React.ReactNode;
52
- }) => void;
53
- };
54
- defaultComponent: D;
55
- }, D>;
56
- export interface BuiSwipeActionContextProps {
57
- /**
58
- * 是否在点击操作按钮时自动归位
59
- */
60
- closeOnClickActionItem?: boolean;
61
- /**
62
- * 关闭函数
63
- */
64
- close: () => void;
65
- }
66
- export type SwipeActionRef = {
67
- close: () => void;
68
- show: (params?: {
69
- side: SideTypeEnum;
70
- }) => void;
71
- open: boolean;
72
- ref?: HTMLDivElement;
73
- };
74
- export declare enum SideTypeEnum {
75
- LEFT = "left",
76
- RIGHT = "right"
77
- }
78
- export declare enum DragPhaseEnum {
79
- START = 1,
80
- MOVE = 2,
81
- END = 3
82
- }
83
- export {};
@@ -1,39 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var SwipeAction_types_exports = {};
19
- __export(SwipeAction_types_exports, {
20
- DragPhaseEnum: () => DragPhaseEnum,
21
- SideTypeEnum: () => SideTypeEnum
22
- });
23
- module.exports = __toCommonJS(SwipeAction_types_exports);
24
- var SideTypeEnum = /* @__PURE__ */ ((SideTypeEnum2) => {
25
- SideTypeEnum2["LEFT"] = "left";
26
- SideTypeEnum2["RIGHT"] = "right";
27
- return SideTypeEnum2;
28
- })(SideTypeEnum || {});
29
- var DragPhaseEnum = /* @__PURE__ */ ((DragPhaseEnum2) => {
30
- DragPhaseEnum2[DragPhaseEnum2["START"] = 1] = "START";
31
- DragPhaseEnum2[DragPhaseEnum2["MOVE"] = 2] = "MOVE";
32
- DragPhaseEnum2[DragPhaseEnum2["END"] = 3] = "END";
33
- return DragPhaseEnum2;
34
- })(DragPhaseEnum || {});
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- DragPhaseEnum,
38
- SideTypeEnum
39
- });
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { BuiSwipeActionContextProps } from './SwipeAction.types';
3
- declare const BuiSwipeActionContext: import("react").Context<BuiSwipeActionContextProps>;
4
- export default BuiSwipeActionContext;
@@ -1,30 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var SwipeActionContext_exports = {};
19
- __export(SwipeActionContext_exports, {
20
- default: () => SwipeActionContext_default
21
- });
22
- module.exports = __toCommonJS(SwipeActionContext_exports);
23
- var import_react = require("react");
24
- const BuiSwipeActionContext = (0, import_react.createContext)({
25
- closeOnClickActionItem: true,
26
- // eslint-disable-next-line @typescript-eslint/no-empty-function
27
- close: () => {
28
- }
29
- });
30
- var SwipeActionContext_default = BuiSwipeActionContext;
@@ -1,31 +0,0 @@
1
- .bui-swipe-action-item {
2
- padding: 0 15px;
3
- display: flex;
4
- align-items: center;
5
- justify-content: center;
6
- height: 100%;
7
- width: 100%;
8
- background: var(--background-button-color);
9
- color: #fff;
10
- box-sizing: content-box;
11
- white-space: nowrap;
12
- font-family: var(--bui-font-family);
13
- }
14
- .bui-swipe-action-item-primary {
15
- background-color: var(--bui-color-primary);
16
- }
17
- .bui-swipe-action-item-vip {
18
- background-color: var(--bui-color-vip);
19
- }
20
- .bui-swipe-action-item-success {
21
- background-color: var(--bui-color-success);
22
- }
23
- .bui-swipe-action-item-info {
24
- background-color: var(--bui-color-info);
25
- }
26
- .bui-swipe-action-item-warning {
27
- background-color: var(--bui-color-warning);
28
- }
29
- .bui-swipe-action-item-danger {
30
- background-color: var(--bui-color-danger);
31
- }
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { SwipeActionItemProps } from './SwipeAction.types';
3
- import './SwipeActionItem.less';
4
- declare const SwipeActionItem: React.ForwardRefExoticComponent<Omit<SwipeActionItemProps<"div", {}>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
- export default SwipeActionItem;
@@ -1,105 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target[prop] = source[prop];
30
- }
31
- return target;
32
- };
33
- var __export = (target, all) => {
34
- for (var name in all)
35
- __defProp(target, name, { get: all[name], enumerable: true });
36
- };
37
- var __copyProps = (to, from, except, desc) => {
38
- if (from && typeof from === "object" || typeof from === "function") {
39
- for (let key of __getOwnPropNames(from))
40
- if (!__hasOwnProp.call(to, key) && key !== except)
41
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
42
- }
43
- return to;
44
- };
45
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
46
- // If the importer is in node compatibility mode or this is not an ESM
47
- // file that has been converted to a CommonJS file using a Babel-
48
- // compatible transform (i.e. "__esModule" has not been set), then set
49
- // "default" to the CommonJS "module.exports" for node compatibility.
50
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
51
- mod
52
- ));
53
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
54
- var SwipeActionItem_exports = {};
55
- __export(SwipeActionItem_exports, {
56
- default: () => SwipeActionItem_default
57
- });
58
- module.exports = __toCommonJS(SwipeActionItem_exports);
59
- var import_react = __toESM(require("react"));
60
- var import_clsx = __toESM(require("clsx"));
61
- var import_SwipeActionContext = __toESM(require("./SwipeActionContext"));
62
- var import_SwipeActionItem = require("./SwipeActionItem.css");
63
- const prefixCls = "bui-swipe-action-item";
64
- const SwipeActionItem = /* @__PURE__ */ import_react.default.forwardRef(
65
- (props, ref) => {
66
- const _a = props, {
67
- className,
68
- children,
69
- onClick,
70
- color = "primary",
71
- id = ""
72
- } = _a, others = __objRest(_a, [
73
- "className",
74
- "children",
75
- "onClick",
76
- "color",
77
- "id"
78
- ]);
79
- const { closeOnClickActionItem, close } = (0, import_react.useContext)(import_SwipeActionContext.default);
80
- const onClickHandle = (e) => {
81
- e.stopPropagation();
82
- if (closeOnClickActionItem) {
83
- close == null ? void 0 : close();
84
- }
85
- onClick == null ? void 0 : onClick(e, {
86
- color,
87
- id,
88
- text: children
89
- });
90
- };
91
- return /* @__PURE__ */ import_react.default.createElement(
92
- "div",
93
- __spreadValues({
94
- className: (0, import_clsx.default)(prefixCls, className, {
95
- [`${prefixCls}-${color}`]: color
96
- }),
97
- ref,
98
- onClick: onClickHandle
99
- }, others),
100
- children
101
- );
102
- }
103
- );
104
- SwipeActionItem.displayName = "SwipeActionItem";
105
- var SwipeActionItem_default = SwipeActionItem;
@@ -1,4 +0,0 @@
1
- export * from './SwipeAction.types';
2
- export { default } from './SwipeAction';
3
- export { default as SwipeAction } from './SwipeAction';
4
- export { default as SwipeActionItem } from './SwipeActionItem';