@fluentui/react-radio 9.5.16 → 9.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -3
- package/dist/index.d.ts +26 -2
- package/lib/Radio.js +1 -1
- package/lib/Radio.js.map +1 -1
- package/lib/RadioGroup.js +1 -1
- package/lib/RadioGroup.js.map +1 -1
- package/lib/components/Radio/Radio.types.js.map +1 -1
- package/lib/components/Radio/index.js +1 -1
- package/lib/components/Radio/index.js.map +1 -1
- package/lib/components/Radio/renderRadio.js.map +1 -1
- package/lib/components/Radio/useRadio.js +27 -2
- package/lib/components/Radio/useRadio.js.map +1 -1
- package/lib/components/RadioGroup/RadioGroup.types.js.map +1 -1
- package/lib/components/RadioGroup/index.js +1 -1
- package/lib/components/RadioGroup/index.js.map +1 -1
- package/lib/components/RadioGroup/renderRadioGroup.js.map +1 -1
- package/lib/components/RadioGroup/useRadioGroup.js +11 -2
- package/lib/components/RadioGroup/useRadioGroup.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Radio.js +3 -0
- package/lib-commonjs/Radio.js.map +1 -1
- package/lib-commonjs/RadioGroup.js +3 -0
- package/lib-commonjs/RadioGroup.js.map +1 -1
- package/lib-commonjs/components/Radio/Radio.types.js.map +1 -1
- package/lib-commonjs/components/Radio/index.js +3 -0
- package/lib-commonjs/components/Radio/index.js.map +1 -1
- package/lib-commonjs/components/Radio/renderRadio.js.map +1 -1
- package/lib-commonjs/components/Radio/useRadio.js +30 -5
- package/lib-commonjs/components/Radio/useRadio.js.map +1 -1
- package/lib-commonjs/components/RadioGroup/RadioGroup.types.js.map +1 -1
- package/lib-commonjs/components/RadioGroup/index.js +3 -0
- package/lib-commonjs/components/RadioGroup/index.js.map +1 -1
- package/lib-commonjs/components/RadioGroup/renderRadioGroup.js.map +1 -1
- package/lib-commonjs/components/RadioGroup/useRadioGroup.js +20 -5
- package/lib-commonjs/components/RadioGroup/useRadioGroup.js.map +1 -1
- package/lib-commonjs/index.js +6 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-radio
|
|
2
2
|
|
|
3
|
-
This log was last generated on Wed,
|
|
3
|
+
This log was last generated on Wed, 01 Apr 2026 15:50:23 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.6.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.6.1)
|
|
8
|
+
|
|
9
|
+
Wed, 01 Apr 2026 15:50:23 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-radio_v9.6.0..@fluentui/react-radio_v9.6.1)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-field to v9.5.0 ([PR #35912](https://github.com/microsoft/fluentui/pull/35912) by beachball)
|
|
15
|
+
- Bump @fluentui/react-label to v9.4.0 ([PR #35912](https://github.com/microsoft/fluentui/pull/35912) by beachball)
|
|
16
|
+
|
|
17
|
+
## [9.6.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.6.0)
|
|
18
|
+
|
|
19
|
+
Mon, 30 Mar 2026 14:37:41 GMT
|
|
20
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-radio_v9.5.16..@fluentui/react-radio_v9.6.0)
|
|
21
|
+
|
|
22
|
+
### Minor changes
|
|
23
|
+
|
|
24
|
+
- feat: expose base state hooks for Radio components ([PR #35894](https://github.com/microsoft/fluentui/pull/35894) by dmytrokirpa@microsoft.com)
|
|
25
|
+
|
|
7
26
|
## [9.5.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.5.16)
|
|
8
27
|
|
|
9
|
-
Wed, 11 Mar 2026 09:
|
|
28
|
+
Wed, 11 Mar 2026 09:22:22 GMT
|
|
10
29
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-radio_v9.5.15..@fluentui/react-radio_v9.5.16)
|
|
11
30
|
|
|
12
31
|
### Patches
|
|
13
32
|
|
|
14
|
-
- Bump @fluentui/react-field to v9.4.16 ([PR #
|
|
33
|
+
- Bump @fluentui/react-field to v9.4.16 ([PR #35859](https://github.com/microsoft/fluentui/pull/35859) by beachball)
|
|
15
34
|
|
|
16
35
|
## [9.5.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-radio_v9.5.15)
|
|
17
36
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const Radio: ForwardRefComponent<RadioProps>;
|
|
14
14
|
|
|
15
|
+
export declare type RadioBaseProps = RadioProps;
|
|
16
|
+
|
|
17
|
+
export declare type RadioBaseState = RadioState;
|
|
18
|
+
|
|
15
19
|
export declare const radioClassNames: SlotClassNames<RadioSlots>;
|
|
16
20
|
|
|
17
21
|
/**
|
|
@@ -19,6 +23,10 @@ export declare const radioClassNames: SlotClassNames<RadioSlots>;
|
|
|
19
23
|
*/
|
|
20
24
|
export declare const RadioGroup: ForwardRefComponent<RadioGroupProps>;
|
|
21
25
|
|
|
26
|
+
export declare type RadioGroupBaseProps = Omit<RadioGroupProps, 'layout'>;
|
|
27
|
+
|
|
28
|
+
export declare type RadioGroupBaseState = Omit<RadioGroupState, 'layout'>;
|
|
29
|
+
|
|
22
30
|
export declare const radioGroupClassNames: SlotClassNames<RadioGroupSlots>;
|
|
23
31
|
|
|
24
32
|
export declare type RadioGroupContextValue = Pick<RadioGroupProps, 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required' | 'aria-describedby'>;
|
|
@@ -163,12 +171,12 @@ export declare type RadioState = ComponentState<RadioSlots> & Required<Pick<Radi
|
|
|
163
171
|
/**
|
|
164
172
|
* Render the final JSX of Radio
|
|
165
173
|
*/
|
|
166
|
-
export declare const renderRadio_unstable: (state:
|
|
174
|
+
export declare const renderRadio_unstable: (state: RadioBaseState) => JSXElement;
|
|
167
175
|
|
|
168
176
|
/**
|
|
169
177
|
* Render the final JSX of RadioGroup
|
|
170
178
|
*/
|
|
171
|
-
export declare const renderRadioGroup_unstable: (state:
|
|
179
|
+
export declare const renderRadioGroup_unstable: (state: RadioGroupBaseState, contextValues: RadioGroupContextValues) => JSXElement;
|
|
172
180
|
|
|
173
181
|
/**
|
|
174
182
|
* Create the state required to render Radio.
|
|
@@ -181,6 +189,17 @@ export declare const renderRadioGroup_unstable: (state: RadioGroupState, context
|
|
|
181
189
|
*/
|
|
182
190
|
export declare const useRadio_unstable: (props: RadioProps, ref: React_2.Ref<HTMLInputElement>) => RadioState;
|
|
183
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Create the state required to render Radio.
|
|
194
|
+
*
|
|
195
|
+
* The returned state can be modified with hooks such as useRadioStyles_unstable,
|
|
196
|
+
* before being passed to renderRadio_unstable.
|
|
197
|
+
*
|
|
198
|
+
* @param props - props from this instance of Radio
|
|
199
|
+
* @param ref - reference to `<input>` element of Radio
|
|
200
|
+
*/
|
|
201
|
+
export declare const useRadioBase_unstable: (props: RadioBaseProps, ref: React_2.Ref<HTMLInputElement>) => RadioBaseState;
|
|
202
|
+
|
|
184
203
|
/**
|
|
185
204
|
* Create the state required to render RadioGroup.
|
|
186
205
|
*
|
|
@@ -192,6 +211,11 @@ export declare const useRadio_unstable: (props: RadioProps, ref: React_2.Ref<HTM
|
|
|
192
211
|
*/
|
|
193
212
|
export declare const useRadioGroup_unstable: (props: RadioGroupProps, ref: React_2.Ref<HTMLDivElement>) => RadioGroupState;
|
|
194
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Create the base state required to render RadioGroup, without design-related properties such as `layout`.
|
|
216
|
+
*/
|
|
217
|
+
export declare const useRadioGroupBase_unstable: (props: RadioGroupBaseProps, ref: React_2.Ref<HTMLDivElement>) => RadioGroupBaseState;
|
|
218
|
+
|
|
195
219
|
/**
|
|
196
220
|
* @deprecated Use useRadioGroupContextValue_unstable instead.
|
|
197
221
|
* RadioGroupContext is no longer a selector context, and no longer benefits from having a selector.
|
package/lib/Radio.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Radio, radioClassNames, renderRadio_unstable, useRadioStyles_unstable, useRadio_unstable } from './components/Radio/index';
|
|
1
|
+
export { Radio, radioClassNames, renderRadio_unstable, useRadioStyles_unstable, useRadio_unstable, useRadioBase_unstable } from './components/Radio/index';
|
package/lib/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Radio.ts"],"sourcesContent":["export type {
|
|
1
|
+
{"version":3,"sources":["../src/Radio.ts"],"sourcesContent":["export type {\n RadioOnChangeData,\n RadioProps,\n RadioSlots,\n RadioState,\n RadioBaseProps,\n RadioBaseState,\n} from './components/Radio/index';\nexport {\n Radio,\n radioClassNames,\n renderRadio_unstable,\n useRadioStyles_unstable,\n useRadio_unstable,\n useRadioBase_unstable,\n} from './components/Radio/index';\n"],"names":["Radio","radioClassNames","renderRadio_unstable","useRadioStyles_unstable","useRadio_unstable","useRadioBase_unstable"],"mappings":"AAQA,SACEA,KAAK,EACLC,eAAe,EACfC,oBAAoB,EACpBC,uBAAuB,EACvBC,iBAAiB,EACjBC,qBAAqB,QAChB,2BAA2B"}
|
package/lib/RadioGroup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RadioGroup, radioGroupClassNames, renderRadioGroup_unstable, useRadioGroupStyles_unstable, useRadioGroup_unstable } from './components/RadioGroup/index';
|
|
1
|
+
export { RadioGroup, radioGroupClassNames, renderRadioGroup_unstable, useRadioGroupStyles_unstable, useRadioGroup_unstable, useRadioGroupBase_unstable } from './components/RadioGroup/index';
|
package/lib/RadioGroup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/RadioGroup.ts"],"sourcesContent":["export type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n} from './components/RadioGroup/index';\nexport {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n} from './components/RadioGroup/index';\n"],"names":["RadioGroup","radioGroupClassNames","renderRadioGroup_unstable","useRadioGroupStyles_unstable","useRadioGroup_unstable"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/RadioGroup.ts"],"sourcesContent":["export type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n RadioGroupBaseProps,\n RadioGroupBaseState,\n} from './components/RadioGroup/index';\nexport {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n useRadioGroupBase_unstable,\n} from './components/RadioGroup/index';\n"],"names":["RadioGroup","radioGroupClassNames","renderRadioGroup_unstable","useRadioGroupStyles_unstable","useRadioGroup_unstable","useRadioGroupBase_unstable"],"mappings":"AAUA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,yBAAyB,EACzBC,4BAA4B,EAC5BC,sBAAsB,EACtBC,0BAA0B,QACrB,gCAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/Radio.types.ts"],"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 // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\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"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/Radio.types.ts"],"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 // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: RadioOnChangeData) => void;\n};\n\nexport type RadioBaseProps = RadioProps;\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\nexport type RadioBaseState = RadioState;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Radio } from './Radio';
|
|
2
2
|
export { renderRadio_unstable } from './renderRadio';
|
|
3
|
-
export { useRadio_unstable } from './useRadio';
|
|
3
|
+
export { useRadio_unstable, useRadioBase_unstable } from './useRadio';
|
|
4
4
|
export { radioClassNames, useRadioStyles_unstable } from './useRadioStyles.styles';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/index.ts"],"sourcesContent":["export { Radio } from './Radio';\nexport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/index.ts"],"sourcesContent":["export { Radio } from './Radio';\nexport type {\n RadioOnChangeData,\n RadioProps,\n RadioSlots,\n RadioState,\n RadioBaseProps,\n RadioBaseState,\n} from './Radio.types';\nexport { renderRadio_unstable } from './renderRadio';\nexport { useRadio_unstable, useRadioBase_unstable } from './useRadio';\nexport { radioClassNames, useRadioStyles_unstable } from './useRadioStyles.styles';\n"],"names":["Radio","renderRadio_unstable","useRadio_unstable","useRadioBase_unstable","radioClassNames","useRadioStyles_unstable"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAU;AAShC,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,aAAa;AACtE,SAASC,eAAe,EAAEC,uBAAuB,QAAQ,0BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/renderRadio.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { RadioSlots,
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/renderRadio.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { RadioSlots, RadioBaseState } from './Radio.types';\n\n/**\n * Render the final JSX of Radio\n */\nexport const renderRadio_unstable = (state: RadioBaseState): JSXElement => {\n assertSlots<RadioSlots>(state);\n\n return (\n <state.root>\n <state.input />\n <state.indicator />\n {state.label && <state.label />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderRadio_unstable","state","root","input","indicator","label"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAIxD;;CAEC,GACD,OAAO,MAAMC,uBAAuB,CAACC;IACnCF,YAAwBE;IAExB,qBACE,MAACA,MAAMC,IAAI;;0BACT,KAACD,MAAME,KAAK;0BACZ,KAACF,MAAMG,SAAS;YACfH,MAAMI,KAAK,kBAAI,KAACJ,MAAMI,KAAK;;;AAGlC,EAAE"}
|
|
@@ -13,6 +13,31 @@ import { useFocusWithin } from '@fluentui/react-tabster';
|
|
|
13
13
|
* @param props - props from this instance of Radio
|
|
14
14
|
* @param ref - reference to `<input>` element of Radio
|
|
15
15
|
*/ export const useRadio_unstable = (props, ref)=>{
|
|
16
|
+
const state = useRadioBase_unstable(props, ref);
|
|
17
|
+
return {
|
|
18
|
+
...state,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
20
|
+
components: {
|
|
21
|
+
...state.components,
|
|
22
|
+
label: Label
|
|
23
|
+
},
|
|
24
|
+
label: slot.optional(props.label, {
|
|
25
|
+
defaultProps: {
|
|
26
|
+
...state.label
|
|
27
|
+
},
|
|
28
|
+
elementType: Label
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Create the state required to render Radio.
|
|
34
|
+
*
|
|
35
|
+
* The returned state can be modified with hooks such as useRadioStyles_unstable,
|
|
36
|
+
* before being passed to renderRadio_unstable.
|
|
37
|
+
*
|
|
38
|
+
* @param props - props from this instance of Radio
|
|
39
|
+
* @param ref - reference to `<input>` element of Radio
|
|
40
|
+
*/ export const useRadioBase_unstable = (props, ref)=>{
|
|
16
41
|
const group = useRadioGroupContextValue_unstable();
|
|
17
42
|
const { name = group.name, checked = group.value !== undefined ? group.value === props.value : undefined, defaultChecked = group.defaultValue !== undefined ? group.defaultValue === props.value : undefined, labelPosition = group.layout === 'horizontal-stacked' ? 'below' : 'after', disabled = group.disabled, required = group.required, 'aria-describedby': ariaDescribedBy = group['aria-describedby'], onChange } = props;
|
|
18
43
|
const nativeProps = getPartitionedNativeProps({
|
|
@@ -54,7 +79,7 @@ import { useFocusWithin } from '@fluentui/react-tabster';
|
|
|
54
79
|
htmlFor: input.id,
|
|
55
80
|
disabled: input.disabled
|
|
56
81
|
},
|
|
57
|
-
elementType:
|
|
82
|
+
elementType: 'label'
|
|
58
83
|
});
|
|
59
84
|
const indicator = slot.always(props.indicator, {
|
|
60
85
|
defaultProps: {
|
|
@@ -67,7 +92,7 @@ import { useFocusWithin } from '@fluentui/react-tabster';
|
|
|
67
92
|
components: {
|
|
68
93
|
root: 'span',
|
|
69
94
|
input: 'input',
|
|
70
|
-
label:
|
|
95
|
+
label: 'label',
|
|
71
96
|
indicator: 'div'
|
|
72
97
|
},
|
|
73
98
|
root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/useRadio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport { useRadioGroupContextValue_unstable } from '../../contexts/RadioGroupContext';\nimport { useFocusWithin } from '@fluentui/react-tabster';\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 = useRadioGroupContextValue_unstable();\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 === 'horizontal-stacked' ? 'below' : 'after',\n disabled = group.disabled,\n required = group.required,\n 'aria-describedby': ariaDescribedBy = group['aria-describedby'],\n onChange,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const root = slot.always(props.root, {\n defaultProps: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\n elementType: 'span',\n });\n const input = slot.always(props.input, {\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 'aria-describedby': ariaDescribedBy,\n ...nativeProps.primary,\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { value: ev.currentTarget.value }));\n const label = slot.optional(props.label, {\n defaultProps: { htmlFor: input.id, disabled: input.disabled },\n elementType:
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/useRadio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport { useRadioGroupContextValue_unstable } from '../../contexts/RadioGroupContext';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport type { RadioBaseProps, RadioBaseState, 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 state = useRadioBase_unstable(props, ref);\n\n return {\n ...state,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n components: { ...state.components, label: Label },\n label: slot.optional(props.label, {\n defaultProps: { ...state.label },\n elementType: Label,\n }),\n };\n};\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 useRadioBase_unstable = (props: RadioBaseProps, ref: React.Ref<HTMLInputElement>): RadioBaseState => {\n const group = useRadioGroupContextValue_unstable();\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 === 'horizontal-stacked' ? 'below' : 'after',\n disabled = group.disabled,\n required = group.required,\n 'aria-describedby': ariaDescribedBy = group['aria-describedby'],\n onChange,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const root = slot.always(props.root, {\n defaultProps: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\n elementType: 'span',\n });\n const input = slot.always(props.input, {\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 'aria-describedby': ariaDescribedBy,\n ...nativeProps.primary,\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { value: ev.currentTarget.value }));\n const label = slot.optional(props.label, {\n defaultProps: { htmlFor: input.id, disabled: input.disabled },\n elementType: 'label',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true },\n elementType: 'div',\n });\n return {\n labelPosition,\n components: { root: 'span', input: 'input', label: 'label', indicator: 'div' },\n root,\n input,\n label,\n indicator,\n };\n};\n"],"names":["React","Label","getPartitionedNativeProps","mergeCallbacks","useId","slot","useRadioGroupContextValue_unstable","useFocusWithin","useRadio_unstable","props","ref","state","useRadioBase_unstable","components","label","optional","defaultProps","elementType","group","name","checked","value","undefined","defaultChecked","defaultValue","labelPosition","layout","disabled","required","ariaDescribedBy","onChange","nativeProps","primarySlotTagName","excludedPropNames","root","always","input","type","id","primary","ev","currentTarget","htmlFor","indicator"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,KAAK,QAAQ,wBAAwB;AAC9C,SAASC,yBAAyB,EAAEC,cAAc,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4BAA4B;AACnG,SAASC,kCAAkC,QAAQ,mCAAmC;AACtF,SAASC,cAAc,QAAQ,0BAA0B;AAGzD;;;;;;;;CAQC,GACD,OAAO,MAAMC,oBAAoB,CAACC,OAAmBC;IACnD,MAAMC,QAAQC,sBAAsBH,OAAOC;IAE3C,OAAO;QACL,GAAGC,KAAK;QACR,4DAA4D;QAC5DE,YAAY;YAAE,GAAGF,MAAME,UAAU;YAAEC,OAAOb;QAAM;QAChDa,OAAOT,KAAKU,QAAQ,CAACN,MAAMK,KAAK,EAAE;YAChCE,cAAc;gBAAE,GAAGL,MAAMG,KAAK;YAAC;YAC/BG,aAAahB;QACf;IACF;AACF,EAAE;AAEF;;;;;;;;CAQC,GACD,OAAO,MAAMW,wBAAwB,CAACH,OAAuBC;IAC3D,MAAMQ,QAAQZ;IAEd,MAAM,EACJa,OAAOD,MAAMC,IAAI,EACjBC,UAAUF,MAAMG,KAAK,KAAKC,YAAYJ,MAAMG,KAAK,KAAKZ,MAAMY,KAAK,GAAGC,SAAS,EAC7EC,iBAAiBL,MAAMM,YAAY,KAAKF,YAAYJ,MAAMM,YAAY,KAAKf,MAAMY,KAAK,GAAGC,SAAS,EAClGG,gBAAgBP,MAAMQ,MAAM,KAAK,uBAAuB,UAAU,OAAO,EACzEC,WAAWT,MAAMS,QAAQ,EACzBC,WAAWV,MAAMU,QAAQ,EACzB,oBAAoBC,kBAAkBX,KAAK,CAAC,mBAAmB,EAC/DY,QAAQ,EACT,GAAGrB;IAEJ,MAAMsB,cAAc7B,0BAA0B;QAC5CO;QACAuB,oBAAoB;QACpBC,mBAAmB;YAAC;YAAW;YAAkB;SAAW;IAC9D;IAEA,MAAMC,OAAO7B,KAAK8B,MAAM,CAAC1B,MAAMyB,IAAI,EAAE;QACnClB,cAAc;YACZN,KAAKH;YACL,GAAGwB,YAAYG,IAAI;QACrB;QACAjB,aAAa;IACf;IACA,MAAMmB,QAAQ/B,KAAK8B,MAAM,CAAC1B,MAAM2B,KAAK,EAAE;QACrCpB,cAAc;YACZN;YACA2B,MAAM;YACNC,IAAIlC,MAAM,UAAU2B,YAAYQ,OAAO,CAACD,EAAE;YAC1CnB;YACAC;YACAG;YACAI;YACAC;YACA,oBAAoBC;YACpB,GAAGE,YAAYQ,OAAO;QACxB;QACAtB,aAAa;IACf;IACAmB,MAAMN,QAAQ,GAAG3B,eAAeiC,MAAMN,QAAQ,EAAEU,CAAAA,KAAMV,qBAAAA,+BAAAA,SAAWU,IAAI;YAAEnB,OAAOmB,GAAGC,aAAa,CAACpB,KAAK;QAAC;IACrG,MAAMP,QAAQT,KAAKU,QAAQ,CAACN,MAAMK,KAAK,EAAE;QACvCE,cAAc;YAAE0B,SAASN,MAAME,EAAE;YAAEX,UAAUS,MAAMT,QAAQ;QAAC;QAC5DV,aAAa;IACf;IACA,MAAM0B,YAAYtC,KAAK8B,MAAM,CAAC1B,MAAMkC,SAAS,EAAE;QAC7C3B,cAAc;YAAE,eAAe;QAAK;QACpCC,aAAa;IACf;IACA,OAAO;QACLQ;QACAZ,YAAY;YAAEqB,MAAM;YAAQE,OAAO;YAAStB,OAAO;YAAS6B,WAAW;QAAM;QAC7ET;QACAE;QACAtB;QACA6B;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/RadioGroup.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type RadioGroupSlots = {\n /**\n * The radio group root.\n */\n root: NonNullable<Slot<'div'>>;\n};\n\nexport type RadioGroupProps = Omit<ComponentProps<Partial<RadioGroupSlots>>, 'onChange'> & {\n /**\n * The name of this radio group. This name is applied to all Radio items inside this group.\n *\n * If no name is provided, one will be generated so that all of the Radio items have the same name.\n */\n name?: string;\n\n /**\n * The selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n value?: string;\n\n /**\n * The default selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n defaultValue?: string;\n\n /**\n * Callback when the selected Radio item changes.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.FormEvent<HTMLDivElement>, data: RadioGroupOnChangeData) => void;\n\n /**\n * How the radio items are laid out in the group.\n *\n * @default vertical\n */\n layout?: 'vertical' | 'horizontal' | 'horizontal-stacked';\n\n /**\n * Disable all Radio items in this group.\n */\n disabled?: boolean;\n\n /**\n * Require a selection in this group. Adds the `required` prop to all child Radio items.\n */\n required?: boolean;\n};\n\n/**\n * Data for the onChange event for RadioGroup.\n */\nexport type RadioGroupOnChangeData = {\n /**\n * The value of the newly selected Radio item.\n */\n value: string;\n};\n\n/**\n * State used in rendering RadioGroup\n */\nexport type RadioGroupState = ComponentState<RadioGroupSlots> &\n Required<Pick<RadioGroupProps, 'layout'>> &\n Pick<RadioGroupProps, 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required'>;\n\nexport type RadioGroupContextValue = Pick<\n RadioGroupProps,\n 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required' | 'aria-describedby'\n>;\n\nexport type RadioGroupContextValues = {\n radioGroup: RadioGroupContextValue;\n};\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/RadioGroup.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type RadioGroupSlots = {\n /**\n * The radio group root.\n */\n root: NonNullable<Slot<'div'>>;\n};\n\nexport type RadioGroupProps = Omit<ComponentProps<Partial<RadioGroupSlots>>, 'onChange'> & {\n /**\n * The name of this radio group. This name is applied to all Radio items inside this group.\n *\n * If no name is provided, one will be generated so that all of the Radio items have the same name.\n */\n name?: string;\n\n /**\n * The selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n value?: string;\n\n /**\n * The default selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n defaultValue?: string;\n\n /**\n * Callback when the selected Radio item changes.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.FormEvent<HTMLDivElement>, data: RadioGroupOnChangeData) => void;\n\n /**\n * How the radio items are laid out in the group.\n *\n * @default vertical\n */\n layout?: 'vertical' | 'horizontal' | 'horizontal-stacked';\n\n /**\n * Disable all Radio items in this group.\n */\n disabled?: boolean;\n\n /**\n * Require a selection in this group. Adds the `required` prop to all child Radio items.\n */\n required?: boolean;\n};\n\nexport type RadioGroupBaseProps = Omit<RadioGroupProps, 'layout'>;\n\n/**\n * Data for the onChange event for RadioGroup.\n */\nexport type RadioGroupOnChangeData = {\n /**\n * The value of the newly selected Radio item.\n */\n value: string;\n};\n\n/**\n * State used in rendering RadioGroup\n */\nexport type RadioGroupState = ComponentState<RadioGroupSlots> &\n Required<Pick<RadioGroupProps, 'layout'>> &\n Pick<RadioGroupProps, 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required'>;\n\nexport type RadioGroupBaseState = Omit<RadioGroupState, 'layout'>;\n\nexport type RadioGroupContextValue = Pick<\n RadioGroupProps,\n 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required' | 'aria-describedby'\n>;\n\nexport type RadioGroupContextValues = {\n radioGroup: RadioGroupContextValue;\n};\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { RadioGroup } from './RadioGroup';
|
|
2
2
|
export { renderRadioGroup_unstable } from './renderRadioGroup';
|
|
3
|
-
export { useRadioGroup_unstable } from './useRadioGroup';
|
|
3
|
+
export { useRadioGroup_unstable, useRadioGroupBase_unstable } from './useRadioGroup';
|
|
4
4
|
export { radioGroupClassNames, useRadioGroupStyles_unstable } from './useRadioGroupStyles.styles';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/index.ts"],"sourcesContent":["export { RadioGroup } from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n} from './RadioGroup.types';\nexport { renderRadioGroup_unstable } from './renderRadioGroup';\nexport { useRadioGroup_unstable } from './useRadioGroup';\nexport { radioGroupClassNames, useRadioGroupStyles_unstable } from './useRadioGroupStyles.styles';\n"],"names":["RadioGroup","renderRadioGroup_unstable","useRadioGroup_unstable","radioGroupClassNames","useRadioGroupStyles_unstable"],"mappings":"AAAA,SAASA,UAAU,QAAQ,eAAe;
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/index.ts"],"sourcesContent":["export { RadioGroup } from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n RadioGroupBaseProps,\n RadioGroupBaseState,\n} from './RadioGroup.types';\nexport { renderRadioGroup_unstable } from './renderRadioGroup';\nexport { useRadioGroup_unstable, useRadioGroupBase_unstable } from './useRadioGroup';\nexport { radioGroupClassNames, useRadioGroupStyles_unstable } from './useRadioGroupStyles.styles';\n"],"names":["RadioGroup","renderRadioGroup_unstable","useRadioGroup_unstable","useRadioGroupBase_unstable","radioGroupClassNames","useRadioGroupStyles_unstable"],"mappings":"AAAA,SAASA,UAAU,QAAQ,eAAe;AAW1C,SAASC,yBAAyB,QAAQ,qBAAqB;AAC/D,SAASC,sBAAsB,EAAEC,0BAA0B,QAAQ,kBAAkB;AACrF,SAASC,oBAAoB,EAAEC,4BAA4B,QAAQ,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/renderRadioGroup.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { RadioGroupContext } from '../../contexts/RadioGroupContext';\nimport { RadioGroupContextValues, RadioGroupSlots,
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/renderRadioGroup.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { RadioGroupContext } from '../../contexts/RadioGroupContext';\nimport { RadioGroupContextValues, RadioGroupSlots, RadioGroupBaseState } from './RadioGroup.types';\n\n/**\n * Render the final JSX of RadioGroup\n */\nexport const renderRadioGroup_unstable = (\n state: RadioGroupBaseState,\n contextValues: RadioGroupContextValues,\n): JSXElement => {\n assertSlots<RadioGroupSlots>(state);\n\n return (\n <RadioGroupContext.Provider value={contextValues.radioGroup}>\n <state.root />\n </RadioGroupContext.Provider>\n );\n};\n"],"names":["assertSlots","RadioGroupContext","renderRadioGroup_unstable","state","contextValues","Provider","value","radioGroup","root"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAExD,SAASC,iBAAiB,QAAQ,mCAAmC;AAGrE;;CAEC,GACD,OAAO,MAAMC,4BAA4B,CACvCC,OACAC;IAEAJ,YAA6BG;IAE7B,qBACE,KAACF,kBAAkBI,QAAQ;QAACC,OAAOF,cAAcG,UAAU;kBACzD,cAAA,KAACJ,MAAMK,IAAI;;AAGjB,EAAE"}
|
|
@@ -11,12 +11,21 @@ import { getIntrinsicElementProps, isHTMLElement, useEventCallback, useId, slot
|
|
|
11
11
|
* @param props - props from this instance of RadioGroup
|
|
12
12
|
* @param ref - reference to root HTMLElement of RadioGroup
|
|
13
13
|
*/ export const useRadioGroup_unstable = (props, ref)=>{
|
|
14
|
+
const { layout = 'vertical', ...baseProps } = props;
|
|
15
|
+
const state = useRadioGroupBase_unstable(baseProps, ref);
|
|
16
|
+
return {
|
|
17
|
+
layout,
|
|
18
|
+
...state
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Create the base state required to render RadioGroup, without design-related properties such as `layout`.
|
|
23
|
+
*/ export const useRadioGroupBase_unstable = (props, ref)=>{
|
|
14
24
|
// Merge props from surrounding <Field>, if any
|
|
15
25
|
props = useFieldControlProps_unstable(props);
|
|
16
26
|
const generatedName = useId('radiogroup-');
|
|
17
|
-
const { name = generatedName, value, defaultValue, disabled,
|
|
27
|
+
const { name = generatedName, value, defaultValue, disabled, onChange, required } = props;
|
|
18
28
|
return {
|
|
19
|
-
layout,
|
|
20
29
|
name,
|
|
21
30
|
value,
|
|
22
31
|
defaultValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/useRadioGroup.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getIntrinsicElementProps, isHTMLElement, useEventCallback, useId, slot } from '@fluentui/react-utilities';\nimport { RadioGroupProps, RadioGroupState } from './RadioGroup.types';\n\n/**\n * Create the state required to render RadioGroup.\n *\n * The returned state can be modified with hooks such as useRadioGroupStyles_unstable,\n * before being passed to renderRadioGroup_unstable.\n *\n * @param props - props from this instance of RadioGroup\n * @param ref - reference to root HTMLElement of RadioGroup\n */\nexport const useRadioGroup_unstable = (props: RadioGroupProps, ref: React.Ref<HTMLDivElement>): RadioGroupState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props);\n\n const generatedName = useId('radiogroup-');\n\n const { name = generatedName, value, defaultValue, disabled,
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/useRadioGroup.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getIntrinsicElementProps, isHTMLElement, useEventCallback, useId, slot } from '@fluentui/react-utilities';\nimport { RadioGroupBaseProps, RadioGroupBaseState, RadioGroupProps, RadioGroupState } from './RadioGroup.types';\n\n/**\n * Create the state required to render RadioGroup.\n *\n * The returned state can be modified with hooks such as useRadioGroupStyles_unstable,\n * before being passed to renderRadioGroup_unstable.\n *\n * @param props - props from this instance of RadioGroup\n * @param ref - reference to root HTMLElement of RadioGroup\n */\nexport const useRadioGroup_unstable = (props: RadioGroupProps, ref: React.Ref<HTMLDivElement>): RadioGroupState => {\n const { layout = 'vertical', ...baseProps } = props;\n const state = useRadioGroupBase_unstable(baseProps, ref);\n\n return {\n layout,\n ...state,\n };\n};\n\n/**\n * Create the base state required to render RadioGroup, without design-related properties such as `layout`.\n */\nexport const useRadioGroupBase_unstable = (\n props: RadioGroupBaseProps,\n ref: React.Ref<HTMLDivElement>,\n): RadioGroupBaseState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props);\n\n const generatedName = useId('radiogroup-');\n\n const { name = generatedName, value, defaultValue, disabled, onChange, required } = props;\n\n return {\n name,\n value,\n defaultValue,\n disabled,\n required,\n components: {\n root: 'div',\n },\n root: {\n ref,\n role: 'radiogroup',\n ...slot.always(getIntrinsicElementProps('div', props, /*excludedPropNames:*/ ['onChange', 'name']), {\n elementType: 'div',\n }),\n onChange: useEventCallback(ev => {\n if (\n onChange &&\n isHTMLElement(ev.target, { constructorName: 'HTMLInputElement' }) &&\n ev.target.type === 'radio'\n ) {\n onChange(ev, { value: ev.target.value });\n }\n }),\n },\n };\n};\n"],"names":["React","useFieldControlProps_unstable","getIntrinsicElementProps","isHTMLElement","useEventCallback","useId","slot","useRadioGroup_unstable","props","ref","layout","baseProps","state","useRadioGroupBase_unstable","generatedName","name","value","defaultValue","disabled","onChange","required","components","root","role","always","elementType","ev","target","constructorName","type"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SAASC,wBAAwB,EAAEC,aAAa,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4BAA4B;AAGnH;;;;;;;;CAQC,GACD,OAAO,MAAMC,yBAAyB,CAACC,OAAwBC;IAC7D,MAAM,EAAEC,SAAS,UAAU,EAAE,GAAGC,WAAW,GAAGH;IAC9C,MAAMI,QAAQC,2BAA2BF,WAAWF;IAEpD,OAAO;QACLC;QACA,GAAGE,KAAK;IACV;AACF,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMC,6BAA6B,CACxCL,OACAC;IAEA,+CAA+C;IAC/CD,QAAQP,8BAA8BO;IAEtC,MAAMM,gBAAgBT,MAAM;IAE5B,MAAM,EAAEU,OAAOD,aAAa,EAAEE,KAAK,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGZ;IAEpF,OAAO;QACLO;QACAC;QACAC;QACAC;QACAE;QACAC,YAAY;YACVC,MAAM;QACR;QACAA,MAAM;YACJb;YACAc,MAAM;YACN,GAAGjB,KAAKkB,MAAM,CAACtB,yBAAyB,OAAOM,OAAO,oBAAoB,GAAG;gBAAC;gBAAY;aAAO,GAAG;gBAClGiB,aAAa;YACf,EAAE;YACFN,UAAUf,iBAAiBsB,CAAAA;gBACzB,IACEP,YACAhB,cAAcuB,GAAGC,MAAM,EAAE;oBAAEC,iBAAiB;gBAAmB,MAC/DF,GAAGC,MAAM,CAACE,IAAI,KAAK,SACnB;oBACAV,SAASO,IAAI;wBAAEV,OAAOU,GAAGC,MAAM,CAACX,KAAK;oBAAC;gBACxC;YACF;QACF;IACF;AACF,EAAE"}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RadioGroup, radioGroupClassNames, renderRadioGroup_unstable, useRadioGroupStyles_unstable, useRadioGroup_unstable } from './RadioGroup';
|
|
2
|
-
export { Radio, radioClassNames, renderRadio_unstable, useRadioStyles_unstable, useRadio_unstable } from './Radio';
|
|
1
|
+
export { RadioGroup, radioGroupClassNames, renderRadioGroup_unstable, useRadioGroupStyles_unstable, useRadioGroup_unstable, useRadioGroupBase_unstable } from './RadioGroup';
|
|
2
|
+
export { Radio, radioClassNames, renderRadio_unstable, useRadioStyles_unstable, useRadio_unstable, useRadioBase_unstable } from './Radio';
|
|
3
3
|
export { RadioGroupProvider, useRadioGroupContextValues, useRadioGroupContext_unstable, useRadioGroupContextValue_unstable } from './contexts/index';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n} from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n} from './RadioGroup';\nexport {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n useRadioGroupBase_unstable,\n} from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n RadioGroupBaseProps,\n RadioGroupBaseState,\n} from './RadioGroup';\nexport {\n Radio,\n radioClassNames,\n renderRadio_unstable,\n useRadioStyles_unstable,\n useRadio_unstable,\n useRadioBase_unstable,\n} from './Radio';\nexport type { RadioProps, RadioSlots, RadioState, RadioOnChangeData, RadioBaseProps, RadioBaseState } from './Radio';\nexport {\n RadioGroupProvider,\n useRadioGroupContextValues,\n useRadioGroupContext_unstable, // eslint-disable-line @typescript-eslint/no-deprecated\n useRadioGroupContextValue_unstable,\n} from './contexts/index';\n"],"names":["RadioGroup","radioGroupClassNames","renderRadioGroup_unstable","useRadioGroupStyles_unstable","useRadioGroup_unstable","useRadioGroupBase_unstable","Radio","radioClassNames","renderRadio_unstable","useRadioStyles_unstable","useRadio_unstable","useRadioBase_unstable","RadioGroupProvider","useRadioGroupContextValues","useRadioGroupContext_unstable","useRadioGroupContextValue_unstable"],"mappings":"AAAA,SACEA,UAAU,EACVC,oBAAoB,EACpBC,yBAAyB,EACzBC,4BAA4B,EAC5BC,sBAAsB,EACtBC,0BAA0B,QACrB,eAAe;AAWtB,SACEC,KAAK,EACLC,eAAe,EACfC,oBAAoB,EACpBC,uBAAuB,EACvBC,iBAAiB,EACjBC,qBAAqB,QAChB,UAAU;AAEjB,SACEC,kBAAkB,EAClBC,0BAA0B,EAC1BC,6BAA6B,EAC7BC,kCAAkC,QAC7B,mBAAmB"}
|
package/lib-commonjs/Radio.js
CHANGED
|
@@ -18,6 +18,9 @@ _export(exports, {
|
|
|
18
18
|
renderRadio_unstable: function() {
|
|
19
19
|
return _index.renderRadio_unstable;
|
|
20
20
|
},
|
|
21
|
+
useRadioBase_unstable: function() {
|
|
22
|
+
return _index.useRadioBase_unstable;
|
|
23
|
+
},
|
|
21
24
|
useRadioStyles_unstable: function() {
|
|
22
25
|
return _index.useRadioStyles_unstable;
|
|
23
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Radio.ts"],"sourcesContent":["export type {
|
|
1
|
+
{"version":3,"sources":["../src/Radio.ts"],"sourcesContent":["export type {\n RadioOnChangeData,\n RadioProps,\n RadioSlots,\n RadioState,\n RadioBaseProps,\n RadioBaseState,\n} from './components/Radio/index';\nexport {\n Radio,\n radioClassNames,\n renderRadio_unstable,\n useRadioStyles_unstable,\n useRadio_unstable,\n useRadioBase_unstable,\n} from './components/Radio/index';\n"],"names":["Radio","radioClassNames","renderRadio_unstable","useRadioStyles_unstable","useRadio_unstable","useRadioBase_unstable"],"mappings":";;;;;;;;;;;;eASEA,YAAK;;;eACLC,sBAAe;;;eACfC,2BAAoB;;;eAGpBG,4BAAqB;;;eAFrBF,8BAAuB;;;eACvBC,wBAAiB;;;uBAEZ,2BAA2B"}
|
|
@@ -18,6 +18,9 @@ _export(exports, {
|
|
|
18
18
|
renderRadioGroup_unstable: function() {
|
|
19
19
|
return _index.renderRadioGroup_unstable;
|
|
20
20
|
},
|
|
21
|
+
useRadioGroupBase_unstable: function() {
|
|
22
|
+
return _index.useRadioGroupBase_unstable;
|
|
23
|
+
},
|
|
21
24
|
useRadioGroupStyles_unstable: function() {
|
|
22
25
|
return _index.useRadioGroupStyles_unstable;
|
|
23
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/RadioGroup.ts"],"sourcesContent":["export type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n} from './components/RadioGroup/index';\nexport {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n} from './components/RadioGroup/index';\n"],"names":["RadioGroup","radioGroupClassNames","renderRadioGroup_unstable","useRadioGroupStyles_unstable","useRadioGroup_unstable"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/RadioGroup.ts"],"sourcesContent":["export type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n RadioGroupBaseProps,\n RadioGroupBaseState,\n} from './components/RadioGroup/index';\nexport {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n useRadioGroupBase_unstable,\n} from './components/RadioGroup/index';\n"],"names":["RadioGroup","radioGroupClassNames","renderRadioGroup_unstable","useRadioGroupStyles_unstable","useRadioGroup_unstable","useRadioGroupBase_unstable"],"mappings":";;;;;;;;;;;;eAWEA,iBAAU;;;eACVC,2BAAoB;;;eACpBC,gCAAyB;;;eAGzBG,iCAA0B;;;eAF1BF,mCAA4B;;;eAC5BC,6BAAsB;;;uBAEjB,gCAAgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/Radio.types.ts"],"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 // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\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"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/Radio.types.ts"],"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 // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: RadioOnChangeData) => void;\n};\n\nexport type RadioBaseProps = RadioProps;\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\nexport type RadioBaseState = RadioState;\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
|
|
@@ -18,6 +18,9 @@ _export(exports, {
|
|
|
18
18
|
renderRadio_unstable: function() {
|
|
19
19
|
return _renderRadio.renderRadio_unstable;
|
|
20
20
|
},
|
|
21
|
+
useRadioBase_unstable: function() {
|
|
22
|
+
return _useRadio.useRadioBase_unstable;
|
|
23
|
+
},
|
|
21
24
|
useRadioStyles_unstable: function() {
|
|
22
25
|
return _useRadioStylesstyles.useRadioStyles_unstable;
|
|
23
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/index.ts"],"sourcesContent":["export { Radio } from './Radio';\nexport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/index.ts"],"sourcesContent":["export { Radio } from './Radio';\nexport type {\n RadioOnChangeData,\n RadioProps,\n RadioSlots,\n RadioState,\n RadioBaseProps,\n RadioBaseState,\n} from './Radio.types';\nexport { renderRadio_unstable } from './renderRadio';\nexport { useRadio_unstable, useRadioBase_unstable } from './useRadio';\nexport { radioClassNames, useRadioStyles_unstable } from './useRadioStyles.styles';\n"],"names":["Radio","renderRadio_unstable","useRadio_unstable","useRadioBase_unstable","radioClassNames","useRadioStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,YAAK;;;eAWLI,qCAAe;;;eAFfH,iCAAoB;;;eACDE,+BAAqB;;;eACvBE,6CAAuB;;;eADxCH,2BAAiB;;;uBAVJ,UAAU;6BASK,gBAAgB;0BACI,aAAa;sCACb,0BAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/renderRadio.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { RadioSlots,
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/renderRadio.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { RadioSlots, RadioBaseState } from './Radio.types';\n\n/**\n * Render the final JSX of Radio\n */\nexport const renderRadio_unstable = (state: RadioBaseState): JSXElement => {\n assertSlots<RadioSlots>(state);\n\n return (\n <state.root>\n <state.input />\n <state.indicator />\n {state.label && <state.label />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderRadio_unstable","state","root","input","indicator","label"],"mappings":";;;;+BAUaC;;;;;;4BATb,iCAAiD;gCAErB,4BAA4B;AAOjD,6BAA6B,CAACC;QACnCF,2BAAAA,EAAwBE;IAExB,OAAA,WAAA,OACE,gBAAA,EAACA,MAAMC,IAAI,EAAA;;8BACT,eAAA,EAACD,MAAME,KAAK,EAAA,CAAA;8BACZ,eAAA,EAACF,MAAMG,SAAS,EAAA,CAAA;YACfH,MAAMI,KAAK,IAAA,WAAA,OAAI,eAAA,EAACJ,MAAMI,KAAK,EAAA,CAAA;;;AAGlC,EAAE"}
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
useRadioBase_unstable: function() {
|
|
14
|
+
return useRadioBase_unstable;
|
|
15
|
+
},
|
|
16
|
+
useRadio_unstable: function() {
|
|
9
17
|
return useRadio_unstable;
|
|
10
18
|
}
|
|
11
19
|
});
|
|
@@ -16,6 +24,23 @@ const _reactutilities = require("@fluentui/react-utilities");
|
|
|
16
24
|
const _RadioGroupContext = require("../../contexts/RadioGroupContext");
|
|
17
25
|
const _reacttabster = require("@fluentui/react-tabster");
|
|
18
26
|
const useRadio_unstable = (props, ref)=>{
|
|
27
|
+
const state = useRadioBase_unstable(props, ref);
|
|
28
|
+
return {
|
|
29
|
+
...state,
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
31
|
+
components: {
|
|
32
|
+
...state.components,
|
|
33
|
+
label: _reactlabel.Label
|
|
34
|
+
},
|
|
35
|
+
label: _reactutilities.slot.optional(props.label, {
|
|
36
|
+
defaultProps: {
|
|
37
|
+
...state.label
|
|
38
|
+
},
|
|
39
|
+
elementType: _reactlabel.Label
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const useRadioBase_unstable = (props, ref)=>{
|
|
19
44
|
const group = (0, _RadioGroupContext.useRadioGroupContextValue_unstable)();
|
|
20
45
|
const { name = group.name, checked = group.value !== undefined ? group.value === props.value : undefined, defaultChecked = group.defaultValue !== undefined ? group.defaultValue === props.value : undefined, labelPosition = group.layout === 'horizontal-stacked' ? 'below' : 'after', disabled = group.disabled, required = group.required, 'aria-describedby': ariaDescribedBy = group['aria-describedby'], onChange } = props;
|
|
21
46
|
const nativeProps = (0, _reactutilities.getPartitionedNativeProps)({
|
|
@@ -57,7 +82,7 @@ const useRadio_unstable = (props, ref)=>{
|
|
|
57
82
|
htmlFor: input.id,
|
|
58
83
|
disabled: input.disabled
|
|
59
84
|
},
|
|
60
|
-
elementType:
|
|
85
|
+
elementType: 'label'
|
|
61
86
|
});
|
|
62
87
|
const indicator = _reactutilities.slot.always(props.indicator, {
|
|
63
88
|
defaultProps: {
|
|
@@ -70,7 +95,7 @@ const useRadio_unstable = (props, ref)=>{
|
|
|
70
95
|
components: {
|
|
71
96
|
root: 'span',
|
|
72
97
|
input: 'input',
|
|
73
|
-
label:
|
|
98
|
+
label: 'label',
|
|
74
99
|
indicator: 'div'
|
|
75
100
|
},
|
|
76
101
|
root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Radio/useRadio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport { useRadioGroupContextValue_unstable } from '../../contexts/RadioGroupContext';\nimport { useFocusWithin } from '@fluentui/react-tabster';\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 = useRadioGroupContextValue_unstable();\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 === 'horizontal-stacked' ? 'below' : 'after',\n disabled = group.disabled,\n required = group.required,\n 'aria-describedby': ariaDescribedBy = group['aria-describedby'],\n onChange,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const root = slot.always(props.root, {\n defaultProps: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\n elementType: 'span',\n });\n const input = slot.always(props.input, {\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 'aria-describedby': ariaDescribedBy,\n ...nativeProps.primary,\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { value: ev.currentTarget.value }));\n const label = slot.optional(props.label, {\n defaultProps: { htmlFor: input.id, disabled: input.disabled },\n elementType:
|
|
1
|
+
{"version":3,"sources":["../src/components/Radio/useRadio.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport { useRadioGroupContextValue_unstable } from '../../contexts/RadioGroupContext';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport type { RadioBaseProps, RadioBaseState, 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 state = useRadioBase_unstable(props, ref);\n\n return {\n ...state,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n components: { ...state.components, label: Label },\n label: slot.optional(props.label, {\n defaultProps: { ...state.label },\n elementType: Label,\n }),\n };\n};\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 useRadioBase_unstable = (props: RadioBaseProps, ref: React.Ref<HTMLInputElement>): RadioBaseState => {\n const group = useRadioGroupContextValue_unstable();\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 === 'horizontal-stacked' ? 'below' : 'after',\n disabled = group.disabled,\n required = group.required,\n 'aria-describedby': ariaDescribedBy = group['aria-describedby'],\n onChange,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const root = slot.always(props.root, {\n defaultProps: {\n ref: useFocusWithin<HTMLSpanElement>(),\n ...nativeProps.root,\n },\n elementType: 'span',\n });\n const input = slot.always(props.input, {\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 'aria-describedby': ariaDescribedBy,\n ...nativeProps.primary,\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { value: ev.currentTarget.value }));\n const label = slot.optional(props.label, {\n defaultProps: { htmlFor: input.id, disabled: input.disabled },\n elementType: 'label',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true },\n elementType: 'div',\n });\n return {\n labelPosition,\n components: { root: 'span', input: 'input', label: 'label', indicator: 'div' },\n root,\n input,\n label,\n indicator,\n };\n};\n"],"names":["React","Label","getPartitionedNativeProps","mergeCallbacks","useId","slot","useRadioGroupContextValue_unstable","useFocusWithin","useRadio_unstable","props","ref","state","useRadioBase_unstable","components","label","optional","defaultProps","elementType","group","name","checked","value","undefined","defaultChecked","defaultValue","labelPosition","layout","disabled","required","ariaDescribedBy","onChange","nativeProps","primarySlotTagName","excludedPropNames","root","always","input","type","id","primary","ev","currentTarget","htmlFor","indicator"],"mappings":"AAAA;;;;;;;;;;;;IAyCaY,qBAAAA;;;qBAvBAJ;;;;;iEAhBU,QAAQ;4BACT,wBAAwB;gCACyB,4BAA4B;mCAChD,mCAAmC;8BACvD,0BAA0B;AAYlD,MAAMA,oBAAoB,CAACC,OAAmBC;IACnD,MAAMC,QAAQC,sBAAsBH,OAAOC;IAE3C,OAAO;QACL,GAAGC,KAAK;QACR,4DAA4D;QAC5DE,YAAY;YAAE,GAAGF,MAAME,UAAU;YAAEC,OAAOb,iBAAAA;QAAM;QAChDa,OAAOT,oBAAAA,CAAKU,QAAQ,CAACN,MAAMK,KAAK,EAAE;YAChCE,cAAc;gBAAE,GAAGL,MAAMG,KAAK;YAAC;YAC/BG,aAAahB,iBAAAA;QACf;IACF;AACF,EAAE;AAWK,8BAA8B,CAACQ,OAAuBC;IAC3D,MAAMQ,YAAQZ,qDAAAA;IAEd,MAAM,EACJa,OAAOD,MAAMC,IAAI,EACjBC,UAAUF,MAAMG,KAAK,KAAKC,YAAYJ,MAAMG,KAAK,KAAKZ,MAAMY,KAAK,GAAGC,SAAS,EAC7EC,iBAAiBL,MAAMM,YAAY,KAAKF,YAAYJ,MAAMM,YAAY,KAAKf,MAAMY,KAAK,GAAGC,SAAS,EAClGG,gBAAgBP,MAAMQ,MAAM,KAAK,uBAAuB,UAAU,OAAO,EACzEC,WAAWT,MAAMS,QAAQ,EACzBC,WAAWV,MAAMU,QAAQ,EACzB,oBAAoBC,kBAAkBX,KAAK,CAAC,mBAAmB,EAC/DY,QAAQ,EACT,GAAGrB;IAEJ,MAAMsB,kBAAc7B,yCAAAA,EAA0B;QAC5CO;QACAuB,oBAAoB;QACpBC,mBAAmB;YAAC;YAAW;YAAkB;SAAW;IAC9D;IAEA,MAAMC,OAAO7B,oBAAAA,CAAK8B,MAAM,CAAC1B,MAAMyB,IAAI,EAAE;QACnClB,cAAc;YACZN,SAAKH,4BAAAA;YACL,GAAGwB,YAAYG,IAAI;QACrB;QACAjB,aAAa;IACf;IACA,MAAMmB,QAAQ/B,oBAAAA,CAAK8B,MAAM,CAAC1B,MAAM2B,KAAK,EAAE;QACrCpB,cAAc;YACZN;YACA2B,MAAM;YACNC,QAAIlC,qBAAAA,EAAM,UAAU2B,YAAYQ,OAAO,CAACD,EAAE;YAC1CnB;YACAC;YACAG;YACAI;YACAC;YACA,oBAAoBC;YACpB,GAAGE,YAAYQ,OAAO;QACxB;QACAtB,aAAa;IACf;IACAmB,MAAMN,QAAQ,OAAG3B,8BAAAA,EAAeiC,MAAMN,QAAQ,EAAEU,CAAAA,KAAMV,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,KAAAA,IAAAA,SAAWU,IAAI;YAAEnB,OAAOmB,GAAGC,aAAa,CAACpB,KAAK;QAAC;IACrG,MAAMP,QAAQT,oBAAAA,CAAKU,QAAQ,CAACN,MAAMK,KAAK,EAAE;QACvCE,cAAc;YAAE0B,SAASN,MAAME,EAAE;YAAEX,UAAUS,MAAMT,QAAQ;QAAC;QAC5DV,aAAa;IACf;IACA,MAAM0B,YAAYtC,oBAAAA,CAAK8B,MAAM,CAAC1B,MAAMkC,SAAS,EAAE;QAC7C3B,cAAc;YAAE,eAAe;QAAK;QACpCC,aAAa;IACf;IACA,OAAO;QACLQ;QACAZ,YAAY;YAAEqB,MAAM;YAAQE,OAAO;YAAStB,OAAO;YAAS6B,WAAW;QAAM;QAC7ET;QACAE;QACAtB;QACA6B;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/RadioGroup.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type RadioGroupSlots = {\n /**\n * The radio group root.\n */\n root: NonNullable<Slot<'div'>>;\n};\n\nexport type RadioGroupProps = Omit<ComponentProps<Partial<RadioGroupSlots>>, 'onChange'> & {\n /**\n * The name of this radio group. This name is applied to all Radio items inside this group.\n *\n * If no name is provided, one will be generated so that all of the Radio items have the same name.\n */\n name?: string;\n\n /**\n * The selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n value?: string;\n\n /**\n * The default selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n defaultValue?: string;\n\n /**\n * Callback when the selected Radio item changes.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.FormEvent<HTMLDivElement>, data: RadioGroupOnChangeData) => void;\n\n /**\n * How the radio items are laid out in the group.\n *\n * @default vertical\n */\n layout?: 'vertical' | 'horizontal' | 'horizontal-stacked';\n\n /**\n * Disable all Radio items in this group.\n */\n disabled?: boolean;\n\n /**\n * Require a selection in this group. Adds the `required` prop to all child Radio items.\n */\n required?: boolean;\n};\n\n/**\n * Data for the onChange event for RadioGroup.\n */\nexport type RadioGroupOnChangeData = {\n /**\n * The value of the newly selected Radio item.\n */\n value: string;\n};\n\n/**\n * State used in rendering RadioGroup\n */\nexport type RadioGroupState = ComponentState<RadioGroupSlots> &\n Required<Pick<RadioGroupProps, 'layout'>> &\n Pick<RadioGroupProps, 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required'>;\n\nexport type RadioGroupContextValue = Pick<\n RadioGroupProps,\n 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required' | 'aria-describedby'\n>;\n\nexport type RadioGroupContextValues = {\n radioGroup: RadioGroupContextValue;\n};\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/RadioGroup.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type RadioGroupSlots = {\n /**\n * The radio group root.\n */\n root: NonNullable<Slot<'div'>>;\n};\n\nexport type RadioGroupProps = Omit<ComponentProps<Partial<RadioGroupSlots>>, 'onChange'> & {\n /**\n * The name of this radio group. This name is applied to all Radio items inside this group.\n *\n * If no name is provided, one will be generated so that all of the Radio items have the same name.\n */\n name?: string;\n\n /**\n * The selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n value?: string;\n\n /**\n * The default selected Radio item in this group.\n *\n * This should be the `value` prop of one of the Radio items inside this group.\n */\n defaultValue?: string;\n\n /**\n * Callback when the selected Radio item changes.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.FormEvent<HTMLDivElement>, data: RadioGroupOnChangeData) => void;\n\n /**\n * How the radio items are laid out in the group.\n *\n * @default vertical\n */\n layout?: 'vertical' | 'horizontal' | 'horizontal-stacked';\n\n /**\n * Disable all Radio items in this group.\n */\n disabled?: boolean;\n\n /**\n * Require a selection in this group. Adds the `required` prop to all child Radio items.\n */\n required?: boolean;\n};\n\nexport type RadioGroupBaseProps = Omit<RadioGroupProps, 'layout'>;\n\n/**\n * Data for the onChange event for RadioGroup.\n */\nexport type RadioGroupOnChangeData = {\n /**\n * The value of the newly selected Radio item.\n */\n value: string;\n};\n\n/**\n * State used in rendering RadioGroup\n */\nexport type RadioGroupState = ComponentState<RadioGroupSlots> &\n Required<Pick<RadioGroupProps, 'layout'>> &\n Pick<RadioGroupProps, 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required'>;\n\nexport type RadioGroupBaseState = Omit<RadioGroupState, 'layout'>;\n\nexport type RadioGroupContextValue = Pick<\n RadioGroupProps,\n 'name' | 'value' | 'defaultValue' | 'disabled' | 'layout' | 'required' | 'aria-describedby'\n>;\n\nexport type RadioGroupContextValues = {\n radioGroup: RadioGroupContextValue;\n};\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
|
|
@@ -18,6 +18,9 @@ _export(exports, {
|
|
|
18
18
|
renderRadioGroup_unstable: function() {
|
|
19
19
|
return _renderRadioGroup.renderRadioGroup_unstable;
|
|
20
20
|
},
|
|
21
|
+
useRadioGroupBase_unstable: function() {
|
|
22
|
+
return _useRadioGroup.useRadioGroupBase_unstable;
|
|
23
|
+
},
|
|
21
24
|
useRadioGroupStyles_unstable: function() {
|
|
22
25
|
return _useRadioGroupStylesstyles.useRadioGroupStyles_unstable;
|
|
23
26
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/index.ts"],"sourcesContent":["export { RadioGroup } from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n} from './RadioGroup.types';\nexport { renderRadioGroup_unstable } from './renderRadioGroup';\nexport { useRadioGroup_unstable } from './useRadioGroup';\nexport { radioGroupClassNames, useRadioGroupStyles_unstable } from './useRadioGroupStyles.styles';\n"],"names":["RadioGroup","renderRadioGroup_unstable","useRadioGroup_unstable","radioGroupClassNames","useRadioGroupStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,sBAAU;;;
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/index.ts"],"sourcesContent":["export { RadioGroup } from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n RadioGroupBaseProps,\n RadioGroupBaseState,\n} from './RadioGroup.types';\nexport { renderRadioGroup_unstable } from './renderRadioGroup';\nexport { useRadioGroup_unstable, useRadioGroupBase_unstable } from './useRadioGroup';\nexport { radioGroupClassNames, useRadioGroupStyles_unstable } from './useRadioGroupStyles.styles';\n"],"names":["RadioGroup","renderRadioGroup_unstable","useRadioGroup_unstable","useRadioGroupBase_unstable","radioGroupClassNames","useRadioGroupStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,sBAAU;;;eAaVI,+CAAoB;;;eAFpBH,2CAAyB;;;eACDE,yCAA0B;;;eAC5BE,uDAA4B;;;eADlDH,qCAAsB;;;4BAZJ,eAAe;kCAWA,qBAAqB;+BACI,kBAAkB;2CAClB,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/renderRadioGroup.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { RadioGroupContext } from '../../contexts/RadioGroupContext';\nimport { RadioGroupContextValues, RadioGroupSlots,
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/renderRadioGroup.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { RadioGroupContext } from '../../contexts/RadioGroupContext';\nimport { RadioGroupContextValues, RadioGroupSlots, RadioGroupBaseState } from './RadioGroup.types';\n\n/**\n * Render the final JSX of RadioGroup\n */\nexport const renderRadioGroup_unstable = (\n state: RadioGroupBaseState,\n contextValues: RadioGroupContextValues,\n): JSXElement => {\n assertSlots<RadioGroupSlots>(state);\n\n return (\n <RadioGroupContext.Provider value={contextValues.radioGroup}>\n <state.root />\n </RadioGroupContext.Provider>\n );\n};\n"],"names":["assertSlots","RadioGroupContext","renderRadioGroup_unstable","state","contextValues","Provider","value","radioGroup","root"],"mappings":";;;;+BAWaE;;;;;;4BAVb,gDAAiD;gCAErB,4BAA4B;mCAEtB,mCAAmC;AAM9D,kCAAkC,CACvCC,OACAC;QAEAJ,2BAAAA,EAA6BG;IAE7B,OAAA,WAAA,OACE,eAAA,EAACF,oCAAAA,CAAkBI,QAAQ,EAAA;QAACC,OAAOF,cAAcG,UAAU;kBACzD,WAAA,OAAA,eAAA,EAACJ,MAAMK,IAAI,EAAA,CAAA;;AAGjB,EAAE"}
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
useRadioGroupBase_unstable: function() {
|
|
14
|
+
return useRadioGroupBase_unstable;
|
|
15
|
+
},
|
|
16
|
+
useRadioGroup_unstable: function() {
|
|
9
17
|
return useRadioGroup_unstable;
|
|
10
18
|
}
|
|
11
19
|
});
|
|
@@ -14,12 +22,19 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
14
22
|
const _reactfield = require("@fluentui/react-field");
|
|
15
23
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
16
24
|
const useRadioGroup_unstable = (props, ref)=>{
|
|
25
|
+
const { layout = 'vertical', ...baseProps } = props;
|
|
26
|
+
const state = useRadioGroupBase_unstable(baseProps, ref);
|
|
27
|
+
return {
|
|
28
|
+
layout,
|
|
29
|
+
...state
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const useRadioGroupBase_unstable = (props, ref)=>{
|
|
17
33
|
// Merge props from surrounding <Field>, if any
|
|
18
34
|
props = (0, _reactfield.useFieldControlProps_unstable)(props);
|
|
19
35
|
const generatedName = (0, _reactutilities.useId)('radiogroup-');
|
|
20
|
-
const { name = generatedName, value, defaultValue, disabled,
|
|
36
|
+
const { name = generatedName, value, defaultValue, disabled, onChange, required } = props;
|
|
21
37
|
return {
|
|
22
|
-
layout,
|
|
23
38
|
name,
|
|
24
39
|
value,
|
|
25
40
|
defaultValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RadioGroup/useRadioGroup.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getIntrinsicElementProps, isHTMLElement, useEventCallback, useId, slot } from '@fluentui/react-utilities';\nimport { RadioGroupProps, RadioGroupState } from './RadioGroup.types';\n\n/**\n * Create the state required to render RadioGroup.\n *\n * The returned state can be modified with hooks such as useRadioGroupStyles_unstable,\n * before being passed to renderRadioGroup_unstable.\n *\n * @param props - props from this instance of RadioGroup\n * @param ref - reference to root HTMLElement of RadioGroup\n */\nexport const useRadioGroup_unstable = (props: RadioGroupProps, ref: React.Ref<HTMLDivElement>): RadioGroupState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props);\n\n const generatedName = useId('radiogroup-');\n\n const { name = generatedName, value, defaultValue, disabled,
|
|
1
|
+
{"version":3,"sources":["../src/components/RadioGroup/useRadioGroup.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { getIntrinsicElementProps, isHTMLElement, useEventCallback, useId, slot } from '@fluentui/react-utilities';\nimport { RadioGroupBaseProps, RadioGroupBaseState, RadioGroupProps, RadioGroupState } from './RadioGroup.types';\n\n/**\n * Create the state required to render RadioGroup.\n *\n * The returned state can be modified with hooks such as useRadioGroupStyles_unstable,\n * before being passed to renderRadioGroup_unstable.\n *\n * @param props - props from this instance of RadioGroup\n * @param ref - reference to root HTMLElement of RadioGroup\n */\nexport const useRadioGroup_unstable = (props: RadioGroupProps, ref: React.Ref<HTMLDivElement>): RadioGroupState => {\n const { layout = 'vertical', ...baseProps } = props;\n const state = useRadioGroupBase_unstable(baseProps, ref);\n\n return {\n layout,\n ...state,\n };\n};\n\n/**\n * Create the base state required to render RadioGroup, without design-related properties such as `layout`.\n */\nexport const useRadioGroupBase_unstable = (\n props: RadioGroupBaseProps,\n ref: React.Ref<HTMLDivElement>,\n): RadioGroupBaseState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props);\n\n const generatedName = useId('radiogroup-');\n\n const { name = generatedName, value, defaultValue, disabled, onChange, required } = props;\n\n return {\n name,\n value,\n defaultValue,\n disabled,\n required,\n components: {\n root: 'div',\n },\n root: {\n ref,\n role: 'radiogroup',\n ...slot.always(getIntrinsicElementProps('div', props, /*excludedPropNames:*/ ['onChange', 'name']), {\n elementType: 'div',\n }),\n onChange: useEventCallback(ev => {\n if (\n onChange &&\n isHTMLElement(ev.target, { constructorName: 'HTMLInputElement' }) &&\n ev.target.type === 'radio'\n ) {\n onChange(ev, { value: ev.target.value });\n }\n }),\n },\n };\n};\n"],"names":["React","useFieldControlProps_unstable","getIntrinsicElementProps","isHTMLElement","useEventCallback","useId","slot","useRadioGroup_unstable","props","ref","layout","baseProps","state","useRadioGroupBase_unstable","generatedName","name","value","defaultValue","disabled","onChange","required","components","root","role","always","elementType","ev","target","constructorName","type"],"mappings":"AAAA;;;;;;;;;;;;IA6Baa,0BAAAA;;;0BAbAN;;;;;iEAdU,QAAQ;4BACe,wBAAwB;gCACiB,4BAA4B;AAY5G,MAAMA,yBAAyB,CAACC,OAAwBC;IAC7D,MAAM,EAAEC,SAAS,UAAU,EAAE,GAAGC,WAAW,GAAGH;IAC9C,MAAMI,QAAQC,2BAA2BF,WAAWF;IAEpD,OAAO;QACLC;QACA,GAAGE,KAAK;IACV;AACF,EAAE;AAKK,mCAAmC,CACxCJ,OACAC;IAEA,+CAA+C;IAC/CD,YAAQP,yCAAAA,EAA8BO;IAEtC,MAAMM,oBAAgBT,qBAAAA,EAAM;IAE5B,MAAM,EAAEU,OAAOD,aAAa,EAAEE,KAAK,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGZ;IAEpF,OAAO;QACLO;QACAC;QACAC;QACAC;QACAE;QACAC,YAAY;YACVC,MAAM;QACR;QACAA,MAAM;YACJb;YACAc,MAAM;YACN,GAAGjB,oBAAAA,CAAKkB,MAAM,KAACtB,wCAAAA,EAAyB,OAAOM,OAAO,oBAAoB,GAAG;gBAAC;gBAAY;aAAO,GAAG;gBAClGiB,aAAa;YACf,EAAE;YACFN,cAAUf,gCAAAA,EAAiBsB,CAAAA;gBACzB,IACEP,gBACAhB,6BAAAA,EAAcuB,GAAGC,MAAM,EAAE;oBAAEC,iBAAiB;gBAAmB,MAC/DF,GAAGC,MAAM,CAACE,IAAI,KAAK,SACnB;oBACAV,SAASO,IAAI;wBAAEV,OAAOU,GAAGC,MAAM,CAACX,KAAK;oBAAC;gBACxC;YACF;QACF;IACF;AACF,EAAE"}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -30,6 +30,12 @@ _export(exports, {
|
|
|
30
30
|
renderRadio_unstable: function() {
|
|
31
31
|
return _Radio.renderRadio_unstable;
|
|
32
32
|
},
|
|
33
|
+
useRadioBase_unstable: function() {
|
|
34
|
+
return _Radio.useRadioBase_unstable;
|
|
35
|
+
},
|
|
36
|
+
useRadioGroupBase_unstable: function() {
|
|
37
|
+
return _RadioGroup.useRadioGroupBase_unstable;
|
|
38
|
+
},
|
|
33
39
|
useRadioGroupContextValue_unstable: function() {
|
|
34
40
|
return _index.useRadioGroupContextValue_unstable;
|
|
35
41
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n} from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n} from './RadioGroup';\nexport {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n RadioGroup,\n radioGroupClassNames,\n renderRadioGroup_unstable,\n useRadioGroupStyles_unstable,\n useRadioGroup_unstable,\n useRadioGroupBase_unstable,\n} from './RadioGroup';\nexport type {\n RadioGroupContextValue,\n RadioGroupContextValues,\n RadioGroupOnChangeData,\n RadioGroupProps,\n RadioGroupSlots,\n RadioGroupState,\n RadioGroupBaseProps,\n RadioGroupBaseState,\n} from './RadioGroup';\nexport {\n Radio,\n radioClassNames,\n renderRadio_unstable,\n useRadioStyles_unstable,\n useRadio_unstable,\n useRadioBase_unstable,\n} from './Radio';\nexport type { RadioProps, RadioSlots, RadioState, RadioOnChangeData, RadioBaseProps, RadioBaseState } from './Radio';\nexport {\n RadioGroupProvider,\n useRadioGroupContextValues,\n useRadioGroupContext_unstable, // eslint-disable-line @typescript-eslint/no-deprecated\n useRadioGroupContextValue_unstable,\n} from './contexts/index';\n"],"names":["RadioGroup","radioGroupClassNames","renderRadioGroup_unstable","useRadioGroupStyles_unstable","useRadioGroup_unstable","useRadioGroupBase_unstable","Radio","radioClassNames","renderRadio_unstable","useRadioStyles_unstable","useRadio_unstable","useRadioBase_unstable","RadioGroupProvider","useRadioGroupContextValues","useRadioGroupContext_unstable","useRadioGroupContextValue_unstable"],"mappings":";;;;;;;;;;;IAmBEM,KAAK;;;;eAlBLN,sBAAU;;;eA2BVY,yBAAkB;;IARlBL,eAAe;;;;eAlBfN,gCAAoB;;;eACpBC,qCAAyB;;;eAkBzBM,2BAAoB;;;eAGpBG,4BAAqB;;;eAlBrBN,sCAA0B;;;eAyB1BU,yCAAkC;;IAFlCF,0BAA0B;;;;eAC1BC,oCAA6B;;IA1B7BX,4BAA4B;;;;eAC5BC,kCAAsB;;IAiBtBK;6CAAuB;;;eACvBC,wBAAiB;;;4BAhBZ,eAAe;uBAkBf,UAAU;uBAOV,mBAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-radio",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.1",
|
|
4
4
|
"description": "Fluent UI Radio component",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@fluentui/react-field": "^9.
|
|
15
|
+
"@fluentui/react-field": "^9.5.0",
|
|
16
16
|
"@fluentui/react-jsx-runtime": "^9.4.1",
|
|
17
|
-
"@fluentui/react-label": "^9.
|
|
17
|
+
"@fluentui/react-label": "^9.4.0",
|
|
18
18
|
"@fluentui/react-shared-contexts": "^9.26.2",
|
|
19
19
|
"@fluentui/react-tabster": "^9.26.13",
|
|
20
20
|
"@fluentui/react-theme": "^9.2.1",
|