@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
@@ -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,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,86 @@ 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 buttonRef = useViewCommandFocus(componentRef);
23
+ /* We don't want to call the user's onChange multiple times on the same selection. */
24
+ const changeSelection = () => {
25
+ if (buttonKey != info.selectedKey) {
26
+ info.onChange && info.onChange(buttonKey);
27
+ info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
28
+ }
29
+ };
30
+ /* We use the componentRef of the currently selected button to maintain the default tabbable
43
31
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
44
32
  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
- },
33
+ React.useEffect(() => {
34
+ if (buttonKey == info.selectedKey) {
35
+ info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
36
+ }
37
+ }, []);
38
+ // Ensure focus is placed on button after click
39
+ const changeSelectionWithFocus = useOnPressWithFocus(componentRef, changeSelection);
40
+ /* RadioButton changes selection when focus is moved between each RadioButton and on a click */
41
+ const pressable = useAsPressable({
42
+ ...rest,
43
+ onPress: changeSelectionWithFocus,
44
+ onFocus: changeSelection,
45
+ });
46
+ // Used when creating accessibility properties in mergeSettings below
47
+ const onAccessibilityAction = React.useCallback((event) => {
48
+ switch (event.nativeEvent.actionName) {
49
+ case 'Select':
50
+ changeSelection();
51
+ break;
52
+ }
53
+ }, [info, buttonKey]);
54
+ const state = {
55
+ ...pressable.state,
56
+ selected: info.selectedKey === userProps.buttonKey,
57
+ disabled: disabled || false,
58
+ };
59
+ // Grab the styling information from the userProps, referencing the state as well as the props.
60
+ const styleProps = useStyling(userProps, (override) => state[override] || userProps[override]);
61
+ const slotProps = mergeSettings(styleProps, {
62
+ root: {
63
+ ...rest,
64
+ ref: buttonRef,
65
+ ...pressable.props,
66
+ accessibilityRole: 'radio',
67
+ accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
68
+ accessibilityState: { disabled: state.disabled, selected: state.selected },
69
+ accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
70
+ accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
71
+ accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
72
+ focusable: !state.disabled,
73
+ onAccessibilityAction: onAccessibilityAction,
74
+ },
75
+ content: { children: content },
76
+ });
77
+ return { slotProps };
78
+ },
79
+ render: (Slots, _renderData, ...children) => {
80
+ return (_jsxs(Slots.root, { children: [
81
+ _jsx(Slots.button, { children: _jsx(Slots.innerCircle, {}) }), _jsx(Slots.content, {}), children] }));
82
+ },
83
+ settings,
84
+ slots: {
85
+ root: View,
86
+ button: { slotType: View, filter: filterViewProps },
87
+ innerCircle: { slotType: View, filter: filterViewProps },
88
+ content: Text,
89
+ },
90
+ styles: {
91
+ root: [],
92
+ button: [borderTokens],
93
+ innerCircle: [backgroundColorTokens],
94
+ content: [foregroundColorTokens, textTokens, [{ source: 'textBorderColor', lookup: getPaletteFromTheme, target: 'borderColor' }]],
95
+ },
112
96
  });
113
97
  export default RadioButton;
114
- //# sourceMappingURL=RadioButton.js.map
98
+ //# sourceMappingURL=RadioButton.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.macos.d.ts.map
4
+ //# sourceMappingURL=RadioButton.macos.d.ts.map
@@ -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,54 @@ 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
+ // 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
29
29
  element in a RadioGroup. Since the componentRef isn't generated until after initial render,
30
30
  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
- },
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
+ },
63
63
  });
64
64
  export default RadioButton;
65
- //# sourceMappingURL=RadioButton.macos.js.map
65
+ //# sourceMappingURL=RadioButton.macos.js.map
@@ -1,5 +1,5 @@
1
1
  import type { IComposeSettings } from '@uifabricshared/foundation-compose';
2
2
  import type { IRadioButtonType } from './RadioButton.types';
3
- export declare const radioButtonSelectActionLabel = 'Select a RadioButton';
3
+ export declare const radioButtonSelectActionLabel = "Select a RadioButton";
4
4
  export declare const settings: IComposeSettings<IRadioButtonType>;
5
- //# sourceMappingURL=RadioButton.settings.d.ts.map
5
+ //# sourceMappingURL=RadioButton.settings.d.ts.map