@tarojs/components-react 4.1.12-beta.62 → 4.1.12-beta.64

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,7 +293,21 @@ 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
313
  ariaHidden: true,
@@ -294,8 +320,6 @@ function PickerGroupBasic(props) {
294
320
  showScrollbar: false,
295
321
  className: "taro-picker__content",
296
322
  ariaHidden: true,
297
- accessibilityElementsHidden: true,
298
- importantForAccessibility: 'no-hide-descendants',
299
323
  style: {
300
324
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
301
325
  },
@@ -308,28 +332,6 @@ function PickerGroupBasic(props) {
308
332
  onScrollEnd: handleScrollEnd,
309
333
  scrollWithAnimation: true,
310
334
  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
335
  })]
334
336
  });
335
337
  }
@@ -352,6 +354,7 @@ function PickerGroupTime(props) {
352
354
  const scrollViewRef = React.useRef(null);
353
355
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
354
356
  const isTouchingRef = React.useRef(false);
357
+ const a11yOpen = useA11yOpen();
355
358
  const lengthScaleRatioRef = React.useRef(1);
356
359
  const useMeasuredScaleRef = React.useRef(false);
357
360
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -522,7 +525,21 @@ function PickerGroupTime(props) {
522
525
  },
523
526
  children: [/*#__PURE__*/jsx(View, {
524
527
  className: "taro-picker__mask",
525
- ariaHidden: true
528
+ style: a11yOpen ? {
529
+ pointerEvents: 'auto'
530
+ } : undefined,
531
+ ariaRole: "slider",
532
+ ariaLabel: ariaLabel
533
+ // @ts-expect-error Taro View 未声明无障碍扩展 props
534
+ ,
535
+ ariaAction: [{
536
+ name: 'increment',
537
+ label: 'increment'
538
+ }, {
539
+ name: 'decrement',
540
+ label: 'decrement'
541
+ }],
542
+ onAriaAction: handleAriaAction
526
543
  }), /*#__PURE__*/jsx(View, {
527
544
  className: "taro-picker__indicator",
528
545
  ariaHidden: true,
@@ -535,8 +552,6 @@ function PickerGroupTime(props) {
535
552
  showScrollbar: false,
536
553
  className: "taro-picker__content",
537
554
  ariaHidden: true,
538
- accessibilityElementsHidden: true,
539
- importantForAccessibility: 'no-hide-descendants',
540
555
  style: {
541
556
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
542
557
  },
@@ -549,28 +564,6 @@ function PickerGroupTime(props) {
549
564
  onScrollEnd: handleScrollEnd,
550
565
  scrollWithAnimation: true,
551
566
  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
567
  })]
575
568
  });
576
569
  }
@@ -590,6 +583,7 @@ function PickerGroupDate(props) {
590
583
  const scrollViewRef = React.useRef(null);
591
584
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
592
585
  const isTouchingRef = React.useRef(false);
586
+ const a11yOpen = useA11yOpen();
593
587
  const lengthScaleRatioRef = React.useRef(1);
594
588
  const useMeasuredScaleRef = React.useRef(false);
595
589
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -739,7 +733,21 @@ function PickerGroupDate(props) {
739
733
  },
740
734
  children: [/*#__PURE__*/jsx(View, {
741
735
  className: "taro-picker__mask",
742
- ariaHidden: true
736
+ style: a11yOpen ? {
737
+ pointerEvents: 'auto'
738
+ } : undefined,
739
+ ariaRole: "slider",
740
+ ariaLabel: ariaLabel
741
+ // @ts-expect-error Taro View 未声明无障碍扩展 props
742
+ ,
743
+ ariaAction: [{
744
+ name: 'increment',
745
+ label: 'increment'
746
+ }, {
747
+ name: 'decrement',
748
+ label: 'decrement'
749
+ }],
750
+ onAriaAction: handleAriaAction
743
751
  }), /*#__PURE__*/jsx(View, {
744
752
  className: "taro-picker__indicator",
745
753
  ariaHidden: true,
@@ -752,8 +760,6 @@ function PickerGroupDate(props) {
752
760
  showScrollbar: false,
753
761
  className: "taro-picker__content",
754
762
  ariaHidden: true,
755
- accessibilityElementsHidden: true,
756
- importantForAccessibility: 'no-hide-descendants',
757
763
  style: {
758
764
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
759
765
  },
@@ -766,28 +772,6 @@ function PickerGroupDate(props) {
766
772
  onScrollEnd: handleScrollEnd,
767
773
  scrollWithAnimation: true,
768
774
  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
775
  })]
792
776
  });
793
777
  }
@@ -811,6 +795,7 @@ function PickerGroupRegion(props) {
811
795
  const isTouchingRef = React.useRef(false);
812
796
  // 程序化滚动标记:开屏/受控同步预设值时置 true,避免被 region 级联门误判为用户滚动而重置后续列
813
797
  const syncScrollFromPropsRef = React.useRef(false);
798
+ const a11yOpen = useA11yOpen();
814
799
  const lengthScaleRatioRef = React.useRef(1);
815
800
  const useMeasuredScaleRef = React.useRef(false);
816
801
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -968,7 +953,21 @@ function PickerGroupRegion(props) {
968
953
  },
969
954
  children: [/*#__PURE__*/jsx(View, {
970
955
  className: "taro-picker__mask",
971
- ariaHidden: true
956
+ style: a11yOpen ? {
957
+ pointerEvents: 'auto'
958
+ } : undefined,
959
+ ariaRole: "slider",
960
+ ariaLabel: ariaLabel
961
+ // @ts-expect-error Taro View 未声明无障碍扩展 props
962
+ ,
963
+ ariaAction: [{
964
+ name: 'increment',
965
+ label: 'increment'
966
+ }, {
967
+ name: 'decrement',
968
+ label: 'decrement'
969
+ }],
970
+ onAriaAction: handleAriaAction
972
971
  }), /*#__PURE__*/jsx(View, {
973
972
  className: "taro-picker__indicator",
974
973
  ariaHidden: true,
@@ -981,8 +980,6 @@ function PickerGroupRegion(props) {
981
980
  showScrollbar: false,
982
981
  className: "taro-picker__content",
983
982
  ariaHidden: true,
984
- accessibilityElementsHidden: true,
985
- importantForAccessibility: 'no-hide-descendants',
986
983
  style: {
987
984
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
988
985
  },
@@ -995,28 +992,6 @@ function PickerGroupRegion(props) {
995
992
  onScrollEnd: handleScrollEnd,
996
993
  scrollWithAnimation: true,
997
994
  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
995
  })]
1021
996
  });
1022
997
  }