@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.
- package/CHANGELOG.md +22 -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.js +70 -91
- package/lib/Radio/useRadio.win32.d.ts +1 -1
- package/lib/Radio/useRadio.win32.js +121 -143
- 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.js +80 -96
- package/lib/legacy/RadioButton.macos.d.ts +2 -8
- package/lib/legacy/RadioButton.macos.js +48 -48
- 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.js +132 -151
- package/lib/legacy/RadioGroup.d.ts +2 -8
- package/lib/legacy/RadioGroup.js +84 -108
- 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.js +105 -143
- package/lib-commonjs/Radio/useRadio.win32.d.ts +1 -1
- package/lib-commonjs/Radio/useRadio.win32.js +157 -196
- 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.js +121 -162
- package/lib-commonjs/legacy/RadioButton.macos.d.ts +2 -8
- package/lib-commonjs/legacy/RadioButton.macos.js +88 -107
- 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.js +173 -217
- package/lib-commonjs/legacy/RadioGroup.d.ts +2 -8
- package/lib-commonjs/legacy/RadioGroup.js +125 -168
- 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 +27 -26
- 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/RadioGroup/RadioGroupTokens.mobile.ts +1 -1
- 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
|
-
|
|
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,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,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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
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(
|
|
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
|
|
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
|
-
|
|
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
|
+
// 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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|