@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.
- package/CHANGELOG.md +60 -0
- package/lib/Radio/Radio.d.ts +2 -7
- package/lib/Radio/Radio.ios.d.ts +2 -7
- package/lib/Radio/Radio.ios.js +31 -50
- package/lib/Radio/Radio.js +31 -46
- package/lib/Radio/Radio.styling.d.ts +1 -1
- package/lib/Radio/Radio.styling.js +88 -109
- package/lib/Radio/Radio.types.d.ts +170 -176
- package/lib/Radio/Radio.types.js +1 -1
- package/lib/Radio/RadioTokens.android.d.ts +1 -1
- package/lib/Radio/RadioTokens.android.js +42 -42
- package/lib/Radio/RadioTokens.android.js.map +1 -1
- package/lib/Radio/RadioTokens.d.ts +1 -1
- package/lib/Radio/RadioTokens.ios.d.ts +1 -1
- package/lib/Radio/RadioTokens.ios.js +39 -39
- package/lib/Radio/RadioTokens.ios.js.map +1 -1
- package/lib/Radio/RadioTokens.js +76 -76
- package/lib/Radio/RadioTokens.js.map +1 -1
- package/lib/Radio/RadioTokens.win32.d.ts +1 -1
- package/lib/Radio/RadioTokens.win32.js +89 -89
- package/lib/Radio/RadioTokens.win32.js.map +1 -1
- package/lib/Radio/__tests__/RadioExperimental.test.d.ts +1 -1
- package/lib/Radio/__tests__/RadioExperimental.test.js +14 -14
- package/lib/Radio/useRadio.d.ts +1 -1
- package/lib/Radio/useRadio.d.ts.map +1 -1
- package/lib/Radio/useRadio.js +72 -91
- package/lib/Radio/useRadio.js.map +1 -1
- package/lib/Radio/useRadio.win32.d.ts +1 -1
- package/lib/Radio/useRadio.win32.d.ts.map +1 -1
- package/lib/Radio/useRadio.win32.js +126 -143
- package/lib/Radio/useRadio.win32.js.map +1 -1
- package/lib/RadioGroup/RadioGroup.d.ts +2 -7
- package/lib/RadioGroup/RadioGroup.js +34 -48
- package/lib/RadioGroup/RadioGroup.styling.d.ts +1 -1
- package/lib/RadioGroup/RadioGroup.styling.js +42 -51
- package/lib/RadioGroup/RadioGroup.types.d.ts +117 -117
- package/lib/RadioGroup/RadioGroup.types.js +1 -1
- package/lib/RadioGroup/RadioGroupTokens.android.d.ts +1 -1
- package/lib/RadioGroup/RadioGroupTokens.android.js +1 -1
- package/lib/RadioGroup/RadioGroupTokens.d.ts +1 -1
- package/lib/RadioGroup/RadioGroupTokens.ios.d.ts +1 -1
- package/lib/RadioGroup/RadioGroupTokens.ios.js +1 -1
- package/lib/RadioGroup/RadioGroupTokens.js +12 -12
- package/lib/RadioGroup/RadioGroupTokens.js.map +1 -1
- package/lib/RadioGroup/RadioGroupTokens.mobile.d.ts +1 -1
- package/lib/RadioGroup/RadioGroupTokens.mobile.js +13 -13
- package/lib/RadioGroup/RadioGroupTokens.mobile.js.map +1 -1
- package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts +1 -1
- package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.js +56 -98
- package/lib/RadioGroup/radioGroupContext.d.ts +1 -1
- package/lib/RadioGroup/radioGroupContext.js +15 -19
- package/lib/RadioGroup/useRadioGroup.d.ts +1 -1
- package/lib/RadioGroup/useRadioGroup.js +63 -93
- package/lib/RadioGroup/useRadioGroupContextValue.d.ts +1 -1
- package/lib/RadioGroup/useRadioGroupContextValue.js +2 -2
- package/lib/index.d.ts +4 -25
- package/lib/index.js +1 -1
- package/lib/legacy/MacOSRadioButtonNativeComponent.d.ts +6 -6
- package/lib/legacy/MacOSRadioButtonNativeComponent.js +1 -1
- package/lib/legacy/RadioButton.d.ts +2 -8
- package/lib/legacy/RadioButton.d.ts.map +1 -1
- package/lib/legacy/RadioButton.js +82 -96
- package/lib/legacy/RadioButton.js.map +1 -1
- package/lib/legacy/RadioButton.macos.d.ts +2 -8
- package/lib/legacy/RadioButton.macos.d.ts.map +1 -1
- package/lib/legacy/RadioButton.macos.js +50 -48
- package/lib/legacy/RadioButton.macos.js.map +1 -1
- package/lib/legacy/RadioButton.settings.d.ts +2 -2
- package/lib/legacy/RadioButton.settings.js +81 -81
- package/lib/legacy/RadioButton.types.d.ts +45 -45
- package/lib/legacy/RadioButton.types.js +1 -1
- package/lib/legacy/RadioButton.win32.d.ts +2 -8
- package/lib/legacy/RadioButton.win32.d.ts.map +1 -1
- package/lib/legacy/RadioButton.win32.js +136 -151
- package/lib/legacy/RadioButton.win32.js.map +1 -1
- package/lib/legacy/RadioGroup.d.ts +2 -8
- package/lib/legacy/RadioGroup.d.ts.map +1 -1
- package/lib/legacy/RadioGroup.js +80 -108
- package/lib/legacy/RadioGroup.js.map +1 -1
- package/lib/legacy/RadioGroup.settings.d.ts +1 -1
- package/lib/legacy/RadioGroup.settings.js +21 -21
- package/lib/legacy/RadioGroup.types.d.ts +79 -78
- package/lib/legacy/RadioGroup.types.js +1 -1
- package/lib/legacy/__tests__/RadioButton.test.d.ts +1 -1
- package/lib/legacy/__tests__/RadioButton.test.js +8 -8
- package/lib/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
- package/lib/legacy/__tests__/RadioButtonGroup.test.js +18 -34
- package/lib-commonjs/Radio/Radio.d.ts +2 -7
- package/lib-commonjs/Radio/Radio.ios.d.ts +2 -7
- package/lib-commonjs/Radio/Radio.ios.js +40 -64
- package/lib-commonjs/Radio/Radio.js +39 -59
- package/lib-commonjs/Radio/Radio.styling.d.ts +1 -1
- package/lib-commonjs/Radio/Radio.styling.js +94 -115
- package/lib-commonjs/Radio/Radio.types.d.ts +170 -176
- package/lib-commonjs/Radio/Radio.types.js +3 -3
- package/lib-commonjs/Radio/RadioTokens.android.d.ts +1 -1
- package/lib-commonjs/Radio/RadioTokens.android.js +45 -45
- package/lib-commonjs/Radio/RadioTokens.android.js.map +1 -1
- package/lib-commonjs/Radio/RadioTokens.d.ts +1 -1
- package/lib-commonjs/Radio/RadioTokens.ios.d.ts +1 -1
- package/lib-commonjs/Radio/RadioTokens.ios.js +42 -42
- package/lib-commonjs/Radio/RadioTokens.ios.js.map +1 -1
- package/lib-commonjs/Radio/RadioTokens.js +79 -79
- package/lib-commonjs/Radio/RadioTokens.js.map +1 -1
- package/lib-commonjs/Radio/RadioTokens.win32.d.ts +1 -1
- package/lib-commonjs/Radio/RadioTokens.win32.js +92 -92
- package/lib-commonjs/Radio/RadioTokens.win32.js.map +1 -1
- package/lib-commonjs/Radio/__tests__/RadioExperimental.test.d.ts +1 -1
- package/lib-commonjs/Radio/__tests__/RadioExperimental.test.js +48 -65
- package/lib-commonjs/Radio/useRadio.d.ts +1 -1
- package/lib-commonjs/Radio/useRadio.d.ts.map +1 -1
- package/lib-commonjs/Radio/useRadio.js +107 -143
- package/lib-commonjs/Radio/useRadio.js.map +1 -1
- package/lib-commonjs/Radio/useRadio.win32.d.ts +1 -1
- package/lib-commonjs/Radio/useRadio.win32.d.ts.map +1 -1
- package/lib-commonjs/Radio/useRadio.win32.js +162 -196
- package/lib-commonjs/Radio/useRadio.win32.js.map +1 -1
- package/lib-commonjs/RadioGroup/RadioGroup.d.ts +2 -7
- package/lib-commonjs/RadioGroup/RadioGroup.js +45 -65
- package/lib-commonjs/RadioGroup/RadioGroup.styling.d.ts +1 -1
- package/lib-commonjs/RadioGroup/RadioGroup.styling.js +48 -57
- package/lib-commonjs/RadioGroup/RadioGroup.types.d.ts +117 -117
- package/lib-commonjs/RadioGroup/RadioGroup.types.js +3 -3
- package/lib-commonjs/RadioGroup/RadioGroupTokens.android.d.ts +1 -1
- package/lib-commonjs/RadioGroup/RadioGroupTokens.android.js +5 -10
- package/lib-commonjs/RadioGroup/RadioGroupTokens.d.ts +1 -1
- package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.d.ts +1 -1
- package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.js +5 -10
- package/lib-commonjs/RadioGroup/RadioGroupTokens.js +15 -15
- package/lib-commonjs/RadioGroup/RadioGroupTokens.js.map +1 -1
- package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.d.ts +1 -1
- package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js +16 -16
- package/lib-commonjs/RadioGroup/RadioGroupTokens.mobile.js.map +1 -1
- package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.d.ts +1 -1
- package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.js +91 -153
- package/lib-commonjs/RadioGroup/radioGroupContext.d.ts +1 -1
- package/lib-commonjs/RadioGroup/radioGroupContext.js +47 -68
- package/lib-commonjs/RadioGroup/useRadioGroup.d.ts +1 -1
- package/lib-commonjs/RadioGroup/useRadioGroup.js +97 -144
- package/lib-commonjs/RadioGroup/useRadioGroupContextValue.d.ts +1 -1
- package/lib-commonjs/RadioGroup/useRadioGroupContextValue.js +4 -4
- package/lib-commonjs/index.d.ts +4 -25
- package/lib-commonjs/index.js +32 -128
- package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.d.ts +6 -6
- package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.js +7 -9
- package/lib-commonjs/legacy/RadioButton.d.ts +2 -8
- package/lib-commonjs/legacy/RadioButton.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.js +123 -162
- package/lib-commonjs/legacy/RadioButton.js.map +1 -1
- package/lib-commonjs/legacy/RadioButton.macos.d.ts +2 -8
- package/lib-commonjs/legacy/RadioButton.macos.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.macos.js +90 -107
- package/lib-commonjs/legacy/RadioButton.macos.js.map +1 -1
- package/lib-commonjs/legacy/RadioButton.settings.d.ts +2 -2
- package/lib-commonjs/legacy/RadioButton.settings.js +84 -84
- package/lib-commonjs/legacy/RadioButton.types.d.ts +45 -45
- package/lib-commonjs/legacy/RadioButton.types.js +3 -3
- package/lib-commonjs/legacy/RadioButton.win32.d.ts +2 -8
- package/lib-commonjs/legacy/RadioButton.win32.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.win32.js +177 -217
- package/lib-commonjs/legacy/RadioButton.win32.js.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.d.ts +2 -8
- package/lib-commonjs/legacy/RadioGroup.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.js +121 -168
- package/lib-commonjs/legacy/RadioGroup.js.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.settings.d.ts +1 -1
- package/lib-commonjs/legacy/RadioGroup.settings.js +24 -24
- package/lib-commonjs/legacy/RadioGroup.types.d.ts +79 -78
- package/lib-commonjs/legacy/RadioGroup.types.js +3 -3
- package/lib-commonjs/legacy/__tests__/RadioButton.test.d.ts +1 -1
- package/lib-commonjs/legacy/__tests__/RadioButton.test.js +42 -59
- package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
- package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.js +53 -96
- package/package.json +35 -34
- package/src/Radio/RadioTokens.android.ts +1 -1
- package/src/Radio/RadioTokens.ios.ts +1 -1
- package/src/Radio/RadioTokens.ts +1 -1
- package/src/Radio/RadioTokens.win32.ts +1 -1
- package/src/Radio/useRadio.ts +13 -11
- package/src/Radio/useRadio.win32.ts +45 -26
- package/src/RadioGroup/RadioGroupTokens.mobile.ts +1 -1
- package/src/RadioGroup/RadioGroupTokens.ts +1 -1
- package/src/legacy/RadioButton.macos.tsx +10 -8
- package/src/legacy/RadioButton.tsx +13 -11
- package/src/legacy/RadioButton.win32.tsx +46 -30
- package/src/legacy/RadioGroup.tsx +4 -8
- package/eslint.config.js +0 -3
|
@@ -6,155 +6,138 @@ import { useRadioGroupContext } from '../RadioGroup/radioGroupContext';
|
|
|
6
6
|
const defaultAccessibilityActions = [{ name: 'Select' }];
|
|
7
7
|
var DirectionalArrowKeys;
|
|
8
8
|
(function (DirectionalArrowKeys) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
DirectionalArrowKeys["ArrowUp"] = "ArrowUp";
|
|
10
|
+
DirectionalArrowKeys["ArrowDown"] = "ArrowDown";
|
|
11
|
+
DirectionalArrowKeys["ArrowRight"] = "ArrowRight";
|
|
12
|
+
DirectionalArrowKeys["ArrowLeft"] = "ArrowLeft";
|
|
13
13
|
})(DirectionalArrowKeys || (DirectionalArrowKeys = {}));
|
|
14
14
|
export const useRadio = (props) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
label,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} = props;
|
|
32
|
-
const labelPosition = radioGroupContext.layout === 'horizontal-stacked' ? 'below' : 'after';
|
|
33
|
-
const isDisabled = radioGroupContext.disabled || disabled;
|
|
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 = React.useCallback(() => {
|
|
37
|
-
if (value !== radioGroupContext.value) {
|
|
38
|
-
radioGroupContext.onChange && radioGroupContext.onChange(value);
|
|
39
|
-
radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
|
|
40
|
-
}
|
|
41
|
-
}, [radioGroupContext, value, componentRef]);
|
|
42
|
-
/* We use the componentRef of the currently selected button to maintain the default tabbable
|
|
15
|
+
const defaultComponentRef = React.useRef(null);
|
|
16
|
+
// Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
|
|
17
|
+
const radioGroupContext = useRadioGroupContext();
|
|
18
|
+
const { addRadioEnabledValue, addRadioValue, disabled: groupDisabled, enabledValues, invoked, layout, onChange, removeRadioEnabledValue, removeRadioValue, updateInvoked, updateSelectedButtonRef, value: selectedValue, values, } = radioGroupContext;
|
|
19
|
+
const { label, subtext, value, disabled, accessibilityActions, accessibilityLabel, accessibilityHint, accessibilityState, componentRef = defaultComponentRef, accessibilityPosInSet, accessibilitySetSize, ...rest } = props;
|
|
20
|
+
const labelPosition = layout === 'horizontal-stacked' ? 'below' : 'after';
|
|
21
|
+
const isDisabled = groupDisabled || disabled;
|
|
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 = React.useCallback(() => {
|
|
25
|
+
if (value !== selectedValue) {
|
|
26
|
+
onChange && onChange(value);
|
|
27
|
+
updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
|
|
28
|
+
}
|
|
29
|
+
}, [componentRef, onChange, selectedValue, updateSelectedButtonRef, value]);
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}, []);
|
|
50
|
-
// Explicitly only run on mount and unmount
|
|
51
|
-
React.useEffect(() => {
|
|
52
|
-
radioGroupContext.addRadioValue(value);
|
|
53
|
-
return () => {
|
|
54
|
-
radioGroupContext.removeRadioValue(value);
|
|
55
|
-
};
|
|
56
|
-
}, []);
|
|
57
|
-
React.useEffect(() => {
|
|
58
|
-
if (isDisabled) {
|
|
59
|
-
radioGroupContext.removeRadioEnabledValue(value);
|
|
60
|
-
} else {
|
|
61
|
-
radioGroupContext.addRadioEnabledValue(value);
|
|
62
|
-
}
|
|
63
|
-
}, [isDisabled]);
|
|
64
|
-
const isRTL = I18nManager.isRTL;
|
|
65
|
-
const onInvoke = React.useCallback(
|
|
66
|
-
(e) => {
|
|
67
|
-
if (e.nativeEvent.key in DirectionalArrowKeys) {
|
|
68
|
-
const length = radioGroupContext.enabledValues.length;
|
|
69
|
-
const previous =
|
|
70
|
-
e.nativeEvent.key === DirectionalArrowKeys.ArrowUp ||
|
|
71
|
-
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowRight : e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft);
|
|
72
|
-
const next =
|
|
73
|
-
e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
|
|
74
|
-
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
|
|
75
|
-
const currRadioIndex = radioGroupContext.enabledValues.indexOf(radioGroupContext.value);
|
|
76
|
-
let newCurrRadioIndex;
|
|
77
|
-
if (next) {
|
|
78
|
-
newCurrRadioIndex = (currRadioIndex + 1) % length;
|
|
79
|
-
radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
|
|
80
|
-
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
|
|
81
|
-
} else if (previous) {
|
|
82
|
-
newCurrRadioIndex = (currRadioIndex - 1 + length) % length;
|
|
83
|
-
radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
|
|
84
|
-
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
if (value === selectedValue && !isDisabled) {
|
|
35
|
+
updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
|
|
85
36
|
}
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
37
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
|
|
38
|
+
}, []);
|
|
39
|
+
// Explicitly only run on mount and unmount
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
addRadioValue(value);
|
|
42
|
+
return () => {
|
|
43
|
+
removeRadioValue(value);
|
|
44
|
+
};
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally run only on mount/unmount
|
|
46
|
+
}, []);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
if (isDisabled) {
|
|
49
|
+
removeRadioEnabledValue(value);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
addRadioEnabledValue(value);
|
|
53
|
+
}
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- only re-run when isDisabled changes
|
|
55
|
+
}, [isDisabled]);
|
|
56
|
+
const isRTL = I18nManager.isRTL;
|
|
57
|
+
const onInvoke = React.useCallback((e) => {
|
|
58
|
+
if (e.nativeEvent.key in DirectionalArrowKeys) {
|
|
59
|
+
const length = enabledValues.length;
|
|
60
|
+
const previous = e.nativeEvent.key === DirectionalArrowKeys.ArrowUp ||
|
|
61
|
+
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowRight : e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft);
|
|
62
|
+
const next = e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
|
|
63
|
+
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
|
|
64
|
+
const currRadioIndex = enabledValues.indexOf(selectedValue);
|
|
65
|
+
let newCurrRadioIndex;
|
|
66
|
+
if (next) {
|
|
67
|
+
newCurrRadioIndex = (currRadioIndex + 1) % length;
|
|
68
|
+
onChange && onChange(enabledValues[newCurrRadioIndex]);
|
|
69
|
+
updateInvoked && updateInvoked(true);
|
|
70
|
+
}
|
|
71
|
+
else if (previous) {
|
|
72
|
+
newCurrRadioIndex = (currRadioIndex - 1 + length) % length;
|
|
73
|
+
onChange && onChange(enabledValues[newCurrRadioIndex]);
|
|
74
|
+
updateInvoked && updateInvoked(true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, [enabledValues, isRTL, onChange, selectedValue, updateInvoked]);
|
|
78
|
+
// Sets the updated selected button ref and focus if this Radio is selected via arrow key.
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
if (invoked && value === selectedValue && !isDisabled) {
|
|
81
|
+
updateSelectedButtonRef && componentRef && updateSelectedButtonRef(componentRef);
|
|
82
|
+
componentRef?.current?.focus();
|
|
83
|
+
updateInvoked && updateInvoked(false);
|
|
84
|
+
}
|
|
85
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- only re-run when invoked changes
|
|
86
|
+
}, [invoked]);
|
|
87
|
+
const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
88
|
+
// Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
|
|
89
|
+
const onKeyDownProps = useKeyDownProps(onInvoke, ...keys);
|
|
90
|
+
// Ensure focus is placed on button after click
|
|
91
|
+
const changeSelectionWithFocus = useOnPressWithFocus(componentRef, changeSelection);
|
|
92
|
+
/* Radio changes selection when focus is moved between each RadioButton and on a click */
|
|
93
|
+
const pressable = usePressableState({
|
|
94
|
+
...rest,
|
|
95
|
+
onPress: changeSelectionWithFocus,
|
|
96
|
+
onFocus: changeSelection,
|
|
97
|
+
});
|
|
98
|
+
const accessibilityActionsProp = React.useMemo(() => (accessibilityActions ? [...defaultAccessibilityActions, ...accessibilityActions] : defaultAccessibilityActions), [accessibilityActions]);
|
|
99
|
+
// Used when creating accessibility properties in mergeSettings below
|
|
100
|
+
const onAccessibilityAction = React.useCallback((event) => {
|
|
101
|
+
switch (event.nativeEvent.actionName) {
|
|
102
|
+
case 'Select':
|
|
103
|
+
changeSelection();
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}, [changeSelection]);
|
|
107
|
+
const state = {
|
|
108
|
+
...pressable.state,
|
|
109
|
+
selected: selectedValue === props.value && !isDisabled,
|
|
110
|
+
disabled: isDisabled || false,
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
props: {
|
|
114
|
+
value,
|
|
115
|
+
label,
|
|
116
|
+
subtext,
|
|
117
|
+
labelPosition,
|
|
118
|
+
...rest,
|
|
119
|
+
ref: buttonRef,
|
|
120
|
+
...pressable.props,
|
|
121
|
+
accessibilityRole: 'radio',
|
|
122
|
+
accessibilityLabel: accessibilityLabel ?? label,
|
|
123
|
+
accessibilityHint: accessibilityHint ?? subtext,
|
|
124
|
+
accessibilityState: getAccessibilityState(state.disabled, state.selected, accessibilityState),
|
|
125
|
+
accessibilityActions: accessibilityActionsProp,
|
|
126
|
+
accessibilityPosInSet: accessibilityPosInSet ?? values.findIndex((x) => x == value) + 1,
|
|
127
|
+
accessibilitySetSize: accessibilitySetSize ?? values.length,
|
|
128
|
+
focusable: !state.disabled,
|
|
129
|
+
disabled: isDisabled,
|
|
130
|
+
onAccessibilityAction: onAccessibilityAction,
|
|
131
|
+
...onKeyDownProps,
|
|
132
|
+
},
|
|
133
|
+
state: state,
|
|
134
|
+
};
|
|
152
135
|
};
|
|
153
136
|
const getAccessibilityState = memoize(getAccessibilityStateWorker);
|
|
154
137
|
function getAccessibilityStateWorker(disabled, selected, accessibilityState) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
138
|
+
if (accessibilityState) {
|
|
139
|
+
return { disabled, selected, ...accessibilityState };
|
|
140
|
+
}
|
|
141
|
+
return { disabled, selected };
|
|
159
142
|
}
|
|
160
|
-
//# sourceMappingURL=useRadio.win32.js.map
|
|
143
|
+
//# sourceMappingURL=useRadio.win32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRadio.win32.js","sourceRoot":"","sources":["../../src/Radio/useRadio.win32.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAGxI,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,MAAM,2BAA2B,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEzD,IAAK,oBAKJ;AALD,WAAK,oBAAoB;IACvB,2CAAmB,CAAA;IACnB,+CAAuB,CAAA;IACvB,iDAAyB,CAAA;IACzB,+CAAuB,CAAA;AAAC,CAC1B,EALK,oBAAoB,KAApB,oBAAoB,QAKxB;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAiB,EAAa,EAAE,CAAC;IACxD,MAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE/C,2GAA2G;IAC3G,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"useRadio.win32.js","sourceRoot":"","sources":["../../src/Radio/useRadio.win32.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,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ACvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAAA,CAC/B"}
|
|
@@ -8,10 +8,5 @@ import type { RadioGroupProps, RadioGroupState } from './RadioGroup.types';
|
|
|
8
8
|
* @returns Whether the styles that are assigned to the layer should be applied to the radiogroup
|
|
9
9
|
*/
|
|
10
10
|
export declare const radioGroupLookup: (layer: string, state: RadioGroupState, userProps: RadioGroupProps) => boolean;
|
|
11
|
-
export declare const RadioGroup: import(
|
|
12
|
-
|
|
13
|
-
import('./RadioGroup.types').RadioGroupSlotProps,
|
|
14
|
-
import('./RadioGroup.types').RadioGroupTokens,
|
|
15
|
-
import('@fluentui-react-native/framework-base').ObjectBase
|
|
16
|
-
>;
|
|
17
|
-
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
11
|
+
export declare const RadioGroup: import("@fluentui-react-native/framework").ComposableComponent<RadioGroupProps, import("./RadioGroup.types").RadioGroupSlotProps, import("./RadioGroup.types").RadioGroupTokens, import("@fluentui-react-native/framework-base").ObjectBase>;
|
|
12
|
+
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui-react-native/framework-base/jsx-runtime";
|
|
2
2
|
import { Platform, View } from 'react-native';
|
|
3
3
|
import { FocusZone } from '@fluentui-react-native/focus-zone';
|
|
4
4
|
import { compose, mergeProps } from '@fluentui-react-native/framework';
|
|
@@ -17,53 +17,39 @@ import { useRadioGroupContextValue } from './useRadioGroupContextValue';
|
|
|
17
17
|
* @returns Whether the styles that are assigned to the layer should be applied to the radiogroup
|
|
18
18
|
*/
|
|
19
19
|
export const radioGroupLookup = (layer, state, userProps) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(userProps['layout'] === 'horizontal' || userProps['layout'] === 'horizontal-stacked'))
|
|
26
|
-
);
|
|
20
|
+
return (state[layer] ||
|
|
21
|
+
userProps[layer] ||
|
|
22
|
+
(!(Platform.OS === 'win32' || Platform.OS === 'android') &&
|
|
23
|
+
layer === 'isHorizontal' &&
|
|
24
|
+
(userProps['layout'] === 'horizontal' || userProps['layout'] === 'horizontal-stacked')));
|
|
27
25
|
};
|
|
28
26
|
export const RadioGroup = compose({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
defaultTabbableElement: defaultTabbableElement,
|
|
57
|
-
children: radioGroupContent,
|
|
58
|
-
});
|
|
59
|
-
return _jsx(RadioGroupProvider, {
|
|
60
|
-
value: contextValue,
|
|
61
|
-
children: _jsxs(Slots.root, {
|
|
62
|
-
...mergedProps,
|
|
63
|
-
children: [label && labelComponent, isFocusZoneImplemented ? radioGroupContentWithFocusZone : radioGroupContent],
|
|
64
|
-
}),
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
},
|
|
27
|
+
displayName: radioGroupName,
|
|
28
|
+
...stylingSettings,
|
|
29
|
+
slots: {
|
|
30
|
+
root: View,
|
|
31
|
+
label: View,
|
|
32
|
+
labelText: Text,
|
|
33
|
+
required: Text,
|
|
34
|
+
options: View,
|
|
35
|
+
container: FocusZone,
|
|
36
|
+
},
|
|
37
|
+
useRender: (userProps, useSlots) => {
|
|
38
|
+
const radioGroup = useRadioGroup(userProps);
|
|
39
|
+
const contextValue = useRadioGroupContextValue(radioGroup.state);
|
|
40
|
+
const Slots = useSlots(userProps, (layer) => radioGroupLookup(layer, radioGroup.state, userProps));
|
|
41
|
+
return (final, ...children) => {
|
|
42
|
+
if (!radioGroup.state) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const { label, required, defaultTabbableElement, isCircularNavigation, ...mergedProps } = mergeProps(radioGroup.props, final);
|
|
46
|
+
const labelComponent = (_jsxs(Slots.label, { children: [
|
|
47
|
+
_jsx(Slots.labelText, { children: label }, "label"), !!required && _jsx(Slots.required, { children: '*' })] }));
|
|
48
|
+
const isFocusZoneImplemented = ['macos', 'win32'].includes(Platform.OS);
|
|
49
|
+
const radioGroupContent = _jsx(Slots.options, { children: children });
|
|
50
|
+
const radioGroupContentWithFocusZone = (_jsx(Slots.container, { disabled: radioGroup.state.selectedButtonDisabled, isCircularNavigation: true, defaultTabbableElement: defaultTabbableElement, children: radioGroupContent }));
|
|
51
|
+
return (_jsx(RadioGroupProvider, { value: contextValue, children: _jsxs(Slots.root, { ...mergedProps, children: [label && labelComponent, isFocusZoneImplemented ? radioGroupContentWithFocusZone : radioGroupContent] }) }));
|
|
52
|
+
};
|
|
53
|
+
},
|
|
68
54
|
});
|
|
69
|
-
//# sourceMappingURL=RadioGroup.js.map
|
|
55
|
+
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -2,4 +2,4 @@ import type { UseStylingOptions } from '@fluentui-react-native/framework';
|
|
|
2
2
|
import type { RadioGroupTokens, RadioGroupSlotProps, RadioGroupProps } from './RadioGroup.types';
|
|
3
3
|
export declare const radioGroupStates: (keyof RadioGroupTokens)[];
|
|
4
4
|
export declare const stylingSettings: UseStylingOptions<RadioGroupProps, RadioGroupSlotProps, RadioGroupTokens>;
|
|
5
|
-
//# sourceMappingURL=RadioGroup.styling.d.ts.map
|
|
5
|
+
//# sourceMappingURL=RadioGroup.styling.d.ts.map
|
|
@@ -4,55 +4,46 @@ import { radioGroupName } from './RadioGroup.types';
|
|
|
4
4
|
import { defaultRadioGroupTokens } from './RadioGroupTokens';
|
|
5
5
|
export const radioGroupStates = ['isHorizontal', 'disabled'];
|
|
6
6
|
export const stylingSettings = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
display: 'flex',
|
|
49
|
-
justifyContent: 'space-around',
|
|
50
|
-
alignItems: 'flex-start',
|
|
51
|
-
flexDirection: tokens.flexDirection,
|
|
52
|
-
},
|
|
53
|
-
}),
|
|
54
|
-
['flexDirection'],
|
|
55
|
-
),
|
|
56
|
-
},
|
|
7
|
+
tokens: [defaultRadioGroupTokens, radioGroupName],
|
|
8
|
+
states: radioGroupStates,
|
|
9
|
+
slotProps: {
|
|
10
|
+
root: buildProps(() => ({
|
|
11
|
+
style: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'flex-start',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
},
|
|
16
|
+
})),
|
|
17
|
+
label: buildProps(() => ({
|
|
18
|
+
style: {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
alignSelf: 'flex-start',
|
|
23
|
+
},
|
|
24
|
+
})),
|
|
25
|
+
labelText: buildProps((tokens, theme) => ({
|
|
26
|
+
variant: tokens.variant,
|
|
27
|
+
style: {
|
|
28
|
+
color: tokens.color,
|
|
29
|
+
...fontStyles.from(tokens, theme),
|
|
30
|
+
},
|
|
31
|
+
}), ['color', ...fontStyles.keys]),
|
|
32
|
+
required: buildProps((tokens) => ({
|
|
33
|
+
variant: tokens.variant,
|
|
34
|
+
style: {
|
|
35
|
+
color: tokens.requiredColor,
|
|
36
|
+
paddingStart: tokens.requiredPadding,
|
|
37
|
+
},
|
|
38
|
+
}), ['requiredColor', 'requiredPadding']),
|
|
39
|
+
options: buildProps((tokens) => ({
|
|
40
|
+
style: {
|
|
41
|
+
display: 'flex',
|
|
42
|
+
justifyContent: 'space-around',
|
|
43
|
+
alignItems: 'flex-start',
|
|
44
|
+
flexDirection: tokens.flexDirection,
|
|
45
|
+
},
|
|
46
|
+
}), ['flexDirection']),
|
|
47
|
+
},
|
|
57
48
|
};
|
|
58
|
-
//# sourceMappingURL=RadioGroup.styling.js.map
|
|
49
|
+
//# sourceMappingURL=RadioGroup.styling.js.map
|