@tarojs/components-react 4.1.12-beta.60 → 4.1.12-beta.61

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.
Files changed (25) hide show
  1. package/dist/components/picker/index.js +10 -0
  2. package/dist/components/picker/index.js.map +1 -1
  3. package/dist/components/picker/picker-group-legacy.js +936 -0
  4. package/dist/components/picker/picker-group-legacy.js.map +1 -0
  5. package/dist/components/picker/picker-group-slider.js +1046 -0
  6. package/dist/components/picker/picker-group-slider.js.map +1 -0
  7. package/dist/components/picker/picker-group.js +37 -926
  8. package/dist/components/picker/picker-group.js.map +1 -1
  9. package/dist/original/components/picker/index.js +10 -0
  10. package/dist/original/components/picker/index.js.map +1 -1
  11. package/dist/original/components/picker/picker-group-legacy.js +936 -0
  12. package/dist/original/components/picker/picker-group-legacy.js.map +1 -0
  13. package/dist/original/components/picker/picker-group-slider.js +1046 -0
  14. package/dist/original/components/picker/picker-group-slider.js.map +1 -0
  15. package/dist/original/components/picker/picker-group.js +37 -926
  16. package/dist/original/components/picker/picker-group.js.map +1 -1
  17. package/dist/solid/components/picker/index.js +10 -0
  18. package/dist/solid/components/picker/index.js.map +1 -1
  19. package/dist/solid/components/picker/picker-group-legacy.js +952 -0
  20. package/dist/solid/components/picker/picker-group-legacy.js.map +1 -0
  21. package/dist/solid/components/picker/picker-group-slider.js +1071 -0
  22. package/dist/solid/components/picker/picker-group-slider.js.map +1 -0
  23. package/dist/solid/components/picker/picker-group.js +33 -942
  24. package/dist/solid/components/picker/picker-group.js.map +1 -1
  25. package/package.json +6 -6
@@ -0,0 +1,952 @@
1
+ import { createComponent, mergeProps } from 'solid-js/web';
2
+ import { View, ScrollView } from '@tarojs/components';
3
+ import Taro from '@tarojs/taro';
4
+ import * as React from 'react';
5
+
6
+ function requestAccessibilityFocusOnView(node) {
7
+ if (node == null) return;
8
+ const fn = Taro.setAccessibilityFocus;
9
+ if (typeof fn !== 'function') return;
10
+ fn({
11
+ viewRef: {
12
+ current: node
13
+ }
14
+ });
15
+ }
16
+ /** 部分端同 id 连续 scrollIntoView 不生效:先清空再在下一宏任务设回目标 id */
17
+ function usePickerItemScrollIntoView() {
18
+ const [scrollIntoView, setScrollIntoView] = React.useState('');
19
+ const pulseRef = React.useRef(0);
20
+ const scrollToItemId = React.useCallback(itemId => {
21
+ pulseRef.current += 1;
22
+ const token = pulseRef.current;
23
+ setScrollIntoView('');
24
+ setTimeout(() => {
25
+ if (pulseRef.current !== token) return;
26
+ setScrollIntoView(itemId);
27
+ }, 0);
28
+ }, []);
29
+ return [scrollIntoView, scrollToItemId];
30
+ }
31
+ // 定义常量
32
+ const PICKER_LINE_HEIGHT = 34; // px
33
+ const PICKER_VISIBLE_ITEMS = 7; // 可见行数
34
+ const PICKER_BLANK_ITEMS = 3; // 空白行数
35
+ const getIndicatorStyle = lineColor => {
36
+ return {
37
+ borderTopColor: lineColor,
38
+ borderBottomColor: lineColor
39
+ };
40
+ };
41
+ // 大屏方案版本要求
42
+ const MIN_DESIGN_APP_VERSION = 16;
43
+ // 判断是否启用测量值缩放适配(true=启用, false=使用系统侧缩放)
44
+ const resolveUseMeasuredScale = res => {
45
+ // H5/weapp 不参与大屏系数
46
+ if (process.env.TARO_ENV === 'h5' || process.env.TARO_ENV === 'weapp') {
47
+ return false;
48
+ }
49
+ const designAppVersionRaw = res.designAppVersion;
50
+ const designAppVersionMajor = designAppVersionRaw != null ? parseInt(String(designAppVersionRaw).trim(), 10) : Number.NaN;
51
+ if (!Number.isFinite(designAppVersionMajor) || designAppVersionMajor < MIN_DESIGN_APP_VERSION) {
52
+ return false;
53
+ }
54
+ const platform = String(res.platform || '').toLowerCase();
55
+ if (platform === 'harmony' || platform === 'android' || platform === 'ios') {
56
+ return true;
57
+ }
58
+ return false;
59
+ };
60
+ // 辅助函数:计算 lengthScaleRatio
61
+ const calculateLengthScaleRatio = res => {
62
+ let lengthScaleRatio = res === null || res === void 0 ? void 0 : res.lengthScaleRatio;
63
+ if (lengthScaleRatio == null || lengthScaleRatio === 0) {
64
+ console.warn('Taro.getSystemInfo: lengthScaleRatio 不存在,使用计算值');
65
+ lengthScaleRatio = 1;
66
+ if (res.windowWidth < 320) {
67
+ lengthScaleRatio = res.windowWidth / 320;
68
+ } else if (res.windowWidth >= 400 && res.windowWidth < 600) {
69
+ lengthScaleRatio = res.windowWidth / 400;
70
+ }
71
+ const shortSide = res.windowWidth < res.windowHeight ? res.windowWidth : res.windowHeight;
72
+ const isBigScreen = shortSide >= 600;
73
+ if (isBigScreen) {
74
+ lengthScaleRatio = shortSide / 720;
75
+ }
76
+ }
77
+ return lengthScaleRatio;
78
+ };
79
+ // 辅助函数:获取系统信息的 lengthScaleRatio 并设置 targetScrollTop
80
+ const setTargetScrollTopWithScale = function (setTargetScrollTop, baseValue, randomOffset) {
81
+ let lengthScaleRatio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
82
+ // H5 和 weapp 不参与放大计算,直接使用 baseValue
83
+ if (process.env.TARO_ENV === 'h5' || process.env.TARO_ENV === 'weapp') {
84
+ const finalValue = randomOffset !== undefined ? baseValue + randomOffset : baseValue;
85
+ setTargetScrollTop(finalValue);
86
+ return;
87
+ }
88
+ if (process.env.TARO_PLATFORM === 'harmony') {
89
+ const scaledValue = baseValue;
90
+ const finalValue = randomOffset !== undefined ? scaledValue + randomOffset : scaledValue;
91
+ setTargetScrollTop(finalValue);
92
+ } else {
93
+ const scaledValue = baseValue * lengthScaleRatio;
94
+ const finalValue = randomOffset !== undefined ? scaledValue + randomOffset : scaledValue;
95
+ setTargetScrollTop(finalValue);
96
+ }
97
+ };
98
+ // 根据 scrollTop 计算选中索引
99
+ // 系统侧缩放模式:scrollHeight 已被系统缩放,直接相除即可
100
+ // 自行缩放模式:需要除以 ratio 换算(harmony 特殊处理,ratio 已内嵌在 itemHeight 中)
101
+ const getSelectedIndex = function (scrollTop, itemHeight) {
102
+ let lengthScaleRatio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
103
+ let useMeasuredScale = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
104
+ if (!useMeasuredScale || process.env.TARO_PLATFORM === 'harmony') {
105
+ return Math.round(scrollTop / itemHeight);
106
+ }
107
+ return Math.round(scrollTop / lengthScaleRatio / itemHeight);
108
+ };
109
+ // 计算单项高度(返回设计稿值)
110
+ const calculateItemHeight = function (scrollView, lengthScaleRatio) {
111
+ let useMeasuredScale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
112
+ if (process.env.TARO_PLATFORM === 'harmony') {
113
+ return useMeasuredScale ? PICKER_LINE_HEIGHT * lengthScaleRatio : PICKER_LINE_HEIGHT;
114
+ }
115
+ if (scrollView && (scrollView === null || scrollView === void 0 ? void 0 : scrollView.scrollHeight)) {
116
+ return useMeasuredScale ? scrollView.scrollHeight / lengthScaleRatio / scrollView.childNodes.length : scrollView.scrollHeight / scrollView.childNodes.length;
117
+ }
118
+ console.warn('Height measurement anomaly');
119
+ return PICKER_LINE_HEIGHT;
120
+ };
121
+ function PickerGroupBasic(props) {
122
+ const {
123
+ range = [],
124
+ rangeKey,
125
+ columnId,
126
+ updateIndex,
127
+ onColumnChange,
128
+ selectedIndex = 0,
129
+ // 使用selectedIndex参数,默认为0
130
+ colors = {},
131
+ enableClickItemScroll = true
132
+ } = props;
133
+ const indicatorStyle = colors.lineColor ? getIndicatorStyle(colors.lineColor) : null;
134
+ const [targetScrollTop, setTargetScrollTop] = React.useState(0);
135
+ const [scrollIntoView, scrollToItemId] = usePickerItemScrollIntoView();
136
+ const scrollViewRef = React.useRef(null);
137
+ const itemRefs = React.useRef([]);
138
+ const selectedIndexPropRef = React.useRef(selectedIndex);
139
+ selectedIndexPropRef.current = selectedIndex;
140
+ const syncScrollFromPropsRef = React.useRef(false);
141
+ const pendingScrollSettleFocusRef = React.useRef(false);
142
+ // 使用selectedIndex初始化当前索引
143
+ const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
144
+ // 触摸状态用于优化用户体验
145
+ const isTouchingRef = React.useRef(false);
146
+ const lengthScaleRatioRef = React.useRef(1);
147
+ const useMeasuredScaleRef = React.useRef(false);
148
+ const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
149
+ // 初始化时计算 lengthScaleRatio 并判定缩放模式
150
+ React.useEffect(() => {
151
+ Taro.getSystemInfo({
152
+ success: res => {
153
+ lengthScaleRatioRef.current = calculateLengthScaleRatio(res);
154
+ useMeasuredScaleRef.current = resolveUseMeasuredScale(res);
155
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
156
+ },
157
+ fail: () => {
158
+ lengthScaleRatioRef.current = 1;
159
+ useMeasuredScaleRef.current = false;
160
+ }
161
+ });
162
+ }, []);
163
+ React.useEffect(() => {
164
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
165
+ }, [range.length]); // 只在range长度变化时重新计算
166
+ // props 的 selectedIndex 变化:滚至对应项并短时标记程序化滚动(syncScrollFromPropsRef)
167
+ React.useEffect(() => {
168
+ if (scrollViewRef.current && range.length > 0 && !isTouchingRef.current) {
169
+ syncScrollFromPropsRef.current = true;
170
+ const baseValue = selectedIndex * itemHeightRef.current;
171
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, undefined, lengthScaleRatioRef.current);
172
+ setCurrentIndex(selectedIndex);
173
+ const tid = setTimeout(() => {
174
+ syncScrollFromPropsRef.current = false;
175
+ }, 400);
176
+ return () => clearTimeout(tid);
177
+ }
178
+ }, [selectedIndex, range]);
179
+ // 是否处于归中状态
180
+ const isCenterTimerId = React.useRef(null);
181
+ // 滚动静止后归中并同步选中
182
+ const handleScrollEnd = () => {
183
+ if (!scrollViewRef.current) return;
184
+ if (isCenterTimerId.current) {
185
+ clearTimeout(isCenterTimerId.current);
186
+ isCenterTimerId.current = null;
187
+ }
188
+ // 100ms 内无新滚动则归中并提交索引
189
+ isCenterTimerId.current = setTimeout(() => {
190
+ if (!scrollViewRef.current) return;
191
+ const scrollTop = scrollViewRef.current.scrollTop;
192
+ const newIndex = getSelectedIndex(scrollTop, itemHeightRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
193
+ const allowA11yFocus = !syncScrollFromPropsRef.current;
194
+ const shouldFocusOnScrollSettle = pendingScrollSettleFocusRef.current;
195
+ isTouchingRef.current = false;
196
+ const baseValue = newIndex * itemHeightRef.current;
197
+ const randomOffset = Math.random() * 0.001; // 随机数为了在一个项内滚动时强制刷新
198
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, randomOffset, lengthScaleRatioRef.current);
199
+ updateIndex(newIndex, columnId);
200
+ onColumnChange === null || onColumnChange === void 0 ? void 0 : onColumnChange({
201
+ columnId,
202
+ index: newIndex
203
+ });
204
+ pendingScrollSettleFocusRef.current = false;
205
+ if (allowA11yFocus && shouldFocusOnScrollSettle) {
206
+ requestAccessibilityFocusOnView(itemRefs.current[newIndex]);
207
+ }
208
+ syncScrollFromPropsRef.current = false;
209
+ isCenterTimerId.current = null;
210
+ }, 100);
211
+ };
212
+ // 滚动中:按 scrollTop 更新高亮索引
213
+ const handleScroll = () => {
214
+ if (!scrollViewRef.current) return;
215
+ if (isCenterTimerId.current) {
216
+ clearTimeout(isCenterTimerId.current);
217
+ isCenterTimerId.current = null;
218
+ }
219
+ const scrollTop = scrollViewRef.current.scrollTop;
220
+ const ih = itemHeightRef.current;
221
+ const newIndex = getSelectedIndex(scrollTop, ih, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
222
+ const spi = selectedIndexPropRef.current;
223
+ if (newIndex !== spi) {
224
+ if (!syncScrollFromPropsRef.current || isTouchingRef.current) {
225
+ pendingScrollSettleFocusRef.current = true;
226
+ }
227
+ if (isTouchingRef.current) {
228
+ syncScrollFromPropsRef.current = false;
229
+ }
230
+ }
231
+ if (newIndex !== currentIndex) {
232
+ setCurrentIndex(newIndex);
233
+ }
234
+ };
235
+ // 渲染选项
236
+ const pickerItem = range.map((item, index) => {
237
+ const content = rangeKey && item && typeof item === 'object' ? item[rangeKey] : item;
238
+ return createComponent(View, mergeProps({
239
+ id: `picker-item-${columnId}-${index}`,
240
+ key: index,
241
+ ref: el => itemRefs.current[index] = el,
242
+ className: `taro-picker__item${index === currentIndex ? ' taro-picker__item--selected' : ''}`
243
+ }, enableClickItemScroll ? {
244
+ onClick: () => scrollToItemId(`picker-item-${columnId}-${index}`)
245
+ } : {}, {
246
+ get style() {
247
+ return {
248
+ height: PICKER_LINE_HEIGHT,
249
+ color: index === currentIndex ? colors.itemSelectedColor || undefined : colors.itemDefaultColor || undefined
250
+ };
251
+ },
252
+ children: content
253
+ }));
254
+ });
255
+ const realPickerItems = [...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
256
+ key: `blank-top-${idx}`,
257
+ className: "taro-picker__item taro-picker__item--blank",
258
+ style: {
259
+ height: PICKER_LINE_HEIGHT
260
+ }
261
+ })), ...pickerItem, ...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
262
+ key: `blank-bottom-${idx}`,
263
+ className: "taro-picker__item taro-picker__item--blank",
264
+ style: {
265
+ height: PICKER_LINE_HEIGHT
266
+ }
267
+ }))];
268
+ const clickScrollViewProps = enableClickItemScroll ? {
269
+ scrollIntoView,
270
+ scrollIntoViewAlignment: 'center'
271
+ } : {};
272
+ return createComponent(View, {
273
+ className: "taro-picker__group",
274
+ get children() {
275
+ return [createComponent(View, {
276
+ className: "taro-picker__mask"
277
+ }), createComponent(View, mergeProps({
278
+ className: "taro-picker__indicator"
279
+ }, indicatorStyle ? {
280
+ style: indicatorStyle
281
+ } : {})), createComponent(ScrollView, mergeProps({
282
+ ref: scrollViewRef,
283
+ scrollY: true,
284
+ showScrollbar: false,
285
+ className: "taro-picker__content",
286
+ style: {
287
+ height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
288
+ },
289
+ scrollTop: targetScrollTop
290
+ }, clickScrollViewProps, {
291
+ onScroll: handleScroll,
292
+ onTouchStart: () => {
293
+ isTouchingRef.current = true;
294
+ },
295
+ onScrollEnd: handleScrollEnd,
296
+ scrollWithAnimation: true,
297
+ children: realPickerItems
298
+ }))];
299
+ }
300
+ });
301
+ }
302
+ // 时间选择器实现
303
+ function PickerGroupTime(props) {
304
+ const {
305
+ range = [],
306
+ rangeKey,
307
+ columnId,
308
+ updateIndex,
309
+ selectedIndex = 0,
310
+ colors = {},
311
+ timeA11yLimitFocus,
312
+ onTimeA11yLimitFocusConsumed,
313
+ timeA11yLimitEventNonce,
314
+ enableClickItemScroll = true
315
+ } = props;
316
+ const indicatorStyle = colors.lineColor ? getIndicatorStyle(colors.lineColor) : null;
317
+ const [targetScrollTop, setTargetScrollTop] = React.useState(0);
318
+ const [scrollIntoView, scrollToItemId] = usePickerItemScrollIntoView();
319
+ const scrollViewRef = React.useRef(null);
320
+ const itemRefs = React.useRef([]);
321
+ const selectedIndexPropRef = React.useRef(selectedIndex);
322
+ selectedIndexPropRef.current = selectedIndex;
323
+ const syncScrollFromPropsRef = React.useRef(false);
324
+ const prevLimitEventNonceRef = React.useRef(undefined);
325
+ const suppressScrollSettleFocusNonceRef = React.useRef(null);
326
+ const pendingScrollSettleFocusRef = React.useRef(false);
327
+ const pendingLimitFocusRef = React.useRef(null);
328
+ const limitFocusTimerRef = React.useRef(null);
329
+ const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
330
+ const isTouchingRef = React.useRef(false);
331
+ const lengthScaleRatioRef = React.useRef(1);
332
+ const useMeasuredScaleRef = React.useRef(false);
333
+ const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
334
+ const clearLimitFocusTimer = React.useCallback(() => {
335
+ if (limitFocusTimerRef.current) {
336
+ clearTimeout(limitFocusTimerRef.current);
337
+ limitFocusTimerRef.current = null;
338
+ }
339
+ }, []);
340
+ const tryFocusPendingLimit = React.useCallback(() => {
341
+ const pending = pendingLimitFocusRef.current;
342
+ const scrollView = scrollViewRef.current;
343
+ if (!pending || !scrollView) return;
344
+ const visualIndex = getSelectedIndex(scrollView.scrollTop, itemHeightRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
345
+ const isStable = visualIndex === pending.index;
346
+ if (!isStable) {
347
+ if (pending.attempts >= 20) {
348
+ pendingLimitFocusRef.current = null;
349
+ if (suppressScrollSettleFocusNonceRef.current === pending.nonce) {
350
+ suppressScrollSettleFocusNonceRef.current = null;
351
+ }
352
+ onTimeA11yLimitFocusConsumed === null || onTimeA11yLimitFocusConsumed === void 0 ? void 0 : onTimeA11yLimitFocusConsumed();
353
+ return;
354
+ }
355
+ pending.attempts += 1;
356
+ clearLimitFocusTimer();
357
+ limitFocusTimerRef.current = setTimeout(() => {
358
+ tryFocusPendingLimit();
359
+ }, 50);
360
+ return;
361
+ }
362
+ const node = itemRefs.current[pending.index];
363
+ pendingLimitFocusRef.current = null;
364
+ if (suppressScrollSettleFocusNonceRef.current === pending.nonce) {
365
+ suppressScrollSettleFocusNonceRef.current = null;
366
+ }
367
+ clearLimitFocusTimer();
368
+ requestAccessibilityFocusOnView(node);
369
+ onTimeA11yLimitFocusConsumed === null || onTimeA11yLimitFocusConsumed === void 0 ? void 0 : onTimeA11yLimitFocusConsumed();
370
+ }, [clearLimitFocusTimer, onTimeA11yLimitFocusConsumed]);
371
+ const schedulePendingLimitFocus = React.useCallback(() => {
372
+ if (!pendingLimitFocusRef.current) return;
373
+ clearLimitFocusTimer();
374
+ limitFocusTimerRef.current = setTimeout(() => {
375
+ tryFocusPendingLimit();
376
+ }, 100);
377
+ }, [clearLimitFocusTimer, tryFocusPendingLimit]);
378
+ React.useEffect(() => clearLimitFocusTimer, [clearLimitFocusTimer]);
379
+ // 初始化时计算 lengthScaleRatio 并判定缩放模式
380
+ React.useEffect(() => {
381
+ Taro.getSystemInfo({
382
+ success: res => {
383
+ lengthScaleRatioRef.current = calculateLengthScaleRatio(res);
384
+ useMeasuredScaleRef.current = resolveUseMeasuredScale(res);
385
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
386
+ },
387
+ fail: () => {
388
+ lengthScaleRatioRef.current = 1;
389
+ useMeasuredScaleRef.current = false;
390
+ }
391
+ });
392
+ }, []);
393
+ React.useEffect(() => {
394
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
395
+ }, [range.length]); // 只在range长度变化时重新计算
396
+ // props 的 selectedIndex 变化:滚至对应项并短时标记程序化滚动(syncScrollFromPropsRef)
397
+ React.useEffect(() => {
398
+ if (scrollViewRef.current && range.length > 0 && !isTouchingRef.current) {
399
+ syncScrollFromPropsRef.current = true;
400
+ const baseValue = selectedIndex * itemHeightRef.current;
401
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, undefined, lengthScaleRatioRef.current);
402
+ setCurrentIndex(selectedIndex);
403
+ const tid = setTimeout(() => {
404
+ syncScrollFromPropsRef.current = false;
405
+ }, 400);
406
+ return () => clearTimeout(tid);
407
+ }
408
+ }, [selectedIndex, range]);
409
+ // time 限位 nonce 变更:强制对齐 scrollTop(避免 remount 打断读屏焦点)
410
+ React.useEffect(() => {
411
+ if (!timeA11yLimitEventNonce) return;
412
+ if (!scrollViewRef.current || range.length === 0 || isTouchingRef.current) return;
413
+ syncScrollFromPropsRef.current = true;
414
+ const baseValue = selectedIndex * itemHeightRef.current;
415
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, Math.random() * 0.001, lengthScaleRatioRef.current);
416
+ setCurrentIndex(selectedIndex);
417
+ const tid = setTimeout(() => {
418
+ syncScrollFromPropsRef.current = false;
419
+ }, 400);
420
+ return () => clearTimeout(tid);
421
+ }, [timeA11yLimitEventNonce]); // 仅依赖 nonce,其余用 ref
422
+ React.useLayoutEffect(() => {
423
+ if (timeA11yLimitEventNonce === undefined) return;
424
+ const prev = prevLimitEventNonceRef.current;
425
+ prevLimitEventNonceRef.current = timeA11yLimitEventNonce;
426
+ if (timeA11yLimitEventNonce > 0 && (prev === undefined || timeA11yLimitEventNonce > prev)) {
427
+ suppressScrollSettleFocusNonceRef.current = timeA11yLimitEventNonce;
428
+ }
429
+ }, [timeA11yLimitEventNonce]);
430
+ // 限位后登记本列待聚焦项,稳定后再 requestAccessibilityFocus
431
+ React.useEffect(() => {
432
+ const req = timeA11yLimitFocus;
433
+ if (!req || req.columnId !== columnId) return;
434
+ const idx = selectedIndex;
435
+ const nonce = req.nonce;
436
+ pendingScrollSettleFocusRef.current = false;
437
+ pendingLimitFocusRef.current = {
438
+ index: idx,
439
+ nonce,
440
+ attempts: 0
441
+ };
442
+ schedulePendingLimitFocus();
443
+ }, [timeA11yLimitFocus, columnId, selectedIndex, schedulePendingLimitFocus]);
444
+ // 是否处于归中状态
445
+ const isCenterTimerId = React.useRef(null);
446
+ // 滚动静止后归中并同步选中
447
+ const handleScrollEnd = () => {
448
+ if (!scrollViewRef.current) return;
449
+ if (isCenterTimerId.current) {
450
+ clearTimeout(isCenterTimerId.current);
451
+ isCenterTimerId.current = null;
452
+ }
453
+ // 100ms 内无新滚动则归中并提交索引
454
+ isCenterTimerId.current = setTimeout(() => {
455
+ if (!scrollViewRef.current) return;
456
+ const scrollTop = scrollViewRef.current.scrollTop;
457
+ const newIndex = getSelectedIndex(scrollTop, itemHeightRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
458
+ const allowA11yFocus = !syncScrollFromPropsRef.current;
459
+ const shouldFocusOnScrollSettle = pendingScrollSettleFocusRef.current;
460
+ isTouchingRef.current = false;
461
+ const isLimited = Boolean(updateIndex(newIndex, columnId, true));
462
+ const hasPendingLimitFocus = pendingLimitFocusRef.current != null;
463
+ if (isLimited) {
464
+ pendingScrollSettleFocusRef.current = false;
465
+ }
466
+ if (!isLimited) {
467
+ const baseValue = newIndex * itemHeightRef.current;
468
+ const randomOffset = Math.random() * 0.001;
469
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, randomOffset, lengthScaleRatioRef.current);
470
+ }
471
+ if (!isLimited && hasPendingLimitFocus) {
472
+ pendingScrollSettleFocusRef.current = false;
473
+ schedulePendingLimitFocus();
474
+ syncScrollFromPropsRef.current = false;
475
+ isCenterTimerId.current = null;
476
+ return;
477
+ }
478
+ if (!isLimited && pendingLimitFocusRef.current == null && suppressScrollSettleFocusNonceRef.current != null) {
479
+ suppressScrollSettleFocusNonceRef.current = null;
480
+ }
481
+ const suppressByLimitNonce = suppressScrollSettleFocusNonceRef.current != null;
482
+ if (!isLimited && allowA11yFocus && shouldFocusOnScrollSettle) {
483
+ pendingScrollSettleFocusRef.current = false;
484
+ if (!suppressByLimitNonce) {
485
+ requestAccessibilityFocusOnView(itemRefs.current[newIndex]);
486
+ }
487
+ }
488
+ syncScrollFromPropsRef.current = false;
489
+ isCenterTimerId.current = null;
490
+ }, 100);
491
+ };
492
+ // 滚动中:按 scrollTop 更新高亮索引
493
+ const handleScroll = () => {
494
+ if (!scrollViewRef.current) return;
495
+ if (isCenterTimerId.current) {
496
+ clearTimeout(isCenterTimerId.current);
497
+ isCenterTimerId.current = null;
498
+ }
499
+ const scrollTop = scrollViewRef.current.scrollTop;
500
+ const ih = itemHeightRef.current;
501
+ const newIndex = getSelectedIndex(scrollTop, ih, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
502
+ const spi = selectedIndexPropRef.current;
503
+ if (newIndex !== spi) {
504
+ if (!syncScrollFromPropsRef.current || isTouchingRef.current) {
505
+ pendingScrollSettleFocusRef.current = true;
506
+ }
507
+ if (isTouchingRef.current) {
508
+ syncScrollFromPropsRef.current = false;
509
+ }
510
+ }
511
+ if (newIndex !== currentIndex) {
512
+ setCurrentIndex(newIndex);
513
+ }
514
+ if (pendingLimitFocusRef.current) {
515
+ schedulePendingLimitFocus();
516
+ }
517
+ };
518
+ // 渲染选项
519
+ const pickerItem = range.map((item, index) => {
520
+ const content = rangeKey && item && typeof item === 'object' ? item[rangeKey] : item;
521
+ return createComponent(View, mergeProps({
522
+ id: `picker-item-${columnId}-${index}`,
523
+ key: index,
524
+ ref: el => itemRefs.current[index] = el,
525
+ className: `taro-picker__item${index === currentIndex ? ' taro-picker__item--selected' : ''}`
526
+ }, enableClickItemScroll ? {
527
+ onClick: () => scrollToItemId(`picker-item-${columnId}-${index}`)
528
+ } : {}, {
529
+ get style() {
530
+ return {
531
+ height: PICKER_LINE_HEIGHT,
532
+ color: index === currentIndex ? colors.itemSelectedColor || undefined : colors.itemDefaultColor || undefined
533
+ };
534
+ },
535
+ children: content
536
+ }));
537
+ });
538
+ const realPickerItems = [...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
539
+ key: `blank-top-${idx}`,
540
+ className: "taro-picker__item taro-picker__item--blank",
541
+ style: {
542
+ height: PICKER_LINE_HEIGHT
543
+ }
544
+ })), ...pickerItem, ...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
545
+ key: `blank-bottom-${idx}`,
546
+ className: "taro-picker__item taro-picker__item--blank",
547
+ style: {
548
+ height: PICKER_LINE_HEIGHT
549
+ }
550
+ }))];
551
+ const clickScrollViewProps = enableClickItemScroll ? {
552
+ scrollIntoView,
553
+ scrollIntoViewAlignment: 'center'
554
+ } : {};
555
+ return createComponent(View, {
556
+ className: "taro-picker__group",
557
+ get children() {
558
+ return [createComponent(View, {
559
+ className: "taro-picker__mask"
560
+ }), createComponent(View, mergeProps({
561
+ className: "taro-picker__indicator"
562
+ }, indicatorStyle ? {
563
+ style: indicatorStyle
564
+ } : {})), createComponent(ScrollView, mergeProps({
565
+ ref: scrollViewRef,
566
+ scrollY: true,
567
+ showScrollbar: false,
568
+ className: "taro-picker__content",
569
+ style: {
570
+ height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
571
+ },
572
+ scrollTop: targetScrollTop
573
+ }, clickScrollViewProps, {
574
+ onScroll: handleScroll,
575
+ onTouchStart: () => {
576
+ isTouchingRef.current = true;
577
+ },
578
+ onScrollEnd: handleScrollEnd,
579
+ scrollWithAnimation: true,
580
+ children: realPickerItems
581
+ }))];
582
+ }
583
+ });
584
+ }
585
+ // 日期选择器实现
586
+ function PickerGroupDate(props) {
587
+ const {
588
+ range = [],
589
+ columnId,
590
+ updateDay,
591
+ selectedIndex = 0,
592
+ colors = {},
593
+ enableClickItemScroll = true
594
+ } = props;
595
+ const indicatorStyle = colors.lineColor ? getIndicatorStyle(colors.lineColor) : null;
596
+ const [targetScrollTop, setTargetScrollTop] = React.useState(0);
597
+ const [scrollIntoView, scrollToItemId] = usePickerItemScrollIntoView();
598
+ const scrollViewRef = React.useRef(null);
599
+ const itemRefs = React.useRef([]);
600
+ const selectedIndexPropRef = React.useRef(selectedIndex);
601
+ selectedIndexPropRef.current = selectedIndex;
602
+ const syncScrollFromPropsRef = React.useRef(false);
603
+ const pendingScrollSettleFocusRef = React.useRef(false);
604
+ const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
605
+ const isTouchingRef = React.useRef(false);
606
+ const lengthScaleRatioRef = React.useRef(1);
607
+ const useMeasuredScaleRef = React.useRef(false);
608
+ const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
609
+ // 初始化时计算 lengthScaleRatio 并判定缩放模式
610
+ React.useEffect(() => {
611
+ Taro.getSystemInfo({
612
+ success: res => {
613
+ lengthScaleRatioRef.current = calculateLengthScaleRatio(res);
614
+ useMeasuredScaleRef.current = resolveUseMeasuredScale(res);
615
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
616
+ },
617
+ fail: () => {
618
+ lengthScaleRatioRef.current = 1;
619
+ useMeasuredScaleRef.current = false;
620
+ }
621
+ });
622
+ }, []);
623
+ React.useEffect(() => {
624
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
625
+ }, [range.length]); // 只在range长度变化时重新计算
626
+ // props 的 selectedIndex 变化:滚至对应项并短时标记程序化滚动(syncScrollFromPropsRef)
627
+ React.useEffect(() => {
628
+ if (scrollViewRef.current && range.length > 0 && !isTouchingRef.current) {
629
+ syncScrollFromPropsRef.current = true;
630
+ const baseValue = selectedIndex * itemHeightRef.current;
631
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, undefined, lengthScaleRatioRef.current);
632
+ setCurrentIndex(selectedIndex);
633
+ const tid = setTimeout(() => {
634
+ syncScrollFromPropsRef.current = false;
635
+ }, 400);
636
+ return () => clearTimeout(tid);
637
+ }
638
+ }, [selectedIndex, range]);
639
+ // 是否处于归中状态
640
+ const isCenterTimerId = React.useRef(null);
641
+ // 滚动静止后归中并同步选中
642
+ const handleScrollEnd = () => {
643
+ if (!scrollViewRef.current) return;
644
+ if (isCenterTimerId.current) {
645
+ clearTimeout(isCenterTimerId.current);
646
+ isCenterTimerId.current = null;
647
+ }
648
+ // 100ms 内无新滚动则归中并提交索引
649
+ isCenterTimerId.current = setTimeout(() => {
650
+ if (!scrollViewRef.current) return;
651
+ const scrollTop = scrollViewRef.current.scrollTop;
652
+ const newIndex = getSelectedIndex(scrollTop, itemHeightRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
653
+ const allowA11yFocus = !syncScrollFromPropsRef.current;
654
+ const shouldFocusOnScrollSettle = pendingScrollSettleFocusRef.current;
655
+ isTouchingRef.current = false;
656
+ const baseValue = newIndex * itemHeightRef.current;
657
+ const randomOffset = Math.random() * 0.001; // 随机数为了在一个项内滚动时强制刷新
658
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, randomOffset, lengthScaleRatioRef.current);
659
+ // 更新日期值
660
+ if (updateDay) {
661
+ // 解析文本中的数字(移除年、月、日等后缀)
662
+ const valueText = range[newIndex] || '';
663
+ const numericValue = parseInt(valueText.replace(/[^0-9]/g, ''));
664
+ updateDay(isNaN(numericValue) ? 0 : numericValue, parseInt(columnId));
665
+ }
666
+ pendingScrollSettleFocusRef.current = false;
667
+ if (allowA11yFocus && shouldFocusOnScrollSettle) {
668
+ requestAccessibilityFocusOnView(itemRefs.current[newIndex]);
669
+ }
670
+ syncScrollFromPropsRef.current = false;
671
+ isCenterTimerId.current = null;
672
+ }, 100);
673
+ };
674
+ // 滚动中:按 scrollTop 更新高亮索引
675
+ const handleScroll = () => {
676
+ if (!scrollViewRef.current) return;
677
+ if (isCenterTimerId.current) {
678
+ clearTimeout(isCenterTimerId.current);
679
+ isCenterTimerId.current = null;
680
+ }
681
+ const scrollTop = scrollViewRef.current.scrollTop;
682
+ const ih = itemHeightRef.current;
683
+ const newIndex = getSelectedIndex(scrollTop, ih, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
684
+ const spi = selectedIndexPropRef.current;
685
+ if (newIndex !== spi) {
686
+ if (!syncScrollFromPropsRef.current || isTouchingRef.current) {
687
+ pendingScrollSettleFocusRef.current = true;
688
+ }
689
+ if (isTouchingRef.current) {
690
+ syncScrollFromPropsRef.current = false;
691
+ }
692
+ }
693
+ if (newIndex !== currentIndex) {
694
+ setCurrentIndex(newIndex);
695
+ }
696
+ };
697
+ // 渲染选项
698
+ const pickerItem = range.map((item, index) => {
699
+ return createComponent(View, mergeProps({
700
+ id: `picker-item-${columnId}-${index}`,
701
+ key: index,
702
+ ref: el => itemRefs.current[index] = el,
703
+ className: `taro-picker__item${index === currentIndex ? ' taro-picker__item--selected' : ''}`
704
+ }, enableClickItemScroll ? {
705
+ onClick: () => scrollToItemId(`picker-item-${columnId}-${index}`)
706
+ } : {}, {
707
+ get style() {
708
+ return {
709
+ height: PICKER_LINE_HEIGHT,
710
+ color: index === currentIndex ? colors.itemSelectedColor || undefined : colors.itemDefaultColor || undefined
711
+ };
712
+ },
713
+ children: item
714
+ }));
715
+ });
716
+ const realPickerItems = [...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
717
+ key: `blank-top-${idx}`,
718
+ className: "taro-picker__item taro-picker__item--blank",
719
+ style: {
720
+ height: PICKER_LINE_HEIGHT
721
+ }
722
+ })), ...pickerItem, ...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
723
+ key: `blank-bottom-${idx}`,
724
+ className: "taro-picker__item taro-picker__item--blank",
725
+ style: {
726
+ height: PICKER_LINE_HEIGHT
727
+ }
728
+ }))];
729
+ const clickScrollViewProps = enableClickItemScroll ? {
730
+ scrollIntoView,
731
+ scrollIntoViewAlignment: 'center'
732
+ } : {};
733
+ return createComponent(View, {
734
+ className: "taro-picker__group",
735
+ get children() {
736
+ return [createComponent(View, {
737
+ className: "taro-picker__mask"
738
+ }), createComponent(View, mergeProps({
739
+ className: "taro-picker__indicator"
740
+ }, indicatorStyle ? {
741
+ style: indicatorStyle
742
+ } : {})), createComponent(ScrollView, mergeProps({
743
+ ref: scrollViewRef,
744
+ scrollY: true,
745
+ showScrollbar: false,
746
+ className: "taro-picker__content",
747
+ style: {
748
+ height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
749
+ },
750
+ scrollTop: targetScrollTop
751
+ }, clickScrollViewProps, {
752
+ onScroll: handleScroll,
753
+ onTouchStart: () => {
754
+ isTouchingRef.current = true;
755
+ },
756
+ onScrollEnd: handleScrollEnd,
757
+ scrollWithAnimation: true,
758
+ children: realPickerItems
759
+ }))];
760
+ }
761
+ });
762
+ }
763
+ // 地区选择器实现
764
+ function PickerGroupRegion(props) {
765
+ const {
766
+ range = [],
767
+ rangeKey,
768
+ columnId,
769
+ updateIndex,
770
+ selectedIndex = 0,
771
+ // 使用selectedIndex参数,默认为0
772
+ colors = {},
773
+ enableClickItemScroll = true
774
+ } = props;
775
+ const indicatorStyle = colors.lineColor ? getIndicatorStyle(colors.lineColor) : null;
776
+ const scrollViewRef = React.useRef(null);
777
+ const [targetScrollTop, setTargetScrollTop] = React.useState(0);
778
+ const [scrollIntoView, scrollToItemId] = usePickerItemScrollIntoView();
779
+ const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
780
+ const isTouchingRef = React.useRef(false);
781
+ const lengthScaleRatioRef = React.useRef(1);
782
+ const useMeasuredScaleRef = React.useRef(false);
783
+ const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
784
+ const itemRefs = React.useRef([]);
785
+ const selectedIndexPropRef = React.useRef(selectedIndex);
786
+ selectedIndexPropRef.current = selectedIndex;
787
+ const syncScrollFromPropsRef = React.useRef(false);
788
+ const pendingScrollSettleFocusRef = React.useRef(false);
789
+ // 初始化时计算 lengthScaleRatio 并判定缩放模式
790
+ React.useEffect(() => {
791
+ Taro.getSystemInfo({
792
+ success: res => {
793
+ lengthScaleRatioRef.current = calculateLengthScaleRatio(res);
794
+ useMeasuredScaleRef.current = resolveUseMeasuredScale(res);
795
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
796
+ },
797
+ fail: () => {
798
+ lengthScaleRatioRef.current = 1;
799
+ useMeasuredScaleRef.current = false;
800
+ }
801
+ });
802
+ }, []);
803
+ React.useEffect(() => {
804
+ itemHeightRef.current = calculateItemHeight(scrollViewRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
805
+ }, [range.length]); // 只在range长度变化时重新计算
806
+ // props 的 selectedIndex 变化:滚至对应项并短时标记程序化滚动(syncScrollFromPropsRef)
807
+ React.useEffect(() => {
808
+ if (scrollViewRef.current && range.length > 0 && !isTouchingRef.current) {
809
+ syncScrollFromPropsRef.current = true;
810
+ const baseValue = selectedIndex * itemHeightRef.current;
811
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, undefined, lengthScaleRatioRef.current);
812
+ setCurrentIndex(selectedIndex);
813
+ const tid = setTimeout(() => {
814
+ syncScrollFromPropsRef.current = false;
815
+ }, 400);
816
+ return () => clearTimeout(tid);
817
+ }
818
+ }, [selectedIndex, range]);
819
+ // 滚动静止后归中(debounce)
820
+ const isCenterTimerId = React.useRef(null);
821
+ const handleScrollEnd = () => {
822
+ if (!scrollViewRef.current) return;
823
+ if (isCenterTimerId.current) {
824
+ clearTimeout(isCenterTimerId.current);
825
+ isCenterTimerId.current = null;
826
+ }
827
+ // 100ms 内无新滚动则归中并提交索引
828
+ isCenterTimerId.current = setTimeout(() => {
829
+ if (!scrollViewRef.current) return;
830
+ const scrollTop = scrollViewRef.current.scrollTop;
831
+ const newIndex = getSelectedIndex(scrollTop, itemHeightRef.current, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
832
+ const allowA11yFocus = !syncScrollFromPropsRef.current;
833
+ const shouldFocusOnScrollSettle = pendingScrollSettleFocusRef.current;
834
+ isTouchingRef.current = false;
835
+ const baseValue = newIndex * itemHeightRef.current;
836
+ const randomOffset = Math.random() * 0.001; // 随机数为了在一个项内滚动时强制刷新
837
+ setTargetScrollTopWithScale(setTargetScrollTop, baseValue, randomOffset, lengthScaleRatioRef.current);
838
+ updateIndex(newIndex, columnId, false, allowA11yFocus);
839
+ pendingScrollSettleFocusRef.current = false;
840
+ if (allowA11yFocus && shouldFocusOnScrollSettle) {
841
+ requestAccessibilityFocusOnView(itemRefs.current[newIndex]);
842
+ }
843
+ syncScrollFromPropsRef.current = false;
844
+ isCenterTimerId.current = null;
845
+ }, 100);
846
+ };
847
+ // 滚动中:按 scrollTop 更新高亮索引
848
+ const handleScroll = () => {
849
+ if (!scrollViewRef.current) return;
850
+ if (isCenterTimerId.current) {
851
+ clearTimeout(isCenterTimerId.current);
852
+ isCenterTimerId.current = null;
853
+ }
854
+ const scrollTop = scrollViewRef.current.scrollTop;
855
+ const ih = itemHeightRef.current;
856
+ const newIndex = getSelectedIndex(scrollTop, ih, lengthScaleRatioRef.current, useMeasuredScaleRef.current);
857
+ const spi = selectedIndexPropRef.current;
858
+ if (newIndex !== spi) {
859
+ if (!syncScrollFromPropsRef.current || isTouchingRef.current) {
860
+ pendingScrollSettleFocusRef.current = true;
861
+ }
862
+ if (isTouchingRef.current) {
863
+ syncScrollFromPropsRef.current = false;
864
+ }
865
+ }
866
+ if (newIndex !== currentIndex) {
867
+ setCurrentIndex(newIndex);
868
+ }
869
+ };
870
+ // 渲染选项
871
+ const pickerItem = range.map((item, index) => {
872
+ const content = rangeKey && item && typeof item === 'object' ? item[rangeKey] : item;
873
+ return createComponent(View, mergeProps({
874
+ id: `picker-item-${columnId}-${index}`,
875
+ key: index,
876
+ ref: el => itemRefs.current[index] = el,
877
+ className: `taro-picker__item${index === currentIndex ? ' taro-picker__item--selected' : ''}`
878
+ }, enableClickItemScroll ? {
879
+ onClick: () => scrollToItemId(`picker-item-${columnId}-${index}`)
880
+ } : {}, {
881
+ get style() {
882
+ return {
883
+ height: PICKER_LINE_HEIGHT,
884
+ color: index === currentIndex ? colors.itemSelectedColor || undefined : colors.itemDefaultColor || undefined
885
+ };
886
+ },
887
+ children: content
888
+ }));
889
+ });
890
+ const realPickerItems = [...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
891
+ key: `blank-top-${idx}`,
892
+ className: "taro-picker__item taro-picker__item--blank",
893
+ style: {
894
+ height: PICKER_LINE_HEIGHT
895
+ }
896
+ })), ...pickerItem, ...new Array(PICKER_BLANK_ITEMS).fill(null).map((_, idx) => createComponent(View, {
897
+ key: `blank-bottom-${idx}`,
898
+ className: "taro-picker__item taro-picker__item--blank",
899
+ style: {
900
+ height: PICKER_LINE_HEIGHT
901
+ }
902
+ }))];
903
+ const clickScrollViewProps = enableClickItemScroll ? {
904
+ scrollIntoView,
905
+ scrollIntoViewAlignment: 'center'
906
+ } : {};
907
+ return createComponent(View, {
908
+ className: "taro-picker__group",
909
+ get children() {
910
+ return [createComponent(View, {
911
+ className: "taro-picker__mask"
912
+ }), createComponent(View, mergeProps({
913
+ className: "taro-picker__indicator"
914
+ }, indicatorStyle ? {
915
+ style: indicatorStyle
916
+ } : {})), createComponent(ScrollView, mergeProps({
917
+ ref: scrollViewRef,
918
+ scrollY: true,
919
+ showScrollbar: false,
920
+ className: "taro-picker__content",
921
+ style: {
922
+ height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
923
+ },
924
+ scrollTop: targetScrollTop
925
+ }, clickScrollViewProps, {
926
+ onScroll: handleScroll,
927
+ onTouchStart: () => {
928
+ isTouchingRef.current = true;
929
+ },
930
+ onScrollEnd: handleScrollEnd,
931
+ scrollWithAnimation: true,
932
+ children: realPickerItems
933
+ }))];
934
+ }
935
+ });
936
+ }
937
+ // 旧版无障碍(逐项 setAccessibilityFocus),根据 mode 自动分发
938
+ function PickerGroupLegacy(props) {
939
+ switch (props.mode) {
940
+ case 'time':
941
+ return createComponent(PickerGroupTime, props);
942
+ case 'date':
943
+ return createComponent(PickerGroupDate, props);
944
+ case 'region':
945
+ return createComponent(PickerGroupRegion, props);
946
+ default:
947
+ return createComponent(PickerGroupBasic, props);
948
+ }
949
+ }
950
+
951
+ export { PickerGroupBasic, PickerGroupDate, PickerGroupLegacy, PickerGroupRegion, PickerGroupTime };
952
+ //# sourceMappingURL=picker-group-legacy.js.map