@bifrostui/react 1.0.5 → 1.1.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/ActionSheet/ActionSheet.less +31 -0
- package/dist/ActionSheet/ActionSheetItem.less +62 -0
- package/dist/Alert/index.less +112 -0
- package/dist/Avatar/Avatar.less +52 -0
- package/dist/Avatar/AvatarGroup.less +39 -0
- package/dist/Backdrop/{Backdrop.css → Backdrop.less} +4 -3
- package/dist/Badge/Badge.less +118 -0
- package/dist/Button/Button.less +244 -0
- package/dist/Calendar/Calendar.less +126 -0
- package/{es/Card/Card.css → dist/Card/Card.less} +1 -0
- package/dist/Card/CardHeader.less +53 -0
- package/dist/Checkbox/Checkbox.less +55 -0
- package/dist/CitySelector/CitySelector.d.ts +4 -0
- package/dist/CitySelector/CitySelector.js +36 -0
- package/dist/CitySelector/CitySelector.less +122 -0
- package/dist/CitySelector/CitySelector.miniapp.d.ts +5 -0
- package/dist/CitySelector/CitySelector.miniapp.js +79 -0
- package/dist/CitySelector/CitySelector.types.d.ts +47 -0
- package/dist/CitySelector/CitySelector.types.js +5 -0
- package/dist/CitySelector/CitySelectorCore.d.ts +5 -0
- package/dist/CitySelector/CitySelectorCore.js +183 -0
- package/dist/CitySelector/Selector/index.d.ts +9 -0
- package/dist/CitySelector/Selector/index.js +22 -0
- package/dist/CitySelector/Selector/index.less +13 -0
- package/dist/CitySelector/index.d.ts +2 -0
- package/dist/CitySelector/index.js +34 -0
- package/dist/CitySelector/miniapp.less +4 -0
- package/dist/Countdown/Countdown.less +39 -0
- package/dist/Divider/Divider.less +50 -0
- package/dist/Drawer/Drawer.less +40 -0
- package/dist/IconButton/IconButton.less +167 -0
- package/dist/Image/index.less +40 -0
- package/dist/Input/Input.less +72 -0
- package/dist/List/{List.css → List.less} +1 -0
- package/dist/List/{ListItem.css → ListItem.less} +17 -6
- package/dist/List/{ListItemContent.css → ListItemContent.less} +7 -2
- package/dist/List/{ListItemFooter.css → ListItemFooter.less} +4 -3
- package/dist/Loading/Loading.less +40 -0
- package/dist/Modal/{Modal.css → Modal.less} +8 -6
- package/dist/Modal/Modal.miniapp.d.ts +16 -0
- package/dist/Modal/Modal.miniapp.js +73 -0
- package/dist/NavBar/NavBar.less +67 -0
- package/dist/Picker/Picker.d.ts +5 -0
- package/dist/Picker/Picker.js +155 -0
- package/dist/Picker/Picker.less +62 -0
- package/dist/Picker/Picker.types.d.ts +98 -0
- package/dist/Picker/Picker.types.js +5 -0
- package/dist/Picker/PickerPanel.d.ts +5 -0
- package/dist/Picker/PickerPanel.js +210 -0
- package/dist/Picker/PickerPanel.less +67 -0
- package/dist/Picker/index.d.ts +2 -0
- package/dist/Picker/index.js +34 -0
- package/dist/Picker/utils.d.ts +13 -0
- package/dist/Picker/utils.js +66 -0
- package/dist/Progress/Progress.less +24 -0
- package/dist/Radio/Radio.less +81 -0
- package/dist/Rating/Rating.less +64 -0
- package/dist/ScrollView/{ScrollView.css → ScrollView.less} +4 -0
- package/dist/Select/Select.less +105 -0
- package/dist/Skeleton/Skeleton.less +72 -0
- package/dist/Slider/Slider.less +108 -0
- package/dist/Stack/demo/index.less +27 -0
- package/dist/Steps/Step.less +228 -0
- package/{es/Steps/Steps.css → dist/Steps/Steps.less} +5 -3
- package/dist/Swiper/Swiper.less +25 -0
- package/dist/Switch/Switch.less +177 -0
- package/dist/TabBar/TabBarItem.less +54 -0
- package/dist/Tabs/Tab.js +1 -1
- package/dist/Tabs/Tab.less +60 -0
- package/dist/Tabs/TabPanel.less +11 -0
- package/dist/Tabs/Tabs.less +77 -0
- package/dist/Tag/Tag.less +119 -0
- package/dist/Tag/TagGroup.less +52 -0
- package/dist/TextArea/{TextArea.css → TextArea.less} +27 -19
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -0
- package/es/ActionSheet/ActionSheet.less +31 -0
- package/es/ActionSheet/ActionSheetItem.less +62 -0
- package/es/Alert/index.less +112 -0
- package/es/Avatar/Avatar.less +52 -0
- package/es/Avatar/AvatarGroup.less +39 -0
- package/es/Backdrop/{Backdrop.css → Backdrop.less} +4 -3
- package/es/Badge/Badge.less +118 -0
- package/es/Button/Button.less +244 -0
- package/es/Calendar/Calendar.less +126 -0
- package/{dist/Card/Card.css → es/Card/Card.less} +1 -0
- package/es/Card/CardHeader.less +53 -0
- package/es/Checkbox/Checkbox.less +55 -0
- package/es/CitySelector/CitySelector.d.ts +4 -0
- package/es/CitySelector/CitySelector.js +36 -0
- package/es/CitySelector/CitySelector.less +122 -0
- package/es/CitySelector/CitySelector.miniapp.d.ts +5 -0
- package/es/CitySelector/CitySelector.miniapp.js +77 -0
- package/es/CitySelector/CitySelector.types.d.ts +47 -0
- package/es/CitySelector/CitySelector.types.js +1 -0
- package/es/CitySelector/CitySelectorCore.d.ts +5 -0
- package/es/CitySelector/CitySelectorCore.js +194 -0
- package/es/CitySelector/Selector/index.d.ts +9 -0
- package/es/CitySelector/Selector/index.js +13 -0
- package/es/CitySelector/Selector/index.less +13 -0
- package/es/CitySelector/index.d.ts +2 -0
- package/es/CitySelector/index.js +2 -0
- package/es/CitySelector/miniapp.less +4 -0
- package/es/Countdown/Countdown.less +39 -0
- package/es/Divider/Divider.less +50 -0
- package/es/Drawer/Drawer.less +40 -0
- package/es/IconButton/IconButton.less +167 -0
- package/es/Image/index.less +40 -0
- package/es/Input/Input.less +72 -0
- package/es/List/{List.css → List.less} +1 -0
- package/es/List/{ListItem.css → ListItem.less} +17 -6
- package/es/List/{ListItemContent.css → ListItemContent.less} +7 -2
- package/es/List/{ListItemFooter.css → ListItemFooter.less} +4 -3
- package/es/Loading/Loading.less +40 -0
- package/es/Modal/{Modal.css → Modal.less} +8 -6
- package/es/Modal/Modal.miniapp.d.ts +16 -0
- package/es/Modal/Modal.miniapp.js +78 -0
- package/es/NavBar/NavBar.less +67 -0
- package/es/Picker/Picker.d.ts +5 -0
- package/es/Picker/Picker.js +171 -0
- package/es/Picker/Picker.less +62 -0
- package/es/Picker/Picker.types.d.ts +98 -0
- package/es/Picker/Picker.types.js +1 -0
- package/es/Picker/PickerPanel.d.ts +5 -0
- package/es/Picker/PickerPanel.js +234 -0
- package/es/Picker/PickerPanel.less +67 -0
- package/es/Picker/index.d.ts +2 -0
- package/es/Picker/index.js +2 -0
- package/es/Picker/utils.d.ts +13 -0
- package/es/Picker/utils.js +65 -0
- package/es/Progress/Progress.less +24 -0
- package/es/Radio/Radio.less +81 -0
- package/es/Rating/Rating.less +64 -0
- package/es/ScrollView/{ScrollView.css → ScrollView.less} +4 -0
- package/es/Select/Select.less +105 -0
- package/es/Skeleton/Skeleton.less +72 -0
- package/es/Slider/Slider.less +108 -0
- package/es/Stack/demo/index.less +27 -0
- package/es/Steps/Step.less +228 -0
- package/{dist/Steps/Steps.css → es/Steps/Steps.less} +5 -3
- package/es/Swiper/Swiper.less +25 -0
- package/es/Switch/Switch.less +177 -0
- package/es/TabBar/TabBarItem.less +54 -0
- package/es/Tabs/Tab.js +1 -1
- package/es/Tabs/Tab.less +60 -0
- package/es/Tabs/TabPanel.less +11 -0
- package/es/Tabs/Tabs.less +77 -0
- package/es/Tag/Tag.less +119 -0
- package/es/Tag/TagGroup.less +52 -0
- package/es/TextArea/{TextArea.css → TextArea.less} +27 -19
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -1
- package/package.json +6 -6
- package/dist/ActionSheet/ActionSheet.css +0 -27
- package/dist/ActionSheet/ActionSheetItem.css +0 -51
- package/dist/Alert/index.css +0 -89
- package/dist/Avatar/Avatar.css +0 -43
- package/dist/Avatar/AvatarGroup.css +0 -31
- package/dist/Badge/Badge.css +0 -95
- package/dist/Button/Button.css +0 -200
- package/dist/Calendar/Calendar.css +0 -105
- package/dist/Card/CardHeader.css +0 -45
- package/dist/Checkbox/Checkbox.css +0 -45
- package/dist/Countdown/Countdown.css +0 -28
- package/dist/Divider/Divider.css +0 -41
- package/dist/Drawer/Drawer.css +0 -35
- package/dist/IconButton/IconButton.css +0 -130
- package/dist/Image/index.css +0 -35
- package/dist/Input/Input.css +0 -59
- package/dist/Loading/Loading.css +0 -31
- package/dist/NavBar/NavBar.css +0 -57
- package/dist/Progress/Progress.css +0 -22
- package/dist/Radio/Radio.css +0 -65
- package/dist/Rating/Rating.css +0 -52
- package/dist/Select/Select.css +0 -89
- package/dist/Skeleton/Skeleton.css +0 -54
- package/dist/Slider/Slider.css +0 -95
- package/dist/Stack/demo/index.css +0 -23
- package/dist/Steps/Step.css +0 -174
- package/dist/Swiper/Swiper.css +0 -20
- package/dist/Switch/Switch.css +0 -127
- package/dist/TabBar/TabBarItem.css +0 -38
- package/dist/Tabs/Tab.css +0 -52
- package/dist/Tabs/TabPanel.css +0 -9
- package/dist/Tabs/Tabs.css +0 -56
- package/dist/Tag/Tag.css +0 -97
- package/dist/Tag/TagGroup.css +0 -43
- package/es/ActionSheet/ActionSheet.css +0 -27
- package/es/ActionSheet/ActionSheetItem.css +0 -51
- package/es/Alert/index.css +0 -89
- package/es/Avatar/Avatar.css +0 -43
- package/es/Avatar/AvatarGroup.css +0 -31
- package/es/Badge/Badge.css +0 -95
- package/es/Button/Button.css +0 -200
- package/es/Calendar/Calendar.css +0 -105
- package/es/Card/CardHeader.css +0 -45
- package/es/Checkbox/Checkbox.css +0 -45
- package/es/Countdown/Countdown.css +0 -28
- package/es/Divider/Divider.css +0 -41
- package/es/Drawer/Drawer.css +0 -35
- package/es/IconButton/IconButton.css +0 -130
- package/es/Image/index.css +0 -35
- package/es/Input/Input.css +0 -59
- package/es/Loading/Loading.css +0 -31
- package/es/NavBar/NavBar.css +0 -57
- package/es/Progress/Progress.css +0 -22
- package/es/Radio/Radio.css +0 -65
- package/es/Rating/Rating.css +0 -52
- package/es/Select/Select.css +0 -89
- package/es/Skeleton/Skeleton.css +0 -54
- package/es/Slider/Slider.css +0 -95
- package/es/Stack/demo/index.css +0 -23
- package/es/Steps/Step.css +0 -174
- package/es/Swiper/Swiper.css +0 -20
- package/es/Switch/Switch.css +0 -127
- package/es/TabBar/TabBarItem.css +0 -38
- package/es/Tabs/Tab.css +0 -52
- package/es/Tabs/TabPanel.css +0 -9
- package/es/Tabs/Tabs.css +0 -56
- package/es/Tag/Tag.css +0 -97
- package/es/Tag/TagGroup.css +0 -43
- /package/dist/Card/{CardContent.css → CardContent.less} +0 -0
- /package/dist/Card/{CardFooter.css → CardFooter.less} +0 -0
- /package/dist/List/{ListItemExtra.css → ListItemExtra.less} +0 -0
- /package/dist/List/{ListItemHeader.css → ListItemHeader.less} +0 -0
- /package/dist/Stack/{Stack.css → Stack.less} +0 -0
- /package/dist/TabBar/{TabBar.css → TabBar.less} +0 -0
- /package/es/Card/{CardContent.css → CardContent.less} +0 -0
- /package/es/Card/{CardFooter.css → CardFooter.less} +0 -0
- /package/es/List/{ListItemExtra.css → ListItemExtra.less} +0 -0
- /package/es/List/{ListItemHeader.css → ListItemHeader.less} +0 -0
- /package/es/Stack/{Stack.css → Stack.less} +0 -0
- /package/es/TabBar/{TabBar.css → TabBar.less} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _utils = require("@bifrostui/utils");
|
|
10
|
+
require("./PickerPanel.css");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
const prefixCls = 'bui-picker-panel';
|
|
16
|
+
const PickerPanel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
17
|
+
const {
|
|
18
|
+
options = [],
|
|
19
|
+
defaultValue,
|
|
20
|
+
onSelect,
|
|
21
|
+
columnIndex,
|
|
22
|
+
...others
|
|
23
|
+
} = props;
|
|
24
|
+
const touch = (0, _utils.useTouch)();
|
|
25
|
+
let timer;
|
|
26
|
+
// 在手指离开屏幕时,如果和上一次 move 时的间隔小于 `INERTIA_TIME` 且 move 距离大于 `INERTIA_DISTANCE` 时,触发惯性滑动
|
|
27
|
+
const INERTIA_TIME = 300;
|
|
28
|
+
const INERTIA_DISTANCE = 15;
|
|
29
|
+
const DEFAULT_DURATION = 200;
|
|
30
|
+
const LINE_SPACING = 36;
|
|
31
|
+
const ROTATION = 20;
|
|
32
|
+
const TOUCH_END = 'end';
|
|
33
|
+
const [startY, setStartY] = (0, _react.useState)(0);
|
|
34
|
+
const [currIndex, setCurrIndex] = (0, _react.useState)(1);
|
|
35
|
+
const [startTime, setStartTime] = (0, _react.useState)(0);
|
|
36
|
+
const [touchTime, setTouchTime] = (0, _react.useState)(0);
|
|
37
|
+
const [touchDeg, setTouchDeg] = (0, _react.useState)('0deg');
|
|
38
|
+
const [scrollDistance, setScrollDistance] = (0, _react.useState)(0);
|
|
39
|
+
const transformY = (0, _react.useRef)(0);
|
|
40
|
+
const isVerticalMoving = (0, _react.useRef)(false);
|
|
41
|
+
const PickerPanelRef = (0, _react.useRef)(null);
|
|
42
|
+
const pickerPanelRef = (0, _utils.useForkRef)(PickerPanelRef, ref);
|
|
43
|
+
(0, _utils.useTouchEmulator)(PickerPanelRef.current);
|
|
44
|
+
const updateSelect = () => {
|
|
45
|
+
let index = -1;
|
|
46
|
+
if (defaultValue) {
|
|
47
|
+
options.some((item, idx) => {
|
|
48
|
+
if (item.value === defaultValue) {
|
|
49
|
+
index = idx;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
setCurrIndex(index === -1 ? 1 : index + 1);
|
|
56
|
+
const move = index === -1 ? 0 : index * LINE_SPACING;
|
|
57
|
+
setMove({
|
|
58
|
+
move: -move
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
(0, _react.useEffect)(() => {
|
|
62
|
+
setScrollDistance(0);
|
|
63
|
+
transformY.current = 0;
|
|
64
|
+
updateSelect();
|
|
65
|
+
return () => {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
};
|
|
68
|
+
}, [options]);
|
|
69
|
+
const setTransform = (type, deg, time = DEFAULT_DURATION, translateY = 0) => {
|
|
70
|
+
let nTime = time;
|
|
71
|
+
if (type !== TOUCH_END) {
|
|
72
|
+
nTime = 0;
|
|
73
|
+
}
|
|
74
|
+
setTouchTime(nTime);
|
|
75
|
+
setTouchDeg(deg);
|
|
76
|
+
setScrollDistance(translateY);
|
|
77
|
+
};
|
|
78
|
+
const setMove = config => {
|
|
79
|
+
const {
|
|
80
|
+
move,
|
|
81
|
+
type,
|
|
82
|
+
time
|
|
83
|
+
} = config || {};
|
|
84
|
+
let updateMove = move + transformY.current;
|
|
85
|
+
if (type === TOUCH_END) {
|
|
86
|
+
// 限定滚动距离
|
|
87
|
+
if (updateMove > 0) {
|
|
88
|
+
updateMove = 0;
|
|
89
|
+
}
|
|
90
|
+
if (updateMove < -(options.length - 1) * LINE_SPACING) {
|
|
91
|
+
updateMove = -(options.length - 1) * LINE_SPACING;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 设置滚动距离为LINE_SPACING的倍数值
|
|
95
|
+
const endMove = Math.round(updateMove / LINE_SPACING) * LINE_SPACING;
|
|
96
|
+
const deg = `${(Math.abs(Math.round(endMove / LINE_SPACING)) + 1) * ROTATION}deg`;
|
|
97
|
+
setTransform(type, deg, time, endMove);
|
|
98
|
+
setCurrIndex(Math.abs(Math.round(endMove / LINE_SPACING)) + 1);
|
|
99
|
+
} else {
|
|
100
|
+
let deg = 0;
|
|
101
|
+
const currentDeg = (-updateMove / LINE_SPACING + 1) * ROTATION;
|
|
102
|
+
|
|
103
|
+
// picker 滚动的最大角度
|
|
104
|
+
const maxDeg = (options.length + 1) * ROTATION;
|
|
105
|
+
const minDeg = 0;
|
|
106
|
+
deg = Math.min(Math.max(currentDeg, minDeg), maxDeg);
|
|
107
|
+
if (minDeg < deg && deg < maxDeg) {
|
|
108
|
+
setTransform('', `${deg}deg`, undefined, updateMove);
|
|
109
|
+
setCurrIndex(Math.abs(Math.round(updateMove / LINE_SPACING)) + 1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// 惯性滚动距离
|
|
115
|
+
const momentum = (distance, duration) => {
|
|
116
|
+
let nDistance = distance;
|
|
117
|
+
// 惯性滚动的速度
|
|
118
|
+
const speed = Math.abs(nDistance / duration);
|
|
119
|
+
// 惯性滚动的距离
|
|
120
|
+
nDistance = speed / 0.003 * (nDistance < 0 ? -1 : 1);
|
|
121
|
+
return nDistance;
|
|
122
|
+
};
|
|
123
|
+
const panelTouchStart = event => {
|
|
124
|
+
touch.start(event);
|
|
125
|
+
setStartY(touch.deltaY.current);
|
|
126
|
+
setStartTime(Date.now());
|
|
127
|
+
transformY.current = scrollDistance;
|
|
128
|
+
};
|
|
129
|
+
const panelTouchMove = event => {
|
|
130
|
+
touch.move(event);
|
|
131
|
+
if (touch.isVertical) {
|
|
132
|
+
isVerticalMoving.current = true;
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
}
|
|
136
|
+
const move = touch.deltaY.current - startY;
|
|
137
|
+
setMove({
|
|
138
|
+
move
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
const panelTouchEnd = () => {
|
|
142
|
+
if (!isVerticalMoving.current) return;
|
|
143
|
+
const move = touch.deltaY.current - startY;
|
|
144
|
+
const moveTime = Date.now() - startTime;
|
|
145
|
+
if (moveTime <= INERTIA_TIME && Math.abs(move) > INERTIA_DISTANCE) {
|
|
146
|
+
// 惯性滚动
|
|
147
|
+
const distance = momentum(move, moveTime);
|
|
148
|
+
setMove({
|
|
149
|
+
move: distance,
|
|
150
|
+
type: TOUCH_END,
|
|
151
|
+
time: 1000
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
// 非惯性滚动
|
|
155
|
+
setMove({
|
|
156
|
+
move,
|
|
157
|
+
type: TOUCH_END
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
timer = setTimeout(() => {
|
|
161
|
+
touch.reset();
|
|
162
|
+
}, 0);
|
|
163
|
+
};
|
|
164
|
+
(0, _react.useEffect)(() => {
|
|
165
|
+
PickerPanelRef.current?.addEventListener('touchstart', panelTouchStart);
|
|
166
|
+
PickerPanelRef.current?.addEventListener('touchmove', panelTouchMove);
|
|
167
|
+
PickerPanelRef.current?.addEventListener('touchend', panelTouchEnd);
|
|
168
|
+
return () => {
|
|
169
|
+
PickerPanelRef.current?.removeEventListener('touchstart', panelTouchStart);
|
|
170
|
+
PickerPanelRef.current?.removeEventListener('touchmove', panelTouchMove);
|
|
171
|
+
PickerPanelRef.current?.removeEventListener('touchend', panelTouchEnd);
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
const onTransitionEnd = e => {
|
|
175
|
+
isVerticalMoving.current = false;
|
|
176
|
+
setTouchTime(0);
|
|
177
|
+
onSelect?.(e, {
|
|
178
|
+
columnOption: options?.[Math.round(-scrollDistance / LINE_SPACING)],
|
|
179
|
+
columnIndex
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
183
|
+
className: prefixCls,
|
|
184
|
+
ref: pickerPanelRef,
|
|
185
|
+
onTouchStart: panelTouchStart,
|
|
186
|
+
onTouchMove: panelTouchMove,
|
|
187
|
+
onTouchEnd: panelTouchEnd
|
|
188
|
+
}, others), /*#__PURE__*/_react.default.createElement("div", {
|
|
189
|
+
className: `${prefixCls}-roller`,
|
|
190
|
+
style: {
|
|
191
|
+
transition: `transform ${touchTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
|
|
192
|
+
transform: `rotate3d(1, 0, 0, ${touchDeg})`
|
|
193
|
+
},
|
|
194
|
+
onTransitionEnd: onTransitionEnd
|
|
195
|
+
}, options.map((item, i) => /*#__PURE__*/_react.default.createElement("div", {
|
|
196
|
+
className: (0, _clsx.default)(`${prefixCls}-option`, {
|
|
197
|
+
[`${prefixCls}-option-hidden`]: i + 1 <= currIndex - 8 || i + 1 >= currIndex + 8
|
|
198
|
+
}),
|
|
199
|
+
key: `${item?.value}-${i}`,
|
|
200
|
+
style: {
|
|
201
|
+
transform: `rotate3d(1, 0, 0, ${-ROTATION * (i + 1)}deg) translate3d(0px, 0px, 104px)`
|
|
202
|
+
}
|
|
203
|
+
}, item?.label))), /*#__PURE__*/_react.default.createElement("div", {
|
|
204
|
+
className: `${prefixCls}-mask`
|
|
205
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
206
|
+
className: `${prefixCls}-indicator`
|
|
207
|
+
}));
|
|
208
|
+
});
|
|
209
|
+
PickerPanel.displayName = 'BuiPickerPanel';
|
|
210
|
+
var _default = exports.default = PickerPanel;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@import '~@bifrostui/styles/mixins/index.less';
|
|
2
|
+
|
|
3
|
+
.bui-picker-panel {
|
|
4
|
+
flex: 1;
|
|
5
|
+
flex-shrink: 0;
|
|
6
|
+
position: relative;
|
|
7
|
+
font-family: var(--bui-font-family);
|
|
8
|
+
|
|
9
|
+
&-roller {
|
|
10
|
+
transform: rotate3d(1, 0, 0, 60deg);
|
|
11
|
+
transform-style: preserve-3d;
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: var(--indicator-top);
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: var(--option-height);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-mask {
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
background-image: linear-gradient(
|
|
25
|
+
180deg,
|
|
26
|
+
var(--bui-color-bg-view-opacity-9),
|
|
27
|
+
var(--bui-color-bg-view-opacity-4)
|
|
28
|
+
),
|
|
29
|
+
linear-gradient(
|
|
30
|
+
0deg,
|
|
31
|
+
var(--bui-color-bg-view-opacity-9),
|
|
32
|
+
var(--bui-color-bg-view-opacity-4)
|
|
33
|
+
);
|
|
34
|
+
background-position: top, bottom;
|
|
35
|
+
background-size: 100% var(--indicator-top);
|
|
36
|
+
background-repeat: no-repeat;
|
|
37
|
+
transform: translateZ(0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&-indicator {
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: var(--indicator-top);
|
|
43
|
+
height: var(--indicator-height);
|
|
44
|
+
width: 100%;
|
|
45
|
+
border-top: 1px solid var(--indicator-border-color);
|
|
46
|
+
border-bottom: 1px solid var(--indicator-border-color);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&-option {
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 0;
|
|
52
|
+
left: 0;
|
|
53
|
+
text-align: center;
|
|
54
|
+
height: var(--option-height);
|
|
55
|
+
line-height: var(--option-height);
|
|
56
|
+
color: var(--option-color);
|
|
57
|
+
font-size: var(--option-font-size);
|
|
58
|
+
backface-visibility: hidden;
|
|
59
|
+
.ellipsis();
|
|
60
|
+
width: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&-option-hidden {
|
|
64
|
+
visibility: hidden;
|
|
65
|
+
opacity: 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
Picker: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "Picker", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _Picker.default;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "default", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _Picker.default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
var _Picker = _interopRequireDefault(require("./Picker"));
|
|
22
|
+
var _Picker2 = require("./Picker.types");
|
|
23
|
+
Object.keys(_Picker2).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
+
if (key in exports && exports[key] === _Picker2[key]) return;
|
|
27
|
+
Object.defineProperty(exports, key, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _Picker2[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ICascadePickerOptionItem } from './Picker.types';
|
|
2
|
+
/**
|
|
3
|
+
* 根据第一列数据判断选择器类型
|
|
4
|
+
*/
|
|
5
|
+
export declare const pickerPanelType: (options?: any[]) => "multiple" | "single" | "cascade";
|
|
6
|
+
/**
|
|
7
|
+
* 格式化级联模式数据
|
|
8
|
+
*/
|
|
9
|
+
export declare const formatCascade: (columns: ICascadePickerOptionItem[], values?: (number | string)[]) => ICascadePickerOptionItem[][];
|
|
10
|
+
/**
|
|
11
|
+
* 统一options数据格式
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatOptions: (internalValue: any, options?: any[]) => any[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pickerPanelType = exports.formatOptions = exports.formatCascade = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* 根据第一列数据判断选择器类型
|
|
9
|
+
*/
|
|
10
|
+
const pickerPanelType = (options = []) => {
|
|
11
|
+
const firstColumn = options[0];
|
|
12
|
+
|
|
13
|
+
// 多列模式
|
|
14
|
+
if (Array.isArray(firstColumn)) {
|
|
15
|
+
return 'multiple';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 级联模式
|
|
19
|
+
if (firstColumn?.children) {
|
|
20
|
+
return 'cascade';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 单列模式
|
|
24
|
+
return 'single';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 格式化级联模式数据
|
|
29
|
+
*/
|
|
30
|
+
exports.pickerPanelType = pickerPanelType;
|
|
31
|
+
const formatCascade = (columns, values) => {
|
|
32
|
+
const result = [];
|
|
33
|
+
let columnOptions = {
|
|
34
|
+
label: '',
|
|
35
|
+
value: '',
|
|
36
|
+
children: columns
|
|
37
|
+
};
|
|
38
|
+
let columnIndex = 0;
|
|
39
|
+
while (columnOptions?.children) {
|
|
40
|
+
const options = columnOptions.children;
|
|
41
|
+
const value = values?.[columnIndex];
|
|
42
|
+
let index = options.findIndex(item => item.value === value);
|
|
43
|
+
if (index === -1) index = 0;
|
|
44
|
+
columnOptions = columnOptions.children[index];
|
|
45
|
+
columnIndex += 1;
|
|
46
|
+
result.push(options);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 统一options数据格式
|
|
53
|
+
*/
|
|
54
|
+
exports.formatCascade = formatCascade;
|
|
55
|
+
const formatOptions = (internalValue, options = []) => {
|
|
56
|
+
const panelType = pickerPanelType(options);
|
|
57
|
+
switch (panelType) {
|
|
58
|
+
case 'multiple':
|
|
59
|
+
return options;
|
|
60
|
+
case 'cascade':
|
|
61
|
+
return formatCascade(options, internalValue);
|
|
62
|
+
default:
|
|
63
|
+
return options;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.formatOptions = formatOptions;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.bui-progress {
|
|
2
|
+
--fill-color: var(--bui-color-primary);
|
|
3
|
+
--trail-color: rgba(156, 156, 165, 0.2);
|
|
4
|
+
--stroke-width: 8px;
|
|
5
|
+
width: 100%;
|
|
6
|
+
font-family: var(--bui-font-family);
|
|
7
|
+
|
|
8
|
+
&-inner {
|
|
9
|
+
position: relative;
|
|
10
|
+
display: inline-block;
|
|
11
|
+
width: 100%;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
vertical-align: middle;
|
|
14
|
+
background-color: var(--trail-color);
|
|
15
|
+
border-radius: 100px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-bg {
|
|
19
|
+
position: relative;
|
|
20
|
+
border-radius: 100px;
|
|
21
|
+
background-color: var(--fill-color);
|
|
22
|
+
height: var(--stroke-width);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.bui-radio {
|
|
2
|
+
--label-color: var(--bui-color-fg-default);
|
|
3
|
+
--label-font-size: var(--bui-text-size-1);
|
|
4
|
+
--icon-font-size: var(--bui-title-size-2);
|
|
5
|
+
@iconSize: 16px;
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
position: relative;
|
|
9
|
+
font-family: var(--bui-font-family);
|
|
10
|
+
|
|
11
|
+
&-disabled {
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
opacity: 0.5;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&-label-left {
|
|
17
|
+
flex-direction: row-reverse;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&-label-top {
|
|
21
|
+
flex-direction: column-reverse;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&-label-bottom {
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&-input {
|
|
29
|
+
opacity: 0;
|
|
30
|
+
// 解决onClick触发两次的问题 & 微信文案点击选中
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
z-index: 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&-icon {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
flex-shrink: 0;
|
|
45
|
+
padding: 5px;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&-label {
|
|
50
|
+
font-size: var(--label-font-size);
|
|
51
|
+
color: var(--label-color);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&-btn-icon {
|
|
55
|
+
position: relative;
|
|
56
|
+
display: flex;
|
|
57
|
+
|
|
58
|
+
.bui-svg-icon {
|
|
59
|
+
font-size: var(--icon-font-size);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&-outline {
|
|
63
|
+
transform: scale(1);
|
|
64
|
+
transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&-contained {
|
|
68
|
+
position: absolute;
|
|
69
|
+
left: 0;
|
|
70
|
+
transform: scale(0);
|
|
71
|
+
transition: transform 150ms cubic-bezier(0.4, 0, 1, 1) 0ms;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&-checked {
|
|
75
|
+
.bui-radio-btn-icon-contained {
|
|
76
|
+
transform: scale(1);
|
|
77
|
+
transition: transform 150ms cubic-bezier(0, 0, 0.2, 1) 0ms;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.bui-rating {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
font-family: var(--bui-font-family);
|
|
5
|
+
|
|
6
|
+
&-disabled {
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
opacity: 0.5;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&-container {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: flex;
|
|
14
|
+
|
|
15
|
+
&:last-child {
|
|
16
|
+
margin-right: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-xsmall {
|
|
20
|
+
font-size: var(--bui-text-size-5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-small {
|
|
24
|
+
font-size: var(--bui-text-size-1);
|
|
25
|
+
margin-right: 0.5px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&-medium {
|
|
29
|
+
font-size: var(--bui-title-size-3);
|
|
30
|
+
margin-right: 1px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-large {
|
|
34
|
+
font-size: 22px;
|
|
35
|
+
margin-right: 2px;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&-item {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
color: var(--bui-color-fg-disabled);
|
|
45
|
+
|
|
46
|
+
&-input {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&-half {
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 0;
|
|
53
|
+
width: 50%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&-readonly {
|
|
57
|
+
cursor: unset;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&-active {
|
|
61
|
+
color: var(--bui-color-warning);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
position: relative;
|
|
4
4
|
font-family: var(--bui-font-family);
|
|
5
5
|
}
|
|
6
|
+
|
|
6
7
|
.bui-scroll::-webkit-scrollbar {
|
|
7
8
|
display: none;
|
|
8
9
|
}
|
|
10
|
+
|
|
9
11
|
.bui-scroll-view {
|
|
10
12
|
overflow: hidden;
|
|
11
13
|
}
|
|
14
|
+
|
|
12
15
|
.bui-scroll-view-scroll-x {
|
|
13
16
|
overflow-x: scroll;
|
|
14
17
|
overflow-y: hidden;
|
|
15
18
|
}
|
|
19
|
+
|
|
16
20
|
.bui-scroll-view-scroll-y {
|
|
17
21
|
overflow-x: hidden;
|
|
18
22
|
overflow-y: scroll;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
@class-prefix-select: ~'bui-select';
|
|
2
|
+
@transition-duration: 0.3s;
|
|
3
|
+
|
|
4
|
+
.@{class-prefix-select} {
|
|
5
|
+
position: relative;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
height: 27px;
|
|
8
|
+
min-width: 100px;
|
|
9
|
+
font-size: var(--bui-title-size-3);
|
|
10
|
+
border-radius: 5px;
|
|
11
|
+
background-color: var(--bui-color-bg-view);
|
|
12
|
+
font-family: var(--bui-font-family);
|
|
13
|
+
|
|
14
|
+
&:active,
|
|
15
|
+
&-active {
|
|
16
|
+
box-shadow: 0 0 0 2px var(--bui-color-bg-default);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-selector-container {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
padding: 0 14px;
|
|
23
|
+
height: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&-input {
|
|
27
|
+
width: 0;
|
|
28
|
+
height: 0;
|
|
29
|
+
border: 0;
|
|
30
|
+
opacity: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-placeholder {
|
|
34
|
+
color: var(--bui-color-fg-disabled);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-selector {
|
|
38
|
+
display: flex;
|
|
39
|
+
justify-content: space-between;
|
|
40
|
+
align-items: center;
|
|
41
|
+
flex: 1;
|
|
42
|
+
height: 27px;
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
outline: none;
|
|
45
|
+
border: 0;
|
|
46
|
+
|
|
47
|
+
&-icon {
|
|
48
|
+
font-size: var(--bui-title-size-3);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&-option-container {
|
|
53
|
+
position: absolute;
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
top: 100%;
|
|
56
|
+
left: 0;
|
|
57
|
+
width: 100%;
|
|
58
|
+
z-index: var(--bui-z-index-dropdown);
|
|
59
|
+
margin-top: 6px;
|
|
60
|
+
background-color: var(--bui-color-bg-view);
|
|
61
|
+
padding: 2px;
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&-option-main {
|
|
66
|
+
border-radius: 3px;
|
|
67
|
+
padding: 3px 0;
|
|
68
|
+
box-shadow: 0 0 0 2px var(--bui-color-bg-default);
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&-option {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
height: 27px;
|
|
76
|
+
padding: 0 14px;
|
|
77
|
+
border-radius: 5px;
|
|
78
|
+
margin: 0 3px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&-option:hover {
|
|
82
|
+
background-color: var(---bui-select-options-active-bg, #fff2f0);
|
|
83
|
+
color: var(--bui-color-primary);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&-option-active {
|
|
87
|
+
font-weight: 500;
|
|
88
|
+
color: var(--bui-color-primary);
|
|
89
|
+
background-color: var(---bui-select-options-active-bg, #fff2f0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&-option-hide {
|
|
93
|
+
opacity: 0;
|
|
94
|
+
transform: translateY(-5px);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.bui-select.bui-select-disabled,
|
|
99
|
+
.bui-select-option-disabled {
|
|
100
|
+
pointer-events: none;
|
|
101
|
+
box-shadow: none;
|
|
102
|
+
background-color: var(--bui-color-bg-view);
|
|
103
|
+
color: var(--bui-color-fg-subtle);
|
|
104
|
+
border: none;
|
|
105
|
+
}
|