@fluentui/react-radio 9.0.0-beta.2 → 9.0.0-beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/CHANGELOG.json +180 -1
  2. package/CHANGELOG.md +49 -2
  3. package/README.md +39 -0
  4. package/dist/{react-radio.d.ts → index.d.ts} +43 -8
  5. package/lib/components/Radio/Radio.types.d.ts +18 -1
  6. package/lib/components/Radio/Radio.types.js.map +1 -1
  7. package/lib/components/Radio/useRadio.js +21 -11
  8. package/lib/components/Radio/useRadio.js.map +1 -1
  9. package/lib/components/Radio/useRadioStyles.d.ts +6 -1
  10. package/lib/components/Radio/useRadioStyles.js +35 -13
  11. package/lib/components/Radio/useRadioStyles.js.map +1 -1
  12. package/lib/components/RadioGroup/RadioGroup.js +3 -1
  13. package/lib/components/RadioGroup/RadioGroup.js.map +1 -1
  14. package/lib/components/RadioGroup/RadioGroup.types.d.ts +10 -5
  15. package/lib/components/RadioGroup/RadioGroup.types.js.map +1 -1
  16. package/lib/components/RadioGroup/renderRadioGroup.d.ts +2 -2
  17. package/lib/components/RadioGroup/renderRadioGroup.js +2 -2
  18. package/lib/components/RadioGroup/renderRadioGroup.js.map +1 -1
  19. package/lib/components/RadioGroup/useRadioGroup.js +7 -9
  20. package/lib/components/RadioGroup/useRadioGroup.js.map +1 -1
  21. package/lib/components/RadioGroup/useRadioGroupStyles.d.ts +6 -1
  22. package/lib/components/RadioGroup/useRadioGroupStyles.js +8 -1
  23. package/lib/components/RadioGroup/useRadioGroupStyles.js.map +1 -1
  24. package/lib/contexts/RadioGroupContext.d.ts +3 -4
  25. package/lib/contexts/RadioGroupContext.js +2 -2
  26. package/lib/contexts/RadioGroupContext.js.map +1 -1
  27. package/lib/contexts/useRadioGroupContextValues.d.ts +2 -0
  28. package/lib/contexts/useRadioGroupContextValues.js +22 -0
  29. package/lib/contexts/useRadioGroupContextValues.js.map +1 -0
  30. package/lib/index.d.ts +5 -3
  31. package/lib/index.js +7 -3
  32. package/lib/index.js.map +1 -1
  33. package/lib-commonjs/components/Radio/Radio.types.d.ts +18 -1
  34. package/lib-commonjs/components/Radio/useRadio.js +21 -10
  35. package/lib-commonjs/components/Radio/useRadio.js.map +1 -1
  36. package/lib-commonjs/components/Radio/useRadioStyles.d.ts +6 -1
  37. package/lib-commonjs/components/Radio/useRadioStyles.js +36 -14
  38. package/lib-commonjs/components/Radio/useRadioStyles.js.map +1 -1
  39. package/lib-commonjs/components/RadioGroup/RadioGroup.js +4 -1
  40. package/lib-commonjs/components/RadioGroup/RadioGroup.js.map +1 -1
  41. package/lib-commonjs/components/RadioGroup/RadioGroup.types.d.ts +10 -5
  42. package/lib-commonjs/components/RadioGroup/renderRadioGroup.d.ts +2 -2
  43. package/lib-commonjs/components/RadioGroup/renderRadioGroup.js +2 -2
  44. package/lib-commonjs/components/RadioGroup/renderRadioGroup.js.map +1 -1
  45. package/lib-commonjs/components/RadioGroup/useRadioGroup.js +7 -10
  46. package/lib-commonjs/components/RadioGroup/useRadioGroup.js.map +1 -1
  47. package/lib-commonjs/components/RadioGroup/useRadioGroupStyles.d.ts +6 -1
  48. package/lib-commonjs/components/RadioGroup/useRadioGroupStyles.js +9 -2
  49. package/lib-commonjs/components/RadioGroup/useRadioGroupStyles.js.map +1 -1
  50. package/lib-commonjs/contexts/RadioGroupContext.d.ts +3 -4
  51. package/lib-commonjs/contexts/RadioGroupContext.js +2 -2
  52. package/lib-commonjs/contexts/RadioGroupContext.js.map +1 -1
  53. package/lib-commonjs/contexts/useRadioGroupContextValues.d.ts +2 -0
  54. package/lib-commonjs/contexts/useRadioGroupContextValues.js +31 -0
  55. package/lib-commonjs/contexts/useRadioGroupContextValues.js.map +1 -0
  56. package/lib-commonjs/index.d.ts +5 -3
  57. package/lib-commonjs/index.js +88 -4
  58. package/lib-commonjs/index.js.map +1 -1
  59. package/package.json +10 -19
package/CHANGELOG.json CHANGED
@@ -2,7 +2,186 @@
2
2
  "name": "@fluentui/react-radio",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 04 Mar 2022 05:15:54 GMT",
5
+ "date": "Wed, 04 May 2022 13:24:16 GMT",
6
+ "tag": "@fluentui/react-radio_v9.0.0-beta.5",
7
+ "version": "9.0.0-beta.5",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "seanmonahan@microsoft.com",
12
+ "package": "@fluentui/react-radio",
13
+ "commit": "9132814df4b6d40d1f5d93d8324d756c1284b294",
14
+ "comment": "react-radio: update context usage"
15
+ },
16
+ {
17
+ "author": "seanmonahan@microsoft.com",
18
+ "package": "@fluentui/react-radio",
19
+ "commit": "8d990349b5af2d61057cccda2357412d2f5ab9b9",
20
+ "comment": "add bundle size fixtures"
21
+ },
22
+ {
23
+ "author": "seanmonahan@microsoft.com",
24
+ "package": "@fluentui/react-radio",
25
+ "commit": "6a017c3b1f2a282fa86c28b675e5ed34a1bb2aee",
26
+ "comment": "react-radio: add required prop to RadioGroup"
27
+ },
28
+ {
29
+ "author": "seanmonahan@microsoft.com",
30
+ "package": "@fluentui/react-radio",
31
+ "commit": "4bc1c43194cb9f44c5ad40ae43ab26556778157e",
32
+ "comment": "react-radio: remove required indicator from label"
33
+ },
34
+ {
35
+ "author": "seanmonahan@microsoft.com",
36
+ "package": "@fluentui/react-radio",
37
+ "commit": "5f27c51743f22f08741a75c2c10032a02afdf6fb",
38
+ "comment": "write readme"
39
+ },
40
+ {
41
+ "author": "miroslav.stastny@microsoft.com",
42
+ "package": "@fluentui/react-radio",
43
+ "commit": "3be7a89d9e9323780bba5b24d3bcc4342e1f1ec7",
44
+ "comment": "Allow data argument on onChange"
45
+ },
46
+ {
47
+ "author": "beachball",
48
+ "package": "@fluentui/react-radio",
49
+ "comment": "Bump @fluentui/react-context-selector to v9.0.0-rc.7",
50
+ "commit": "65f94192ed3b2cde7e52b9c7e12d6f38b81965dd"
51
+ },
52
+ {
53
+ "author": "beachball",
54
+ "package": "@fluentui/react-radio",
55
+ "comment": "Bump @fluentui/react-label to v9.0.0-beta.11",
56
+ "commit": "65f94192ed3b2cde7e52b9c7e12d6f38b81965dd"
57
+ },
58
+ {
59
+ "author": "beachball",
60
+ "package": "@fluentui/react-radio",
61
+ "comment": "Bump @fluentui/react-tabster to v9.0.0-rc.8",
62
+ "commit": "65f94192ed3b2cde7e52b9c7e12d6f38b81965dd"
63
+ },
64
+ {
65
+ "author": "beachball",
66
+ "package": "@fluentui/react-radio",
67
+ "comment": "Bump @fluentui/react-theme to v9.0.0-rc.6",
68
+ "commit": "65f94192ed3b2cde7e52b9c7e12d6f38b81965dd"
69
+ },
70
+ {
71
+ "author": "beachball",
72
+ "package": "@fluentui/react-radio",
73
+ "comment": "Bump @fluentui/react-utilities to v9.0.0-rc.7",
74
+ "commit": "65f94192ed3b2cde7e52b9c7e12d6f38b81965dd"
75
+ }
76
+ ]
77
+ }
78
+ },
79
+ {
80
+ "date": "Mon, 25 Apr 2022 09:32:19 GMT",
81
+ "tag": "@fluentui/react-radio_v9.0.0-beta.4",
82
+ "version": "9.0.0-beta.4",
83
+ "comments": {
84
+ "prerelease": [
85
+ {
86
+ "author": "beachball",
87
+ "package": "@fluentui/react-radio",
88
+ "comment": "Bump @fluentui/react-tabster to v9.0.0-rc.7",
89
+ "commit": "02ca1d3c198452c1693067f5f18bd01b2ed5d6e6"
90
+ }
91
+ ]
92
+ }
93
+ },
94
+ {
95
+ "date": "Tue, 19 Apr 2022 19:16:50 GMT",
96
+ "tag": "@fluentui/react-radio_v9.0.0-beta.3",
97
+ "version": "9.0.0-beta.3",
98
+ "comments": {
99
+ "prerelease": [
100
+ {
101
+ "author": "seanmonahan@microsoft.com",
102
+ "package": "@fluentui/react-radio",
103
+ "commit": "086a675fd0c648944ff4048450190a0a13467de3",
104
+ "comment": "Deprecate static classname string for Radio."
105
+ },
106
+ {
107
+ "author": "seanmonahan@microsoft.com",
108
+ "package": "@fluentui/react-radio",
109
+ "commit": "c0c9b30ae2393775eac02870f6b04cade31ef3ac",
110
+ "comment": "Remove star exports from react-radio"
111
+ },
112
+ {
113
+ "author": "seanmonahan@microsoft.com",
114
+ "package": "@fluentui/react-radio",
115
+ "commit": "c6af0f7fa900a2f497f4c7477bb05ca2c59c7987",
116
+ "comment": "Add onChange event prop to Radio"
117
+ },
118
+ {
119
+ "author": "seanmonahan@microsoft.com",
120
+ "package": "@fluentui/react-radio",
121
+ "commit": "bea6aecfed8612f7b0664ab8bac77c5fccee1efb",
122
+ "comment": "update react-icons version to ^2.0.166-rc.3 from ^2.0.159-beta.10"
123
+ },
124
+ {
125
+ "author": "olfedias@microsoft.com",
126
+ "package": "@fluentui/react-radio",
127
+ "commit": "e569d6e04d83cbcc6225e61db52ff81d2addd363",
128
+ "comment": "chore: Update Griffel to latest version"
129
+ },
130
+ {
131
+ "author": "seanmonahan@microsoft.com",
132
+ "package": "@fluentui/react-radio",
133
+ "commit": "0f509ed4c7e26548ae9d27e3001bd8db4784e838",
134
+ "comment": "Radio/RadioGroup API alignment."
135
+ },
136
+ {
137
+ "author": "beachball",
138
+ "package": "@fluentui/react-radio",
139
+ "comment": "Bump @fluentui/react-label to v9.0.0-beta.10",
140
+ "commit": "f94b48c825ca8c8b2e3b6755bdd29fe15c7d435d"
141
+ },
142
+ {
143
+ "author": "beachball",
144
+ "package": "@fluentui/react-radio",
145
+ "comment": "Bump @fluentui/react-tabster to v9.0.0-rc.6",
146
+ "commit": "f94b48c825ca8c8b2e3b6755bdd29fe15c7d435d"
147
+ },
148
+ {
149
+ "author": "beachball",
150
+ "package": "@fluentui/react-radio",
151
+ "comment": "Bump @fluentui/react-theme to v9.0.0-rc.5",
152
+ "commit": "f94b48c825ca8c8b2e3b6755bdd29fe15c7d435d"
153
+ },
154
+ {
155
+ "author": "beachball",
156
+ "package": "@fluentui/react-radio",
157
+ "comment": "Bump @fluentui/react-utilities to v9.0.0-rc.6",
158
+ "commit": "f94b48c825ca8c8b2e3b6755bdd29fe15c7d435d"
159
+ },
160
+ {
161
+ "author": "beachball",
162
+ "package": "@fluentui/react-radio",
163
+ "comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.4",
164
+ "commit": "f94b48c825ca8c8b2e3b6755bdd29fe15c7d435d"
165
+ }
166
+ ],
167
+ "none": [
168
+ {
169
+ "author": "mgodbolt@microsoft.com",
170
+ "package": "@fluentui/react-radio",
171
+ "commit": "905e46db07ada986fd7885531f72a71b7bbaabdc",
172
+ "comment": "create v9 api extractor config and set all v9 packags to use it, suppress forgotten export"
173
+ },
174
+ {
175
+ "author": "elcraig@microsoft.com",
176
+ "package": "@fluentui/react-radio",
177
+ "commit": "b7f17e976f9e058f39c9fce4f0f9bb6eb4dfa577",
178
+ "comment": "Update React dev deps and hoist them to the repo root"
179
+ }
180
+ ]
181
+ }
182
+ },
183
+ {
184
+ "date": "Fri, 04 Mar 2022 05:17:40 GMT",
6
185
  "tag": "@fluentui/react-radio_v9.0.0-beta.2",
7
186
  "version": "9.0.0-beta.2",
8
187
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,59 @@
1
1
  # Change Log - @fluentui/react-radio
2
2
 
3
- This log was last generated on Fri, 04 Mar 2022 05:15:54 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 04 May 2022 13:24:16 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-beta.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.0.0-beta.5)
8
+
9
+ Wed, 04 May 2022 13:24:16 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-radio_v9.0.0-beta.4..@fluentui/react-radio_v9.0.0-beta.5)
11
+
12
+ ### Changes
13
+
14
+ - react-radio: update context usage ([PR #22803](https://github.com/microsoft/fluentui/pull/22803) by seanmonahan@microsoft.com)
15
+ - add bundle size fixtures ([PR #22675](https://github.com/microsoft/fluentui/pull/22675) by seanmonahan@microsoft.com)
16
+ - react-radio: add required prop to RadioGroup ([PR #22809](https://github.com/microsoft/fluentui/pull/22809) by seanmonahan@microsoft.com)
17
+ - react-radio: remove required indicator from label ([PR #22782](https://github.com/microsoft/fluentui/pull/22782) by seanmonahan@microsoft.com)
18
+ - write readme ([PR #22676](https://github.com/microsoft/fluentui/pull/22676) by seanmonahan@microsoft.com)
19
+ - Allow data argument on onChange ([PR #22753](https://github.com/microsoft/fluentui/pull/22753) by miroslav.stastny@microsoft.com)
20
+ - Bump @fluentui/react-context-selector to v9.0.0-rc.7 ([PR #22786](https://github.com/microsoft/fluentui/pull/22786) by beachball)
21
+ - Bump @fluentui/react-label to v9.0.0-beta.11 ([PR #22786](https://github.com/microsoft/fluentui/pull/22786) by beachball)
22
+ - Bump @fluentui/react-tabster to v9.0.0-rc.8 ([PR #22786](https://github.com/microsoft/fluentui/pull/22786) by beachball)
23
+ - Bump @fluentui/react-theme to v9.0.0-rc.6 ([PR #22786](https://github.com/microsoft/fluentui/pull/22786) by beachball)
24
+ - Bump @fluentui/react-utilities to v9.0.0-rc.7 ([PR #22786](https://github.com/microsoft/fluentui/pull/22786) by beachball)
25
+
26
+ ## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.0.0-beta.4)
27
+
28
+ Mon, 25 Apr 2022 09:32:19 GMT
29
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-radio_v9.0.0-beta.3..@fluentui/react-radio_v9.0.0-beta.4)
30
+
31
+ ### Changes
32
+
33
+ - Bump @fluentui/react-tabster to v9.0.0-rc.7 ([PR #22601](https://github.com/microsoft/fluentui/pull/22601) by beachball)
34
+
35
+ ## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.0.0-beta.3)
36
+
37
+ Tue, 19 Apr 2022 19:16:50 GMT
38
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-radio_v9.0.0-beta.2..@fluentui/react-radio_v9.0.0-beta.3)
39
+
40
+ ### Changes
41
+
42
+ - Deprecate static classname string for Radio. ([PR #21960](https://github.com/microsoft/fluentui/pull/21960) by seanmonahan@microsoft.com)
43
+ - Remove star exports from react-radio ([PR #22106](https://github.com/microsoft/fluentui/pull/22106) by seanmonahan@microsoft.com)
44
+ - Add onChange event prop to Radio ([PR #22104](https://github.com/microsoft/fluentui/pull/22104) by seanmonahan@microsoft.com)
45
+ - update react-icons version to ^2.0.166-rc.3 from ^2.0.159-beta.10 ([PR #22512](https://github.com/microsoft/fluentui/pull/22512) by seanmonahan@microsoft.com)
46
+ - chore: Update Griffel to latest version ([PR #21976](https://github.com/microsoft/fluentui/pull/21976) by olfedias@microsoft.com)
47
+ - Radio/RadioGroup API alignment. ([PR #22065](https://github.com/microsoft/fluentui/pull/22065) by seanmonahan@microsoft.com)
48
+ - Bump @fluentui/react-label to v9.0.0-beta.10 ([PR #21995](https://github.com/microsoft/fluentui/pull/21995) by beachball)
49
+ - Bump @fluentui/react-tabster to v9.0.0-rc.6 ([PR #21995](https://github.com/microsoft/fluentui/pull/21995) by beachball)
50
+ - Bump @fluentui/react-theme to v9.0.0-rc.5 ([PR #21995](https://github.com/microsoft/fluentui/pull/21995) by beachball)
51
+ - Bump @fluentui/react-utilities to v9.0.0-rc.6 ([PR #21995](https://github.com/microsoft/fluentui/pull/21995) by beachball)
52
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.4 ([PR #21995](https://github.com/microsoft/fluentui/pull/21995) by beachball)
53
+
7
54
  ## [9.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.0.0-beta.2)
8
55
 
9
- Fri, 04 Mar 2022 05:15:54 GMT
56
+ Fri, 04 Mar 2022 05:17:40 GMT
10
57
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-radio_v9.0.0-beta.1..@fluentui/react-radio_v9.0.0-beta.2)
11
58
 
12
59
  ### Changes
package/README.md CHANGED
@@ -3,3 +3,42 @@
3
3
  **React Radio components for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)**
4
4
 
5
5
  These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
6
+
7
+ 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.
8
+
9
+ ### Usage
10
+
11
+ Import `Radio` and `RadioGroup`:
12
+
13
+ ```js
14
+ import { Radio, RadioGroup } from '@fluentui/react-radio';
15
+ ```
16
+
17
+ #### Examples
18
+
19
+ ```jsx
20
+ <RadioGroup defaultValue="B">
21
+ <Radio value="A" label="Option A" />
22
+ <Radio value="B" label="Option B" />
23
+ <Radio value="C" label="Option C" />
24
+ <Radio value="D" label="Option D" />
25
+ </RadioGroup>
26
+
27
+ <RadioGroup value={value} onChange={(_, data) => setValue(data.value)}>
28
+ <Radio value="A" label="Option A" />
29
+ <Radio value="B" label="Option B" />
30
+ <Radio value="C" label="Option C" />
31
+ <Radio value="D" label="Option D" />
32
+ </RadioGroup>
33
+ ```
34
+
35
+ See [Fluent UI Storybook](https://aka.ms/fluentui-storybook) for more detailed usage examples.
36
+
37
+ Alternatively, run Storybook locally with:
38
+
39
+ 1. `yarn start`
40
+ 2. Select `react-radio` from the list.
41
+
42
+ ### Specification
43
+
44
+ See [Spec.md](./Spec.md).
@@ -1,30 +1,46 @@
1
1
  import type { ComponentProps } from '@fluentui/react-utilities';
2
2
  import type { ComponentState } from '@fluentui/react-utilities';
3
+ import type { Context } from '@fluentui/react-context-selector';
3
4
  import type { ForwardRefComponent } from '@fluentui/react-utilities';
4
5
  import { Label } from '@fluentui/react-label';
5
6
  import * as React_2 from 'react';
6
7
  import type { Slot } from '@fluentui/react-utilities';
8
+ import type { SlotClassNames } from '@fluentui/react-utilities';
7
9
 
8
10
  /**
9
11
  * Radio component is a wrapper for a radio button with a label.
10
12
  */
11
13
  export declare const Radio: ForwardRefComponent<RadioProps>;
12
14
 
15
+ /**
16
+ * @deprecated Use `radioClassNames.root` instead.
17
+ */
13
18
  export declare const radioClassName = "fui-Radio";
14
19
 
20
+ export declare const radioClassNames: SlotClassNames<RadioSlots>;
21
+
15
22
  /**
16
23
  * A RadioGroup component presents a set of options where only one option can be selected.
17
24
  */
18
25
  export declare const RadioGroup: ForwardRefComponent<RadioGroupProps>;
19
26
 
27
+ /**
28
+ * @deprecated Use `radioGroupClassNames.root` instead.
29
+ */
20
30
  export declare const radioGroupClassName = "fui-RadioGroup";
21
31
 
32
+ export declare const radioGroupClassNames: SlotClassNames<RadioGroupSlots>;
33
+
22
34
  /**
23
35
  * RadioGroupContext is provided by RadioGroup, and is consumed by Radio to determine default values of some props.
24
36
  */
25
- export declare const RadioGroupContext: React_2.Context<RadioGroupContextValue>;
37
+ export declare const RadioGroupContext: Context<RadioGroupContextValue>;
38
+
39
+ export declare type RadioGroupContextValue = Pick<RadioGroupProps, 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required'>;
26
40
 
27
- export declare type RadioGroupContextValue = Pick<RadioGroupProps, 'name' | 'layout' | 'value' | 'defaultValue' | 'disabled'>;
41
+ export declare type RadioGroupContextValues = {
42
+ radioGroup: RadioGroupContextValue;
43
+ };
28
44
 
29
45
  /**
30
46
  * Data for the onChange event for RadioGroup.
@@ -62,33 +78,45 @@ export declare type RadioGroupProps = Omit<ComponentProps<Partial<RadioGroupSlot
62
78
  /**
63
79
  * How the radio items are laid out in the group.
64
80
  *
65
- * @defaultvalue vertical
81
+ * @default vertical
66
82
  */
67
83
  layout?: 'vertical' | 'horizontal' | 'horizontalStacked';
68
84
  /**
69
85
  * Disable all Radio items in this group.
70
86
  */
71
87
  disabled?: boolean;
88
+ /**
89
+ * Require all Radio items in this group.
90
+ */
91
+ required?: boolean;
72
92
  };
73
93
 
74
94
  export declare type RadioGroupSlots = {
75
95
  /**
76
96
  * The radio group root.
77
97
  */
78
- root: Slot<'div'>;
98
+ root: NonNullable<Slot<'div'>>;
79
99
  };
80
100
 
81
101
  /**
82
102
  * State used in rendering RadioGroup
83
103
  */
84
- export declare type RadioGroupState = ComponentState<RadioGroupSlots> & Required<Pick<RadioGroupProps, 'layout'>> & {
85
- context: RadioGroupContextValue;
104
+ export declare type RadioGroupState = ComponentState<RadioGroupSlots> & Required<Pick<RadioGroupProps, 'layout'>> & Partial<Exclude<RadioGroupProps, 'onChange' | 'layout'>>;
105
+
106
+ /**
107
+ * Data for the onChange event for Radio.
108
+ */
109
+ export declare type RadioOnChangeData = {
110
+ /**
111
+ * The value prop of this Radio item.
112
+ */
113
+ value: string;
86
114
  };
87
115
 
88
116
  /**
89
117
  * Radio Props
90
118
  */
91
- export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input'>, 'size'> & {
119
+ export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input'>, 'onChange' | 'size'> & {
92
120
  /**
93
121
  * The value of the RadioGroup when this Radio item is selected.
94
122
  */
@@ -106,6 +134,13 @@ export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input
106
134
  * Disable this Radio item.
107
135
  */
108
136
  disabled?: boolean;
137
+ /**
138
+ * Callback when this Radio is selected in its group.
139
+ *
140
+ * **Note:** `onChange` is NOT called when this Radio is deselected.
141
+ * Use RadioGroup's `onChange` event to determine when the selection in the group changes.
142
+ */
143
+ onChange?: (ev: React_2.ChangeEvent<HTMLInputElement>, data: RadioOnChangeData) => void;
109
144
  };
110
145
 
111
146
  export declare type RadioSlots = {
@@ -146,7 +181,7 @@ export declare const renderRadio_unstable: (state: RadioState) => JSX.Element;
146
181
  /**
147
182
  * Render the final JSX of RadioGroup
148
183
  */
149
- export declare const renderRadioGroup_unstable: (state: RadioGroupState) => JSX.Element;
184
+ export declare const renderRadioGroup_unstable: (state: RadioGroupState, contextValues: RadioGroupContextValues) => JSX.Element;
150
185
 
151
186
  /**
152
187
  * Create the state required to render Radio.
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { Label } from '@fluentui/react-label';
2
3
  import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
3
4
  export declare type RadioSlots = {
@@ -27,7 +28,7 @@ export declare type RadioSlots = {
27
28
  /**
28
29
  * Radio Props
29
30
  */
30
- export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input'>, 'size'> & {
31
+ export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input'>, 'onChange' | 'size'> & {
31
32
  /**
32
33
  * The value of the RadioGroup when this Radio item is selected.
33
34
  */
@@ -45,6 +46,22 @@ export declare type RadioProps = Omit<ComponentProps<Partial<RadioSlots>, 'input
45
46
  * Disable this Radio item.
46
47
  */
47
48
  disabled?: boolean;
49
+ /**
50
+ * Callback when this Radio is selected in its group.
51
+ *
52
+ * **Note:** `onChange` is NOT called when this Radio is deselected.
53
+ * Use RadioGroup's `onChange` event to determine when the selection in the group changes.
54
+ */
55
+ onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: RadioOnChangeData) => void;
56
+ };
57
+ /**
58
+ * Data for the onChange event for Radio.
59
+ */
60
+ export declare type RadioOnChangeData = {
61
+ /**
62
+ * The value prop of this Radio item.
63
+ */
64
+ value: string;
48
65
  };
49
66
  /**
50
67
  * State used in rendering Radio
@@ -1 +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"]}
1
+ {"version":3,"file":"Radio.types.js","sourceRoot":"../src/","sources":["components/Radio/Radio.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { 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'>, 'onChange' | '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 * Callback when this Radio is selected in its group.\n *\n * **Note:** `onChange` is NOT called when this Radio is deselected.\n * Use RadioGroup's `onChange` event to determine when the selection in the group changes.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: RadioOnChangeData) => void;\n};\n\n/**\n * Data for the onChange event for Radio.\n */\nexport type RadioOnChangeData = {\n /**\n * The value prop of this Radio item.\n */\n value: string;\n};\n\n/**\n * State used in rendering Radio\n */\nexport type RadioState = ComponentState<RadioSlots> & Required<Pick<RadioProps, 'labelPosition'>>;\n"]}
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { CircleFilled } from '@fluentui/react-icons';
3
3
  import { Label } from '@fluentui/react-label';
4
- import { getPartitionedNativeProps, resolveShorthand, useId } from '@fluentui/react-utilities';
4
+ import { getPartitionedNativeProps, resolveShorthand, useId, useMergedEventCallbacks } from '@fluentui/react-utilities';
5
5
  import { RadioGroupContext } from '../../contexts/RadioGroupContext';
6
+ import { useContextSelector } from '@fluentui/react-context-selector';
6
7
  /**
7
8
  * Create the state required to render Radio.
8
9
  *
@@ -14,19 +15,25 @@ import { RadioGroupContext } from '../../contexts/RadioGroupContext';
14
15
  */
15
16
 
16
17
  export const useRadio_unstable = (props, ref) => {
17
- const group = React.useContext(RadioGroupContext);
18
+ const nameGroup = useContextSelector(RadioGroupContext, ctx => ctx.name);
19
+ const value = useContextSelector(RadioGroupContext, ctx => ctx.value);
20
+ const defaultValue = useContextSelector(RadioGroupContext, ctx => ctx.defaultValue);
21
+ const disabledGroup = useContextSelector(RadioGroupContext, ctx => ctx.disabled);
22
+ const layout = useContextSelector(RadioGroupContext, ctx => ctx.layout);
23
+ const requiredGroup = useContextSelector(RadioGroupContext, ctx => ctx.required);
18
24
  const {
19
- name = group.name,
20
- checked = group.value !== undefined ? group.value === props.value : undefined,
21
- defaultChecked = group.defaultValue !== undefined ? group.defaultValue === props.value : undefined,
22
- labelPosition = group.layout === 'horizontalStacked' ? 'below' : 'after',
23
- disabled = group.disabled,
24
- required
25
+ name = nameGroup,
26
+ checked = value !== undefined ? value === props.value : undefined,
27
+ defaultChecked = defaultValue !== undefined ? defaultValue === props.value : undefined,
28
+ labelPosition = layout === 'horizontalStacked' ? 'below' : 'after',
29
+ disabled = disabledGroup,
30
+ required = requiredGroup,
31
+ onChange
25
32
  } = props;
26
33
  const nativeProps = getPartitionedNativeProps({
27
34
  props,
28
35
  primarySlotTagName: 'input',
29
- excludedPropNames: ['checked', 'defaultChecked']
36
+ excludedPropNames: ['checked', 'defaultChecked', 'onChange']
30
37
  });
31
38
  const root = resolveShorthand(props.root, {
32
39
  required: true,
@@ -42,14 +49,17 @@ export const useRadio_unstable = (props, ref) => {
42
49
  checked,
43
50
  defaultChecked,
44
51
  disabled,
52
+ required,
45
53
  ...nativeProps.primary
46
54
  }
47
55
  });
56
+ input.onChange = useMergedEventCallbacks(input.onChange, ev => onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
57
+ value: ev.currentTarget.value
58
+ }));
48
59
  const label = resolveShorthand(props.label, {
49
60
  defaultProps: {
50
61
  htmlFor: input.id,
51
- disabled,
52
- required
62
+ disabled
53
63
  }
54
64
  });
55
65
  const indicator = resolveShorthand(props.indicator, {
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Radio/useRadio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,YAAT,QAA6B,uBAA7B;AACA,SAAS,KAAT,QAAsB,uBAAtB;AACA,SAAS,yBAAT,EAAoC,gBAApC,EAAsD,KAAtD,QAAmE,2BAAnE;AACA,SAAS,iBAAT,QAAkC,kCAAlC;AAGA;;;;;;;;AAQG;;AACH,OAAO,MAAM,iBAAiB,GAAG,CAAC,KAAD,EAAoB,GAApB,KAAoE;AACnG,QAAM,KAAK,GAAG,KAAK,CAAC,UAAN,CAAiB,iBAAjB,CAAd;AAEA,QAAM;AACJ,IAAA,IAAI,GAAG,KAAK,CAAC,IADT;AAEJ,IAAA,OAAO,GAAG,KAAK,CAAC,KAAN,KAAgB,SAAhB,GAA4B,KAAK,CAAC,KAAN,KAAgB,KAAK,CAAC,KAAlD,GAA0D,SAFhE;AAGJ,IAAA,cAAc,GAAG,KAAK,CAAC,YAAN,KAAuB,SAAvB,GAAmC,KAAK,CAAC,YAAN,KAAuB,KAAK,CAAC,KAAhE,GAAwE,SAHrF;AAIJ,IAAA,aAAa,GAAG,KAAK,CAAC,MAAN,KAAiB,mBAAjB,GAAuC,OAAvC,GAAiD,OAJ7D;AAKJ,IAAA,QAAQ,GAAG,KAAK,CAAC,QALb;AAMJ,IAAA;AANI,MAOF,KAPJ;AASA,QAAM,WAAW,GAAG,yBAAyB,CAAC;AAC5C,IAAA,KAD4C;AAE5C,IAAA,kBAAkB,EAAE,OAFwB;AAG5C,IAAA,iBAAiB,EAAE,CAAC,SAAD,EAAY,gBAAZ;AAHyB,GAAD,CAA7C;AAMA,QAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAP,EAAa;AACxC,IAAA,QAAQ,EAAE,IAD8B;AAExC,IAAA,YAAY,EAAE,WAAW,CAAC;AAFc,GAAb,CAA7B;AAKA,QAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAP,EAAc;AAC1C,IAAA,QAAQ,EAAE,IADgC;AAE1C,IAAA,YAAY,EAAE;AACZ,MAAA,GADY;AAEZ,MAAA,IAAI,EAAE,OAFM;AAGZ,MAAA,EAAE,EAAE,KAAK,CAAC,QAAD,EAAW,WAAW,CAAC,OAAZ,CAAoB,EAA/B,CAHG;AAIZ,MAAA,IAJY;AAKZ,MAAA,OALY;AAMZ,MAAA,cANY;AAOZ,MAAA,QAPY;AAQZ,SAAG,WAAW,CAAC;AARH;AAF4B,GAAd,CAA9B;AAcA,QAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAP,EAAc;AAC1C,IAAA,YAAY,EAAE;AACZ,MAAA,OAAO,EAAE,KAAK,CAAC,EADH;AAEZ,MAAA,QAFY;AAGZ,MAAA;AAHY;AAD4B,GAAd,CAA9B;AAQA,QAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,SAAP,EAAkB;AAClD,IAAA,QAAQ,EAAE,IADwC;AAElD,IAAA,YAAY,EAAE;AACZ,qBAAe,IADH;AAEZ,MAAA,QAAQ,eAAE,KAAA,CAAA,aAAA,CAAC,YAAD,EAAa,IAAb;AAFE;AAFoC,GAAlB,CAAlC;AAQA,SAAO;AACL,IAAA,aADK;AAEL,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE,MADI;AAEV,MAAA,KAAK,EAAE,OAFG;AAGV,MAAA,KAAK,EAAE,KAHG;AAIV,MAAA,SAAS,EAAE;AAJD,KAFP;AAQL,IAAA,IARK;AASL,IAAA,KATK;AAUL,IAAA,KAVK;AAWL,IAAA;AAXK,GAAP;AAaD,CAlEM","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/"}
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, useMergedEventCallbacks } from '@fluentui/react-utilities';\nimport { RadioGroupContext } from '../../contexts/RadioGroupContext';\nimport { useContextSelector } from '@fluentui/react-context-selector';\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 nameGroup = useContextSelector(RadioGroupContext, ctx => ctx.name);\n const value = useContextSelector(RadioGroupContext, ctx => ctx.value);\n const defaultValue = useContextSelector(RadioGroupContext, ctx => ctx.defaultValue);\n const disabledGroup = useContextSelector(RadioGroupContext, ctx => ctx.disabled);\n const layout = useContextSelector(RadioGroupContext, ctx => ctx.layout);\n const requiredGroup = useContextSelector(RadioGroupContext, ctx => ctx.required);\n\n const {\n name = nameGroup,\n checked = value !== undefined ? value === props.value : undefined,\n defaultChecked = defaultValue !== undefined ? defaultValue === props.value : undefined,\n labelPosition = layout === 'horizontalStacked' ? 'below' : 'after',\n disabled = disabledGroup,\n required = requiredGroup,\n onChange,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\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 required,\n ...nativeProps.primary,\n },\n });\n\n input.onChange = useMergedEventCallbacks(input.onChange, ev => onChange?.(ev, { value: ev.currentTarget.value }));\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n htmlFor: input.id,\n disabled,\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/"}
@@ -1,5 +1,10 @@
1
- import type { RadioState } from './Radio.types';
1
+ import type { RadioSlots, RadioState } from './Radio.types';
2
+ import type { SlotClassNames } from '@fluentui/react-utilities';
3
+ /**
4
+ * @deprecated Use `radioClassNames.root` instead.
5
+ */
2
6
  export declare const radioClassName = "fui-Radio";
7
+ export declare const radioClassNames: SlotClassNames<RadioSlots>;
3
8
  /**
4
9
  * Apply styling to the Radio slots based on the state
5
10
  */