@nutui/nutui-react-taro 3.0.13 → 3.0.15
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/CHANGELOG.md +45 -12
- package/dist/cjs/packages/button/style/button.scss +3 -0
- package/dist/cjs/packages/button/style/style.css +3 -3
- package/dist/cjs/packages/button/style/style.harmony.css +12 -0
- package/dist/cjs/packages/button/style-jmapp/button.scss +3 -0
- package/dist/cjs/packages/button/style-jmapp/style.css +3 -3
- package/dist/cjs/packages/button/style-jrkf/button.scss +3 -0
- package/dist/cjs/packages/button/style-jrkf/style.css +3 -3
- package/dist/cjs/packages/calendarcard/calendarcard.js +10 -4
- package/dist/cjs/packages/configprovider/types.d.ts +1 -1
- package/dist/cjs/packages/datepicker/utils.js +23 -38
- package/dist/cjs/packages/dialog/dialog.js +2 -7
- package/dist/cjs/packages/elevator/elevator.d.ts +3 -20
- package/dist/cjs/packages/elevator/elevator.js +119 -91
- package/dist/cjs/packages/elevator/index.d.ts +1 -1
- package/dist/cjs/packages/elevator/style/elevator.scss +61 -33
- package/dist/cjs/packages/elevator/style/style.css +65 -40
- package/dist/cjs/packages/elevator/style/style.harmony.css +69 -41
- package/dist/cjs/packages/elevator/style-jmapp/elevator.scss +61 -33
- package/dist/cjs/packages/elevator/style-jmapp/style.css +56 -31
- package/dist/cjs/packages/elevator/style-jrkf/elevator.scss +61 -33
- package/dist/cjs/packages/elevator/style-jrkf/style.css +56 -31
- package/dist/cjs/packages/formitem/formitem.js +2 -2
- package/dist/cjs/packages/formitem/style/formitem.scss +14 -15
- package/dist/cjs/packages/formitem/style/style.css +9 -11
- package/dist/cjs/packages/formitem/style/style.harmony.css +8 -10
- package/dist/cjs/packages/formitem/style-jmapp/formitem.scss +14 -15
- package/dist/cjs/packages/formitem/style-jmapp/style.css +8 -10
- package/dist/cjs/packages/formitem/style-jrkf/formitem.scss +14 -15
- package/dist/cjs/packages/formitem/style-jrkf/style.css +8 -10
- package/dist/cjs/packages/image/image.js +2 -2
- package/dist/cjs/packages/input/input.js +1 -1
- package/dist/cjs/packages/navbar/style/navbar.scss +2 -0
- package/dist/cjs/packages/navbar/style/style.css +2 -0
- package/dist/cjs/packages/navbar/style/style.harmony.css +2 -0
- package/dist/cjs/packages/navbar/style-jmapp/navbar.scss +2 -0
- package/dist/cjs/packages/navbar/style-jmapp/style.css +2 -0
- package/dist/cjs/packages/navbar/style-jrkf/navbar.scss +2 -0
- package/dist/cjs/packages/navbar/style-jrkf/style.css +2 -0
- package/dist/cjs/packages/noticebar/noticebar.js +1 -1
- package/dist/cjs/packages/overlay/style/overlay.scss +0 -1
- package/dist/cjs/packages/overlay/style/style.css +0 -1
- package/dist/cjs/packages/overlay/style/style.harmony.css +0 -1
- package/dist/cjs/packages/overlay/style-jmapp/overlay.scss +0 -1
- package/dist/cjs/packages/overlay/style-jmapp/style.css +0 -1
- package/dist/cjs/packages/overlay/style-jrkf/overlay.scss +0 -1
- package/dist/cjs/packages/overlay/style-jrkf/style.css +0 -1
- package/dist/cjs/packages/pickerview/pickerroller.js +9 -1
- package/dist/cjs/packages/switch/switch.js +0 -1
- package/dist/cjs/packages/tabpane/style/style.css +1 -1
- package/dist/cjs/packages/tabpane/style/tabpane.scss +1 -1
- package/dist/cjs/packages/tabpane/style-jmapp/style.css +1 -1
- package/dist/cjs/packages/tabpane/style-jmapp/tabpane.scss +1 -1
- package/dist/cjs/packages/tabpane/style-jrkf/style.css +1 -1
- package/dist/cjs/packages/tabpane/style-jrkf/tabpane.scss +1 -1
- package/dist/cjs/types/spec/calendarcard/base.d.ts +1 -0
- package/dist/cjs/types/spec/datepicker/base.d.ts +1 -1
- package/dist/cjs/types/spec/elevator/base.d.ts +5 -2
- package/dist/es/packages/button/style/button.scss +3 -0
- package/dist/es/packages/button/style/style.css +3 -3
- package/dist/es/packages/button/style/style.harmony.css +12 -0
- package/dist/es/packages/button/style-jmapp/button.scss +3 -0
- package/dist/es/packages/button/style-jmapp/style.css +3 -3
- package/dist/es/packages/button/style-jrkf/button.scss +3 -0
- package/dist/es/packages/button/style-jrkf/style.css +3 -3
- package/dist/es/packages/calendarcard/calendarcard.js +11 -5
- package/dist/es/packages/configprovider/types.d.ts +1 -1
- package/dist/es/packages/datepicker/utils.js +23 -38
- package/dist/es/packages/dialog/dialog.js +2 -7
- package/dist/es/packages/elevator/elevator.d.ts +3 -20
- package/dist/es/packages/elevator/elevator.js +119 -91
- package/dist/es/packages/elevator/index.d.ts +1 -1
- package/dist/es/packages/elevator/style/elevator.scss +61 -33
- package/dist/es/packages/elevator/style/style.css +65 -40
- package/dist/es/packages/elevator/style/style.harmony.css +69 -41
- package/dist/es/packages/elevator/style-jmapp/elevator.scss +61 -33
- package/dist/es/packages/elevator/style-jmapp/style.css +56 -31
- package/dist/es/packages/elevator/style-jrkf/elevator.scss +61 -33
- package/dist/es/packages/elevator/style-jrkf/style.css +56 -31
- package/dist/es/packages/formitem/formitem.js +2 -2
- package/dist/es/packages/formitem/style/formitem.scss +14 -15
- package/dist/es/packages/formitem/style/style.css +9 -11
- package/dist/es/packages/formitem/style/style.harmony.css +8 -10
- package/dist/es/packages/formitem/style-jmapp/formitem.scss +14 -15
- package/dist/es/packages/formitem/style-jmapp/style.css +8 -10
- package/dist/es/packages/formitem/style-jrkf/formitem.scss +14 -15
- package/dist/es/packages/formitem/style-jrkf/style.css +8 -10
- package/dist/es/packages/image/image.js +2 -2
- package/dist/es/packages/input/input.js +1 -1
- package/dist/es/packages/navbar/style/navbar.scss +2 -0
- package/dist/es/packages/navbar/style/style.css +2 -0
- package/dist/es/packages/navbar/style/style.harmony.css +2 -0
- package/dist/es/packages/navbar/style-jmapp/navbar.scss +2 -0
- package/dist/es/packages/navbar/style-jmapp/style.css +2 -0
- package/dist/es/packages/navbar/style-jrkf/navbar.scss +2 -0
- package/dist/es/packages/navbar/style-jrkf/style.css +2 -0
- package/dist/es/packages/noticebar/noticebar.js +1 -1
- package/dist/es/packages/overlay/style/overlay.scss +0 -1
- package/dist/es/packages/overlay/style/style.css +0 -1
- package/dist/es/packages/overlay/style/style.harmony.css +0 -1
- package/dist/es/packages/overlay/style-jmapp/overlay.scss +0 -1
- package/dist/es/packages/overlay/style-jmapp/style.css +0 -1
- package/dist/es/packages/overlay/style-jrkf/overlay.scss +0 -1
- package/dist/es/packages/overlay/style-jrkf/style.css +0 -1
- package/dist/es/packages/pickerview/pickerroller.js +9 -1
- package/dist/es/packages/switch/switch.js +0 -1
- package/dist/es/packages/tabpane/style/style.css +1 -1
- package/dist/es/packages/tabpane/style/tabpane.scss +1 -1
- package/dist/es/packages/tabpane/style-jmapp/style.css +1 -1
- package/dist/es/packages/tabpane/style-jmapp/tabpane.scss +1 -1
- package/dist/es/packages/tabpane/style-jrkf/style.css +1 -1
- package/dist/es/packages/tabpane/style-jrkf/tabpane.scss +1 -1
- package/dist/es/types/spec/calendarcard/base.d.ts +4 -0
- package/dist/es/types/spec/datepicker/base.d.ts +1 -1
- package/dist/es/types/spec/elevator/base.d.ts +15 -6
- package/dist/nutui.react.umd.js +904 -888
- package/dist/style-jmapp.css +1 -1
- package/dist/style-jmapp.scss +31 -31
- package/dist/style-jrkf.css +1 -1
- package/dist/style-jrkf.scss +29 -29
- package/dist/style.css +1 -1
- package/dist/style.scss +26 -26
- package/dist/styles/variables-jmapp.scss +14 -2
- package/dist/styles/variables-jrkf.scss +14 -2
- package/dist/styles/variables.scss +25 -45
- package/package.json +1 -1
|
@@ -65,8 +65,6 @@ export var BaseDialog = function(props) {
|
|
|
65
65
|
var handleCancel = function(e) {
|
|
66
66
|
e.stopPropagation();
|
|
67
67
|
if (!(beforeCancel === null || beforeCancel === void 0 ? void 0 : beforeCancel())) return;
|
|
68
|
-
if (!(beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose())) return;
|
|
69
|
-
onClose();
|
|
70
68
|
onCancel();
|
|
71
69
|
};
|
|
72
70
|
var handleOk = /*#__PURE__*/ function() {
|
|
@@ -152,24 +150,21 @@ export var BaseDialog = function(props) {
|
|
|
152
150
|
};
|
|
153
151
|
var renderCloseIcon = function() {
|
|
154
152
|
if (!closeIcon) return null;
|
|
155
|
-
var
|
|
156
|
-
if (!(beforeCancel === null || beforeCancel === void 0 ? void 0 : beforeCancel())) return;
|
|
153
|
+
var handleClose = function() {
|
|
157
154
|
if (!(beforeClose === null || beforeClose === void 0 ? void 0 : beforeClose())) return;
|
|
158
155
|
onClose();
|
|
159
|
-
onCancel();
|
|
160
156
|
};
|
|
161
157
|
var _obj;
|
|
162
158
|
var closeClasses = classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-close"), true), _define_property(_obj, "".concat(classPrefix, "-close-").concat(closeIconPosition), true), _obj));
|
|
163
159
|
var systomIcon = closeIconPosition !== 'bottom' ? /*#__PURE__*/ React.createElement(Close, null) : /*#__PURE__*/ React.createElement(Failure, null);
|
|
164
160
|
return /*#__PURE__*/ React.createElement(View, {
|
|
165
161
|
className: closeClasses,
|
|
166
|
-
onClick:
|
|
162
|
+
onClick: handleClose
|
|
167
163
|
}, /*#__PURE__*/ React.isValidElement(closeIcon) ? closeIcon : systomIcon);
|
|
168
164
|
};
|
|
169
165
|
var onHandleClickOverlay = function(e) {
|
|
170
166
|
if (closeOnOverlayClick && visible && e.target === e.currentTarget) {
|
|
171
167
|
var closed = onOverlayClick && onOverlayClick(e);
|
|
172
|
-
closed && onClose();
|
|
173
168
|
closed && onCancel();
|
|
174
169
|
}
|
|
175
170
|
};
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import React, { FunctionComponent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export declare const elevatorContext: React.Context<
|
|
4
|
-
export
|
|
5
|
-
height: number | string;
|
|
6
|
-
floorKey: string;
|
|
7
|
-
list: any[];
|
|
8
|
-
sticky: boolean;
|
|
9
|
-
spaceHeight: number;
|
|
10
|
-
titleHeight: number;
|
|
11
|
-
showKeys: boolean;
|
|
12
|
-
onItemClick: (key: string, item: ElevatorData) => void;
|
|
13
|
-
onIndexClick: (key: string) => void;
|
|
14
|
-
}
|
|
15
|
-
interface ElevatorData {
|
|
16
|
-
name: string;
|
|
17
|
-
id: number | string;
|
|
18
|
-
[key: string]: string | number;
|
|
19
|
-
}
|
|
20
|
-
export declare const Elevator: FunctionComponent<Partial<ElevatorProps> & React.HTMLAttributes<HTMLDivElement>> & {
|
|
2
|
+
import { ElevatorItem, TaroElevatorProps } from "../../types";
|
|
3
|
+
export declare const elevatorContext: React.Context<ElevatorItem>;
|
|
4
|
+
export declare const Elevator: FunctionComponent<Partial<TaroElevatorProps> & React.HTMLAttributes<HTMLDivElement>> & {
|
|
21
5
|
Context: typeof elevatorContext;
|
|
22
6
|
};
|
|
23
|
-
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
1
2
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
3
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
4
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
5
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
5
6
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
|
-
import { _ as
|
|
7
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
8
|
import React, { useEffect, useRef, useState, createContext, useMemo } from "react";
|
|
8
9
|
import Taro, { nextTick, createSelectorQuery } from "@tarojs/taro";
|
|
9
10
|
import { ScrollView, View, Text } from "@tarojs/components";
|
|
@@ -11,25 +12,30 @@ import classNames from "classnames";
|
|
|
11
12
|
import { ComponentDefaults } from "../../utils/typings";
|
|
12
13
|
import { harmony } from "../../utils/taro/platform";
|
|
13
14
|
import { useUuid } from "../../hooks/use-uuid";
|
|
15
|
+
import raf from "../../utils/raf";
|
|
16
|
+
import { usePropsValue } from "../../hooks";
|
|
14
17
|
export var elevatorContext = /*#__PURE__*/ createContext({});
|
|
15
18
|
var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
|
|
19
|
+
mode: 'horizontal',
|
|
16
20
|
height: '200px',
|
|
17
21
|
floorKey: 'title',
|
|
18
22
|
list: [],
|
|
19
23
|
sticky: false,
|
|
20
|
-
spaceHeight:
|
|
21
|
-
titleHeight: 35,
|
|
24
|
+
spaceHeight: 18,
|
|
22
25
|
showKeys: true,
|
|
23
|
-
|
|
26
|
+
defaultValue: undefined,
|
|
27
|
+
value: undefined
|
|
24
28
|
});
|
|
25
29
|
export var Elevator = function(props) {
|
|
26
|
-
var _ref = _object_spread({}, defaultProps, props), height = _ref.height, floorKey = _ref.floorKey, list = _ref.list, sticky = _ref.sticky, spaceHeight = _ref.spaceHeight,
|
|
30
|
+
var _ref = _object_spread({}, defaultProps, props), value = _ref.value, defaultValue = _ref.defaultValue, mode = _ref.mode, height = _ref.height, floorKey = _ref.floorKey, list = _ref.list, sticky = _ref.sticky, spaceHeight = _ref.spaceHeight, showKeys = _ref.showKeys, className = _ref.className, style = _ref.style, onItemClick = _ref.onItemClick, onIndexClick = _ref.onIndexClick, children = _ref.children, rest = _object_without_properties(_ref, [
|
|
31
|
+
"value",
|
|
32
|
+
"defaultValue",
|
|
33
|
+
"mode",
|
|
27
34
|
"height",
|
|
28
35
|
"floorKey",
|
|
29
36
|
"list",
|
|
30
37
|
"sticky",
|
|
31
38
|
"spaceHeight",
|
|
32
|
-
"titleHeight",
|
|
33
39
|
"showKeys",
|
|
34
40
|
"className",
|
|
35
41
|
"style",
|
|
@@ -39,25 +45,25 @@ export var Elevator = function(props) {
|
|
|
39
45
|
]);
|
|
40
46
|
var uuid = useUuid();
|
|
41
47
|
var classPrefix = 'nut-elevator';
|
|
42
|
-
var listview = useRef(null);
|
|
43
48
|
var initData = {
|
|
44
49
|
anchorIndex: 0,
|
|
45
50
|
listHeight: [],
|
|
46
|
-
listGroup: [],
|
|
47
51
|
scrollY: 0
|
|
48
52
|
};
|
|
49
53
|
var touchState = useRef({
|
|
50
54
|
y1: 0,
|
|
51
55
|
y2: 0
|
|
52
56
|
});
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
var _usePropsValue = _sliced_to_array(usePropsValue({
|
|
58
|
+
value: value,
|
|
59
|
+
defaultValue: defaultValue || {}
|
|
60
|
+
}), 2), currentData = _usePropsValue[0], setCurrentData = _usePropsValue[1];
|
|
61
|
+
var _useState = _sliced_to_array(useState(0), 2), codeIndex = _useState[0], setCodeIndex = _useState[1];
|
|
62
|
+
var _useState1 = _sliced_to_array(useState(false), 2), scrollStart = _useState1[0], setScrollStart = _useState1[1];
|
|
57
63
|
var state = useRef(initData);
|
|
58
64
|
var scrolling = useRef(false);
|
|
59
|
-
var
|
|
60
|
-
var
|
|
65
|
+
var _useState2 = _sliced_to_array(useState(0), 2), scrollTop = _useState2[0], setScrollTop = _useState2[1];
|
|
66
|
+
var _useState3 = _sliced_to_array(useState(0), 2), scrollY = _useState3[0], setScrollY = _useState3[1];
|
|
61
67
|
var resetScrollState = function() {
|
|
62
68
|
setScrollStart(false);
|
|
63
69
|
};
|
|
@@ -68,39 +74,71 @@ export var Elevator = function(props) {
|
|
|
68
74
|
return el.dataset.index;
|
|
69
75
|
};
|
|
70
76
|
var calculateHeight = function() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
state.current.listHeight.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
var cacheIndex = index;
|
|
91
|
-
if (index < 0) {
|
|
92
|
-
cacheIndex = 0;
|
|
93
|
-
}
|
|
94
|
-
if (index > state.current.listHeight.length - 2) {
|
|
95
|
-
cacheIndex = Math.max(0, state.current.listHeight.length - 2);
|
|
96
|
-
}
|
|
97
|
-
setCodeIndex(cacheIndex);
|
|
98
|
-
var scrollTop = state.current.listHeight[cacheIndex];
|
|
99
|
-
setScrollTop(scrollTop);
|
|
100
|
-
if (sticky && scrollY !== scrollTop) {
|
|
101
|
-
setScrollY(Math.floor(scrollTop) > 0 ? 1 : 0);
|
|
102
|
-
}
|
|
77
|
+
state.current.listHeight = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
var query = createSelectorQuery();
|
|
81
|
+
query.selectAll("#".concat(classPrefix, "-").concat(uuid, " .").concat(classPrefix, "-list-item")).boundingClientRect().exec(function() {
|
|
82
|
+
var rect = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
83
|
+
if (rect[0] && rect[0].length) {
|
|
84
|
+
// rect[0] = rect[0].reverse()
|
|
85
|
+
state.current.listHeight = rect[0].reduce(function(acc, item, index) {
|
|
86
|
+
// 当前项的高度等于前面所有项的高度之和
|
|
87
|
+
var height = acc[index] + item.height;
|
|
88
|
+
acc.push(height);
|
|
89
|
+
return acc;
|
|
90
|
+
}, [
|
|
91
|
+
0
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
103
95
|
};
|
|
96
|
+
var scrollTo = /*#__PURE__*/ function() {
|
|
97
|
+
var _ref = _async_to_generator(function(index) {
|
|
98
|
+
var cacheIndex, scrollTop;
|
|
99
|
+
return _ts_generator(this, function(_state) {
|
|
100
|
+
switch(_state.label){
|
|
101
|
+
case 0:
|
|
102
|
+
if (!index && index !== 0) {
|
|
103
|
+
return [
|
|
104
|
+
2
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
if (!!state.current.listHeight.length) return [
|
|
108
|
+
3,
|
|
109
|
+
2
|
|
110
|
+
];
|
|
111
|
+
return [
|
|
112
|
+
4,
|
|
113
|
+
calculateHeight()
|
|
114
|
+
];
|
|
115
|
+
case 1:
|
|
116
|
+
_state.sent();
|
|
117
|
+
_state.label = 2;
|
|
118
|
+
case 2:
|
|
119
|
+
cacheIndex = index;
|
|
120
|
+
if (index < 0) {
|
|
121
|
+
cacheIndex = 0;
|
|
122
|
+
}
|
|
123
|
+
if (index > state.current.listHeight.length - 2) {
|
|
124
|
+
cacheIndex = Math.max(0, state.current.listHeight.length - 2);
|
|
125
|
+
}
|
|
126
|
+
setCodeIndex(cacheIndex);
|
|
127
|
+
scrollTop = state.current.listHeight[cacheIndex];
|
|
128
|
+
setScrollTop(scrollTop);
|
|
129
|
+
if (mode === 'vertical' && sticky) {
|
|
130
|
+
setScrollY(Math.floor(scrollTop) > 0 ? 1 : 0);
|
|
131
|
+
}
|
|
132
|
+
return [
|
|
133
|
+
2
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
return function scrollTo(index) {
|
|
139
|
+
return _ref.apply(this, arguments);
|
|
140
|
+
};
|
|
141
|
+
}();
|
|
104
142
|
var touchMove = function(e) {
|
|
105
143
|
var firstTouch = e.touches[0];
|
|
106
144
|
touchState.current.y2 = firstTouch.pageY;
|
|
@@ -125,39 +163,31 @@ export var Elevator = function(props) {
|
|
|
125
163
|
var handleClickItem = function(key, item) {
|
|
126
164
|
onItemClick && onItemClick(key, item);
|
|
127
165
|
setCurrentData(item);
|
|
128
|
-
setCurrentKey(key);
|
|
129
166
|
};
|
|
130
167
|
var handleClickIndex = function(key) {
|
|
131
168
|
onIndexClick && onIndexClick(key);
|
|
132
169
|
};
|
|
133
|
-
var setListGroup = function() {
|
|
134
|
-
if (listview.current) {
|
|
135
|
-
createSelectorQuery().selectAll(".".concat(classPrefix, "-").concat(uuid, " .nut-elevator-list-item")).node(function(el) {
|
|
136
|
-
state.current.listGroup = _to_consumable_array(Object.keys(el));
|
|
137
|
-
calculateHeight();
|
|
138
|
-
}).exec();
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
170
|
var listViewScroll = function(e) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
var target = e.target;
|
|
147
|
-
var scrollTop = target.scrollTop;
|
|
148
|
-
state.current.scrollY = Math.floor(scrollTop);
|
|
149
|
-
Taro.getEnv() === 'WEB' && setScrollTop(scrollTop);
|
|
150
|
-
if (sticky && scrollTop !== scrollY) {
|
|
151
|
-
setScrollY(Math.floor(scrollTop) > 0 ? 1 : 0);
|
|
152
|
-
}
|
|
153
|
-
if (scrolling.current) return;
|
|
154
|
-
for(var i = 0; i < listHeight.length - 1; i++){
|
|
155
|
-
var height1 = listHeight[i];
|
|
156
|
-
var height2 = listHeight[i + 1];
|
|
157
|
-
if (state.current.scrollY >= height1 && state.current.scrollY < height2) {
|
|
158
|
-
return setCodeIndex(i);
|
|
171
|
+
raf(function() {
|
|
172
|
+
var listHeight = state.current.listHeight;
|
|
173
|
+
if (!listHeight.length) {
|
|
174
|
+
calculateHeight();
|
|
159
175
|
}
|
|
160
|
-
|
|
176
|
+
var target = e.target;
|
|
177
|
+
var scrollTop = target.scrollTop;
|
|
178
|
+
state.current.scrollY = Math.floor(scrollTop);
|
|
179
|
+
Taro.getEnv() === 'WEB' && setScrollTop(scrollTop);
|
|
180
|
+
if (mode === 'vertical' && sticky) {
|
|
181
|
+
setScrollY(Math.floor(scrollTop) > 0 ? 1 : 0);
|
|
182
|
+
}
|
|
183
|
+
if (scrolling.current) return;
|
|
184
|
+
var index = listHeight.findIndex(function(height, i) {
|
|
185
|
+
return state.current.scrollY >= height && state.current.scrollY < (listHeight[i + 1] || Infinity);
|
|
186
|
+
});
|
|
187
|
+
if (index !== -1 && index !== codeIndex) {
|
|
188
|
+
setCodeIndex(index);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
161
191
|
};
|
|
162
192
|
var getWrapStyle = useMemo(function() {
|
|
163
193
|
var calcHeight = Number.isNaN(+height) ? height : "".concat(height, "px");
|
|
@@ -168,17 +198,14 @@ export var Elevator = function(props) {
|
|
|
168
198
|
height
|
|
169
199
|
]);
|
|
170
200
|
useEffect(function() {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
}, [
|
|
177
|
-
listview
|
|
178
|
-
]);
|
|
201
|
+
nextTick(function() {
|
|
202
|
+
calculateHeight();
|
|
203
|
+
});
|
|
204
|
+
}, []);
|
|
179
205
|
var _obj;
|
|
180
206
|
return /*#__PURE__*/ React.createElement("div", _object_spread({
|
|
181
|
-
className: "".concat(classPrefix, " ").concat(className, " ").concat(classPrefix, "-").concat(
|
|
207
|
+
className: "".concat(classPrefix, " ").concat(className, " ").concat(classPrefix, "-").concat(mode, " "),
|
|
208
|
+
id: "".concat(classPrefix, "-").concat(uuid),
|
|
182
209
|
style: style
|
|
183
210
|
}, rest), /*#__PURE__*/ React.createElement(View, {
|
|
184
211
|
className: "".concat(classPrefix, "-list"),
|
|
@@ -186,11 +213,10 @@ export var Elevator = function(props) {
|
|
|
186
213
|
}, /*#__PURE__*/ React.createElement(ScrollView, {
|
|
187
214
|
scrollTop: scrollTop,
|
|
188
215
|
scrollY: true,
|
|
189
|
-
|
|
216
|
+
enhanced: true,
|
|
217
|
+
scrollWithAnimation: false,
|
|
190
218
|
scrollAnchoring: true,
|
|
191
219
|
className: "".concat(classPrefix, "-list-inner"),
|
|
192
|
-
type: "list",
|
|
193
|
-
ref: listview,
|
|
194
220
|
onScroll: listViewScroll,
|
|
195
221
|
onTouchStart: function(e) {
|
|
196
222
|
scrolling.current = false;
|
|
@@ -201,10 +227,12 @@ export var Elevator = function(props) {
|
|
|
201
227
|
key: idx
|
|
202
228
|
}, /*#__PURE__*/ React.createElement(View, {
|
|
203
229
|
className: "".concat(classPrefix, "-list-item-code")
|
|
204
|
-
}, item[floorKey]), /*#__PURE__*/ React.createElement(
|
|
230
|
+
}, item[floorKey]), /*#__PURE__*/ React.createElement(View, {
|
|
231
|
+
className: "".concat(classPrefix, "-list-item-sublist")
|
|
232
|
+
}, item.list.map(function(subitem) {
|
|
205
233
|
var _obj;
|
|
206
234
|
return /*#__PURE__*/ React.createElement(View, {
|
|
207
|
-
className: classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-list-item-name"), true), _define_property(_obj, "".concat(classPrefix, "-list-item-name-highcolor"), currentData.id === subitem.id
|
|
235
|
+
className: classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-list-item-name"), true), _define_property(_obj, "".concat(classPrefix, "-list-item-name-highcolor"), currentData.id === subitem.id), _obj)),
|
|
208
236
|
key: subitem.id,
|
|
209
237
|
onClick: function() {
|
|
210
238
|
return handleClickItem(item[floorKey], subitem);
|
|
@@ -215,7 +243,7 @@ export var Elevator = function(props) {
|
|
|
215
243
|
})));
|
|
216
244
|
}))), showKeys ? /*#__PURE__*/ React.createElement(React.Fragment, null, list.length && scrollStart ? /*#__PURE__*/ React.createElement(View, {
|
|
217
245
|
className: classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-code-current"), true), _define_property(_obj, "".concat(classPrefix, "-code-current-current"), true), _obj))
|
|
218
|
-
}, list[codeIndex][floorKey]) : null, /*#__PURE__*/ React.createElement(View, {
|
|
246
|
+
}, list[codeIndex] && String(list[codeIndex][floorKey])) : null, /*#__PURE__*/ React.createElement(View, {
|
|
219
247
|
className: "".concat(classPrefix, "-bars")
|
|
220
248
|
}, /*#__PURE__*/ React.createElement(View, {
|
|
221
249
|
className: "".concat(classPrefix, "-bars-inner")
|
|
@@ -238,12 +266,12 @@ export var Elevator = function(props) {
|
|
|
238
266
|
style: {
|
|
239
267
|
touchAction: 'pan-y'
|
|
240
268
|
}
|
|
241
|
-
}, item[floorKey]);
|
|
242
|
-
})))) : null, sticky && scrollY > 0 ? /*#__PURE__*/ React.createElement(View, {
|
|
269
|
+
}, String(item[floorKey]));
|
|
270
|
+
})))) : null, mode === 'vertical' && sticky && scrollY > 0 ? /*#__PURE__*/ React.createElement(View, {
|
|
243
271
|
className: "".concat(classPrefix, "-list-fixed")
|
|
244
272
|
}, /*#__PURE__*/ React.createElement(Text, {
|
|
245
273
|
className: "".concat(classPrefix, "-list-fixed-title")
|
|
246
|
-
}, list[codeIndex][floorKey])) : null);
|
|
274
|
+
}, list[codeIndex] && String(list[codeIndex][floorKey]))) : null);
|
|
247
275
|
};
|
|
248
276
|
Elevator.displayName = 'NutElevator';
|
|
249
277
|
Elevator.Context = elevatorContext;
|
|
@@ -1,68 +1,66 @@
|
|
|
1
1
|
.nut-elevator {
|
|
2
|
-
width: 100%;
|
|
3
|
-
display: block;
|
|
4
2
|
position: relative;
|
|
5
|
-
|
|
3
|
+
display: flex;
|
|
4
|
+
width: 100%;
|
|
6
5
|
|
|
7
6
|
&-list {
|
|
8
|
-
display: block;
|
|
9
7
|
position: relative;
|
|
10
8
|
top: 0;
|
|
9
|
+
display: flex;
|
|
10
|
+
width: 100%;
|
|
11
11
|
overflow: hidden;
|
|
12
|
-
font-size: $elevator-list-font-size;
|
|
13
|
-
color: $elevator-list-color;
|
|
14
12
|
|
|
15
13
|
&-inner {
|
|
16
|
-
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
min-height: 100%;
|
|
17
17
|
width: 100%;
|
|
18
|
-
display: block;
|
|
19
18
|
background-color: $elevator-list-bg-color;
|
|
20
19
|
overflow: auto;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
&-item {
|
|
24
|
-
display:
|
|
25
|
-
|
|
23
|
+
display: flex;
|
|
24
|
+
&-sublist {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
}
|
|
26
28
|
&-code {
|
|
27
29
|
display: flex;
|
|
28
|
-
|
|
30
|
+
align-items: center;
|
|
29
31
|
height: $elevator-list-item-code-height;
|
|
30
|
-
line-height: $elevator-list-item-code-line-height;
|
|
31
32
|
font-size: $elevator-list-item-code-font-size;
|
|
32
33
|
color: $elevator-list-item-code-color;
|
|
33
|
-
padding: $elevator-list-item-padding;
|
|
34
34
|
font-weight: $elevator-list-item-code-font-weight;
|
|
35
|
-
box-sizing: border-box;
|
|
36
|
-
border-bottom: $elevator-list-item-code-border-bottom;
|
|
37
|
-
background-color: $elevator-list-item-code-background-color;
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
&-name {
|
|
41
38
|
display: flex;
|
|
42
39
|
align-items: center;
|
|
43
|
-
padding: $elevator-list-item-padding;
|
|
44
40
|
height: $elevator-list-item-name-height;
|
|
45
|
-
|
|
41
|
+
font-size: $elevator-list-font-size;
|
|
42
|
+
color: $elevator-list-color;
|
|
46
43
|
|
|
47
44
|
&-highcolor {
|
|
48
45
|
color: $color-primary;
|
|
46
|
+
font-weight: 600;
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
&-fixed {
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
width: 100%;
|
|
57
52
|
position: absolute;
|
|
58
53
|
top: 0;
|
|
59
54
|
left: 0;
|
|
60
55
|
z-index: 1;
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
width: 100%;
|
|
61
59
|
padding: $elevator-list-item-padding;
|
|
62
60
|
height: $elevator-list-item-code-height;
|
|
63
|
-
background-color: $elevator-list-fixed-bg-color;
|
|
64
61
|
box-sizing: border-box;
|
|
65
62
|
box-shadow: $elevator-list-fixed-box-shadow;
|
|
63
|
+
background-color: $elevator-list-fixed-bg-color;
|
|
66
64
|
&-title {
|
|
67
65
|
font-size: $elevator-list-item-code-font-size;
|
|
68
66
|
color: $elevator-list-fixed-color;
|
|
@@ -76,41 +74,71 @@
|
|
|
76
74
|
right: $elevator-list-item-code-current-right;
|
|
77
75
|
top: $elevator-list-item-code-current-top;
|
|
78
76
|
transform: $elevator-bars-transform;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
79
80
|
width: $elevator-list-item-code-current-width;
|
|
80
81
|
height: $elevator-list-item-code-current-height;
|
|
81
|
-
line-height: $elevator-list-item-code-current-line-height;
|
|
82
82
|
border-radius: $elevator-list-item-code-current-border-radius;
|
|
83
83
|
background: $elevator-list-item-code-current-bg-color;
|
|
84
84
|
box-shadow: $elevator-list-item-code-current-box-shadow;
|
|
85
|
-
|
|
85
|
+
color: $elevator-list-item-code-current-color;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
&-bars {
|
|
89
89
|
position: absolute;
|
|
90
90
|
right: $elevator-bars-right;
|
|
91
91
|
top: $elevator-bars-top;
|
|
92
|
-
color: $color-text-help;
|
|
93
|
-
font-size: $elevator-bars-font-size;
|
|
94
92
|
transform: $elevator-bars-transform;
|
|
95
|
-
padding: $elevator-bars-padding;
|
|
96
|
-
background-color: $elevator-bars-background-color;
|
|
97
|
-
border-radius: $elevator-bars-border-radius;
|
|
98
|
-
text-align: center;
|
|
99
93
|
z-index: $elevator-bars-z-index;
|
|
100
94
|
|
|
101
95
|
&-inner {
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-direction: column;
|
|
102
98
|
&-item {
|
|
103
|
-
display:
|
|
104
|
-
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
height: 16px;
|
|
103
|
+
width: 16px;
|
|
104
|
+
border-radius: 50%;
|
|
105
|
+
margin: 1px 0;
|
|
106
|
+
color: $elevator-bars-color;
|
|
107
|
+
font-size: $elevator-bars-font-size;
|
|
105
108
|
cursor: pointer;
|
|
106
|
-
|
|
107
109
|
&-active {
|
|
108
110
|
font-weight: $font-weight-bold;
|
|
109
111
|
color: $elevator-bars-active-color;
|
|
112
|
+
/* #ifndef weapp jd*/
|
|
113
|
+
background: linear-gradient(to right, #ff475d, #ff0f23);
|
|
114
|
+
/* #endif */
|
|
115
|
+
/* #ifdef weapp jd*/
|
|
116
|
+
background: #ff0f23;
|
|
117
|
+
/* #endif */
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
121
|
}
|
|
122
|
+
&-horizontal {
|
|
123
|
+
.nut-elevator-list-item {
|
|
124
|
+
&-code {
|
|
125
|
+
width: $elevator-list-item-code-width;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
&-vertical {
|
|
131
|
+
.nut-elevator-list-item {
|
|
132
|
+
flex-direction: column;
|
|
133
|
+
&-code {
|
|
134
|
+
border-bottom: $elevator-list-item-code-border-bottom;
|
|
135
|
+
}
|
|
136
|
+
&-name,
|
|
137
|
+
&-code {
|
|
138
|
+
padding: $elevator-list-item-padding;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
114
142
|
}
|
|
115
143
|
|
|
116
144
|
[dir='rtl'] .nut-elevator,
|