@bifrostui/react 2.0.0-beta.10 → 2.0.0-beta.11
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/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/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
|
@@ -50,7 +50,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
import React, { useCallback, useEffect, useState } from "react";
|
|
53
|
-
import {
|
|
53
|
+
import { getRootContainer, render, unmount } from "@bifrostui/utils";
|
|
54
54
|
import Popup from "./Dialog";
|
|
55
55
|
const { isValidElement, Component } = React;
|
|
56
56
|
const formatProps = (props) => {
|
|
@@ -61,10 +61,21 @@ const formatProps = (props) => {
|
|
|
61
61
|
};
|
|
62
62
|
const DialogGenerator = (options) => {
|
|
63
63
|
const rootWrapper = document.createElement("div");
|
|
64
|
-
const rootElement =
|
|
64
|
+
const rootElement = getRootContainer(options == null ? void 0 : options.container);
|
|
65
65
|
rootElement.appendChild(rootWrapper);
|
|
66
66
|
const DialogComponent = () => {
|
|
67
|
-
const _a = options, {
|
|
67
|
+
const _a = options, {
|
|
68
|
+
onConfirm,
|
|
69
|
+
onCancel,
|
|
70
|
+
ref,
|
|
71
|
+
container: container
|
|
72
|
+
} = _a, others = __objRest(_a, [
|
|
73
|
+
"onConfirm",
|
|
74
|
+
"onCancel",
|
|
75
|
+
"ref",
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
77
|
+
"container"
|
|
78
|
+
]);
|
|
68
79
|
const [visible, setVisible] = useState(false);
|
|
69
80
|
const close = useCallback(() => {
|
|
70
81
|
setVisible(false);
|
package/es/Input/Input.css
CHANGED
package/es/Picker/Picker.css
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
--panel-container-height: var(--bui-picker-panel-height, 260px);
|
|
9
9
|
--indicator-top: var(--bui-picker-indicator-top, 108px);
|
|
10
10
|
--option-height: var(--bui-picker-option-height, 36px);
|
|
11
|
+
--bui-picker-confirm-disabled-opacity: 0.38;
|
|
11
12
|
font-family: var(--bui-font-family);
|
|
12
13
|
}
|
|
13
14
|
.bui-picker .bui-drawer-content {
|
|
@@ -41,6 +42,10 @@
|
|
|
41
42
|
line-height: var(--confirm-line-height);
|
|
42
43
|
color: var(--bui-color-primary);
|
|
43
44
|
}
|
|
45
|
+
.bui-picker-confirm-disabled {
|
|
46
|
+
color: var(--bui-color-fg-default);
|
|
47
|
+
opacity: var(--bui-picker-confirm-disabled-opacity);
|
|
48
|
+
}
|
|
44
49
|
.bui-picker-container {
|
|
45
50
|
width: 100%;
|
|
46
51
|
height: var(--panel-container-height);
|
package/es/Picker/Picker.js
CHANGED
|
@@ -37,6 +37,12 @@ import { useLocaleText } from "../locales";
|
|
|
37
37
|
import { formatOptions, pickerPanelType, safeData } from "./utils";
|
|
38
38
|
import "./Picker.css";
|
|
39
39
|
const prefixCls = "bui-picker";
|
|
40
|
+
const checkDisabled = (values, columns) => values.find(
|
|
41
|
+
(value, index) => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
return (_b = (_a = columns == null ? void 0 : columns[index]) == null ? void 0 : _a.find((column) => (column == null ? void 0 : column.value) === value)) == null ? void 0 : _b.disabled;
|
|
44
|
+
}
|
|
45
|
+
);
|
|
40
46
|
const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
41
47
|
const _a = props, {
|
|
42
48
|
className,
|
|
@@ -44,6 +50,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
44
50
|
title,
|
|
45
51
|
options = [],
|
|
46
52
|
value,
|
|
53
|
+
confirmText: propConfirmText,
|
|
54
|
+
cancelText: propCancelText,
|
|
47
55
|
contentProps,
|
|
48
56
|
onConfirm,
|
|
49
57
|
onOptionChange,
|
|
@@ -55,6 +63,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
55
63
|
"title",
|
|
56
64
|
"options",
|
|
57
65
|
"value",
|
|
66
|
+
"confirmText",
|
|
67
|
+
"cancelText",
|
|
58
68
|
"contentProps",
|
|
59
69
|
"onConfirm",
|
|
60
70
|
"onOptionChange",
|
|
@@ -66,6 +76,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
66
76
|
const [columns, setColumns] = useState([]);
|
|
67
77
|
const [internalValue, setInternalValue] = useState([]);
|
|
68
78
|
const { cancel: cancelText, confirm: confirmText } = useLocaleText("picker");
|
|
79
|
+
const disabled = checkDisabled(internalValue, columns);
|
|
69
80
|
useEffect(() => {
|
|
70
81
|
if (!open)
|
|
71
82
|
return;
|
|
@@ -88,7 +99,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
88
99
|
}, [value, options]);
|
|
89
100
|
const confirm = (e) => {
|
|
90
101
|
const isMoving = rollerRefs.current.some((roller) => roller == null ? void 0 : roller.isMoving);
|
|
91
|
-
if (isMoving)
|
|
102
|
+
if (isMoving || disabled)
|
|
92
103
|
return;
|
|
93
104
|
const { safeValue } = safeData({
|
|
94
105
|
value: internalValue,
|
|
@@ -147,7 +158,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
147
158
|
onOptionChange == null ? void 0 : onOptionChange(e, {
|
|
148
159
|
value: conbineValues,
|
|
149
160
|
options: formatted,
|
|
150
|
-
currentOption: columnOption
|
|
161
|
+
currentOption: columnOption,
|
|
162
|
+
columnIndex
|
|
151
163
|
});
|
|
152
164
|
} else {
|
|
153
165
|
const result = [...internalValue];
|
|
@@ -156,7 +168,8 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
156
168
|
onOptionChange == null ? void 0 : onOptionChange(e, {
|
|
157
169
|
value: result,
|
|
158
170
|
options,
|
|
159
|
-
currentOption: columnOption
|
|
171
|
+
currentOption: columnOption,
|
|
172
|
+
columnIndex
|
|
160
173
|
});
|
|
161
174
|
}
|
|
162
175
|
}
|
|
@@ -198,7 +211,16 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
198
211
|
__spreadProps(__spreadValues({}, contentProps), {
|
|
199
212
|
className: clsx(`${prefixCls}-content`, contentProps == null ? void 0 : contentProps.className)
|
|
200
213
|
}),
|
|
201
|
-
/* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel }, cancelText), title && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-title` }, title), /* @__PURE__ */ React.createElement(
|
|
214
|
+
/* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-header` }, /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-cancel`, onClick: cancel }, propCancelText || cancelText), title && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-title` }, title), /* @__PURE__ */ React.createElement(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
className: clsx(`${prefixCls}-confirm`, {
|
|
218
|
+
[`${prefixCls}-confirm-disabled`]: disabled
|
|
219
|
+
}),
|
|
220
|
+
onClick: confirm
|
|
221
|
+
},
|
|
222
|
+
propConfirmText || confirmText
|
|
223
|
+
)),
|
|
202
224
|
/* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-container` }, columns.map((column, index) => /* @__PURE__ */ React.createElement(
|
|
203
225
|
PickerPanel,
|
|
204
226
|
{
|
|
@@ -206,7 +228,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
206
228
|
key: index,
|
|
207
229
|
options: column,
|
|
208
230
|
columnIndex: index,
|
|
209
|
-
|
|
231
|
+
value: internalValue == null ? void 0 : internalValue[index],
|
|
210
232
|
onSelect: handleSelect,
|
|
211
233
|
pickerStyle: others == null ? void 0 : others.style
|
|
212
234
|
}
|
|
@@ -10,6 +10,10 @@ export interface IPickerOptionItem {
|
|
|
10
10
|
* 选项对应唯一的值
|
|
11
11
|
*/
|
|
12
12
|
value: string | number;
|
|
13
|
+
/**
|
|
14
|
+
* 是否禁用
|
|
15
|
+
*/
|
|
16
|
+
disabled?: boolean;
|
|
13
17
|
}
|
|
14
18
|
export type ICascadePickerChildOptionItem = IPickerOptionItem & {
|
|
15
19
|
/**
|
|
@@ -34,6 +38,14 @@ export type PickerProps<D extends React.ElementType = 'div', P = DrawerProps> =
|
|
|
34
38
|
* 标题
|
|
35
39
|
*/
|
|
36
40
|
title?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 确认文本内容
|
|
43
|
+
*/
|
|
44
|
+
confirmText?: string;
|
|
45
|
+
/**
|
|
46
|
+
* 取消文本内容
|
|
47
|
+
*/
|
|
48
|
+
cancelText?: string;
|
|
37
49
|
/**
|
|
38
50
|
* 列表数据
|
|
39
51
|
* @default []
|
|
@@ -61,6 +73,7 @@ export type PickerProps<D extends React.ElementType = 'div', P = DrawerProps> =
|
|
|
61
73
|
value: (string | number)[];
|
|
62
74
|
options: ICascadePickerChildOptionItem[][];
|
|
63
75
|
currentOption: ICascadePickerChildOptionItem;
|
|
76
|
+
columnIndex: number;
|
|
64
77
|
}) => void;
|
|
65
78
|
/**
|
|
66
79
|
* 点击取消按钮时候回调
|
|
@@ -85,9 +98,9 @@ export type PickerPanelProps<D extends React.ElementType = 'div', P = {}> = Over
|
|
|
85
98
|
*/
|
|
86
99
|
options?: ICascadePickerChildOptionItem[];
|
|
87
100
|
/**
|
|
88
|
-
*
|
|
101
|
+
* 选中值
|
|
89
102
|
*/
|
|
90
|
-
|
|
103
|
+
value?: string | number;
|
|
91
104
|
/**
|
|
92
105
|
* 列索引
|
|
93
106
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.bui-picker-panel {
|
|
2
|
+
--bui-picker-option-disabled-opacity: 0.38;
|
|
2
3
|
flex: 1;
|
|
3
4
|
flex-shrink: 0;
|
|
4
5
|
position: relative;
|
|
@@ -56,6 +57,9 @@
|
|
|
56
57
|
white-space: nowrap;
|
|
57
58
|
width: 100%;
|
|
58
59
|
}
|
|
60
|
+
.bui-picker-panel-option-disabled {
|
|
61
|
+
opacity: var(--bui-picker-option-disabled-opacity);
|
|
62
|
+
}
|
|
59
63
|
.bui-picker-panel-option-hidden {
|
|
60
64
|
visibility: hidden;
|
|
61
65
|
opacity: 0;
|
package/es/Picker/PickerPanel.js
CHANGED
|
@@ -36,13 +36,13 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
36
36
|
var _b;
|
|
37
37
|
const _a = props, {
|
|
38
38
|
options = [],
|
|
39
|
-
|
|
39
|
+
value,
|
|
40
40
|
onSelect,
|
|
41
41
|
columnIndex,
|
|
42
42
|
pickerStyle
|
|
43
43
|
} = _a, others = __objRest(_a, [
|
|
44
44
|
"options",
|
|
45
|
-
"
|
|
45
|
+
"value",
|
|
46
46
|
"onSelect",
|
|
47
47
|
"columnIndex",
|
|
48
48
|
"pickerStyle"
|
|
@@ -72,9 +72,9 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
72
72
|
useTouchEmulator(PickerPanelRef.current);
|
|
73
73
|
const updateSelect = () => {
|
|
74
74
|
let index = -1;
|
|
75
|
-
if (
|
|
75
|
+
if (value) {
|
|
76
76
|
options.some((item, idx) => {
|
|
77
|
-
if (item.value ===
|
|
77
|
+
if (item.value === value) {
|
|
78
78
|
index = idx;
|
|
79
79
|
return true;
|
|
80
80
|
}
|
|
@@ -92,7 +92,7 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
92
92
|
return () => {
|
|
93
93
|
clearTimeout(timer);
|
|
94
94
|
};
|
|
95
|
-
}, [options]);
|
|
95
|
+
}, [options, value]);
|
|
96
96
|
const setTransform = (type, deg, time = DEFAULT_DURATION, translateY = 0) => {
|
|
97
97
|
let nTime = time;
|
|
98
98
|
if (type !== TOUCH_END) {
|
|
@@ -225,7 +225,8 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
225
225
|
"div",
|
|
226
226
|
{
|
|
227
227
|
className: clsx(`${prefixCls}-option`, {
|
|
228
|
-
[`${prefixCls}-option-hidden`]: i + 1 <= currIndex - 8 || i + 1 >= currIndex + 8
|
|
228
|
+
[`${prefixCls}-option-hidden`]: i + 1 <= currIndex - 8 || i + 1 >= currIndex + 8,
|
|
229
|
+
[`${prefixCls}-option-disabled`]: item == null ? void 0 : item.disabled
|
|
229
230
|
}),
|
|
230
231
|
key: `${item == null ? void 0 : item.value}-${i}`,
|
|
231
232
|
style: {
|
package/es/Popover/Popover.js
CHANGED
|
@@ -26,14 +26,35 @@ var __objRest = (source, exclude) => {
|
|
|
26
26
|
}
|
|
27
27
|
return target;
|
|
28
28
|
};
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
29
49
|
import clsx from "clsx";
|
|
30
50
|
import React, { useState, useRef, useEffect } from "react";
|
|
31
51
|
import {
|
|
32
52
|
getStylesAndLocation,
|
|
33
53
|
triggerEventTransform,
|
|
34
54
|
parsePlacement,
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
throttle,
|
|
56
|
+
useForkRef,
|
|
57
|
+
isMini
|
|
37
58
|
} from "@bifrostui/utils";
|
|
38
59
|
import Portal from "../Portal";
|
|
39
60
|
import "./Popover.css";
|
|
@@ -49,9 +70,9 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
49
70
|
offsetSpacing = 0,
|
|
50
71
|
placement = "top",
|
|
51
72
|
trigger = "click",
|
|
52
|
-
onOpenChange,
|
|
53
73
|
open,
|
|
54
|
-
hideArrow
|
|
74
|
+
hideArrow,
|
|
75
|
+
onOpenChange
|
|
55
76
|
} = _a, others = __objRest(_a, [
|
|
56
77
|
"className",
|
|
57
78
|
"style",
|
|
@@ -62,9 +83,9 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
62
83
|
"offsetSpacing",
|
|
63
84
|
"placement",
|
|
64
85
|
"trigger",
|
|
65
|
-
"onOpenChange",
|
|
66
86
|
"open",
|
|
67
|
-
"hideArrow"
|
|
87
|
+
"hideArrow",
|
|
88
|
+
"onOpenChange"
|
|
68
89
|
]);
|
|
69
90
|
const controlByUser = typeof open !== "undefined";
|
|
70
91
|
const { direction, location = "center" } = parsePlacement(placement);
|
|
@@ -72,11 +93,18 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
72
93
|
const [openStatus, setOpenStatus] = useState(defaultOpen);
|
|
73
94
|
const [arrowDirection, setArrowDirection] = useState(direction);
|
|
74
95
|
const [arrowLocation, setArrowLocation] = useState(location);
|
|
75
|
-
const [
|
|
76
|
-
const
|
|
96
|
+
const [toolStyles, setToolStyles] = useState({});
|
|
97
|
+
const tipRef = useRef(null);
|
|
98
|
+
const nodeRef = useForkRef(ref, tipRef);
|
|
99
|
+
const clearRef = (status) => {
|
|
100
|
+
if (status === false) {
|
|
101
|
+
tipRef.current = null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
77
104
|
const changeOpenStatus = (event, status) => {
|
|
78
105
|
if (controlByUser)
|
|
79
106
|
return;
|
|
107
|
+
clearRef(status);
|
|
80
108
|
setOpenStatus(status);
|
|
81
109
|
onOpenChange == null ? void 0 : onOpenChange(event, { open: status });
|
|
82
110
|
};
|
|
@@ -95,23 +123,33 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
95
123
|
if (!controlByUser)
|
|
96
124
|
return;
|
|
97
125
|
setOpenStatus(open);
|
|
126
|
+
clearRef(open);
|
|
98
127
|
}, [open]);
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (!openStatus) {
|
|
130
|
+
setToolStyles({
|
|
131
|
+
visibility: "hidden"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}, [openStatus]);
|
|
99
135
|
const clickEventHandler = (event) => {
|
|
100
136
|
if (trigger === "hover" || (trigger == null ? void 0 : trigger.length) === 1 && (trigger == null ? void 0 : trigger[0]) === "hover")
|
|
101
137
|
return;
|
|
102
138
|
hidePopover(event);
|
|
103
139
|
};
|
|
104
|
-
const onRootElementMouted = throttle(() => {
|
|
140
|
+
const onRootElementMouted = throttle(() => __async(void 0, null, function* () {
|
|
141
|
+
if (!tipRef.current)
|
|
142
|
+
return;
|
|
105
143
|
const {
|
|
106
144
|
direction: newParsedDirection,
|
|
107
145
|
location: newParsedLocation = "center"
|
|
108
146
|
} = parsePlacement(placement);
|
|
109
|
-
const result = getStylesAndLocation({
|
|
147
|
+
const result = yield getStylesAndLocation({
|
|
110
148
|
childrenRef,
|
|
111
149
|
arrowDirection: newParsedDirection,
|
|
112
150
|
arrowLocation: newParsedLocation,
|
|
113
151
|
offsetSpacing,
|
|
114
|
-
|
|
152
|
+
tipRef
|
|
115
153
|
});
|
|
116
154
|
if (!result)
|
|
117
155
|
return;
|
|
@@ -122,26 +160,32 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
122
160
|
if (newArrowLocation !== arrowLocation) {
|
|
123
161
|
setArrowLocation(newArrowLocation);
|
|
124
162
|
}
|
|
125
|
-
|
|
126
|
-
}, 100);
|
|
127
|
-
const bindEvent = () => {
|
|
128
|
-
if (!controlByUser) {
|
|
129
|
-
document.addEventListener("click", clickEventHandler);
|
|
130
|
-
}
|
|
131
|
-
window.addEventListener("resize", onRootElementMouted);
|
|
132
|
-
};
|
|
133
|
-
const unbindEvent = () => {
|
|
134
|
-
if (!controlByUser) {
|
|
135
|
-
document.removeEventListener("click", clickEventHandler);
|
|
136
|
-
}
|
|
137
|
-
window.removeEventListener("resize", onRootElementMouted);
|
|
138
|
-
};
|
|
163
|
+
setToolStyles(styles);
|
|
164
|
+
}), 100);
|
|
139
165
|
useEffect(() => {
|
|
166
|
+
const bindEvent = () => {
|
|
167
|
+
if (!tipRef.current)
|
|
168
|
+
return;
|
|
169
|
+
if (!controlByUser) {
|
|
170
|
+
document.addEventListener("click", clickEventHandler);
|
|
171
|
+
}
|
|
172
|
+
if (!isMini) {
|
|
173
|
+
window.addEventListener("resize", onRootElementMouted);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const unbindEvent = () => {
|
|
177
|
+
if (!controlByUser) {
|
|
178
|
+
document.removeEventListener("click", clickEventHandler);
|
|
179
|
+
}
|
|
180
|
+
if (!isMini) {
|
|
181
|
+
window.removeEventListener("resize", onRootElementMouted);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
140
184
|
bindEvent();
|
|
141
185
|
return () => {
|
|
142
186
|
unbindEvent();
|
|
143
187
|
};
|
|
144
|
-
}, []);
|
|
188
|
+
}, [openStatus]);
|
|
145
189
|
if (!title && !content)
|
|
146
190
|
return null;
|
|
147
191
|
let triggerEventOption;
|
|
@@ -156,14 +200,14 @@ const Popover = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
156
200
|
const childrenOptions = __spreadValues({
|
|
157
201
|
ref: childrenRef
|
|
158
202
|
}, triggerEventOption);
|
|
159
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, open || openStatus ? /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted
|
|
203
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, open || openStatus ? /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted }, /* @__PURE__ */ React.createElement(
|
|
160
204
|
"div",
|
|
161
205
|
__spreadValues({
|
|
162
206
|
className: clsx(prefixCls, className, `popover-${arrowDirection}`, {
|
|
163
207
|
"bui-popover-arrow-hide": hideArrow
|
|
164
208
|
}),
|
|
165
|
-
|
|
166
|
-
|
|
209
|
+
style: __spreadValues(__spreadValues({}, style), toolStyles),
|
|
210
|
+
ref: nodeRef
|
|
167
211
|
}, others),
|
|
168
212
|
!hideArrow ? /* @__PURE__ */ React.createElement(
|
|
169
213
|
"div",
|
|
@@ -18,11 +18,13 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import Taro from "@tarojs/taro";
|
|
21
|
-
import React, { forwardRef,
|
|
21
|
+
import React, { forwardRef, useEffect, useState } from "react";
|
|
22
22
|
import PortalCore from "./PortalCore";
|
|
23
23
|
const Portal = forwardRef((props, ref) => {
|
|
24
24
|
const { disablePortal } = props;
|
|
25
|
-
const rootWrapperElement =
|
|
25
|
+
const [rootWrapperElement, setRootWrapperElement] = useState();
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
let root;
|
|
26
28
|
if (!disablePortal) {
|
|
27
29
|
const currentPages = Taro.getCurrentPages() || [];
|
|
28
30
|
const currentPage = currentPages[currentPages.length - 1];
|
|
@@ -34,11 +36,12 @@ const Portal = forwardRef((props, ref) => {
|
|
|
34
36
|
const view = document.createElement("view");
|
|
35
37
|
view.id = portalId;
|
|
36
38
|
rootElement == null ? void 0 : rootElement.appendChild(view);
|
|
37
|
-
|
|
39
|
+
root = view;
|
|
40
|
+
} else {
|
|
41
|
+
root = portalWrapperElement;
|
|
38
42
|
}
|
|
39
|
-
return portalWrapperElement;
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
setRootWrapperElement(root);
|
|
42
45
|
}, []);
|
|
43
46
|
return /* @__PURE__ */ React.createElement(PortalCore, __spreadProps(__spreadValues({}, props), { ref, rootElement: rootWrapperElement }));
|
|
44
47
|
});
|
|
@@ -2,12 +2,14 @@ import { useForkRef } from "@bifrostui/utils";
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import React, { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
4
4
|
import "./ScrollView.css";
|
|
5
|
-
function easeOutScroll(from, to, callback) {
|
|
5
|
+
function easeOutScroll(from, to, callback, dur) {
|
|
6
|
+
if (dur <= 0) {
|
|
7
|
+
dur = 500;
|
|
8
|
+
}
|
|
6
9
|
if (from === to || typeof from !== "number") {
|
|
7
10
|
return;
|
|
8
11
|
}
|
|
9
12
|
const change = to - from;
|
|
10
|
-
const dur = 500;
|
|
11
13
|
const sTime = +/* @__PURE__ */ new Date();
|
|
12
14
|
function linear(t, b, c, d) {
|
|
13
15
|
return c * t / d + b;
|
|
@@ -42,7 +44,8 @@ const ScrollView = forwardRef(
|
|
|
42
44
|
scrollIntoView,
|
|
43
45
|
onTouchMove: propsOnTouchMove,
|
|
44
46
|
scrollIntoViewAlignment,
|
|
45
|
-
children
|
|
47
|
+
children,
|
|
48
|
+
scrollAnimationDuration = 500
|
|
46
49
|
} = props;
|
|
47
50
|
const container = useRef(null);
|
|
48
51
|
const handleRef = useForkRef(ref, container);
|
|
@@ -52,10 +55,15 @@ const ScrollView = forwardRef(
|
|
|
52
55
|
if (top === void 0)
|
|
53
56
|
return;
|
|
54
57
|
if (isAnimation) {
|
|
55
|
-
easeOutScroll(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
easeOutScroll(
|
|
59
|
+
container.current.scrollTop,
|
|
60
|
+
top,
|
|
61
|
+
(pos) => {
|
|
62
|
+
if (container.current)
|
|
63
|
+
container.current.scrollTop = pos;
|
|
64
|
+
},
|
|
65
|
+
scrollAnimationDuration
|
|
66
|
+
);
|
|
59
67
|
} else if (container.current)
|
|
60
68
|
container.current.scrollTop = top;
|
|
61
69
|
}, []);
|
|
@@ -63,10 +71,15 @@ const ScrollView = forwardRef(
|
|
|
63
71
|
if (left === void 0)
|
|
64
72
|
return;
|
|
65
73
|
if (isAnimation) {
|
|
66
|
-
easeOutScroll(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
easeOutScroll(
|
|
75
|
+
container.current.scrollLeft,
|
|
76
|
+
left,
|
|
77
|
+
(pos) => {
|
|
78
|
+
if (container.current)
|
|
79
|
+
container.current.scrollLeft = pos;
|
|
80
|
+
},
|
|
81
|
+
scrollAnimationDuration
|
|
82
|
+
);
|
|
70
83
|
} else if (container.current)
|
|
71
84
|
container.current.scrollLeft = left;
|
|
72
85
|
}, []);
|
|
@@ -138,7 +138,6 @@ export type ScrollViewProps<D extends React.ElementType = 'div', P = {}> = Overr
|
|
|
138
138
|
*/
|
|
139
139
|
fastDeceleration?: boolean;
|
|
140
140
|
/** 当 scroll-with-animation设置为 true 时,可以设置 scroll-animation-duration 来控制动画的执行时间,单位 ms。
|
|
141
|
-
* 仅小程序可用
|
|
142
141
|
*/
|
|
143
142
|
scrollAnimationDuration?: number;
|
|
144
143
|
/** 纵向滚动时,当滚动到顶部或底部时,强制禁止触发页面滚动,仍然只触发 scroll-view 自身的滚动。
|
package/es/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 {
|