@fluentui-react-native/radio-group 0.21.31 → 0.22.0
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 +57 -0
- package/SPEC.md +1 -1
- package/lib/Radio/Radio.d.ts +7 -2
- package/lib/Radio/Radio.d.ts.map +1 -1
- package/lib/Radio/Radio.ios.d.ts +7 -2
- package/lib/Radio/Radio.ios.d.ts.map +1 -1
- package/lib/Radio/Radio.ios.js +52 -36
- package/lib/Radio/Radio.ios.js.map +1 -1
- package/lib/Radio/Radio.js +48 -36
- package/lib/Radio/Radio.js.map +1 -1
- package/lib/Radio/Radio.styling.d.ts +1 -1
- package/lib/Radio/Radio.styling.js +109 -88
- package/lib/Radio/Radio.types.d.ts +176 -170
- 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 +15 -8
- package/lib/Radio/__tests__/RadioExperimental.test.js.map +1 -1
- package/lib/Radio/useRadio.d.ts +1 -1
- package/lib/Radio/useRadio.d.ts.map +1 -1
- package/lib/Radio/useRadio.js +91 -70
- package/lib/Radio/useRadio.js.map +1 -1
- package/lib/Radio/useRadio.win32.d.ts +1 -1
- package/lib/Radio/useRadio.win32.d.ts.map +1 -1
- package/lib/Radio/useRadio.win32.js +143 -121
- package/lib/Radio/useRadio.win32.js.map +1 -1
- package/lib/RadioGroup/RadioGroup.d.ts +7 -2
- package/lib/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib/RadioGroup/RadioGroup.js +49 -38
- package/lib/RadioGroup/RadioGroup.js.map +1 -1
- package/lib/RadioGroup/RadioGroup.styling.d.ts +1 -1
- package/lib/RadioGroup/RadioGroup.styling.js +51 -42
- 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 +99 -50
- package/lib/RadioGroup/__tests__/RadioGroupExperimental.test.js.map +1 -1
- package/lib/RadioGroup/radioGroupContext.d.ts +1 -1
- package/lib/RadioGroup/radioGroupContext.js +19 -15
- package/lib/RadioGroup/radioGroupContext.js.map +1 -1
- package/lib/RadioGroup/useRadioGroup.d.ts +1 -1
- package/lib/RadioGroup/useRadioGroup.d.ts.map +1 -1
- package/lib/RadioGroup/useRadioGroup.js +93 -63
- package/lib/RadioGroup/useRadioGroup.js.map +1 -1
- package/lib/RadioGroup/useRadioGroupContextValue.d.ts +2 -3
- package/lib/RadioGroup/useRadioGroupContextValue.d.ts.map +1 -1
- package/lib/RadioGroup/useRadioGroupContextValue.js +2 -2
- package/lib/RadioGroup/useRadioGroupContextValue.js.map +1 -1
- package/lib/index.d.ts +25 -4
- 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 +8 -2
- package/lib/legacy/RadioButton.d.ts.map +1 -1
- package/lib/legacy/RadioButton.js +97 -85
- package/lib/legacy/RadioButton.js.map +1 -1
- package/lib/legacy/RadioButton.macos.d.ts +8 -2
- package/lib/legacy/RadioButton.macos.d.ts.map +1 -1
- package/lib/legacy/RadioButton.macos.js +49 -50
- package/lib/legacy/RadioButton.macos.js.map +1 -1
- package/lib/legacy/RadioButton.settings.d.ts +2 -2
- package/lib/legacy/RadioButton.settings.js +81 -81
- package/lib/legacy/RadioButton.types.d.ts +46 -46
- package/lib/legacy/RadioButton.types.d.ts.map +1 -1
- package/lib/legacy/RadioButton.types.js +1 -1
- package/lib/legacy/RadioButton.win32.d.ts +8 -2
- package/lib/legacy/RadioButton.win32.d.ts.map +1 -1
- package/lib/legacy/RadioButton.win32.js +152 -137
- package/lib/legacy/RadioButton.win32.js.map +1 -1
- package/lib/legacy/RadioGroup.d.ts +9 -4
- package/lib/legacy/RadioGroup.d.ts.map +1 -1
- package/lib/legacy/RadioGroup.js +109 -87
- package/lib/legacy/RadioGroup.js.map +1 -1
- package/lib/legacy/RadioGroup.settings.d.ts +1 -1
- package/lib/legacy/RadioGroup.settings.js +21 -21
- package/lib/legacy/RadioGroup.types.d.ts +78 -79
- 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 +9 -5
- package/lib/legacy/__tests__/RadioButton.test.js.map +1 -1
- package/lib/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
- package/lib/legacy/__tests__/RadioButtonGroup.test.js +35 -13
- package/lib/legacy/__tests__/RadioButtonGroup.test.js.map +1 -1
- package/lib-commonjs/Radio/Radio.d.ts +7 -2
- package/lib-commonjs/Radio/Radio.d.ts.map +1 -1
- package/lib-commonjs/Radio/Radio.ios.d.ts +7 -2
- package/lib-commonjs/Radio/Radio.ios.d.ts.map +1 -1
- package/lib-commonjs/Radio/Radio.ios.js +65 -44
- package/lib-commonjs/Radio/Radio.ios.js.map +1 -1
- package/lib-commonjs/Radio/Radio.js +60 -43
- package/lib-commonjs/Radio/Radio.js.map +1 -1
- package/lib-commonjs/Radio/Radio.styling.d.ts +1 -1
- package/lib-commonjs/Radio/Radio.styling.js +115 -94
- package/lib-commonjs/Radio/Radio.styling.js.map +1 -1
- package/lib-commonjs/Radio/Radio.types.d.ts +176 -170
- 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 +69 -35
- package/lib-commonjs/Radio/__tests__/RadioExperimental.test.js.map +1 -1
- package/lib-commonjs/Radio/useRadio.d.ts +1 -1
- package/lib-commonjs/Radio/useRadio.d.ts.map +1 -1
- package/lib-commonjs/Radio/useRadio.js +147 -99
- package/lib-commonjs/Radio/useRadio.js.map +1 -1
- package/lib-commonjs/Radio/useRadio.win32.d.ts +1 -1
- package/lib-commonjs/Radio/useRadio.win32.d.ts.map +1 -1
- package/lib-commonjs/Radio/useRadio.win32.js +200 -151
- package/lib-commonjs/Radio/useRadio.win32.js.map +1 -1
- package/lib-commonjs/RadioGroup/RadioGroup.d.ts +7 -2
- package/lib-commonjs/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib-commonjs/RadioGroup/RadioGroup.js +65 -48
- package/lib-commonjs/RadioGroup/RadioGroup.js.map +1 -1
- package/lib-commonjs/RadioGroup/RadioGroup.styling.d.ts +1 -1
- package/lib-commonjs/RadioGroup/RadioGroup.styling.js +57 -48
- package/lib-commonjs/RadioGroup/RadioGroup.styling.js.map +1 -1
- 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 +10 -5
- package/lib-commonjs/RadioGroup/RadioGroupTokens.android.js.map +1 -1
- 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 +10 -5
- package/lib-commonjs/RadioGroup/RadioGroupTokens.ios.js.map +1 -1
- 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 +157 -78
- package/lib-commonjs/RadioGroup/__tests__/RadioGroupExperimental.test.js.map +1 -1
- package/lib-commonjs/RadioGroup/radioGroupContext.d.ts +1 -1
- package/lib-commonjs/RadioGroup/radioGroupContext.js +72 -41
- package/lib-commonjs/RadioGroup/radioGroupContext.js.map +1 -1
- package/lib-commonjs/RadioGroup/useRadioGroup.d.ts +1 -1
- package/lib-commonjs/RadioGroup/useRadioGroup.d.ts.map +1 -1
- package/lib-commonjs/RadioGroup/useRadioGroup.js +148 -91
- package/lib-commonjs/RadioGroup/useRadioGroup.js.map +1 -1
- package/lib-commonjs/RadioGroup/useRadioGroupContextValue.d.ts +2 -3
- package/lib-commonjs/RadioGroup/useRadioGroupContextValue.d.ts.map +1 -1
- package/lib-commonjs/RadioGroup/useRadioGroupContextValue.js +4 -4
- package/lib-commonjs/RadioGroup/useRadioGroupContextValue.js.map +1 -1
- package/lib-commonjs/index.d.ts +25 -4
- package/lib-commonjs/index.js +128 -32
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.d.ts +6 -6
- package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.js +9 -7
- package/lib-commonjs/legacy/MacOSRadioButtonNativeComponent.js.map +1 -1
- package/lib-commonjs/legacy/RadioButton.d.ts +8 -2
- package/lib-commonjs/legacy/RadioButton.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.js +167 -120
- package/lib-commonjs/legacy/RadioButton.js.map +1 -1
- package/lib-commonjs/legacy/RadioButton.macos.d.ts +8 -2
- package/lib-commonjs/legacy/RadioButton.macos.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.macos.js +112 -84
- package/lib-commonjs/legacy/RadioButton.macos.js.map +1 -1
- package/lib-commonjs/legacy/RadioButton.settings.d.ts +2 -2
- package/lib-commonjs/legacy/RadioButton.settings.js +84 -84
- package/lib-commonjs/legacy/RadioButton.types.d.ts +46 -46
- package/lib-commonjs/legacy/RadioButton.types.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.types.js +3 -3
- package/lib-commonjs/legacy/RadioButton.win32.d.ts +8 -2
- package/lib-commonjs/legacy/RadioButton.win32.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioButton.win32.js +222 -172
- package/lib-commonjs/legacy/RadioButton.win32.js.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.d.ts +9 -4
- package/lib-commonjs/legacy/RadioGroup.d.ts.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.js +173 -122
- package/lib-commonjs/legacy/RadioGroup.js.map +1 -1
- package/lib-commonjs/legacy/RadioGroup.settings.d.ts +1 -1
- package/lib-commonjs/legacy/RadioGroup.settings.js +24 -24
- package/lib-commonjs/legacy/RadioGroup.types.d.ts +78 -79
- 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 +63 -32
- package/lib-commonjs/legacy/__tests__/RadioButton.test.js.map +1 -1
- package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.d.ts +1 -1
- package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.js +100 -41
- package/lib-commonjs/legacy/__tests__/RadioButtonGroup.test.js.map +1 -1
- package/package.json +72 -71
- package/src/Radio/Radio.ios.tsx +2 -3
- package/src/Radio/Radio.tsx +2 -3
- package/src/Radio/__tests__/RadioExperimental.test.tsx +11 -5
- package/src/Radio/__tests__/__snapshots__/RadioExperimental.test.tsx.snap +2 -2
- package/src/Radio/useRadio.ts +2 -2
- package/src/Radio/useRadio.win32.ts +2 -2
- package/src/RadioGroup/RadioGroup.tsx +2 -3
- package/src/RadioGroup/__tests__/RadioGroupExperimental.test.tsx +53 -47
- package/src/RadioGroup/__tests__/__snapshots__/RadioGroupExperimental.test.tsx.snap +12 -12
- package/src/legacy/RadioButton.macos.tsx +1 -3
- package/src/legacy/RadioButton.tsx +3 -5
- package/src/legacy/RadioButton.types.ts +3 -3
- package/src/legacy/RadioButton.win32.tsx +3 -5
- package/src/legacy/RadioGroup.tsx +1 -3
- package/src/legacy/__tests__/RadioButton.test.tsx +6 -3
- package/src/legacy/__tests__/RadioButtonGroup.test.tsx +23 -19
- package/src/legacy/__tests__/__snapshots__/RadioButton.test.tsx.snap +1 -1
- package/src/legacy/__tests__/__snapshots__/RadioButtonGroup.test.tsx.snap +4 -4
|
@@ -1,165 +1,214 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
});
|
|
22
|
+
var __setModuleDefault =
|
|
23
|
+
(this && this.__setModuleDefault) ||
|
|
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;
|
|
41
|
+
};
|
|
42
|
+
return ownKeys(o);
|
|
43
|
+
};
|
|
44
|
+
return function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== 'default') __createBinding(result, mod, k[i]);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
26
53
|
exports.useRadio = void 0;
|
|
27
|
-
const React = __importStar(require(
|
|
28
|
-
const react_native_1 = require(
|
|
29
|
-
const framework_1 = require(
|
|
30
|
-
const interactive_hooks_1 = require(
|
|
31
|
-
const radioGroupContext_1 = require(
|
|
54
|
+
const React = __importStar(require('react'));
|
|
55
|
+
const react_native_1 = require('react-native');
|
|
56
|
+
const framework_1 = require('@fluentui-react-native/framework');
|
|
57
|
+
const interactive_hooks_1 = require('@fluentui-react-native/interactive-hooks');
|
|
58
|
+
const radioGroupContext_1 = require('../RadioGroup/radioGroupContext');
|
|
32
59
|
const defaultAccessibilityActions = [{ name: 'Select' }];
|
|
33
60
|
var DirectionalArrowKeys;
|
|
34
61
|
(function (DirectionalArrowKeys) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
62
|
+
DirectionalArrowKeys['ArrowUp'] = 'ArrowUp';
|
|
63
|
+
DirectionalArrowKeys['ArrowDown'] = 'ArrowDown';
|
|
64
|
+
DirectionalArrowKeys['ArrowRight'] = 'ArrowRight';
|
|
65
|
+
DirectionalArrowKeys['ArrowLeft'] = 'ArrowLeft';
|
|
39
66
|
})(DirectionalArrowKeys || (DirectionalArrowKeys = {}));
|
|
40
67
|
const useRadio = (props) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
const defaultComponentRef = React.useRef(null);
|
|
69
|
+
// Grabs the context information from RadioGroup (currently selected button and client's onChange callback)
|
|
70
|
+
const radioGroupContext = (0, radioGroupContext_1.useRadioGroupContext)();
|
|
71
|
+
const {
|
|
72
|
+
label,
|
|
73
|
+
subtext,
|
|
74
|
+
value,
|
|
75
|
+
disabled,
|
|
76
|
+
accessibilityActions,
|
|
77
|
+
accessibilityLabel,
|
|
78
|
+
accessibilityHint,
|
|
79
|
+
accessibilityState,
|
|
80
|
+
componentRef = defaultComponentRef,
|
|
81
|
+
accessibilityPosInSet,
|
|
82
|
+
accessibilitySetSize,
|
|
83
|
+
...rest
|
|
84
|
+
} = props;
|
|
85
|
+
const labelPosition = radioGroupContext.layout === 'horizontal-stacked' ? 'below' : 'after';
|
|
86
|
+
const isDisabled = radioGroupContext.disabled || disabled;
|
|
87
|
+
const buttonRef = (0, interactive_hooks_1.useViewCommandFocus)(componentRef);
|
|
88
|
+
/* We don't want to call the user's onChange multiple times on the same selection. */
|
|
89
|
+
const changeSelection = React.useCallback(() => {
|
|
90
|
+
if (value !== radioGroupContext.value) {
|
|
91
|
+
radioGroupContext.onChange && radioGroupContext.onChange(value);
|
|
92
|
+
radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
|
|
93
|
+
}
|
|
94
|
+
}, [radioGroupContext, value, componentRef]);
|
|
95
|
+
/* We use the componentRef of the currently selected button to maintain the default tabbable
|
|
56
96
|
element in a RadioGroup. Since the componentRef isn't generated until after initial render,
|
|
57
97
|
we must update it once here. */
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
}, []);
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
if (isDisabled) {
|
|
72
|
-
radioGroupContext.removeRadioEnabledValue(value);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
radioGroupContext.addRadioEnabledValue(value);
|
|
76
|
-
}
|
|
77
|
-
}, [isDisabled]);
|
|
78
|
-
const isRTL = react_native_1.I18nManager.isRTL;
|
|
79
|
-
const onInvoke = React.useCallback((e) => {
|
|
80
|
-
if (e.nativeEvent.key in DirectionalArrowKeys) {
|
|
81
|
-
const length = radioGroupContext.enabledValues.length;
|
|
82
|
-
const previous = e.nativeEvent.key === DirectionalArrowKeys.ArrowUp ||
|
|
83
|
-
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowRight : e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft);
|
|
84
|
-
const next = e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
|
|
85
|
-
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
|
|
86
|
-
const currRadioIndex = radioGroupContext.enabledValues.indexOf(radioGroupContext.value);
|
|
87
|
-
let newCurrRadioIndex;
|
|
88
|
-
if (next) {
|
|
89
|
-
newCurrRadioIndex = (currRadioIndex + 1) % length;
|
|
90
|
-
radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
|
|
91
|
-
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
|
|
92
|
-
}
|
|
93
|
-
else if (previous) {
|
|
94
|
-
newCurrRadioIndex = (currRadioIndex - 1 + length) % length;
|
|
95
|
-
radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
|
|
96
|
-
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}, [radioGroupContext]);
|
|
100
|
-
// Sets the updated selected button ref and focus if this Radio is selected via arrow key.
|
|
101
|
-
React.useEffect(() => {
|
|
102
|
-
if (radioGroupContext.invoked && value === radioGroupContext.value && !isDisabled) {
|
|
103
|
-
radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
|
|
104
|
-
componentRef?.current?.focus();
|
|
105
|
-
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(false);
|
|
106
|
-
}
|
|
107
|
-
}, [radioGroupContext.invoked]);
|
|
108
|
-
const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
109
|
-
// Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
|
|
110
|
-
const onKeyDownProps = (0, interactive_hooks_1.useKeyDownProps)(onInvoke, ...keys);
|
|
111
|
-
// Ensure focus is placed on button after click
|
|
112
|
-
const changeSelectionWithFocus = (0, interactive_hooks_1.useOnPressWithFocus)(componentRef, changeSelection);
|
|
113
|
-
/* Radio changes selection when focus is moved between each RadioButton and on a click */
|
|
114
|
-
const pressable = (0, interactive_hooks_1.usePressableState)({
|
|
115
|
-
...rest,
|
|
116
|
-
onPress: changeSelectionWithFocus,
|
|
117
|
-
onFocus: changeSelection,
|
|
118
|
-
});
|
|
119
|
-
const accessibilityActionsProp = React.useMemo(() => (accessibilityActions ? [...defaultAccessibilityActions, ...accessibilityActions] : defaultAccessibilityActions), [accessibilityActions]);
|
|
120
|
-
// Used when creating accessibility properties in mergeSettings below
|
|
121
|
-
const onAccessibilityAction = React.useCallback((event) => {
|
|
122
|
-
switch (event.nativeEvent.actionName) {
|
|
123
|
-
case 'Select':
|
|
124
|
-
changeSelection();
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}, [changeSelection]);
|
|
128
|
-
const state = {
|
|
129
|
-
...pressable.state,
|
|
130
|
-
selected: radioGroupContext.value === props.value && !isDisabled,
|
|
131
|
-
disabled: isDisabled || false,
|
|
132
|
-
};
|
|
133
|
-
return {
|
|
134
|
-
props: {
|
|
135
|
-
value,
|
|
136
|
-
label,
|
|
137
|
-
subtext,
|
|
138
|
-
labelPosition,
|
|
139
|
-
...rest,
|
|
140
|
-
ref: buttonRef,
|
|
141
|
-
...pressable.props,
|
|
142
|
-
accessibilityRole: 'radio',
|
|
143
|
-
accessibilityLabel: accessibilityLabel ?? label,
|
|
144
|
-
accessibilityHint: accessibilityHint ?? subtext,
|
|
145
|
-
accessibilityState: getAccessibilityState(state.disabled, state.selected, accessibilityState),
|
|
146
|
-
accessibilityActions: accessibilityActionsProp,
|
|
147
|
-
accessibilityPositionInSet: accessibilityPositionInSet ?? radioGroupContext.values.findIndex((x) => x == value) + 1,
|
|
148
|
-
accessibilitySetSize: accessibilitySetSize ?? radioGroupContext.values.length,
|
|
149
|
-
focusable: !state.disabled,
|
|
150
|
-
disabled: isDisabled,
|
|
151
|
-
onAccessibilityAction: onAccessibilityAction,
|
|
152
|
-
...onKeyDownProps,
|
|
153
|
-
},
|
|
154
|
-
state: state,
|
|
98
|
+
React.useEffect(() => {
|
|
99
|
+
if (value === radioGroupContext.value && !isDisabled) {
|
|
100
|
+
radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
// Explicitly only run on mount and unmount
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
radioGroupContext.addRadioValue(value);
|
|
106
|
+
return () => {
|
|
107
|
+
radioGroupContext.removeRadioValue(value);
|
|
155
108
|
};
|
|
109
|
+
}, []);
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
if (isDisabled) {
|
|
112
|
+
radioGroupContext.removeRadioEnabledValue(value);
|
|
113
|
+
} else {
|
|
114
|
+
radioGroupContext.addRadioEnabledValue(value);
|
|
115
|
+
}
|
|
116
|
+
}, [isDisabled]);
|
|
117
|
+
const isRTL = react_native_1.I18nManager.isRTL;
|
|
118
|
+
const onInvoke = React.useCallback(
|
|
119
|
+
(e) => {
|
|
120
|
+
if (e.nativeEvent.key in DirectionalArrowKeys) {
|
|
121
|
+
const length = radioGroupContext.enabledValues.length;
|
|
122
|
+
const previous =
|
|
123
|
+
e.nativeEvent.key === DirectionalArrowKeys.ArrowUp ||
|
|
124
|
+
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowRight : e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft);
|
|
125
|
+
const next =
|
|
126
|
+
e.nativeEvent.key === DirectionalArrowKeys.ArrowDown ||
|
|
127
|
+
(isRTL ? e.nativeEvent.key === DirectionalArrowKeys.ArrowLeft : e.nativeEvent.key === DirectionalArrowKeys.ArrowRight);
|
|
128
|
+
const currRadioIndex = radioGroupContext.enabledValues.indexOf(radioGroupContext.value);
|
|
129
|
+
let newCurrRadioIndex;
|
|
130
|
+
if (next) {
|
|
131
|
+
newCurrRadioIndex = (currRadioIndex + 1) % length;
|
|
132
|
+
radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
|
|
133
|
+
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
|
|
134
|
+
} else if (previous) {
|
|
135
|
+
newCurrRadioIndex = (currRadioIndex - 1 + length) % length;
|
|
136
|
+
radioGroupContext.onChange && radioGroupContext.onChange(radioGroupContext.enabledValues[newCurrRadioIndex]);
|
|
137
|
+
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(true);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
[radioGroupContext],
|
|
142
|
+
);
|
|
143
|
+
// Sets the updated selected button ref and focus if this Radio is selected via arrow key.
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
if (radioGroupContext.invoked && value === radioGroupContext.value && !isDisabled) {
|
|
146
|
+
radioGroupContext.updateSelectedButtonRef && componentRef && radioGroupContext.updateSelectedButtonRef(componentRef);
|
|
147
|
+
componentRef?.current?.focus();
|
|
148
|
+
radioGroupContext.updateInvoked && radioGroupContext.updateInvoked(false);
|
|
149
|
+
}
|
|
150
|
+
}, [radioGroupContext.invoked]);
|
|
151
|
+
const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
152
|
+
// Explicitly override onKeyDown to override the native behavior of moving focus with arrow keys.
|
|
153
|
+
const onKeyDownProps = (0, interactive_hooks_1.useKeyDownProps)(onInvoke, ...keys);
|
|
154
|
+
// Ensure focus is placed on button after click
|
|
155
|
+
const changeSelectionWithFocus = (0, interactive_hooks_1.useOnPressWithFocus)(componentRef, changeSelection);
|
|
156
|
+
/* Radio changes selection when focus is moved between each RadioButton and on a click */
|
|
157
|
+
const pressable = (0, interactive_hooks_1.usePressableState)({
|
|
158
|
+
...rest,
|
|
159
|
+
onPress: changeSelectionWithFocus,
|
|
160
|
+
onFocus: changeSelection,
|
|
161
|
+
});
|
|
162
|
+
const accessibilityActionsProp = React.useMemo(
|
|
163
|
+
() => (accessibilityActions ? [...defaultAccessibilityActions, ...accessibilityActions] : defaultAccessibilityActions),
|
|
164
|
+
[accessibilityActions],
|
|
165
|
+
);
|
|
166
|
+
// Used when creating accessibility properties in mergeSettings below
|
|
167
|
+
const onAccessibilityAction = React.useCallback(
|
|
168
|
+
(event) => {
|
|
169
|
+
switch (event.nativeEvent.actionName) {
|
|
170
|
+
case 'Select':
|
|
171
|
+
changeSelection();
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
[changeSelection],
|
|
176
|
+
);
|
|
177
|
+
const state = {
|
|
178
|
+
...pressable.state,
|
|
179
|
+
selected: radioGroupContext.value === props.value && !isDisabled,
|
|
180
|
+
disabled: isDisabled || false,
|
|
181
|
+
};
|
|
182
|
+
return {
|
|
183
|
+
props: {
|
|
184
|
+
value,
|
|
185
|
+
label,
|
|
186
|
+
subtext,
|
|
187
|
+
labelPosition,
|
|
188
|
+
...rest,
|
|
189
|
+
ref: buttonRef,
|
|
190
|
+
...pressable.props,
|
|
191
|
+
accessibilityRole: 'radio',
|
|
192
|
+
accessibilityLabel: accessibilityLabel ?? label,
|
|
193
|
+
accessibilityHint: accessibilityHint ?? subtext,
|
|
194
|
+
accessibilityState: getAccessibilityState(state.disabled, state.selected, accessibilityState),
|
|
195
|
+
accessibilityActions: accessibilityActionsProp,
|
|
196
|
+
accessibilityPosInSet: accessibilityPosInSet ?? radioGroupContext.values.findIndex((x) => x == value) + 1,
|
|
197
|
+
accessibilitySetSize: accessibilitySetSize ?? radioGroupContext.values.length,
|
|
198
|
+
focusable: !state.disabled,
|
|
199
|
+
disabled: isDisabled,
|
|
200
|
+
onAccessibilityAction: onAccessibilityAction,
|
|
201
|
+
...onKeyDownProps,
|
|
202
|
+
},
|
|
203
|
+
state: state,
|
|
204
|
+
};
|
|
156
205
|
};
|
|
157
206
|
exports.useRadio = useRadio;
|
|
158
207
|
const getAccessibilityState = (0, framework_1.memoize)(getAccessibilityStateWorker);
|
|
159
208
|
function getAccessibilityStateWorker(disabled, selected, accessibilityState) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
209
|
+
if (accessibilityState) {
|
|
210
|
+
return { disabled, selected, ...accessibilityState };
|
|
211
|
+
}
|
|
212
|
+
return { disabled, selected };
|
|
164
213
|
}
|
|
165
|
-
//# sourceMappingURL=useRadio.win32.js.map
|
|
214
|
+
//# sourceMappingURL=useRadio.win32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRadio.win32.js","sourceRoot":"","sources":["../../src/Radio/useRadio.win32.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRadio.win32.js","sourceRoot":"","sources":["../../src/Radio/useRadio.win32.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,KAAK,kCAAc;AAE/B,+CAA2C;AAE3C,gEAA2D;AAE3D,gFAAwI;AAGxI,uEAAuE;AAEvE,MAAM,2BAA2B,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEzD,IAAK,oBAKJ;AALD,WAAK,oBAAoB;IACvB,2CAAmB,CAAA;IACnB,+CAAuB,CAAA;IACvB,iDAAyB,CAAA;IACzB,+CAAuB,CAAA;AAAC,CAC1B,EALK,oBAAoB,KAApB,oBAAoB,QAKxB;AAEM,MAAM,QAAQ,GAAG,CAAC,KAAiB,EAAa,EAAE,CAAC;IACxD,MAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE/C,2GAA2G;IAC3G,MAAM,iBAAiB,GAAG,IAAA,wCAAoB,GAAE,CAAC;IAEjD,MAAM,EACJ,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,GAAG,mBAAmB,EAClC,qBAAqB,EACrB,oBAAoB,EACpB,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,KAAK,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAE5F,MAAM,UAAU,GAAG,iBAAiB,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAE1D,MAAM,SAAS,GAAG,IAAA,uCAAmB,EAAC,YAAY,CAAC,CAAC;IAEpD,qFAAqF;IACrF,MAAM,eAAe,GAA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AK,CAAC,QAAQ;YAC1B,QAAQ,EAAE,UAAU;YACpB,qBAAqB,EAAE,qBAAqB;YAC5C,GAAG,cAAc;SAClB;QACD,KAAK,EAAE,KAAK;KACb,CAAC;AAAA,CACH,CAAC;AA/JW,QAAA,QAAQ,GAAR,QAAQ,CA+JnB;AAEF,MAAM,qBAAqB,GAAG,IAAA,mBAAO,EAAC,2BAA2B,CAAC,CAAC;AACnE,SAAS,2BAA2B,CAAC,QAAiB,EAAE,QAAiB,EAAE,kBAAuC,EAAE;IAClH,IAAI,kBAAkB,EAAE,CAAC;QACvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAAA,CAC/B"}
|
|
@@ -8,5 +8,10 @@ import type { RadioGroupProps, RadioGroupState } from './RadioGroup.types';
|
|
|
8
8
|
* @returns Whether the styles that are assigned to the layer should be applied to the radiogroup
|
|
9
9
|
*/
|
|
10
10
|
export declare const radioGroupLookup: (layer: string, state: RadioGroupState, userProps: RadioGroupProps) => boolean;
|
|
11
|
-
export declare const RadioGroup: import(
|
|
12
|
-
|
|
11
|
+
export declare const RadioGroup: import('@fluentui-react-native/framework').ComposableComponent<
|
|
12
|
+
RadioGroupProps,
|
|
13
|
+
import('./RadioGroup.types').RadioGroupSlotProps,
|
|
14
|
+
import('./RadioGroup.types').RadioGroupTokens,
|
|
15
|
+
import('@fluentui-react-native/framework').ObjectBase
|
|
16
|
+
>;
|
|
17
|
+
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAkB,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAM3F;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,gFAQ5B,CAAC;AAEF,eAAO,MAAM,UAAU,yOAqDrB,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.RadioGroup = exports.radioGroupLookup = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
4
|
+
const jsx_runtime_1 = require('@fluentui-react-native/framework-base/jsx-runtime');
|
|
5
|
+
const react_native_1 = require('react-native');
|
|
6
|
+
const focus_zone_1 = require('@fluentui-react-native/focus-zone');
|
|
7
|
+
const framework_1 = require('@fluentui-react-native/framework');
|
|
8
|
+
const text_1 = require('@fluentui-react-native/text');
|
|
9
|
+
const RadioGroup_styling_1 = require('./RadioGroup.styling');
|
|
10
|
+
const RadioGroup_types_1 = require('./RadioGroup.types');
|
|
11
|
+
const radioGroupContext_1 = require('./radioGroupContext');
|
|
12
|
+
const useRadioGroup_1 = require('./useRadioGroup');
|
|
13
|
+
const useRadioGroupContextValue_1 = require('./useRadioGroupContextValue');
|
|
13
14
|
/**
|
|
14
15
|
* A function which determines if a set of styles should be applied to the component given the current state and props of the radiogroup.
|
|
15
16
|
*
|
|
@@ -19,44 +20,60 @@ const useRadioGroupContextValue_1 = require("./useRadioGroupContextValue");
|
|
|
19
20
|
* @returns Whether the styles that are assigned to the layer should be applied to the radiogroup
|
|
20
21
|
*/
|
|
21
22
|
const radioGroupLookup = (layer, state, userProps) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
return (
|
|
24
|
+
state[layer] ||
|
|
25
|
+
userProps[layer] ||
|
|
26
|
+
(!(react_native_1.Platform.OS === 'win32' || react_native_1.Platform.OS === 'android') &&
|
|
27
|
+
layer === 'isHorizontal' &&
|
|
28
|
+
(userProps['layout'] === 'horizontal' || userProps['layout'] === 'horizontal-stacked'))
|
|
29
|
+
);
|
|
27
30
|
};
|
|
28
31
|
exports.radioGroupLookup = radioGroupLookup;
|
|
29
32
|
exports.RadioGroup = (0, framework_1.compose)({
|
|
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
|
-
|
|
33
|
+
displayName: RadioGroup_types_1.radioGroupName,
|
|
34
|
+
...RadioGroup_styling_1.stylingSettings,
|
|
35
|
+
slots: {
|
|
36
|
+
root: react_native_1.View,
|
|
37
|
+
label: react_native_1.View,
|
|
38
|
+
labelText: text_1.TextV1,
|
|
39
|
+
required: text_1.TextV1,
|
|
40
|
+
options: react_native_1.View,
|
|
41
|
+
container: focus_zone_1.FocusZone,
|
|
42
|
+
},
|
|
43
|
+
useRender: (userProps, useSlots) => {
|
|
44
|
+
const radioGroup = (0, useRadioGroup_1.useRadioGroup)(userProps);
|
|
45
|
+
const contextValue = (0, useRadioGroupContextValue_1.useRadioGroupContextValue)(radioGroup.state);
|
|
46
|
+
const Slots = useSlots(userProps, (layer) => (0, exports.radioGroupLookup)(layer, radioGroup.state, userProps));
|
|
47
|
+
return (final, ...children) => {
|
|
48
|
+
if (!radioGroup.state) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const { label, required, defaultTabbableElement, isCircularNavigation, ...mergedProps } = (0, framework_1.mergeProps)(
|
|
52
|
+
radioGroup.props,
|
|
53
|
+
final,
|
|
54
|
+
);
|
|
55
|
+
const labelComponent = jsx_runtime_1.jsxs(Slots.label, {
|
|
56
|
+
children: [
|
|
57
|
+
jsx_runtime_1.jsx(Slots.labelText, { children: label }, 'label'),
|
|
58
|
+
!!required && jsx_runtime_1.jsx(Slots.required, { children: '*' }),
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
const isFocusZoneImplemented = ['macos', 'win32'].includes(react_native_1.Platform.OS);
|
|
62
|
+
const radioGroupContent = jsx_runtime_1.jsx(Slots.options, { children: children });
|
|
63
|
+
const radioGroupContentWithFocusZone = jsx_runtime_1.jsx(Slots.container, {
|
|
64
|
+
disabled: radioGroup.state.selectedButtonDisabled,
|
|
65
|
+
isCircularNavigation: true,
|
|
66
|
+
defaultTabbableElement: defaultTabbableElement,
|
|
67
|
+
children: radioGroupContent,
|
|
68
|
+
});
|
|
69
|
+
return jsx_runtime_1.jsx(radioGroupContext_1.RadioGroupProvider, {
|
|
70
|
+
value: contextValue,
|
|
71
|
+
children: jsx_runtime_1.jsxs(Slots.root, {
|
|
72
|
+
...mergedProps,
|
|
73
|
+
children: [label && labelComponent, isFocusZoneImplemented ? radioGroupContentWithFocusZone : radioGroupContent],
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
},
|
|
61
78
|
});
|
|
62
|
-
//# sourceMappingURL=RadioGroup.js.map
|
|
79
|
+
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../src/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../src/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":";;;;AAEA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upTokens, RadioGroupSlotProps, RadioGroupProps } from './RadioGroup.types';
|
|
3
3
|
export declare const radioGroupStates: (keyof RadioGroupTokens)[];
|
|
4
4
|
export declare const stylingSettings: UseStylingOptions<RadioGroupProps, RadioGroupSlotProps, RadioGroupTokens>;
|
|
5
|
-
//# sourceMappingURL=RadioGroup.styling.d.ts.map
|
|
5
|
+
//# sourceMappingURL=RadioGroup.styling.d.ts.map
|