@fluentui/react-switch 9.5.2 → 9.5.3

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 CHANGED
@@ -1,12 +1,24 @@
1
1
  # Change Log - @fluentui/react-switch
2
2
 
3
- This log was last generated on Thu, 22 Jan 2026 17:01:24 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 12 Feb 2026 10:42:44 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.5.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.5.3)
8
+
9
+ Thu, 12 Feb 2026 10:42:44 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.5.2..@fluentui/react-switch_v9.5.3)
11
+
12
+ ### Patches
13
+
14
+ - refactor: add base state hooks for Switch component ([PR #35720](https://github.com/microsoft/fluentui/pull/35720) by copilot@github.com)
15
+ - Bump @fluentui/react-field to v9.4.14 ([PR #35743](https://github.com/microsoft/fluentui/pull/35743) by beachball)
16
+ - Bump @fluentui/react-jsx-runtime to v9.4.0 ([PR #35743](https://github.com/microsoft/fluentui/pull/35743) by beachball)
17
+ - Bump @fluentui/react-label to v9.3.14 ([PR #35743](https://github.com/microsoft/fluentui/pull/35743) by beachball)
18
+
7
19
  ## [9.5.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.5.2)
8
20
 
9
- Thu, 22 Jan 2026 17:01:24 GMT
21
+ Thu, 22 Jan 2026 17:06:40 GMT
10
22
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-switch_v9.5.1..@fluentui/react-switch_v9.5.2)
11
23
 
12
24
  ### Patches
package/lib/Switch.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { Switch, renderSwitch_unstable, // eslint-disable-next-line @typescript-eslint/no-deprecated
2
- switchClassName, switchClassNames, useSwitchStyles_unstable, useSwitch_unstable } from './components/Switch/index';
2
+ switchClassName, switchClassNames, useSwitchStyles_unstable, useSwitch_unstable, useSwitchBase_unstable } from './components/Switch/index';
package/lib/Switch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Switch.ts"],"sourcesContent":["export type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './components/Switch/index';\nexport {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n} from './components/Switch/index';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable"],"mappings":"AACA,SACEA,MAAM,EACNC,qBAAqB,EACrB,4DAA4D;AAC5DC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBC,kBAAkB,QACb,4BAA4B"}
1
+ {"version":3,"sources":["../src/Switch.ts"],"sourcesContent":["export type {\n SwitchBaseProps,\n SwitchBaseState,\n SwitchOnChangeData,\n SwitchProps,\n SwitchSlots,\n SwitchState,\n} from './components/Switch/index';\nexport {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n useSwitchBase_unstable,\n} from './components/Switch/index';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable","useSwitchBase_unstable"],"mappings":"AAQA,SACEA,MAAM,EACNC,qBAAqB,EACrB,4DAA4D;AAC5DC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBC,kBAAkB,EAClBC,sBAAsB,QACjB,4BAA4B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Switch/Switch.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 SwitchSlots = {\n /**\n * The root element of the Switch.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.\n * All other native props will be applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The track and the thumb sliding over it indicating the on and off status of the Switch.\n */\n indicator: NonNullable<Slot<'div'>>;\n\n /**\n * Hidden input that handles the Switch's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this\n * slot, except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The Switch's label.\n */\n label?: Slot<typeof Label>;\n};\n\nexport type SwitchOnChangeData = {\n checked: boolean;\n};\n\n/**\n * Switch Props\n */\nexport type SwitchProps = Omit<\n ComponentProps<Partial<SwitchSlots>, 'input'>,\n 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * Defines the controlled checked state of the Switch.\n * If passed, Switch ignores the `defaultChecked` property.\n * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the\n * correct value based on handling `onChange` events and re-rendering.\n *\n * @default false\n */\n checked?: boolean;\n\n /**\n * Defines whether the Switch is initially in a checked state or not when rendered.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The position of the label relative to the Switch.\n *\n * @default after\n */\n labelPosition?: 'above' | 'after' | 'before';\n\n /**\n * The size of the Switch.\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n\n /**\n * Callback to be called when the checked state value 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: SwitchOnChangeData) => void;\n};\n\n/**\n * State used in rendering Switch\n */\nexport type SwitchState = ComponentState<SwitchSlots> & Required<Pick<SwitchProps, 'labelPosition' | 'size'>>;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["../src/components/Switch/Switch.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 SwitchSlots = {\n /**\n * The root element of the Switch.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.\n * All other native props will be applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The track and the thumb sliding over it indicating the on and off status of the Switch.\n */\n indicator: NonNullable<Slot<'div'>>;\n\n /**\n * Hidden input that handles the Switch's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this\n * slot, except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The Switch's label.\n */\n label?: Slot<typeof Label>;\n};\n\nexport type SwitchOnChangeData = {\n checked: boolean;\n};\n\n/**\n * Switch Props\n */\nexport type SwitchProps = Omit<\n ComponentProps<Partial<SwitchSlots>, 'input'>,\n 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * Defines the controlled checked state of the Switch.\n * If passed, Switch ignores the `defaultChecked` property.\n * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the\n * correct value based on handling `onChange` events and re-rendering.\n *\n * @default false\n */\n checked?: boolean;\n\n /**\n * Defines whether the Switch is initially in a checked state or not when rendered.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The position of the label relative to the Switch.\n *\n * @default after\n */\n labelPosition?: 'above' | 'after' | 'before';\n\n /**\n * The size of the Switch.\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n\n /**\n * Callback to be called when the checked state value 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: SwitchOnChangeData) => void;\n};\n\n/**\n * Switch base props, excluding design-related props like size\n */\nexport type SwitchBaseProps = Omit<SwitchProps, 'size'>;\n\n/**\n * State used in rendering Switch\n */\nexport type SwitchState = ComponentState<SwitchSlots> & Required<Pick<SwitchProps, 'labelPosition' | 'size'>>;\n\n/**\n * Switch base state, excluding design-related state like size\n */\nexport type SwitchBaseState = Omit<SwitchState, 'size'>;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -1,5 +1,5 @@
1
1
  export { Switch } from './Switch';
2
2
  export { renderSwitch_unstable } from './renderSwitch';
3
- export { useSwitch_unstable } from './useSwitch';
3
+ export { useSwitch_unstable, useSwitchBase_unstable } from './useSwitch';
4
4
  export { // eslint-disable-next-line @typescript-eslint/no-deprecated
5
5
  switchClassName, switchClassNames, useSwitchStyles_unstable } from './useSwitchStyles.styles';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Switch/index.ts"],"sourcesContent":["export { Switch } from './Switch';\nexport type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch.types';\nexport { renderSwitch_unstable } from './renderSwitch';\nexport { useSwitch_unstable } from './useSwitch';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n} from './useSwitchStyles.styles';\n"],"names":["Switch","renderSwitch_unstable","useSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAW;AAElC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SACE,4DAA4D;AAC5DC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,QACnB,2BAA2B"}
1
+ {"version":3,"sources":["../src/components/Switch/index.ts"],"sourcesContent":["export { Switch } from './Switch';\nexport type {\n SwitchBaseProps,\n SwitchBaseState,\n SwitchOnChangeData,\n SwitchProps,\n SwitchSlots,\n SwitchState,\n} from './Switch.types';\nexport { renderSwitch_unstable } from './renderSwitch';\nexport { useSwitch_unstable, useSwitchBase_unstable } from './useSwitch';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n} from './useSwitchStyles.styles';\n"],"names":["Switch","renderSwitch_unstable","useSwitch_unstable","useSwitchBase_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAW;AASlC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,kBAAkB,EAAEC,sBAAsB,QAAQ,cAAc;AACzE,SACE,4DAA4D;AAC5DC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,QACnB,2BAA2B"}
@@ -14,20 +14,32 @@ import { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentu
14
14
  * @param props - props from this instance of Switch
15
15
  * @param ref - reference to `<input>` element of Switch
16
16
  */ export const useSwitch_unstable = (props, ref)=>{
17
+ const { size = 'medium', ...baseProps } = props;
18
+ const baseState = useSwitchBase_unstable(baseProps, ref);
19
+ return {
20
+ ...baseState,
21
+ size
22
+ };
23
+ };
24
+ /**
25
+ * Base hook for Switch component, manages state and structure common to all variants of Switch
26
+ *
27
+ * @param props - base props from this instance of Switch
28
+ * @param ref - reference to `<input>` element of Switch
29
+ */ export const useSwitchBase_unstable = (props, ref)=>{
17
30
  // Merge props from surrounding <Field>, if any
18
31
  props = useFieldControlProps_unstable(props, {
19
32
  supportsLabelFor: true,
20
33
  supportsRequired: true
21
34
  });
22
- const { checked, defaultChecked, disabled, labelPosition = 'after', size = 'medium', onChange, required } = props;
35
+ const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;
23
36
  const nativeProps = getPartitionedNativeProps({
24
37
  props,
25
38
  primarySlotTagName: 'input',
26
39
  excludedPropNames: [
27
40
  'checked',
28
41
  'defaultChecked',
29
- 'onChange',
30
- 'size'
42
+ 'onChange'
31
43
  ]
32
44
  });
33
45
  const id = useId('switch-', nativeProps.primary.id);
@@ -80,7 +92,6 @@ import { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentu
80
92
  root,
81
93
  indicator,
82
94
  input,
83
- label,
84
- size
95
+ label
85
96
  };
86
97
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Switch/useSwitch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { checked, defaultChecked, disabled, labelPosition = 'after', size = 'medium', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange', 'size'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = slot.always(props.root, {\n defaultProps: { ref: useFocusWithin<HTMLDivElement>(), ...nativeProps.root },\n elementType: 'div',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true, children: <CircleFilled /> },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: { checked, defaultChecked, id, ref, role: 'switch', type: 'checkbox', ...nativeProps.primary },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n const label = slot.optional(props.label, {\n defaultProps: { disabled, htmlFor: id, required, size: 'medium' },\n elementType: Label,\n });\n return {\n labelPosition, //Slots definition\n components: { root: 'div', indicator: 'div', input: 'input', label: Label },\n\n root,\n indicator,\n input,\n label,\n size,\n };\n};\n"],"names":["React","useFieldControlProps_unstable","CircleFilled","Label","useFocusWithin","getPartitionedNativeProps","mergeCallbacks","useId","slot","useSwitch_unstable","props","ref","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","labelPosition","size","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","always","defaultProps","elementType","indicator","children","input","role","type","ev","currentTarget","label","optional","htmlFor","components"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,KAAK,QAAQ,wBAAwB;AAC9C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,yBAAyB,EAAEC,cAAc,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4BAA4B;AAGnG;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAqB,CAACC,OAAoBC;IACrD,+CAA+C;IAC/CD,QAAQT,8BAA8BS,OAAO;QAAEE,kBAAkB;QAAMC,kBAAkB;IAAK;IAE9F,MAAM,EAAEC,OAAO,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,gBAAgB,OAAO,EAAEC,OAAO,QAAQ,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGV;IAE5G,MAAMW,cAAchB,0BAA0B;QAC5CK;QACAY,oBAAoB;QACpBC,mBAAmB;YAAC;YAAW;YAAkB;YAAY;SAAO;IACtE;IAEA,MAAMC,KAAKjB,MAAM,WAAWc,YAAYI,OAAO,CAACD,EAAE;IAElD,MAAME,OAAOlB,KAAKmB,MAAM,CAACjB,MAAMgB,IAAI,EAAE;QACnCE,cAAc;YAAEjB,KAAKP;YAAkC,GAAGiB,YAAYK,IAAI;QAAC;QAC3EG,aAAa;IACf;IACA,MAAMC,YAAYtB,KAAKmB,MAAM,CAACjB,MAAMoB,SAAS,EAAE;QAC7CF,cAAc;YAAE,eAAe;YAAMG,wBAAU,oBAAC7B;QAAgB;QAChE2B,aAAa;IACf;IACA,MAAMG,QAAQxB,KAAKmB,MAAM,CAACjB,MAAMsB,KAAK,EAAE;QACrCJ,cAAc;YAAEd;YAASC;YAAgBS;YAAIb;YAAKsB,MAAM;YAAUC,MAAM;YAAY,GAAGb,YAAYI,OAAO;QAAC;QAC3GI,aAAa;IACf;IACAG,MAAMb,QAAQ,GAAGb,eAAe0B,MAAMb,QAAQ,EAAEgB,CAAAA,KAAMhB,qBAAAA,+BAAAA,SAAWgB,IAAI;YAAErB,SAASqB,GAAGC,aAAa,CAACtB,OAAO;QAAC;IACzG,MAAMuB,QAAQ7B,KAAK8B,QAAQ,CAAC5B,MAAM2B,KAAK,EAAE;QACvCT,cAAc;YAAEZ;YAAUuB,SAASf;YAAIJ;YAAUF,MAAM;QAAS;QAChEW,aAAa1B;IACf;IACA,OAAO;QACLc;QACAuB,YAAY;YAAEd,MAAM;YAAOI,WAAW;YAAOE,OAAO;YAASK,OAAOlC;QAAM;QAE1EuB;QACAI;QACAE;QACAK;QACAnB;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Switch/useSwitch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState, SwitchBaseProps, SwitchBaseState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n const { size = 'medium', ...baseProps } = props;\n\n const baseState = useSwitchBase_unstable(baseProps, ref);\n\n return {\n ...baseState,\n size,\n };\n};\n\n/**\n * Base hook for Switch component, manages state and structure common to all variants of Switch\n *\n * @param props - base props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitchBase_unstable = (props: SwitchBaseProps, ref?: React.Ref<HTMLInputElement>): SwitchBaseState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = slot.always(props.root, {\n defaultProps: { ref: useFocusWithin<HTMLDivElement>(), ...nativeProps.root },\n elementType: 'div',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true, children: <CircleFilled /> },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: { checked, defaultChecked, id, ref, role: 'switch', type: 'checkbox', ...nativeProps.primary },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n const label = slot.optional(props.label, {\n defaultProps: { disabled, htmlFor: id, required, size: 'medium' },\n elementType: Label,\n });\n return {\n labelPosition,\n components: { root: 'div', indicator: 'div', input: 'input', label: Label },\n\n root,\n indicator,\n input,\n label,\n };\n};\n"],"names":["React","useFieldControlProps_unstable","CircleFilled","Label","useFocusWithin","getPartitionedNativeProps","mergeCallbacks","useId","slot","useSwitch_unstable","props","ref","size","baseProps","baseState","useSwitchBase_unstable","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","always","defaultProps","elementType","indicator","children","input","role","type","ev","currentTarget","label","optional","htmlFor","components"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,w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AUC,MAAM;YAAY,GAAGb,YAAYI,OAAO;QAAC;QAC3GI,aAAa;IACf;IACAG,MAAMb,QAAQ,GAAGhB,eAAe6B,MAAMb,QAAQ,EAAEgB,CAAAA,KAAMhB,qBAAAA,+BAAAA,SAAWgB,IAAI;YAAEpB,SAASoB,GAAGC,aAAa,CAACrB,OAAO;QAAC;IACzG,MAAMsB,QAAQhC,KAAKiC,QAAQ,CAAC/B,MAAM8B,KAAK,EAAE;QACvCT,cAAc;YAAEX;YAAUsB,SAASf;YAAIJ;YAAUX,MAAM;QAAS;QAChEoB,aAAa7B;IACf;IACA,OAAO;QACLkB;QACAsB,YAAY;YAAEd,MAAM;YAAOI,WAAW;YAAOE,OAAO;YAASK,OAAOrC;QAAM;QAE1E0B;QACAI;QACAE;QACAK;IACF;AACF,EAAE"}
package/lib/index.js CHANGED
@@ -1,2 +1,5 @@
1
1
  export { Switch, renderSwitch_unstable, // eslint-disable-next-line @typescript-eslint/no-deprecated
2
2
  switchClassName, switchClassNames, useSwitchStyles_unstable, useSwitch_unstable } from './Switch';
3
+ // Experimental APIs - will be uncommented in experimental branch
4
+ // export { useSwitchBase_unstable } from './Switch';
5
+ // export type { SwitchBaseProps, SwitchBaseState } from './Switch';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n} from './Switch';\nexport type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable"],"mappings":"AAAA,SACEA,MAAM,EACNC,qBAAqB,EACrB,4DAA4D;AAC5DC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBC,kBAAkB,QACb,WAAW"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n} from './Switch';\nexport type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch';\n\n// Experimental APIs - will be uncommented in experimental branch\n// export { useSwitchBase_unstable } from './Switch';\n// export type { SwitchBaseProps, SwitchBaseState } from './Switch';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable"],"mappings":"AAAA,SACEA,MAAM,EACNC,qBAAqB,EACrB,4DAA4D;AAC5DC,eAAe,EACfC,gBAAgB,EAChBC,wBAAwB,EACxBC,kBAAkB,QACb,WAAW;CAGlB,iEAAiE;CACjE,qDAAqD;CACrD,oEAAoE"}
@@ -21,6 +21,9 @@ _export(exports, {
21
21
  switchClassNames: function() {
22
22
  return _index.switchClassNames;
23
23
  },
24
+ useSwitchBase_unstable: function() {
25
+ return _index.useSwitchBase_unstable;
26
+ },
24
27
  useSwitchStyles_unstable: function() {
25
28
  return _index.useSwitchStyles_unstable;
26
29
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Switch.ts"],"sourcesContent":["export type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './components/Switch/index';\nexport {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n} from './components/Switch/index';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable"],"mappings":";;;;;;;;;;;;eAEEA,aAAM;;;eACNC,4BAAqB,EACrB,4DAA4D;;;eAC5DC,sBAAe;;;eACfC,uBAAgB;;;eAChBC,+BAAwB;;;eACxBC,yBAAkB;;;uBACb,4BAA4B"}
1
+ {"version":3,"sources":["../src/Switch.ts"],"sourcesContent":["export type {\n SwitchBaseProps,\n SwitchBaseState,\n SwitchOnChangeData,\n SwitchProps,\n SwitchSlots,\n SwitchState,\n} from './components/Switch/index';\nexport {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n useSwitchBase_unstable,\n} from './components/Switch/index';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable","useSwitchBase_unstable"],"mappings":";;;;;;;;;;;;eASEA,aAAM;;;eACNC,4BAAqB,EACrB,4DAA4D;;;eAC5DC,sBAAe;;;eACfC,uBAAgB;;;eAGhBG,6BAAsB;;;eAFtBF,+BAAwB;;;eACxBC,yBAAkB;;;uBAEb,4BAA4B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Switch/Switch.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 SwitchSlots = {\n /**\n * The root element of the Switch.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.\n * All other native props will be applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The track and the thumb sliding over it indicating the on and off status of the Switch.\n */\n indicator: NonNullable<Slot<'div'>>;\n\n /**\n * Hidden input that handles the Switch's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this\n * slot, except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The Switch's label.\n */\n label?: Slot<typeof Label>;\n};\n\nexport type SwitchOnChangeData = {\n checked: boolean;\n};\n\n/**\n * Switch Props\n */\nexport type SwitchProps = Omit<\n ComponentProps<Partial<SwitchSlots>, 'input'>,\n 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * Defines the controlled checked state of the Switch.\n * If passed, Switch ignores the `defaultChecked` property.\n * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the\n * correct value based on handling `onChange` events and re-rendering.\n *\n * @default false\n */\n checked?: boolean;\n\n /**\n * Defines whether the Switch is initially in a checked state or not when rendered.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The position of the label relative to the Switch.\n *\n * @default after\n */\n labelPosition?: 'above' | 'after' | 'before';\n\n /**\n * The size of the Switch.\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n\n /**\n * Callback to be called when the checked state value 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: SwitchOnChangeData) => void;\n};\n\n/**\n * State used in rendering Switch\n */\nexport type SwitchState = ComponentState<SwitchSlots> & Required<Pick<SwitchProps, 'labelPosition' | 'size'>>;\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
1
+ {"version":3,"sources":["../src/components/Switch/Switch.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 SwitchSlots = {\n /**\n * The root element of the Switch.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.\n * All other native props will be applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The track and the thumb sliding over it indicating the on and off status of the Switch.\n */\n indicator: NonNullable<Slot<'div'>>;\n\n /**\n * Hidden input that handles the Switch's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this\n * slot, except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The Switch's label.\n */\n label?: Slot<typeof Label>;\n};\n\nexport type SwitchOnChangeData = {\n checked: boolean;\n};\n\n/**\n * Switch Props\n */\nexport type SwitchProps = Omit<\n ComponentProps<Partial<SwitchSlots>, 'input'>,\n 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * Defines the controlled checked state of the Switch.\n * If passed, Switch ignores the `defaultChecked` property.\n * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the\n * correct value based on handling `onChange` events and re-rendering.\n *\n * @default false\n */\n checked?: boolean;\n\n /**\n * Defines whether the Switch is initially in a checked state or not when rendered.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The position of the label relative to the Switch.\n *\n * @default after\n */\n labelPosition?: 'above' | 'after' | 'before';\n\n /**\n * The size of the Switch.\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n\n /**\n * Callback to be called when the checked state value 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: SwitchOnChangeData) => void;\n};\n\n/**\n * Switch base props, excluding design-related props like size\n */\nexport type SwitchBaseProps = Omit<SwitchProps, 'size'>;\n\n/**\n * State used in rendering Switch\n */\nexport type SwitchState = ComponentState<SwitchSlots> & Required<Pick<SwitchProps, 'labelPosition' | 'size'>>;\n\n/**\n * Switch base state, excluding design-related state like size\n */\nexport type SwitchBaseState = Omit<SwitchState, 'size'>;\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
@@ -21,6 +21,9 @@ _export(exports, {
21
21
  switchClassNames: function() {
22
22
  return _useSwitchStylesstyles.switchClassNames;
23
23
  },
24
+ useSwitchBase_unstable: function() {
25
+ return _useSwitch.useSwitchBase_unstable;
26
+ },
24
27
  useSwitchStyles_unstable: function() {
25
28
  return _useSwitchStylesstyles.useSwitchStyles_unstable;
26
29
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Switch/index.ts"],"sourcesContent":["export { Switch } from './Switch';\nexport type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch.types';\nexport { renderSwitch_unstable } from './renderSwitch';\nexport { useSwitch_unstable } from './useSwitch';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n} from './useSwitchStyles.styles';\n"],"names":["Switch","renderSwitch_unstable","useSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,cAAM;;;eAENC,mCAAqB;;;eAI5BE,sCAAe;;;eACfC,uCAAgB;;;eAChBC,+CAAwB;;;eALjBH,6BAAkB;;;wBAHJ,WAAW;8BAEI,iBAAiB;2BACpB,cAAc;uCAM1C,2BAA2B"}
1
+ {"version":3,"sources":["../src/components/Switch/index.ts"],"sourcesContent":["export { Switch } from './Switch';\nexport type {\n SwitchBaseProps,\n SwitchBaseState,\n SwitchOnChangeData,\n SwitchProps,\n SwitchSlots,\n SwitchState,\n} from './Switch.types';\nexport { renderSwitch_unstable } from './renderSwitch';\nexport { useSwitch_unstable, useSwitchBase_unstable } from './useSwitch';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n} from './useSwitchStyles.styles';\n"],"names":["Switch","renderSwitch_unstable","useSwitch_unstable","useSwitchBase_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,cAAM;;;eASNC,mCAAqB;;;eAI5BG,sCAAe;;;eACfC,uCAAgB;;;eAJWF,iCAAsB;;;eAKjDG,+CAAwB;;;eALjBJ,6BAAkB;;;wBAVJ,WAAW;8BASI,iBAAiB;2BACI,cAAc;uCAMlE,2BAA2B"}
@@ -3,9 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "useSwitch_unstable", {
7
- enumerable: true,
8
- get: function() {
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
+ useSwitchBase_unstable: function() {
14
+ return useSwitchBase_unstable;
15
+ },
16
+ useSwitch_unstable: function() {
9
17
  return useSwitch_unstable;
10
18
  }
11
19
  });
@@ -17,20 +25,27 @@ const _reactlabel = require("@fluentui/react-label");
17
25
  const _reacttabster = require("@fluentui/react-tabster");
18
26
  const _reactutilities = require("@fluentui/react-utilities");
19
27
  const useSwitch_unstable = (props, ref)=>{
28
+ const { size = 'medium', ...baseProps } = props;
29
+ const baseState = useSwitchBase_unstable(baseProps, ref);
30
+ return {
31
+ ...baseState,
32
+ size
33
+ };
34
+ };
35
+ const useSwitchBase_unstable = (props, ref)=>{
20
36
  // Merge props from surrounding <Field>, if any
21
37
  props = (0, _reactfield.useFieldControlProps_unstable)(props, {
22
38
  supportsLabelFor: true,
23
39
  supportsRequired: true
24
40
  });
25
- const { checked, defaultChecked, disabled, labelPosition = 'after', size = 'medium', onChange, required } = props;
41
+ const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;
26
42
  const nativeProps = (0, _reactutilities.getPartitionedNativeProps)({
27
43
  props,
28
44
  primarySlotTagName: 'input',
29
45
  excludedPropNames: [
30
46
  'checked',
31
47
  'defaultChecked',
32
- 'onChange',
33
- 'size'
48
+ 'onChange'
34
49
  ]
35
50
  });
36
51
  const id = (0, _reactutilities.useId)('switch-', nativeProps.primary.id);
@@ -83,7 +98,6 @@ const useSwitch_unstable = (props, ref)=>{
83
98
  root,
84
99
  indicator,
85
100
  input,
86
- label,
87
- size
101
+ label
88
102
  };
89
103
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Switch/useSwitch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { checked, defaultChecked, disabled, labelPosition = 'after', size = 'medium', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange', 'size'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = slot.always(props.root, {\n defaultProps: { ref: useFocusWithin<HTMLDivElement>(), ...nativeProps.root },\n elementType: 'div',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true, children: <CircleFilled /> },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: { checked, defaultChecked, id, ref, role: 'switch', type: 'checkbox', ...nativeProps.primary },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n const label = slot.optional(props.label, {\n defaultProps: { disabled, htmlFor: id, required, size: 'medium' },\n elementType: Label,\n });\n return {\n labelPosition, //Slots definition\n components: { root: 'div', indicator: 'div', input: 'input', label: Label },\n\n root,\n indicator,\n input,\n label,\n size,\n };\n};\n"],"names":["React","useFieldControlProps_unstable","CircleFilled","Label","useFocusWithin","getPartitionedNativeProps","mergeCallbacks","useId","slot","useSwitch_unstable","props","ref","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","labelPosition","size","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","always","defaultProps","elementType","indicator","children","input","role","type","ev","currentTarget","label","optional","htmlFor","components"],"mappings":"AAAA;;;;;+BAmBaS;;;;;;;iEAjBU,QAAQ;4BACe,wBAAwB;4BACzC,wBA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ACzG,MAAMuB,QAAQ7B,oBAAAA,CAAK8B,QAAQ,CAAC5B,MAAM2B,KAAK,EAAE;QACvCT,cAAc;YAAEZ;YAAUuB,SAASf;YAAIJ;YAAUF,MAAM;QAAS;QAChEW,aAAa1B,iBAAAA;IACf;IACA,OAAO;QACLc;QACAuB,YAAY;YAAEd,MAAM;YAAOI,WAAW;YAAOE,OAAO;YAASK,OAAOlC,iBAAAA;QAAM;QAE1EuB;QACAI;QACAE;QACAK;QACAnB;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Switch/useSwitch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, useId, slot } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState, SwitchBaseProps, SwitchBaseState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n const { size = 'medium', ...baseProps } = props;\n\n const baseState = useSwitchBase_unstable(baseProps, ref);\n\n return {\n ...baseState,\n size,\n };\n};\n\n/**\n * Base hook for Switch component, manages state and structure common to all variants of Switch\n *\n * @param props - base props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitchBase_unstable = (props: SwitchBaseProps, ref?: React.Ref<HTMLInputElement>): SwitchBaseState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n\n const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = slot.always(props.root, {\n defaultProps: { ref: useFocusWithin<HTMLDivElement>(), ...nativeProps.root },\n elementType: 'div',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true, children: <CircleFilled /> },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: { checked, defaultChecked, id, ref, role: 'switch', type: 'checkbox', ...nativeProps.primary },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n const label = slot.optional(props.label, {\n defaultProps: { disabled, htmlFor: id, required, size: 'medium' },\n elementType: Label,\n });\n return {\n labelPosition,\n components: { root: 'div', indicator: 'div', input: 'input', label: Label },\n\n root,\n indicator,\n input,\n label,\n };\n};\n"],"names":["React","useFieldControlProps_unstable","CircleFilled","Label","useFocusWithin","getPartitionedNativeProps","mergeCallbacks","useId","slot","useSwitch_unstable","props","ref","size","baseProps","baseState","useSwitchBase_unstable","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","always","defaultProps","elementType","indicator","children","input","role","type","ev","currentTarget","label","optional","htmlFor","components"],"mappings":"AAAA;;;;;;;;;;;;0BAoCae;eAAAA;;IAjBAN,kBAAAA;;;;;iEAjBU,QAAQ;4BACe,wBAAwB;4BACzC,wBAAwB;4BAC/B,wBAAwB;8BACf,0BAA0B;gCACc,4BAA4B;AAY5F,2BAA2B,CAACC,OAAoBC;IACrD,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGC,WAAW,GAAGH;IAE1C,MAAMI,YAAYC,uBAAuBF,WAAWF;IAEpD,OAAO;QACL,GAAGG,SAAS;QACZF;IACF;AACF,EAAE;AAQK,+BAA+B,CAACF,OAAwBC;IAC7D,+CAA+C;IAC/CD,YAAQT,y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;QAAS;QAChEoB,aAAa7B,iBAAAA;IACf;IACA,OAAO;QACLkB;QACAsB,YAAY;YAAEd,MAAM;YAAOI,WAAW;YAAOE,OAAO;YAASK,OAAOrC,iBAAAA;QAAM;QAE1E0B;QACAI;QACAE;QACAK;IACF;AACF,EAAE"}
@@ -29,3 +29,6 @@ _export(exports, {
29
29
  }
30
30
  });
31
31
  const _Switch = require("./Switch");
32
+ // Experimental APIs - will be uncommented in experimental branch
33
+ // export { useSwitchBase_unstable } from './Switch';
34
+ // export type { SwitchBaseProps, SwitchBaseState } from './Switch';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n} from './Switch';\nexport type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable"],"mappings":";;;;;;;;;;;;eACEA,cAAM;;;eACNC,6BAAqB,EACrB,4DAA4D;;;eAC5DC,uBAAe;;;eACfC,wBAAgB;;;eAChBC,gCAAwB;;;eACxBC,0BAAkB;;;wBACb,WAAW"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n Switch,\n renderSwitch_unstable,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n useSwitch_unstable,\n} from './Switch';\nexport type { SwitchOnChangeData, SwitchProps, SwitchSlots, SwitchState } from './Switch';\n\n// Experimental APIs - will be uncommented in experimental branch\n// export { useSwitchBase_unstable } from './Switch';\n// export type { SwitchBaseProps, SwitchBaseState } from './Switch';\n"],"names":["Switch","renderSwitch_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable","useSwitch_unstable"],"mappings":";;;;;;;;;;;;eACEA,cAAM;;;eACNC,6BAAqB,EACrB,4DAA4D;;;eAC5DC,uBAAe;;;eACfC,wBAAgB;;;eAChBC,gCAAwB;;;eACxBC,0BAAkB;;;wBACb,WAAW;CAGlB,iEAAiE;CACjE,qDAAqD;CACrD,oEAAoE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-switch",
3
- "version": "9.5.2",
3
+ "version": "9.5.3",
4
4
  "description": "Fluent UI React Switch component.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -12,10 +12,10 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@fluentui/react-field": "^9.4.13",
15
+ "@fluentui/react-field": "^9.4.14",
16
16
  "@fluentui/react-icons": "^2.0.245",
17
- "@fluentui/react-jsx-runtime": "^9.3.5",
18
- "@fluentui/react-label": "^9.3.13",
17
+ "@fluentui/react-jsx-runtime": "^9.4.0",
18
+ "@fluentui/react-label": "^9.3.14",
19
19
  "@fluentui/react-shared-contexts": "^9.26.1",
20
20
  "@fluentui/react-tabster": "^9.26.12",
21
21
  "@fluentui/react-theme": "^9.2.1",