@fluentui-react-native/radio-group 0.20.6 → 0.20.8
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.json +73 -1
- package/CHANGELOG.md +25 -2
- package/lib/legacy/RadioButton.win32.d.ts +4 -0
- package/lib/legacy/RadioButton.win32.d.ts.map +1 -0
- package/lib/legacy/RadioButton.win32.js +143 -0
- package/lib/legacy/RadioButton.win32.js.map +1 -0
- package/lib/legacy/RadioGroup.d.ts.map +1 -1
- package/lib/legacy/RadioGroup.js +30 -12
- package/lib/legacy/RadioGroup.js.map +1 -1
- package/lib/legacy/RadioGroup.types.d.ts +26 -0
- package/lib/legacy/RadioGroup.types.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.win32.d.ts +4 -0
- package/lib-commonjs/legacy/RadioButton.win32.d.ts.map +1 -0
- package/lib-commonjs/legacy/RadioButton.win32.js +145 -0
- package/lib-commonjs/legacy/RadioButton.win32.js.map +1 -0
- package/lib-commonjs/legacy/RadioGroup.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.js +30 -12
- package/lib-commonjs/legacy/RadioGroup.js.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.types.d.ts +26 -0
- package/lib-commonjs/legacy/RadioGroup.types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/legacy/RadioButton.win32.tsx +208 -0
- package/src/legacy/RadioGroup.tsx +53 -13
- package/src/legacy/RadioGroup.types.ts +31 -0
- package/src/legacy/__tests__/__snapshots__/RadioButtonGroup.test.tsx.snap +4 -4
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,79 @@
|
|
|
2
2
|
"name": "@fluentui-react-native/radio-group",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 10 Jan 2024 19:27:37 GMT",
|
|
6
|
+
"version": "0.20.8",
|
|
7
|
+
"tag": "@fluentui-react-native/radio-group_v0.20.8",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "gulnazsayed@microsoft.com",
|
|
12
|
+
"package": "@fluentui-react-native/radio-group",
|
|
13
|
+
"commit": "41920c7cbc84771e6e25429856a635d24fabd4ea",
|
|
14
|
+
"comment": "manually setting focus after selection to fix narrator bug"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Thu, 04 Jan 2024 21:06:26 GMT",
|
|
21
|
+
"version": "0.20.7",
|
|
22
|
+
"tag": "@fluentui-react-native/radio-group_v0.20.7",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "beachball",
|
|
27
|
+
"package": "@fluentui-react-native/radio-group",
|
|
28
|
+
"comment": "Bump @fluentui-react-native/focus-zone to v0.16.6",
|
|
29
|
+
"commit": "not available"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "@fluentui-react-native/radio-group",
|
|
34
|
+
"comment": "Bump @fluentui-react-native/framework to v0.13.5",
|
|
35
|
+
"commit": "not available"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@fluentui-react-native/radio-group",
|
|
40
|
+
"comment": "Bump @fluentui-react-native/interactive-hooks to v0.25.6",
|
|
41
|
+
"commit": "not available"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"author": "beachball",
|
|
45
|
+
"package": "@fluentui-react-native/radio-group",
|
|
46
|
+
"comment": "Bump @fluentui-react-native/pressable to v0.11.6",
|
|
47
|
+
"commit": "not available"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"author": "beachball",
|
|
51
|
+
"package": "@fluentui-react-native/radio-group",
|
|
52
|
+
"comment": "Bump @fluentui-react-native/text to v0.22.6",
|
|
53
|
+
"commit": "not available"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"author": "beachball",
|
|
57
|
+
"package": "@fluentui-react-native/radio-group",
|
|
58
|
+
"comment": "Bump @fluentui-react-native/theme-tokens to v0.26.5",
|
|
59
|
+
"commit": "not available"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"author": "beachball",
|
|
63
|
+
"package": "@fluentui-react-native/radio-group",
|
|
64
|
+
"comment": "Bump @fluentui-react-native/tokens to v0.22.5",
|
|
65
|
+
"commit": "not available"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"author": "beachball",
|
|
69
|
+
"package": "@fluentui-react-native/radio-group",
|
|
70
|
+
"comment": "Bump @uifabricshared/foundation-compose to v1.14.19",
|
|
71
|
+
"commit": "not available"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"date": "Thu, 04 Jan 2024 01:35:42 GMT",
|
|
6
78
|
"version": "0.20.6",
|
|
7
79
|
"tag": "@fluentui-react-native/radio-group_v0.20.6",
|
|
8
80
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
# Change Log - @fluentui-react-native/radio-group
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 10 Jan 2024 19:27:37 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.20.8
|
|
8
|
+
|
|
9
|
+
Wed, 10 Jan 2024 19:27:37 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- manually setting focus after selection to fix narrator bug (gulnazsayed@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 0.20.7
|
|
16
|
+
|
|
17
|
+
Thu, 04 Jan 2024 21:06:26 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Bump @fluentui-react-native/focus-zone to v0.16.6
|
|
22
|
+
- Bump @fluentui-react-native/framework to v0.13.5
|
|
23
|
+
- Bump @fluentui-react-native/interactive-hooks to v0.25.6
|
|
24
|
+
- Bump @fluentui-react-native/pressable to v0.11.6
|
|
25
|
+
- Bump @fluentui-react-native/text to v0.22.6
|
|
26
|
+
- Bump @fluentui-react-native/theme-tokens to v0.26.5
|
|
27
|
+
- Bump @fluentui-react-native/tokens to v0.22.5
|
|
28
|
+
- Bump @uifabricshared/foundation-compose to v1.14.19
|
|
29
|
+
|
|
7
30
|
## 0.20.6
|
|
8
31
|
|
|
9
|
-
Thu, 04 Jan 2024 01:
|
|
32
|
+
Thu, 04 Jan 2024 01:35:42 GMT
|
|
10
33
|
|
|
11
34
|
### Patches
|
|
12
35
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IRadioButtonProps, IRadioButtonSlotProps } from './RadioButton.types';
|
|
2
|
+
export declare const RadioButton: import("@uifabricshared/foundation-compose").IComposeReturnType<IRadioButtonProps, IRadioButtonSlotProps, import("./RadioButton.types").IRadioButtonTokens, object, object>;
|
|
3
|
+
export default RadioButton;
|
|
4
|
+
//# sourceMappingURL=RadioButton.win32.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.win32.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioButton.win32.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,qBAAqB,EAA0B,MAAM,qBAAqB,CAAC;AAW9H,eAAO,MAAM,WAAW,6KAgLtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
/** @jsx withSlots */
|
|
3
|
+
'use strict';
|
|
4
|
+
import { __assign, __rest, __spreadArray } from "tslib";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { View, I18nManager } from 'react-native';
|
|
7
|
+
import { filterViewProps } from '@fluentui-react-native/adapters';
|
|
8
|
+
import { useAsPressable, useViewCommandFocus, useKeyDownProps } from '@fluentui-react-native/interactive-hooks';
|
|
9
|
+
import { Text } from '@fluentui-react-native/text';
|
|
10
|
+
import { foregroundColorTokens, textTokens, borderTokens, backgroundColorTokens, getPaletteFromTheme } from '@fluentui-react-native/tokens';
|
|
11
|
+
import { withSlots } from '@uifabricshared/foundation-composable';
|
|
12
|
+
import { compose } from '@uifabricshared/foundation-compose';
|
|
13
|
+
import { mergeSettings } from '@uifabricshared/foundation-settings';
|
|
14
|
+
import { settings, radioButtonSelectActionLabel } from './RadioButton.settings';
|
|
15
|
+
import { radioButtonName } from './RadioButton.types';
|
|
16
|
+
import { RadioGroupContext } from './RadioGroup';
|
|
17
|
+
var DirectionalArrowKeys;
|
|
18
|
+
(function (DirectionalArrowKeys) {
|
|
19
|
+
DirectionalArrowKeys["ArrowUp"] = "ArrowUp";
|
|
20
|
+
DirectionalArrowKeys["ArrowDown"] = "ArrowDown";
|
|
21
|
+
DirectionalArrowKeys["ArrowRight"] = "ArrowRight";
|
|
22
|
+
DirectionalArrowKeys["ArrowLeft"] = "ArrowLeft";
|
|
23
|
+
})(DirectionalArrowKeys || (DirectionalArrowKeys = {}));
|
|
24
|
+
export var RadioButton = compose({
|
|
25
|
+
displayName: radioButtonName,
|
|
26
|
+
usePrepareProps: function (userProps, useStyling) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
var defaultComponentRef = React.useRef(null);
|
|
29
|
+
var content = userProps.content, buttonKey = userProps.buttonKey, disabled = userProps.disabled, accessibilityLabel = userProps.accessibilityLabel, ariaLabel = userProps.ariaLabel, _d = userProps.componentRef, componentRef = _d === void 0 ? defaultComponentRef : _d, accessibilityPositionInSet = userProps.accessibilityPositionInSet, ariaPosInSet = userProps.ariaPosInSet, accessibilitySetSize = userProps.accessibilitySetSize, ariaSetSize = userProps.ariaSetSize, rest = __rest(userProps, ["content", "buttonKey", "disabled", "accessibilityLabel", "ariaLabel", "componentRef", "accessibilityPositionInSet", "ariaPosInSet", "accessibilitySetSize", "ariaSetSize"]);
|
|
30
|
+
// Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
|
|
31
|
+
var info = React.useContext(RadioGroupContext);
|
|
32
|
+
var buttonRef = useViewCommandFocus(componentRef);
|
|
33
|
+
/* We don't want to call the user's onChange multiple times on the same selection. */
|
|
34
|
+
var changeSelection = function () {
|
|
35
|
+
if (buttonKey != info.selectedKey) {
|
|
36
|
+
info.onChange && info.onChange(buttonKey);
|
|
37
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/* We use the componentRef of the currently selected button to maintain the default tabbable
|
|
41
|
+
element in a RadioGroup. Since the componentRef isn't generated until after initial render,
|
|
42
|
+
we must update it once here. */
|
|
43
|
+
React.useEffect(function () {
|
|
44
|
+
if (buttonKey == info.selectedKey) {
|
|
45
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
// Explicitly only run on mount and unmount
|
|
49
|
+
React.useEffect(function () {
|
|
50
|
+
info.addRadioButtonKey(buttonKey);
|
|
51
|
+
if (!disabled) {
|
|
52
|
+
info.addRadioButtonEnabledKey(buttonKey);
|
|
53
|
+
}
|
|
54
|
+
return function () {
|
|
55
|
+
info.removeRadioButtonKey(buttonKey);
|
|
56
|
+
info.removeRadioButtonEnabledKey(buttonKey);
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
var isRTL = I18nManager.isRTL;
|
|
60
|
+
var onInvoke = React.useCallback(function (e) {
|
|
61
|
+
if (e.nativeEvent.key in DirectionalArrowKeys) {
|
|
62
|
+
var length_1 = info.enabledButtonKeys.length;
|
|
63
|
+
var next = e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
|
|
64
|
+
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
|
|
65
|
+
var currRadioButtonIndex = info.enabledButtonKeys.indexOf(info.selectedKey);
|
|
66
|
+
var newCurrRadioButtonIndex = void 0;
|
|
67
|
+
if (next) {
|
|
68
|
+
newCurrRadioButtonIndex = (currRadioButtonIndex + 1) % length_1;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// previous
|
|
72
|
+
newCurrRadioButtonIndex = (currRadioButtonIndex - 1 + length_1) % length_1;
|
|
73
|
+
}
|
|
74
|
+
info.onChange && info.onChange(info.enabledButtonKeys[newCurrRadioButtonIndex]);
|
|
75
|
+
info.updateInvoked && info.updateInvoked(true);
|
|
76
|
+
}
|
|
77
|
+
}, [info]);
|
|
78
|
+
// Sets the updated selected button ref and focus if this Radio is selected via arrow key.
|
|
79
|
+
React.useEffect(function () {
|
|
80
|
+
var _a;
|
|
81
|
+
if (info.invoked && buttonKey === info.selectedKey && !disabled) {
|
|
82
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
83
|
+
(_a = componentRef === null || componentRef === void 0 ? void 0 : componentRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
84
|
+
info.updateInvoked && info.updateInvoked(false);
|
|
85
|
+
}
|
|
86
|
+
}, [info.invoked]);
|
|
87
|
+
var keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
88
|
+
// Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
|
|
89
|
+
var onKeyDownProps = useKeyDownProps.apply(void 0, __spreadArray([onInvoke], keys, false));
|
|
90
|
+
// Ensure focus is placed on button after click
|
|
91
|
+
var changeSelectionWithFocus = function () {
|
|
92
|
+
if (buttonKey != info.selectedKey) {
|
|
93
|
+
info.onChange && info.onChange(buttonKey);
|
|
94
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
95
|
+
info.updateInvoked && info.updateInvoked(true);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/* RadioButton changes selection when focus is moved between each RadioButton and on a click */
|
|
99
|
+
var pressable = useAsPressable(__assign(__assign({}, rest), { onPress: changeSelectionWithFocus, onFocus: changeSelection }));
|
|
100
|
+
// Used when creating accessibility properties in mergeSettings below
|
|
101
|
+
var onAccessibilityAction = React.useCallback(function (event) {
|
|
102
|
+
switch (event.nativeEvent.actionName) {
|
|
103
|
+
case 'Select':
|
|
104
|
+
changeSelection();
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}, [info, buttonKey]);
|
|
108
|
+
var state = __assign(__assign({}, pressable.state), { selected: info.selectedKey === userProps.buttonKey && !disabled, disabled: disabled || false });
|
|
109
|
+
// Grab the styling information from the userProps, referencing the state as well as the props.
|
|
110
|
+
var styleProps = useStyling(userProps, function (override) { return state[override] || userProps[override]; });
|
|
111
|
+
var slotProps = mergeSettings(styleProps, {
|
|
112
|
+
root: __assign(__assign(__assign(__assign(__assign({}, rest), { ref: buttonRef }), pressable.props), { accessibilityRole: 'radio', accessibilityLabel: (_a = accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : ariaLabel) !== null && _a !== void 0 ? _a : content, accessibilityState: { disabled: state.disabled, selected: state.selected }, accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }], accessibilityPositionInSet: (_b = accessibilityPositionInSet !== null && accessibilityPositionInSet !== void 0 ? accessibilityPositionInSet : ariaPosInSet) !== null && _b !== void 0 ? _b : info.buttonKeys.findIndex(function (x) { return x == buttonKey; }) + 1, accessibilitySetSize: (_c = accessibilitySetSize !== null && accessibilitySetSize !== void 0 ? accessibilitySetSize : ariaSetSize) !== null && _c !== void 0 ? _c : info.buttonKeys.length, focusable: !state.disabled, onAccessibilityAction: onAccessibilityAction }), onKeyDownProps),
|
|
113
|
+
content: { children: content },
|
|
114
|
+
});
|
|
115
|
+
return { slotProps: slotProps };
|
|
116
|
+
},
|
|
117
|
+
render: function (Slots, _renderData) {
|
|
118
|
+
var children = [];
|
|
119
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
120
|
+
children[_i - 2] = arguments[_i];
|
|
121
|
+
}
|
|
122
|
+
return (withSlots(Slots.root, null,
|
|
123
|
+
withSlots(Slots.button, null,
|
|
124
|
+
withSlots(Slots.innerCircle, null)),
|
|
125
|
+
withSlots(Slots.content, null),
|
|
126
|
+
children));
|
|
127
|
+
},
|
|
128
|
+
settings: settings,
|
|
129
|
+
slots: {
|
|
130
|
+
root: View,
|
|
131
|
+
button: { slotType: View, filter: filterViewProps },
|
|
132
|
+
innerCircle: { slotType: View, filter: filterViewProps },
|
|
133
|
+
content: Text,
|
|
134
|
+
},
|
|
135
|
+
styles: {
|
|
136
|
+
root: [],
|
|
137
|
+
button: [borderTokens],
|
|
138
|
+
innerCircle: [backgroundColorTokens],
|
|
139
|
+
content: [foregroundColorTokens, textTokens, [{ source: 'textBorderColor', lookup: getPaletteFromTheme, target: 'borderColor' }]],
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
export default RadioButton;
|
|
143
|
+
//# sourceMappingURL=RadioButton.win32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.win32.js","sourceRoot":"","sources":["../../src/legacy/RadioButton.win32.tsx"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,qBAAqB;AACrB,YAAY,CAAC;;AACb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChH,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,YAAY,EAAE,qBA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IAED,QAAQ,UAAA;IACR,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;QACnD,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;QACxD,OAAO,EAAE,IAAI;KACd;IACD,MAAM,EAAE;QACN,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC,YAAY,CAAC;QACtB,WAAW,EAAE,CAAC,qBAAqB,CAAC;QACpC,OAAO,EAAE,CAAC,qBAAqB,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;KAClI;CACF,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioGroup.tsx"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,qBAAqB;AACrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EAEpB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,iBAAiB,mCAS5B,CAAC;AAEH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioGroup.tsx"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,qBAAqB;AACrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EAEpB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,iBAAiB,mCAS5B,CAAC;AAEH,eAAO,MAAM,UAAU,mLAuHrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
package/lib/legacy/RadioGroup.js
CHANGED
|
@@ -33,11 +33,41 @@ export var RadioGroup = compose({
|
|
|
33
33
|
var onSelectButtonRef = React.useCallback(function (ref) {
|
|
34
34
|
setSelectedButtonRef(ref);
|
|
35
35
|
}, [setSelectedButtonRef]);
|
|
36
|
+
var _c = React.useState(false), invoked = _c[0], setInvoked = _c[1];
|
|
37
|
+
var onInvoked = React.useCallback(function (check) {
|
|
38
|
+
setInvoked(check);
|
|
39
|
+
}, [setInvoked]);
|
|
40
|
+
var _d = React.useState([]), buttonKeys = _d[0], setButtonKeys = _d[1];
|
|
41
|
+
var onAddRadioButtonKey = React.useCallback(function (buttonKey) {
|
|
42
|
+
buttonKeys.push(buttonKey);
|
|
43
|
+
setButtonKeys(buttonKeys);
|
|
44
|
+
}, [setButtonKeys]);
|
|
45
|
+
var onRemoveRadioButtonKey = React.useCallback(function (buttonKey) {
|
|
46
|
+
buttonKeys.filter(function (item) { return item !== buttonKey; });
|
|
47
|
+
setButtonKeys(buttonKeys);
|
|
48
|
+
}, [setButtonKeys]);
|
|
49
|
+
var _e = React.useState([]), enabledButtonKeys = _e[0], setEnabledButtonKeys = _e[1];
|
|
50
|
+
var onAddRadioButtonEnabledKey = React.useCallback(function (buttonKey) {
|
|
51
|
+
enabledButtonKeys.push(buttonKey);
|
|
52
|
+
setEnabledButtonKeys(enabledButtonKeys);
|
|
53
|
+
}, [setEnabledButtonKeys]);
|
|
54
|
+
var onRemoveRadioButtonEnabledKey = React.useCallback(function (buttonKey) {
|
|
55
|
+
enabledButtonKeys.filter(function (item) { return item !== buttonKey; });
|
|
56
|
+
setEnabledButtonKeys(enabledButtonKeys);
|
|
57
|
+
}, [setEnabledButtonKeys]);
|
|
36
58
|
var state = {
|
|
37
59
|
context: {
|
|
38
60
|
selectedKey: selectedKey !== null && selectedKey !== void 0 ? selectedKey : data.selectedKey,
|
|
39
61
|
onChange: data.onKeySelect,
|
|
40
62
|
updateSelectedButtonRef: onSelectButtonRef,
|
|
63
|
+
invoked: invoked,
|
|
64
|
+
updateInvoked: onInvoked,
|
|
65
|
+
buttonKeys: buttonKeys,
|
|
66
|
+
enabledButtonKeys: enabledButtonKeys,
|
|
67
|
+
addRadioButtonKey: onAddRadioButtonKey,
|
|
68
|
+
removeRadioButtonKey: onRemoveRadioButtonKey,
|
|
69
|
+
addRadioButtonEnabledKey: onAddRadioButtonEnabledKey,
|
|
70
|
+
removeRadioButtonEnabledKey: onRemoveRadioButtonEnabledKey,
|
|
41
71
|
},
|
|
42
72
|
};
|
|
43
73
|
var styleProps = useStyling(userProps, function (override) { return state[override] || userProps[override]; });
|
|
@@ -56,18 +86,6 @@ export var RadioGroup = compose({
|
|
|
56
86
|
if (renderData.state == undefined) {
|
|
57
87
|
return null;
|
|
58
88
|
}
|
|
59
|
-
// Populate the buttonKeys array
|
|
60
|
-
if (children) {
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
62
|
-
// @ts-ignore - TODO, fix typing error
|
|
63
|
-
renderData.state.context.buttonKeys = React.Children.map(children, function (child) {
|
|
64
|
-
if (React.isValidElement(child)) {
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
66
|
-
// @ts-ignore - TODO, fix typing error
|
|
67
|
-
return child.props.buttonKey;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
89
|
return (withSlots(RadioGroupContext.Provider
|
|
72
90
|
// Passes in the selected key and a hook function to update the newly selected button and call the client's onChange callback
|
|
73
91
|
, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../src/legacy/RadioGroup.tsx"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B,qBAAqB;AACrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,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,CACc,CAC9B,CAAC;IACJ,CAAC;IAED,QAAQ,UAAA;IACR,KAAK,EAAE;QACL,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,SAAS;KACrB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,CAAC,qBAAqB,EAAE,UAAU,CAAC;QAC1C,SAAS,EAAE,EAAE;KACd;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -22,6 +22,32 @@ export interface IRadioGroupContext {
|
|
|
22
22
|
* Array of radio button keys in the group
|
|
23
23
|
*/
|
|
24
24
|
buttonKeys?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Populate the buttonKeys array (all RadioButton keys) at mount and un-mount
|
|
27
|
+
*/
|
|
28
|
+
addRadioButtonKey?: (value: string) => void;
|
|
29
|
+
removeRadioButtonKey?: (value: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Array of enabled Radio keys in the RadioGroup
|
|
32
|
+
* @platform win32
|
|
33
|
+
*/
|
|
34
|
+
enabledButtonKeys?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Populate the enabledButtonKeys array (only enabled/valid RadioButton keys) at mount and un-mount
|
|
37
|
+
* @platform win32
|
|
38
|
+
*/
|
|
39
|
+
addRadioButtonEnabledKey?: (value: string) => void;
|
|
40
|
+
removeRadioButtonEnabledKey?: (value: string) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Updates invoked to signal that arrow key has been pressed and focus needs to be set
|
|
43
|
+
* @platform win32
|
|
44
|
+
*/
|
|
45
|
+
updateInvoked?: (check: boolean) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Signals whether arrow key has been pressed
|
|
48
|
+
* @platform win32
|
|
49
|
+
*/
|
|
50
|
+
invoked?: boolean;
|
|
25
51
|
}
|
|
26
52
|
export interface IRadioGroupState {
|
|
27
53
|
context: IRadioGroupContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.types.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioGroup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEzE,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjC;;OAEG;IACH,uBAAuB,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IAE9D;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"RadioGroup.types.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioGroup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,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AErB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB,EAAE,UAAU;CAAG;AAEhF,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAC1C,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;AAExF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,oBAAoB,CAAC;IAChC,KAAK,EAAE,gBAAgB,CAAC;CACzB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IRadioButtonProps, IRadioButtonSlotProps } from './RadioButton.types';
|
|
2
|
+
export declare const RadioButton: import("@uifabricshared/foundation-compose").IComposeReturnType<IRadioButtonProps, IRadioButtonSlotProps, import("./RadioButton.types").IRadioButtonTokens, object, object>;
|
|
3
|
+
export default RadioButton;
|
|
4
|
+
//# sourceMappingURL=RadioButton.win32.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.win32.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioButton.win32.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,qBAAqB,EAA0B,MAAM,qBAAqB,CAAC;AAW9H,eAAO,MAAM,WAAW,6KAgLtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
/** @jsx withSlots */
|
|
3
|
+
'use strict';
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.RadioButton = void 0;
|
|
6
|
+
var tslib_1 = require("tslib");
|
|
7
|
+
var React = tslib_1.__importStar(require("react"));
|
|
8
|
+
var react_native_1 = require("react-native");
|
|
9
|
+
var adapters_1 = require("@fluentui-react-native/adapters");
|
|
10
|
+
var interactive_hooks_1 = require("@fluentui-react-native/interactive-hooks");
|
|
11
|
+
var text_1 = require("@fluentui-react-native/text");
|
|
12
|
+
var tokens_1 = require("@fluentui-react-native/tokens");
|
|
13
|
+
var foundation_composable_1 = require("@uifabricshared/foundation-composable");
|
|
14
|
+
var foundation_compose_1 = require("@uifabricshared/foundation-compose");
|
|
15
|
+
var foundation_settings_1 = require("@uifabricshared/foundation-settings");
|
|
16
|
+
var RadioButton_settings_1 = require("./RadioButton.settings");
|
|
17
|
+
var RadioButton_types_1 = require("./RadioButton.types");
|
|
18
|
+
var RadioGroup_1 = require("./RadioGroup");
|
|
19
|
+
var DirectionalArrowKeys;
|
|
20
|
+
(function (DirectionalArrowKeys) {
|
|
21
|
+
DirectionalArrowKeys["ArrowUp"] = "ArrowUp";
|
|
22
|
+
DirectionalArrowKeys["ArrowDown"] = "ArrowDown";
|
|
23
|
+
DirectionalArrowKeys["ArrowRight"] = "ArrowRight";
|
|
24
|
+
DirectionalArrowKeys["ArrowLeft"] = "ArrowLeft";
|
|
25
|
+
})(DirectionalArrowKeys || (DirectionalArrowKeys = {}));
|
|
26
|
+
exports.RadioButton = (0, foundation_compose_1.compose)({
|
|
27
|
+
displayName: RadioButton_types_1.radioButtonName,
|
|
28
|
+
usePrepareProps: function (userProps, useStyling) {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
var defaultComponentRef = React.useRef(null);
|
|
31
|
+
var content = userProps.content, buttonKey = userProps.buttonKey, disabled = userProps.disabled, accessibilityLabel = userProps.accessibilityLabel, ariaLabel = userProps.ariaLabel, _d = userProps.componentRef, componentRef = _d === void 0 ? defaultComponentRef : _d, accessibilityPositionInSet = userProps.accessibilityPositionInSet, ariaPosInSet = userProps.ariaPosInSet, accessibilitySetSize = userProps.accessibilitySetSize, ariaSetSize = userProps.ariaSetSize, rest = tslib_1.__rest(userProps, ["content", "buttonKey", "disabled", "accessibilityLabel", "ariaLabel", "componentRef", "accessibilityPositionInSet", "ariaPosInSet", "accessibilitySetSize", "ariaSetSize"]);
|
|
32
|
+
// Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
|
|
33
|
+
var info = React.useContext(RadioGroup_1.RadioGroupContext);
|
|
34
|
+
var buttonRef = (0, interactive_hooks_1.useViewCommandFocus)(componentRef);
|
|
35
|
+
/* We don't want to call the user's onChange multiple times on the same selection. */
|
|
36
|
+
var changeSelection = function () {
|
|
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
|
|
43
|
+
element in a RadioGroup. Since the componentRef isn't generated until after initial render,
|
|
44
|
+
we must update it once here. */
|
|
45
|
+
React.useEffect(function () {
|
|
46
|
+
if (buttonKey == info.selectedKey) {
|
|
47
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
// Explicitly only run on mount and unmount
|
|
51
|
+
React.useEffect(function () {
|
|
52
|
+
info.addRadioButtonKey(buttonKey);
|
|
53
|
+
if (!disabled) {
|
|
54
|
+
info.addRadioButtonEnabledKey(buttonKey);
|
|
55
|
+
}
|
|
56
|
+
return function () {
|
|
57
|
+
info.removeRadioButtonKey(buttonKey);
|
|
58
|
+
info.removeRadioButtonEnabledKey(buttonKey);
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
var isRTL = react_native_1.I18nManager.isRTL;
|
|
62
|
+
var onInvoke = React.useCallback(function (e) {
|
|
63
|
+
if (e.nativeEvent.key in DirectionalArrowKeys) {
|
|
64
|
+
var length_1 = info.enabledButtonKeys.length;
|
|
65
|
+
var next = e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
|
|
66
|
+
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
|
|
67
|
+
var currRadioButtonIndex = info.enabledButtonKeys.indexOf(info.selectedKey);
|
|
68
|
+
var newCurrRadioButtonIndex = void 0;
|
|
69
|
+
if (next) {
|
|
70
|
+
newCurrRadioButtonIndex = (currRadioButtonIndex + 1) % length_1;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// previous
|
|
74
|
+
newCurrRadioButtonIndex = (currRadioButtonIndex - 1 + length_1) % length_1;
|
|
75
|
+
}
|
|
76
|
+
info.onChange && info.onChange(info.enabledButtonKeys[newCurrRadioButtonIndex]);
|
|
77
|
+
info.updateInvoked && info.updateInvoked(true);
|
|
78
|
+
}
|
|
79
|
+
}, [info]);
|
|
80
|
+
// Sets the updated selected button ref and focus if this Radio is selected via arrow key.
|
|
81
|
+
React.useEffect(function () {
|
|
82
|
+
var _a;
|
|
83
|
+
if (info.invoked && buttonKey === info.selectedKey && !disabled) {
|
|
84
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
85
|
+
(_a = componentRef === null || componentRef === void 0 ? void 0 : componentRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
86
|
+
info.updateInvoked && info.updateInvoked(false);
|
|
87
|
+
}
|
|
88
|
+
}, [info.invoked]);
|
|
89
|
+
var keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
90
|
+
// Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
|
|
91
|
+
var onKeyDownProps = interactive_hooks_1.useKeyDownProps.apply(void 0, tslib_1.__spreadArray([onInvoke], keys, false));
|
|
92
|
+
// Ensure focus is placed on button after click
|
|
93
|
+
var changeSelectionWithFocus = function () {
|
|
94
|
+
if (buttonKey != info.selectedKey) {
|
|
95
|
+
info.onChange && info.onChange(buttonKey);
|
|
96
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
97
|
+
info.updateInvoked && info.updateInvoked(true);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/* RadioButton changes selection when focus is moved between each RadioButton and on a click */
|
|
101
|
+
var pressable = (0, interactive_hooks_1.useAsPressable)(tslib_1.__assign(tslib_1.__assign({}, rest), { onPress: changeSelectionWithFocus, onFocus: changeSelection }));
|
|
102
|
+
// Used when creating accessibility properties in mergeSettings below
|
|
103
|
+
var onAccessibilityAction = React.useCallback(function (event) {
|
|
104
|
+
switch (event.nativeEvent.actionName) {
|
|
105
|
+
case 'Select':
|
|
106
|
+
changeSelection();
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}, [info, buttonKey]);
|
|
110
|
+
var state = tslib_1.__assign(tslib_1.__assign({}, pressable.state), { selected: info.selectedKey === userProps.buttonKey && !disabled, disabled: disabled || false });
|
|
111
|
+
// Grab the styling information from the userProps, referencing the state as well as the props.
|
|
112
|
+
var styleProps = useStyling(userProps, function (override) { return state[override] || userProps[override]; });
|
|
113
|
+
var slotProps = (0, foundation_settings_1.mergeSettings)(styleProps, {
|
|
114
|
+
root: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, rest), { ref: buttonRef }), pressable.props), { accessibilityRole: 'radio', accessibilityLabel: (_a = accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : ariaLabel) !== null && _a !== void 0 ? _a : content, accessibilityState: { disabled: state.disabled, selected: state.selected }, accessibilityActions: [{ name: 'Select', label: RadioButton_settings_1.radioButtonSelectActionLabel }], accessibilityPositionInSet: (_b = accessibilityPositionInSet !== null && accessibilityPositionInSet !== void 0 ? accessibilityPositionInSet : ariaPosInSet) !== null && _b !== void 0 ? _b : info.buttonKeys.findIndex(function (x) { return x == buttonKey; }) + 1, accessibilitySetSize: (_c = accessibilitySetSize !== null && accessibilitySetSize !== void 0 ? accessibilitySetSize : ariaSetSize) !== null && _c !== void 0 ? _c : info.buttonKeys.length, focusable: !state.disabled, onAccessibilityAction: onAccessibilityAction }), onKeyDownProps),
|
|
115
|
+
content: { children: content },
|
|
116
|
+
});
|
|
117
|
+
return { slotProps: slotProps };
|
|
118
|
+
},
|
|
119
|
+
render: function (Slots, _renderData) {
|
|
120
|
+
var children = [];
|
|
121
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
122
|
+
children[_i - 2] = arguments[_i];
|
|
123
|
+
}
|
|
124
|
+
return ((0, foundation_composable_1.withSlots)(Slots.root, null,
|
|
125
|
+
(0, foundation_composable_1.withSlots)(Slots.button, null,
|
|
126
|
+
(0, foundation_composable_1.withSlots)(Slots.innerCircle, null)),
|
|
127
|
+
(0, foundation_composable_1.withSlots)(Slots.content, null),
|
|
128
|
+
children));
|
|
129
|
+
},
|
|
130
|
+
settings: RadioButton_settings_1.settings,
|
|
131
|
+
slots: {
|
|
132
|
+
root: react_native_1.View,
|
|
133
|
+
button: { slotType: react_native_1.View, filter: adapters_1.filterViewProps },
|
|
134
|
+
innerCircle: { slotType: react_native_1.View, filter: adapters_1.filterViewProps },
|
|
135
|
+
content: text_1.Text,
|
|
136
|
+
},
|
|
137
|
+
styles: {
|
|
138
|
+
root: [],
|
|
139
|
+
button: [tokens_1.borderTokens],
|
|
140
|
+
innerCircle: [tokens_1.backgroundColorTokens],
|
|
141
|
+
content: [tokens_1.foregroundColorTokens, tokens_1.textTokens, [{ source: 'textBorderColor', lookup: tokens_1.getPaletteFromTheme, target: 'borderColor' }]],
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
exports.default = exports.RadioButton;
|
|
145
|
+
//# sourceMappingURL=RadioButton.win32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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KAAK,EAAE;QACL,IAAI,EAAE,mBAAI;QACV,MAAM,EAAE,EAAE,QAAQ,EAAE,mBAAI,EAAE,MAAM,EAAE,0BAAe,EAAE;QACnD,WAAW,EAAE,EAAE,QAAQ,EAAE,mBAAI,EAAE,MAAM,EAAE,0BAAe,EAAE;QACxD,OAAO,EAAE,WAAI;KACd;IACD,MAAM,EAAE;QACN,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC,qBAAY,CAAC;QACtB,WAAW,EAAE,CAAC,8BAAqB,CAAC;QACpC,OAAO,EAAE,CAAC,8BAAqB,EAAE,mBAAU,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,4BAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;KAClI;CACF,CAAC,CAAC;AAEH,kBAAe,mBAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioGroup.tsx"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,qBAAqB;AACrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EAEpB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,iBAAiB,mCAS5B,CAAC;AAEH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioGroup.tsx"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,qBAAqB;AACrB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EAEpB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,iBAAiB,mCAS5B,CAAC;AAEH,eAAO,MAAM,UAAU,mLAuHrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -36,11 +36,41 @@ exports.RadioGroup = (0, foundation_compose_1.compose)({
|
|
|
36
36
|
var onSelectButtonRef = React.useCallback(function (ref) {
|
|
37
37
|
setSelectedButtonRef(ref);
|
|
38
38
|
}, [setSelectedButtonRef]);
|
|
39
|
+
var _c = React.useState(false), invoked = _c[0], setInvoked = _c[1];
|
|
40
|
+
var onInvoked = React.useCallback(function (check) {
|
|
41
|
+
setInvoked(check);
|
|
42
|
+
}, [setInvoked]);
|
|
43
|
+
var _d = React.useState([]), buttonKeys = _d[0], setButtonKeys = _d[1];
|
|
44
|
+
var onAddRadioButtonKey = React.useCallback(function (buttonKey) {
|
|
45
|
+
buttonKeys.push(buttonKey);
|
|
46
|
+
setButtonKeys(buttonKeys);
|
|
47
|
+
}, [setButtonKeys]);
|
|
48
|
+
var onRemoveRadioButtonKey = React.useCallback(function (buttonKey) {
|
|
49
|
+
buttonKeys.filter(function (item) { return item !== buttonKey; });
|
|
50
|
+
setButtonKeys(buttonKeys);
|
|
51
|
+
}, [setButtonKeys]);
|
|
52
|
+
var _e = React.useState([]), enabledButtonKeys = _e[0], setEnabledButtonKeys = _e[1];
|
|
53
|
+
var onAddRadioButtonEnabledKey = React.useCallback(function (buttonKey) {
|
|
54
|
+
enabledButtonKeys.push(buttonKey);
|
|
55
|
+
setEnabledButtonKeys(enabledButtonKeys);
|
|
56
|
+
}, [setEnabledButtonKeys]);
|
|
57
|
+
var onRemoveRadioButtonEnabledKey = React.useCallback(function (buttonKey) {
|
|
58
|
+
enabledButtonKeys.filter(function (item) { return item !== buttonKey; });
|
|
59
|
+
setEnabledButtonKeys(enabledButtonKeys);
|
|
60
|
+
}, [setEnabledButtonKeys]);
|
|
39
61
|
var state = {
|
|
40
62
|
context: {
|
|
41
63
|
selectedKey: selectedKey !== null && selectedKey !== void 0 ? selectedKey : data.selectedKey,
|
|
42
64
|
onChange: data.onKeySelect,
|
|
43
65
|
updateSelectedButtonRef: onSelectButtonRef,
|
|
66
|
+
invoked: invoked,
|
|
67
|
+
updateInvoked: onInvoked,
|
|
68
|
+
buttonKeys: buttonKeys,
|
|
69
|
+
enabledButtonKeys: enabledButtonKeys,
|
|
70
|
+
addRadioButtonKey: onAddRadioButtonKey,
|
|
71
|
+
removeRadioButtonKey: onRemoveRadioButtonKey,
|
|
72
|
+
addRadioButtonEnabledKey: onAddRadioButtonEnabledKey,
|
|
73
|
+
removeRadioButtonEnabledKey: onRemoveRadioButtonEnabledKey,
|
|
44
74
|
},
|
|
45
75
|
};
|
|
46
76
|
var styleProps = useStyling(userProps, function (override) { return state[override] || userProps[override]; });
|
|
@@ -59,18 +89,6 @@ exports.RadioGroup = (0, foundation_compose_1.compose)({
|
|
|
59
89
|
if (renderData.state == undefined) {
|
|
60
90
|
return null;
|
|
61
91
|
}
|
|
62
|
-
// Populate the buttonKeys array
|
|
63
|
-
if (children) {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
65
|
-
// @ts-ignore - TODO, fix typing error
|
|
66
|
-
renderData.state.context.buttonKeys = React.Children.map(children, function (child) {
|
|
67
|
-
if (React.isValidElement(child)) {
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
69
|
-
// @ts-ignore - TODO, fix typing error
|
|
70
|
-
return child.props.buttonKey;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
92
|
return ((0, foundation_composable_1.withSlots)(exports.RadioGroupContext.Provider
|
|
75
93
|
// Passes in the selected key and a hook function to update the newly selected button and call the client's onChange callback
|
|
76
94
|
, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../src/legacy/RadioGroup.tsx"],"names":[],"mappings":";;;;AAAA,0BAA0B;AAC1B,qBAAqB;AACrB,mDAA+B;AAC/B,6CAAoC;AAEpC,gEAA8D;AAC9D,8EAA0E;AAC1E,oDAAmD;AACnD,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ED,MAAM,EAAE,UAAC,KAAmC,EAAE,UAAiC;QAAE,kBAA8B;aAA9B,UAA8B,EAA9B,qBAA8B,EAA9B,IAA8B;YAA9B,iCAA8B;;QAC7G,IAAI,UAAU,CAAC,KAAK,IAAI,SAAS,EAAE;YACjC,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CACL,uCAAC,yBAAiB,CAAC,QAAQ;QACzB,6HAA6H;;YAA7H,6HAA6H;YAC7H,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO;YAE/B,uCAAC,KAAK,CAAC,IAAI;gBACT,uCAAC,KAAK,CAAC,KAAK,OAAG;gBACf,uCAAC,KAAK,CAAC,SAAS,QAAE,QAAQ,CAAmB,CAClC,CACc,CAC9B,CAAC;IACJ,CAAC;IAED,QAAQ,gCAAA;IACR,KAAK,EAAE;QACL,IAAI,EAAE,mBAAI;QACV,KAAK,EAAE,WAAI;QACX,SAAS,EAAE,sBAAS;KACrB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,CAAC,8BAAqB,EAAE,mBAAU,CAAC;QAC1C,SAAS,EAAE,EAAE;KACd;CACF,CAAC,CAAC;AAEH,kBAAe,kBAAU,CAAC"}
|
|
@@ -22,6 +22,32 @@ export interface IRadioGroupContext {
|
|
|
22
22
|
* Array of radio button keys in the group
|
|
23
23
|
*/
|
|
24
24
|
buttonKeys?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Populate the buttonKeys array (all RadioButton keys) at mount and un-mount
|
|
27
|
+
*/
|
|
28
|
+
addRadioButtonKey?: (value: string) => void;
|
|
29
|
+
removeRadioButtonKey?: (value: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Array of enabled Radio keys in the RadioGroup
|
|
32
|
+
* @platform win32
|
|
33
|
+
*/
|
|
34
|
+
enabledButtonKeys?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Populate the enabledButtonKeys array (only enabled/valid RadioButton keys) at mount and un-mount
|
|
37
|
+
* @platform win32
|
|
38
|
+
*/
|
|
39
|
+
addRadioButtonEnabledKey?: (value: string) => void;
|
|
40
|
+
removeRadioButtonEnabledKey?: (value: string) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Updates invoked to signal that arrow key has been pressed and focus needs to be set
|
|
43
|
+
* @platform win32
|
|
44
|
+
*/
|
|
45
|
+
updateInvoked?: (check: boolean) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Signals whether arrow key has been pressed
|
|
48
|
+
* @platform win32
|
|
49
|
+
*/
|
|
50
|
+
invoked?: boolean;
|
|
25
51
|
}
|
|
26
52
|
export interface IRadioGroupState {
|
|
27
53
|
context: IRadioGroupContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.types.d.ts","sourceRoot":"","sources":["../../src/legacy/RadioGroup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEzE,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjC;;OAEG;IACH,uBAAuB,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IAE9D;;OAEG;IACH,UAAU,CAAC,EAAE,MA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,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAEzC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACrD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB,EAAE,UAAU;CAAG;AAEhF,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAC1C,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;AAExF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,oBAAoB,CAAC;IAChC,KAAK,EAAE,gBAAgB,CAAC;CACzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-react-native/radio-group",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.8",
|
|
4
4
|
"description": "A cross-platform Radio Group component using the Fluent Design System",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@fluentui-react-native/adapters": ">=0.12.0 <1.0.0",
|
|
26
26
|
"@fluentui-react-native/component-cache": "^1.6.0",
|
|
27
|
-
"@fluentui-react-native/focus-zone": ">=0.16.
|
|
28
|
-
"@fluentui-react-native/framework": "0.13.
|
|
29
|
-
"@fluentui-react-native/interactive-hooks": ">=0.25.
|
|
30
|
-
"@fluentui-react-native/pressable": ">=0.11.
|
|
31
|
-
"@fluentui-react-native/text": ">=0.22.
|
|
32
|
-
"@fluentui-react-native/theme-tokens": ">=0.26.
|
|
33
|
-
"@fluentui-react-native/tokens": ">=0.22.
|
|
27
|
+
"@fluentui-react-native/focus-zone": ">=0.16.6 <1.0.0",
|
|
28
|
+
"@fluentui-react-native/framework": "0.13.5",
|
|
29
|
+
"@fluentui-react-native/interactive-hooks": ">=0.25.6 <1.0.0",
|
|
30
|
+
"@fluentui-react-native/pressable": ">=0.11.6 <1.0.0",
|
|
31
|
+
"@fluentui-react-native/text": ">=0.22.6 <1.0.0",
|
|
32
|
+
"@fluentui-react-native/theme-tokens": ">=0.26.5 <1.0.0",
|
|
33
|
+
"@fluentui-react-native/tokens": ">=0.22.5 <1.0.0",
|
|
34
34
|
"@fluentui-react-native/use-styling": ">=0.12.0 <1.0.0",
|
|
35
35
|
"@uifabricshared/foundation-composable": ">=0.12.3 <1.0.0",
|
|
36
|
-
"@uifabricshared/foundation-compose": "^1.14.
|
|
36
|
+
"@uifabricshared/foundation-compose": "^1.14.19",
|
|
37
37
|
"@uifabricshared/foundation-settings": ">=0.14.0 <1.0.0",
|
|
38
38
|
"tslib": "^2.3.1"
|
|
39
39
|
},
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
/** @jsx withSlots */
|
|
3
|
+
'use strict';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { View, I18nManager } from 'react-native';
|
|
6
|
+
|
|
7
|
+
import { filterViewProps } from '@fluentui-react-native/adapters';
|
|
8
|
+
import type { KeyPressEvent } from '@fluentui-react-native/interactive-hooks';
|
|
9
|
+
import { useAsPressable, useViewCommandFocus, useKeyDownProps } from '@fluentui-react-native/interactive-hooks';
|
|
10
|
+
import { Text } from '@fluentui-react-native/text';
|
|
11
|
+
import { foregroundColorTokens, textTokens, borderTokens, backgroundColorTokens, getPaletteFromTheme } from '@fluentui-react-native/tokens';
|
|
12
|
+
import type { ISlots } from '@uifabricshared/foundation-composable';
|
|
13
|
+
import { withSlots } from '@uifabricshared/foundation-composable';
|
|
14
|
+
import type { IUseComposeStyling } from '@uifabricshared/foundation-compose';
|
|
15
|
+
import { compose } from '@uifabricshared/foundation-compose';
|
|
16
|
+
import { mergeSettings } from '@uifabricshared/foundation-settings';
|
|
17
|
+
|
|
18
|
+
import { settings, radioButtonSelectActionLabel } from './RadioButton.settings';
|
|
19
|
+
import type { IRadioButtonType, IRadioButtonProps, IRadioButtonSlotProps, IRadioButtonRenderData } from './RadioButton.types';
|
|
20
|
+
import { radioButtonName } from './RadioButton.types';
|
|
21
|
+
import { RadioGroupContext } from './RadioGroup';
|
|
22
|
+
|
|
23
|
+
enum DirectionalArrowKeys {
|
|
24
|
+
ArrowUp = 'ArrowUp',
|
|
25
|
+
ArrowDown = 'ArrowDown',
|
|
26
|
+
ArrowRight = 'ArrowRight',
|
|
27
|
+
ArrowLeft = 'ArrowLeft',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const RadioButton = compose<IRadioButtonType>({
|
|
31
|
+
displayName: radioButtonName,
|
|
32
|
+
|
|
33
|
+
usePrepareProps: (userProps: IRadioButtonProps, useStyling: IUseComposeStyling<IRadioButtonType>) => {
|
|
34
|
+
const defaultComponentRef = React.useRef(null);
|
|
35
|
+
const {
|
|
36
|
+
content,
|
|
37
|
+
buttonKey,
|
|
38
|
+
disabled,
|
|
39
|
+
accessibilityLabel,
|
|
40
|
+
ariaLabel,
|
|
41
|
+
componentRef = defaultComponentRef,
|
|
42
|
+
accessibilityPositionInSet,
|
|
43
|
+
ariaPosInSet,
|
|
44
|
+
accessibilitySetSize,
|
|
45
|
+
ariaSetSize,
|
|
46
|
+
...rest
|
|
47
|
+
} = userProps;
|
|
48
|
+
|
|
49
|
+
// Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
|
|
50
|
+
const info = React.useContext(RadioGroupContext);
|
|
51
|
+
|
|
52
|
+
const buttonRef = useViewCommandFocus(componentRef);
|
|
53
|
+
|
|
54
|
+
/* We don't want to call the user's onChange multiple times on the same selection. */
|
|
55
|
+
const changeSelection = () => {
|
|
56
|
+
if (buttonKey != info.selectedKey) {
|
|
57
|
+
info.onChange && info.onChange(buttonKey);
|
|
58
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/* We use the componentRef of the currently selected button to maintain the default tabbable
|
|
63
|
+
element in a RadioGroup. Since the componentRef isn't generated until after initial render,
|
|
64
|
+
we must update it once here. */
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
if (buttonKey == info.selectedKey) {
|
|
67
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
71
|
+
// Explicitly only run on mount and unmount
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
info.addRadioButtonKey(buttonKey);
|
|
74
|
+
|
|
75
|
+
if (!disabled) {
|
|
76
|
+
info.addRadioButtonEnabledKey(buttonKey);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return () => {
|
|
80
|
+
info.removeRadioButtonKey(buttonKey);
|
|
81
|
+
info.removeRadioButtonEnabledKey(buttonKey);
|
|
82
|
+
};
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
const isRTL = I18nManager.isRTL;
|
|
86
|
+
|
|
87
|
+
const onInvoke = React.useCallback(
|
|
88
|
+
(e: KeyPressEvent) => {
|
|
89
|
+
if (e.nativeEvent.key in DirectionalArrowKeys) {
|
|
90
|
+
const length = info.enabledButtonKeys.length;
|
|
91
|
+
const next =
|
|
92
|
+
e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
|
|
93
|
+
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
|
|
94
|
+
const currRadioButtonIndex = info.enabledButtonKeys.indexOf(info.selectedKey);
|
|
95
|
+
let newCurrRadioButtonIndex;
|
|
96
|
+
if (next) {
|
|
97
|
+
newCurrRadioButtonIndex = (currRadioButtonIndex + 1) % length;
|
|
98
|
+
} else {
|
|
99
|
+
// previous
|
|
100
|
+
newCurrRadioButtonIndex = (currRadioButtonIndex - 1 + length) % length;
|
|
101
|
+
}
|
|
102
|
+
info.onChange && info.onChange(info.enabledButtonKeys[newCurrRadioButtonIndex]);
|
|
103
|
+
info.updateInvoked && info.updateInvoked(true);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
[info],
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// Sets the updated selected button ref and focus if this Radio is selected via arrow key.
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
if (info.invoked && buttonKey === info.selectedKey && !disabled) {
|
|
112
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
113
|
+
componentRef?.current?.focus();
|
|
114
|
+
info.updateInvoked && info.updateInvoked(false);
|
|
115
|
+
}
|
|
116
|
+
}, [info.invoked]);
|
|
117
|
+
|
|
118
|
+
const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
119
|
+
|
|
120
|
+
// Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
|
|
121
|
+
const onKeyDownProps = useKeyDownProps(onInvoke, ...keys);
|
|
122
|
+
|
|
123
|
+
// Ensure focus is placed on button after click
|
|
124
|
+
const changeSelectionWithFocus = () => {
|
|
125
|
+
if (buttonKey != info.selectedKey) {
|
|
126
|
+
info.onChange && info.onChange(buttonKey);
|
|
127
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
128
|
+
info.updateInvoked && info.updateInvoked(true);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/* RadioButton changes selection when focus is moved between each RadioButton and on a click */
|
|
133
|
+
const pressable = useAsPressable({
|
|
134
|
+
...rest,
|
|
135
|
+
onPress: changeSelectionWithFocus,
|
|
136
|
+
onFocus: changeSelection,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Used when creating accessibility properties in mergeSettings below
|
|
140
|
+
const onAccessibilityAction = React.useCallback(
|
|
141
|
+
(event: { nativeEvent: { actionName: any } }) => {
|
|
142
|
+
switch (event.nativeEvent.actionName) {
|
|
143
|
+
case 'Select':
|
|
144
|
+
changeSelection();
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
[info, buttonKey],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const state = {
|
|
152
|
+
...pressable.state,
|
|
153
|
+
selected: info.selectedKey === userProps.buttonKey && !disabled,
|
|
154
|
+
disabled: disabled || false,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Grab the styling information from the userProps, referencing the state as well as the props.
|
|
158
|
+
const styleProps = useStyling(userProps, (override: string) => state[override] || userProps[override]);
|
|
159
|
+
|
|
160
|
+
const slotProps = mergeSettings<IRadioButtonSlotProps>(styleProps, {
|
|
161
|
+
root: {
|
|
162
|
+
...rest,
|
|
163
|
+
ref: buttonRef,
|
|
164
|
+
...pressable.props,
|
|
165
|
+
accessibilityRole: 'radio',
|
|
166
|
+
accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
|
|
167
|
+
accessibilityState: { disabled: state.disabled, selected: state.selected },
|
|
168
|
+
accessibilityActions: [{ name: 'Select', label: radioButtonSelectActionLabel }],
|
|
169
|
+
accessibilityPositionInSet: accessibilityPositionInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
|
|
170
|
+
accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
|
|
171
|
+
focusable: !state.disabled,
|
|
172
|
+
onAccessibilityAction: onAccessibilityAction,
|
|
173
|
+
...onKeyDownProps,
|
|
174
|
+
},
|
|
175
|
+
content: { children: content },
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return { slotProps };
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
render: (Slots: ISlots<IRadioButtonSlotProps>, _renderData: IRadioButtonRenderData, ...children: React.ReactNode[]) => {
|
|
182
|
+
return (
|
|
183
|
+
<Slots.root>
|
|
184
|
+
<Slots.button>
|
|
185
|
+
<Slots.innerCircle />
|
|
186
|
+
</Slots.button>
|
|
187
|
+
<Slots.content />
|
|
188
|
+
{children}
|
|
189
|
+
</Slots.root>
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
settings,
|
|
194
|
+
slots: {
|
|
195
|
+
root: View,
|
|
196
|
+
button: { slotType: View, filter: filterViewProps },
|
|
197
|
+
innerCircle: { slotType: View, filter: filterViewProps },
|
|
198
|
+
content: Text,
|
|
199
|
+
},
|
|
200
|
+
styles: {
|
|
201
|
+
root: [],
|
|
202
|
+
button: [borderTokens],
|
|
203
|
+
innerCircle: [backgroundColorTokens],
|
|
204
|
+
content: [foregroundColorTokens, textTokens, [{ source: 'textBorderColor', lookup: getPaletteFromTheme, target: 'borderColor' }]],
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
export default RadioButton;
|
|
@@ -53,11 +53,64 @@ export const RadioGroup = compose<IRadioGroupType>({
|
|
|
53
53
|
[setSelectedButtonRef],
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
+
const [invoked, setInvoked] = React.useState(false);
|
|
57
|
+
|
|
58
|
+
const onInvoked = React.useCallback(
|
|
59
|
+
(check: boolean) => {
|
|
60
|
+
setInvoked(check);
|
|
61
|
+
},
|
|
62
|
+
[setInvoked],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const [buttonKeys, setButtonKeys] = React.useState([]);
|
|
66
|
+
|
|
67
|
+
const onAddRadioButtonKey = React.useCallback(
|
|
68
|
+
(buttonKey: string) => {
|
|
69
|
+
buttonKeys.push(buttonKey);
|
|
70
|
+
setButtonKeys(buttonKeys);
|
|
71
|
+
},
|
|
72
|
+
[setButtonKeys],
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const onRemoveRadioButtonKey = React.useCallback(
|
|
76
|
+
(buttonKey: string) => {
|
|
77
|
+
buttonKeys.filter((item) => item !== buttonKey);
|
|
78
|
+
setButtonKeys(buttonKeys);
|
|
79
|
+
},
|
|
80
|
+
[setButtonKeys],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const [enabledButtonKeys, setEnabledButtonKeys] = React.useState([]);
|
|
84
|
+
|
|
85
|
+
const onAddRadioButtonEnabledKey = React.useCallback(
|
|
86
|
+
(buttonKey: string) => {
|
|
87
|
+
enabledButtonKeys.push(buttonKey);
|
|
88
|
+
setEnabledButtonKeys(enabledButtonKeys);
|
|
89
|
+
},
|
|
90
|
+
[setEnabledButtonKeys],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const onRemoveRadioButtonEnabledKey = React.useCallback(
|
|
94
|
+
(buttonKey: string) => {
|
|
95
|
+
enabledButtonKeys.filter((item) => item !== buttonKey);
|
|
96
|
+
setEnabledButtonKeys(enabledButtonKeys);
|
|
97
|
+
},
|
|
98
|
+
[setEnabledButtonKeys],
|
|
99
|
+
);
|
|
100
|
+
|
|
56
101
|
const state: IRadioGroupState = {
|
|
57
102
|
context: {
|
|
58
103
|
selectedKey: selectedKey ?? data.selectedKey,
|
|
59
104
|
onChange: data.onKeySelect,
|
|
60
105
|
updateSelectedButtonRef: onSelectButtonRef,
|
|
106
|
+
invoked: invoked,
|
|
107
|
+
updateInvoked: onInvoked,
|
|
108
|
+
buttonKeys: buttonKeys,
|
|
109
|
+
enabledButtonKeys: enabledButtonKeys,
|
|
110
|
+
addRadioButtonKey: onAddRadioButtonKey,
|
|
111
|
+
removeRadioButtonKey: onRemoveRadioButtonKey,
|
|
112
|
+
addRadioButtonEnabledKey: onAddRadioButtonEnabledKey,
|
|
113
|
+
removeRadioButtonEnabledKey: onRemoveRadioButtonEnabledKey,
|
|
61
114
|
},
|
|
62
115
|
};
|
|
63
116
|
|
|
@@ -77,19 +130,6 @@ export const RadioGroup = compose<IRadioGroupType>({
|
|
|
77
130
|
return null;
|
|
78
131
|
}
|
|
79
132
|
|
|
80
|
-
// Populate the buttonKeys array
|
|
81
|
-
if (children) {
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
83
|
-
// @ts-ignore - TODO, fix typing error
|
|
84
|
-
renderData.state.context.buttonKeys = React.Children.map(children, (child: React.ReactChild) => {
|
|
85
|
-
if (React.isValidElement(child)) {
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
-
// @ts-ignore - TODO, fix typing error
|
|
88
|
-
return child.props.buttonKey;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
133
|
return (
|
|
94
134
|
<RadioGroupContext.Provider
|
|
95
135
|
// Passes in the selected key and a hook function to update the newly selected button and call the client's onChange callback
|
|
@@ -28,6 +28,37 @@ export interface IRadioGroupContext {
|
|
|
28
28
|
* Array of radio button keys in the group
|
|
29
29
|
*/
|
|
30
30
|
buttonKeys?: string[];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Populate the buttonKeys array (all RadioButton keys) at mount and un-mount
|
|
34
|
+
*/
|
|
35
|
+
addRadioButtonKey?: (value: string) => void;
|
|
36
|
+
removeRadioButtonKey?: (value: string) => void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Array of enabled Radio keys in the RadioGroup
|
|
40
|
+
* @platform win32
|
|
41
|
+
*/
|
|
42
|
+
enabledButtonKeys?: string[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Populate the enabledButtonKeys array (only enabled/valid RadioButton keys) at mount and un-mount
|
|
46
|
+
* @platform win32
|
|
47
|
+
*/
|
|
48
|
+
addRadioButtonEnabledKey?: (value: string) => void;
|
|
49
|
+
removeRadioButtonEnabledKey?: (value: string) => void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Updates invoked to signal that arrow key has been pressed and focus needs to be set
|
|
53
|
+
* @platform win32
|
|
54
|
+
*/
|
|
55
|
+
updateInvoked?: (check: boolean) => void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Signals whether arrow key has been pressed
|
|
59
|
+
* @platform win32
|
|
60
|
+
*/
|
|
61
|
+
invoked?: boolean;
|
|
31
62
|
}
|
|
32
63
|
|
|
33
64
|
export interface IRadioGroupState {
|
|
@@ -39,9 +39,9 @@ exports[`RadioButton component tests RadioButton default 1`] = `
|
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
accessibilityLabel="RadioButton1"
|
|
42
|
-
accessibilityPositionInSet={
|
|
42
|
+
accessibilityPositionInSet={0}
|
|
43
43
|
accessibilityRole="radio"
|
|
44
|
-
accessibilitySetSize={
|
|
44
|
+
accessibilitySetSize={0}
|
|
45
45
|
accessibilityState={
|
|
46
46
|
{
|
|
47
47
|
"disabled": false,
|
|
@@ -134,9 +134,9 @@ exports[`RadioButton component tests RadioButton default 1`] = `
|
|
|
134
134
|
]
|
|
135
135
|
}
|
|
136
136
|
accessibilityLabel="RadioButton2"
|
|
137
|
-
accessibilityPositionInSet={
|
|
137
|
+
accessibilityPositionInSet={0}
|
|
138
138
|
accessibilityRole="radio"
|
|
139
|
-
accessibilitySetSize={
|
|
139
|
+
accessibilitySetSize={0}
|
|
140
140
|
accessibilityState={
|
|
141
141
|
{
|
|
142
142
|
"disabled": false,
|