@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
package/Spec.md ADDED
@@ -0,0 +1,292 @@
1
+ # @fluentui/react-radio Spec
2
+
3
+ A Radio allows a user to select a single value from two or more options. All Radios with the same `name` are considered to be part of the same group. However, a `RadioGroup` is recommended to add a group label, formatting, and other functionality.
4
+
5
+ ## Background
6
+
7
+ ### Prior Art
8
+
9
+ - [OpenUI research](https://open-ui.org/components/radio-button.research)
10
+ - [Epic](https://github.com/microsoft/fluentui/issues/19953)
11
+
12
+ ### Comparison of [Fabric ChoiceGroup](https://developer.microsoft.com/en-us/fluentui#/controls/web/choicegroup) and [Stardust RadioGroup](https://fluentsite.z22.web.core.windows.net/components/radio-group/definition)
13
+
14
+ - All mentions of v7 or v8 refer to Fabric - `@fluentui/react` ([docsite](https://developer.microsoft.com/en-us/fluentui#/))
15
+ - All mentions of v0 refer to Northstar - `@fluentui/react-northstar` ([docsite](https://fluentsite.z22.web.core.windows.net/))
16
+
17
+ See Appendix for a detailed comparison of the two components.
18
+
19
+ In Fabric the Radio component is represented by the [ChoiceGroup](https://developer.microsoft.com/en-us/fluentui#/controls/web/choicegroup) component.
20
+ Fabric creates options based on data passed in via the `options` prop.
21
+ It uses the option's `key` property as the input value and holds the currently selected value in the `selectedKey` prop.
22
+ Fabric also allows an image to serve as a label for an option.
23
+
24
+ ```tsx
25
+ <ChoiceGroup
26
+ defaultSelectedKey="B"
27
+ options={[
28
+ { key: 'A', text: 'Option A' },
29
+ { key: 'B', text: 'Option B' },
30
+ { key: 'C', text: 'Option C', disabled: true },
31
+ { key: 'D', text: 'Option D' },
32
+ ]}
33
+ label="Pick one"
34
+ required={true}
35
+ />
36
+ ```
37
+
38
+ In Northstar the Radio component is represented by the [RadioGroup](https://fluentsite.z22.web.core.windows.net/components/radio-group/definition) component.
39
+ Northstar creates options based on data passed in via the `items` prop.
40
+ It uses the option's `value` property as the input value and holds the currently selected value in the `checkedValue` prop.
41
+
42
+ ```tsx
43
+ <RadioGroup
44
+ onCheckedValueChange={handleChange}
45
+ items={[
46
+ { key: '1', label: 'Make your choice', value: '1' },
47
+ { key: '2', label: 'Another option', value: '2' },
48
+ ]}
49
+ />
50
+ ```
51
+
52
+ ## Variants
53
+
54
+ ### Layout
55
+
56
+ #### Horizonal
57
+
58
+ Inline positioning of the inputs and labels.
59
+
60
+ ![Horizontal group](./etc/images/horizontal-group.png)
61
+
62
+ #### Horizonal stacked
63
+
64
+ Positioning the label at the bottom of the radio inputs.
65
+
66
+ ![Horizontal group - stacked](./etc/images/horizontal-group-stacked.png)
67
+
68
+ #### Vertical
69
+
70
+ Default vertical positioning of Radio items.
71
+
72
+ ![Vertical group](./etc/images/vertical-group.png)
73
+
74
+ #### Vertical with input
75
+
76
+ Default positioning of Radio items with an input as its last Radio item.
77
+
78
+ ![Vertical group with input](./etc/images/vertical-group-with-input.png)
79
+
80
+ ### Vertical with dropdown
81
+
82
+ Default positioning of Radio items with a dropdown as its last Radio item.
83
+
84
+ ![Vertical group with dropdown](./etc/images/vertical-group-with-dropdown.png)
85
+
86
+ ## API
87
+
88
+ ### Components
89
+
90
+ | Component | Purpose |
91
+ | ----------------- | ------------------------------------------------------------------------------- |
92
+ | RadioGroup | Wraps radio inputs. Provides RadioGroupContext and layout for the radio items. |
93
+ | RadioGroupContext | Provides some props like `name` to Radio items that are children of RadioGroup. |
94
+ | Radio | Represents a single radio item (input and label). |
95
+
96
+ ### RadioGroup
97
+
98
+ Link to [RadioGroup.types.ts](https://github.com/microsoft/fluentui/blob/master/packages/react-radio/src/components/RadioGroup/RadioGroup.types.ts)
99
+
100
+ | Prop | Type | Default value | Purpose |
101
+ | -------------- | --------------------------------------------------- | ---------------------- | -------------------------------------------------------- |
102
+ | (root) | slot: `<div role="radiogroup">` | | The root slot has the radiogroup role. |
103
+ | `name` | `string` | `useId('radiogroup-')` | Name property passed to child radios. |
104
+ | `value` | `string` | | Currently selected value. Used only for controlled mode. |
105
+ | `defaultValue` | `string` | | Default selected value. |
106
+ | `disabled` | `boolean` | `false` | Disables all radio items inside the group. |
107
+ | `layout` | `"vertical" \| "horizontal" \| "horizontalStacked"` | `vertical` | Specifies the layout of the radio items. |
108
+ | `onChange` | `(event, data: { value: string }) => void` | | Callback when a radio item is selected. |
109
+
110
+ ### RadioGroupContext
111
+
112
+ This is a context object provided by RadioGroup that allows all of the child Radio items to have the same name, and coordinate the selected item.
113
+
114
+ The context contains the following props from RadioGroup:
115
+
116
+ - `name`
117
+ - `layout`
118
+ - `defaultValue`
119
+ - `value`
120
+ - `disabled`
121
+
122
+ ### Radio
123
+
124
+ Link to [Radio.types.ts](https://github.com/microsoft/fluentui/blob/master/packages/react-radio/src/components/Radio/Radio.types.ts)
125
+
126
+ | Prop | Type | Purpose |
127
+ | ----------- | ---------------------------- | ------------------------------------------------------------------- |
128
+ | (root) | slot: `<span>` | Wrapper for the input, indicator, and label |
129
+ | `input` | slot: `<input type="radio">` | Hidden input element that handles the radio's behavior. |
130
+ | `indicator` | slot: `<div>` | The circular indicator to show the radio's checked/unchecked state. |
131
+ | `label` | slot: `<Label>` | Label that will be rendered next to the radio indicator. |
132
+ | `value` | `string` | The value of the RadioGroup when this Radio is selected |
133
+ | `checked` | `boolean` | Whether the input is checked or not. |
134
+ | `disabled` | `boolean` | Whether the input is disabled or not. |
135
+
136
+ ## Sample Code
137
+
138
+ A simple `RadioGroup`.
139
+
140
+ ```jsx
141
+ <RadioGroup defaultValue="one">
142
+ <Radio value="one" label="Option One" />
143
+ <Radio value="two" label="Option Two" />
144
+ <Radio value="three" label="Option Three" />
145
+ </RadioGroup>
146
+ ```
147
+
148
+ `Radio` can be used without a `RadioGroup`, but it is then up to the user to add the same `name` to each item:
149
+
150
+ ```jsx
151
+ <>
152
+ <Radio name="number" value="one" label="Option One" defaultChecked />
153
+ <Radio name="number" value="two" label="Option Two" />
154
+ <Radio name="number" value="three" label="Option Three" />
155
+ </>
156
+ ```
157
+
158
+ ## Structure
159
+
160
+ ### Expected DOM structure
161
+
162
+ ```html
163
+ <div role="radiogroup" class="fui-RadioGroup" name="radiogroup-0">
164
+ <span class="fui-Radio">
165
+ <input type="radio" id="radio-1" name="radiogroup-0" value="one" checked />
166
+ <div class="fui-Radio__indicator">
167
+ <svg><circle /></svg>
168
+ </div>
169
+ <label class="fui-Label" for="radio-1">Option One</label>
170
+ </span>
171
+
172
+ <span class="fui-Radio">
173
+ <input type="radio" id="radio-2" name="radiogroup-0" value="two" />
174
+ <div class="fui-Radio__indicator">
175
+ <svg><circle /></svg>
176
+ </div>
177
+ <label class="fui-Label" for="radio-2">Option Two</label>
178
+ </span>
179
+
180
+ <span class="fui-Radio">
181
+ <input type="radio" id="radio-3" name="radiogroup-0" value="three" />
182
+ <div class="fui-Radio__indicator">
183
+ <svg><circle /></svg>
184
+ </div>
185
+ <label class="fui-Label" for="radio-3">Option Three</label>
186
+ </span>
187
+ </div>
188
+ ```
189
+
190
+ ## Behaviors
191
+
192
+ ### Mouse/Touch
193
+
194
+ The Radio's hit target fills the entire space around the indicator and label (including the padding).
195
+
196
+ ### Keyboard
197
+
198
+ RadioGroup inherits all of its mouse and keyboard behaviors from the browser's handling of `<input type="radio">`.
199
+
200
+ - It has no special handling of clicks or keypresses for toggling beyond the built-in control.
201
+ - The browser handles arrow key selection, and creating a single tab stop for the control.
202
+
203
+ ### Disabled
204
+
205
+ - Individual Radio items can be disabled, in which case they are grayed out and can't be selected or focused.
206
+ - This interaction is built-into the browser by setting `disabled` on the `<input>` control.
207
+ - The entire RadioGroup can be disabled, which uses RadioGroupContext to disable all of the individual Radio items.
208
+
209
+ ### Group Name
210
+
211
+ - All Radio items in a group must have the same `name` for the browser to handle keyboarding and selection.
212
+ - The RadioGroup provides its `name` through RadioGroupContext, and each Radio inside applies the `name`.
213
+ - If a `name` is not provided on RadioGroup, a unique name is automatically generated with `useId`.
214
+
215
+ ## Accessibility
216
+
217
+ ### RadioGroup
218
+
219
+ This implementation based on the [Grouping Controls](https://www.w3.org/WAI/tutorials/forms/grouping/) examples of Web Accessibility Tutorials (that follow WCAG).
220
+
221
+ - The RadioGroup root is a `<div role="radiogroup">` to provide the default accessibility behavior of a radiogroup.
222
+ - If a group label is added, the RadioGroup needs to have `aria-labelledby` referencing the label.
223
+
224
+ ### Radio
225
+
226
+ - The Radio's primary slot is an `<input type="radio">`, with opacity 0, and covers the root.
227
+ - This way, the Radio's hit target fills the entire space around the indicator and label (including the padding).
228
+ - The Radio's label is a `<label>` element with `for={input.id}` to associate it with the input slot.
229
+
230
+ <!--
231
+ ## Migration
232
+ TBD: Link to Migration guide
233
+ -->
234
+
235
+ # Appendix
236
+
237
+ ## v8 vs v0 comparison
238
+
239
+ ### RadioGroup (v0) vs ChoiceGroup (v8) prop mapping
240
+
241
+ _⚠️ Props not included in this section are marked as deprecated and will not be considered._
242
+
243
+ | Purpose | Fabric (v8) | Northstar (v0) | Matching |
244
+ | ------------------------------------------------------------------------------------------------- | ------------------ | -------------------- | ------------------------------------------ |
245
+ | Called after radio group value is changed. | onChange | onCheckedValueChange | Matching 🛠️ |
246
+ | The options/items for the group. | options | items | Matching |
247
+ | Additional CSS styles to apply to the component instance. | styles | styles | Matching |
248
+ | Initial checkedValue value. | defaultSelectedKey | defaultCheckedValue | Matching functionality, not implementation |
249
+ | Value of the currently checked radio item. | selectedKey | checkedValue | Matching functionality, not implementation |
250
+ | Theme - Override for theme site variables to allow modifications of component styling via themes. | theme | variables | Matching |
251
+ | ID of an element to use as the aria label for this ChoiceGroup. | ariaLabelledBy | - | - |
252
+ | Optional callback to access the `IChoiceGroup` interface. | componentRef | - | - |
253
+ | Descriptive label for the choice group. | label | - | - |
254
+ | Accessibility behavior if overridden by the user. | - | accessibility | - |
255
+ | An element type to render as (string or component). | - | as | - |
256
+ | Additional CSS class name(s) to apply. | - | className | - |
257
+ | A vertical radio group displays elements vertically. | - | vertical | - |
258
+ | - | - | design | - |
259
+
260
+ ### RadioItem (v0) vs ChoiceGroupOption (v8) props mapping
261
+
262
+ | Purpose | Fabric (v8) | Northstar (v0) | Matching |
263
+ | ------------------------------------------------------------------------------- | ------------------ | ---------------- | -------- |
264
+ | A required key to uniquely identify the option. | key (required) | - | - |
265
+ | The text string for the option. | text (required) ❓ | label | Matching |
266
+ | Call to provide customized styling that will layer on top of the variant rules. | styles | styles | Matching |
267
+ | A radio item can appear disabled and be unable to change states. | disabled | disabled | Matching |
268
+ | Aria label of the option for the benefit of screen reader users. | ariaLabel | - | - |
269
+ | Props for an icon to display with this option. | iconProps | - | - |
270
+ | ID used on the option's input element. | id | - | - |
271
+ | Alt text if the option is an image. | imageAlt | - | - |
272
+ | The width and height of the image in px for choice field. | imageSize | - | - |
273
+ | Image to display with this option. | imageSrc | - | - |
274
+ | ID used on the option's label. | labelId | - | - |
275
+ | Used to customize option rendering. | onRenderField | - | - |
276
+ | Used to customize label rendering. | onRenderLabel | - | - |
277
+ | The src of image for choice field which is selected. | selectedImageSrc | - | - |
278
+ | Accessibility behavior if overridden by the user. | - | accessibility | - |
279
+ | Whether or not radio item is checked. | - | checked | - |
280
+ | The checked radio item indicator can be customized. | - | checkedIndicator | - |
281
+ | Initial checked value. | - | defaultChecked | - |
282
+ | The radio item indicator can be customized. | - | indicator | - |
283
+ | The HTML input name. | - | name | - |
284
+ | Called after radio item checked state is changed. | - | onChange | - |
285
+ | Called after radio item is clicked. | - | onClick | - |
286
+ | Whether should focus when checked | - | shouldFocus | - |
287
+ | The HTML input value. | - | value | - |
288
+ | A vertical radio group displays elements vertically. | - | vertical | - |
289
+ | - | - | as | - |
290
+ | - | - | className | - |
291
+ | - | - | variables | - |
292
+ | - | - | design | - |
@@ -0,0 +1,183 @@
1
+ import type { ComponentProps } from '@fluentui/react-utilities';
2
+ import type { ComponentState } from '@fluentui/react-utilities';
3
+ import type { ForwardRefComponent } from '@fluentui/react-utilities';
4
+ import { Label } from '@fluentui/react-label';
5
+ import * as React_2 from 'react';
6
+ import type { Slot } from '@fluentui/react-utilities';
7
+
8
+ /**
9
+ * Radio component is a wrapper for a radio button with a label.
10
+ */
11
+ export declare const Radio: ForwardRefComponent<RadioProps>;
12
+
13
+ export declare const radioClassName = "fui-Radio";
14
+
15
+ /**
16
+ * A RadioGroup component presents a set of options where only one option can be selected.
17
+ */
18
+ export declare const RadioGroup: ForwardRefComponent<RadioGroupProps>;
19
+
20
+ export declare const radioGroupClassName = "fui-RadioGroup";
21
+
22
+ /**
23
+ * RadioGroupContext is provided by RadioGroup, and is consumed by Radio to determine default values of some props.
24
+ */
25
+ export declare const RadioGroupContext: React_2.Context<RadioGroupContextValue>;
26
+
27
+ export declare type RadioGroupContextValue = Pick<RadioGroupProps, 'name' | 'layout' | 'value' | 'defaultValue' | 'disabled'>;
28
+
29
+ /**
30
+ * Data for the onChange event for RadioGroup.
31
+ */
32
+ export declare type RadioGroupOnChangeData = {
33
+ /**
34
+ * The value of the newly selected Radio item.
35
+ */
36
+ value: string;
37
+ };
38
+
39
+ export declare type RadioGroupProps = Omit<ComponentProps<Partial<RadioGroupSlots>>, 'onChange'> & {
40
+ /**
41
+ * The name of this radio group. This name is applied to all Radio items inside this group.
42
+ *
43
+ * If no name is provided, one will be generated so that all of the Radio items have the same name.
44
+ */
45
+ name?: string;
46
+ /**
47
+ * The selected Radio item in this group.
48
+ *
49
+ * This should be the `value` prop of one of the Radio items inside this group.
50
+ */
51
+ value?: string;
52
+ /**
53
+ * The default selected Radio item in this group.
54
+ *
55
+ * This should be the `value` prop of one of the Radio items inside this group.
56
+ */
57
+ defaultValue?: string;
58
+ /**
59
+ * Callback when the selected Radio item changes.
60
+ */
61
+ onChange?: (ev: React_2.FormEvent<HTMLDivElement>, data: RadioGroupOnChangeData) => void;
62
+ /**
63
+ * How the radio items are laid out in the group.
64
+ *
65
+ * @defaultvalue vertical
66
+ */
67
+ layout?: 'vertical' | 'horizontal' | 'horizontalStacked';
68
+ /**
69
+ * Disable all Radio items in this group.
70
+ */
71
+ disabled?: boolean;
72
+ };
73
+
74
+ export declare type RadioGroupSlots = {
75
+ /**
76
+ * The radio group root.
77
+ */
78
+ root: Slot<'div'>;
79
+ };
80
+
81
+ /**
82
+ * State used in rendering RadioGroup
83
+ */
84
+ export declare type RadioGroupState = ComponentState<RadioGroupSlots> & Required<Pick<RadioGroupProps, 'layout'>> & {
85
+ context: RadioGroupContextValue;
86
+ };
87
+
88
+ /**
89
+ * Radio Props
90
+ */
91
+ export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input'>, 'size'> & {
92
+ /**
93
+ * The value of the RadioGroup when this Radio item is selected.
94
+ */
95
+ value?: string;
96
+ /**
97
+ * The position of the label relative to the radio indicator.
98
+ *
99
+ * This defaults to `after` unless the Radio is inside a RadioGroup with `layout="horizontalStacked"`,
100
+ * in which case it defaults to `below`.
101
+ *
102
+ * @defaultvalue after
103
+ */
104
+ labelPosition?: 'after' | 'below';
105
+ /**
106
+ * Disable this Radio item.
107
+ */
108
+ disabled?: boolean;
109
+ };
110
+
111
+ export declare type RadioSlots = {
112
+ /**
113
+ * The root element of the Radio.
114
+ *
115
+ * The root slot receives the `className` and `style` specified directly on the `<Radio>`.
116
+ * All other native props will be applied to the primary slot: `input`
117
+ */
118
+ root: NonNullable<Slot<'span'>>;
119
+ /**
120
+ * The Radio's label.
121
+ */
122
+ label: Slot<typeof Label>;
123
+ /**
124
+ * Hidden input that handles the radio's functionality.
125
+ *
126
+ * This is the PRIMARY slot: all native properties specified directly on `<Radio>` will be applied to this slot,
127
+ * except `className` and `style`, which remain on the root slot.
128
+ */
129
+ input: NonNullable<Slot<'input'>>;
130
+ /**
131
+ * A circle outline, with a filled circle icon inside when the Radio is checked.
132
+ */
133
+ indicator: NonNullable<Slot<'div'>>;
134
+ };
135
+
136
+ /**
137
+ * State used in rendering Radio
138
+ */
139
+ export declare type RadioState = ComponentState<RadioSlots> & Required<Pick<RadioProps, 'labelPosition'>>;
140
+
141
+ /**
142
+ * Render the final JSX of Radio
143
+ */
144
+ export declare const renderRadio_unstable: (state: RadioState) => JSX.Element;
145
+
146
+ /**
147
+ * Render the final JSX of RadioGroup
148
+ */
149
+ export declare const renderRadioGroup_unstable: (state: RadioGroupState) => JSX.Element;
150
+
151
+ /**
152
+ * Create the state required to render Radio.
153
+ *
154
+ * The returned state can be modified with hooks such as useRadioStyles_unstable,
155
+ * before being passed to renderRadio_unstable.
156
+ *
157
+ * @param props - props from this instance of Radio
158
+ * @param ref - reference to `<input>` element of Radio
159
+ */
160
+ export declare const useRadio_unstable: (props: RadioProps, ref: React_2.Ref<HTMLInputElement>) => RadioState;
161
+
162
+ /**
163
+ * Create the state required to render RadioGroup.
164
+ *
165
+ * The returned state can be modified with hooks such as useRadioGroupStyles_unstable,
166
+ * before being passed to renderRadioGroup_unstable.
167
+ *
168
+ * @param props - props from this instance of RadioGroup
169
+ * @param ref - reference to root HTMLElement of RadioGroup
170
+ */
171
+ export declare const useRadioGroup_unstable: (props: RadioGroupProps, ref: React_2.Ref<HTMLDivElement>) => RadioGroupState;
172
+
173
+ /**
174
+ * Apply styling to the RadioGroup slots based on the state
175
+ */
176
+ export declare const useRadioGroupStyles_unstable: (state: RadioGroupState) => void;
177
+
178
+ /**
179
+ * Apply styling to the Radio slots based on the state
180
+ */
181
+ export declare const useRadioStyles_unstable: (state: RadioState) => void;
182
+
183
+ export { }
package/lib/Radio.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './components/Radio/index';
package/lib/Radio.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components/Radio/index';
2
+ //# sourceMappingURL=Radio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Radio.js","sourceRoot":"../src/","sources":["Radio.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './components/Radio/index';\n"]}
@@ -0,0 +1 @@
1
+ export * from './components/RadioGroup/index';
@@ -0,0 +1,2 @@
1
+ export * from './components/RadioGroup/index';
2
+ //# sourceMappingURL=RadioGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroup.js","sourceRoot":"../src/","sources":["RadioGroup.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC","sourcesContent":["export * from './components/RadioGroup/index';\n"]}
@@ -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,15 @@
1
+ import * as React from 'react';
2
+ import { renderRadio_unstable } from './renderRadio';
3
+ import { useRadio_unstable } from './useRadio';
4
+ import { useRadioStyles_unstable } from './useRadioStyles';
5
+ /**
6
+ * Radio component is a wrapper for a radio button with a label.
7
+ */
8
+
9
+ export const Radio = /*#__PURE__*/React.forwardRef((props, ref) => {
10
+ const state = useRadio_unstable(props, ref);
11
+ useRadioStyles_unstable(state);
12
+ return renderRadio_unstable(state);
13
+ });
14
+ Radio.displayName = 'Radio';
15
+ //# sourceMappingURL=Radio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Radio/Radio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA,SAAS,oBAAT,QAAqC,eAArC;AACA,SAAS,iBAAT,QAAkC,YAAlC;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AAEA;;AAEG;;AACH,OAAO,MAAM,KAAK,gBAAoC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACpF,QAAM,KAAK,GAAG,iBAAiB,CAAC,KAAD,EAAQ,GAAR,CAA/B;AAEA,EAAA,uBAAuB,CAAC,KAAD,CAAvB;AACA,SAAO,oBAAoB,CAAC,KAAD,CAA3B;AACD,CALqD,CAA/C;AAOP,KAAK,CAAC,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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Radio.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Radio.types.js","sourceRoot":"../src/","sources":["components/Radio/Radio.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Label } from '@fluentui/react-label';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type RadioSlots = {\n /**\n * The root element of the Radio.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Radio>`.\n * All other native props will be applied to the primary slot: `input`\n */\n root: NonNullable<Slot<'span'>>;\n\n /**\n * The Radio's label.\n */\n label: Slot<typeof Label>;\n\n /**\n * Hidden input that handles the radio's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on `<Radio>` will be applied to this slot,\n * except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * A circle outline, with a filled circle icon inside when the Radio is checked.\n */\n indicator: NonNullable<Slot<'div'>>;\n};\n\n/**\n * Radio Props\n */\nexport type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input'>, 'size'> & {\n /**\n * The value of the RadioGroup when this Radio item is selected.\n */\n value?: string;\n\n /**\n * The position of the label relative to the radio indicator.\n *\n * This defaults to `after` unless the Radio is inside a RadioGroup with `layout=\"horizontalStacked\"`,\n * in which case it defaults to `below`.\n *\n * @defaultvalue after\n */\n labelPosition?: 'after' | 'below';\n\n /**\n * Disable this Radio item.\n */\n disabled?: boolean;\n};\n\n/**\n * State used in rendering Radio\n */\nexport type RadioState = ComponentState<RadioSlots> & Required<Pick<RadioProps, 'labelPosition'>>;\n"]}
@@ -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,6 @@
1
+ export * from './Radio';
2
+ export * from './Radio.types';
3
+ export * from './renderRadio';
4
+ export * from './useRadio';
5
+ export * from './useRadioStyles';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Radio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './Radio';\nexport * from './Radio.types';\nexport * from './renderRadio';\nexport * from './useRadio';\nexport * from './useRadioStyles';\n"]}
@@ -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,18 @@
1
+ import * as React from 'react';
2
+ import { getSlots } from '@fluentui/react-utilities';
3
+ /**
4
+ * Render the final JSX of Radio
5
+ */
6
+
7
+ export const renderRadio_unstable = state => {
8
+ const {
9
+ slots,
10
+ slotProps
11
+ } = getSlots(state);
12
+ return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
13
+ }, /*#__PURE__*/React.createElement(slots.input, { ...slotProps.input
14
+ }), /*#__PURE__*/React.createElement(slots.indicator, { ...slotProps.indicator
15
+ }), slots.label && /*#__PURE__*/React.createElement(slots.label, { ...slotProps.label
16
+ }));
17
+ };
18
+ //# sourceMappingURL=renderRadio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/Radio/renderRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAAI,KAAD,IAAsB;AACxD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAa,KAAb,CAArC;AAEA,sBACE,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,iBAAe,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CAHlB,CADF;AAOD,CAVM","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;