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

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 (191) hide show
  1. package/.cache/tsconfig.tsbuildinfo +1 -0
  2. package/CHANGELOG.md +67 -0
  3. package/jest.config.cjs +1 -0
  4. package/lib/Radio/Radio.d.ts.map +1 -1
  5. package/lib/Radio/Radio.ios.d.ts.map +1 -1
  6. package/lib/Radio/Radio.ios.js +2 -4
  7. package/lib/Radio/Radio.ios.js.map +1 -1
  8. package/lib/Radio/Radio.js +2 -4
  9. package/lib/Radio/Radio.js.map +1 -1
  10. package/lib/Radio/__tests__/RadioExperimental.test.js.map +1 -1
  11. package/lib/Radio/useRadio.d.ts.map +1 -1
  12. package/lib/Radio/useRadio.js +13 -11
  13. package/lib/Radio/useRadio.js.map +1 -1
  14. package/lib/Radio/useRadio.win32.d.ts.map +1 -1
  15. package/lib/Radio/useRadio.win32.js +37 -33
  16. package/lib/Radio/useRadio.win32.js.map +1 -1
  17. package/lib/RadioGroup/RadioGroup.d.ts.map +1 -1
  18. package/lib/RadioGroup/RadioGroup.js +1 -2
  19. package/lib/RadioGroup/RadioGroup.js.map +1 -1
  20. package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.js +6 -18
  21. package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.js.map +1 -1
  22. package/lib/RadioGroup/radioGroupContext.js +6 -6
  23. package/lib/RadioGroup/radioGroupContext.js.map +1 -1
  24. package/lib/RadioGroup/useRadioGroup.d.ts.map +1 -1
  25. package/lib/RadioGroup/useRadioGroup.js.map +1 -1
  26. package/lib/RadioGroup/useRadioGroupContextValue.d.ts +2 -1
  27. package/lib/RadioGroup/useRadioGroupContextValue.d.ts.map +1 -1
  28. package/lib/RadioGroup/useRadioGroupContextValue.js.map +1 -1
  29. package/lib/legacy/MacOSRadioButtonNativeComponent.d.ts.map +1 -1
  30. package/lib/legacy/RadioButton.d.ts.map +1 -1
  31. package/lib/legacy/RadioButton.js +14 -13
  32. package/lib/legacy/RadioButton.js.map +1 -1
  33. package/lib/legacy/RadioButton.macos.d.ts.map +1 -1
  34. package/lib/legacy/RadioButton.macos.js +10 -8
  35. package/lib/legacy/RadioButton.macos.js.map +1 -1
  36. package/lib/legacy/RadioButton.win32.d.ts.map +1 -1
  37. package/lib/legacy/RadioButton.win32.js +41 -39
  38. package/lib/legacy/RadioButton.win32.js.map +1 -1
  39. package/lib/legacy/RadioGroup.d.ts.map +1 -1
  40. package/lib/legacy/RadioGroup.js +7 -13
  41. package/lib/legacy/RadioGroup.js.map +1 -1
  42. package/lib/legacy/__tests__/RadioButton.test.js.map +1 -1
  43. package/lib/legacy/__tests__/RadioButtonGroup.test.js +2 -6
  44. package/lib/legacy/__tests__/RadioButtonGroup.test.js.map +1 -1
  45. package/package.json +33 -38
  46. package/src/Radio/useRadio.ts +13 -11
  47. package/src/Radio/useRadio.win32.ts +52 -32
  48. package/src/legacy/RadioButton.macos.tsx +10 -8
  49. package/src/legacy/RadioButton.tsx +13 -11
  50. package/src/legacy/RadioButton.win32.tsx +53 -36
  51. package/src/legacy/RadioGroup.tsx +4 -8
  52. package/tsconfig.json +53 -3
  53. package/babel.config.js +0 -1
  54. package/eslint.config.js +0 -3
  55. package/jest.config.js +0 -2
  56. package/lib-commonjs/Radio/Radio.d.ts +0 -13
  57. package/lib-commonjs/Radio/Radio.d.ts.map +0 -1
  58. package/lib-commonjs/Radio/Radio.ios.d.ts +0 -13
  59. package/lib-commonjs/Radio/Radio.ios.d.ts.map +0 -1
  60. package/lib-commonjs/Radio/Radio.ios.js +0 -55
  61. package/lib-commonjs/Radio/Radio.ios.js.map +0 -1
  62. package/lib-commonjs/Radio/Radio.js +0 -54
  63. package/lib-commonjs/Radio/Radio.js.map +0 -1
  64. package/lib-commonjs/Radio/Radio.styling.d.ts +0 -5
  65. package/lib-commonjs/Radio/Radio.styling.d.ts.map +0 -1
  66. package/lib-commonjs/Radio/Radio.styling.js +0 -98
  67. package/lib-commonjs/Radio/Radio.styling.js.map +0 -1
  68. package/lib-commonjs/Radio/Radio.types.d.ts +0 -186
  69. package/lib-commonjs/Radio/Radio.types.d.ts.map +0 -1
  70. package/lib-commonjs/Radio/Radio.types.js +0 -5
  71. package/lib-commonjs/Radio/Radio.types.js.map +0 -1
  72. package/lib-commonjs/Radio/RadioTokens.android.d.ts +0 -5
  73. package/lib-commonjs/Radio/RadioTokens.android.d.ts.map +0 -1
  74. package/lib-commonjs/Radio/RadioTokens.android.js +0 -53
  75. package/lib-commonjs/Radio/RadioTokens.android.js.map +0 -1
  76. package/lib-commonjs/Radio/RadioTokens.d.ts +0 -5
  77. package/lib-commonjs/Radio/RadioTokens.d.ts.map +0 -1
  78. package/lib-commonjs/Radio/RadioTokens.ios.d.ts +0 -5
  79. package/lib-commonjs/Radio/RadioTokens.ios.d.ts.map +0 -1
  80. package/lib-commonjs/Radio/RadioTokens.ios.js +0 -51
  81. package/lib-commonjs/Radio/RadioTokens.ios.js.map +0 -1
  82. package/lib-commonjs/Radio/RadioTokens.js +0 -88
  83. package/lib-commonjs/Radio/RadioTokens.js.map +0 -1
  84. package/lib-commonjs/Radio/RadioTokens.win32.d.ts +0 -5
  85. package/lib-commonjs/Radio/RadioTokens.win32.d.ts.map +0 -1
  86. package/lib-commonjs/Radio/RadioTokens.win32.js +0 -102
  87. package/lib-commonjs/Radio/RadioTokens.win32.js.map +0 -1
  88. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.d.ts +0 -2
  89. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.d.ts.map +0 -1
  90. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.js +0 -56
  91. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.js.map +0 -1
  92. package/lib-commonjs/Radio/useRadio.d.ts +0 -3
  93. package/lib-commonjs/Radio/useRadio.d.ts.map +0 -1
  94. package/lib-commonjs/Radio/useRadio.js +0 -119
  95. package/lib-commonjs/Radio/useRadio.js.map +0 -1
  96. package/lib-commonjs/Radio/useRadio.win32.d.ts +0 -3
  97. package/lib-commonjs/Radio/useRadio.win32.d.ts.map +0 -1
  98. package/lib-commonjs/Radio/useRadio.win32.js +0 -175
  99. package/lib-commonjs/Radio/useRadio.win32.js.map +0 -1
  100. package/lib-commonjs/RadioGroup/RadioGroup.d.ts +0 -12
  101. package/lib-commonjs/RadioGroup/RadioGroup.d.ts.map +0 -1
  102. package/lib-commonjs/RadioGroup/RadioGroup.js +0 -59
  103. package/lib-commonjs/RadioGroup/RadioGroup.js.map +0 -1
  104. package/lib-commonjs/RadioGroup/RadioGroup.styling.d.ts +0 -5
  105. package/lib-commonjs/RadioGroup/RadioGroup.styling.d.ts.map +0 -1
  106. package/lib-commonjs/RadioGroup/RadioGroup.styling.js +0 -52
  107. package/lib-commonjs/RadioGroup/RadioGroup.styling.js.map +0 -1
  108. package/lib-commonjs/RadioGroup/RadioGroup.types.d.ts +0 -134
  109. package/lib-commonjs/RadioGroup/RadioGroup.types.d.ts.map +0 -1
  110. package/lib-commonjs/RadioGroup/RadioGroup.types.js +0 -5
  111. package/lib-commonjs/RadioGroup/RadioGroup.types.js.map +0 -1
  112. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.d.ts +0 -3
  113. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.d.ts.map +0 -1
  114. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.js +0 -6
  115. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.js.map +0 -1
  116. package/lib-commonjs/RadioGroup/RadioGroupTokens.d.ts +0 -5
  117. package/lib-commonjs/RadioGroup/RadioGroupTokens.d.ts.map +0 -1
  118. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.d.ts +0 -2
  119. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.d.ts.map +0 -1
  120. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.js +0 -6
  121. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.js.map +0 -1
  122. package/lib-commonjs/RadioGroup/RadioGroupTokens.js +0 -19
  123. package/lib-commonjs/RadioGroup/RadioGroupTokens.js.map +0 -1
  124. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.d.ts +0 -5
  125. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.d.ts.map +0 -1
  126. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js +0 -20
  127. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js.map +0 -1
  128. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts +0 -2
  129. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts.map +0 -1
  130. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.js +0 -104
  131. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.js.map +0 -1
  132. package/lib-commonjs/RadioGroup/radioGroupContext.d.ts +0 -10
  133. package/lib-commonjs/RadioGroup/radioGroupContext.d.ts.map +0 -1
  134. package/lib-commonjs/RadioGroup/radioGroupContext.js +0 -59
  135. package/lib-commonjs/RadioGroup/radioGroupContext.js.map +0 -1
  136. package/lib-commonjs/RadioGroup/useRadioGroup.d.ts +0 -3
  137. package/lib-commonjs/RadioGroup/useRadioGroup.d.ts.map +0 -1
  138. package/lib-commonjs/RadioGroup/useRadioGroup.js +0 -108
  139. package/lib-commonjs/RadioGroup/useRadioGroup.js.map +0 -1
  140. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.d.ts +0 -3
  141. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.d.ts.map +0 -1
  142. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.js +0 -8
  143. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.js.map +0 -1
  144. package/lib-commonjs/index.d.ts +0 -18
  145. package/lib-commonjs/index.d.ts.map +0 -1
  146. package/lib-commonjs/index.js +0 -32
  147. package/lib-commonjs/index.js.map +0 -1
  148. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.d.ts +0 -17
  149. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.d.ts.map +0 -1
  150. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.js +0 -13
  151. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.js.map +0 -1
  152. package/lib-commonjs/legacy/RadioButton.d.ts +0 -4
  153. package/lib-commonjs/legacy/RadioButton.d.ts.map +0 -1
  154. package/lib-commonjs/legacy/RadioButton.js +0 -133
  155. package/lib-commonjs/legacy/RadioButton.js.map +0 -1
  156. package/lib-commonjs/legacy/RadioButton.macos.d.ts +0 -4
  157. package/lib-commonjs/legacy/RadioButton.macos.d.ts.map +0 -1
  158. package/lib-commonjs/legacy/RadioButton.macos.js +0 -104
  159. package/lib-commonjs/legacy/RadioButton.macos.js.map +0 -1
  160. package/lib-commonjs/legacy/RadioButton.settings.d.ts +0 -5
  161. package/lib-commonjs/legacy/RadioButton.settings.d.ts.map +0 -1
  162. package/lib-commonjs/legacy/RadioButton.settings.js +0 -98
  163. package/lib-commonjs/legacy/RadioButton.settings.js.map +0 -1
  164. package/lib-commonjs/legacy/RadioButton.types.d.ts +0 -62
  165. package/lib-commonjs/legacy/RadioButton.types.d.ts.map +0 -1
  166. package/lib-commonjs/legacy/RadioButton.types.js +0 -5
  167. package/lib-commonjs/legacy/RadioButton.types.js.map +0 -1
  168. package/lib-commonjs/legacy/RadioButton.win32.d.ts +0 -4
  169. package/lib-commonjs/legacy/RadioButton.win32.d.ts.map +0 -1
  170. package/lib-commonjs/legacy/RadioButton.win32.js +0 -188
  171. package/lib-commonjs/legacy/RadioButton.win32.js.map +0 -1
  172. package/lib-commonjs/legacy/RadioGroup.d.ts +0 -7
  173. package/lib-commonjs/legacy/RadioGroup.d.ts.map +0 -1
  174. package/lib-commonjs/legacy/RadioGroup.js +0 -139
  175. package/lib-commonjs/legacy/RadioGroup.js.map +0 -1
  176. package/lib-commonjs/legacy/RadioGroup.settings.d.ts +0 -4
  177. package/lib-commonjs/legacy/RadioGroup.settings.d.ts.map +0 -1
  178. package/lib-commonjs/legacy/RadioGroup.settings.js +0 -28
  179. package/lib-commonjs/legacy/RadioGroup.settings.js.map +0 -1
  180. package/lib-commonjs/legacy/RadioGroup.types.d.ts +0 -96
  181. package/lib-commonjs/legacy/RadioGroup.types.d.ts.map +0 -1
  182. package/lib-commonjs/legacy/RadioGroup.types.js +0 -5
  183. package/lib-commonjs/legacy/RadioGroup.types.js.map +0 -1
  184. package/lib-commonjs/legacy/__tests__/RadioButton.test.d.ts +0 -2
  185. package/lib-commonjs/legacy/__tests__/RadioButton.test.d.ts.map +0 -1
  186. package/lib-commonjs/legacy/__tests__/RadioButton.test.js +0 -49
  187. package/lib-commonjs/legacy/__tests__/RadioButton.test.js.map +0 -1
  188. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.d.ts +0 -2
  189. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.d.ts.map +0 -1
  190. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.js +0 -61
  191. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.js.map +0 -1
@@ -11,18 +11,34 @@ import { useRadioGroupContext } from '../RadioGroup/radioGroupContext';
11
11
 
12
12
  const defaultAccessibilityActions = [{ name: 'Select' }];
13
13
 
14
- enum DirectionalArrowKeys {
15
- ArrowUp = 'ArrowUp',
16
- ArrowDown = 'ArrowDown',
17
- ArrowRight = 'ArrowRight',
18
- ArrowLeft = 'ArrowLeft',
19
- }
14
+ const DirectionalArrowKeys = {
15
+ ArrowUp: 'ArrowUp',
16
+ ArrowDown: 'ArrowDown',
17
+ ArrowRight: 'ArrowRight',
18
+ ArrowLeft: 'ArrowLeft',
19
+ } as const;
20
+ type DirectionalArrowKeys = (typeof DirectionalArrowKeys)[keyof typeof DirectionalArrowKeys];
20
21
 
21
22
  export const useRadio = (props: RadioProps): RadioInfo => {
22
23
  const defaultComponentRef = React.useRef(null);
23
24
 
24
25
  // Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
25
26
  const radioGroupContext = useRadioGroupContext();
27
+ const {
28
+ addRadioEnabledValue,
29
+ addRadioValue,
30
+ disabled: groupDisabled,
31
+ enabledValues,
32
+ invoked,
33
+ layout,
34
+ onChange,
35
+ removeRadioEnabledValue,
36
+ removeRadioValue,
37
+ updateInvoked,
38
+ updateSelectedButtonRef,
39
+ value: selectedValue,
40
+ values,
41
+ } = radioGroupContext;
26
42
 
27
43
  const {
28
44
  label,
@@ -39,44 +55,47 @@ export const useRadio = (props: RadioProps): RadioInfo => {
39
55
  ...rest
40
56
  } = props;
41
57
 
42
- const labelPosition = radioGroupContext.layout === 'horizontal-stacked' ? 'below' : 'after';
58
+ const labelPosition = layout === 'horizontal-stacked' ? 'below' : 'after';
43
59
 
44
- const isDisabled = radioGroupContext.disabled || disabled;
60
+ const isDisabled = groupDisabled || disabled;
45
61
 
46
62
  const buttonRef = useViewCommandFocus(componentRef);
47
63
 
48
64
  /* We don't want to call the user's onChange multiple times on the same selection. */
49
65
  const changeSelection = React.useCallback(() => {
50
- if (value !== radioGroupContext.value) {
51
- radioGroupContext.onChange && radioGroupContext.onChange(value);
52
- radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
66
+ if (value !== selectedValue) {
67
+ onChange && onChange(value);
68
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
53
69
  }
54
- }, [radioGroupContext, value, componentRef]);
70
+ }, [componentRef, onChange, selectedValue, updateSelectedButtonRef, value]);
55
71
 
56
72
  /* We use the componentRef of the currently selected button to maintain the default tabbable
57
73
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
58
74
  we must update it once here. */
59
75
  React.useEffect(() => {
60
- if (value === radioGroupContext.value && !isDisabled) {
61
- radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
76
+ if (value === selectedValue && !isDisabled) {
77
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
62
78
  }
79
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
63
80
  }, []);
64
81
 
65
82
  // Explicitly only run on mount and unmount
66
83
  React.useEffect(() => {
67
- radioGroupContext.addRadioValue(value);
84
+ addRadioValue(value);
68
85
 
69
86
  return () => {
70
- radioGroupContext.removeRadioValue(value);
87
+ removeRadioValue(value);
71
88
  };
89
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
72
90
  }, []);
73
91
 
74
92
  React.useEffect(() => {
75
93
  if (isDisabled) {
76
- radioGroupContext.removeRadioEnabledValue(value);
94
+ removeRadioEnabledValue(value);
77
95
  } else {
78
- radioGroupContext.addRadioEnabledValue(value);
96
+ addRadioEnabledValue(value);
79
97
  }
98
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- only re-run when isDisabled changes
80
99
  }, [isDisabled]);
81
100
 
82
101
  const isRTL = I18nManager.isRTL;
@@ -84,37 +103,38 @@ export const useRadio = (props: RadioProps): RadioInfo => {
84
103
  const onInvoke = React.useCallback(
85
104
  (e: KeyPressEvent) => {
86
105
  if (e.nativeEvent.key in DirectionalArrowKeys) {
87
- const length = radioGroupContext.enabledValues.length;
106
+ const length = enabledValues.length;
88
107
  const previous =
89
108
  e.nativeEvent.key === DirectionalArrowKeys.ArrowUp ||
90
109
  (isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowRight : e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft);
91
110
  const next =
92
111
  e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
93
112
  (isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
94
- const currRadioIndex = radioGroupContext.enabledValues.indexOf(radioGroupContext.value);
113
+ const currRadioIndex = enabledValues.indexOf(selectedValue);
95
114
  let newCurrRadioIndex;
96
115
  if (next) {
97
116
  newCurrRadioIndex = (currRadioIndex + 1) % length;
98
- radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
99
- radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
117
+ onChange && onChange(enabledValues[newCurrRadioIndex]);
118
+ updateInvoked && updateInvoked(true);
100
119
  } else if (previous) {
101
120
  newCurrRadioIndex = (currRadioIndex - 1 + length) % length;
102
- radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
103
- radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
121
+ onChange && onChange(enabledValues[newCurrRadioIndex]);
122
+ updateInvoked && updateInvoked(true);
104
123
  }
105
124
  }
106
125
  },
107
- [radioGroupContext],
126
+ [enabledValues, isRTL, onChange, selectedValue, updateInvoked],
108
127
  );
109
128
 
110
129
  // Sets the updated selected button ref and focus if this Radio is selected via arrow key.
111
130
  React.useEffect(() => {
112
- if (radioGroupContext.invoked && value === radioGroupContext.value && !isDisabled) {
113
- radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
131
+ if (invoked && value === selectedValue && !isDisabled) {
132
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
114
133
  componentRef?.current?.focus();
115
- radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(false);
134
+ updateInvoked && updateInvoked(false);
116
135
  }
117
- }, [radioGroupContext.invoked]);
136
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- only re-run when invoked changes
137
+ }, [invoked]);
118
138
 
119
139
  const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
120
140
 
@@ -150,7 +170,7 @@ export const useRadio = (props: RadioProps): RadioInfo => {
150
170
 
151
171
  const state = {
152
172
  ...pressable.state,
153
- selected: radioGroupContext.value === props.value && !isDisabled,
173
+ selected: selectedValue === props.value && !isDisabled,
154
174
  disabled: isDisabled || false,
155
175
  };
156
176
 
@@ -168,8 +188,8 @@ export const useRadio = (props: RadioProps): RadioInfo => {
168
188
  accessibilityHint: accessibilityHint ?? subtext,
169
189
  accessibilityState: getAccessibilityState(state.disabled, state.selected, accessibilityState),
170
190
  accessibilityActions: accessibilityActionsProp,
171
- accessibilityPosInSet: accessibilityPosInSet ?? radioGroupContext.values.findIndex((x) => x == value) + 1,
172
- accessibilitySetSize: accessibilitySetSize ?? radioGroupContext.values.length,
191
+ accessibilityPosInSet: accessibilityPosInSet ?? values.findIndex((x) => x == value) + 1,
192
+ accessibilitySetSize: accessibilitySetSize ?? values.length,
173
193
  focusable: !state.disabled,
174
194
  disabled: isDisabled,
175
195
  onAccessibilityAction: onAccessibilityAction,
@@ -22,27 +22,29 @@ export const RadioButton = compose<IRadioButtonType>({
22
22
  const defaultComponentRef = React.useRef(null);
23
23
  const { content, buttonKey, disabled, componentRef = defaultComponentRef } = userProps;
24
24
  const info = React.useContext(RadioGroupContext);
25
+ const { onChange, selectedKey, updateSelectedButtonRef } = info;
25
26
 
26
27
  // Reroute the native component's onPress event to RadioGroup's onChange
27
- const onPressRerouted = () => {
28
+ const onPressRerouted = React.useCallback(() => {
28
29
  // Prevent calls to RadioGroup's onChange on the currently selected button
29
- if (buttonKey != info.selectedKey) {
30
- info.onChange && info.onChange(buttonKey);
31
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
30
+ if (buttonKey != selectedKey) {
31
+ onChange && onChange(buttonKey);
32
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
32
33
  }
33
- };
34
+ }, [buttonKey, componentRef, onChange, selectedKey, updateSelectedButtonRef]);
34
35
 
35
36
  /* We use the componentRef of the currently selected button to maintain the default tabbable
36
37
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
37
38
  we must update it once here. */
38
39
  React.useEffect(() => {
39
- if (buttonKey === info.selectedKey) {
40
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
40
+ if (buttonKey === selectedKey) {
41
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
41
42
  }
43
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
42
44
  }, []);
43
45
 
44
46
  const styleProps = useStyling(userProps);
45
- const isSelected = info.selectedKey === buttonKey;
47
+ const isSelected = selectedKey === buttonKey;
46
48
  const slotProps = mergeSettings<IRadioButtonSlotProps>(styleProps, {
47
49
  root: {
48
50
  ref: componentRef,
@@ -38,24 +38,26 @@ export const RadioButton = compose<IRadioButtonType>({
38
38
 
39
39
  // Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
40
40
  const info = React.useContext(RadioGroupContext);
41
+ const { selectedKey, onChange, updateSelectedButtonRef, buttonKeys } = info;
41
42
 
42
43
  const buttonRef = useViewCommandFocus(componentRef);
43
44
 
44
45
  /* We don't want to call the user's onChange multiple times on the same selection. */
45
- const changeSelection = () => {
46
- if (buttonKey != info.selectedKey) {
47
- info.onChange && info.onChange(buttonKey);
48
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
46
+ const changeSelection = React.useCallback(() => {
47
+ if (buttonKey != selectedKey) {
48
+ onChange && onChange(buttonKey);
49
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
49
50
  }
50
- };
51
+ }, [buttonKey, componentRef, onChange, selectedKey, updateSelectedButtonRef]);
51
52
 
52
53
  /* We use the componentRef of the currently selected button to maintain the default tabbable
53
54
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
54
55
  we must update it once here. */
55
56
  React.useEffect(() => {
56
- if (buttonKey == info.selectedKey) {
57
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
57
+ if (buttonKey == selectedKey) {
58
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
58
59
  }
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
59
61
  }, []);
60
62
 
61
63
  // Ensure focus is placed on button after click
@@ -77,12 +79,12 @@ export const RadioButton = compose<IRadioButtonType>({
77
79
  break;
78
80
  }
79
81
  },
80
- [info, buttonKey],
82
+ [changeSelection],
81
83
  );
82
84
 
83
85
  const state = {
84
86
  ...pressable.state,
85
- selected: info.selectedKey === userProps.buttonKey,
87
+ selected: selectedKey === userProps.buttonKey,
86
88
  disabled: disabled || false,
87
89
  };
88
90
 
@@ -98,8 +100,8 @@ export const RadioButton = compose<IRadioButtonType>({
98
100
  accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
99
101
  accessibilityState: { disabled: state.disabled, selected: state.selected },
100
102
  accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
101
- accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
102
- accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
103
+ accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? buttonKeys.findIndex((x) => x == buttonKey) + 1,
104
+ accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? buttonKeys.length,
103
105
  focusable: !state.disabled,
104
106
  onAccessibilityAction: onAccessibilityAction,
105
107
  },
@@ -18,12 +18,13 @@ import type { IRadioButtonType, IRadioButtonProps, IRadioButtonSlotProps, IRadio
18
18
  import { radioButtonName } from './RadioButton.types';
19
19
  import { RadioGroupContext } from './RadioGroup';
20
20
 
21
- enum DirectionalArrowKeys {
22
- ArrowUp = 'ArrowUp',
23
- ArrowDown = 'ArrowDown',
24
- ArrowRight = 'ArrowRight',
25
- ArrowLeft = 'ArrowLeft',
26
- }
21
+ const DirectionalArrowKeys = {
22
+ ArrowUp: 'ArrowUp',
23
+ ArrowDown: 'ArrowDown',
24
+ ArrowRight: 'ArrowRight',
25
+ ArrowLeft: 'ArrowLeft',
26
+ } as const;
27
+ type DirectionalArrowKeys = (typeof DirectionalArrowKeys)[keyof typeof DirectionalArrowKeys];
27
28
 
28
29
  export const RadioButton = compose<IRadioButtonType>({
29
30
  displayName: radioButtonName,
@@ -46,38 +47,53 @@ export const RadioButton = compose<IRadioButtonType>({
46
47
 
47
48
  // Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
48
49
  const info = React.useContext(RadioGroupContext);
50
+ const {
51
+ addRadioButtonEnabledKey,
52
+ addRadioButtonKey,
53
+ buttonKeys,
54
+ enabledButtonKeys,
55
+ invoked,
56
+ onChange,
57
+ removeRadioButtonEnabledKey,
58
+ removeRadioButtonKey,
59
+ selectedKey,
60
+ updateInvoked,
61
+ updateSelectedButtonRef,
62
+ } = info;
49
63
 
50
64
  const buttonRef = useViewCommandFocus(componentRef);
51
65
 
52
66
  /* We don't want to call the user's onChange multiple times on the same selection. */
53
- const changeSelection = () => {
54
- if (buttonKey != info.selectedKey) {
55
- info.onChange && info.onChange(buttonKey);
56
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
67
+ const changeSelection = React.useCallback(() => {
68
+ if (buttonKey != selectedKey) {
69
+ onChange && onChange(buttonKey);
70
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
57
71
  }
58
- };
72
+ }, [buttonKey, componentRef, onChange, selectedKey, updateSelectedButtonRef]);
59
73
 
60
74
  /* We use the componentRef of the currently selected button to maintain the default tabbable
61
75
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
62
76
  we must update it once here. */
63
77
  React.useEffect(() => {
64
- if (buttonKey == info.selectedKey) {
65
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
78
+ if (buttonKey == selectedKey) {
79
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
66
80
  }
81
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
67
82
  }, []);
68
83
 
69
84
  // Explicitly only run on mount and unmount
70
85
  React.useEffect(() => {
71
- info.addRadioButtonKey(buttonKey);
86
+ addRadioButtonKey(buttonKey);
72
87
 
73
88
  if (!disabled) {
74
- info.addRadioButtonEnabledKey(buttonKey);
89
+ addRadioButtonEnabledKey(buttonKey);
75
90
  }
76
91
 
77
92
  return () => {
78
- info.removeRadioButtonKey(buttonKey);
79
- info.removeRadioButtonEnabledKey(buttonKey);
93
+ removeRadioButtonKey(buttonKey);
94
+ removeRadioButtonEnabledKey(buttonKey);
80
95
  };
96
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
81
97
  }, []);
82
98
 
83
99
  const isRTL = I18nManager.isRTL;
@@ -85,11 +101,11 @@ export const RadioButton = compose<IRadioButtonType>({
85
101
  const onInvoke = React.useCallback(
86
102
  (e: KeyPressEvent) => {
87
103
  if (e.nativeEvent.key in DirectionalArrowKeys) {
88
- const length = info.enabledButtonKeys.length;
104
+ const length = enabledButtonKeys.length;
89
105
  const next =
90
106
  e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
91
107
  (isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
92
- const currRadioButtonIndex = info.enabledButtonKeys.indexOf(info.selectedKey);
108
+ const currRadioButtonIndex = enabledButtonKeys.indexOf(selectedKey);
93
109
  let newCurrRadioButtonIndex;
94
110
  if (next) {
95
111
  newCurrRadioButtonIndex = (currRadioButtonIndex + 1) % length;
@@ -97,21 +113,22 @@ export const RadioButton = compose<IRadioButtonType>({
97
113
  // previous
98
114
  newCurrRadioButtonIndex = (currRadioButtonIndex - 1 + length) % length;
99
115
  }
100
- info.onChange && info.onChange(info.enabledButtonKeys[newCurrRadioButtonIndex]);
101
- info.updateInvoked && info.updateInvoked(true);
116
+ onChange && onChange(enabledButtonKeys[newCurrRadioButtonIndex]);
117
+ updateInvoked && updateInvoked(true);
102
118
  }
103
119
  },
104
- [info],
120
+ [enabledButtonKeys, isRTL, onChange, selectedKey, updateInvoked],
105
121
  );
106
122
 
107
123
  // Sets the updated selected button ref and focus if this Radio is selected via arrow key.
108
124
  React.useEffect(() => {
109
- if (info.invoked && buttonKey === info.selectedKey && !disabled) {
110
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
125
+ if (invoked && buttonKey === selectedKey && !disabled) {
126
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
111
127
  componentRef?.current?.focus();
112
- info.updateInvoked && info.updateInvoked(false);
128
+ updateInvoked && updateInvoked(false);
113
129
  }
114
- }, [info.invoked]);
130
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- only re-run when invoked changes
131
+ }, [invoked]);
115
132
 
116
133
  const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
117
134
 
@@ -119,13 +136,13 @@ export const RadioButton = compose<IRadioButtonType>({
119
136
  const onKeyDownProps = useKeyDownProps(onInvoke, ...keys);
120
137
 
121
138
  // Ensure focus is placed on button after click
122
- const changeSelectionWithFocus = () => {
123
- if (buttonKey != info.selectedKey) {
124
- info.onChange && info.onChange(buttonKey);
125
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
126
- info.updateInvoked && info.updateInvoked(true);
139
+ const changeSelectionWithFocus = React.useCallback(() => {
140
+ if (buttonKey != selectedKey) {
141
+ onChange && onChange(buttonKey);
142
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
143
+ updateInvoked && updateInvoked(true);
127
144
  }
128
- };
145
+ }, [buttonKey, componentRef, onChange, selectedKey, updateInvoked, updateSelectedButtonRef]);
129
146
 
130
147
  /* RadioButton changes selection when focus is moved between each RadioButton and on a click */
131
148
  const pressable = useAsPressable({
@@ -143,12 +160,12 @@ export const RadioButton = compose<IRadioButtonType>({
143
160
  break;
144
161
  }
145
162
  },
146
- [info, buttonKey],
163
+ [changeSelection],
147
164
  );
148
165
 
149
166
  const state = {
150
167
  ...pressable.state,
151
- selected: info.selectedKey === userProps.buttonKey && !disabled,
168
+ selected: selectedKey === userProps.buttonKey && !disabled,
152
169
  disabled: disabled || false,
153
170
  };
154
171
 
@@ -164,8 +181,8 @@ export const RadioButton = compose<IRadioButtonType>({
164
181
  accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
165
182
  accessibilityState: { disabled: state.disabled, selected: state.selected },
166
183
  accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
167
- accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
168
- accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
184
+ accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? buttonKeys.findIndex((x) => x == buttonKey) + 1,
185
+ accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? buttonKeys.length,
169
186
  focusable: !state.disabled,
170
187
  onAccessibilityAction: onAccessibilityAction,
171
188
  ...onKeyDownProps,
@@ -64,16 +64,14 @@ export const RadioGroup = compose<IRadioGroupType>({
64
64
 
65
65
  const onAddRadioButtonKey = React.useCallback(
66
66
  (buttonKey: string) => {
67
- buttonKeys.push(buttonKey);
68
- setButtonKeys(buttonKeys);
67
+ setButtonKeys((prevButtonKeys) => [...prevButtonKeys, buttonKey]);
69
68
  },
70
69
  [setButtonKeys],
71
70
  );
72
71
 
73
72
  const onRemoveRadioButtonKey = React.useCallback(
74
73
  (buttonKey: string) => {
75
- buttonKeys.filter((item) => item !== buttonKey);
76
- setButtonKeys(buttonKeys);
74
+ setButtonKeys((prevButtonKeys) => prevButtonKeys.filter((item) => item !== buttonKey));
77
75
  },
78
76
  [setButtonKeys],
79
77
  );
@@ -82,16 +80,14 @@ export const RadioGroup = compose<IRadioGroupType>({
82
80
 
83
81
  const onAddRadioButtonEnabledKey = React.useCallback(
84
82
  (buttonKey: string) => {
85
- enabledButtonKeys.push(buttonKey);
86
- setEnabledButtonKeys(enabledButtonKeys);
83
+ setEnabledButtonKeys((prevEnabledButtonKeys) => [...prevEnabledButtonKeys, buttonKey]);
87
84
  },
88
85
  [setEnabledButtonKeys],
89
86
  );
90
87
 
91
88
  const onRemoveRadioButtonEnabledKey = React.useCallback(
92
89
  (buttonKey: string) => {
93
- enabledButtonKeys.filter((item) => item !== buttonKey);
94
- setEnabledButtonKeys(enabledButtonKeys);
90
+ setEnabledButtonKeys((prevEnabledButtonKeys) => prevEnabledButtonKeys.filter((item) => item !== buttonKey));
95
91
  },
96
92
  [setEnabledButtonKeys],
97
93
  );
package/tsconfig.json CHANGED
@@ -1,7 +1,57 @@
1
1
  {
2
- "extends": "@fluentui-react-native/scripts/configs/tsconfig.json",
2
+ "extends": "@fluentui-react-native/scripts/tsconfig",
3
3
  "compilerOptions": {
4
- "outDir": "lib"
4
+ "outDir": "lib",
5
+ "rootDir": "src",
6
+ "composite": true,
7
+ "tsBuildInfoFile": ".cache/tsconfig.tsbuildinfo"
5
8
  },
6
- "include": ["src"]
9
+ "include": ["src"],
10
+ "references": [
11
+ {
12
+ "path": "../../utils/adapters/tsconfig.json"
13
+ },
14
+ {
15
+ "path": "../FocusZone/tsconfig.json"
16
+ },
17
+ {
18
+ "path": "../../framework-base/tsconfig.json"
19
+ },
20
+ {
21
+ "path": "../../framework/framework/tsconfig.json"
22
+ },
23
+ {
24
+ "path": "../../utils/interactive-hooks/tsconfig.json"
25
+ },
26
+ {
27
+ "path": "../Pressable/tsconfig.json"
28
+ },
29
+ {
30
+ "path": "../../../scripts/tsconfig.json"
31
+ },
32
+ {
33
+ "path": "../../utils/test-tools/tsconfig.json"
34
+ },
35
+ {
36
+ "path": "../Text/tsconfig.json"
37
+ },
38
+ {
39
+ "path": "../../theming/theme-tokens/tsconfig.json"
40
+ },
41
+ {
42
+ "path": "../../utils/tokens/tsconfig.json"
43
+ },
44
+ {
45
+ "path": "../../framework/use-styling/tsconfig.json"
46
+ },
47
+ {
48
+ "path": "../../deprecated/foundation-composable/tsconfig.json"
49
+ },
50
+ {
51
+ "path": "../../deprecated/foundation-compose/tsconfig.json"
52
+ },
53
+ {
54
+ "path": "../../deprecated/foundation-settings/tsconfig.json"
55
+ }
56
+ ]
7
57
  }
package/babel.config.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('@fluentui-react-native/babel-config');
package/eslint.config.js DELETED
@@ -1,3 +0,0 @@
1
- const baseConfig = require('@fluentui-react-native/eslint-config-rules');
2
-
3
- module.exports = baseConfig;
package/jest.config.js DELETED
@@ -1,2 +0,0 @@
1
- const { configureReactNativeJest } = require('@fluentui-react-native/jest-config');
2
- module.exports = configureReactNativeJest('android');
@@ -1,13 +0,0 @@
1
- import type { PressableState } from '@fluentui-react-native/interactive-hooks';
2
- import type { RadioProps } from './Radio.types';
3
- /**
4
- * A function which determines if a set of styles should be applied to the component given the current state and props of the Radio.
5
- *
6
- * @param layer The name of the state that is being checked for
7
- * @param state The current state of the Radio
8
- * @param userProps The props that were passed into the Radio
9
- * @returns Whether the styles that are assigned to the layer should be applied to the Radio
10
- */
11
- export declare const radioLookup: (layer: string, state: PressableState, userProps: RadioProps) => boolean;
12
- export declare const Radio: import("@fluentui-react-native/framework").ComposableComponent<RadioProps, import("./Radio.types").RadioSlotProps, import("./Radio.types").RadioTokens, import("@fluentui-react-native/framework").ObjectBase>;
13
- //# sourceMappingURL=Radio.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../src/Radio/Radio.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAI/E,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3D;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,0EAQvB,CAAC;AAEF,eAAO,MAAM,KAAK,gNA6ChB,CAAC"}
@@ -1,13 +0,0 @@
1
- import type { PressableState } from '@fluentui-react-native/interactive-hooks';
2
- import type { RadioProps } from './Radio.types';
3
- /**
4
- * A function which determines if a set of styles should be applied to the component given the current state and props of the Radio.
5
- *
6
- * @param layer The name of the state that is being checked for
7
- * @param state The current state of the Radio
8
- * @param userProps The props that were passed into the Radio
9
- * @returns Whether the styles that are assigned to the layer should be applied to the Radio
10
- */
11
- export declare const radioLookup: (layer: string, state: PressableState, userProps: RadioProps) => boolean;
12
- export declare const Radio: import("@fluentui-react-native/framework").ComposableComponent<RadioProps, import("./Radio.types").RadioSlotProps, import("./Radio.types").RadioTokens, import("@fluentui-react-native/framework").ObjectBase>;
13
- //# sourceMappingURL=Radio.ios.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Radio.ios.d.ts","sourceRoot":"","sources":["../../src/Radio/Radio.ios.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAK/E,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3D;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,0EAQvB,CAAC;AAEF,eAAO,MAAM,KAAK,gNAqDhB,CAAC"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Radio = exports.radioLookup = void 0;
4
- const jsx_runtime_1 = require("@fluentui-react-native/framework-base/jsx-runtime");
5
- /** @jsxImportSource @fluentui-react-native/framework-base */
6
- const react_native_1 = require("react-native");
7
- const framework_1 = require("@fluentui-react-native/framework");
8
- const text_1 = require("@fluentui-react-native/text");
9
- const react_native_svg_1 = require("react-native-svg");
10
- const Radio_styling_1 = require("./Radio.styling");
11
- const Radio_types_1 = require("./Radio.types");
12
- const useRadio_1 = require("./useRadio");
13
- /**
14
- * A function which determines if a set of styles should be applied to the component given the current state and props of the Radio.
15
- *
16
- * @param layer The name of the state that is being checked for
17
- * @param state The current state of the Radio
18
- * @param userProps The props that were passed into the Radio
19
- * @returns Whether the styles that are assigned to the layer should be applied to the Radio
20
- */
21
- const radioLookup = (layer, state, userProps) => {
22
- return (state[layer] ||
23
- userProps[layer] ||
24
- (!(react_native_1.Platform.OS === 'win32' || react_native_1.Platform.OS === 'android') &&
25
- layer === 'labelPositionBelow' &&
26
- userProps['labelPosition'] === 'below'));
27
- };
28
- exports.radioLookup = radioLookup;
29
- exports.Radio = (0, framework_1.compose)({
30
- displayName: Radio_types_1.radioName,
31
- ...Radio_styling_1.stylingSettings,
32
- slots: {
33
- root: react_native_1.Pressable,
34
- button: react_native_1.Pressable,
35
- checkmark: react_native_svg_1.Svg,
36
- labelContent: react_native_1.View,
37
- label: text_1.TextV1,
38
- subtext: text_1.TextV1,
39
- },
40
- useRender: (userProps, useSlots) => {
41
- const radio = (0, useRadio_1.useRadio)(userProps);
42
- const Slots = useSlots(userProps, (layer) => (0, exports.radioLookup)(layer, radio.state, radio.props));
43
- // now return the handler for finishing render
44
- return (final) => {
45
- const { label, subtext, ...mergedProps } = (0, framework_1.mergeProps)(radio.props, final);
46
- const { onPress, disabled, onPressIn, onPressOut } = mergedProps;
47
- const labelComponent = (jsx_runtime_1.jsxs(Slots.labelContent, { children: [
48
- jsx_runtime_1.jsx(Slots.label, { children: label }), !!subtext && jsx_runtime_1.jsx(Slots.subtext, { children: subtext })] }));
49
- const checkmarkPath = (jsx_runtime_1.jsx(react_native_svg_1.Path, { fill: "currentColor", d: "M9.76497 3.20474C10.0661 3.48915 10.0797 3.96383 9.79526 4.26497L5.54526 8.76497C5.40613 8.91228 5.21332 8.99703 5.01071 8.99993C4.8081 9.00282 4.61295 8.92361 4.46967 8.78033L2.21967 6.53033C1.92678 6.23744 1.92678 5.76257 2.21967 5.46967C2.51256 5.17678 2.98744 5.17678 3.28033 5.46967L4.98463 7.17397L8.70474 3.23503C8.98915 2.9339 9.46383 2.92033 9.76497 3.20474Z" }));
50
- return (jsx_runtime_1.jsxs(Slots.root, { ...mergedProps, accessible: !disabled, focusable: !disabled, children: [
51
- jsx_runtime_1.jsx(Slots.button, { accessible: false, onPress: onPress, onPressIn: onPressIn, onPressOut: onPressOut, disabled: disabled, focusable: false, children: jsx_runtime_1.jsx(Slots.checkmark, { viewBox: "0 0 12 12", children: checkmarkPath }, "checkmark") }), labelComponent] }));
52
- };
53
- },
54
- });
55
- //# sourceMappingURL=Radio.ios.js.map