@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.
- package/dist/Calendar/Calendar.js +5 -1
- package/dist/Calendar/Calendar.types.d.ts +5 -0
- package/dist/Collapse/Collapse.css +0 -1
- package/dist/Collapse/Collapse.d.ts +1 -1
- package/dist/Collapse/Collapse.js +11 -8
- package/dist/Collapse/Collapse.miniapp.d.ts +5 -0
- package/dist/Collapse/Collapse.miniapp.js +177 -0
- package/dist/CollapsePanel/CollapsePanel.css +4 -2
- package/dist/DatePicker/DatePicker.d.ts +4 -0
- package/dist/DatePicker/DatePicker.js +335 -0
- package/dist/DatePicker/DatePicker.types.d.ts +36 -0
- package/dist/DatePicker/DatePicker.types.js +15 -0
- package/dist/DatePicker/constants.d.ts +9 -0
- package/dist/DatePicker/constants.js +37 -0
- package/dist/DatePicker/index.d.ts +3 -0
- package/dist/DatePicker/index.js +44 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.js +280 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
- package/dist/DesktopDatePicker/DesktopDatePicker.types.js +15 -0
- package/dist/DesktopDatePicker/deskTopPickerContainer.css +100 -0
- package/dist/DesktopDatePicker/index.css +61 -0
- package/dist/DesktopDatePicker/index.d.ts +2 -0
- package/dist/DesktopDatePicker/index.js +41 -0
- package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
- package/dist/DesktopDatePicker/useGetDatePickerContent.js +343 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +322 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +15 -0
- package/dist/DesktopDateTimePicker/index.css +66 -0
- package/dist/DesktopDateTimePicker/index.d.ts +2 -0
- package/dist/DesktopDateTimePicker/index.js +41 -0
- package/dist/DesktopPicker/DesktopPicker.d.ts +5 -0
- package/dist/DesktopPicker/DesktopPicker.js +243 -0
- package/dist/DesktopPicker/DesktopPicker.types.d.ts +61 -0
- package/dist/DesktopPicker/DesktopPicker.types.js +15 -0
- package/dist/DesktopPicker/index.css +39 -0
- package/dist/DesktopPicker/index.d.ts +2 -0
- package/dist/DesktopPicker/index.js +41 -0
- package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
- package/dist/{Tabs/utils/bound.js → DesktopPicker/utils/calcAfterMounted.js} +7 -14
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +38 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.js +288 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
- package/dist/DesktopTimePicker/DesktopTimePicker.types.js +15 -0
- package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
- package/dist/DesktopTimePicker/DesktopTimePickerList.js +111 -0
- package/dist/DesktopTimePicker/index.css +170 -0
- package/dist/DesktopTimePicker/index.d.ts +2 -0
- package/dist/DesktopTimePicker/index.js +41 -0
- package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
- package/dist/DesktopTimePicker/useGetTimePickerContent.js +249 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.js +27 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +51 -0
- package/dist/DesktopTimePicker/utils/utils.d.ts +28 -0
- package/dist/DesktopTimePicker/utils/utils.js +408 -0
- package/dist/Dialog/Dialog.types.d.ts +5 -0
- package/dist/Dialog/FunctionalDialog.js +13 -2
- package/dist/Input/Input.css +0 -2
- package/dist/Modal/Modal.miniapp.d.ts +1 -1
- package/dist/Picker/Picker.css +5 -0
- package/dist/Picker/Picker.js +27 -5
- package/dist/Picker/Picker.types.d.ts +15 -2
- package/dist/Picker/PickerPanel.css +4 -0
- package/dist/Picker/PickerPanel.js +7 -6
- package/dist/Popover/Popover.js +70 -27
- package/dist/Portal/Portal.miniapp.js +7 -4
- package/dist/ScrollView/ScrollView.js +24 -11
- package/dist/ScrollView/ScrollView.types.d.ts +0 -1
- package/dist/Select/Select.css +1 -4
- package/dist/Select/Select.js +62 -37
- package/dist/Slider/Slider.js +13 -5
- package/dist/SwipeAction/SwipeAction.css +79 -0
- package/dist/SwipeAction/SwipeAction.d.ts +5 -0
- package/dist/SwipeAction/SwipeAction.js +349 -0
- package/dist/SwipeAction/SwipeAction.types.d.ts +75 -0
- package/dist/SwipeAction/SwipeAction.types.js +15 -0
- package/dist/SwipeAction/SwipeActionContext.d.ts +4 -0
- package/dist/SwipeAction/SwipeActionContext.js +30 -0
- package/dist/SwipeAction/SwipeActionItem.css +31 -0
- package/dist/SwipeAction/SwipeActionItem.d.ts +5 -0
- package/dist/SwipeAction/SwipeActionItem.js +105 -0
- package/dist/SwipeAction/constants.d.ts +9 -0
- package/dist/SwipeAction/constants.js +39 -0
- package/dist/SwipeAction/index.d.ts +5 -0
- package/dist/SwipeAction/index.js +50 -0
- package/dist/TabBar/TabBarItem.js +2 -2
- package/dist/Tabs/Tabs.js +29 -14
- package/dist/Tabs/utils/scroll.d.ts +2 -0
- package/dist/Tabs/utils/scroll.js +55 -0
- package/dist/Toast/FunctionalToast.js +13 -2
- package/dist/Toast/Toast.css +0 -1
- package/dist/Toast/Toast.types.d.ts +5 -0
- package/dist/Tooltip/Tooltip.js +70 -27
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -1
- package/dist/locales/base.d.ts +11 -0
- package/dist/locales/en-US.js +24 -0
- package/dist/locales/zh-CN.js +24 -0
- package/dist/locales/zh-TW.js +24 -0
- package/es/Calendar/Calendar.js +5 -1
- package/es/Calendar/Calendar.types.d.ts +5 -0
- package/es/Collapse/Collapse.css +0 -1
- package/es/Collapse/Collapse.d.ts +1 -1
- package/es/Collapse/Collapse.js +11 -8
- package/es/Collapse/Collapse.miniapp.d.ts +5 -0
- package/es/Collapse/Collapse.miniapp.js +157 -0
- package/es/CollapsePanel/CollapsePanel.css +4 -2
- package/es/DatePicker/DatePicker.d.ts +4 -0
- package/es/DatePicker/DatePicker.js +308 -0
- package/es/DatePicker/DatePicker.types.d.ts +36 -0
- package/es/DatePicker/DatePicker.types.js +1 -0
- package/es/DatePicker/constants.d.ts +9 -0
- package/es/DatePicker/constants.js +14 -0
- package/es/DatePicker/index.d.ts +3 -0
- package/es/DatePicker/index.js +8 -0
- package/es/DesktopDatePicker/DesktopDatePicker.d.ts +5 -0
- package/es/DesktopDatePicker/DesktopDatePicker.js +253 -0
- package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +163 -0
- package/es/DesktopDatePicker/DesktopDatePicker.types.js +1 -0
- package/es/DesktopDatePicker/deskTopPickerContainer.css +100 -0
- package/es/DesktopDatePicker/index.css +61 -0
- package/es/DesktopDatePicker/index.d.ts +2 -0
- package/es/DesktopDatePicker/index.js +6 -0
- package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +6 -0
- package/es/DesktopDatePicker/useGetDatePickerContent.js +316 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +5 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +295 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +163 -0
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +1 -0
- package/es/DesktopDateTimePicker/index.css +66 -0
- package/es/DesktopDateTimePicker/index.d.ts +2 -0
- package/es/DesktopDateTimePicker/index.js +9 -0
- package/es/DesktopPicker/DesktopPicker.d.ts +5 -0
- package/es/DesktopPicker/DesktopPicker.js +226 -0
- package/es/DesktopPicker/DesktopPicker.types.d.ts +61 -0
- package/es/DesktopPicker/DesktopPicker.types.js +1 -0
- package/es/DesktopPicker/index.css +39 -0
- package/es/DesktopPicker/index.d.ts +2 -0
- package/es/DesktopPicker/index.js +6 -0
- package/es/DesktopPicker/utils/calcAfterMounted.d.ts +2 -0
- package/es/DesktopPicker/utils/calcAfterMounted.js +6 -0
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +2 -0
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +9 -0
- package/es/DesktopTimePicker/DesktopTimePicker.d.ts +5 -0
- package/es/DesktopTimePicker/DesktopTimePicker.js +261 -0
- package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +182 -0
- package/es/DesktopTimePicker/DesktopTimePicker.types.js +1 -0
- package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +4 -0
- package/es/DesktopTimePicker/DesktopTimePickerList.js +84 -0
- package/es/DesktopTimePicker/index.css +170 -0
- package/es/DesktopTimePicker/index.d.ts +2 -0
- package/es/DesktopTimePicker/index.js +6 -0
- package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +6 -0
- package/es/DesktopTimePicker/useGetTimePickerContent.js +226 -0
- package/es/DesktopTimePicker/utils/scrollUtil.d.ts +2 -0
- package/es/DesktopTimePicker/utils/scrollUtil.js +8 -0
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +2 -0
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +22 -0
- package/es/DesktopTimePicker/utils/utils.d.ts +28 -0
- package/es/DesktopTimePicker/utils/utils.js +365 -0
- package/es/Dialog/Dialog.types.d.ts +5 -0
- package/es/Dialog/FunctionalDialog.js +14 -3
- package/es/Input/Input.css +0 -2
- package/es/Picker/Picker.css +5 -0
- package/es/Picker/Picker.js +27 -5
- package/es/Picker/Picker.types.d.ts +15 -2
- package/es/Picker/PickerPanel.css +4 -0
- package/es/Picker/PickerPanel.js +7 -6
- package/es/Popover/Popover.js +73 -29
- package/es/Portal/Portal.miniapp.js +8 -5
- package/es/ScrollView/ScrollView.js +24 -11
- package/es/ScrollView/ScrollView.types.d.ts +0 -1
- package/es/Select/Select.css +1 -4
- package/es/Select/Select.js +62 -38
- package/es/Slider/Slider.js +16 -6
- package/es/SwipeAction/SwipeAction.css +79 -0
- package/es/SwipeAction/SwipeAction.d.ts +5 -0
- package/es/SwipeAction/SwipeAction.js +334 -0
- package/es/SwipeAction/SwipeAction.types.d.ts +75 -0
- package/es/SwipeAction/SwipeAction.types.js +1 -0
- package/es/SwipeAction/SwipeActionContext.d.ts +4 -0
- package/es/SwipeAction/SwipeActionContext.js +11 -0
- package/es/SwipeAction/SwipeActionItem.css +31 -0
- package/es/SwipeAction/SwipeActionItem.d.ts +5 -0
- package/es/SwipeAction/SwipeActionItem.js +78 -0
- package/es/SwipeAction/constants.d.ts +9 -0
- package/es/SwipeAction/constants.js +15 -0
- package/es/SwipeAction/index.d.ts +5 -0
- package/es/SwipeAction/index.js +12 -0
- package/es/TabBar/TabBarItem.js +1 -1
- package/es/Tabs/Tabs.js +29 -14
- package/es/Tabs/utils/scroll.d.ts +2 -0
- package/es/Tabs/utils/scroll.js +36 -0
- package/es/Toast/FunctionalToast.js +14 -3
- package/es/Toast/Toast.css +0 -1
- package/es/Toast/Toast.types.d.ts +5 -0
- package/es/Tooltip/Tooltip.js +73 -29
- package/es/index.d.ts +6 -0
- package/es/index.js +6 -0
- package/es/locales/base.d.ts +11 -0
- package/es/locales/en-US.js +24 -0
- package/es/locales/zh-CN.js +24 -0
- package/es/locales/zh-TW.js +24 -0
- package/package.json +5 -5
- package/dist/Tabs/utils/bound.d.ts +0 -1
- package/es/Tabs/utils/bound.d.ts +0 -1
- package/es/Tabs/utils/bound.js +0 -13
package/dist/Popover/Popover.js
CHANGED
|
@@ -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 [
|
|
100
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
190
|
-
|
|
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.
|
|
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
|
-
|
|
70
|
+
root = view;
|
|
71
|
+
} else {
|
|
72
|
+
root = portalWrapperElement;
|
|
69
73
|
}
|
|
70
|
-
return portalWrapperElement;
|
|
71
74
|
}
|
|
72
|
-
|
|
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(
|
|
88
|
-
|
|
89
|
-
|
|
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(
|
|
99
|
-
|
|
100
|
-
|
|
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 自身的滚动。
|
package/dist/Select/Select.css
CHANGED
|
@@ -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 {
|
package/dist/Select/Select.js
CHANGED
|
@@ -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
|
|
127
|
-
const
|
|
128
|
-
const updateOptionStyle = (0,
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
}
|
|
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
|
-
|
|
150
|
-
|
|
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",
|
|
202
|
+
window.addEventListener("resize", resizeCb);
|
|
184
203
|
return () => {
|
|
185
|
-
window.removeEventListener("resize",
|
|
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:
|
|
204
|
-
exit:
|
|
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
|
-
|
|
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:
|
|
228
|
-
exit:
|
|
246
|
+
enter: 167,
|
|
247
|
+
exit: 167
|
|
229
248
|
}
|
|
230
249
|
},
|
|
231
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
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
|
-
|
|
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,
|
package/dist/Slider/Slider.js
CHANGED
|
@@ -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
|
-
|
|
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;
|