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

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.
@@ -17,6 +17,16 @@ function usePickerItemScrollIntoView() {
17
17
  }, []);
18
18
  return [scrollIntoView, scrollToItemId];
19
19
  }
20
+ /** 系统读屏是否开启:开启时 mask 需可命中(关掉 pointer-events:none) */
21
+ function useA11yOpen() {
22
+ const [a11yOpen, setA11yOpen] = React.useState(false);
23
+ React.useEffect(() => {
24
+ Taro.checkIsOpenAccessibility().then(res => {
25
+ setA11yOpen(!!res.open);
26
+ }).catch(() => {});
27
+ }, []);
28
+ return a11yOpen;
29
+ }
20
30
  // 定义常量
21
31
  const PICKER_LINE_HEIGHT = 34; // px
22
32
  const PICKER_VISIBLE_ITEMS = 7; // 可见行数
@@ -127,6 +137,8 @@ function PickerGroupBasic(props) {
127
137
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
128
138
  // 触摸状态用于优化用户体验
129
139
  const isTouchingRef = React.useRef(false);
140
+ // 系统读屏开启时关闭 mask 的 pointer-events:none,便于无障碍命中;未开启则保持穿透以便手势滚动
141
+ const a11yOpen = useA11yOpen();
130
142
  const lengthScaleRatioRef = React.useRef(1);
131
143
  const useMeasuredScaleRef = React.useRef(false);
132
144
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -281,10 +293,23 @@ function PickerGroupBasic(props) {
281
293
  },
282
294
  children: [/*#__PURE__*/jsx(View, {
283
295
  className: "taro-picker__mask",
284
- ariaHidden: true
296
+ style: a11yOpen ? {
297
+ pointerEvents: 'auto'
298
+ } : undefined,
299
+ ariaRole: "slider",
300
+ ariaLabel: ariaLabel
301
+ // @ts-expect-error Taro View 未声明无障碍扩展 props
302
+ ,
303
+ ariaAction: [{
304
+ name: 'increment',
305
+ label: 'increment'
306
+ }, {
307
+ name: 'decrement',
308
+ label: 'decrement'
309
+ }],
310
+ onAriaAction: handleAriaAction
285
311
  }), /*#__PURE__*/jsx(View, {
286
312
  className: "taro-picker__indicator",
287
- ariaHidden: true,
288
313
  ...(indicatorStyle ? {
289
314
  style: indicatorStyle
290
315
  } : {})
@@ -294,8 +319,6 @@ function PickerGroupBasic(props) {
294
319
  showScrollbar: false,
295
320
  className: "taro-picker__content",
296
321
  ariaHidden: true,
297
- accessibilityElementsHidden: true,
298
- importantForAccessibility: 'no-hide-descendants',
299
322
  style: {
300
323
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
301
324
  },
@@ -308,28 +331,6 @@ function PickerGroupBasic(props) {
308
331
  onScrollEnd: handleScrollEnd,
309
332
  scrollWithAnimation: true,
310
333
  children: realPickerItems
311
- }), /*#__PURE__*/jsx(View, {
312
- className: "taro-picker__a11y-overlay",
313
- style: {
314
- position: 'absolute',
315
- top: 0,
316
- left: 0,
317
- right: 0,
318
- bottom: 0,
319
- pointerEvents: 'none'
320
- },
321
- ariaRole: "slider",
322
- ...(ariaLabel !== undefined ? {
323
- ariaLabel
324
- } : {}),
325
- ariaAction: [{
326
- name: 'increment',
327
- label: 'increment'
328
- }, {
329
- name: 'decrement',
330
- label: 'decrement'
331
- }],
332
- onAriaAction: handleAriaAction
333
334
  })]
334
335
  });
335
336
  }
@@ -352,6 +353,7 @@ function PickerGroupTime(props) {
352
353
  const scrollViewRef = React.useRef(null);
353
354
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
354
355
  const isTouchingRef = React.useRef(false);
356
+ const a11yOpen = useA11yOpen();
355
357
  const lengthScaleRatioRef = React.useRef(1);
356
358
  const useMeasuredScaleRef = React.useRef(false);
357
359
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -522,7 +524,21 @@ function PickerGroupTime(props) {
522
524
  },
523
525
  children: [/*#__PURE__*/jsx(View, {
524
526
  className: "taro-picker__mask",
525
- ariaHidden: true
527
+ style: a11yOpen ? {
528
+ pointerEvents: 'auto'
529
+ } : undefined,
530
+ ariaRole: "slider",
531
+ ariaLabel: ariaLabel
532
+ // @ts-expect-error Taro View 未声明无障碍扩展 props
533
+ ,
534
+ ariaAction: [{
535
+ name: 'increment',
536
+ label: 'increment'
537
+ }, {
538
+ name: 'decrement',
539
+ label: 'decrement'
540
+ }],
541
+ onAriaAction: handleAriaAction
526
542
  }), /*#__PURE__*/jsx(View, {
527
543
  className: "taro-picker__indicator",
528
544
  ariaHidden: true,
@@ -549,28 +565,6 @@ function PickerGroupTime(props) {
549
565
  onScrollEnd: handleScrollEnd,
550
566
  scrollWithAnimation: true,
551
567
  children: realPickerItems
552
- }), /*#__PURE__*/jsx(View, {
553
- className: "taro-picker__a11y-overlay",
554
- style: {
555
- position: 'absolute',
556
- top: 0,
557
- left: 0,
558
- right: 0,
559
- bottom: 0,
560
- pointerEvents: 'none'
561
- },
562
- ariaRole: "slider",
563
- ...(ariaLabel !== undefined ? {
564
- ariaLabel
565
- } : {}),
566
- ariaAction: [{
567
- name: 'increment',
568
- label: 'increment'
569
- }, {
570
- name: 'decrement',
571
- label: 'decrement'
572
- }],
573
- onAriaAction: handleAriaAction
574
568
  })]
575
569
  });
576
570
  }
@@ -590,6 +584,7 @@ function PickerGroupDate(props) {
590
584
  const scrollViewRef = React.useRef(null);
591
585
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
592
586
  const isTouchingRef = React.useRef(false);
587
+ const a11yOpen = useA11yOpen();
593
588
  const lengthScaleRatioRef = React.useRef(1);
594
589
  const useMeasuredScaleRef = React.useRef(false);
595
590
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -739,7 +734,21 @@ function PickerGroupDate(props) {
739
734
  },
740
735
  children: [/*#__PURE__*/jsx(View, {
741
736
  className: "taro-picker__mask",
742
- ariaHidden: true
737
+ style: a11yOpen ? {
738
+ pointerEvents: 'auto'
739
+ } : undefined,
740
+ ariaRole: "slider",
741
+ ariaLabel: ariaLabel
742
+ // @ts-expect-error Taro View 未声明无障碍扩展 props
743
+ ,
744
+ ariaAction: [{
745
+ name: 'increment',
746
+ label: 'increment'
747
+ }, {
748
+ name: 'decrement',
749
+ label: 'decrement'
750
+ }],
751
+ onAriaAction: handleAriaAction
743
752
  }), /*#__PURE__*/jsx(View, {
744
753
  className: "taro-picker__indicator",
745
754
  ariaHidden: true,
@@ -766,28 +775,6 @@ function PickerGroupDate(props) {
766
775
  onScrollEnd: handleScrollEnd,
767
776
  scrollWithAnimation: true,
768
777
  children: realPickerItems
769
- }), /*#__PURE__*/jsx(View, {
770
- className: "taro-picker__a11y-overlay",
771
- style: {
772
- position: 'absolute',
773
- top: 0,
774
- left: 0,
775
- right: 0,
776
- bottom: 0,
777
- pointerEvents: 'none'
778
- },
779
- ariaRole: "slider",
780
- ...(ariaLabel !== undefined ? {
781
- ariaLabel
782
- } : {}),
783
- ariaAction: [{
784
- name: 'increment',
785
- label: 'increment'
786
- }, {
787
- name: 'decrement',
788
- label: 'decrement'
789
- }],
790
- onAriaAction: handleAriaAction
791
778
  })]
792
779
  });
793
780
  }
@@ -811,6 +798,7 @@ function PickerGroupRegion(props) {
811
798
  const isTouchingRef = React.useRef(false);
812
799
  // 程序化滚动标记:开屏/受控同步预设值时置 true,避免被 region 级联门误判为用户滚动而重置后续列
813
800
  const syncScrollFromPropsRef = React.useRef(false);
801
+ const a11yOpen = useA11yOpen();
814
802
  const lengthScaleRatioRef = React.useRef(1);
815
803
  const useMeasuredScaleRef = React.useRef(false);
816
804
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -968,7 +956,21 @@ function PickerGroupRegion(props) {
968
956
  },
969
957
  children: [/*#__PURE__*/jsx(View, {
970
958
  className: "taro-picker__mask",
971
- ariaHidden: true
959
+ style: a11yOpen ? {
960
+ pointerEvents: 'auto'
961
+ } : undefined,
962
+ ariaRole: "slider",
963
+ ariaLabel: ariaLabel
964
+ // @ts-expect-error Taro View 未声明无障碍扩展 props
965
+ ,
966
+ ariaAction: [{
967
+ name: 'increment',
968
+ label: 'increment'
969
+ }, {
970
+ name: 'decrement',
971
+ label: 'decrement'
972
+ }],
973
+ onAriaAction: handleAriaAction
972
974
  }), /*#__PURE__*/jsx(View, {
973
975
  className: "taro-picker__indicator",
974
976
  ariaHidden: true,
@@ -995,28 +997,6 @@ function PickerGroupRegion(props) {
995
997
  onScrollEnd: handleScrollEnd,
996
998
  scrollWithAnimation: true,
997
999
  children: realPickerItems
998
- }), /*#__PURE__*/jsx(View, {
999
- className: "taro-picker__a11y-overlay",
1000
- style: {
1001
- position: 'absolute',
1002
- top: 0,
1003
- left: 0,
1004
- right: 0,
1005
- bottom: 0,
1006
- pointerEvents: 'none'
1007
- },
1008
- ariaRole: "slider",
1009
- ...(ariaLabel !== undefined ? {
1010
- ariaLabel
1011
- } : {}),
1012
- ariaAction: [{
1013
- name: 'increment',
1014
- label: 'increment'
1015
- }, {
1016
- name: 'decrement',
1017
- label: 'decrement'
1018
- }],
1019
- onAriaAction: handleAriaAction
1020
1000
  })]
1021
1001
  });
1022
1002
  }