@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.
- package/dist/Calendar/Calendar.js +1 -5
- package/dist/Calendar/Calendar.types.d.ts +0 -5
- package/dist/Collapse/Collapse.css +1 -0
- package/dist/Collapse/Collapse.d.ts +1 -1
- package/dist/Collapse/Collapse.js +8 -11
- package/dist/CollapsePanel/CollapsePanel.css +2 -4
- package/dist/Dialog/FunctionalDialog.js +1 -1
- package/dist/Modal/Modal.miniapp.d.ts +1 -1
- package/dist/Picker/Picker.css +0 -5
- package/dist/Picker/Picker.js +5 -27
- package/dist/Picker/Picker.types.d.ts +2 -15
- package/dist/Picker/PickerPanel.css +0 -4
- package/dist/Picker/PickerPanel.js +6 -7
- package/dist/Popover/Popover.js +27 -70
- package/dist/Portal/Portal.miniapp.js +4 -7
- package/dist/ScrollView/ScrollView.js +11 -24
- package/dist/ScrollView/ScrollView.types.d.ts +1 -0
- package/dist/Select/Select.css +4 -1
- package/dist/Select/Select.js +40 -63
- package/dist/Slider/Slider.js +5 -13
- package/dist/Tabs/Tab.js +4 -13
- package/dist/Tabs/Tabs.js +15 -30
- package/dist/Tabs/utils/bound.d.ts +1 -0
- package/dist/{DesktopPicker/utils/calcAfterMounted.js → Tabs/utils/bound.js} +14 -7
- package/dist/Toast/FunctionalToast.js +1 -1
- package/dist/Toast/Toast.css +1 -0
- package/dist/Tooltip/Tooltip.js +27 -70
- package/dist/index.d.ts +0 -6
- package/dist/index.js +1 -13
- package/dist/locales/base.d.ts +0 -11
- package/dist/locales/en-US.js +0 -24
- package/dist/locales/zh-CN.js +0 -24
- package/dist/locales/zh-TW.js +0 -24
- package/es/Calendar/Calendar.js +1 -5
- package/es/Calendar/Calendar.types.d.ts +0 -5
- package/es/Collapse/Collapse.css +1 -0
- package/es/Collapse/Collapse.d.ts +1 -1
- package/es/Collapse/Collapse.js +8 -11
- package/es/CollapsePanel/CollapsePanel.css +2 -4
- package/es/Dialog/FunctionalDialog.js +2 -2
- package/es/Picker/Picker.css +0 -5
- package/es/Picker/Picker.js +5 -27
- package/es/Picker/Picker.types.d.ts +2 -15
- package/es/Picker/PickerPanel.css +0 -4
- package/es/Picker/PickerPanel.js +6 -7
- package/es/Popover/Popover.js +29 -73
- package/es/Portal/Portal.miniapp.js +5 -8
- package/es/ScrollView/ScrollView.js +11 -24
- package/es/ScrollView/ScrollView.types.d.ts +1 -0
- package/es/Select/Select.css +4 -1
- package/es/Select/Select.js +41 -63
- package/es/Slider/Slider.js +6 -16
- package/es/Tabs/Tab.js +4 -13
- package/es/Tabs/Tabs.js +15 -30
- package/es/Tabs/utils/bound.d.ts +1 -0
- package/es/Tabs/utils/bound.js +13 -0
- package/es/Toast/FunctionalToast.js +2 -2
- package/es/Toast/Toast.css +1 -0
- package/es/Tooltip/Tooltip.js +29 -73
- package/es/index.d.ts +0 -6
- package/es/index.js +0 -6
- package/es/locales/base.d.ts +0 -11
- package/es/locales/en-US.js +0 -24
- package/es/locales/zh-CN.js +0 -24
- package/es/locales/zh-TW.js +0 -24
- package/package.json +5 -5
- package/dist/Collapse/Collapse.miniapp.d.ts +0 -5
- package/dist/Collapse/Collapse.miniapp.js +0 -177
- package/dist/DatePicker/DatePicker.d.ts +0 -4
- package/dist/DatePicker/DatePicker.js +0 -335
- package/dist/DatePicker/DatePicker.types.d.ts +0 -43
- package/dist/DatePicker/DatePicker.types.js +0 -35
- package/dist/DatePicker/index.d.ts +0 -2
- package/dist/DatePicker/index.js +0 -41
- package/dist/DesktopDatePicker/DesktopDatePicker.d.ts +0 -5
- package/dist/DesktopDatePicker/DesktopDatePicker.js +0 -280
- package/dist/DesktopDatePicker/DesktopDatePicker.types.d.ts +0 -163
- package/dist/DesktopDatePicker/DesktopDatePicker.types.js +0 -15
- package/dist/DesktopDatePicker/deskTopPickerContainer.css +0 -100
- package/dist/DesktopDatePicker/index.css +0 -61
- package/dist/DesktopDatePicker/index.d.ts +0 -2
- package/dist/DesktopDatePicker/index.js +0 -41
- package/dist/DesktopDatePicker/useGetDatePickerContent.d.ts +0 -6
- package/dist/DesktopDatePicker/useGetDatePickerContent.js +0 -343
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +0 -5
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -322
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +0 -163
- package/dist/DesktopDateTimePicker/DesktopDateTimePicker.types.js +0 -15
- package/dist/DesktopDateTimePicker/index.css +0 -66
- package/dist/DesktopDateTimePicker/index.d.ts +0 -2
- package/dist/DesktopDateTimePicker/index.js +0 -41
- package/dist/DesktopPicker/DesktopPicker.d.ts +0 -5
- package/dist/DesktopPicker/DesktopPicker.js +0 -238
- package/dist/DesktopPicker/DesktopPicker.types.d.ts +0 -57
- package/dist/DesktopPicker/DesktopPicker.types.js +0 -15
- package/dist/DesktopPicker/index.css +0 -37
- package/dist/DesktopPicker/index.d.ts +0 -2
- package/dist/DesktopPicker/index.js +0 -41
- package/dist/DesktopPicker/utils/calcAfterMounted.d.ts +0 -2
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +0 -2
- package/dist/DesktopPicker/utils/calcAfterMounted.miniapp.js +0 -38
- package/dist/DesktopTimePicker/DesktopTimePicker.d.ts +0 -5
- package/dist/DesktopTimePicker/DesktopTimePicker.js +0 -288
- package/dist/DesktopTimePicker/DesktopTimePicker.types.d.ts +0 -182
- package/dist/DesktopTimePicker/DesktopTimePicker.types.js +0 -15
- package/dist/DesktopTimePicker/DesktopTimePickerList.d.ts +0 -4
- package/dist/DesktopTimePicker/DesktopTimePickerList.js +0 -111
- package/dist/DesktopTimePicker/index.css +0 -170
- package/dist/DesktopTimePicker/index.d.ts +0 -2
- package/dist/DesktopTimePicker/index.js +0 -41
- package/dist/DesktopTimePicker/useGetTimePickerContent.d.ts +0 -6
- package/dist/DesktopTimePicker/useGetTimePickerContent.js +0 -246
- package/dist/DesktopTimePicker/utils/scrollUtil.d.ts +0 -2
- package/dist/DesktopTimePicker/utils/scrollUtil.js +0 -27
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +0 -2
- package/dist/DesktopTimePicker/utils/scrollUtil.miniapp.js +0 -51
- package/dist/DesktopTimePicker/utils/utils.d.ts +0 -28
- package/dist/DesktopTimePicker/utils/utils.js +0 -408
- package/dist/SwipeAction/SwipeAction.css +0 -79
- package/dist/SwipeAction/SwipeAction.d.ts +0 -5
- package/dist/SwipeAction/SwipeAction.js +0 -349
- package/dist/SwipeAction/SwipeAction.types.d.ts +0 -83
- package/dist/SwipeAction/SwipeAction.types.js +0 -39
- package/dist/SwipeAction/SwipeActionContext.d.ts +0 -4
- package/dist/SwipeAction/SwipeActionContext.js +0 -30
- package/dist/SwipeAction/SwipeActionItem.css +0 -31
- package/dist/SwipeAction/SwipeActionItem.d.ts +0 -5
- package/dist/SwipeAction/SwipeActionItem.js +0 -105
- package/dist/SwipeAction/index.d.ts +0 -4
- package/dist/SwipeAction/index.js +0 -45
- package/dist/Tabs/utils/scroll.d.ts +0 -2
- package/dist/Tabs/utils/scroll.js +0 -55
- package/es/Collapse/Collapse.miniapp.d.ts +0 -5
- package/es/Collapse/Collapse.miniapp.js +0 -157
- package/es/DatePicker/DatePicker.d.ts +0 -4
- package/es/DatePicker/DatePicker.js +0 -310
- package/es/DatePicker/DatePicker.types.d.ts +0 -43
- package/es/DatePicker/DatePicker.types.js +0 -1
- package/es/DatePicker/index.d.ts +0 -2
- package/es/DatePicker/index.js +0 -6
- package/es/DesktopDatePicker/DesktopDatePicker.d.ts +0 -5
- package/es/DesktopDatePicker/DesktopDatePicker.js +0 -253
- package/es/DesktopDatePicker/DesktopDatePicker.types.d.ts +0 -163
- package/es/DesktopDatePicker/DesktopDatePicker.types.js +0 -1
- package/es/DesktopDatePicker/deskTopPickerContainer.css +0 -100
- package/es/DesktopDatePicker/index.css +0 -61
- package/es/DesktopDatePicker/index.d.ts +0 -2
- package/es/DesktopDatePicker/index.js +0 -6
- package/es/DesktopDatePicker/useGetDatePickerContent.d.ts +0 -6
- package/es/DesktopDatePicker/useGetDatePickerContent.js +0 -316
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.d.ts +0 -5
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.js +0 -295
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +0 -163
- package/es/DesktopDateTimePicker/DesktopDateTimePicker.types.js +0 -1
- package/es/DesktopDateTimePicker/index.css +0 -66
- package/es/DesktopDateTimePicker/index.d.ts +0 -2
- package/es/DesktopDateTimePicker/index.js +0 -9
- package/es/DesktopPicker/DesktopPicker.d.ts +0 -5
- package/es/DesktopPicker/DesktopPicker.js +0 -221
- package/es/DesktopPicker/DesktopPicker.types.d.ts +0 -57
- package/es/DesktopPicker/DesktopPicker.types.js +0 -1
- package/es/DesktopPicker/index.css +0 -37
- package/es/DesktopPicker/index.d.ts +0 -2
- package/es/DesktopPicker/index.js +0 -6
- package/es/DesktopPicker/utils/calcAfterMounted.d.ts +0 -2
- package/es/DesktopPicker/utils/calcAfterMounted.js +0 -6
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.d.ts +0 -2
- package/es/DesktopPicker/utils/calcAfterMounted.miniapp.js +0 -9
- package/es/DesktopTimePicker/DesktopTimePicker.d.ts +0 -5
- package/es/DesktopTimePicker/DesktopTimePicker.js +0 -261
- package/es/DesktopTimePicker/DesktopTimePicker.types.d.ts +0 -182
- package/es/DesktopTimePicker/DesktopTimePicker.types.js +0 -1
- package/es/DesktopTimePicker/DesktopTimePickerList.d.ts +0 -4
- package/es/DesktopTimePicker/DesktopTimePickerList.js +0 -84
- package/es/DesktopTimePicker/index.css +0 -170
- package/es/DesktopTimePicker/index.d.ts +0 -2
- package/es/DesktopTimePicker/index.js +0 -6
- package/es/DesktopTimePicker/useGetTimePickerContent.d.ts +0 -6
- package/es/DesktopTimePicker/useGetTimePickerContent.js +0 -223
- package/es/DesktopTimePicker/utils/scrollUtil.d.ts +0 -2
- package/es/DesktopTimePicker/utils/scrollUtil.js +0 -8
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.d.ts +0 -2
- package/es/DesktopTimePicker/utils/scrollUtil.miniapp.js +0 -22
- package/es/DesktopTimePicker/utils/utils.d.ts +0 -28
- package/es/DesktopTimePicker/utils/utils.js +0 -365
- package/es/SwipeAction/SwipeAction.css +0 -79
- package/es/SwipeAction/SwipeAction.d.ts +0 -5
- package/es/SwipeAction/SwipeAction.js +0 -337
- package/es/SwipeAction/SwipeAction.types.d.ts +0 -83
- package/es/SwipeAction/SwipeAction.types.js +0 -1
- package/es/SwipeAction/SwipeActionContext.d.ts +0 -4
- package/es/SwipeAction/SwipeActionContext.js +0 -11
- package/es/SwipeAction/SwipeActionItem.css +0 -31
- package/es/SwipeAction/SwipeActionItem.d.ts +0 -5
- package/es/SwipeAction/SwipeActionItem.js +0 -78
- package/es/SwipeAction/index.d.ts +0 -4
- package/es/SwipeAction/index.js +0 -9
- package/es/Tabs/utils/scroll.d.ts +0 -2
- package/es/Tabs/utils/scroll.js +0 -36
|
@@ -18,13 +18,11 @@ 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, useMemo } from "react";
|
|
22
22
|
import PortalCore from "./PortalCore";
|
|
23
23
|
const Portal = forwardRef((props, ref) => {
|
|
24
24
|
const { disablePortal } = props;
|
|
25
|
-
const
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
let root;
|
|
25
|
+
const rootWrapperElement = useMemo(() => {
|
|
28
26
|
if (!disablePortal) {
|
|
29
27
|
const currentPages = Taro.getCurrentPages() || [];
|
|
30
28
|
const currentPage = currentPages[currentPages.length - 1];
|
|
@@ -36,12 +34,11 @@ const Portal = forwardRef((props, ref) => {
|
|
|
36
34
|
const view = document.createElement("view");
|
|
37
35
|
view.id = portalId;
|
|
38
36
|
rootElement == null ? void 0 : rootElement.appendChild(view);
|
|
39
|
-
|
|
40
|
-
} else {
|
|
41
|
-
root = portalWrapperElement;
|
|
37
|
+
return view;
|
|
42
38
|
}
|
|
39
|
+
return portalWrapperElement;
|
|
43
40
|
}
|
|
44
|
-
|
|
41
|
+
return void 0;
|
|
45
42
|
}, []);
|
|
46
43
|
return /* @__PURE__ */ React.createElement(PortalCore, __spreadProps(__spreadValues({}, props), { ref, rootElement: rootWrapperElement }));
|
|
47
44
|
});
|
|
@@ -2,14 +2,12 @@ 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
|
|
6
|
-
if (dur <= 0) {
|
|
7
|
-
dur = 500;
|
|
8
|
-
}
|
|
5
|
+
function easeOutScroll(from, to, callback) {
|
|
9
6
|
if (from === to || typeof from !== "number") {
|
|
10
7
|
return;
|
|
11
8
|
}
|
|
12
9
|
const change = to - from;
|
|
10
|
+
const dur = 500;
|
|
13
11
|
const sTime = +/* @__PURE__ */ new Date();
|
|
14
12
|
function linear(t, b, c, d) {
|
|
15
13
|
return c * t / d + b;
|
|
@@ -44,8 +42,7 @@ const ScrollView = forwardRef(
|
|
|
44
42
|
scrollIntoView,
|
|
45
43
|
onTouchMove: propsOnTouchMove,
|
|
46
44
|
scrollIntoViewAlignment,
|
|
47
|
-
children
|
|
48
|
-
scrollAnimationDuration = 500
|
|
45
|
+
children
|
|
49
46
|
} = props;
|
|
50
47
|
const container = useRef(null);
|
|
51
48
|
const handleRef = useForkRef(ref, container);
|
|
@@ -55,15 +52,10 @@ const ScrollView = forwardRef(
|
|
|
55
52
|
if (top === void 0)
|
|
56
53
|
return;
|
|
57
54
|
if (isAnimation) {
|
|
58
|
-
easeOutScroll(
|
|
59
|
-
container.current
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (container.current)
|
|
63
|
-
container.current.scrollTop = pos;
|
|
64
|
-
},
|
|
65
|
-
scrollAnimationDuration
|
|
66
|
-
);
|
|
55
|
+
easeOutScroll(container.current.scrollTop, top, (pos) => {
|
|
56
|
+
if (container.current)
|
|
57
|
+
container.current.scrollTop = pos;
|
|
58
|
+
});
|
|
67
59
|
} else if (container.current)
|
|
68
60
|
container.current.scrollTop = top;
|
|
69
61
|
}, []);
|
|
@@ -71,15 +63,10 @@ const ScrollView = forwardRef(
|
|
|
71
63
|
if (left === void 0)
|
|
72
64
|
return;
|
|
73
65
|
if (isAnimation) {
|
|
74
|
-
easeOutScroll(
|
|
75
|
-
container.current
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (container.current)
|
|
79
|
-
container.current.scrollLeft = pos;
|
|
80
|
-
},
|
|
81
|
-
scrollAnimationDuration
|
|
82
|
-
);
|
|
66
|
+
easeOutScroll(container.current.scrollLeft, left, (pos) => {
|
|
67
|
+
if (container.current)
|
|
68
|
+
container.current.scrollLeft = pos;
|
|
69
|
+
});
|
|
83
70
|
} else if (container.current)
|
|
84
71
|
container.current.scrollLeft = left;
|
|
85
72
|
}, []);
|
|
@@ -138,6 +138,7 @@ 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
|
+
* 仅小程序可用
|
|
141
142
|
*/
|
|
142
143
|
scrollAnimationDuration?: number;
|
|
143
144
|
/** 纵向滚动时,当滚动到顶部或底部时,强制禁止触发页面滚动,仍然只触发 scroll-view 自身的滚动。
|
package/es/Select/Select.css
CHANGED
|
@@ -48,9 +48,13 @@
|
|
|
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%;
|
|
51
54
|
font-size: var(--bui-select-font-size, var(--bui-title-size-3));
|
|
52
55
|
z-index: var(--bui-z-index-tooltip);
|
|
53
56
|
border-radius: 3px;
|
|
57
|
+
background-color: var(--bui-color-bg-view);
|
|
54
58
|
padding: 2px;
|
|
55
59
|
overflow: hidden;
|
|
56
60
|
}
|
|
@@ -67,7 +71,6 @@
|
|
|
67
71
|
border-radius: 3px;
|
|
68
72
|
padding: var(--bui-select-option-container-padding, 3px 0);
|
|
69
73
|
box-shadow: 0 0 0 2px var(--bui-color-bg-default);
|
|
70
|
-
background-color: var(--bui-color-bg-view);
|
|
71
74
|
overflow: hidden;
|
|
72
75
|
}
|
|
73
76
|
.bui-select-option {
|
package/es/Select/Select.js
CHANGED
|
@@ -29,32 +29,13 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
32
|
import { CaretDownIcon, CaretUpIcon } from "@bifrostui/icons";
|
|
53
33
|
import {
|
|
54
34
|
getStylesAndLocation,
|
|
55
35
|
isMini,
|
|
56
36
|
throttle,
|
|
57
37
|
useForkRef,
|
|
38
|
+
useUniqueId,
|
|
58
39
|
useValue
|
|
59
40
|
} from "@bifrostui/utils";
|
|
60
41
|
import clsx from "clsx";
|
|
@@ -117,36 +98,38 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
117
98
|
const isOpen = open !== void 0 ? open : internalOpen;
|
|
118
99
|
const locatorRef = useRef(null);
|
|
119
100
|
const rootRef = useForkRef(ref, locatorRef);
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
const updateOptionStyle = () =>
|
|
101
|
+
const ttId = useUniqueId();
|
|
102
|
+
const dataId = `${prefixCls}-tt-${ttId}`;
|
|
103
|
+
const updateOptionStyle = throttle(() => {
|
|
123
104
|
const curScrollRoot = scrollContainer();
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
const changeOpen = (newOpen) =>
|
|
105
|
+
if (!isMini && curScrollRoot) {
|
|
106
|
+
const result = getStylesAndLocation({
|
|
107
|
+
scrollRoot: curScrollRoot,
|
|
108
|
+
childrenRef: locatorRef,
|
|
109
|
+
arrowDirection: defaultPlacement,
|
|
110
|
+
arrowLocation: "none",
|
|
111
|
+
selector: `[data-id="${dataId}"]`,
|
|
112
|
+
offsetSpacing: 0
|
|
113
|
+
});
|
|
114
|
+
if (!result)
|
|
115
|
+
return;
|
|
116
|
+
const { styles, childrenStyle, newArrowDirection } = result;
|
|
117
|
+
setPlacement(newArrowDirection);
|
|
118
|
+
setOptionStyle(__spreadProps(__spreadValues({}, styles), { width: childrenStyle.width }));
|
|
119
|
+
}
|
|
120
|
+
}, 100);
|
|
121
|
+
const changeOpen = (newOpen) => {
|
|
141
122
|
if (newOpen) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
123
|
+
updateOptionStyle();
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
setInternalOpen(newOpen);
|
|
126
|
+
onOpen == null ? void 0 : onOpen();
|
|
127
|
+
}, 100);
|
|
145
128
|
} else {
|
|
146
129
|
onClose == null ? void 0 : onClose();
|
|
147
130
|
setInternalOpen(newOpen);
|
|
148
131
|
}
|
|
149
|
-
}
|
|
132
|
+
};
|
|
150
133
|
const handleSelectClick = (e) => {
|
|
151
134
|
if (disabled)
|
|
152
135
|
return;
|
|
@@ -171,11 +154,10 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
171
154
|
[selectValue, onChange, setRenderValue]
|
|
172
155
|
);
|
|
173
156
|
useEffect(() => {
|
|
174
|
-
const resizeCb = throttle(updateOptionStyle, 100);
|
|
175
157
|
if (!isMini) {
|
|
176
|
-
window.addEventListener("resize",
|
|
158
|
+
window.addEventListener("resize", updateOptionStyle);
|
|
177
159
|
return () => {
|
|
178
|
-
window.removeEventListener("resize",
|
|
160
|
+
window.removeEventListener("resize", updateOptionStyle);
|
|
179
161
|
};
|
|
180
162
|
}
|
|
181
163
|
}, []);
|
|
@@ -193,8 +175,8 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
193
175
|
{
|
|
194
176
|
in: isOpen,
|
|
195
177
|
timeout: {
|
|
196
|
-
enter:
|
|
197
|
-
exit:
|
|
178
|
+
enter: 150,
|
|
179
|
+
exit: 150
|
|
198
180
|
}
|
|
199
181
|
},
|
|
200
182
|
/* @__PURE__ */ React.createElement(
|
|
@@ -208,7 +190,7 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
208
190
|
[`${prefixCls}-option-container-hide`]: !isOpen
|
|
209
191
|
}
|
|
210
192
|
),
|
|
211
|
-
|
|
193
|
+
"data-id": dataId,
|
|
212
194
|
style: optionStyle
|
|
213
195
|
},
|
|
214
196
|
/* @__PURE__ */ React.createElement(
|
|
@@ -217,18 +199,11 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
217
199
|
in: isOpen,
|
|
218
200
|
direction: placement === "bottom" ? "down" : "up",
|
|
219
201
|
timeout: {
|
|
220
|
-
enter:
|
|
221
|
-
exit:
|
|
202
|
+
enter: 150,
|
|
203
|
+
exit: 150
|
|
222
204
|
}
|
|
223
205
|
},
|
|
224
|
-
/* @__PURE__ */ React.createElement(
|
|
225
|
-
"div",
|
|
226
|
-
{
|
|
227
|
-
className: clsx(`${prefixCls}-option-main`),
|
|
228
|
-
ref: optionMainRef
|
|
229
|
-
},
|
|
230
|
-
children
|
|
231
|
-
)
|
|
206
|
+
/* @__PURE__ */ React.createElement("div", { className: clsx(`${prefixCls}-option-main`) }, children)
|
|
232
207
|
)
|
|
233
208
|
)
|
|
234
209
|
);
|
|
@@ -256,8 +231,9 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
256
231
|
[inputProps == null ? void 0 : inputProps.className]: inputProps == null ? void 0 : inputProps.className
|
|
257
232
|
})
|
|
258
233
|
})
|
|
259
|
-
), icon || defaultIcon)
|
|
260
|
-
|
|
234
|
+
), icon || defaultIcon),
|
|
235
|
+
isMini && renderOptions()
|
|
236
|
+
), !isMini && /* @__PURE__ */ React.createElement(Portal, { onRootElementMouted: updateOptionStyle }, renderOptions()), /* @__PURE__ */ React.createElement(
|
|
261
237
|
Backdrop,
|
|
262
238
|
__spreadProps(__spreadValues({
|
|
263
239
|
open: isOpen,
|
|
@@ -274,7 +250,9 @@ const Select = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
274
250
|
Select.displayName = "BuiSelect";
|
|
275
251
|
Select.defaultProps = {
|
|
276
252
|
defaultValue: "",
|
|
277
|
-
scrollContainer: () =>
|
|
253
|
+
scrollContainer: () => {
|
|
254
|
+
return isMini ? null : document.body;
|
|
255
|
+
}
|
|
278
256
|
};
|
|
279
257
|
var Select_default = Select;
|
|
280
258
|
export {
|
package/es/Slider/Slider.js
CHANGED
|
@@ -50,9 +50,7 @@ import { GripperBarVerticalIcon } from "@bifrostui/icons";
|
|
|
50
50
|
import {
|
|
51
51
|
isMini,
|
|
52
52
|
useForkRef,
|
|
53
|
-
|
|
54
|
-
emulateTouchMove,
|
|
55
|
-
emulateTouchEnd,
|
|
53
|
+
useTouchEmulator,
|
|
56
54
|
useValue,
|
|
57
55
|
getBoundingClientRect
|
|
58
56
|
} from "@bifrostui/utils";
|
|
@@ -112,6 +110,7 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
112
110
|
const value = shouldProtection ? latestVal.current : valueProp;
|
|
113
111
|
const [rootRef, setRootRef] = useState(null);
|
|
114
112
|
const handleRef = useForkRef(ref, setRootRef);
|
|
113
|
+
useTouchEmulator(rootRef);
|
|
115
114
|
const sliderRect = useRef();
|
|
116
115
|
const touchStartPageX = useRef();
|
|
117
116
|
const touchStartLeft = useRef();
|
|
@@ -182,7 +181,9 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
182
181
|
return;
|
|
183
182
|
beforeMoveValue.current = internalValue;
|
|
184
183
|
tooltipRef.current = internalValue;
|
|
185
|
-
|
|
184
|
+
if (!sliderRect.current.width) {
|
|
185
|
+
getLineWidth();
|
|
186
|
+
}
|
|
186
187
|
const currentTarget = isMini ? e.mpEvent.currentTarget : e.currentTarget;
|
|
187
188
|
touchStartPageX.current = e.touches[0].pageX;
|
|
188
189
|
touchStartLeft.current = currentTarget == null ? void 0 : currentTarget.offsetLeft;
|
|
@@ -241,16 +242,6 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
241
242
|
setFrontTooltipVisible(false);
|
|
242
243
|
setEndTooltipVisible(false);
|
|
243
244
|
};
|
|
244
|
-
const onMouseUp = (e) => {
|
|
245
|
-
emulateTouchEnd(e);
|
|
246
|
-
document.removeEventListener("mousemove", emulateTouchMove);
|
|
247
|
-
document.removeEventListener("mouseup", onMouseUp);
|
|
248
|
-
};
|
|
249
|
-
const onMouseDown = (e) => {
|
|
250
|
-
emulateTouchStart(e);
|
|
251
|
-
document.addEventListener("mousemove", emulateTouchMove);
|
|
252
|
-
document.addEventListener("mouseup", onMouseUp);
|
|
253
|
-
};
|
|
254
245
|
const renderButton = (index) => {
|
|
255
246
|
const valuenow = internalValue[index];
|
|
256
247
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -273,8 +264,7 @@ const Slider = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
273
264
|
},
|
|
274
265
|
onTouchMove,
|
|
275
266
|
onTouchEnd,
|
|
276
|
-
onTouchCancel: onTouchEnd
|
|
277
|
-
onMouseDown
|
|
267
|
+
onTouchCancel: onTouchEnd
|
|
278
268
|
},
|
|
279
269
|
index === SLIDER_BUTTON.FRONT ? startIcon || defaultIcon : endIcon || defaultIcon
|
|
280
270
|
);
|
package/es/Tabs/Tab.js
CHANGED
|
@@ -36,19 +36,7 @@ import TabsContext from "./TabsContext";
|
|
|
36
36
|
import "./Tab.css";
|
|
37
37
|
const prefixCls = "bui-tab";
|
|
38
38
|
const Tab = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
39
|
-
const _a = props, {
|
|
40
|
-
className,
|
|
41
|
-
children,
|
|
42
|
-
index,
|
|
43
|
-
disabled = false,
|
|
44
|
-
onClick
|
|
45
|
-
} = _a, others = __objRest(_a, [
|
|
46
|
-
"className",
|
|
47
|
-
"children",
|
|
48
|
-
"index",
|
|
49
|
-
"disabled",
|
|
50
|
-
"onClick"
|
|
51
|
-
]);
|
|
39
|
+
const _a = props, { className, children, index, disabled, onClick } = _a, others = __objRest(_a, ["className", "children", "index", "disabled", "onClick"]);
|
|
52
40
|
const tabsContext = React.useContext(TabsContext);
|
|
53
41
|
const { value, align, triggerChange } = tabsContext;
|
|
54
42
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -86,6 +74,9 @@ const Tab = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
86
74
|
);
|
|
87
75
|
});
|
|
88
76
|
Tab.displayName = "BuiTab";
|
|
77
|
+
Tab.defaultProps = {
|
|
78
|
+
disabled: false
|
|
79
|
+
};
|
|
89
80
|
var Tab_default = Tab;
|
|
90
81
|
export {
|
|
91
82
|
Tab_default as default
|
package/es/Tabs/Tabs.js
CHANGED
|
@@ -42,10 +42,9 @@ import React, {
|
|
|
42
42
|
} from "react";
|
|
43
43
|
import Tab from "./Tab";
|
|
44
44
|
import { TabsContextProvider } from "./TabsContext";
|
|
45
|
-
import
|
|
45
|
+
import bound from "./utils/bound";
|
|
46
46
|
import "./Tabs.css";
|
|
47
47
|
const prefixCls = "bui-tabs";
|
|
48
|
-
const duration = 300;
|
|
49
48
|
const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
50
49
|
const _a = props, { children, className, value, tabs, align, onChange } = _a, others = __objRest(_a, ["children", "className", "value", "tabs", "align", "onChange"]);
|
|
51
50
|
const [active, setActive] = useState("");
|
|
@@ -60,11 +59,14 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
60
59
|
leftMaskOpacity: 0,
|
|
61
60
|
rightMaskOpacity: 0
|
|
62
61
|
});
|
|
63
|
-
const
|
|
62
|
+
const animate = ({ transitionInUse }) => {
|
|
64
63
|
const container = tabsRef.current;
|
|
65
64
|
if (!container)
|
|
66
|
-
return
|
|
65
|
+
return;
|
|
67
66
|
const activeIndex = !!tabs.length && tabs.findIndex((item) => item.index === active);
|
|
67
|
+
const activeLine = activeLineRef.current;
|
|
68
|
+
if (!activeLine)
|
|
69
|
+
return;
|
|
68
70
|
let activeTab;
|
|
69
71
|
if (tabs.length) {
|
|
70
72
|
activeTab = activeIndex > -1 ? container.childNodes[activeIndex + 1] : void 0;
|
|
@@ -78,25 +80,6 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
78
80
|
return [...child.classList].includes("bui-tab-active");
|
|
79
81
|
});
|
|
80
82
|
}
|
|
81
|
-
return activeTab;
|
|
82
|
-
};
|
|
83
|
-
const scrollIntoView = () => {
|
|
84
|
-
const tabsContainer = tabsRef.current;
|
|
85
|
-
const activeTab = getActiveTabElement();
|
|
86
|
-
if (!tabsContainer || !activeTab) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const to = activeTab.offsetLeft - (tabsContainer.offsetWidth - activeTab.offsetWidth) / 2;
|
|
90
|
-
scrollLeftTo(tabsContainer, to, duration);
|
|
91
|
-
};
|
|
92
|
-
const animate = ({ transitionInUse }) => {
|
|
93
|
-
const container = tabsRef.current;
|
|
94
|
-
if (!container)
|
|
95
|
-
return;
|
|
96
|
-
const activeLine = activeLineRef.current;
|
|
97
|
-
if (!activeLine)
|
|
98
|
-
return;
|
|
99
|
-
const activeTab = getActiveTabElement();
|
|
100
83
|
let activeTabLeft = 0;
|
|
101
84
|
let activeTabWidth = 0;
|
|
102
85
|
let containerWidth = 0;
|
|
@@ -119,8 +102,13 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
119
102
|
const maxScrollDistance = containerScrollWidth - containerWidth;
|
|
120
103
|
if (maxScrollDistance <= 0 || !activeTab)
|
|
121
104
|
return;
|
|
122
|
-
|
|
123
|
-
|
|
105
|
+
const nextScrollLeft = bound(
|
|
106
|
+
activeTabLeft - (containerWidth - activeTabWidth) / 2,
|
|
107
|
+
0,
|
|
108
|
+
containerScrollWidth - containerWidth
|
|
109
|
+
);
|
|
110
|
+
if (tabsRef.current) {
|
|
111
|
+
tabsRef.current.scrollLeft = nextScrollLeft;
|
|
124
112
|
}
|
|
125
113
|
};
|
|
126
114
|
useEffect(() => {
|
|
@@ -150,10 +138,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
150
138
|
return;
|
|
151
139
|
const scrollLeft = container == null ? void 0 : container.scrollLeft;
|
|
152
140
|
const showLeftMask = scrollLeft > 0;
|
|
153
|
-
const
|
|
154
|
-
container.scrollWidth - (scrollLeft + container.offsetWidth)
|
|
155
|
-
);
|
|
156
|
-
const showRightMask = rightRange > 1;
|
|
141
|
+
const showRightMask = scrollLeft + container.offsetWidth < container.scrollWidth;
|
|
157
142
|
setMaskData({
|
|
158
143
|
leftMaskOpacity: showLeftMask ? 1 : 0,
|
|
159
144
|
rightMaskOpacity: showRightMask ? 1 : 0
|
|
@@ -211,7 +196,7 @@ const Tabs = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
211
196
|
"bui-tabline-invisible": isMini || !lineData.hasActiveTab
|
|
212
197
|
}),
|
|
213
198
|
style: {
|
|
214
|
-
transition: lineData.transitionInUse ?
|
|
199
|
+
transition: lineData.transitionInUse ? "transform 0.25s ease-in-out" : void 0,
|
|
215
200
|
transform: `translate3d(${lineData.x}px, 0px, 0px)`
|
|
216
201
|
}
|
|
217
202
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function bound(position: number, min: number | undefined, max: number | undefined): number;
|
|
@@ -29,7 +29,7 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
}
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
|
-
import { render, unmount,
|
|
32
|
+
import { render, unmount, getRootElement } from "@bifrostui/utils";
|
|
33
33
|
import React, { useCallback, useEffect, useState } from "react";
|
|
34
34
|
import ToastView from "./Toast";
|
|
35
35
|
let toastCloses = [];
|
|
@@ -70,7 +70,7 @@ const functionalToast = (props) => {
|
|
|
70
70
|
rootWrapper.style[property] = styles[property];
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
const rootElement =
|
|
73
|
+
const rootElement = getRootElement();
|
|
74
74
|
rootElement.appendChild(rootWrapper);
|
|
75
75
|
const ToastComponent = () => {
|
|
76
76
|
const _a = options, { duration, allowMultiple, onClose } = _a, others = __objRest(_a, ["duration", "allowMultiple", "onClose"]);
|