@fluentui-react-native/radio-group 0.22.0 → 0.22.1

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 (156) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/Radio/Radio.d.ts +2 -7
  3. package/lib/Radio/Radio.ios.d.ts +2 -7
  4. package/lib/Radio/Radio.ios.js +31 -50
  5. package/lib/Radio/Radio.js +31 -46
  6. package/lib/Radio/Radio.styling.d.ts +1 -1
  7. package/lib/Radio/Radio.styling.js +88 -109
  8. package/lib/Radio/Radio.types.d.ts +170 -176
  9. package/lib/Radio/Radio.types.js +1 -1
  10. package/lib/Radio/RadioTokens.android.d.ts +1 -1
  11. package/lib/Radio/RadioTokens.android.js +42 -42
  12. package/lib/Radio/RadioTokens.android.js.map +1 -1
  13. package/lib/Radio/RadioTokens.d.ts +1 -1
  14. package/lib/Radio/RadioTokens.ios.d.ts +1 -1
  15. package/lib/Radio/RadioTokens.ios.js +39 -39
  16. package/lib/Radio/RadioTokens.ios.js.map +1 -1
  17. package/lib/Radio/RadioTokens.js +76 -76
  18. package/lib/Radio/RadioTokens.js.map +1 -1
  19. package/lib/Radio/RadioTokens.win32.d.ts +1 -1
  20. package/lib/Radio/RadioTokens.win32.js +89 -89
  21. package/lib/Radio/RadioTokens.win32.js.map +1 -1
  22. package/lib/Radio/__tests__/RadioExperimental.test.d.ts +1 -1
  23. package/lib/Radio/__tests__/RadioExperimental.test.js +14 -14
  24. package/lib/Radio/useRadio.d.ts +1 -1
  25. package/lib/Radio/useRadio.js +70 -91
  26. package/lib/Radio/useRadio.win32.d.ts +1 -1
  27. package/lib/Radio/useRadio.win32.js +121 -143
  28. package/lib/RadioGroup/RadioGroup.d.ts +2 -7
  29. package/lib/RadioGroup/RadioGroup.js +34 -48
  30. package/lib/RadioGroup/RadioGroup.styling.d.ts +1 -1
  31. package/lib/RadioGroup/RadioGroup.styling.js +42 -51
  32. package/lib/RadioGroup/RadioGroup.types.d.ts +117 -117
  33. package/lib/RadioGroup/RadioGroup.types.js +1 -1
  34. package/lib/RadioGroup/RadioGroupTokens.android.d.ts +1 -1
  35. package/lib/RadioGroup/RadioGroupTokens.android.js +1 -1
  36. package/lib/RadioGroup/RadioGroupTokens.d.ts +1 -1
  37. package/lib/RadioGroup/RadioGroupTokens.ios.d.ts +1 -1
  38. package/lib/RadioGroup/RadioGroupTokens.ios.js +1 -1
  39. package/lib/RadioGroup/RadioGroupTokens.js +12 -12
  40. package/lib/RadioGroup/RadioGroupTokens.js.map +1 -1
  41. package/lib/RadioGroup/RadioGroupTokens.mobile.d.ts +1 -1
  42. package/lib/RadioGroup/RadioGroupTokens.mobile.js +13 -13
  43. package/lib/RadioGroup/RadioGroupTokens.mobile.js.map +1 -1
  44. package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts +1 -1
  45. package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.js +56 -98
  46. package/lib/RadioGroup/radioGroupContext.d.ts +1 -1
  47. package/lib/RadioGroup/radioGroupContext.js +15 -19
  48. package/lib/RadioGroup/useRadioGroup.d.ts +1 -1
  49. package/lib/RadioGroup/useRadioGroup.js +63 -93
  50. package/lib/RadioGroup/useRadioGroupContextValue.d.ts +1 -1
  51. package/lib/RadioGroup/useRadioGroupContextValue.js +2 -2
  52. package/lib/index.d.ts +4 -25
  53. package/lib/index.js +1 -1
  54. package/lib/legacy/MacOSRadioButtonNativeComponent.d.ts +6 -6
  55. package/lib/legacy/MacOSRadioButtonNativeComponent.js +1 -1
  56. package/lib/legacy/RadioButton.d.ts +2 -8
  57. package/lib/legacy/RadioButton.js +80 -96
  58. package/lib/legacy/RadioButton.macos.d.ts +2 -8
  59. package/lib/legacy/RadioButton.macos.js +48 -48
  60. package/lib/legacy/RadioButton.settings.d.ts +2 -2
  61. package/lib/legacy/RadioButton.settings.js +81 -81
  62. package/lib/legacy/RadioButton.types.d.ts +45 -45
  63. package/lib/legacy/RadioButton.types.js +1 -1
  64. package/lib/legacy/RadioButton.win32.d.ts +2 -8
  65. package/lib/legacy/RadioButton.win32.js +132 -151
  66. package/lib/legacy/RadioGroup.d.ts +2 -8
  67. package/lib/legacy/RadioGroup.js +84 -108
  68. package/lib/legacy/RadioGroup.settings.d.ts +1 -1
  69. package/lib/legacy/RadioGroup.settings.js +21 -21
  70. package/lib/legacy/RadioGroup.types.d.ts +79 -78
  71. package/lib/legacy/RadioGroup.types.js +1 -1
  72. package/lib/legacy/__tests__/RadioButton.test.d.ts +1 -1
  73. package/lib/legacy/__tests__/RadioButton.test.js +8 -8
  74. package/lib/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
  75. package/lib/legacy/__tests__/RadioButtonGroup.test.js +18 -34
  76. package/lib-commonjs/Radio/Radio.d.ts +2 -7
  77. package/lib-commonjs/Radio/Radio.ios.d.ts +2 -7
  78. package/lib-commonjs/Radio/Radio.ios.js +40 -64
  79. package/lib-commonjs/Radio/Radio.js +39 -59
  80. package/lib-commonjs/Radio/Radio.styling.d.ts +1 -1
  81. package/lib-commonjs/Radio/Radio.styling.js +94 -115
  82. package/lib-commonjs/Radio/Radio.types.d.ts +170 -176
  83. package/lib-commonjs/Radio/Radio.types.js +3 -3
  84. package/lib-commonjs/Radio/RadioTokens.android.d.ts +1 -1
  85. package/lib-commonjs/Radio/RadioTokens.android.js +45 -45
  86. package/lib-commonjs/Radio/RadioTokens.android.js.map +1 -1
  87. package/lib-commonjs/Radio/RadioTokens.d.ts +1 -1
  88. package/lib-commonjs/Radio/RadioTokens.ios.d.ts +1 -1
  89. package/lib-commonjs/Radio/RadioTokens.ios.js +42 -42
  90. package/lib-commonjs/Radio/RadioTokens.ios.js.map +1 -1
  91. package/lib-commonjs/Radio/RadioTokens.js +79 -79
  92. package/lib-commonjs/Radio/RadioTokens.js.map +1 -1
  93. package/lib-commonjs/Radio/RadioTokens.win32.d.ts +1 -1
  94. package/lib-commonjs/Radio/RadioTokens.win32.js +92 -92
  95. package/lib-commonjs/Radio/RadioTokens.win32.js.map +1 -1
  96. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.d.ts +1 -1
  97. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.js +48 -65
  98. package/lib-commonjs/Radio/useRadio.d.ts +1 -1
  99. package/lib-commonjs/Radio/useRadio.js +105 -143
  100. package/lib-commonjs/Radio/useRadio.win32.d.ts +1 -1
  101. package/lib-commonjs/Radio/useRadio.win32.js +157 -196
  102. package/lib-commonjs/RadioGroup/RadioGroup.d.ts +2 -7
  103. package/lib-commonjs/RadioGroup/RadioGroup.js +45 -65
  104. package/lib-commonjs/RadioGroup/RadioGroup.styling.d.ts +1 -1
  105. package/lib-commonjs/RadioGroup/RadioGroup.styling.js +48 -57
  106. package/lib-commonjs/RadioGroup/RadioGroup.types.d.ts +117 -117
  107. package/lib-commonjs/RadioGroup/RadioGroup.types.js +3 -3
  108. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.d.ts +1 -1
  109. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.js +5 -10
  110. package/lib-commonjs/RadioGroup/RadioGroupTokens.d.ts +1 -1
  111. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.d.ts +1 -1
  112. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.js +5 -10
  113. package/lib-commonjs/RadioGroup/RadioGroupTokens.js +15 -15
  114. package/lib-commonjs/RadioGroup/RadioGroupTokens.js.map +1 -1
  115. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.d.ts +1 -1
  116. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js +16 -16
  117. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js.map +1 -1
  118. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts +1 -1
  119. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.js +91 -153
  120. package/lib-commonjs/RadioGroup/radioGroupContext.d.ts +1 -1
  121. package/lib-commonjs/RadioGroup/radioGroupContext.js +47 -68
  122. package/lib-commonjs/RadioGroup/useRadioGroup.d.ts +1 -1
  123. package/lib-commonjs/RadioGroup/useRadioGroup.js +97 -144
  124. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.d.ts +1 -1
  125. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.js +4 -4
  126. package/lib-commonjs/index.d.ts +4 -25
  127. package/lib-commonjs/index.js +32 -128
  128. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.d.ts +6 -6
  129. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.js +7 -9
  130. package/lib-commonjs/legacy/RadioButton.d.ts +2 -8
  131. package/lib-commonjs/legacy/RadioButton.js +121 -162
  132. package/lib-commonjs/legacy/RadioButton.macos.d.ts +2 -8
  133. package/lib-commonjs/legacy/RadioButton.macos.js +88 -107
  134. package/lib-commonjs/legacy/RadioButton.settings.d.ts +2 -2
  135. package/lib-commonjs/legacy/RadioButton.settings.js +84 -84
  136. package/lib-commonjs/legacy/RadioButton.types.d.ts +45 -45
  137. package/lib-commonjs/legacy/RadioButton.types.js +3 -3
  138. package/lib-commonjs/legacy/RadioButton.win32.d.ts +2 -8
  139. package/lib-commonjs/legacy/RadioButton.win32.js +173 -217
  140. package/lib-commonjs/legacy/RadioGroup.d.ts +2 -8
  141. package/lib-commonjs/legacy/RadioGroup.js +125 -168
  142. package/lib-commonjs/legacy/RadioGroup.settings.d.ts +1 -1
  143. package/lib-commonjs/legacy/RadioGroup.settings.js +24 -24
  144. package/lib-commonjs/legacy/RadioGroup.types.d.ts +79 -78
  145. package/lib-commonjs/legacy/RadioGroup.types.js +3 -3
  146. package/lib-commonjs/legacy/__tests__/RadioButton.test.d.ts +1 -1
  147. package/lib-commonjs/legacy/__tests__/RadioButton.test.js +42 -59
  148. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
  149. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.js +53 -96
  150. package/package.json +27 -26
  151. package/src/Radio/RadioTokens.android.ts +1 -1
  152. package/src/Radio/RadioTokens.ios.ts +1 -1
  153. package/src/Radio/RadioTokens.ts +1 -1
  154. package/src/Radio/RadioTokens.win32.ts +1 -1
  155. package/src/RadioGroup/RadioGroupTokens.mobile.ts +1 -1
  156. package/src/RadioGroup/RadioGroupTokens.ts +1 -1
@@ -5,91 +5,91 @@ const radioButtonInnerCircleSize = 10;
5
5
  const radioButtonInnerCircleRadius = radioButtonInnerCircleSize / 2;
6
6
  export const radioButtonSelectActionLabel = 'Select a RadioButton';
7
7
  export const settings = [
8
- {
9
- tokens: {
10
- borderColor: 'menuItemText',
11
- color: 'menuItemText',
12
- backgroundColor: 'menuItemText',
13
- textBorderColor: 'transparent',
14
- },
15
- root: {
16
- accessible: true,
17
- focusable: true,
18
- accessibilityRole: 'radio',
19
- style: {
20
- display: 'flex',
21
- alignItems: 'center',
22
- flexDirection: 'row',
23
- minHeight: 20,
24
- marginTop: 0,
25
- position: 'relative',
26
- },
27
- },
28
- button: {
29
- style: {
30
- backgroundColor: 'transparent',
31
- width: radioButtonSize,
32
- height: radioButtonSize,
33
- top: 0,
34
- left: 0,
35
- borderWidth: 1,
36
- borderStyle: 'solid',
37
- borderRadius: radioButtonRadius,
38
- marginTop: 4,
39
- marginRight: 6,
40
- marginBottom: 6,
41
- marginLeft: 6,
42
- },
43
- },
44
- innerCircle: {
45
- style: {
46
- position: 'relative',
47
- opacity: 0,
48
- borderRadius: radioButtonInnerCircleRadius,
49
- height: radioButtonInnerCircleSize,
50
- width: radioButtonInnerCircleSize,
51
- left: 4,
52
- top: 4,
53
- },
54
- },
55
- content: {
56
- variant: 'subheaderStandard',
57
- style: {
58
- marginTop: 2,
59
- borderStyle: 'solid',
60
- borderWidth: 2,
61
- },
62
- },
63
- _precedence: ['disabled', 'hovered', 'focused', 'selected'],
64
- _overrides: {
65
- selected: {
66
- innerCircle: {
67
- style: {
68
- opacity: 1,
69
- },
70
- },
71
- },
72
- focused: {
8
+ {
73
9
  tokens: {
74
- textBorderColor: 'focusBorder',
10
+ borderColor: 'menuItemText',
11
+ color: 'menuItemText',
12
+ backgroundColor: 'menuItemText',
13
+ textBorderColor: 'transparent',
14
+ },
15
+ root: {
16
+ accessible: true,
17
+ focusable: true,
18
+ accessibilityRole: 'radio',
19
+ style: {
20
+ display: 'flex',
21
+ alignItems: 'center',
22
+ flexDirection: 'row',
23
+ minHeight: 20,
24
+ marginTop: 0,
25
+ position: 'relative',
26
+ },
27
+ },
28
+ button: {
29
+ style: {
30
+ backgroundColor: 'transparent',
31
+ width: radioButtonSize,
32
+ height: radioButtonSize,
33
+ top: 0,
34
+ left: 0,
35
+ borderWidth: 1,
36
+ borderStyle: 'solid',
37
+ borderRadius: radioButtonRadius,
38
+ marginTop: 4,
39
+ marginRight: 6,
40
+ marginBottom: 6,
41
+ marginLeft: 6,
42
+ },
75
43
  },
76
- },
77
- hovered: {
78
44
  innerCircle: {
79
- style: {
80
- opacity: 0.5,
81
- },
45
+ style: {
46
+ position: 'relative',
47
+ opacity: 0,
48
+ borderRadius: radioButtonInnerCircleRadius,
49
+ height: radioButtonInnerCircleSize,
50
+ width: radioButtonInnerCircleSize,
51
+ left: 4,
52
+ top: 4,
53
+ },
82
54
  },
83
- },
84
- disabled: {
85
- tokens: {
86
- borderColor: 'buttonBorderDisabled',
87
- color: 'disabledBodyText',
88
- backgroundColor: 'background',
55
+ content: {
56
+ variant: 'subheaderStandard',
57
+ style: {
58
+ marginTop: 2,
59
+ borderStyle: 'solid',
60
+ borderWidth: 2,
61
+ },
62
+ },
63
+ _precedence: ['disabled', 'hovered', 'focused', 'selected'],
64
+ _overrides: {
65
+ selected: {
66
+ innerCircle: {
67
+ style: {
68
+ opacity: 1,
69
+ },
70
+ },
71
+ },
72
+ focused: {
73
+ tokens: {
74
+ textBorderColor: 'focusBorder',
75
+ },
76
+ },
77
+ hovered: {
78
+ innerCircle: {
79
+ style: {
80
+ opacity: 0.5,
81
+ },
82
+ },
83
+ },
84
+ disabled: {
85
+ tokens: {
86
+ borderColor: 'buttonBorderDisabled',
87
+ color: 'disabledBodyText',
88
+ backgroundColor: 'background',
89
+ },
90
+ },
89
91
  },
90
- },
91
92
  },
92
- },
93
- radioButtonName,
93
+ radioButtonName,
94
94
  ];
95
- //# sourceMappingURL=RadioButton.settings.js.map
95
+ //# sourceMappingURL=RadioButton.settings.js.map
@@ -6,57 +6,57 @@ import type { ITextProps } from '@fluentui-react-native/text';
6
6
  import type { FontTokens, IForegroundColorTokens, IBackgroundColorTokens, IBorderTokens } from '@fluentui-react-native/tokens';
7
7
  import type { IRenderData } from '@uifabricshared/foundation-composable';
8
8
  import type { IViewProps } from '@fluentui-react-native/adapters';
9
- export declare const radioButtonName = 'RadioButton';
9
+ export declare const radioButtonName = "RadioButton";
10
10
  export interface IRadioButtonProps extends IPressableProps {
11
- /**
12
- * The text string for the option
13
- */
14
- content: string;
15
- /**
16
- * A unique key-identifier for each option
17
- */
18
- buttonKey: string;
19
- /**
20
- * Whether or not the radio button is selectable
21
- */
22
- disabled?: boolean;
23
- /**
24
- * An optional string for the Narrator to read for each RadioButton. If not provided, this will be set to the button's content.
25
- * @deprecated Use accessibilityLabel instead.
26
- */
27
- ariaLabel?: string;
28
- /**
29
- * Defines the current radio button's position in the radio group for accessibility purposes. It's recommended to set this value
30
- * if radio buttons are not direct children of radio group. This value is auto-generated if radio buttons are direct children of
31
- * radio group.
32
- * @deprecated Use accessibilityPosInSet instead.
33
- */
34
- ariaPosInSet?: number;
35
- /**
36
- * Defines the number of radio buttons in the group for accessibility purposes.It's recommended to set this value if radio
37
- * buttons are not direct children of radio group. This value is auto-generated if radio buttons are direct children of
38
- * radio group.
39
- * @deprecated Use accessibilitySetSize instead.
40
- */
41
- ariaSetSize?: number;
42
- /**
43
- * A RefObject to access the IFocusable interface. Use this to access the public methods and properties of the component.
44
- */
45
- componentRef?: React.RefObject<IFocusable>;
11
+ /**
12
+ * The text string for the option
13
+ */
14
+ content: string;
15
+ /**
16
+ * A unique key-identifier for each option
17
+ */
18
+ buttonKey: string;
19
+ /**
20
+ * Whether or not the radio button is selectable
21
+ */
22
+ disabled?: boolean;
23
+ /**
24
+ * An optional string for the Narrator to read for each RadioButton. If not provided, this will be set to the button's content.
25
+ * @deprecated Use accessibilityLabel instead.
26
+ */
27
+ ariaLabel?: string;
28
+ /**
29
+ * Defines the current radio button's position in the radio group for accessibility purposes. It's recommended to set this value
30
+ * if radio buttons are not direct children of radio group. This value is auto-generated if radio buttons are direct children of
31
+ * radio group.
32
+ * @deprecated Use accessibilityPosInSet instead.
33
+ */
34
+ ariaPosInSet?: number;
35
+ /**
36
+ * Defines the number of radio buttons in the group for accessibility purposes.It's recommended to set this value if radio
37
+ * buttons are not direct children of radio group. This value is auto-generated if radio buttons are direct children of
38
+ * radio group.
39
+ * @deprecated Use accessibilitySetSize instead.
40
+ */
41
+ ariaSetSize?: number;
42
+ /**
43
+ * A RefObject to access the IFocusable interface. Use this to access the public methods and properties of the component.
44
+ */
45
+ componentRef?: React.RefObject<IFocusable>;
46
46
  }
47
47
  export interface IRadioButtonTokens extends FontTokens, IForegroundColorTokens, IBackgroundColorTokens, IBorderTokens {
48
- textBorderColor?: string;
48
+ textBorderColor?: string;
49
49
  }
50
50
  export interface IRadioButtonSlotProps {
51
- root: React.PropsWithRef<IViewProps>;
52
- button: ViewProps;
53
- innerCircle: ViewProps;
54
- content: ITextProps;
51
+ root: React.PropsWithRef<IViewProps>;
52
+ button: ViewProps;
53
+ innerCircle: ViewProps;
54
+ content: ITextProps;
55
55
  }
56
56
  export type IRadioButtonRenderData = IRenderData<IRadioButtonSlotProps>;
57
57
  export interface IRadioButtonType {
58
- props: IRadioButtonProps;
59
- tokens: IRadioButtonTokens;
60
- slotProps: IRadioButtonSlotProps;
58
+ props: IRadioButtonProps;
59
+ tokens: IRadioButtonTokens;
60
+ slotProps: IRadioButtonSlotProps;
61
61
  }
62
- //# sourceMappingURL=RadioButton.types.d.ts.map
62
+ //# sourceMappingURL=RadioButton.types.d.ts.map
@@ -1,2 +1,2 @@
1
1
  export const radioButtonName = 'RadioButton';
2
- //# sourceMappingURL=RadioButton.types.js.map
2
+ //# sourceMappingURL=RadioButton.types.js.map
@@ -1,10 +1,4 @@
1
1
  import type { IRadioButtonProps, IRadioButtonSlotProps } from './RadioButton.types';
2
- export declare const RadioButton: import('@uifabricshared/foundation-compose').IComposeReturnType<
3
- IRadioButtonProps,
4
- IRadioButtonSlotProps,
5
- import('./RadioButton.types').IRadioButtonTokens,
6
- object,
7
- object
8
- >;
2
+ export declare const RadioButton: import("@uifabricshared/foundation-compose").IComposeReturnType<IRadioButtonProps, IRadioButtonSlotProps, import("./RadioButton.types").IRadioButtonTokens, object, object>;
9
3
  export default RadioButton;
10
- //# sourceMappingURL=RadioButton.win32.d.ts.map
4
+ //# sourceMappingURL=RadioButton.win32.d.ts.map
@@ -1,6 +1,6 @@
1
1
  /** @jsxImportSource @fluentui-react-native/framework-base */
2
2
  'use strict';
3
- import { jsx as _jsx, jsxs as _jsxs } from '@fluentui-react-native/framework-base/jsx-runtime';
3
+ import { jsx as _jsx, jsxs as _jsxs } from "@fluentui-react-native/framework-base/jsx-runtime";
4
4
  import * as React from 'react';
5
5
  import { View, I18nManager } from 'react-native';
6
6
  import { filterViewProps } from '@fluentui-react-native/adapters';
@@ -14,159 +14,140 @@ import { radioButtonName } from './RadioButton.types';
14
14
  import { RadioGroupContext } from './RadioGroup';
15
15
  var DirectionalArrowKeys;
16
16
  (function (DirectionalArrowKeys) {
17
- DirectionalArrowKeys['ArrowUp'] = 'ArrowUp';
18
- DirectionalArrowKeys['ArrowDown'] = 'ArrowDown';
19
- DirectionalArrowKeys['ArrowRight'] = 'ArrowRight';
20
- DirectionalArrowKeys['ArrowLeft'] = 'ArrowLeft';
17
+ DirectionalArrowKeys["ArrowUp"] = "ArrowUp";
18
+ DirectionalArrowKeys["ArrowDown"] = "ArrowDown";
19
+ DirectionalArrowKeys["ArrowRight"] = "ArrowRight";
20
+ DirectionalArrowKeys["ArrowLeft"] = "ArrowLeft";
21
21
  })(DirectionalArrowKeys || (DirectionalArrowKeys = {}));
22
22
  export const RadioButton = compose({
23
- displayName: radioButtonName,
24
- usePrepareProps: (userProps, useStyling) => {
25
- const defaultComponentRef = React.useRef(null);
26
- const {
27
- content,
28
- buttonKey,
29
- disabled,
30
- accessibilityLabel,
31
- ariaLabel,
32
- componentRef = defaultComponentRef,
33
- accessibilityPosInSet,
34
- ariaPosInSet,
35
- accessibilitySetSize,
36
- ariaSetSize,
37
- ...rest
38
- } = userProps;
39
- // Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
40
- const info = React.useContext(RadioGroupContext);
41
- const buttonRef = useViewCommandFocus(componentRef);
42
- /* We don't want to call the user's onChange multiple times on the same selection. */
43
- const changeSelection = () => {
44
- if (buttonKey != info.selectedKey) {
45
- info.onChange && info.onChange(buttonKey);
46
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
47
- }
48
- };
49
- /* We use the componentRef of the currently selected button to maintain the default tabbable
23
+ displayName: radioButtonName,
24
+ usePrepareProps: (userProps, useStyling) => {
25
+ const defaultComponentRef = React.useRef(null);
26
+ const { content, buttonKey, disabled, accessibilityLabel, ariaLabel, componentRef = defaultComponentRef, accessibilityPosInSet, ariaPosInSet, accessibilitySetSize, ariaSetSize, ...rest } = userProps;
27
+ // Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
28
+ const info = React.useContext(RadioGroupContext);
29
+ const buttonRef = useViewCommandFocus(componentRef);
30
+ /* We don't want to call the user's onChange multiple times on the same selection. */
31
+ const changeSelection = () => {
32
+ if (buttonKey != info.selectedKey) {
33
+ info.onChange && info.onChange(buttonKey);
34
+ info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
35
+ }
36
+ };
37
+ /* We use the componentRef of the currently selected button to maintain the default tabbable
50
38
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
51
39
  we must update it once here. */
52
- React.useEffect(() => {
53
- if (buttonKey == info.selectedKey) {
54
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
55
- }
56
- }, []);
57
- // Explicitly only run on mount and unmount
58
- React.useEffect(() => {
59
- info.addRadioButtonKey(buttonKey);
60
- if (!disabled) {
61
- info.addRadioButtonEnabledKey(buttonKey);
62
- }
63
- return () => {
64
- info.removeRadioButtonKey(buttonKey);
65
- info.removeRadioButtonEnabledKey(buttonKey);
66
- };
67
- }, []);
68
- const isRTL = I18nManager.isRTL;
69
- const onInvoke = React.useCallback(
70
- (e) => {
71
- if (e.nativeEvent.key in DirectionalArrowKeys) {
72
- const length = info.enabledButtonKeys.length;
73
- const next =
74
- e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
75
- (isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
76
- const currRadioButtonIndex = info.enabledButtonKeys.indexOf(info.selectedKey);
77
- let newCurrRadioButtonIndex;
78
- if (next) {
79
- newCurrRadioButtonIndex = (currRadioButtonIndex + 1) % length;
80
- } else {
81
- // previous
82
- newCurrRadioButtonIndex = (currRadioButtonIndex - 1 + length) % length;
83
- }
84
- info.onChange && info.onChange(info.enabledButtonKeys[newCurrRadioButtonIndex]);
85
- info.updateInvoked && info.updateInvoked(true);
86
- }
87
- },
88
- [info],
89
- );
90
- // Sets the updated selected button ref and focus if this Radio is selected via arrow key.
91
- React.useEffect(() => {
92
- if (info.invoked && buttonKey === info.selectedKey && !disabled) {
93
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
94
- componentRef?.current?.focus();
95
- info.updateInvoked && info.updateInvoked(false);
96
- }
97
- }, [info.invoked]);
98
- const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
99
- // Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
100
- const onKeyDownProps = useKeyDownProps(onInvoke, ...keys);
101
- // Ensure focus is placed on button after click
102
- const changeSelectionWithFocus = () => {
103
- if (buttonKey != info.selectedKey) {
104
- info.onChange && info.onChange(buttonKey);
105
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
106
- info.updateInvoked && info.updateInvoked(true);
107
- }
108
- };
109
- /* RadioButton changes selection when focus is moved between each RadioButton and on a click */
110
- const pressable = useAsPressable({
111
- ...rest,
112
- onPress: changeSelectionWithFocus,
113
- onFocus: changeSelection,
114
- });
115
- // Used when creating accessibility properties in mergeSettings below
116
- const onAccessibilityAction = React.useCallback(
117
- (event) => {
118
- switch (event.nativeEvent.actionName) {
119
- case 'Select':
120
- changeSelection();
121
- break;
122
- }
123
- },
124
- [info, buttonKey],
125
- );
126
- const state = {
127
- ...pressable.state,
128
- selected: info.selectedKey === userProps.buttonKey && !disabled,
129
- disabled: disabled || false,
130
- };
131
- // Grab the styling information from the userProps, referencing the state as well as the props.
132
- const styleProps = useStyling(userProps, (override) => state[override] || userProps[override]);
133
- const slotProps = mergeSettings(styleProps, {
134
- root: {
135
- ...rest,
136
- ref: buttonRef,
137
- ...pressable.props,
138
- accessibilityRole: 'radio',
139
- accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
140
- accessibilityState: { disabled: state.disabled, selected: state.selected },
141
- accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
142
- accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
143
- accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
144
- focusable: !state.disabled,
145
- onAccessibilityAction: onAccessibilityAction,
146
- ...onKeyDownProps,
147
- },
148
- content: { children: content },
149
- });
150
- return { slotProps };
151
- },
152
- render: (Slots, _renderData, ...children) => {
153
- return _jsxs(Slots.root, {
154
- children: [_jsx(Slots.button, { children: _jsx(Slots.innerCircle, {}) }), _jsx(Slots.content, {}), children],
155
- });
156
- },
157
- settings,
158
- slots: {
159
- root: View,
160
- button: { slotType: View, filter: filterViewProps },
161
- innerCircle: { slotType: View, filter: filterViewProps },
162
- content: Text,
163
- },
164
- styles: {
165
- root: [],
166
- button: [borderTokens],
167
- innerCircle: [backgroundColorTokens],
168
- content: [foregroundColorTokens, textTokens, [{ source: 'textBorderColor', lookup: getPaletteFromTheme, target: 'borderColor' }]],
169
- },
40
+ React.useEffect(() => {
41
+ if (buttonKey == info.selectedKey) {
42
+ info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
43
+ }
44
+ }, []);
45
+ // Explicitly only run on mount and unmount
46
+ React.useEffect(() => {
47
+ info.addRadioButtonKey(buttonKey);
48
+ if (!disabled) {
49
+ info.addRadioButtonEnabledKey(buttonKey);
50
+ }
51
+ return () => {
52
+ info.removeRadioButtonKey(buttonKey);
53
+ info.removeRadioButtonEnabledKey(buttonKey);
54
+ };
55
+ }, []);
56
+ const isRTL = I18nManager.isRTL;
57
+ const onInvoke = React.useCallback((e) => {
58
+ if (e.nativeEvent.key in DirectionalArrowKeys) {
59
+ const length = info.enabledButtonKeys.length;
60
+ const next = e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
61
+ (isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
62
+ const currRadioButtonIndex = info.enabledButtonKeys.indexOf(info.selectedKey);
63
+ let newCurrRadioButtonIndex;
64
+ if (next) {
65
+ newCurrRadioButtonIndex = (currRadioButtonIndex + 1) % length;
66
+ }
67
+ else {
68
+ // previous
69
+ newCurrRadioButtonIndex = (currRadioButtonIndex - 1 + length) % length;
70
+ }
71
+ info.onChange && info.onChange(info.enabledButtonKeys[newCurrRadioButtonIndex]);
72
+ info.updateInvoked && info.updateInvoked(true);
73
+ }
74
+ }, [info]);
75
+ // Sets the updated selected button ref and focus if this Radio is selected via arrow key.
76
+ React.useEffect(() => {
77
+ if (info.invoked && buttonKey === info.selectedKey && !disabled) {
78
+ info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
79
+ componentRef?.current?.focus();
80
+ info.updateInvoked && info.updateInvoked(false);
81
+ }
82
+ }, [info.invoked]);
83
+ const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
84
+ // Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
85
+ const onKeyDownProps = useKeyDownProps(onInvoke, ...keys);
86
+ // Ensure focus is placed on button after click
87
+ const changeSelectionWithFocus = () => {
88
+ if (buttonKey != info.selectedKey) {
89
+ info.onChange && info.onChange(buttonKey);
90
+ info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
91
+ info.updateInvoked && info.updateInvoked(true);
92
+ }
93
+ };
94
+ /* RadioButton changes selection when focus is moved between each RadioButton and on a click */
95
+ const pressable = useAsPressable({
96
+ ...rest,
97
+ onPress: changeSelectionWithFocus,
98
+ onFocus: changeSelection,
99
+ });
100
+ // Used when creating accessibility properties in mergeSettings below
101
+ const onAccessibilityAction = React.useCallback((event) => {
102
+ switch (event.nativeEvent.actionName) {
103
+ case 'Select':
104
+ changeSelection();
105
+ break;
106
+ }
107
+ }, [info, buttonKey]);
108
+ const state = {
109
+ ...pressable.state,
110
+ selected: info.selectedKey === userProps.buttonKey && !disabled,
111
+ disabled: disabled || false,
112
+ };
113
+ // Grab the styling information from the userProps, referencing the state as well as the props.
114
+ const styleProps = useStyling(userProps, (override) => state[override] || userProps[override]);
115
+ const slotProps = mergeSettings(styleProps, {
116
+ root: {
117
+ ...rest,
118
+ ref: buttonRef,
119
+ ...pressable.props,
120
+ accessibilityRole: 'radio',
121
+ accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
122
+ accessibilityState: { disabled: state.disabled, selected: state.selected },
123
+ accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
124
+ accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
125
+ accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
126
+ focusable: !state.disabled,
127
+ onAccessibilityAction: onAccessibilityAction,
128
+ ...onKeyDownProps,
129
+ },
130
+ content: { children: content },
131
+ });
132
+ return { slotProps };
133
+ },
134
+ render: (Slots, _renderData, ...children) => {
135
+ return (_jsxs(Slots.root, { children: [
136
+ _jsx(Slots.button, { children: _jsx(Slots.innerCircle, {}) }), _jsx(Slots.content, {}), children] }));
137
+ },
138
+ settings,
139
+ slots: {
140
+ root: View,
141
+ button: { slotType: View, filter: filterViewProps },
142
+ innerCircle: { slotType: View, filter: filterViewProps },
143
+ content: Text,
144
+ },
145
+ styles: {
146
+ root: [],
147
+ button: [borderTokens],
148
+ innerCircle: [backgroundColorTokens],
149
+ content: [foregroundColorTokens, textTokens, [{ source: 'textBorderColor', lookup: getPaletteFromTheme, target: 'borderColor' }]],
150
+ },
170
151
  });
171
152
  export default RadioButton;
172
- //# sourceMappingURL=RadioButton.win32.js.map
153
+ //# sourceMappingURL=RadioButton.win32.js.map
@@ -2,12 +2,6 @@
2
2
  import * as React from 'react';
3
3
  import type { IRadioGroupProps, IRadioGroupState, IRadioGroupSlotProps, IRadioGroupContext } from './RadioGroup.types';
4
4
  export declare const RadioGroupContext: React.Context<IRadioGroupContext>;
5
- export declare const RadioGroup: import('@uifabricshared/foundation-compose').IComposeReturnType<
6
- IRadioGroupProps,
7
- IRadioGroupSlotProps,
8
- import('./RadioGroup.types').IRadioGroupTokens,
9
- IRadioGroupState,
10
- object
11
- >;
5
+ export declare const RadioGroup: import("@uifabricshared/foundation-compose").IComposeReturnType<IRadioGroupProps, IRadioGroupSlotProps, import("./RadioGroup.types").IRadioGroupTokens, IRadioGroupState, object>;
12
6
  export default RadioGroup;
13
- //# sourceMappingURL=RadioGroup.d.ts.map
7
+ //# sourceMappingURL=RadioGroup.d.ts.map