@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.
@@ -18,6 +18,16 @@ function usePickerItemScrollIntoView() {
18
18
  }, []);
19
19
  return [scrollIntoView, scrollToItemId];
20
20
  }
21
+ /** 系统读屏是否开启:开启时 mask 需可命中(关掉 pointer-events:none) */
22
+ function useA11yOpen() {
23
+ const [a11yOpen, setA11yOpen] = React.useState(false);
24
+ React.useEffect(() => {
25
+ Taro.checkIsOpenAccessibility().then(res => {
26
+ setA11yOpen(!!res.open);
27
+ }).catch(() => {});
28
+ }, []);
29
+ return a11yOpen;
30
+ }
21
31
  // 定义常量
22
32
  const PICKER_LINE_HEIGHT = 34; // px
23
33
  const PICKER_VISIBLE_ITEMS = 7; // 可见行数
@@ -128,6 +138,8 @@ function PickerGroupBasic(props) {
128
138
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
129
139
  // 触摸状态用于优化用户体验
130
140
  const isTouchingRef = React.useRef(false);
141
+ // 系统读屏开启时关闭 mask 的 pointer-events:none,便于无障碍命中;未开启则保持穿透以便手势滚动
142
+ const a11yOpen = useA11yOpen();
131
143
  const lengthScaleRatioRef = React.useRef(1);
132
144
  const useMeasuredScaleRef = React.useRef(false);
133
145
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -288,7 +300,19 @@ function PickerGroupBasic(props) {
288
300
  get children() {
289
301
  return [createComponent(View, {
290
302
  className: "taro-picker__mask",
291
- ariaHidden: true
303
+ style: a11yOpen ? {
304
+ pointerEvents: 'auto'
305
+ } : undefined,
306
+ ariaRole: "slider",
307
+ ariaLabel: ariaLabel,
308
+ ariaAction: [{
309
+ name: 'increment',
310
+ label: 'increment'
311
+ }, {
312
+ name: 'decrement',
313
+ label: 'decrement'
314
+ }],
315
+ onAriaAction: handleAriaAction
292
316
  }), createComponent(View, mergeProps({
293
317
  className: "taro-picker__indicator",
294
318
  ariaHidden: true
@@ -299,11 +323,7 @@ function PickerGroupBasic(props) {
299
323
  scrollY: true,
300
324
  showScrollbar: false,
301
325
  className: "taro-picker__content",
302
- ariaHidden: true
303
- }, {
304
- accessibilityElementsHidden: true,
305
- importantForAccessibility: 'no-hide-descendants'
306
- }, {
326
+ ariaHidden: true,
307
327
  style: {
308
328
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
309
329
  },
@@ -316,28 +336,6 @@ function PickerGroupBasic(props) {
316
336
  onScrollEnd: handleScrollEnd,
317
337
  scrollWithAnimation: true,
318
338
  children: realPickerItems
319
- })), createComponent(View, mergeProps({
320
- className: "taro-picker__a11y-overlay",
321
- style: {
322
- position: 'absolute',
323
- top: 0,
324
- left: 0,
325
- right: 0,
326
- bottom: 0,
327
- pointerEvents: 'none'
328
- },
329
- ariaRole: "slider"
330
- }, ariaLabel !== undefined ? {
331
- ariaLabel
332
- } : {}, {
333
- ariaAction: [{
334
- name: 'increment',
335
- label: 'increment'
336
- }, {
337
- name: 'decrement',
338
- label: 'decrement'
339
- }],
340
- onAriaAction: handleAriaAction
341
339
  }))];
342
340
  }
343
341
  });
@@ -361,6 +359,7 @@ function PickerGroupTime(props) {
361
359
  const scrollViewRef = React.useRef(null);
362
360
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
363
361
  const isTouchingRef = React.useRef(false);
362
+ const a11yOpen = useA11yOpen();
364
363
  const lengthScaleRatioRef = React.useRef(1);
365
364
  const useMeasuredScaleRef = React.useRef(false);
366
365
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -537,7 +536,19 @@ function PickerGroupTime(props) {
537
536
  get children() {
538
537
  return [createComponent(View, {
539
538
  className: "taro-picker__mask",
540
- ariaHidden: true
539
+ style: a11yOpen ? {
540
+ pointerEvents: 'auto'
541
+ } : undefined,
542
+ ariaRole: "slider",
543
+ ariaLabel: ariaLabel,
544
+ ariaAction: [{
545
+ name: 'increment',
546
+ label: 'increment'
547
+ }, {
548
+ name: 'decrement',
549
+ label: 'decrement'
550
+ }],
551
+ onAriaAction: handleAriaAction
541
552
  }), createComponent(View, mergeProps({
542
553
  className: "taro-picker__indicator",
543
554
  ariaHidden: true
@@ -548,11 +559,7 @@ function PickerGroupTime(props) {
548
559
  scrollY: true,
549
560
  showScrollbar: false,
550
561
  className: "taro-picker__content",
551
- ariaHidden: true
552
- }, {
553
- accessibilityElementsHidden: true,
554
- importantForAccessibility: 'no-hide-descendants'
555
- }, {
562
+ ariaHidden: true,
556
563
  style: {
557
564
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
558
565
  },
@@ -565,28 +572,6 @@ function PickerGroupTime(props) {
565
572
  onScrollEnd: handleScrollEnd,
566
573
  scrollWithAnimation: true,
567
574
  children: realPickerItems
568
- })), createComponent(View, mergeProps({
569
- className: "taro-picker__a11y-overlay",
570
- style: {
571
- position: 'absolute',
572
- top: 0,
573
- left: 0,
574
- right: 0,
575
- bottom: 0,
576
- pointerEvents: 'none'
577
- },
578
- ariaRole: "slider"
579
- }, ariaLabel !== undefined ? {
580
- ariaLabel
581
- } : {}, {
582
- ariaAction: [{
583
- name: 'increment',
584
- label: 'increment'
585
- }, {
586
- name: 'decrement',
587
- label: 'decrement'
588
- }],
589
- onAriaAction: handleAriaAction
590
575
  }))];
591
576
  }
592
577
  });
@@ -607,6 +592,7 @@ function PickerGroupDate(props) {
607
592
  const scrollViewRef = React.useRef(null);
608
593
  const [currentIndex, setCurrentIndex] = React.useState(selectedIndex);
609
594
  const isTouchingRef = React.useRef(false);
595
+ const a11yOpen = useA11yOpen();
610
596
  const lengthScaleRatioRef = React.useRef(1);
611
597
  const useMeasuredScaleRef = React.useRef(false);
612
598
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -762,7 +748,19 @@ function PickerGroupDate(props) {
762
748
  get children() {
763
749
  return [createComponent(View, {
764
750
  className: "taro-picker__mask",
765
- ariaHidden: true
751
+ style: a11yOpen ? {
752
+ pointerEvents: 'auto'
753
+ } : undefined,
754
+ ariaRole: "slider",
755
+ ariaLabel: ariaLabel,
756
+ ariaAction: [{
757
+ name: 'increment',
758
+ label: 'increment'
759
+ }, {
760
+ name: 'decrement',
761
+ label: 'decrement'
762
+ }],
763
+ onAriaAction: handleAriaAction
766
764
  }), createComponent(View, mergeProps({
767
765
  className: "taro-picker__indicator",
768
766
  ariaHidden: true
@@ -773,11 +771,7 @@ function PickerGroupDate(props) {
773
771
  scrollY: true,
774
772
  showScrollbar: false,
775
773
  className: "taro-picker__content",
776
- ariaHidden: true
777
- }, {
778
- accessibilityElementsHidden: true,
779
- importantForAccessibility: 'no-hide-descendants'
780
- }, {
774
+ ariaHidden: true,
781
775
  style: {
782
776
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
783
777
  },
@@ -790,28 +784,6 @@ function PickerGroupDate(props) {
790
784
  onScrollEnd: handleScrollEnd,
791
785
  scrollWithAnimation: true,
792
786
  children: realPickerItems
793
- })), createComponent(View, mergeProps({
794
- className: "taro-picker__a11y-overlay",
795
- style: {
796
- position: 'absolute',
797
- top: 0,
798
- left: 0,
799
- right: 0,
800
- bottom: 0,
801
- pointerEvents: 'none'
802
- },
803
- ariaRole: "slider"
804
- }, ariaLabel !== undefined ? {
805
- ariaLabel
806
- } : {}, {
807
- ariaAction: [{
808
- name: 'increment',
809
- label: 'increment'
810
- }, {
811
- name: 'decrement',
812
- label: 'decrement'
813
- }],
814
- onAriaAction: handleAriaAction
815
787
  }))];
816
788
  }
817
789
  });
@@ -836,6 +808,7 @@ function PickerGroupRegion(props) {
836
808
  const isTouchingRef = React.useRef(false);
837
809
  // 程序化滚动标记:开屏/受控同步预设值时置 true,避免被 region 级联门误判为用户滚动而重置后续列
838
810
  const syncScrollFromPropsRef = React.useRef(false);
811
+ const a11yOpen = useA11yOpen();
839
812
  const lengthScaleRatioRef = React.useRef(1);
840
813
  const useMeasuredScaleRef = React.useRef(false);
841
814
  const itemHeightRef = React.useRef(PICKER_LINE_HEIGHT);
@@ -999,7 +972,19 @@ function PickerGroupRegion(props) {
999
972
  get children() {
1000
973
  return [createComponent(View, {
1001
974
  className: "taro-picker__mask",
1002
- ariaHidden: true
975
+ style: a11yOpen ? {
976
+ pointerEvents: 'auto'
977
+ } : undefined,
978
+ ariaRole: "slider",
979
+ ariaLabel: ariaLabel,
980
+ ariaAction: [{
981
+ name: 'increment',
982
+ label: 'increment'
983
+ }, {
984
+ name: 'decrement',
985
+ label: 'decrement'
986
+ }],
987
+ onAriaAction: handleAriaAction
1003
988
  }), createComponent(View, mergeProps({
1004
989
  className: "taro-picker__indicator",
1005
990
  ariaHidden: true
@@ -1010,11 +995,7 @@ function PickerGroupRegion(props) {
1010
995
  scrollY: true,
1011
996
  showScrollbar: false,
1012
997
  className: "taro-picker__content",
1013
- ariaHidden: true
1014
- }, {
1015
- accessibilityElementsHidden: true,
1016
- importantForAccessibility: 'no-hide-descendants'
1017
- }, {
998
+ ariaHidden: true,
1018
999
  style: {
1019
1000
  height: PICKER_LINE_HEIGHT * PICKER_VISIBLE_ITEMS
1020
1001
  },
@@ -1027,28 +1008,6 @@ function PickerGroupRegion(props) {
1027
1008
  onScrollEnd: handleScrollEnd,
1028
1009
  scrollWithAnimation: true,
1029
1010
  children: realPickerItems
1030
- })), createComponent(View, mergeProps({
1031
- className: "taro-picker__a11y-overlay",
1032
- style: {
1033
- position: 'absolute',
1034
- top: 0,
1035
- left: 0,
1036
- right: 0,
1037
- bottom: 0,
1038
- pointerEvents: 'none'
1039
- },
1040
- ariaRole: "slider"
1041
- }, ariaLabel !== undefined ? {
1042
- ariaLabel
1043
- } : {}, {
1044
- ariaAction: [{
1045
- name: 'increment',
1046
- label: 'increment'
1047
- }, {
1048
- name: 'decrement',
1049
- label: 'decrement'
1050
- }],
1051
- onAriaAction: handleAriaAction
1052
1011
  }))];
1053
1012
  }
1054
1013
  });