@fluentui/react-radio 0.0.0-nightly-20220302-0405.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. package/CHANGELOG.json +305 -0
  2. package/CHANGELOG.md +106 -0
  3. package/LICENSE +15 -0
  4. package/README.md +5 -0
  5. package/Spec.md +292 -0
  6. package/dist/react-radio.d.ts +183 -0
  7. package/lib/Radio.d.ts +1 -0
  8. package/lib/Radio.js +2 -0
  9. package/lib/Radio.js.map +1 -0
  10. package/lib/RadioGroup.d.ts +1 -0
  11. package/lib/RadioGroup.js +2 -0
  12. package/lib/RadioGroup.js.map +1 -0
  13. package/lib/components/Radio/Radio.d.ts +6 -0
  14. package/lib/components/Radio/Radio.js +15 -0
  15. package/lib/components/Radio/Radio.js.map +1 -0
  16. package/lib/components/Radio/Radio.types.d.ts +52 -0
  17. package/lib/components/Radio/Radio.types.js +2 -0
  18. package/lib/components/Radio/Radio.types.js.map +1 -0
  19. package/lib/components/Radio/index.d.ts +5 -0
  20. package/lib/components/Radio/index.js +6 -0
  21. package/lib/components/Radio/index.js.map +1 -0
  22. package/lib/components/Radio/renderRadio.d.ts +5 -0
  23. package/lib/components/Radio/renderRadio.js +18 -0
  24. package/lib/components/Radio/renderRadio.js.map +1 -0
  25. package/lib/components/Radio/useRadio.d.ts +12 -0
  26. package/lib/components/Radio/useRadio.js +76 -0
  27. package/lib/components/Radio/useRadio.js.map +1 -0
  28. package/lib/components/Radio/useRadioStyles.d.ts +6 -0
  29. package/lib/components/Radio/useRadioStyles.js +174 -0
  30. package/lib/components/Radio/useRadioStyles.js.map +1 -0
  31. package/lib/components/RadioGroup/RadioGroup.d.ts +6 -0
  32. package/lib/components/RadioGroup/RadioGroup.js +15 -0
  33. package/lib/components/RadioGroup/RadioGroup.js.map +1 -0
  34. package/lib/components/RadioGroup/RadioGroup.types.d.ts +58 -0
  35. package/lib/components/RadioGroup/RadioGroup.types.js +2 -0
  36. package/lib/components/RadioGroup/RadioGroup.types.js.map +1 -0
  37. package/lib/components/RadioGroup/index.d.ts +5 -0
  38. package/lib/components/RadioGroup/index.js +6 -0
  39. package/lib/components/RadioGroup/index.js.map +1 -0
  40. package/lib/components/RadioGroup/renderRadioGroup.d.ts +5 -0
  41. package/lib/components/RadioGroup/renderRadioGroup.js +18 -0
  42. package/lib/components/RadioGroup/renderRadioGroup.js.map +1 -0
  43. package/lib/components/RadioGroup/useRadioGroup.d.ts +12 -0
  44. package/lib/components/RadioGroup/useRadioGroup.js +51 -0
  45. package/lib/components/RadioGroup/useRadioGroup.js.map +1 -0
  46. package/lib/components/RadioGroup/useRadioGroupStyles.d.ts +6 -0
  47. package/lib/components/RadioGroup/useRadioGroupStyles.js +24 -0
  48. package/lib/components/RadioGroup/useRadioGroupStyles.js.map +1 -0
  49. package/lib/contexts/RadioGroupContext.d.ts +7 -0
  50. package/lib/contexts/RadioGroupContext.js +7 -0
  51. package/lib/contexts/RadioGroupContext.js.map +1 -0
  52. package/lib/index.d.ts +3 -0
  53. package/lib/index.js +4 -0
  54. package/lib/index.js.map +1 -0
  55. package/lib/tsdoc-metadata.json +11 -0
  56. package/lib-commonjs/Radio.d.ts +1 -0
  57. package/lib-commonjs/Radio.js +10 -0
  58. package/lib-commonjs/Radio.js.map +1 -0
  59. package/lib-commonjs/RadioGroup.d.ts +1 -0
  60. package/lib-commonjs/RadioGroup.js +10 -0
  61. package/lib-commonjs/RadioGroup.js.map +1 -0
  62. package/lib-commonjs/components/Radio/Radio.d.ts +6 -0
  63. package/lib-commonjs/components/Radio/Radio.js +26 -0
  64. package/lib-commonjs/components/Radio/Radio.js.map +1 -0
  65. package/lib-commonjs/components/Radio/Radio.types.d.ts +52 -0
  66. package/lib-commonjs/components/Radio/Radio.types.js +6 -0
  67. package/lib-commonjs/components/Radio/Radio.types.js.map +1 -0
  68. package/lib-commonjs/components/Radio/index.d.ts +5 -0
  69. package/lib-commonjs/components/Radio/index.js +18 -0
  70. package/lib-commonjs/components/Radio/index.js.map +1 -0
  71. package/lib-commonjs/components/Radio/renderRadio.d.ts +5 -0
  72. package/lib-commonjs/components/Radio/renderRadio.js +29 -0
  73. package/lib-commonjs/components/Radio/renderRadio.js.map +1 -0
  74. package/lib-commonjs/components/Radio/useRadio.d.ts +12 -0
  75. package/lib-commonjs/components/Radio/useRadio.js +90 -0
  76. package/lib-commonjs/components/Radio/useRadio.js.map +1 -0
  77. package/lib-commonjs/components/Radio/useRadioStyles.d.ts +6 -0
  78. package/lib-commonjs/components/Radio/useRadioStyles.js +186 -0
  79. package/lib-commonjs/components/Radio/useRadioStyles.js.map +1 -0
  80. package/lib-commonjs/components/RadioGroup/RadioGroup.d.ts +6 -0
  81. package/lib-commonjs/components/RadioGroup/RadioGroup.js +26 -0
  82. package/lib-commonjs/components/RadioGroup/RadioGroup.js.map +1 -0
  83. package/lib-commonjs/components/RadioGroup/RadioGroup.types.d.ts +58 -0
  84. package/lib-commonjs/components/RadioGroup/RadioGroup.types.js +6 -0
  85. package/lib-commonjs/components/RadioGroup/RadioGroup.types.js.map +1 -0
  86. package/lib-commonjs/components/RadioGroup/index.d.ts +5 -0
  87. package/lib-commonjs/components/RadioGroup/index.js +18 -0
  88. package/lib-commonjs/components/RadioGroup/index.js.map +1 -0
  89. package/lib-commonjs/components/RadioGroup/renderRadioGroup.d.ts +5 -0
  90. package/lib-commonjs/components/RadioGroup/renderRadioGroup.js +30 -0
  91. package/lib-commonjs/components/RadioGroup/renderRadioGroup.js.map +1 -0
  92. package/lib-commonjs/components/RadioGroup/useRadioGroup.d.ts +12 -0
  93. package/lib-commonjs/components/RadioGroup/useRadioGroup.js +62 -0
  94. package/lib-commonjs/components/RadioGroup/useRadioGroup.js.map +1 -0
  95. package/lib-commonjs/components/RadioGroup/useRadioGroupStyles.d.ts +6 -0
  96. package/lib-commonjs/components/RadioGroup/useRadioGroupStyles.js +34 -0
  97. package/lib-commonjs/components/RadioGroup/useRadioGroupStyles.js.map +1 -0
  98. package/lib-commonjs/contexts/RadioGroupContext.d.ts +7 -0
  99. package/lib-commonjs/contexts/RadioGroupContext.js +15 -0
  100. package/lib-commonjs/contexts/RadioGroupContext.js.map +1 -0
  101. package/lib-commonjs/index.d.ts +3 -0
  102. package/lib-commonjs/index.js +14 -0
  103. package/lib-commonjs/index.js.map +1 -0
  104. package/package.json +65 -0
@@ -0,0 +1 @@
1
+ export * from './components/RadioGroup/index';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./components/RadioGroup/index"), exports);
10
+ //# sourceMappingURL=RadioGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["RadioGroup.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/RadioGroup/index';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
2
+ import type { RadioProps } from './Radio.types';
3
+ /**
4
+ * Radio component is a wrapper for a radio button with a label.
5
+ */
6
+ export declare const Radio: ForwardRefComponent<RadioProps>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Radio = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const renderRadio_1 = /*#__PURE__*/require("./renderRadio");
11
+
12
+ const useRadio_1 = /*#__PURE__*/require("./useRadio");
13
+
14
+ const useRadioStyles_1 = /*#__PURE__*/require("./useRadioStyles");
15
+ /**
16
+ * Radio component is a wrapper for a radio button with a label.
17
+ */
18
+
19
+
20
+ exports.Radio = /*#__PURE__*/React.forwardRef((props, ref) => {
21
+ const state = useRadio_1.useRadio_unstable(props, ref);
22
+ useRadioStyles_1.useRadioStyles_unstable(state);
23
+ return renderRadio_1.renderRadio_unstable(state);
24
+ });
25
+ exports.Radio.displayName = 'Radio';
26
+ //# sourceMappingURL=Radio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Radio/Radio.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAGA,MAAA,aAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AACA,MAAA,UAAA,gBAAA,OAAA,CAAA,YAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;AAEA;;AAEG;;;AACU,OAAA,CAAA,KAAA,gBAAyC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACpF,QAAM,KAAK,GAAG,UAAA,CAAA,iBAAA,CAAkB,KAAlB,EAAyB,GAAzB,CAAd;AAEA,EAAA,gBAAA,CAAA,uBAAA,CAAwB,KAAxB;AACA,SAAO,aAAA,CAAA,oBAAA,CAAqB,KAArB,CAAP;AACD,CALqD,CAAzC;AAOb,OAAA,CAAA,KAAA,CAAM,WAAN,GAAoB,OAApB","sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { RadioProps } from './Radio.types';\nimport { renderRadio_unstable } from './renderRadio';\nimport { useRadio_unstable } from './useRadio';\nimport { useRadioStyles_unstable } from './useRadioStyles';\n\n/**\n * Radio component is a wrapper for a radio button with a label.\n */\nexport const Radio: ForwardRefComponent<RadioProps> = React.forwardRef((props, ref) => {\n const state = useRadio_unstable(props, ref);\n\n useRadioStyles_unstable(state);\n return renderRadio_unstable(state);\n});\n\nRadio.displayName = 'Radio';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,52 @@
1
+ import { Label } from '@fluentui/react-label';
2
+ import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
3
+ export declare type RadioSlots = {
4
+ /**
5
+ * The root element of the Radio.
6
+ *
7
+ * The root slot receives the `className` and `style` specified directly on the `<Radio>`.
8
+ * All other native props will be applied to the primary slot: `input`
9
+ */
10
+ root: NonNullable<Slot<'span'>>;
11
+ /**
12
+ * The Radio's label.
13
+ */
14
+ label: Slot<typeof Label>;
15
+ /**
16
+ * Hidden input that handles the radio's functionality.
17
+ *
18
+ * This is the PRIMARY slot: all native properties specified directly on `<Radio>` will be applied to this slot,
19
+ * except `className` and `style`, which remain on the root slot.
20
+ */
21
+ input: NonNullable<Slot<'input'>>;
22
+ /**
23
+ * A circle outline, with a filled circle icon inside when the Radio is checked.
24
+ */
25
+ indicator: NonNullable<Slot<'div'>>;
26
+ };
27
+ /**
28
+ * Radio Props
29
+ */
30
+ export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input'>, 'size'> & {
31
+ /**
32
+ * The value of the RadioGroup when this Radio item is selected.
33
+ */
34
+ value?: string;
35
+ /**
36
+ * The position of the label relative to the radio indicator.
37
+ *
38
+ * This defaults to `after` unless the Radio is inside a RadioGroup with `layout="horizontalStacked"`,
39
+ * in which case it defaults to `below`.
40
+ *
41
+ * @defaultvalue after
42
+ */
43
+ labelPosition?: 'after' | 'below';
44
+ /**
45
+ * Disable this Radio item.
46
+ */
47
+ disabled?: boolean;
48
+ };
49
+ /**
50
+ * State used in rendering Radio
51
+ */
52
+ export declare type RadioState = ComponentState<RadioSlots> & Required<Pick<RadioProps, 'labelPosition'>>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=Radio.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ export * from './Radio';
2
+ export * from './Radio.types';
3
+ export * from './renderRadio';
4
+ export * from './useRadio';
5
+ export * from './useRadioStyles';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./Radio"), exports);
10
+
11
+ tslib_1.__exportStar(require("./Radio.types"), exports);
12
+
13
+ tslib_1.__exportStar(require("./renderRadio"), exports);
14
+
15
+ tslib_1.__exportStar(require("./useRadio"), exports);
16
+
17
+ tslib_1.__exportStar(require("./useRadioStyles"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Radio/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Radio';\nexport * from './Radio.types';\nexport * from './renderRadio';\nexport * from './useRadio';\nexport * from './useRadioStyles';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,5 @@
1
+ import type { RadioState } from './Radio.types';
2
+ /**
3
+ * Render the final JSX of Radio
4
+ */
5
+ export declare const renderRadio_unstable: (state: RadioState) => JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderRadio_unstable = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+ /**
12
+ * Render the final JSX of Radio
13
+ */
14
+
15
+
16
+ const renderRadio_unstable = state => {
17
+ const {
18
+ slots,
19
+ slotProps
20
+ } = react_utilities_1.getSlots(state);
21
+ return React.createElement(slots.root, { ...slotProps.root
22
+ }, React.createElement(slots.input, { ...slotProps.input
23
+ }), React.createElement(slots.indicator, { ...slotProps.indicator
24
+ }), slots.label && React.createElement(slots.label, { ...slotProps.label
25
+ }));
26
+ };
27
+
28
+ exports.renderRadio_unstable = renderRadio_unstable;
29
+ //# sourceMappingURL=renderRadio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Radio/renderRadio.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,oBAAoB,GAAI,KAAD,IAAsB;AACxD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,iBAAA,CAAA,QAAA,CAAqB,KAArB,CAA7B;AAEA,SACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CADF,EAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,SAAP,EAAgB,EAAA,GAAK,SAAS,CAAC;AAAf,GAAhB,CAFF,EAGG,KAAK,CAAC,KAAN,IAAe,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CAHlB,CADF;AAOD,CAVM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { RadioSlots, RadioState } from './Radio.types';\n\n/**\n * Render the final JSX of Radio\n */\nexport const renderRadio_unstable = (state: RadioState) => {\n const { slots, slotProps } = getSlots<RadioSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <slots.input {...slotProps.input} />\n <slots.indicator {...slotProps.indicator} />\n {slots.label && <slots.label {...slotProps.label} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { RadioProps, RadioState } from './Radio.types';
3
+ /**
4
+ * Create the state required to render Radio.
5
+ *
6
+ * The returned state can be modified with hooks such as useRadioStyles_unstable,
7
+ * before being passed to renderRadio_unstable.
8
+ *
9
+ * @param props - props from this instance of Radio
10
+ * @param ref - reference to `<input>` element of Radio
11
+ */
12
+ export declare const useRadio_unstable: (props: RadioProps, ref: React.Ref<HTMLInputElement>) => RadioState;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useRadio_unstable = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
11
+
12
+ const react_label_1 = /*#__PURE__*/require("@fluentui/react-label");
13
+
14
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
15
+
16
+ const RadioGroupContext_1 = /*#__PURE__*/require("../../contexts/RadioGroupContext");
17
+ /**
18
+ * Create the state required to render Radio.
19
+ *
20
+ * The returned state can be modified with hooks such as useRadioStyles_unstable,
21
+ * before being passed to renderRadio_unstable.
22
+ *
23
+ * @param props - props from this instance of Radio
24
+ * @param ref - reference to `<input>` element of Radio
25
+ */
26
+
27
+
28
+ const useRadio_unstable = (props, ref) => {
29
+ const group = React.useContext(RadioGroupContext_1.RadioGroupContext);
30
+ const {
31
+ name = group.name,
32
+ checked = group.value !== undefined ? group.value === props.value : undefined,
33
+ defaultChecked = group.defaultValue !== undefined ? group.defaultValue === props.value : undefined,
34
+ labelPosition = group.layout === 'horizontalStacked' ? 'below' : 'after',
35
+ disabled = group.disabled,
36
+ required
37
+ } = props;
38
+ const nativeProps = react_utilities_1.getPartitionedNativeProps({
39
+ props,
40
+ primarySlotTagName: 'input',
41
+ excludedPropNames: ['checked', 'defaultChecked']
42
+ });
43
+ const root = react_utilities_1.resolveShorthand(props.root, {
44
+ required: true,
45
+ defaultProps: nativeProps.root
46
+ });
47
+ const input = react_utilities_1.resolveShorthand(props.input, {
48
+ required: true,
49
+ defaultProps: {
50
+ ref,
51
+ type: 'radio',
52
+ id: react_utilities_1.useId('radio-', nativeProps.primary.id),
53
+ name,
54
+ checked,
55
+ defaultChecked,
56
+ disabled,
57
+ ...nativeProps.primary
58
+ }
59
+ });
60
+ const label = react_utilities_1.resolveShorthand(props.label, {
61
+ defaultProps: {
62
+ htmlFor: input.id,
63
+ disabled,
64
+ required
65
+ }
66
+ });
67
+ const indicator = react_utilities_1.resolveShorthand(props.indicator, {
68
+ required: true,
69
+ defaultProps: {
70
+ 'aria-hidden': true,
71
+ children: React.createElement(react_icons_1.CircleFilled, null)
72
+ }
73
+ });
74
+ return {
75
+ labelPosition,
76
+ components: {
77
+ root: 'span',
78
+ input: 'input',
79
+ label: react_label_1.Label,
80
+ indicator: 'div'
81
+ },
82
+ root,
83
+ input,
84
+ label,
85
+ indicator
86
+ };
87
+ };
88
+
89
+ exports.useRadio_unstable = useRadio_unstable;
90
+ //# sourceMappingURL=useRadio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Radio/useRadio.tsx"],"names":[],"mappings":"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","sourcesContent":["import * as React from 'react';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { getPartitionedNativeProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { RadioGroupContext } from '../../contexts/RadioGroupContext';\nimport type { RadioProps, RadioState } from './Radio.types';\n\n/**\n * Create the state required to render Radio.\n *\n * The returned state can be modified with hooks such as useRadioStyles_unstable,\n * before being passed to renderRadio_unstable.\n *\n * @param props - props from this instance of Radio\n * @param ref - reference to `<input>` element of Radio\n */\nexport const useRadio_unstable = (props: RadioProps, ref: React.Ref<HTMLInputElement>): RadioState => {\n const group = React.useContext(RadioGroupContext);\n\n const {\n name = group.name,\n checked = group.value !== undefined ? group.value === props.value : undefined,\n defaultChecked = group.defaultValue !== undefined ? group.defaultValue === props.value : undefined,\n labelPosition = group.layout === 'horizontalStacked' ? 'below' : 'after',\n disabled = group.disabled,\n required,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked'],\n });\n\n const root = resolveShorthand(props.root, {\n required: true,\n defaultProps: nativeProps.root,\n });\n\n const input = resolveShorthand(props.input, {\n required: true,\n defaultProps: {\n ref,\n type: 'radio',\n id: useId('radio-', nativeProps.primary.id),\n name,\n checked,\n defaultChecked,\n disabled,\n ...nativeProps.primary,\n },\n });\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n htmlFor: input.id,\n disabled,\n required,\n },\n });\n\n const indicator = resolveShorthand(props.indicator, {\n required: true,\n defaultProps: {\n 'aria-hidden': true,\n children: <CircleFilled />,\n },\n });\n\n return {\n labelPosition,\n components: {\n root: 'span',\n input: 'input',\n label: Label,\n indicator: 'div',\n },\n root,\n input,\n label,\n indicator,\n };\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ import type { RadioState } from './Radio.types';
2
+ export declare const radioClassName = "fui-Radio";
3
+ /**
4
+ * Apply styling to the Radio slots based on the state
5
+ */
6
+ export declare const useRadioStyles_unstable: (state: RadioState) => void;
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useRadioStyles_unstable = exports.radioClassName = void 0;
7
+
8
+ const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
9
+
10
+ const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
11
+
12
+ const react_1 = /*#__PURE__*/require("@griffel/react");
13
+
14
+ exports.radioClassName = 'fui-Radio';
15
+ const indicatorClassName = 'fui-Radio__indicator';
16
+ const labelClassName = 'fui-Radio__label'; // TODO replace these spacing constants with theme values once they're on the theme
17
+
18
+ const spacingHorizontalS = '8px';
19
+ const spacingHorizontalM = '12px'; // The indicator size is used by the indicator and label styles
20
+
21
+ const indicatorSize = '16px';
22
+ /**
23
+ * Styles for the root slot
24
+ */
25
+
26
+ const useRootStyles = /*#__PURE__*/react_1.__styles({
27
+ "base": {
28
+ "mc9l5x": "ftuwxu6",
29
+ "qhf8xq": "f10pi13n",
30
+ "i8kkvl": "f4akndk",
31
+ "z8tnut": "fp9bwmr",
32
+ "z189sj": ["f19lj068", "f177v4lu"],
33
+ "Byoj8tv": "f150uoa4",
34
+ "uwmqm3": ["f177v4lu", "f19lj068"]
35
+ },
36
+ "vertical": {
37
+ "Beiy3e4": "f1vx9l62",
38
+ "Bt984gj": "f122n59",
39
+ "Belr9w4": "fe5j3v"
40
+ },
41
+ "focusIndicator": {
42
+ "B486eqv": "f2hkw1w",
43
+ "c2y4jd": "fsofd9k",
44
+ "B8vm7ur": "f12sql3b",
45
+ "f4hv8x": "f1i4q40k",
46
+ "Gpan81": "fcrbge9",
47
+ "z7afg": "ft464mn",
48
+ "rsjj6t": "fskqmiq",
49
+ "Bqsd8kq": "f2gy8jn",
50
+ "sfhsbh": "f1pke3uf",
51
+ "Bugh3ej": "f18xdlq9",
52
+ "hpanx6": "f1114nks",
53
+ "Bjkpy09": "f1unftzx",
54
+ "Jxg1p8": "f8rjbh6",
55
+ "Bc94xmo": ["fxfgh6q", "f8l10fm"],
56
+ "Bj23z95": ["f8l10fm", "fxfgh6q"]
57
+ }
58
+ }, {
59
+ "d": [".ftuwxu6{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}", ".f10pi13n{position:relative;}", ".f4akndk{-webkit-column-gap:12px;column-gap:12px;}", ".fp9bwmr{padding-top:8px;}", ".f19lj068{padding-right:8px;}", ".f177v4lu{padding-left:8px;}", ".f150uoa4{padding-bottom:8px;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".fe5j3v{row-gap:12px;}", "[data-keyboard-nav] .fsofd9k:focus-within{border-color:transparent;}", "[data-keyboard-nav] .f12sql3b:focus-within:after{content:\"\";}", "[data-keyboard-nav] .f1i4q40k:focus-within:after{position:absolute;}", "[data-keyboard-nav] .fcrbge9:focus-within:after{pointer-events:none;}", "[data-keyboard-nav] .ft464mn:focus-within:after{box-sizing:outline-box;}", "[data-keyboard-nav] .fskqmiq:focus-within:after{z-index:1;}", "[data-keyboard-nav] .f2gy8jn:focus-within:after{border-style:solid;}", "[data-keyboard-nav] .f1pke3uf:focus-within:after{border-width:2px;}", "[data-keyboard-nav] .f18xdlq9:focus-within:after{border-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f1114nks:focus-within:after{border-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f1unftzx:focus-within:after{top:-2px;}", "[data-keyboard-nav] .f8rjbh6:focus-within:after{bottom:-2px;}", "[data-keyboard-nav] .fxfgh6q:focus-within:after{left:-2px;}", "[data-keyboard-nav] .f8l10fm:focus-within:after{right:-2px;}"],
60
+ "i": [".f2hkw1w:focus-visible{outline-style:none;}"]
61
+ });
62
+
63
+ const useInputStyles = /*#__PURE__*/react_1.__styles({
64
+ "base": {
65
+ "qhf8xq": "f1euv43f",
66
+ "oyh7mz": ["f1vgc2s3", "f1e31b4d"],
67
+ "Bhzewxz": "f15twtuk",
68
+ "a9b677": "fly5x3f",
69
+ "Bqenvij": "f1l02sjl",
70
+ "B7ck84d": "f1ewtqcl",
71
+ "B6of3ja": "f1hu3pq6",
72
+ "t21cq0": ["f11qmguv", "f1tyq0we"],
73
+ "jrapky": "f19f4twv",
74
+ "Frg6f3": ["f1tyq0we", "f11qmguv"],
75
+ "abs64n": "fk73vx1",
76
+ "By9lhj9": "fg45n87",
77
+ "Bojc29n": "fhb1dn5",
78
+ "p8xby4": "fiegpko",
79
+ "Bmzgt9v": "fdi60kf",
80
+ "un08vv": ["fz3jc1r", "f1fwo01y"],
81
+ "Bluxpkm": "f1m2gv5u",
82
+ "upm9ap": ["f1fwo01y", "fz3jc1r"],
83
+ "Bv6ccmg": "ft7ju8s",
84
+ "w6pjei": "f1ofw0le",
85
+ "drfev3": ["fothmfx", "f13qgzgl"],
86
+ "ujr3xk": "fp5vmb3",
87
+ "Bib2mth": ["f13qgzgl", "fothmfx"],
88
+ "za2ojl": "f1snis2b",
89
+ "Bu1fve0": "ff9psms",
90
+ "B42z6en": ["f1fg9ko4", "fqj7xkg"],
91
+ "mosl6v": "f1vebft2",
92
+ "e3wlmb": ["fqj7xkg", "f1fg9ko4"],
93
+ "swj8lc": "f1vtc7ej",
94
+ "kbzjta": "f1fj62aq",
95
+ "Bnazurh": ["fc4i2ph", "f137d5x6"],
96
+ "Enz1qu": "f1v2xs8c",
97
+ "B4rl0r3": ["f137d5x6", "fc4i2ph"],
98
+ "oi7lcb": "f14bpgh5",
99
+ "bwebxt": "f1ariq71",
100
+ "ax4tcq": ["fu58av6", "f1qj5h2v"],
101
+ "z2by79": "fptcwjq",
102
+ "Bpz2hdf": ["f1qj5h2v", "fu58av6"],
103
+ "Btliz3o": "filss48",
104
+ "Bre5bwy": "frtrqgn",
105
+ "Bayw8dt": ["f1v1lrlm", "fapcpph"],
106
+ "lb5vkw": "f49ptgb",
107
+ "yhmu5n": ["fapcpph", "f1v1lrlm"],
108
+ "Blcfbx4": "fgnwcez",
109
+ "yksgid": "f1l3wt4b",
110
+ "B78hamy": "fdubm5j",
111
+ "t61w4e": ["f11to73e", "f9u8p8h"],
112
+ "Dvncu9": "fw62pkm",
113
+ "qbflri": ["f9u8p8h", "f11to73e"],
114
+ "Byzt4r9": "fqaqzd4"
115
+ }
116
+ }, {
117
+ "d": [".f1euv43f{position:absolute;}", ".f1vgc2s3{left:0;}", ".f1e31b4d{right:0;}", ".f15twtuk{top:0;}", ".fly5x3f{width:100%;}", ".f1l02sjl{height:100%;}", ".f1ewtqcl{box-sizing:border-box;}", ".f1hu3pq6{margin-top:0;}", ".f11qmguv{margin-right:0;}", ".f1tyq0we{margin-left:0;}", ".f19f4twv{margin-bottom:0;}", ".fk73vx1{opacity:0;}", ".fg45n87:enabled{cursor:pointer;}", ".fhb1dn5:not(:checked)~.fui-Radio__indicator>*{opacity:0;}", ".fiegpko:enabled:not(:checked)~.fui-Radio__label{color:var(--colorNeutralForeground3);}", ".fdi60kf:enabled:not(:checked)~.fui-Radio__indicator{border-top-color:var(--colorNeutralStrokeAccessible);}", ".fz3jc1r:enabled:not(:checked)~.fui-Radio__indicator{border-right-color:var(--colorNeutralStrokeAccessible);}", ".f1fwo01y:enabled:not(:checked)~.fui-Radio__indicator{border-left-color:var(--colorNeutralStrokeAccessible);}", ".f1m2gv5u:enabled:not(:checked)~.fui-Radio__indicator{border-bottom-color:var(--colorNeutralStrokeAccessible);}", ".ft7ju8s:enabled:not(:checked):hover~.fui-Radio__label{color:var(--colorNeutralForeground2);}", ".f1ofw0le:enabled:not(:checked):hover~.fui-Radio__indicator{border-top-color:var(--colorNeutralStrokeAccessibleHover);}", ".fothmfx:enabled:not(:checked):hover~.fui-Radio__indicator{border-right-color:var(--colorNeutralStrokeAccessibleHover);}", ".f13qgzgl:enabled:not(:checked):hover~.fui-Radio__indicator{border-left-color:var(--colorNeutralStrokeAccessibleHover);}", ".fp5vmb3:enabled:not(:checked):hover~.fui-Radio__indicator{border-bottom-color:var(--colorNeutralStrokeAccessibleHover);}", ".f1snis2b:enabled:not(:checked):hover:active~.fui-Radio__label{color:var(--colorNeutralForeground1);}", ".ff9psms:enabled:not(:checked):hover:active~.fui-Radio__indicator{border-top-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f1fg9ko4:enabled:not(:checked):hover:active~.fui-Radio__indicator{border-right-color:var(--colorNeutralStrokeAccessiblePressed);}", ".fqj7xkg:enabled:not(:checked):hover:active~.fui-Radio__indicator{border-left-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f1vebft2:enabled:not(:checked):hover:active~.fui-Radio__indicator{border-bottom-color:var(--colorNeutralStrokeAccessiblePressed);}", ".f1vtc7ej:enabled:checked~.fui-Radio__label{color:var(--colorNeutralForeground1);}", ".f1fj62aq:enabled:checked~.fui-Radio__indicator{border-top-color:var(--colorCompoundBrandStroke);}", ".fc4i2ph:enabled:checked~.fui-Radio__indicator{border-right-color:var(--colorCompoundBrandStroke);}", ".f137d5x6:enabled:checked~.fui-Radio__indicator{border-left-color:var(--colorCompoundBrandStroke);}", ".f1v2xs8c:enabled:checked~.fui-Radio__indicator{border-bottom-color:var(--colorCompoundBrandStroke);}", ".f14bpgh5:enabled:checked~.fui-Radio__indicator{color:var(--colorCompoundBrandForeground1);}", ".f1ariq71:enabled:checked:hover~.fui-Radio__indicator{border-top-color:var(--colorCompoundBrandStrokeHover);}", ".fu58av6:enabled:checked:hover~.fui-Radio__indicator{border-right-color:var(--colorCompoundBrandStrokeHover);}", ".f1qj5h2v:enabled:checked:hover~.fui-Radio__indicator{border-left-color:var(--colorCompoundBrandStrokeHover);}", ".fptcwjq:enabled:checked:hover~.fui-Radio__indicator{border-bottom-color:var(--colorCompoundBrandStrokeHover);}", ".filss48:enabled:checked:hover~.fui-Radio__indicator{color:var(--colorCompoundBrandForeground1Hover);}", ".frtrqgn:enabled:checked:hover:active~.fui-Radio__indicator{border-top-color:var(--colorCompoundBrandStrokePressed);}", ".f1v1lrlm:enabled:checked:hover:active~.fui-Radio__indicator{border-right-color:var(--colorCompoundBrandStrokePressed);}", ".fapcpph:enabled:checked:hover:active~.fui-Radio__indicator{border-left-color:var(--colorCompoundBrandStrokePressed);}", ".f49ptgb:enabled:checked:hover:active~.fui-Radio__indicator{border-bottom-color:var(--colorCompoundBrandStrokePressed);}", ".fgnwcez:enabled:checked:hover:active~.fui-Radio__indicator{color:var(--colorCompoundBrandForeground1Pressed);}", ".f1l3wt4b:disabled~.fui-Radio__label{color:var(--colorNeutralForegroundDisabled);}", ".fdubm5j:disabled~.fui-Radio__indicator{border-top-color:var(--colorNeutralStrokeDisabled);}", ".f11to73e:disabled~.fui-Radio__indicator{border-right-color:var(--colorNeutralStrokeDisabled);}", ".f9u8p8h:disabled~.fui-Radio__indicator{border-left-color:var(--colorNeutralStrokeDisabled);}", ".fw62pkm:disabled~.fui-Radio__indicator{border-bottom-color:var(--colorNeutralStrokeDisabled);}", ".fqaqzd4:disabled~.fui-Radio__indicator{color:var(--colorNeutralForegroundDisabled);}"]
118
+ });
119
+
120
+ const useIndicatorStyles = /*#__PURE__*/react_1.__styles({
121
+ "base": {
122
+ "a9b677": "fjw5fx7",
123
+ "Bqenvij": "fd461yt",
124
+ "Be2twd7": "f1ugzwwg",
125
+ "B7ck84d": "f1ewtqcl",
126
+ "Bnnss6s": "fi64zpg",
127
+ "mc9l5x": "f22iagw",
128
+ "Bt984gj": "f122n59",
129
+ "Brf1p80": "f4d9j23",
130
+ "B68tc82": "f1p9o1ba",
131
+ "Bmxbyg5": "f1sil6mw",
132
+ "B4j52fo": "f192inf7",
133
+ "Bekrc4i": ["f5tn483", "f1ojsxk5"],
134
+ "Bn0qgzm": "f1vxd6vx",
135
+ "ibv6hh": ["f1ojsxk5", "f5tn483"],
136
+ "icvyot": "fzkkow9",
137
+ "vrafjx": ["fcdblym", "fjik90z"],
138
+ "oivjwe": "fg706s2",
139
+ "wvpqe5": ["fjik90z", "fcdblym"],
140
+ "Bbmb7ep": ["f8fbkgy", "f1nfllo7"],
141
+ "Beyfa6y": ["f1nfllo7", "f8fbkgy"],
142
+ "B7oj6ja": ["f1djnp8u", "f1s8kh49"],
143
+ "Btl43ni": ["f1s8kh49", "f1djnp8u"],
144
+ "Bkfmm31": "f1w9h62z",
145
+ "Bkecrkj": "f1aehjj5"
146
+ }
147
+ }, {
148
+ "d": [".fjw5fx7{width:16px;}", ".fd461yt{height:16px;}", ".f1ugzwwg{font-size:12px;}", ".f1ewtqcl{box-sizing:border-box;}", ".fi64zpg{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f4d9j23{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}", ".f1p9o1ba{overflow-x:hidden;}", ".f1sil6mw{overflow-y:hidden;}", ".f192inf7{border-top-width:var(--strokeWidthThin);}", ".f5tn483{border-right-width:var(--strokeWidthThin);}", ".f1ojsxk5{border-left-width:var(--strokeWidthThin);}", ".f1vxd6vx{border-bottom-width:var(--strokeWidthThin);}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".f8fbkgy{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1nfllo7{border-bottom-left-radius:var(--borderRadiusCircular);}", ".f1djnp8u{border-top-right-radius:var(--borderRadiusCircular);}", ".f1s8kh49{border-top-left-radius:var(--borderRadiusCircular);}", ".f1w9h62z{fill:currentColor;}", ".f1aehjj5{pointer-events:none;}"]
149
+ });
150
+
151
+ const useLabelStyles = /*#__PURE__*/react_1.__styles({
152
+ "base": {
153
+ "qb2dma": "f7nlbp4",
154
+ "famaaq": "f1xqy1su",
155
+ "B6of3ja": "fjzwpt6",
156
+ "t21cq0": ["f11qmguv", "f1tyq0we"],
157
+ "jrapky": "fh6j2fo",
158
+ "Frg6f3": ["f1tyq0we", "f11qmguv"]
159
+ },
160
+ "below": {
161
+ "fsow6f": "f17mccla"
162
+ }
163
+ }, {
164
+ "d": [".f7nlbp4{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".fjzwpt6{margin-top:calc((16px - var(--lineHeightBase300)) / 2);}", ".f11qmguv{margin-right:0;}", ".f1tyq0we{margin-left:0;}", ".fh6j2fo{margin-bottom:calc((16px - var(--lineHeightBase300)) / 2);}", ".f17mccla{text-align:center;}"]
165
+ });
166
+ /**
167
+ * Apply styling to the Radio slots based on the state
168
+ */
169
+
170
+
171
+ const useRadioStyles_unstable = state => {
172
+ const rootStyles = useRootStyles();
173
+ state.root.className = react_1.mergeClasses(exports.radioClassName, rootStyles.base, rootStyles.focusIndicator, state.labelPosition === 'below' && rootStyles.vertical, state.root.className);
174
+ const inputStyles = useInputStyles();
175
+ state.input.className = react_1.mergeClasses(inputStyles.base, state.input.className);
176
+ const indicatorStyles = useIndicatorStyles();
177
+ state.indicator.className = react_1.mergeClasses(indicatorClassName, indicatorStyles.base, state.indicator.className);
178
+ const labelStyles = useLabelStyles();
179
+
180
+ if (state.label) {
181
+ state.label.className = react_1.mergeClasses(labelClassName, labelStyles.base, state.labelPosition === 'below' && labelStyles.below, state.label.className);
182
+ }
183
+ };
184
+
185
+ exports.useRadioStyles_unstable = useRadioStyles_unstable;
186
+ //# sourceMappingURL=useRadioStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Radio/useRadioStyles.ts"],"names":[],"mappings":"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","sourcesContent":["import { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { RadioState } from './Radio.types';\n\nexport const radioClassName = 'fui-Radio';\nconst indicatorClassName = 'fui-Radio__indicator';\nconst labelClassName = 'fui-Radio__label';\n\n// TODO replace these spacing constants with theme values once they're on the theme\nconst spacingHorizontalS = '8px';\nconst spacingHorizontalM = '12px';\n\n// The indicator size is used by the indicator and label styles\nconst indicatorSize = '16px';\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n base: {\n display: 'inline-flex',\n position: 'relative',\n columnGap: spacingHorizontalM,\n ...shorthands.padding(spacingHorizontalS),\n },\n\n vertical: {\n flexDirection: 'column',\n alignItems: 'center',\n rowGap: spacingHorizontalM,\n },\n\n focusIndicator: createFocusOutlineStyle({ style: {}, selector: 'focus-within' }),\n});\n\nconst useInputStyles = makeStyles({\n base: {\n position: 'absolute',\n left: 0,\n top: 0,\n width: '100%',\n height: '100%',\n boxSizing: 'border-box',\n ...shorthands.margin(0),\n opacity: 0,\n\n ':enabled': {\n cursor: 'pointer',\n },\n\n // When unchecked, hide the circle icon (child of the indicator)\n [`:not(:checked) ~ .${indicatorClassName} > *`]: {\n opacity: '0',\n },\n\n // Colors for the unchecked state\n ':enabled:not(:checked)': {\n [`& ~ .${labelClassName}`]: {\n color: tokens.colorNeutralForeground3,\n },\n [`& ~ .${indicatorClassName}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessible),\n },\n\n ':hover': {\n [`& ~ .${labelClassName}`]: {\n color: tokens.colorNeutralForeground2,\n },\n [`& ~ .${indicatorClassName}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessibleHover),\n },\n },\n\n ':hover:active': {\n [`& ~ .${labelClassName}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${indicatorClassName}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeAccessiblePressed),\n },\n },\n },\n\n // Colors for the checked state\n ':enabled:checked': {\n [`& ~ .${labelClassName}`]: {\n color: tokens.colorNeutralForeground1,\n },\n [`& ~ .${indicatorClassName}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStroke),\n color: tokens.colorCompoundBrandForeground1,\n },\n\n ':hover': {\n [`& ~ .${indicatorClassName}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokeHover),\n color: tokens.colorCompoundBrandForeground1Hover,\n },\n },\n\n ':hover:active': {\n [`& ~ .${indicatorClassName}`]: {\n ...shorthands.borderColor(tokens.colorCompoundBrandStrokePressed),\n color: tokens.colorCompoundBrandForeground1Pressed,\n },\n },\n },\n\n // Colors for the disabled state\n ':disabled': {\n [`& ~ .${labelClassName}`]: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n [`& ~ .${indicatorClassName}`]: {\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n },\n});\n\nconst useIndicatorStyles = makeStyles({\n base: {\n width: indicatorSize,\n height: indicatorSize,\n fontSize: '12px',\n boxSizing: 'border-box',\n flexShrink: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n ...shorthands.overflow('hidden'),\n\n ...shorthands.border(tokens.strokeWidthThin, 'solid'),\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n fill: 'currentColor',\n pointerEvents: 'none',\n },\n});\n\nconst useLabelStyles = makeStyles({\n base: {\n alignSelf: 'center',\n userSelect: 'none',\n\n // Use a (negative) margin to account for the difference between the indicator's height and the label's line height.\n // This prevents the label from expanding the height of the Radio, but preserves line height if the label wraps.\n ...shorthands.margin(`calc((${indicatorSize} - ${tokens.lineHeightBase300}) / 2)`, 0),\n },\n\n below: {\n textAlign: 'center',\n },\n});\n\n/**\n * Apply styling to the Radio slots based on the state\n */\nexport const useRadioStyles_unstable = (state: RadioState) => {\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n radioClassName,\n rootStyles.base,\n rootStyles.focusIndicator,\n state.labelPosition === 'below' && rootStyles.vertical,\n state.root.className,\n );\n\n const inputStyles = useInputStyles();\n state.input.className = mergeClasses(inputStyles.base, state.input.className);\n\n const indicatorStyles = useIndicatorStyles();\n state.indicator.className = mergeClasses(indicatorClassName, indicatorStyles.base, state.indicator.className);\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n labelClassName,\n labelStyles.base,\n state.labelPosition === 'below' && labelStyles.below,\n state.label.className,\n );\n }\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,6 @@
1
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
2
+ import { RadioGroupProps } from './RadioGroup.types';
3
+ /**
4
+ * A RadioGroup component presents a set of options where only one option can be selected.
5
+ */
6
+ export declare const RadioGroup: ForwardRefComponent<RadioGroupProps>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RadioGroup = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const renderRadioGroup_1 = /*#__PURE__*/require("./renderRadioGroup");
11
+
12
+ const useRadioGroup_1 = /*#__PURE__*/require("./useRadioGroup");
13
+
14
+ const useRadioGroupStyles_1 = /*#__PURE__*/require("./useRadioGroupStyles");
15
+ /**
16
+ * A RadioGroup component presents a set of options where only one option can be selected.
17
+ */
18
+
19
+
20
+ exports.RadioGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
21
+ const state = useRadioGroup_1.useRadioGroup_unstable(props, ref);
22
+ useRadioGroupStyles_1.useRadioGroupStyles_unstable(state);
23
+ return renderRadioGroup_1.renderRadioGroup_unstable(state);
24
+ });
25
+ exports.RadioGroup.displayName = 'RadioGroup';
26
+ //# sourceMappingURL=RadioGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAGA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,iBAAA,CAAA;;AACA,MAAA,qBAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAEA;;AAEG;;;AACU,OAAA,CAAA,UAAA,gBAAmD,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AAC9F,QAAM,KAAK,GAAG,eAAA,CAAA,sBAAA,CAAuB,KAAvB,EAA8B,GAA9B,CAAd;AAEA,EAAA,qBAAA,CAAA,4BAAA,CAA6B,KAA7B;AACA,SAAO,kBAAA,CAAA,yBAAA,CAA0B,KAA1B,CAAP;AACD,CAL+D,CAAnD;AAOb,OAAA,CAAA,UAAA,CAAW,WAAX,GAAyB,YAAzB","sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { RadioGroupProps } from './RadioGroup.types';\nimport { renderRadioGroup_unstable } from './renderRadioGroup';\nimport { useRadioGroup_unstable } from './useRadioGroup';\nimport { useRadioGroupStyles_unstable } from './useRadioGroupStyles';\n\n/**\n * A RadioGroup component presents a set of options where only one option can be selected.\n */\nexport const RadioGroup: ForwardRefComponent<RadioGroupProps> = React.forwardRef((props, ref) => {\n const state = useRadioGroup_unstable(props, ref);\n\n useRadioGroupStyles_unstable(state);\n return renderRadioGroup_unstable(state);\n});\n\nRadioGroup.displayName = 'RadioGroup';\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,58 @@
1
+ import * as React from 'react';
2
+ import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
3
+ import { RadioGroupContextValue } from '../../contexts/RadioGroupContext';
4
+ export declare type RadioGroupSlots = {
5
+ /**
6
+ * The radio group root.
7
+ */
8
+ root: Slot<'div'>;
9
+ };
10
+ export declare type RadioGroupProps = Omit<ComponentProps<Partial<RadioGroupSlots>>, 'onChange'> & {
11
+ /**
12
+ * The name of this radio group. This name is applied to all Radio items inside this group.
13
+ *
14
+ * If no name is provided, one will be generated so that all of the Radio items have the same name.
15
+ */
16
+ name?: string;
17
+ /**
18
+ * The selected Radio item in this group.
19
+ *
20
+ * This should be the `value` prop of one of the Radio items inside this group.
21
+ */
22
+ value?: string;
23
+ /**
24
+ * The default selected Radio item in this group.
25
+ *
26
+ * This should be the `value` prop of one of the Radio items inside this group.
27
+ */
28
+ defaultValue?: string;
29
+ /**
30
+ * Callback when the selected Radio item changes.
31
+ */
32
+ onChange?: (ev: React.FormEvent<HTMLDivElement>, data: RadioGroupOnChangeData) => void;
33
+ /**
34
+ * How the radio items are laid out in the group.
35
+ *
36
+ * @defaultvalue vertical
37
+ */
38
+ layout?: 'vertical' | 'horizontal' | 'horizontalStacked';
39
+ /**
40
+ * Disable all Radio items in this group.
41
+ */
42
+ disabled?: boolean;
43
+ };
44
+ /**
45
+ * Data for the onChange event for RadioGroup.
46
+ */
47
+ export declare type RadioGroupOnChangeData = {
48
+ /**
49
+ * The value of the newly selected Radio item.
50
+ */
51
+ value: string;
52
+ };
53
+ /**
54
+ * State used in rendering RadioGroup
55
+ */
56
+ export declare type RadioGroupState = ComponentState<RadioGroupSlots> & Required<Pick<RadioGroupProps, 'layout'>> & {
57
+ context: RadioGroupContextValue;
58
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=RadioGroup.types.js.map