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

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 (187) hide show
  1. package/CHANGELOG.md +60 -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.d.ts.map +1 -1
  26. package/lib/Radio/useRadio.js +72 -91
  27. package/lib/Radio/useRadio.js.map +1 -1
  28. package/lib/Radio/useRadio.win32.d.ts +1 -1
  29. package/lib/Radio/useRadio.win32.d.ts.map +1 -1
  30. package/lib/Radio/useRadio.win32.js +126 -143
  31. package/lib/Radio/useRadio.win32.js.map +1 -1
  32. package/lib/RadioGroup/RadioGroup.d.ts +2 -7
  33. package/lib/RadioGroup/RadioGroup.js +34 -48
  34. package/lib/RadioGroup/RadioGroup.styling.d.ts +1 -1
  35. package/lib/RadioGroup/RadioGroup.styling.js +42 -51
  36. package/lib/RadioGroup/RadioGroup.types.d.ts +117 -117
  37. package/lib/RadioGroup/RadioGroup.types.js +1 -1
  38. package/lib/RadioGroup/RadioGroupTokens.android.d.ts +1 -1
  39. package/lib/RadioGroup/RadioGroupTokens.android.js +1 -1
  40. package/lib/RadioGroup/RadioGroupTokens.d.ts +1 -1
  41. package/lib/RadioGroup/RadioGroupTokens.ios.d.ts +1 -1
  42. package/lib/RadioGroup/RadioGroupTokens.ios.js +1 -1
  43. package/lib/RadioGroup/RadioGroupTokens.js +12 -12
  44. package/lib/RadioGroup/RadioGroupTokens.js.map +1 -1
  45. package/lib/RadioGroup/RadioGroupTokens.mobile.d.ts +1 -1
  46. package/lib/RadioGroup/RadioGroupTokens.mobile.js +13 -13
  47. package/lib/RadioGroup/RadioGroupTokens.mobile.js.map +1 -1
  48. package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts +1 -1
  49. package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.js +56 -98
  50. package/lib/RadioGroup/radioGroupContext.d.ts +1 -1
  51. package/lib/RadioGroup/radioGroupContext.js +15 -19
  52. package/lib/RadioGroup/useRadioGroup.d.ts +1 -1
  53. package/lib/RadioGroup/useRadioGroup.js +63 -93
  54. package/lib/RadioGroup/useRadioGroupContextValue.d.ts +1 -1
  55. package/lib/RadioGroup/useRadioGroupContextValue.js +2 -2
  56. package/lib/index.d.ts +4 -25
  57. package/lib/index.js +1 -1
  58. package/lib/legacy/MacOSRadioButtonNativeComponent.d.ts +6 -6
  59. package/lib/legacy/MacOSRadioButtonNativeComponent.js +1 -1
  60. package/lib/legacy/RadioButton.d.ts +2 -8
  61. package/lib/legacy/RadioButton.d.ts.map +1 -1
  62. package/lib/legacy/RadioButton.js +82 -96
  63. package/lib/legacy/RadioButton.js.map +1 -1
  64. package/lib/legacy/RadioButton.macos.d.ts +2 -8
  65. package/lib/legacy/RadioButton.macos.d.ts.map +1 -1
  66. package/lib/legacy/RadioButton.macos.js +50 -48
  67. package/lib/legacy/RadioButton.macos.js.map +1 -1
  68. package/lib/legacy/RadioButton.settings.d.ts +2 -2
  69. package/lib/legacy/RadioButton.settings.js +81 -81
  70. package/lib/legacy/RadioButton.types.d.ts +45 -45
  71. package/lib/legacy/RadioButton.types.js +1 -1
  72. package/lib/legacy/RadioButton.win32.d.ts +2 -8
  73. package/lib/legacy/RadioButton.win32.d.ts.map +1 -1
  74. package/lib/legacy/RadioButton.win32.js +136 -151
  75. package/lib/legacy/RadioButton.win32.js.map +1 -1
  76. package/lib/legacy/RadioGroup.d.ts +2 -8
  77. package/lib/legacy/RadioGroup.d.ts.map +1 -1
  78. package/lib/legacy/RadioGroup.js +80 -108
  79. package/lib/legacy/RadioGroup.js.map +1 -1
  80. package/lib/legacy/RadioGroup.settings.d.ts +1 -1
  81. package/lib/legacy/RadioGroup.settings.js +21 -21
  82. package/lib/legacy/RadioGroup.types.d.ts +79 -78
  83. package/lib/legacy/RadioGroup.types.js +1 -1
  84. package/lib/legacy/__tests__/RadioButton.test.d.ts +1 -1
  85. package/lib/legacy/__tests__/RadioButton.test.js +8 -8
  86. package/lib/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
  87. package/lib/legacy/__tests__/RadioButtonGroup.test.js +18 -34
  88. package/lib-commonjs/Radio/Radio.d.ts +2 -7
  89. package/lib-commonjs/Radio/Radio.ios.d.ts +2 -7
  90. package/lib-commonjs/Radio/Radio.ios.js +40 -64
  91. package/lib-commonjs/Radio/Radio.js +39 -59
  92. package/lib-commonjs/Radio/Radio.styling.d.ts +1 -1
  93. package/lib-commonjs/Radio/Radio.styling.js +94 -115
  94. package/lib-commonjs/Radio/Radio.types.d.ts +170 -176
  95. package/lib-commonjs/Radio/Radio.types.js +3 -3
  96. package/lib-commonjs/Radio/RadioTokens.android.d.ts +1 -1
  97. package/lib-commonjs/Radio/RadioTokens.android.js +45 -45
  98. package/lib-commonjs/Radio/RadioTokens.android.js.map +1 -1
  99. package/lib-commonjs/Radio/RadioTokens.d.ts +1 -1
  100. package/lib-commonjs/Radio/RadioTokens.ios.d.ts +1 -1
  101. package/lib-commonjs/Radio/RadioTokens.ios.js +42 -42
  102. package/lib-commonjs/Radio/RadioTokens.ios.js.map +1 -1
  103. package/lib-commonjs/Radio/RadioTokens.js +79 -79
  104. package/lib-commonjs/Radio/RadioTokens.js.map +1 -1
  105. package/lib-commonjs/Radio/RadioTokens.win32.d.ts +1 -1
  106. package/lib-commonjs/Radio/RadioTokens.win32.js +92 -92
  107. package/lib-commonjs/Radio/RadioTokens.win32.js.map +1 -1
  108. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.d.ts +1 -1
  109. package/lib-commonjs/Radio/__tests__/RadioExperimental.test.js +48 -65
  110. package/lib-commonjs/Radio/useRadio.d.ts +1 -1
  111. package/lib-commonjs/Radio/useRadio.d.ts.map +1 -1
  112. package/lib-commonjs/Radio/useRadio.js +107 -143
  113. package/lib-commonjs/Radio/useRadio.js.map +1 -1
  114. package/lib-commonjs/Radio/useRadio.win32.d.ts +1 -1
  115. package/lib-commonjs/Radio/useRadio.win32.d.ts.map +1 -1
  116. package/lib-commonjs/Radio/useRadio.win32.js +162 -196
  117. package/lib-commonjs/Radio/useRadio.win32.js.map +1 -1
  118. package/lib-commonjs/RadioGroup/RadioGroup.d.ts +2 -7
  119. package/lib-commonjs/RadioGroup/RadioGroup.js +45 -65
  120. package/lib-commonjs/RadioGroup/RadioGroup.styling.d.ts +1 -1
  121. package/lib-commonjs/RadioGroup/RadioGroup.styling.js +48 -57
  122. package/lib-commonjs/RadioGroup/RadioGroup.types.d.ts +117 -117
  123. package/lib-commonjs/RadioGroup/RadioGroup.types.js +3 -3
  124. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.d.ts +1 -1
  125. package/lib-commonjs/RadioGroup/RadioGroupTokens.android.js +5 -10
  126. package/lib-commonjs/RadioGroup/RadioGroupTokens.d.ts +1 -1
  127. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.d.ts +1 -1
  128. package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.js +5 -10
  129. package/lib-commonjs/RadioGroup/RadioGroupTokens.js +15 -15
  130. package/lib-commonjs/RadioGroup/RadioGroupTokens.js.map +1 -1
  131. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.d.ts +1 -1
  132. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js +16 -16
  133. package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js.map +1 -1
  134. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts +1 -1
  135. package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.js +91 -153
  136. package/lib-commonjs/RadioGroup/radioGroupContext.d.ts +1 -1
  137. package/lib-commonjs/RadioGroup/radioGroupContext.js +47 -68
  138. package/lib-commonjs/RadioGroup/useRadioGroup.d.ts +1 -1
  139. package/lib-commonjs/RadioGroup/useRadioGroup.js +97 -144
  140. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.d.ts +1 -1
  141. package/lib-commonjs/RadioGroup/useRadioGroupContextValue.js +4 -4
  142. package/lib-commonjs/index.d.ts +4 -25
  143. package/lib-commonjs/index.js +32 -128
  144. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.d.ts +6 -6
  145. package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.js +7 -9
  146. package/lib-commonjs/legacy/RadioButton.d.ts +2 -8
  147. package/lib-commonjs/legacy/RadioButton.d.ts.map +1 -1
  148. package/lib-commonjs/legacy/RadioButton.js +123 -162
  149. package/lib-commonjs/legacy/RadioButton.js.map +1 -1
  150. package/lib-commonjs/legacy/RadioButton.macos.d.ts +2 -8
  151. package/lib-commonjs/legacy/RadioButton.macos.d.ts.map +1 -1
  152. package/lib-commonjs/legacy/RadioButton.macos.js +90 -107
  153. package/lib-commonjs/legacy/RadioButton.macos.js.map +1 -1
  154. package/lib-commonjs/legacy/RadioButton.settings.d.ts +2 -2
  155. package/lib-commonjs/legacy/RadioButton.settings.js +84 -84
  156. package/lib-commonjs/legacy/RadioButton.types.d.ts +45 -45
  157. package/lib-commonjs/legacy/RadioButton.types.js +3 -3
  158. package/lib-commonjs/legacy/RadioButton.win32.d.ts +2 -8
  159. package/lib-commonjs/legacy/RadioButton.win32.d.ts.map +1 -1
  160. package/lib-commonjs/legacy/RadioButton.win32.js +177 -217
  161. package/lib-commonjs/legacy/RadioButton.win32.js.map +1 -1
  162. package/lib-commonjs/legacy/RadioGroup.d.ts +2 -8
  163. package/lib-commonjs/legacy/RadioGroup.d.ts.map +1 -1
  164. package/lib-commonjs/legacy/RadioGroup.js +121 -168
  165. package/lib-commonjs/legacy/RadioGroup.js.map +1 -1
  166. package/lib-commonjs/legacy/RadioGroup.settings.d.ts +1 -1
  167. package/lib-commonjs/legacy/RadioGroup.settings.js +24 -24
  168. package/lib-commonjs/legacy/RadioGroup.types.d.ts +79 -78
  169. package/lib-commonjs/legacy/RadioGroup.types.js +3 -3
  170. package/lib-commonjs/legacy/__tests__/RadioButton.test.d.ts +1 -1
  171. package/lib-commonjs/legacy/__tests__/RadioButton.test.js +42 -59
  172. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
  173. package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.js +53 -96
  174. package/package.json +35 -34
  175. package/src/Radio/RadioTokens.android.ts +1 -1
  176. package/src/Radio/RadioTokens.ios.ts +1 -1
  177. package/src/Radio/RadioTokens.ts +1 -1
  178. package/src/Radio/RadioTokens.win32.ts +1 -1
  179. package/src/Radio/useRadio.ts +13 -11
  180. package/src/Radio/useRadio.win32.ts +45 -26
  181. package/src/RadioGroup/RadioGroupTokens.mobile.ts +1 -1
  182. package/src/RadioGroup/RadioGroupTokens.ts +1 -1
  183. package/src/legacy/RadioButton.macos.tsx +10 -8
  184. package/src/legacy/RadioButton.tsx +13 -11
  185. package/src/legacy/RadioButton.win32.tsx +46 -30
  186. package/src/legacy/RadioGroup.tsx +4 -8
  187. package/eslint.config.js +0 -3
@@ -2,100 +2,70 @@ import * as React from 'react';
2
2
  import { memoize } from '@fluentui-react-native/framework';
3
3
  import { useSelectedKey as useValue } from '@fluentui-react-native/interactive-hooks';
4
4
  export const useRadioGroup = (props) => {
5
- const {
6
- accessible,
7
- value,
8
- defaultValue,
9
- disabled,
10
- required,
11
- layout,
12
- onChange,
13
- isCircularNavigation,
14
- accessibilityLabel,
15
- label,
16
- accessibilityState,
17
- } = props;
18
- // This hook updates the selected Radio and calls the customer's onClick function. This gets called after a button is pressed.
19
- const data = useValue(value || defaultValue || null, onChange);
20
- const [selectedButtonRef, setSelectedButtonRef] = React.useState(React.useRef(null));
21
- const onSelectButtonRef = React.useCallback(
22
- (ref) => {
23
- setSelectedButtonRef(ref);
24
- },
25
- [setSelectedButtonRef],
26
- );
27
- const [invoked, setInvoked] = React.useState(false);
28
- const onInvoked = React.useCallback(
29
- (check) => {
30
- setInvoked(check);
31
- },
32
- [setInvoked],
33
- );
34
- const [values, setValues] = React.useState([]);
35
- const onAddRadioValue = React.useCallback(
36
- (value) => {
37
- setValues((values) => [...values, value]);
38
- },
39
- [setValues],
40
- );
41
- const onRemoveRadioValue = React.useCallback(
42
- (value) => {
43
- setValues((values) => values.filter((item) => item !== value));
44
- },
45
- [setValues],
46
- );
47
- const [enabledValues, setEnabledValues] = React.useState([]);
48
- const onAddRadioEnabledValue = React.useCallback(
49
- (value) => {
50
- setEnabledValues((enabledValues) => [...enabledValues, value]);
51
- },
52
- [setEnabledValues],
53
- );
54
- const onRemoveRadioEnabledValue = React.useCallback(
55
- (value) => {
56
- setEnabledValues((enabledValues) => enabledValues.filter((item) => item !== value));
57
- },
58
- [setEnabledValues],
59
- );
60
- const state = {
61
- value: data.selectedKey,
62
- required: required || false,
63
- disabled: disabled || false,
64
- layout: layout || 'vertical',
65
- onChange: data.onKeySelect,
66
- updateSelectedButtonRef: onSelectButtonRef,
67
- invoked: invoked,
68
- updateInvoked: onInvoked,
69
- values: values,
70
- enabledValues: enabledValues,
71
- addRadioValue: onAddRadioValue,
72
- removeRadioValue: onRemoveRadioValue,
73
- addRadioEnabledValue: onAddRadioEnabledValue,
74
- removeRadioEnabledValue: onRemoveRadioEnabledValue,
75
- selectedButtonDisabled: values.includes(data.selectedKey) && !enabledValues.includes(data.selectedKey),
76
- };
77
- return {
78
- props: {
79
- ...props,
80
- required,
81
- layout,
82
- accessible: accessible ?? true,
83
- accessibilityRole: 'radiogroup',
84
- accessibilityLabel: accessibilityLabel ?? label,
85
- accessibilityState: getAccessibilityState(state.disabled, state.required, accessibilityState),
86
- defaultTabbableElement: selectedButtonRef,
87
- isCircularNavigation: isCircularNavigation ?? true,
88
- },
89
- state: {
90
- ...state,
91
- },
92
- };
5
+ const { accessible, value, defaultValue, disabled, required, layout, onChange, isCircularNavigation, accessibilityLabel, label, accessibilityState, } = props;
6
+ // This hook updates the selected Radio and calls the customer's onClick function. This gets called after a button is pressed.
7
+ const data = useValue(value || defaultValue || null, onChange);
8
+ const [selectedButtonRef, setSelectedButtonRef] = React.useState(React.useRef(null));
9
+ const onSelectButtonRef = React.useCallback((ref) => {
10
+ setSelectedButtonRef(ref);
11
+ }, [setSelectedButtonRef]);
12
+ const [invoked, setInvoked] = React.useState(false);
13
+ const onInvoked = React.useCallback((check) => {
14
+ setInvoked(check);
15
+ }, [setInvoked]);
16
+ const [values, setValues] = React.useState([]);
17
+ const onAddRadioValue = React.useCallback((value) => {
18
+ setValues((values) => [...values, value]);
19
+ }, [setValues]);
20
+ const onRemoveRadioValue = React.useCallback((value) => {
21
+ setValues((values) => values.filter((item) => item !== value));
22
+ }, [setValues]);
23
+ const [enabledValues, setEnabledValues] = React.useState([]);
24
+ const onAddRadioEnabledValue = React.useCallback((value) => {
25
+ setEnabledValues((enabledValues) => [...enabledValues, value]);
26
+ }, [setEnabledValues]);
27
+ const onRemoveRadioEnabledValue = React.useCallback((value) => {
28
+ setEnabledValues((enabledValues) => enabledValues.filter((item) => item !== value));
29
+ }, [setEnabledValues]);
30
+ const state = {
31
+ value: data.selectedKey,
32
+ required: required || false,
33
+ disabled: disabled || false,
34
+ layout: layout || 'vertical',
35
+ onChange: data.onKeySelect,
36
+ updateSelectedButtonRef: onSelectButtonRef,
37
+ invoked: invoked,
38
+ updateInvoked: onInvoked,
39
+ values: values,
40
+ enabledValues: enabledValues,
41
+ addRadioValue: onAddRadioValue,
42
+ removeRadioValue: onRemoveRadioValue,
43
+ addRadioEnabledValue: onAddRadioEnabledValue,
44
+ removeRadioEnabledValue: onRemoveRadioEnabledValue,
45
+ selectedButtonDisabled: values.includes(data.selectedKey) && !enabledValues.includes(data.selectedKey),
46
+ };
47
+ return {
48
+ props: {
49
+ ...props,
50
+ required,
51
+ layout,
52
+ accessible: accessible ?? true,
53
+ accessibilityRole: 'radiogroup',
54
+ accessibilityLabel: accessibilityLabel ?? label,
55
+ accessibilityState: getAccessibilityState(state.disabled, state.required, accessibilityState),
56
+ defaultTabbableElement: selectedButtonRef,
57
+ isCircularNavigation: isCircularNavigation ?? true,
58
+ },
59
+ state: {
60
+ ...state,
61
+ },
62
+ };
93
63
  };
94
64
  const getAccessibilityState = memoize(getAccessibilityStateWorker);
95
65
  function getAccessibilityStateWorker(disabled, required, accessibilityState) {
96
- if (accessibilityState) {
97
- return { disabled, required, ...accessibilityState };
98
- }
99
- return { disabled, required };
66
+ if (accessibilityState) {
67
+ return { disabled, required, ...accessibilityState };
68
+ }
69
+ return { disabled, required };
100
70
  }
101
- //# sourceMappingURL=useRadioGroup.js.map
71
+ //# sourceMappingURL=useRadioGroup.js.map
@@ -1,3 +1,3 @@
1
1
  import type { RadioGroupState } from './RadioGroup.types';
2
2
  export declare const useRadioGroupContextValue: (state: RadioGroupState) => RadioGroupState;
3
- //# sourceMappingURL=useRadioGroupContextValue.d.ts.map
3
+ //# sourceMappingURL=useRadioGroupContextValue.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export const useRadioGroupContextValue = (state) => {
2
- return { ...state };
2
+ return { ...state };
3
3
  };
4
- //# sourceMappingURL=useRadioGroupContextValue.js.map
4
+ //# sourceMappingURL=useRadioGroupContextValue.js.map
package/lib/index.d.ts CHANGED
@@ -1,12 +1,5 @@
1
1
  export { RadioGroup as RadioGroupV1 } from './RadioGroup/RadioGroup';
2
- export type {
3
- RadioGroupInfo,
4
- RadioGroupProps,
5
- RadioGroupSlotProps,
6
- RadioGroupState,
7
- RadioGroupTokens,
8
- RadioGroupType,
9
- } from './RadioGroup/RadioGroup.types';
2
+ export type { RadioGroupInfo, RadioGroupProps, RadioGroupSlotProps, RadioGroupState, RadioGroupTokens, RadioGroupType, } from './RadioGroup/RadioGroup.types';
10
3
  export { radioGroupName as radioGroupNameV1 } from './RadioGroup/RadioGroup.types';
11
4
  export type { RadioGroupContextValue } from './RadioGroup/radioGroupContext';
12
5
  export { RadioGroupContext as RadioGroupContextV1, RadioGroupProvider, useRadioGroupContext } from './RadioGroup/radioGroupContext';
@@ -18,22 +11,8 @@ export { radioName } from './Radio/Radio.types';
18
11
  export { useRadio } from './Radio/useRadio';
19
12
  export { RadioButton } from './legacy/RadioButton';
20
13
  export { radioButtonName } from './legacy/RadioButton.types';
21
- export type {
22
- IRadioButtonProps,
23
- IRadioButtonRenderData,
24
- IRadioButtonSlotProps,
25
- IRadioButtonTokens,
26
- IRadioButtonType,
27
- } from './legacy/RadioButton.types';
14
+ export type { IRadioButtonProps, IRadioButtonRenderData, IRadioButtonSlotProps, IRadioButtonTokens, IRadioButtonType, } from './legacy/RadioButton.types';
28
15
  export { RadioGroup, RadioGroupContext } from './legacy/RadioGroup';
29
16
  export { radioGroupName } from './legacy/RadioGroup.types';
30
- export type {
31
- IRadioGroupContext,
32
- IRadioGroupProps,
33
- IRadioGroupRenderData,
34
- IRadioGroupSlotProps,
35
- IRadioGroupState,
36
- IRadioGroupTokens,
37
- IRadioGroupType,
38
- } from './legacy/RadioGroup.types';
39
- //# sourceMappingURL=index.d.ts.map
17
+ export type { IRadioGroupContext, IRadioGroupProps, IRadioGroupRenderData, IRadioGroupSlotProps, IRadioGroupState, IRadioGroupTokens, IRadioGroupType, } from './legacy/RadioGroup.types';
18
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -10,4 +10,4 @@ export { RadioButton } from './legacy/RadioButton';
10
10
  export { radioButtonName } from './legacy/RadioButton.types';
11
11
  export { RadioGroup, RadioGroupContext } from './legacy/RadioGroup';
12
12
  export { radioGroupName } from './legacy/RadioGroup.types';
13
- //# sourceMappingURL=index.js.map
13
+ //# sourceMappingURL=index.js.map
@@ -6,12 +6,12 @@
6
6
  import type { HostComponent, ViewProps } from 'react-native';
7
7
  import type { BubblingEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
8
8
  export interface NativeProps extends ViewProps {
9
- content?: string;
10
- disabled?: boolean;
11
- buttonKey?: string;
12
- selected?: boolean;
13
- onPress?: BubblingEventHandler<null>;
9
+ content?: string;
10
+ disabled?: boolean;
11
+ buttonKey?: string;
12
+ selected?: boolean;
13
+ onPress?: BubblingEventHandler<null>;
14
14
  }
15
15
  declare const _default: HostComponent<NativeProps>;
16
16
  export default _default;
17
- //# sourceMappingURL=MacOSRadioButtonNativeComponent.d.ts.map
17
+ //# sourceMappingURL=MacOSRadioButtonNativeComponent.d.ts.map
@@ -5,4 +5,4 @@
5
5
  */
6
6
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
7
  export default codegenNativeComponent('FRNRadioButtonView');
8
- //# sourceMappingURL=MacOSRadioButtonNativeComponent.js.map
8
+ //# sourceMappingURL=MacOSRadioButtonNativeComponent.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.d.ts.map
4
+ //# sourceMappingURL=RadioButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioButton.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,qBAAqB,EAA0B,MAAM,qBAAqB,CAAC;AAI9H,eAAO,MAAM,WAAW,6KAqHtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioButton.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,qBAAqB,EAA0B,MAAM,qBAAqB,CAAC;AAI9H,eAAO,MAAM,WAAW,6KAuHtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -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 } from 'react-native';
6
6
  import { filterViewProps } from '@fluentui-react-native/adapters';
@@ -13,102 +13,88 @@ import { settings, radioButtonSelectActionLabel } from './RadioButton.settings';
13
13
  import { radioButtonName } from './RadioButton.types';
14
14
  import { RadioGroupContext } from './RadioGroup';
15
15
  export const RadioButton = compose({
16
- displayName: radioButtonName,
17
- usePrepareProps: (userProps, useStyling) => {
18
- const defaultComponentRef = React.useRef(null);
19
- const {
20
- content,
21
- buttonKey,
22
- disabled,
23
- accessibilityLabel,
24
- ariaLabel,
25
- componentRef = defaultComponentRef,
26
- accessibilityPosInSet,
27
- ariaPosInSet,
28
- accessibilitySetSize,
29
- ariaSetSize,
30
- ...rest
31
- } = userProps;
32
- // Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
33
- const info = React.useContext(RadioGroupContext);
34
- const buttonRef = useViewCommandFocus(componentRef);
35
- /* We don't want to call the user's onChange multiple times on the same selection. */
36
- const changeSelection = () => {
37
- if (buttonKey != info.selectedKey) {
38
- info.onChange && info.onChange(buttonKey);
39
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
40
- }
41
- };
42
- /* We use the componentRef of the currently selected button to maintain the default tabbable
16
+ displayName: radioButtonName,
17
+ usePrepareProps: (userProps, useStyling) => {
18
+ const defaultComponentRef = React.useRef(null);
19
+ const { content, buttonKey, disabled, accessibilityLabel, ariaLabel, componentRef = defaultComponentRef, accessibilityPosInSet, ariaPosInSet, accessibilitySetSize, ariaSetSize, ...rest } = userProps;
20
+ // Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
21
+ const info = React.useContext(RadioGroupContext);
22
+ const { selectedKey, onChange, updateSelectedButtonRef, buttonKeys } = info;
23
+ const buttonRef = useViewCommandFocus(componentRef);
24
+ /* We don't want to call the user's onChange multiple times on the same selection. */
25
+ const changeSelection = React.useCallback(() => {
26
+ if (buttonKey != selectedKey) {
27
+ onChange && onChange(buttonKey);
28
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
29
+ }
30
+ }, [buttonKey, componentRef, onChange, selectedKey, updateSelectedButtonRef]);
31
+ /* We use the componentRef of the currently selected button to maintain the default tabbable
43
32
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
44
33
  we must update it once here. */
45
- React.useEffect(() => {
46
- if (buttonKey == info.selectedKey) {
47
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
48
- }
49
- }, []);
50
- // Ensure focus is placed on button after click
51
- const changeSelectionWithFocus = useOnPressWithFocus(componentRef, changeSelection);
52
- /* RadioButton changes selection when focus is moved between each RadioButton and on a click */
53
- const pressable = useAsPressable({
54
- ...rest,
55
- onPress: changeSelectionWithFocus,
56
- onFocus: changeSelection,
57
- });
58
- // Used when creating accessibility properties in mergeSettings below
59
- const onAccessibilityAction = React.useCallback(
60
- (event) => {
61
- switch (event.nativeEvent.actionName) {
62
- case 'Select':
63
- changeSelection();
64
- break;
65
- }
66
- },
67
- [info, buttonKey],
68
- );
69
- const state = {
70
- ...pressable.state,
71
- selected: info.selectedKey === userProps.buttonKey,
72
- disabled: disabled || false,
73
- };
74
- // Grab the styling information from the userProps, referencing the state as well as the props.
75
- const styleProps = useStyling(userProps, (override) => state[override] || userProps[override]);
76
- const slotProps = mergeSettings(styleProps, {
77
- root: {
78
- ...rest,
79
- ref: buttonRef,
80
- ...pressable.props,
81
- accessibilityRole: 'radio',
82
- accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
83
- accessibilityState: { disabled: state.disabled, selected: state.selected },
84
- accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
85
- accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
86
- accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
87
- focusable: !state.disabled,
88
- onAccessibilityAction: onAccessibilityAction,
89
- },
90
- content: { children: content },
91
- });
92
- return { slotProps };
93
- },
94
- render: (Slots, _renderData, ...children) => {
95
- return _jsxs(Slots.root, {
96
- children: [_jsx(Slots.button, { children: _jsx(Slots.innerCircle, {}) }), _jsx(Slots.content, {}), children],
97
- });
98
- },
99
- settings,
100
- slots: {
101
- root: View,
102
- button: { slotType: View, filter: filterViewProps },
103
- innerCircle: { slotType: View, filter: filterViewProps },
104
- content: Text,
105
- },
106
- styles: {
107
- root: [],
108
- button: [borderTokens],
109
- innerCircle: [backgroundColorTokens],
110
- content: [foregroundColorTokens, textTokens, [{ source: 'textBorderColor', lookup: getPaletteFromTheme, target: 'borderColor' }]],
111
- },
34
+ React.useEffect(() => {
35
+ if (buttonKey == selectedKey) {
36
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
37
+ }
38
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
39
+ }, []);
40
+ // Ensure focus is placed on button after click
41
+ const changeSelectionWithFocus = useOnPressWithFocus(componentRef, changeSelection);
42
+ /* RadioButton changes selection when focus is moved between each RadioButton and on a click */
43
+ const pressable = useAsPressable({
44
+ ...rest,
45
+ onPress: changeSelectionWithFocus,
46
+ onFocus: changeSelection,
47
+ });
48
+ // Used when creating accessibility properties in mergeSettings below
49
+ const onAccessibilityAction = React.useCallback((event) => {
50
+ switch (event.nativeEvent.actionName) {
51
+ case 'Select':
52
+ changeSelection();
53
+ break;
54
+ }
55
+ }, [changeSelection]);
56
+ const state = {
57
+ ...pressable.state,
58
+ selected: selectedKey === userProps.buttonKey,
59
+ disabled: disabled || false,
60
+ };
61
+ // Grab the styling information from the userProps, referencing the state as well as the props.
62
+ const styleProps = useStyling(userProps, (override) => state[override] || userProps[override]);
63
+ const slotProps = mergeSettings(styleProps, {
64
+ root: {
65
+ ...rest,
66
+ ref: buttonRef,
67
+ ...pressable.props,
68
+ accessibilityRole: 'radio',
69
+ accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
70
+ accessibilityState: { disabled: state.disabled, selected: state.selected },
71
+ accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
72
+ accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? buttonKeys.findIndex((x) => x == buttonKey) + 1,
73
+ accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? buttonKeys.length,
74
+ focusable: !state.disabled,
75
+ onAccessibilityAction: onAccessibilityAction,
76
+ },
77
+ content: { children: content },
78
+ });
79
+ return { slotProps };
80
+ },
81
+ render: (Slots, _renderData, ...children) => {
82
+ return (_jsxs(Slots.root, { children: [
83
+ _jsx(Slots.button, { children: _jsx(Slots.innerCircle, {}) }), _jsx(Slots.content, {}), children] }));
84
+ },
85
+ settings,
86
+ slots: {
87
+ root: View,
88
+ button: { slotType: View, filter: filterViewProps },
89
+ innerCircle: { slotType: View, filter: filterViewProps },
90
+ content: Text,
91
+ },
92
+ styles: {
93
+ root: [],
94
+ button: [borderTokens],
95
+ innerCircle: [backgroundColorTokens],
96
+ content: [foregroundColorTokens, textTokens, [{ source: 'textBorderColor', lookup: getPaletteFromTheme, target: 'borderColor' }]],
97
+ },
112
98
  });
113
99
  export default RadioButton;
114
- //# sourceMappingURL=RadioButton.js.map
100
+ //# sourceMappingURL=RadioButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.js","sourceRoot":"","sources":["../../src/legacy/RadioButton.tsx"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,YAAY,CAAC;;AACb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AACpH,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAG5I,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,CAAC,MAAM,WA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ACR,EACf,KAAC,KAAK,CAAC,OAAO,KAAG,EAChB,QAAQ,IACE,CACd,CAAC;IAAA,CACH;IAED,QAAQ;IACR,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;QACnD,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;QACxD,OAAO,EAAE,IAAI;KACd;IACD,MAAM,EAAE;QACN,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC,YAAY,CAAC;QACtB,WAAW,EAAE,CAAC,qBAAqB,CAAC;QACpC,OAAO,EAAE,CAAC,qBAAqB,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;KAClI;CACF,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -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.macos.d.ts.map
4
+ //# sourceMappingURL=RadioButton.macos.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.macos.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioButton.macos.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAoB,MAAM,qBAAqB,CAAC;AAItG,eAAO,MAAM,WAAW,6KAqDtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"RadioButton.macos.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioButton.macos.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAoB,MAAM,qBAAqB,CAAC;AAItG,eAAO,MAAM,WAAW,6KAuDtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from '@fluentui-react-native/framework-base/jsx-runtime';
1
+ import { jsx as _jsx } from "@fluentui-react-native/framework-base/jsx-runtime";
2
2
  /**
3
3
  * Copyright (c) Microsoft Corporation.
4
4
  * Licensed under the MIT License.
@@ -12,54 +12,56 @@ import NativeRadioButtonView from './MacOSRadioButtonNativeComponent';
12
12
  import { radioButtonName } from './RadioButton.types';
13
13
  import { RadioGroupContext } from './RadioGroup';
14
14
  export const RadioButton = compose({
15
- displayName: radioButtonName,
16
- usePrepareProps: (userProps, useStyling) => {
17
- const defaultComponentRef = React.useRef(null);
18
- const { content, buttonKey, disabled, componentRef = defaultComponentRef } = userProps;
19
- const info = React.useContext(RadioGroupContext);
20
- // Reroute the native component's onPress event to RadioGroup's onChange
21
- const onPressRerouted = () => {
22
- // Prevent calls to RadioGroup's onChange on the currently selected button
23
- if (buttonKey != info.selectedKey) {
24
- info.onChange && info.onChange(buttonKey);
25
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
26
- }
27
- };
28
- /* We use the componentRef of the currently selected button to maintain the default tabbable
15
+ displayName: radioButtonName,
16
+ usePrepareProps: (userProps, useStyling) => {
17
+ const defaultComponentRef = React.useRef(null);
18
+ const { content, buttonKey, disabled, componentRef = defaultComponentRef } = userProps;
19
+ const info = React.useContext(RadioGroupContext);
20
+ const { onChange, selectedKey, updateSelectedButtonRef } = info;
21
+ // Reroute the native component's onPress event to RadioGroup's onChange
22
+ const onPressRerouted = React.useCallback(() => {
23
+ // Prevent calls to RadioGroup's onChange on the currently selected button
24
+ if (buttonKey != selectedKey) {
25
+ onChange && onChange(buttonKey);
26
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
27
+ }
28
+ }, [buttonKey, componentRef, onChange, selectedKey, updateSelectedButtonRef]);
29
+ /* We use the componentRef of the currently selected button to maintain the default tabbable
29
30
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
30
31
  we must update it once here. */
31
- React.useEffect(() => {
32
- if (buttonKey === info.selectedKey) {
33
- info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
34
- }
35
- }, []);
36
- const styleProps = useStyling(userProps);
37
- const isSelected = info.selectedKey === buttonKey;
38
- const slotProps = mergeSettings(styleProps, {
39
- root: {
40
- ref: componentRef,
41
- buttonKey: buttonKey,
42
- content: content,
43
- disabled: disabled,
44
- onPress: onPressRerouted,
45
- selected: isSelected,
46
- style: {
47
- minWidth: '100%',
48
- minHeight: 20,
49
- },
50
- },
51
- });
52
- return { slotProps };
53
- },
54
- slots: {
55
- root: NativeRadioButtonView,
56
- },
57
- styles: {
58
- root: [],
59
- },
60
- render: (Slots) => {
61
- return _jsx(Slots.root, {});
62
- },
32
+ React.useEffect(() => {
33
+ if (buttonKey === selectedKey) {
34
+ updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
35
+ }
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
37
+ }, []);
38
+ const styleProps = useStyling(userProps);
39
+ const isSelected = selectedKey === buttonKey;
40
+ const slotProps = mergeSettings(styleProps, {
41
+ root: {
42
+ ref: componentRef,
43
+ buttonKey: buttonKey,
44
+ content: content,
45
+ disabled: disabled,
46
+ onPress: onPressRerouted,
47
+ selected: isSelected,
48
+ style: {
49
+ minWidth: '100%',
50
+ minHeight: 20,
51
+ },
52
+ },
53
+ });
54
+ return { slotProps };
55
+ },
56
+ slots: {
57
+ root: NativeRadioButtonView,
58
+ },
59
+ styles: {
60
+ root: [],
61
+ },
62
+ render: (Slots) => {
63
+ return _jsx(Slots.root, {});
64
+ },
63
65
  });
64
66
  export default RadioButton;
65
- //# sourceMappingURL=RadioButton.macos.js.map
67
+ //# sourceMappingURL=RadioButton.macos.js.map