@tarojs/components-react 4.1.4-beta.20 → 4.1.4-beta.21
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/components/list/ListItem.js +18 -0
- package/dist/components/list/ListItem.js.map +1 -0
- package/dist/components/list/StickyHeader.js +18 -0
- package/dist/components/list/StickyHeader.js.map +1 -0
- package/dist/components/list/StickySection.js +18 -0
- package/dist/components/list/StickySection.js.map +1 -0
- package/dist/components/list/index.js +348 -0
- package/dist/components/list/index.js.map +1 -0
- package/dist/components/list/style/index.scss.js +4 -0
- package/dist/components/list/style/index.scss.js.map +1 -0
- package/dist/components/picker/index.js +21 -21
- package/dist/components/picker/index.js.map +1 -1
- package/dist/components/scroll-view/index.js +7 -2
- package/dist/components/scroll-view/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/solid/components/list/ListItem.js +21 -0
- package/dist/solid/components/list/ListItem.js.map +1 -0
- package/dist/solid/components/list/StickyHeader.js +21 -0
- package/dist/solid/components/list/StickyHeader.js.map +1 -0
- package/dist/solid/components/list/StickySection.js +21 -0
- package/dist/solid/components/list/StickySection.js.map +1 -0
- package/dist/solid/components/list/index.js +355 -0
- package/dist/solid/components/list/index.js.map +1 -0
- package/dist/solid/components/list/style/index.scss.js +4 -0
- package/dist/solid/components/list/style/index.scss.js.map +1 -0
- package/dist/solid/components/picker/index.js +21 -21
- package/dist/solid/components/picker/index.js.map +1 -1
- package/dist/solid/components/scroll-view/index.js +7 -2
- package/dist/solid/components/scroll-view/index.js.map +1 -1
- package/dist/solid/index.css +1 -1
- package/dist/solid/index.js +5 -1
- package/dist/solid/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StickySection.js","sources":["../../../../src/components/list/StickySection.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface StickySectionProps {\n children: React.ReactNode\n className?: string\n style?: React.CSSProperties\n}\n\nconst StickySection: React.FC<StickySectionProps> = ({ children, className, style }) => {\n return <div className={className} style={style}>{children}</div>\n}\n\nexport default StickySection\n"],"names":["StickySection","_ref","children","className","style","_el$","_tmpl$","_$insert","_$effect","_$p","_$style"],"mappings":";;;;AAQMA,MAAAA,aAAa,GAAiCC,IAAA,IAAmC;EAAA,IAAlC;IAAEC,QAAQ;IAAEC,SAAS;AAAEC,WAAAA;AAAO,GAAA,GAAAH,IAAA;AACjF,EAAA,OAAA,CAAA,MAAA;IAAA,IAAAI,IAAA,GAAAC,MAAA,EAAA;IAAAD,IAAA,CAAAF,SAAA,GAAuBA,SAAS;IAAAI,MAAA,CAAAF,IAAA,EAAiBH,QAAQ,CAAA;IAAAM,MAAA,CAAAC,GAAA,IAAAC,KAAA,CAAAL,IAAA,EAAhBD,OAAK,EAAAK,GAAA,CAAA,CAAA;AAAA,IAAA,OAAAJ,IAAA;AAAA,GAAA,GAAA;AAChD;;;;"}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { createComponent, mergeProps, memo } from 'solid-js/web';
|
|
2
|
+
import './style/index.scss.js';
|
|
3
|
+
import { View, ScrollView } from '@tarojs/components';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import ListItem from './ListItem.js';
|
|
6
|
+
import StickyHeader from './StickyHeader.js';
|
|
7
|
+
import StickySection from './StickySection.js';
|
|
8
|
+
|
|
9
|
+
// 工具:累加数组
|
|
10
|
+
function accumulate(arr) {
|
|
11
|
+
const result = [0];
|
|
12
|
+
for (let i = 0; i < arr.length; i++) {
|
|
13
|
+
result[i + 1] = result[i] + arr[i];
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
// 检测抖动
|
|
18
|
+
function isShaking(diffList) {
|
|
19
|
+
if (diffList.length < 3) return false;
|
|
20
|
+
// 检查是否有连续的正负交替
|
|
21
|
+
const signs = diffList.map(diff => Math.sign(diff));
|
|
22
|
+
let alternations = 0;
|
|
23
|
+
for (let i = 1; i < signs.length; i++) {
|
|
24
|
+
if (signs[i] !== 0 && signs[i] !== signs[i - 1]) {
|
|
25
|
+
alternations++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// 如果交替次数过多,认为是抖动
|
|
29
|
+
return alternations >= 2;
|
|
30
|
+
}
|
|
31
|
+
const List = props => {
|
|
32
|
+
const isH5 = process.env.TARO_ENV === 'h5';
|
|
33
|
+
const {
|
|
34
|
+
stickyHeader = false,
|
|
35
|
+
space = 0,
|
|
36
|
+
height = 400,
|
|
37
|
+
width = '100%',
|
|
38
|
+
showScrollbar = true,
|
|
39
|
+
scrollTop: controlledScrollTop,
|
|
40
|
+
onScroll,
|
|
41
|
+
onScrollToUpper,
|
|
42
|
+
onScrollToLower,
|
|
43
|
+
upperThresholdCount = 0,
|
|
44
|
+
lowerThresholdCount = 0,
|
|
45
|
+
cacheCount = 2,
|
|
46
|
+
style,
|
|
47
|
+
children,
|
|
48
|
+
layout = 'vertical'
|
|
49
|
+
} = props;
|
|
50
|
+
const isHorizontal = layout === 'horizontal';
|
|
51
|
+
const DEFAULT_ITEM_WIDTH = 120;
|
|
52
|
+
const DEFAULT_ITEM_HEIGHT = 40;
|
|
53
|
+
// 滚动状态管理
|
|
54
|
+
const containerRef = React__default.useRef(null);
|
|
55
|
+
// 渲染偏移量 - 用于计算应该渲染哪些元素
|
|
56
|
+
const [renderOffset, setRenderOffset] = React__default.useState(controlledScrollTop !== null && controlledScrollTop !== void 0 ? controlledScrollTop : 0);
|
|
57
|
+
// 滚动视图偏移量 - 只在滚动结束或明确请求时更新到ScrollView
|
|
58
|
+
const [scrollViewOffset, setScrollViewOffset] = React__default.useState(controlledScrollTop !== null && controlledScrollTop !== void 0 ? controlledScrollTop : 0);
|
|
59
|
+
const [containerLength] = React__default.useState(typeof (isHorizontal ? width : height) === 'number' ? isHorizontal ? width : height : 400);
|
|
60
|
+
// 滚动追踪相关refs
|
|
61
|
+
const isScrollingRef = React__default.useRef(false);
|
|
62
|
+
const lastScrollTopRef = React__default.useRef(controlledScrollTop !== null && controlledScrollTop !== void 0 ? controlledScrollTop : 0);
|
|
63
|
+
const scrollDiffListRef = React__default.useRef([0, 0, 0]);
|
|
64
|
+
const scrollTimeoutRef = React__default.useRef(null);
|
|
65
|
+
// 解析分组结构,只支持 StickySection 和 ListItem 作为直接子组件
|
|
66
|
+
const sections = React__default.useMemo(() => {
|
|
67
|
+
const result = [];
|
|
68
|
+
const defaultItems = [];
|
|
69
|
+
React__default.Children.forEach(children, (child, idx) => {
|
|
70
|
+
if (/*#__PURE__*/React__default.isValidElement(child) && child.type === StickySection) {
|
|
71
|
+
// 分组模式
|
|
72
|
+
const sectionProps = child.props;
|
|
73
|
+
let header = null;
|
|
74
|
+
const items = [];
|
|
75
|
+
React__default.Children.forEach(sectionProps.children, subChild => {
|
|
76
|
+
if (/*#__PURE__*/React__default.isValidElement(subChild) && subChild.type === StickyHeader) header = subChild;else if (/*#__PURE__*/React__default.isValidElement(subChild) && subChild.type === ListItem) items.push(subChild);
|
|
77
|
+
});
|
|
78
|
+
result.push({
|
|
79
|
+
header,
|
|
80
|
+
items,
|
|
81
|
+
key: child.key || String(idx)
|
|
82
|
+
});
|
|
83
|
+
} else if (/*#__PURE__*/React__default.isValidElement(child) && child.type === ListItem) {
|
|
84
|
+
// 普通 ListItem
|
|
85
|
+
defaultItems.push(child);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (defaultItems.length > 0) {
|
|
89
|
+
result.push({
|
|
90
|
+
header: null,
|
|
91
|
+
items: defaultItems,
|
|
92
|
+
key: 'default'
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}, [children]);
|
|
97
|
+
// 工具:获取 header 尺寸,确保所有 header 相关逻辑一致
|
|
98
|
+
const getHeaderSize = () => {
|
|
99
|
+
if (isHorizontal) {
|
|
100
|
+
if (typeof props.headerWidth === 'number') return props.headerWidth;
|
|
101
|
+
if (typeof props.itemWidth === 'number') return props.itemWidth;
|
|
102
|
+
if (typeof props.itemSize === 'number') return props.itemSize;
|
|
103
|
+
if (typeof props.itemSize === 'function') return props.itemSize(0, props.itemData) || DEFAULT_ITEM_WIDTH;
|
|
104
|
+
return DEFAULT_ITEM_WIDTH;
|
|
105
|
+
} else {
|
|
106
|
+
if (typeof props.headerHeight === 'number') return props.headerHeight;
|
|
107
|
+
if (typeof props.itemHeight === 'number') return props.itemHeight;
|
|
108
|
+
if (typeof props.itemSize === 'number') return props.itemSize;
|
|
109
|
+
if (typeof props.itemSize === 'function') return props.itemSize(0, props.itemData) || DEFAULT_ITEM_HEIGHT;
|
|
110
|
+
return DEFAULT_ITEM_HEIGHT;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
// 工具:获取 item 尺寸,支持函数/props/默认值
|
|
114
|
+
const getItemSize = index => {
|
|
115
|
+
if (isHorizontal) {
|
|
116
|
+
if (typeof props.itemWidth === 'number') return props.itemWidth;
|
|
117
|
+
if (typeof props.itemSize === 'number') return props.itemSize;
|
|
118
|
+
if (typeof props.itemSize === 'function') return props.itemSize(index, props.itemData) || DEFAULT_ITEM_WIDTH;
|
|
119
|
+
return DEFAULT_ITEM_WIDTH;
|
|
120
|
+
} else {
|
|
121
|
+
if (typeof props.itemHeight === 'number') return props.itemHeight;
|
|
122
|
+
if (typeof props.itemSize === 'number') return props.itemSize;
|
|
123
|
+
if (typeof props.itemSize === 'function') return props.itemSize(index, props.itemData) || DEFAULT_ITEM_HEIGHT;
|
|
124
|
+
return DEFAULT_ITEM_HEIGHT;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
// 计算分组累积高度/宽度
|
|
128
|
+
const sectionOffsets = React__default.useMemo(() => {
|
|
129
|
+
const offsets = [0];
|
|
130
|
+
sections.forEach(section => {
|
|
131
|
+
const headerSize = getHeaderSize();
|
|
132
|
+
const itemSizes = section.items.map((_, i) => getItemSize(i));
|
|
133
|
+
const groupSize = (section.header ? headerSize : 0) + itemSizes.reduce((a, b) => a + b, 0) + Math.max(0, section.items.length) * space;
|
|
134
|
+
offsets.push(offsets[offsets.length - 1] + groupSize);
|
|
135
|
+
});
|
|
136
|
+
return offsets;
|
|
137
|
+
}, [sections, space, isHorizontal, props.headerHeight, props.headerWidth, props.itemHeight, props.itemWidth, props.itemSize, props.itemData]);
|
|
138
|
+
// 外层虚拟滚动:可见分组
|
|
139
|
+
const [startSection, endSection] = React__default.useMemo(() => {
|
|
140
|
+
let start = 0;
|
|
141
|
+
let end = sections.length - 1;
|
|
142
|
+
for (let i = 0; i < sections.length; i++) {
|
|
143
|
+
if (sectionOffsets[i + 1] > renderOffset) {
|
|
144
|
+
start = Math.max(0, i - cacheCount);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
for (let i = start; i < sections.length; i++) {
|
|
149
|
+
if (sectionOffsets[i] >= renderOffset + containerLength) {
|
|
150
|
+
end = Math.min(sections.length - 1, i + cacheCount);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return [start, end];
|
|
155
|
+
}, [renderOffset, containerLength, sectionOffsets, sections.length, cacheCount]);
|
|
156
|
+
// 触顶/触底事件
|
|
157
|
+
React__default.useEffect(() => {
|
|
158
|
+
if (onScrollToUpper && renderOffset <= (upperThresholdCount > 0 ? sectionOffsets[upperThresholdCount] : 0)) {
|
|
159
|
+
onScrollToUpper();
|
|
160
|
+
}
|
|
161
|
+
if (onScrollToLower && renderOffset + containerLength >= sectionOffsets[sectionOffsets.length - 1] - (lowerThresholdCount > 0 ? sectionOffsets[sectionOffsets.length - 1] - sectionOffsets[sections.length - lowerThresholdCount] : 0)) {
|
|
162
|
+
onScrollToLower();
|
|
163
|
+
}
|
|
164
|
+
}, [renderOffset, containerLength, sectionOffsets, sections.length, upperThresholdCount, lowerThresholdCount, onScrollToUpper, onScrollToLower]);
|
|
165
|
+
// 处理渲染偏移量更新
|
|
166
|
+
const updateRenderOffset = React__default.useCallback(newOffset => {
|
|
167
|
+
lastScrollTopRef.current = newOffset;
|
|
168
|
+
isScrollingRef.current = true;
|
|
169
|
+
if (scrollTimeoutRef.current) {
|
|
170
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
171
|
+
}
|
|
172
|
+
setRenderOffset(newOffset); // 立即更新渲染偏移量
|
|
173
|
+
scrollTimeoutRef.current = setTimeout(() => {
|
|
174
|
+
isScrollingRef.current = false;
|
|
175
|
+
setScrollViewOffset(newOffset); // 滚动结束后,同步滚动视图偏移量
|
|
176
|
+
}, 200);
|
|
177
|
+
}, []);
|
|
178
|
+
// 智能滚动处理函数
|
|
179
|
+
const handleScroll = React__default.useCallback(e => {
|
|
180
|
+
const newOffset = isHorizontal ? e.detail.scrollLeft : e.detail.scrollTop;
|
|
181
|
+
const diff = newOffset - lastScrollTopRef.current;
|
|
182
|
+
scrollDiffListRef.current.shift();
|
|
183
|
+
scrollDiffListRef.current.push(diff);
|
|
184
|
+
// 只保留抖动检测,移除方向检测
|
|
185
|
+
if (isScrollingRef.current && isShaking(scrollDiffListRef.current)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
updateRenderOffset(newOffset); // 直接更新渲染偏移量
|
|
189
|
+
onScroll === null || onScroll === void 0 ? void 0 : onScroll({
|
|
190
|
+
scrollTop: isHorizontal ? 0 : newOffset,
|
|
191
|
+
scrollLeft: isHorizontal ? newOffset : 0
|
|
192
|
+
});
|
|
193
|
+
}, [isHorizontal, onScroll, updateRenderOffset, containerLength]);
|
|
194
|
+
// 初始化后的延迟同步 - 确保ScrollView正确设置初始位置
|
|
195
|
+
React__default.useEffect(() => {
|
|
196
|
+
if (typeof controlledScrollTop === 'number') {
|
|
197
|
+
setScrollViewOffset(controlledScrollTop);
|
|
198
|
+
lastScrollTopRef.current = controlledScrollTop;
|
|
199
|
+
}
|
|
200
|
+
}, [controlledScrollTop]);
|
|
201
|
+
// 清理定时器
|
|
202
|
+
React__default.useEffect(() => {
|
|
203
|
+
return () => {
|
|
204
|
+
if (scrollTimeoutRef.current) {
|
|
205
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}, []);
|
|
209
|
+
// 容器样式
|
|
210
|
+
const containerStyle = Object.assign({
|
|
211
|
+
height: isHorizontal ? width : height,
|
|
212
|
+
width: isHorizontal ? height : width
|
|
213
|
+
}, style);
|
|
214
|
+
// 修改ScrollView组件的props,添加data-testid属性
|
|
215
|
+
// ScrollView 属性
|
|
216
|
+
const scrollViewProps = {
|
|
217
|
+
scrollY: !isHorizontal,
|
|
218
|
+
scrollX: isHorizontal,
|
|
219
|
+
style: containerStyle,
|
|
220
|
+
enhanced: true,
|
|
221
|
+
showScrollbar: showScrollbar,
|
|
222
|
+
onScroll: handleScroll,
|
|
223
|
+
onScrollToUpper,
|
|
224
|
+
onScrollToLower,
|
|
225
|
+
'data-testid': 'taro-list-container'
|
|
226
|
+
};
|
|
227
|
+
// 设置ScrollView的滚动位置
|
|
228
|
+
if (isHorizontal) {
|
|
229
|
+
scrollViewProps.scrollLeft = scrollViewOffset;
|
|
230
|
+
} else {
|
|
231
|
+
scrollViewProps.scrollTop = scrollViewOffset;
|
|
232
|
+
}
|
|
233
|
+
// H5上额外使用DOM直接操作确保滚动位置正确
|
|
234
|
+
if (isH5) {
|
|
235
|
+
React__default.useEffect(() => {
|
|
236
|
+
if (containerRef.current && typeof scrollViewOffset === 'number') {
|
|
237
|
+
if (isHorizontal) {
|
|
238
|
+
containerRef.current.scrollLeft = scrollViewOffset;
|
|
239
|
+
} else {
|
|
240
|
+
containerRef.current.scrollTop = scrollViewOffset;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}, [scrollViewOffset, isHorizontal]);
|
|
244
|
+
}
|
|
245
|
+
// 总高度/宽度
|
|
246
|
+
const totalLength = sectionOffsets[sectionOffsets.length - 1];
|
|
247
|
+
// 吸顶/吸左 header
|
|
248
|
+
const stickyHeaderNode = React__default.useMemo(() => {
|
|
249
|
+
if (!stickyHeader) return null;
|
|
250
|
+
for (let i = 0; i < sections.length; i++) {
|
|
251
|
+
if (sectionOffsets[i] <= renderOffset && renderOffset < sectionOffsets[i + 1]) {
|
|
252
|
+
const section = sections[i];
|
|
253
|
+
if (section.header) {
|
|
254
|
+
const headerSize = getHeaderSize();
|
|
255
|
+
return createComponent(View, {
|
|
256
|
+
className: "taro-list-sticky-header",
|
|
257
|
+
style: isHorizontal ? {
|
|
258
|
+
width: headerSize
|
|
259
|
+
} : {
|
|
260
|
+
height: headerSize
|
|
261
|
+
},
|
|
262
|
+
get children() {
|
|
263
|
+
return section.header;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}, [stickyHeader, renderOffset, sectionOffsets, sections, isHorizontal, props.headerHeight, props.headerWidth, props.itemHeight, props.itemWidth, props.itemSize, props.itemData]);
|
|
271
|
+
// 渲染分组+item双层虚拟滚动
|
|
272
|
+
const renderSections = () => {
|
|
273
|
+
const nodes = [];
|
|
274
|
+
let offset = sectionOffsets[startSection];
|
|
275
|
+
for (let s = startSection; s <= endSection; s++) {
|
|
276
|
+
const section = sections[s];
|
|
277
|
+
const headerSize = getHeaderSize();
|
|
278
|
+
const itemSizes = section.items.map((_, i) => getItemSize(i));
|
|
279
|
+
// header
|
|
280
|
+
if (section.header) {
|
|
281
|
+
nodes.push(/*#__PURE__*/React__default.createElement('div', {
|
|
282
|
+
key: section.key + '-header' + '-' + layout,
|
|
283
|
+
className: isHorizontal ? 'taro-list-section-header horizontal' : 'taro-list-section-header',
|
|
284
|
+
style: isHorizontal ? {
|
|
285
|
+
left: offset,
|
|
286
|
+
width: headerSize
|
|
287
|
+
} : {
|
|
288
|
+
top: offset,
|
|
289
|
+
height: headerSize
|
|
290
|
+
}
|
|
291
|
+
}, section.header));
|
|
292
|
+
offset += headerSize;
|
|
293
|
+
}
|
|
294
|
+
// item offsets
|
|
295
|
+
const itemOffsets = accumulate(itemSizes.map(size => size + space));
|
|
296
|
+
// 内层虚拟滚动:可见item区间
|
|
297
|
+
let startItem = 0;
|
|
298
|
+
let endItem = section.items.length - 1;
|
|
299
|
+
for (let i = 0; i < section.items.length; i++) {
|
|
300
|
+
if (offset + itemOffsets[i + 1] > renderOffset) {
|
|
301
|
+
startItem = Math.max(0, i - cacheCount);
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
for (let i = startItem; i < section.items.length; i++) {
|
|
306
|
+
if (offset + itemOffsets[i] >= renderOffset + containerLength) {
|
|
307
|
+
endItem = Math.min(section.items.length - 1, i + cacheCount);
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// 渲染可见item
|
|
312
|
+
for (let i = startItem; i <= endItem; i++) {
|
|
313
|
+
nodes.push(/*#__PURE__*/React__default.createElement('div', {
|
|
314
|
+
key: section.key + '-item-' + i + '-' + layout,
|
|
315
|
+
className: isHorizontal ? 'taro-list-section-item horizontal' : 'taro-list-section-item',
|
|
316
|
+
style: isHorizontal ? {
|
|
317
|
+
left: offset + itemOffsets[i],
|
|
318
|
+
width: itemSizes[i],
|
|
319
|
+
marginRight: space
|
|
320
|
+
} : {
|
|
321
|
+
top: offset + itemOffsets[i],
|
|
322
|
+
height: itemSizes[i],
|
|
323
|
+
marginBottom: space
|
|
324
|
+
}
|
|
325
|
+
}, section.items[i]));
|
|
326
|
+
}
|
|
327
|
+
offset += itemOffsets[itemOffsets.length - 1];
|
|
328
|
+
}
|
|
329
|
+
return nodes;
|
|
330
|
+
};
|
|
331
|
+
return createComponent(ScrollView, mergeProps({
|
|
332
|
+
ref: containerRef,
|
|
333
|
+
className: "taro-list-container"
|
|
334
|
+
}, scrollViewProps, {
|
|
335
|
+
get children() {
|
|
336
|
+
return createComponent(View, {
|
|
337
|
+
style: isHorizontal ? {
|
|
338
|
+
width: totalLength,
|
|
339
|
+
position: 'relative',
|
|
340
|
+
height: '100%'
|
|
341
|
+
} : {
|
|
342
|
+
height: totalLength,
|
|
343
|
+
position: 'relative',
|
|
344
|
+
width: '100%'
|
|
345
|
+
},
|
|
346
|
+
get children() {
|
|
347
|
+
return [stickyHeaderNode, memo(() => renderSections())];
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}));
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
export { accumulate, List as default, isShaking };
|
|
355
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/list/index.tsx"],"sourcesContent":["import './style/index.scss'\n\nimport { ScrollView, View } from '@tarojs/components'\nimport React from 'react'\n\nimport ListItem from './ListItem'\nimport StickyHeader from './StickyHeader'\nimport StickySection from './StickySection'\n\nexport interface ListProps {\n showScrollbar?: boolean\n scrollTop?: number\n onScroll?: (e: { scrollTop: number, scrollLeft: number }) => void\n onScrollToUpper?: () => void\n onScrollToLower?: () => void\n upperThresholdCount?: number\n lowerThresholdCount?: number\n cacheCount?: number\n stickyHeader?: boolean\n space?: number\n item?: React.ComponentType<any>\n itemCount?: number\n itemData?: any[]\n itemSize?: number | ((index: number, data?: any[]) => number)\n height?: number | string\n width?: number | string\n layout?: 'vertical' | 'horizontal'\n style?: React.CSSProperties\n children?: React.ReactNode\n headerHeight?: number // 纵向 header 高度\n headerWidth?: number // 横向 header 宽度\n itemHeight?: number // 纵向 item 高度\n itemWidth?: number // 横向 item 宽度\n}\n\n// 工具:累加数组\nexport function accumulate(arr: number[]) {\n const result = [0]\n for (let i = 0; i < arr.length; i++) {\n result[i + 1] = result[i] + arr[i]\n }\n return result\n}\n\n// 检测抖动\nexport function isShaking(diffList: number[]): boolean {\n if (diffList.length < 3) return false\n\n // 检查是否有连续的正负交替\n const signs = diffList.map(diff => Math.sign(diff))\n let alternations = 0\n for (let i = 1; i < signs.length; i++) {\n if (signs[i] !== 0 && signs[i] !== signs[i - 1]) {\n alternations++\n }\n }\n\n // 如果交替次数过多,认为是抖动\n return alternations >= 2\n}\n\nconst List: React.FC<ListProps> = (props) => {\n const isH5 = process.env.TARO_ENV === 'h5'\n const {\n stickyHeader = false,\n space = 0,\n height = 400,\n width = '100%',\n showScrollbar = true,\n scrollTop: controlledScrollTop,\n onScroll,\n onScrollToUpper,\n onScrollToLower,\n upperThresholdCount = 0,\n lowerThresholdCount = 0,\n cacheCount = 2,\n style,\n children,\n layout = 'vertical'\n } = props\n\n const isHorizontal = layout === 'horizontal'\n const DEFAULT_ITEM_WIDTH = 120\n const DEFAULT_ITEM_HEIGHT = 40\n\n // 滚动状态管理\n const containerRef = React.useRef<HTMLDivElement>(null)\n\n // 渲染偏移量 - 用于计算应该渲染哪些元素\n const [renderOffset, setRenderOffset] = React.useState(controlledScrollTop ?? 0)\n\n // 滚动视图偏移量 - 只在滚动结束或明确请求时更新到ScrollView\n const [scrollViewOffset, setScrollViewOffset] = React.useState(controlledScrollTop ?? 0)\n\n\n const [containerLength] = React.useState<number>(typeof (isHorizontal ? width : height) === 'number' ? (isHorizontal ? (width as number) : (height as number)) : 400)\n\n // 滚动追踪相关refs\n const isScrollingRef = React.useRef(false)\n const lastScrollTopRef = React.useRef(controlledScrollTop ?? 0)\n const scrollDiffListRef = React.useRef<number[]>([0, 0, 0])\n const scrollTimeoutRef = React.useRef<NodeJS.Timeout | null>(null)\n\n // 解析分组结构,只支持 StickySection 和 ListItem 作为直接子组件\n const sections = React.useMemo(() => {\n const result: Array<{\n header: React.ReactElement | null\n items: React.ReactElement[]\n key: string\n }> = []\n const defaultItems: React.ReactElement[] = []\n React.Children.forEach(children, (child, idx) => {\n if (React.isValidElement(child) && child.type === StickySection) {\n // 分组模式\n const sectionProps = child.props as any\n let header: React.ReactElement | null = null\n const items: React.ReactElement[] = []\n React.Children.forEach(sectionProps.children, (subChild) => {\n if (React.isValidElement(subChild) && subChild.type === StickyHeader) header = subChild\n else if (React.isValidElement(subChild) && subChild.type === ListItem) items.push(subChild)\n })\n result.push({ header, items, key: child.key || String(idx) })\n } else if (React.isValidElement(child) && child.type === ListItem) {\n // 普通 ListItem\n defaultItems.push(child)\n }\n })\n if (defaultItems.length > 0) {\n result.push({ header: null, items: defaultItems, key: 'default' })\n }\n return result\n }, [children])\n\n // 工具:获取 header 尺寸,确保所有 header 相关逻辑一致\n const getHeaderSize = () => {\n if (isHorizontal) {\n if (typeof props.headerWidth === 'number') return props.headerWidth\n if (typeof props.itemWidth === 'number') return props.itemWidth\n if (typeof props.itemSize === 'number') return props.itemSize\n if (typeof props.itemSize === 'function') return props.itemSize(0, props.itemData) || DEFAULT_ITEM_WIDTH\n return DEFAULT_ITEM_WIDTH\n } else {\n if (typeof props.headerHeight === 'number') return props.headerHeight\n if (typeof props.itemHeight === 'number') return props.itemHeight\n if (typeof props.itemSize === 'number') return props.itemSize\n if (typeof props.itemSize === 'function') return props.itemSize(0, props.itemData) || DEFAULT_ITEM_HEIGHT\n return DEFAULT_ITEM_HEIGHT\n }\n }\n\n // 工具:获取 item 尺寸,支持函数/props/默认值\n const getItemSize = (index: number) => {\n if (isHorizontal) {\n if (typeof props.itemWidth === 'number') return props.itemWidth\n if (typeof props.itemSize === 'number') return props.itemSize\n if (typeof props.itemSize === 'function') return props.itemSize(index, props.itemData) || DEFAULT_ITEM_WIDTH\n return DEFAULT_ITEM_WIDTH\n } else {\n if (typeof props.itemHeight === 'number') return props.itemHeight\n if (typeof props.itemSize === 'number') return props.itemSize\n if (typeof props.itemSize === 'function') return props.itemSize(index, props.itemData) || DEFAULT_ITEM_HEIGHT\n return DEFAULT_ITEM_HEIGHT\n }\n }\n\n // 计算分组累积高度/宽度\n const sectionOffsets = React.useMemo(() => {\n const offsets: number[] = [0]\n sections.forEach((section) => {\n const headerSize = getHeaderSize()\n const itemSizes = section.items.map((_, i) => getItemSize(i))\n const groupSize = (section.header ? headerSize : 0) +\n itemSizes.reduce((a, b) => a + b, 0) +\n Math.max(0, section.items.length) * space\n offsets.push(offsets[offsets.length - 1] + groupSize)\n })\n return offsets\n }, [sections, space, isHorizontal, props.headerHeight, props.headerWidth, props.itemHeight, props.itemWidth, props.itemSize, props.itemData])\n\n // 外层虚拟滚动:可见分组\n const [startSection, endSection] = React.useMemo(() => {\n let start = 0; let end = sections.length - 1\n for (let i = 0; i < sections.length; i++) {\n if (sectionOffsets[i + 1] > renderOffset) {\n start = Math.max(0, i - cacheCount)\n break\n }\n }\n for (let i = start; i < sections.length; i++) {\n if (sectionOffsets[i] >= renderOffset + containerLength) {\n end = Math.min(sections.length - 1, i + cacheCount)\n break\n }\n }\n return [start, end]\n }, [renderOffset, containerLength, sectionOffsets, sections.length, cacheCount])\n\n // 触顶/触底事件\n React.useEffect(() => {\n if (onScrollToUpper && renderOffset <= (upperThresholdCount > 0 ? sectionOffsets[upperThresholdCount] : 0)) {\n onScrollToUpper()\n }\n if (onScrollToLower && renderOffset + containerLength >= sectionOffsets[sectionOffsets.length - 1] - (lowerThresholdCount > 0 ? sectionOffsets[sectionOffsets.length - 1] - sectionOffsets[sections.length - lowerThresholdCount] : 0)) {\n onScrollToLower()\n }\n }, [renderOffset, containerLength, sectionOffsets, sections.length, upperThresholdCount, lowerThresholdCount, onScrollToUpper, onScrollToLower])\n\n // 处理渲染偏移量更新\n const updateRenderOffset = React.useCallback((newOffset: number) => {\n lastScrollTopRef.current = newOffset\n isScrollingRef.current = true\n\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current)\n }\n\n setRenderOffset(newOffset) // 立即更新渲染偏移量\n\n scrollTimeoutRef.current = setTimeout(() => {\n isScrollingRef.current = false\n setScrollViewOffset(newOffset) // 滚动结束后,同步滚动视图偏移量\n }, 200)\n }, [])\n\n\n\n // 智能滚动处理函数\n const handleScroll = React.useCallback((e: any) => {\n const newOffset = isHorizontal ? e.detail.scrollLeft : e.detail.scrollTop\n\n const diff = newOffset - lastScrollTopRef.current\n scrollDiffListRef.current.shift()\n scrollDiffListRef.current.push(diff)\n\n // 只保留抖动检测,移除方向检测\n if (isScrollingRef.current && isShaking(scrollDiffListRef.current)) {\n return\n }\n\n updateRenderOffset(newOffset) // 直接更新渲染偏移量\n\n onScroll?.({\n scrollTop: isHorizontal ? 0 : newOffset,\n scrollLeft: isHorizontal ? newOffset : 0\n })\n }, [isHorizontal, onScroll, updateRenderOffset, containerLength])\n\n // 初始化后的延迟同步 - 确保ScrollView正确设置初始位置\n React.useEffect(() => {\n if (typeof controlledScrollTop === 'number') {\n setScrollViewOffset(controlledScrollTop)\n lastScrollTopRef.current = controlledScrollTop\n }\n }, [controlledScrollTop])\n\n // 清理定时器\n React.useEffect(() => {\n return () => {\n if (scrollTimeoutRef.current) {\n clearTimeout(scrollTimeoutRef.current)\n }\n }\n }, [])\n\n // 容器样式\n const containerStyle: React.CSSProperties = {\n height: isHorizontal ? width : height,\n width: isHorizontal ? height : width,\n ...style,\n }\n\n // 修改ScrollView组件的props,添加data-testid属性\n // ScrollView 属性\n const scrollViewProps: any = {\n scrollY: !isHorizontal,\n scrollX: isHorizontal,\n style: containerStyle,\n enhanced: true,\n showScrollbar: showScrollbar,\n onScroll: handleScroll,\n onScrollToUpper,\n onScrollToLower,\n 'data-testid': 'taro-list-container'\n }\n\n // 设置ScrollView的滚动位置\n if (isHorizontal) {\n scrollViewProps.scrollLeft = scrollViewOffset\n } else {\n scrollViewProps.scrollTop = scrollViewOffset\n }\n\n // H5上额外使用DOM直接操作确保滚动位置正确\n if (isH5) {\n React.useEffect(() => {\n if (containerRef.current && typeof scrollViewOffset === 'number') {\n if (isHorizontal) {\n containerRef.current.scrollLeft = scrollViewOffset\n } else {\n containerRef.current.scrollTop = scrollViewOffset\n }\n }\n }, [scrollViewOffset, isHorizontal])\n }\n\n // 总高度/宽度\n const totalLength = sectionOffsets[sectionOffsets.length - 1]\n\n // 吸顶/吸左 header\n const stickyHeaderNode = React.useMemo(() => {\n if (!stickyHeader) return null\n for (let i = 0; i < sections.length; i++) {\n if (sectionOffsets[i] <= renderOffset && renderOffset < sectionOffsets[i + 1]) {\n const section = sections[i]\n if (section.header) {\n const headerSize = getHeaderSize()\n return (\n <View className=\"taro-list-sticky-header\" style={isHorizontal ? { width: headerSize } : { height: headerSize }}>\n {section.header}\n </View>\n )\n }\n }\n }\n return null\n }, [stickyHeader, renderOffset, sectionOffsets, sections, isHorizontal, props.headerHeight, props.headerWidth, props.itemHeight, props.itemWidth, props.itemSize, props.itemData])\n\n // 渲染分组+item双层虚拟滚动\n const renderSections = () => {\n const nodes: React.ReactNode[] = []\n let offset = sectionOffsets[startSection]\n for (let s = startSection; s <= endSection; s++) {\n const section = sections[s]\n const headerSize = getHeaderSize()\n const itemSizes = section.items.map((_, i) => getItemSize(i))\n // header\n if (section.header) {\n nodes.push(\n React.createElement('div', {\n key: section.key + '-header' + '-' + layout,\n className: isHorizontal ? 'taro-list-section-header horizontal' : 'taro-list-section-header',\n style: isHorizontal ? { left: offset, width: headerSize } : { top: offset, height: headerSize },\n }, section.header)\n )\n offset += headerSize\n }\n // item offsets\n const itemOffsets = accumulate(itemSizes.map((size) => size + space))\n // 内层虚拟滚动:可见item区间\n let startItem = 0; let endItem = section.items.length - 1\n for (let i = 0; i < section.items.length; i++) {\n if (offset + itemOffsets[i + 1] > renderOffset) {\n startItem = Math.max(0, i - cacheCount)\n break\n }\n }\n for (let i = startItem; i < section.items.length; i++) {\n if (offset + itemOffsets[i] >= renderOffset + containerLength) {\n endItem = Math.min(section.items.length - 1, i + cacheCount)\n break\n }\n }\n // 渲染可见item\n for (let i = startItem; i <= endItem; i++) {\n nodes.push(\n React.createElement('div', {\n key: section.key + '-item-' + i + '-' + layout,\n className: isHorizontal ? 'taro-list-section-item horizontal' : 'taro-list-section-item',\n style: isHorizontal\n ? {\n left: offset + itemOffsets[i],\n width: itemSizes[i],\n marginRight: space,\n }\n : {\n top: offset + itemOffsets[i],\n height: itemSizes[i],\n marginBottom: space,\n },\n }, section.items[i])\n )\n }\n offset += itemOffsets[itemOffsets.length - 1]\n }\n return nodes\n }\n\n return (\n <ScrollView ref={containerRef} className=\"taro-list-container\" {...scrollViewProps}>\n <View style={isHorizontal ? { width: totalLength, position: 'relative', height: '100%' } : { height: totalLength, position: 'relative', width: '100%' }}>\n {stickyHeaderNode}\n {renderSections()}\n </View>\n </ScrollView>\n )\n}\n\nexport default List\n"],"names":["accumulate","arr","result","i","length","isShaking","diffList","signs","map","diff","Math","sign","alternations","List","props","isH5","process","env","TARO_ENV","stickyHeader","space","height","width","showScrollbar","scrollTop","controlledScrollTop","onScroll","onScrollToUpper","onScrollToLower","upperThresholdCount","lowerThresholdCount","cacheCount","style","children","layout","isHorizontal","DEFAULT_ITEM_WIDTH","DEFAULT_ITEM_HEIGHT","containerRef","React","useRef","renderOffset","setRenderOffset","useState","scrollViewOffset","setScrollViewOffset","containerLength","isScrollingRef","lastScrollTopRef","scrollDiffListRef","scrollTimeoutRef","sections","useMemo","defaultItems","Children","forEach","child","idx","isValidElement","type","StickySection","sectionProps","header","items","subChild","StickyHeader","ListItem","push","key","String","getHeaderSize","headerWidth","itemWidth","itemSize","itemData","headerHeight","itemHeight","getItemSize","index","sectionOffsets","offsets","section","headerSize","itemSizes","_","groupSize","reduce","a","b","max","startSection","endSection","start","end","min","useEffect","updateRenderOffset","useCallback","newOffset","current","clearTimeout","setTimeout","handleScroll","e","detail","scrollLeft","shift","containerStyle","Object","assign","scrollViewProps","scrollY","scrollX","enhanced","totalLength","stickyHeaderNode","_$createComponent","View","className","renderSections","nodes","offset","s","createElement","left","top","itemOffsets","size","startItem","endItem","marginRight","marginBottom","ScrollView","_$mergeProps","ref","position","_$memo"],"mappings":";;;;;;;;AAmCA;AACM,SAAUA,UAAUA,CAACC,GAAa,EAAA;AACtC,EAAA,MAAMC,MAAM,GAAG,CAAC,CAAC,CAAC;AAClB,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,GAAG,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;AACnCD,I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version":3,"file":"index.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -3,7 +3,7 @@ import { __rest } from 'tslib';
|
|
|
3
3
|
import './style/index.scss.js';
|
|
4
4
|
import { View } from '@tarojs/components';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import
|
|
6
|
+
import React__default from 'react';
|
|
7
7
|
import { verifyValue, verifyTime, hoursRange, minutesRange, verifyDate, getYearRange, getMonthRange, getDayRange, compareTime, omit } from '../../utils/index.js';
|
|
8
8
|
import { PickerGroup } from './picker-group.js';
|
|
9
9
|
|
|
@@ -95,7 +95,7 @@ function getRegionColumnsCount(level) {
|
|
|
95
95
|
// 默认显示省市区/县三列
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
const Picker = /*#__PURE__*/
|
|
98
|
+
const Picker = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
99
99
|
var _a, _b;
|
|
100
100
|
const {
|
|
101
101
|
mode = 'selector',
|
|
@@ -118,11 +118,11 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
118
118
|
formType
|
|
119
119
|
} = props,
|
|
120
120
|
restProps = __rest(props, ["mode", "disabled", "range", "rangeKey", "value", "start", "end", "fields", "headerText", "level", "regionData", "textProps", "onChange", "onColumnChange", "onCancel", "children", "style", "formType"]);
|
|
121
|
-
const indexRef =
|
|
122
|
-
const pickerDateRef =
|
|
121
|
+
const indexRef = React__default.useRef([]);
|
|
122
|
+
const pickerDateRef = React__default.useRef();
|
|
123
123
|
// 记录是否是用户滚动
|
|
124
|
-
const isInitializationCompletedRef =
|
|
125
|
-
const [state, setState] =
|
|
124
|
+
const isInitializationCompletedRef = React__default.useRef(false);
|
|
125
|
+
const [state, setState] = React__default.useState({
|
|
126
126
|
pickerValue: value || EMPTY_ARRAY,
|
|
127
127
|
selectedIndices: EMPTY_ARRAY.slice(),
|
|
128
128
|
// 索引数组
|
|
@@ -132,17 +132,17 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
132
132
|
timestamp: 0 // 用以部分模式下强制刷新组件的的时间戳,多用于反复限位
|
|
133
133
|
});
|
|
134
134
|
// 在组件内部
|
|
135
|
-
const [columnsCount, setColumnsCount] =
|
|
135
|
+
const [columnsCount, setColumnsCount] = React__default.useState(() => getRegionColumnsCount(level));
|
|
136
136
|
// 只在level变化时更新列数
|
|
137
|
-
|
|
137
|
+
React__default.useEffect(() => {
|
|
138
138
|
setColumnsCount(getRegionColumnsCount(level));
|
|
139
139
|
}, [level]);
|
|
140
140
|
// 获取当前索引数组
|
|
141
|
-
const getIndices =
|
|
141
|
+
const getIndices = React__default.useCallback(() => {
|
|
142
142
|
return indexRef.current;
|
|
143
143
|
}, []);
|
|
144
144
|
// 处理属性变化
|
|
145
|
-
const handleProps =
|
|
145
|
+
const handleProps = React__default.useCallback(() => {
|
|
146
146
|
var _a;
|
|
147
147
|
if (mode === 'selector') {
|
|
148
148
|
const val = value;
|
|
@@ -240,20 +240,20 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
240
240
|
}));
|
|
241
241
|
}, [mode, range, value, start, end, fields, regionData, level, columnsCount, getIndices]);
|
|
242
242
|
// 组件初始化
|
|
243
|
-
|
|
243
|
+
React__default.useEffect(() => {
|
|
244
244
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
245
245
|
isWillLoadCalled: true
|
|
246
246
|
}));
|
|
247
247
|
handleProps();
|
|
248
248
|
}, []);
|
|
249
249
|
// 属性变化监听 - 添加 value 依赖以支持联动选择器
|
|
250
|
-
|
|
250
|
+
React__default.useEffect(() => {
|
|
251
251
|
if (state.isWillLoadCalled) {
|
|
252
252
|
handleProps();
|
|
253
253
|
}
|
|
254
254
|
}, [handleProps, state.isWillLoadCalled, JSON.stringify(value)]);
|
|
255
255
|
// 显示 Picker
|
|
256
|
-
const showPicker =
|
|
256
|
+
const showPicker = React__default.useCallback(() => {
|
|
257
257
|
if (disabled) return;
|
|
258
258
|
isInitializationCompletedRef.current = false;
|
|
259
259
|
const newIndices = getIndices();
|
|
@@ -263,7 +263,7 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
263
263
|
}));
|
|
264
264
|
}, [disabled, getIndices]);
|
|
265
265
|
// 隐藏 Picker
|
|
266
|
-
const hidePicker =
|
|
266
|
+
const hidePicker = React__default.useCallback(() => {
|
|
267
267
|
isInitializationCompletedRef.current = false;
|
|
268
268
|
setState(prev => Object.assign(Object.assign({}, prev), {
|
|
269
269
|
fadeOut: true
|
|
@@ -276,7 +276,7 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
276
276
|
}, 350);
|
|
277
277
|
}, []);
|
|
278
278
|
// 更新索引
|
|
279
|
-
const updateIndex =
|
|
279
|
+
const updateIndex = React__default.useCallback(function (index, columnId) {
|
|
280
280
|
let needRevise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
281
281
|
let isUserScrollRef = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
282
282
|
const columnIndex = Number(columnId);
|
|
@@ -354,7 +354,7 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
354
354
|
return false; // 没有限位
|
|
355
355
|
}, [start, end, mode, regionData, state.selectedIndices, columnsCount]);
|
|
356
356
|
// 更新日期
|
|
357
|
-
const updateDay =
|
|
357
|
+
const updateDay = React__default.useCallback((value, fields) => {
|
|
358
358
|
if (!pickerDateRef.current) return;
|
|
359
359
|
const {
|
|
360
360
|
_start,
|
|
@@ -432,7 +432,7 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
432
432
|
}
|
|
433
433
|
}, [state.selectedIndices]);
|
|
434
434
|
// 处理确认
|
|
435
|
-
const handleChange =
|
|
435
|
+
const handleChange = React__default.useCallback(() => {
|
|
436
436
|
const newIndices = [...state.selectedIndices];
|
|
437
437
|
indexRef.current = newIndices;
|
|
438
438
|
let newValue = newIndices.length && mode !== 'selector' ? newIndices : newIndices[0];
|
|
@@ -558,7 +558,7 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
558
558
|
});
|
|
559
559
|
}, [hidePicker, state.selectedIndices, mode, fields, onChange, regionData, columnsCount]);
|
|
560
560
|
// 处理列变化
|
|
561
|
-
const handleColumnChange =
|
|
561
|
+
const handleColumnChange = React__default.useCallback(e => {
|
|
562
562
|
const {
|
|
563
563
|
columnId,
|
|
564
564
|
index
|
|
@@ -571,12 +571,12 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
571
571
|
});
|
|
572
572
|
}, [onColumnChange]);
|
|
573
573
|
// 处理取消
|
|
574
|
-
const handleCancel =
|
|
574
|
+
const handleCancel = React__default.useCallback(() => {
|
|
575
575
|
hidePicker();
|
|
576
576
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
577
577
|
}, [hidePicker, onCancel]);
|
|
578
578
|
// 渲染选择器组
|
|
579
|
-
const renderPickerGroup =
|
|
579
|
+
const renderPickerGroup = React__default.useMemo(() => {
|
|
580
580
|
switch (mode) {
|
|
581
581
|
case 'multiSelector':
|
|
582
582
|
{
|
|
@@ -731,7 +731,7 @@ const Picker = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
731
731
|
'taro-picker__animate-slide-down': state.fadeOut
|
|
732
732
|
});
|
|
733
733
|
// 暴露方法给外部
|
|
734
|
-
|
|
734
|
+
React__default.useImperativeHandle(ref, () => ({
|
|
735
735
|
showPicker,
|
|
736
736
|
hidePicker
|
|
737
737
|
}));
|