@bifrostui/react 1.2.4 → 1.2.5
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/Picker/Picker.js +12 -0
- package/dist/Picker/PickerPanel.js +6 -1
- package/dist/Tabs/Tabs.css +4 -2
- package/es/Modal/Modal.miniapp.d.ts +1 -1
- package/es/Picker/Picker.js +13 -1
- package/es/Picker/PickerPanel.js +7 -2
- package/es/Tabs/Tabs.css +4 -2
- package/package.json +5 -5
package/dist/Picker/Picker.js
CHANGED
|
@@ -91,6 +91,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
91
91
|
"onClose"
|
|
92
92
|
]);
|
|
93
93
|
const pickerType = (0, import_utils.pickerPanelType)(options);
|
|
94
|
+
const rollerRefs = (0, import_react.useRef)([]);
|
|
94
95
|
const [columns, setColumns] = (0, import_react.useState)([]);
|
|
95
96
|
const [internalValue, setInternalValue] = (0, import_react.useState)([]);
|
|
96
97
|
(0, import_react.useEffect)(() => {
|
|
@@ -118,6 +119,9 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
118
119
|
value: internalValue,
|
|
119
120
|
options: columns
|
|
120
121
|
};
|
|
122
|
+
const isMoving = rollerRefs.current.some((roller) => roller == null ? void 0 : roller.isMoving);
|
|
123
|
+
if (isMoving)
|
|
124
|
+
return;
|
|
121
125
|
onConfirm == null ? void 0 : onConfirm(e, payload);
|
|
122
126
|
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
123
127
|
from: "confirm"
|
|
@@ -182,6 +186,13 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
182
186
|
options: columns
|
|
183
187
|
}, data));
|
|
184
188
|
};
|
|
189
|
+
const setRefs = (0, import_react.useCallback)(
|
|
190
|
+
(index) => (e) => {
|
|
191
|
+
if (e)
|
|
192
|
+
rollerRefs.current[index] = e;
|
|
193
|
+
},
|
|
194
|
+
[]
|
|
195
|
+
);
|
|
185
196
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
186
197
|
import_Drawer.default,
|
|
187
198
|
__spreadValues({
|
|
@@ -199,6 +210,7 @@ const Picker = /* @__PURE__ */ import_react.default.forwardRef((props, ref) => {
|
|
|
199
210
|
/* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-container` }, columns.map((column, index) => /* @__PURE__ */ import_react.default.createElement(
|
|
200
211
|
import_PickerPanel.default,
|
|
201
212
|
{
|
|
213
|
+
ref: setRefs(index),
|
|
202
214
|
key: index,
|
|
203
215
|
options: column,
|
|
204
216
|
columnIndex: index,
|
|
@@ -76,7 +76,7 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
76
76
|
]);
|
|
77
77
|
const touch = (0, import_utils.useTouch)();
|
|
78
78
|
let timer;
|
|
79
|
-
const INERTIA_TIME =
|
|
79
|
+
const INERTIA_TIME = 200;
|
|
80
80
|
const INERTIA_DISTANCE = 15;
|
|
81
81
|
const DEFAULT_DURATION = 200;
|
|
82
82
|
const LINE_SPACING = 36;
|
|
@@ -90,6 +90,7 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
90
90
|
const [scrollDistance, setScrollDistance] = (0, import_react.useState)(0);
|
|
91
91
|
const transformY = (0, import_react.useRef)(0);
|
|
92
92
|
const isVerticalMoving = (0, import_react.useRef)(false);
|
|
93
|
+
const rollerRef = (0, import_react.useRef)(null);
|
|
93
94
|
const PickerPanelRef = (0, import_react.useRef)(null);
|
|
94
95
|
const pickerPanelRef = (0, import_utils.useForkRef)(PickerPanelRef, ref);
|
|
95
96
|
(0, import_utils.useTouchEmulator)(PickerPanelRef.current);
|
|
@@ -221,6 +222,9 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
221
222
|
columnIndex
|
|
222
223
|
});
|
|
223
224
|
};
|
|
225
|
+
(0, import_react.useImperativeHandle)(ref, () => ({
|
|
226
|
+
isMoving: isVerticalMoving.current
|
|
227
|
+
}));
|
|
224
228
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
225
229
|
"div",
|
|
226
230
|
__spreadValues({
|
|
@@ -234,6 +238,7 @@ const PickerPanel = /* @__PURE__ */ import_react.default.forwardRef(
|
|
|
234
238
|
"div",
|
|
235
239
|
{
|
|
236
240
|
className: `${prefixCls}-roller`,
|
|
241
|
+
ref: rollerRef,
|
|
237
242
|
style: {
|
|
238
243
|
transition: `transform ${touchTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
|
|
239
244
|
transform: `rotate3d(1, 0, 0, ${touchDeg})`
|
package/dist/Tabs/Tabs.css
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
--color: var(--bui-color-fg-subtle);
|
|
5
5
|
--active-color: var(--bui-color-fg-default);
|
|
6
6
|
--line-color: var(--bui-color-primary);
|
|
7
|
+
--line-height: 3PX;
|
|
8
|
+
--line-width: 18px;
|
|
7
9
|
position: relative;
|
|
8
10
|
font-family: var(--bui-font-family);
|
|
9
11
|
}
|
|
@@ -22,9 +24,9 @@
|
|
|
22
24
|
}
|
|
23
25
|
.bui-tabs-tabline {
|
|
24
26
|
position: absolute;
|
|
25
|
-
width:
|
|
27
|
+
width: var(--line-width);
|
|
26
28
|
bottom: 0;
|
|
27
|
-
height:
|
|
29
|
+
height: var(--line-height);
|
|
28
30
|
color: var(--bui-color-primary);
|
|
29
31
|
background: var(--line-color);
|
|
30
32
|
border-radius: var(--bui-shape-radius-label);
|
|
@@ -12,5 +12,5 @@ declare const Modal: React.ForwardRefExoticComponent<Omit<ViewProps & {
|
|
|
12
12
|
keepMounted?: boolean;
|
|
13
13
|
} & import("@bifrostui/types").ICommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
14
14
|
ref?: React.Ref<HTMLDivElement>;
|
|
15
|
-
},
|
|
15
|
+
}, keyof import("@bifrostui/types").ICommonProps | "open" | "container" | "disablePortal" | "hideBackdrop" | "BackdropProps" | "onClose" | "disableScrollLock" | "keepMounted">, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
16
16
|
export default Modal;
|
package/es/Picker/Picker.js
CHANGED
|
@@ -30,7 +30,7 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import clsx from "clsx";
|
|
33
|
-
import React, { useEffect, useState } from "react";
|
|
33
|
+
import React, { useEffect, useRef, useState, useCallback } from "react";
|
|
34
34
|
import Drawer from "../Drawer";
|
|
35
35
|
import PickerPanel from "./PickerPanel";
|
|
36
36
|
import { formatOptions, pickerPanelType } from "./utils";
|
|
@@ -61,6 +61,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
61
61
|
"onClose"
|
|
62
62
|
]);
|
|
63
63
|
const pickerType = pickerPanelType(options);
|
|
64
|
+
const rollerRefs = useRef([]);
|
|
64
65
|
const [columns, setColumns] = useState([]);
|
|
65
66
|
const [internalValue, setInternalValue] = useState([]);
|
|
66
67
|
useEffect(() => {
|
|
@@ -88,6 +89,9 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
88
89
|
value: internalValue,
|
|
89
90
|
options: columns
|
|
90
91
|
};
|
|
92
|
+
const isMoving = rollerRefs.current.some((roller) => roller == null ? void 0 : roller.isMoving);
|
|
93
|
+
if (isMoving)
|
|
94
|
+
return;
|
|
91
95
|
onConfirm == null ? void 0 : onConfirm(e, payload);
|
|
92
96
|
onClose == null ? void 0 : onClose(e, __spreadValues({
|
|
93
97
|
from: "confirm"
|
|
@@ -152,6 +156,13 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
152
156
|
options: columns
|
|
153
157
|
}, data));
|
|
154
158
|
};
|
|
159
|
+
const setRefs = useCallback(
|
|
160
|
+
(index) => (e) => {
|
|
161
|
+
if (e)
|
|
162
|
+
rollerRefs.current[index] = e;
|
|
163
|
+
},
|
|
164
|
+
[]
|
|
165
|
+
);
|
|
155
166
|
return /* @__PURE__ */ React.createElement(
|
|
156
167
|
Drawer,
|
|
157
168
|
__spreadValues({
|
|
@@ -169,6 +180,7 @@ const Picker = /* @__PURE__ */ React.forwardRef((props, ref) => {
|
|
|
169
180
|
/* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-container` }, columns.map((column, index) => /* @__PURE__ */ React.createElement(
|
|
170
181
|
PickerPanel,
|
|
171
182
|
{
|
|
183
|
+
ref: setRefs(index),
|
|
172
184
|
key: index,
|
|
173
185
|
options: column,
|
|
174
186
|
columnIndex: index,
|
package/es/Picker/PickerPanel.js
CHANGED
|
@@ -27,7 +27,7 @@ var __objRest = (source, exclude) => {
|
|
|
27
27
|
return target;
|
|
28
28
|
};
|
|
29
29
|
import clsx from "clsx";
|
|
30
|
-
import React, { useEffect, useState, useRef } from "react";
|
|
30
|
+
import React, { useEffect, useState, useRef, useImperativeHandle } from "react";
|
|
31
31
|
import { useTouch, useForkRef, useTouchEmulator } from "@bifrostui/utils";
|
|
32
32
|
import "./PickerPanel.css";
|
|
33
33
|
const prefixCls = "bui-picker-panel";
|
|
@@ -46,7 +46,7 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
46
46
|
]);
|
|
47
47
|
const touch = useTouch();
|
|
48
48
|
let timer;
|
|
49
|
-
const INERTIA_TIME =
|
|
49
|
+
const INERTIA_TIME = 200;
|
|
50
50
|
const INERTIA_DISTANCE = 15;
|
|
51
51
|
const DEFAULT_DURATION = 200;
|
|
52
52
|
const LINE_SPACING = 36;
|
|
@@ -60,6 +60,7 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
60
60
|
const [scrollDistance, setScrollDistance] = useState(0);
|
|
61
61
|
const transformY = useRef(0);
|
|
62
62
|
const isVerticalMoving = useRef(false);
|
|
63
|
+
const rollerRef = useRef(null);
|
|
63
64
|
const PickerPanelRef = useRef(null);
|
|
64
65
|
const pickerPanelRef = useForkRef(PickerPanelRef, ref);
|
|
65
66
|
useTouchEmulator(PickerPanelRef.current);
|
|
@@ -191,6 +192,9 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
191
192
|
columnIndex
|
|
192
193
|
});
|
|
193
194
|
};
|
|
195
|
+
useImperativeHandle(ref, () => ({
|
|
196
|
+
isMoving: isVerticalMoving.current
|
|
197
|
+
}));
|
|
194
198
|
return /* @__PURE__ */ React.createElement(
|
|
195
199
|
"div",
|
|
196
200
|
__spreadValues({
|
|
@@ -204,6 +208,7 @@ const PickerPanel = /* @__PURE__ */ React.forwardRef(
|
|
|
204
208
|
"div",
|
|
205
209
|
{
|
|
206
210
|
className: `${prefixCls}-roller`,
|
|
211
|
+
ref: rollerRef,
|
|
207
212
|
style: {
|
|
208
213
|
transition: `transform ${touchTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
|
|
209
214
|
transform: `rotate3d(1, 0, 0, ${touchDeg})`
|
package/es/Tabs/Tabs.css
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
--color: var(--bui-color-fg-subtle);
|
|
5
5
|
--active-color: var(--bui-color-fg-default);
|
|
6
6
|
--line-color: var(--bui-color-primary);
|
|
7
|
+
--line-height: 3PX;
|
|
8
|
+
--line-width: 18px;
|
|
7
9
|
position: relative;
|
|
8
10
|
font-family: var(--bui-font-family);
|
|
9
11
|
}
|
|
@@ -22,9 +24,9 @@
|
|
|
22
24
|
}
|
|
23
25
|
.bui-tabs-tabline {
|
|
24
26
|
position: absolute;
|
|
25
|
-
width:
|
|
27
|
+
width: var(--line-width);
|
|
26
28
|
bottom: 0;
|
|
27
|
-
height:
|
|
29
|
+
height: var(--line-height);
|
|
28
30
|
color: var(--bui-color-primary);
|
|
29
31
|
background: var(--line-color);
|
|
30
32
|
border-radius: var(--bui-shape-radius-label);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bifrostui/react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "React components for building mobile application",
|
|
5
5
|
"homepage": "http://bui.taopiaopiao.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"clsx": "^1.2.1",
|
|
34
34
|
"dayjs": "^1.11.7",
|
|
35
35
|
"swiper": "^8.1.5",
|
|
36
|
-
"@bifrostui/types": "1.2.
|
|
37
|
-
"@bifrostui/
|
|
38
|
-
"@bifrostui/
|
|
39
|
-
"@bifrostui/icons": "1.2.
|
|
36
|
+
"@bifrostui/types": "1.2.5",
|
|
37
|
+
"@bifrostui/styles": "1.2.5",
|
|
38
|
+
"@bifrostui/utils": "1.2.5",
|
|
39
|
+
"@bifrostui/icons": "1.2.5"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@tarojs/components": "^3.0.0",
|