@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
|
@@ -1,174 +1,133 @@
|
|
|
1
1
|
/** @jsxImportSource @fluentui-react-native/framework-base */
|
|
2
2
|
'use strict';
|
|
3
|
-
var __createBinding =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
(Object.create
|
|
26
|
-
? function (o, v) {
|
|
27
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
28
|
-
}
|
|
29
|
-
: function (o, v) {
|
|
30
|
-
o['default'] = v;
|
|
31
|
-
});
|
|
32
|
-
var __importStar =
|
|
33
|
-
(this && this.__importStar) ||
|
|
34
|
-
(function () {
|
|
35
|
-
var ownKeys = function (o) {
|
|
36
|
-
ownKeys =
|
|
37
|
-
Object.getOwnPropertyNames ||
|
|
38
|
-
function (o) {
|
|
39
|
-
var ar = [];
|
|
40
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
41
|
-
return ar;
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
42
25
|
};
|
|
43
|
-
|
|
26
|
+
return ownKeys(o);
|
|
44
27
|
};
|
|
45
28
|
return function (mod) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
51
34
|
};
|
|
52
|
-
|
|
53
|
-
Object.defineProperty(exports,
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
37
|
exports.RadioButton = void 0;
|
|
55
|
-
const jsx_runtime_1 = require(
|
|
56
|
-
const React = __importStar(require(
|
|
57
|
-
const react_native_1 = require(
|
|
58
|
-
const adapters_1 = require(
|
|
59
|
-
const interactive_hooks_1 = require(
|
|
60
|
-
const text_1 = require(
|
|
61
|
-
const tokens_1 = require(
|
|
62
|
-
const foundation_compose_1 = require(
|
|
63
|
-
const foundation_settings_1 = require(
|
|
64
|
-
const RadioButton_settings_1 = require(
|
|
65
|
-
const RadioButton_types_1 = require(
|
|
66
|
-
const RadioGroup_1 = require(
|
|
38
|
+
const jsx_runtime_1 = require("@fluentui-react-native/framework-base/jsx-runtime");
|
|
39
|
+
const React = __importStar(require("react"));
|
|
40
|
+
const react_native_1 = require("react-native");
|
|
41
|
+
const adapters_1 = require("@fluentui-react-native/adapters");
|
|
42
|
+
const interactive_hooks_1 = require("@fluentui-react-native/interactive-hooks");
|
|
43
|
+
const text_1 = require("@fluentui-react-native/text");
|
|
44
|
+
const tokens_1 = require("@fluentui-react-native/tokens");
|
|
45
|
+
const foundation_compose_1 = require("@uifabricshared/foundation-compose");
|
|
46
|
+
const foundation_settings_1 = require("@uifabricshared/foundation-settings");
|
|
47
|
+
const RadioButton_settings_1 = require("./RadioButton.settings");
|
|
48
|
+
const RadioButton_types_1 = require("./RadioButton.types");
|
|
49
|
+
const RadioGroup_1 = require("./RadioGroup");
|
|
67
50
|
exports.RadioButton = (0, foundation_compose_1.compose)({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} = userProps;
|
|
84
|
-
// Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
|
|
85
|
-
const info = React.useContext(RadioGroup_1.RadioGroupContext);
|
|
86
|
-
const buttonRef = (0, interactive_hooks_1.useViewCommandFocus)(componentRef);
|
|
87
|
-
/* We don't want to call the user's onChange multiple times on the same selection. */
|
|
88
|
-
const changeSelection = () => {
|
|
89
|
-
if (buttonKey != info.selectedKey) {
|
|
90
|
-
info.onChange && info.onChange(buttonKey);
|
|
91
|
-
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
/* We use the componentRef of the currently selected button to maintain the default tabbable
|
|
51
|
+
displayName: RadioButton_types_1.radioButtonName,
|
|
52
|
+
usePrepareProps: (userProps, useStyling) => {
|
|
53
|
+
const defaultComponentRef = React.useRef(null);
|
|
54
|
+
const { content, buttonKey, disabled, accessibilityLabel, ariaLabel, componentRef = defaultComponentRef, accessibilityPosInSet, ariaPosInSet, accessibilitySetSize, ariaSetSize, ...rest } = userProps;
|
|
55
|
+
// Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
|
|
56
|
+
const info = React.useContext(RadioGroup_1.RadioGroupContext);
|
|
57
|
+
const buttonRef = (0, interactive_hooks_1.useViewCommandFocus)(componentRef);
|
|
58
|
+
/* We don't want to call the user's onChange multiple times on the same selection. */
|
|
59
|
+
const changeSelection = () => {
|
|
60
|
+
if (buttonKey != info.selectedKey) {
|
|
61
|
+
info.onChange && info.onChange(buttonKey);
|
|
62
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/* We use the componentRef of the currently selected button to maintain the default tabbable
|
|
95
66
|
element in a RadioGroup. Since the componentRef isn't generated until after initial render,
|
|
96
67
|
we must update it once here. */
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
content: text_1.Text,
|
|
161
|
-
},
|
|
162
|
-
styles: {
|
|
163
|
-
root: [],
|
|
164
|
-
button: [tokens_1.borderTokens],
|
|
165
|
-
innerCircle: [tokens_1.backgroundColorTokens],
|
|
166
|
-
content: [
|
|
167
|
-
tokens_1.foregroundColorTokens,
|
|
168
|
-
tokens_1.textTokens,
|
|
169
|
-
[{ source: 'textBorderColor', lookup: tokens_1.getPaletteFromTheme, target: 'borderColor' }],
|
|
170
|
-
],
|
|
171
|
-
},
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
if (buttonKey == info.selectedKey) {
|
|
70
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
71
|
+
}
|
|
72
|
+
}, []);
|
|
73
|
+
// Ensure focus is placed on button after click
|
|
74
|
+
const changeSelectionWithFocus = (0, interactive_hooks_1.useOnPressWithFocus)(componentRef, changeSelection);
|
|
75
|
+
/* RadioButton changes selection when focus is moved between each RadioButton and on a click */
|
|
76
|
+
const pressable = (0, interactive_hooks_1.useAsPressable)({
|
|
77
|
+
...rest,
|
|
78
|
+
onPress: changeSelectionWithFocus,
|
|
79
|
+
onFocus: changeSelection,
|
|
80
|
+
});
|
|
81
|
+
// Used when creating accessibility properties in mergeSettings below
|
|
82
|
+
const onAccessibilityAction = React.useCallback((event) => {
|
|
83
|
+
switch (event.nativeEvent.actionName) {
|
|
84
|
+
case 'Select':
|
|
85
|
+
changeSelection();
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}, [info, buttonKey]);
|
|
89
|
+
const state = {
|
|
90
|
+
...pressable.state,
|
|
91
|
+
selected: info.selectedKey === userProps.buttonKey,
|
|
92
|
+
disabled: disabled || false,
|
|
93
|
+
};
|
|
94
|
+
// Grab the styling information from the userProps, referencing the state as well as the props.
|
|
95
|
+
const styleProps = useStyling(userProps, (override) => state[override] || userProps[override]);
|
|
96
|
+
const slotProps = (0, foundation_settings_1.mergeSettings)(styleProps, {
|
|
97
|
+
root: {
|
|
98
|
+
...rest,
|
|
99
|
+
ref: buttonRef,
|
|
100
|
+
...pressable.props,
|
|
101
|
+
accessibilityRole: 'radio',
|
|
102
|
+
accessibilityLabel: accessibilityLabel ?? ariaLabel ?? content,
|
|
103
|
+
accessibilityState: { disabled: state.disabled, selected: state.selected },
|
|
104
|
+
accessibilityActions: [{ name: 'Select', label: RadioButton_settings_1.radioButtonSelectActionLabel }],
|
|
105
|
+
accessibilityPosInSet: accessibilityPosInSet ?? ariaPosInSet ?? info.buttonKeys.findIndex((x) => x == buttonKey) + 1,
|
|
106
|
+
accessibilitySetSize: accessibilitySetSize ?? ariaSetSize ?? info.buttonKeys.length,
|
|
107
|
+
focusable: !state.disabled,
|
|
108
|
+
onAccessibilityAction: onAccessibilityAction,
|
|
109
|
+
},
|
|
110
|
+
content: { children: content },
|
|
111
|
+
});
|
|
112
|
+
return { slotProps };
|
|
113
|
+
},
|
|
114
|
+
render: (Slots, _renderData, ...children) => {
|
|
115
|
+
return (jsx_runtime_1.jsxs(Slots.root, { children: [
|
|
116
|
+
jsx_runtime_1.jsx(Slots.button, { children: jsx_runtime_1.jsx(Slots.innerCircle, {}) }), jsx_runtime_1.jsx(Slots.content, {}), children] }));
|
|
117
|
+
},
|
|
118
|
+
settings: RadioButton_settings_1.settings,
|
|
119
|
+
slots: {
|
|
120
|
+
root: react_native_1.View,
|
|
121
|
+
button: { slotType: react_native_1.View, filter: adapters_1.filterViewProps },
|
|
122
|
+
innerCircle: { slotType: react_native_1.View, filter: adapters_1.filterViewProps },
|
|
123
|
+
content: text_1.Text,
|
|
124
|
+
},
|
|
125
|
+
styles: {
|
|
126
|
+
root: [],
|
|
127
|
+
button: [tokens_1.borderTokens],
|
|
128
|
+
innerCircle: [tokens_1.backgroundColorTokens],
|
|
129
|
+
content: [tokens_1.foregroundColorTokens, tokens_1.textTokens, [{ source: 'textBorderColor', lookup: tokens_1.getPaletteFromTheme, target: 'borderColor' }]],
|
|
130
|
+
},
|
|
172
131
|
});
|
|
173
132
|
exports.default = exports.RadioButton;
|
|
174
|
-
//# sourceMappingURL=RadioButton.js.map
|
|
133
|
+
//# 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,123 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
(Object.create
|
|
25
|
-
? function (o, v) {
|
|
26
|
-
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
-
}
|
|
28
|
-
: function (o, v) {
|
|
29
|
-
o['default'] = v;
|
|
30
|
-
});
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
(function () {
|
|
34
|
-
var ownKeys = function (o) {
|
|
35
|
-
ownKeys =
|
|
36
|
-
Object.getOwnPropertyNames ||
|
|
37
|
-
function (o) {
|
|
38
|
-
var ar = [];
|
|
39
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
-
return ar;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
41
24
|
};
|
|
42
|
-
|
|
25
|
+
return ownKeys(o);
|
|
43
26
|
};
|
|
44
27
|
return function (mod) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
50
33
|
};
|
|
51
|
-
|
|
52
|
-
var __importDefault =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
39
|
exports.RadioButton = void 0;
|
|
59
|
-
const jsx_runtime_1 = require(
|
|
40
|
+
const jsx_runtime_1 = require("@fluentui-react-native/framework-base/jsx-runtime");
|
|
60
41
|
/**
|
|
61
42
|
* Copyright (c) Microsoft Corporation.
|
|
62
43
|
* Licensed under the MIT License.
|
|
63
44
|
* @format
|
|
64
45
|
*/
|
|
65
46
|
/** @jsxImportSource @fluentui-react-native/framework-base */
|
|
66
|
-
const React = __importStar(require(
|
|
67
|
-
const foundation_compose_1 = require(
|
|
68
|
-
const foundation_settings_1 = require(
|
|
69
|
-
const MacOSRadioButtonNativeComponent_1 = __importDefault(require(
|
|
70
|
-
const RadioButton_types_1 = require(
|
|
71
|
-
const RadioGroup_1 = require(
|
|
47
|
+
const React = __importStar(require("react"));
|
|
48
|
+
const foundation_compose_1 = require("@uifabricshared/foundation-compose");
|
|
49
|
+
const foundation_settings_1 = require("@uifabricshared/foundation-settings");
|
|
50
|
+
const MacOSRadioButtonNativeComponent_1 = __importDefault(require("./MacOSRadioButtonNativeComponent"));
|
|
51
|
+
const RadioButton_types_1 = require("./RadioButton.types");
|
|
52
|
+
const RadioGroup_1 = require("./RadioGroup");
|
|
72
53
|
exports.RadioButton = (0, foundation_compose_1.compose)({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
54
|
+
displayName: RadioButton_types_1.radioButtonName,
|
|
55
|
+
usePrepareProps: (userProps, useStyling) => {
|
|
56
|
+
const defaultComponentRef = React.useRef(null);
|
|
57
|
+
const { content, buttonKey, disabled, componentRef = defaultComponentRef } = userProps;
|
|
58
|
+
const info = React.useContext(RadioGroup_1.RadioGroupContext);
|
|
59
|
+
// Reroute the native component's onPress event to RadioGroup's onChange
|
|
60
|
+
const onPressRerouted = () => {
|
|
61
|
+
// Prevent calls to RadioGroup's onChange on the currently selected button
|
|
62
|
+
if (buttonKey != info.selectedKey) {
|
|
63
|
+
info.onChange && info.onChange(buttonKey);
|
|
64
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/* We use the componentRef of the currently selected button to maintain the default tabbable
|
|
87
68
|
element in a RadioGroup. Since the componentRef isn't generated until after initial render,
|
|
88
69
|
we must update it once here. */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
if (buttonKey === info.selectedKey) {
|
|
72
|
+
info.updateSelectedButtonRef && componentRef && info.updateSelectedButtonRef(componentRef);
|
|
73
|
+
}
|
|
74
|
+
}, []);
|
|
75
|
+
const styleProps = useStyling(userProps);
|
|
76
|
+
const isSelected = info.selectedKey === buttonKey;
|
|
77
|
+
const slotProps = (0, foundation_settings_1.mergeSettings)(styleProps, {
|
|
78
|
+
root: {
|
|
79
|
+
ref: componentRef,
|
|
80
|
+
buttonKey: buttonKey,
|
|
81
|
+
content: content,
|
|
82
|
+
disabled: disabled,
|
|
83
|
+
onPress: onPressRerouted,
|
|
84
|
+
selected: isSelected,
|
|
85
|
+
style: {
|
|
86
|
+
minWidth: '100%',
|
|
87
|
+
minHeight: 20,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return { slotProps };
|
|
92
|
+
},
|
|
93
|
+
slots: {
|
|
94
|
+
root: MacOSRadioButtonNativeComponent_1.default,
|
|
95
|
+
},
|
|
96
|
+
styles: {
|
|
97
|
+
root: [],
|
|
98
|
+
},
|
|
99
|
+
render: (Slots) => {
|
|
100
|
+
return jsx_runtime_1.jsx(Slots.root, {});
|
|
101
|
+
},
|
|
121
102
|
});
|
|
122
103
|
exports.default = exports.RadioButton;
|
|
123
|
-
//# sourceMappingURL=RadioButton.macos.js.map
|
|
104
|
+
//# 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
|