@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
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
value,
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
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
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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(
|
|
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,
|
|
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
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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,OA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,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(
|
|
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,
|
|
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
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|