@fluentui/react-switch 9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 → 9.75.2-experimental.css-modules.20261113-ba13c87438.0

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,23 +1,23 @@
1
1
  # Change Log - @fluentui/react-switch
2
2
 
3
- <!-- This log was last generated on Tue, 03 Nov 2026 14:18:11 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Fri, 13 Nov 2026 20:37:00 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [9.75.1-experimental.positioning-engine.20261103-19efe125d1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0)
7
+ ## [9.75.2-experimental.css-modules.20261113-ba13c87438.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.75.2-experimental.css-modules.20261113-ba13c87438.0)
8
8
 
9
- Tue, 03 Nov 2026 14:18:11 GMT
9
+ Fri, 13 Nov 2026 20:37:00 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
- - Release 9.75.1-experimental.positioning-engine.20261103-19efe125d1 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by 257645319+office-ogx-auth-helper[bot]@users.noreply.github.com)
14
- - Bump @fluentui/react-field to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
- - Bump @fluentui/react-jsx-runtime to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
- - Bump @fluentui/react-label to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
- - Bump @fluentui/react-shared-contexts to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
- - Bump @fluentui/react-tabster to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
19
- - Bump @fluentui/react-theme to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
20
- - Bump @fluentui/react-utilities to v9.75.1-experimental.positioning-engine.20261103-19efe125d1.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
13
+ - Release 9.75.2-experimental.css-modules.20261113-ba13c87438 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by 257645319+office-ogx-auth-helper[bot]@users.noreply.github.com)
14
+ - Bump @fluentui/react-field to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
+ - Bump @fluentui/react-jsx-runtime to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
+ - Bump @fluentui/react-label to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
+ - Bump @fluentui/react-shared-contexts to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
+ - Bump @fluentui/react-tabster to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
19
+ - Bump @fluentui/react-theme to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
20
+ - Bump @fluentui/react-utilities to v9.75.2-experimental.css-modules.20261113-ba13c87438.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
21
21
 
22
22
  ## [9.7.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.7.7)
23
23
 
package/README.md CHANGED
@@ -31,8 +31,16 @@ Alternatively, run Storybook locally with:
31
31
 
32
32
  ### Specification
33
33
 
34
- See [SPEC.md](./Spec.md).
34
+ See [SPEC.md](./docs/Spec.md).
35
35
 
36
36
  ### Migration Guide
37
37
 
38
- If you're upgrading to Fluent UI v9 see [MIGRATION.md](./MIGRATION.md) for guidance on updating to the latest Switch implementation.
38
+ If you're upgrading to Fluent UI v9 see [MIGRATION.md](./docs/MIGRATION.md) for guidance on updating to the latest Switch implementation.
39
+
40
+ ## Opt-in CSS Modules styles
41
+
42
+ CSS Modules alternatives are available for `Switch`. The default exports and component imports continue to use Griffel.
43
+
44
+ To opt in, configure your bundler to replace each `use<Component>Styles.styles.js` module with its adjacent `use<Component>Styles.styles.css.js` alternative (or `.styles.ts` with `.styles.css.ts` for source builds). Apply the replacement consistently to client and server bundles. The CSS loader must provide a default class-name map and retain the adjacent `.module.css` asset, including CSS from dependencies. Component rules are unlayered, like Griffel's, and use the theme custom properties supplied by `FluentProvider`.
45
+
46
+ For composed labels, also select the CSS Modules alternative for `@fluentui/react-label`. Mixing its default Griffel styles with these alternatives makes label typography depend on style insertion order.
@@ -0,0 +1,289 @@
1
+ /* @griffel-buckets reset: .root, .indicator, .input */
2
+ .root:focus {
3
+ outline-style: none;
4
+ }
5
+
6
+ .root:focus-visible {
7
+ outline-style: none;
8
+ }
9
+
10
+ .root[data-fui-focus-within]:focus-within::after {
11
+ content: '';
12
+ position: absolute;
13
+ pointer-events: none;
14
+ z-index: 1;
15
+ border: var(--strokeWidthThick) solid var(--colorStrokeFocus2);
16
+ border-radius: var(--borderRadiusMedium);
17
+ top: calc(var(--strokeWidthThick) * -1);
18
+ inset-inline-end: calc(var(--strokeWidthThick) * -1);
19
+ bottom: calc(var(--strokeWidthThick) * -1);
20
+ inset-inline-start: calc(var(--strokeWidthThick) * -1);
21
+ }
22
+
23
+ .root[data-fui-focus-within]:focus-within {
24
+ border-top-color: transparent;
25
+ border-inline-end-color: transparent;
26
+ border-bottom-color: transparent;
27
+ border-inline-start-color: transparent;
28
+ }
29
+
30
+ .root {
31
+ align-items: flex-start;
32
+ box-sizing: border-box;
33
+ display: inline-flex;
34
+ position: relative;
35
+ }
36
+
37
+ .above {
38
+ flex-direction: column;
39
+ }
40
+
41
+ .indicator > * {
42
+ transition-duration: var(--durationNormal);
43
+ transition-timing-function: var(--curveEasyEase);
44
+ transition-property: transform;
45
+ }
46
+
47
+ .indicator {
48
+ border-radius: var(--borderRadiusCircular);
49
+ border: var(--strokeWidthThin) solid;
50
+ line-height: 0;
51
+ box-sizing: border-box;
52
+ fill: currentColor;
53
+ flex-shrink: 0;
54
+ font-size: calc(var(--spacingHorizontalXS) * 4.5);
55
+ height: var(--spacingHorizontalXL);
56
+ margin: var(--spacingVerticalS) var(--spacingHorizontalS);
57
+ pointer-events: none;
58
+ transition-duration: var(--durationNormal);
59
+ transition-timing-function: var(--curveEasyEase);
60
+ transition-property: background, border, color;
61
+ width: calc(var(--spacingHorizontalXS) * 10);
62
+ }
63
+
64
+ :where(.withLabel.above) > .indicator {
65
+ margin-top: 0;
66
+ }
67
+
68
+ :where(.small) > .indicator {
69
+ font-size: var(--fontSizeBase300);
70
+ height: var(--spacingHorizontalL);
71
+ width: var(--spacingHorizontalXXXL);
72
+ }
73
+
74
+ .input:checked ~ :global(.fui-Switch__indicator) > * {
75
+ transform: translateX(var(--spacingHorizontalXL));
76
+ }
77
+
78
+ .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
79
+ transform: translateX(calc(var(--spacingHorizontalXL) * -1));
80
+ }
81
+
82
+ .input:disabled ~ :global(.fui-Switch__indicator),
83
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
84
+ color: var(--colorNeutralForegroundDisabled);
85
+ }
86
+
87
+ .input:disabled ~ :global(.fui-Switch__label),
88
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__label) {
89
+ cursor: default;
90
+ color: var(--colorNeutralForegroundDisabled);
91
+ }
92
+
93
+ .input:disabled,
94
+ .input[aria-disabled='true'] {
95
+ cursor: default;
96
+ }
97
+
98
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
99
+ color: var(--colorNeutralStrokeAccessible);
100
+ border-color: var(--colorNeutralStrokeAccessible);
101
+ }
102
+
103
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__label) {
104
+ color: var(--colorNeutralForeground1);
105
+ }
106
+
107
+ .input:enabled:not(:checked):not([aria-disabled='true']):hover ~ :global(.fui-Switch__indicator) {
108
+ color: var(--colorNeutralStrokeAccessibleHover);
109
+ border-color: var(--colorNeutralStrokeAccessibleHover);
110
+ }
111
+
112
+ .input:enabled:not(:checked):not([aria-disabled='true']):hover:active ~ :global(.fui-Switch__indicator) {
113
+ color: var(--colorNeutralStrokeAccessiblePressed);
114
+ border-color: var(--colorNeutralStrokeAccessiblePressed);
115
+ }
116
+
117
+ .input:enabled:checked:not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
118
+ background-color: var(--colorCompoundBrandBackground);
119
+ color: var(--colorNeutralForegroundInverted);
120
+ border-color: var(--colorTransparentStroke);
121
+ }
122
+
123
+ .input:enabled:checked:not([aria-disabled='true']):hover ~ :global(.fui-Switch__indicator) {
124
+ background-color: var(--colorCompoundBrandBackgroundHover);
125
+ border-color: var(--colorTransparentStrokeInteractive);
126
+ }
127
+
128
+ .input:enabled:checked:not([aria-disabled='true']):hover:active ~ :global(.fui-Switch__indicator) {
129
+ background-color: var(--colorCompoundBrandBackgroundPressed);
130
+ border-color: var(--colorTransparentStrokeInteractive);
131
+ }
132
+
133
+ .input:disabled:not(:checked) ~ :global(.fui-Switch__indicator),
134
+ .input[aria-disabled='true']:not(:checked) ~ :global(.fui-Switch__indicator) {
135
+ border-color: var(--colorNeutralStrokeDisabled);
136
+ }
137
+
138
+ .input:disabled:checked ~ :global(.fui-Switch__indicator),
139
+ .input[aria-disabled='true']:checked ~ :global(.fui-Switch__indicator) {
140
+ background-color: var(--colorNeutralBackgroundDisabled);
141
+ border-color: var(--colorTransparentStrokeDisabled);
142
+ }
143
+
144
+ .input {
145
+ box-sizing: border-box;
146
+ cursor: pointer;
147
+ height: 100%;
148
+ margin: 0;
149
+ opacity: 0;
150
+ position: absolute;
151
+ width: calc(calc(var(--spacingHorizontalXS) * 10) + 2 * var(--spacingHorizontalS));
152
+ }
153
+
154
+ :where(.withLabel.before) > .input {
155
+ inset-inline-end: 0;
156
+ top: 0;
157
+ }
158
+
159
+ :where(.withLabel.after) > .input {
160
+ inset-inline-start: 0;
161
+ top: 0;
162
+ }
163
+
164
+ :where(.withLabel.above) > .input {
165
+ bottom: 0;
166
+ height: calc(var(--spacingHorizontalXL) + var(--spacingVerticalS));
167
+ width: 100%;
168
+ }
169
+
170
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > * {
171
+ transform: translateX(var(--spacingHorizontalL));
172
+ }
173
+
174
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
175
+ transform: translateX(calc(var(--spacingHorizontalL) * -1));
176
+ }
177
+
178
+ :where(.small) > .input {
179
+ width: calc(var(--spacingHorizontalXXXL) + 2 * var(--spacingHorizontalS));
180
+ }
181
+
182
+ .label {
183
+ cursor: pointer;
184
+ margin-bottom: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
185
+ margin-top: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
186
+ padding: var(--spacingVerticalS) var(--spacingHorizontalS);
187
+ }
188
+
189
+ :where(.small) > .label {
190
+ font-size: var(--fontSizeBase200);
191
+ line-height: var(--lineHeightBase200);
192
+ margin-bottom: calc((var(--spacingHorizontalL) - var(--lineHeightBase200)) / 2);
193
+ margin-top: calc((var(--spacingHorizontalL) - var(--lineHeightBase200)) / 2);
194
+ }
195
+
196
+ :where(.above) > .label {
197
+ padding-top: var(--spacingVerticalXS);
198
+ padding-bottom: var(--spacingVerticalXS);
199
+ width: 100%;
200
+ }
201
+
202
+ :where(.after) > .label {
203
+ padding-inline-start: var(--spacingHorizontalXS);
204
+ }
205
+
206
+ :where(.before) > .label {
207
+ padding-inline-end: var(--spacingHorizontalXS);
208
+ }
209
+
210
+ @media (forced-colors: active) {
211
+ .root[data-fui-focus-within]:focus-within::after {
212
+ border-top-color: Highlight;
213
+ border-inline-end-color: Highlight;
214
+ border-bottom-color: Highlight;
215
+ border-inline-start-color: Highlight;
216
+ }
217
+ }
218
+
219
+ @media screen and (prefers-reduced-motion: reduce) {
220
+ .indicator {
221
+ transition-duration: 0.01ms;
222
+ }
223
+ }
224
+
225
+ @media (forced-colors: active) {
226
+ .indicator > i {
227
+ forced-color-adjust: none;
228
+ }
229
+ }
230
+
231
+ @media (forced-colors: active) {
232
+ .indicator {
233
+ color: CanvasText;
234
+ }
235
+ }
236
+
237
+ @media screen and (prefers-reduced-motion: reduce) {
238
+ .indicator > * {
239
+ transition-duration: 0.01ms;
240
+ }
241
+ }
242
+
243
+ @media (forced-colors: active) {
244
+ .input:disabled ~ :global(.fui-Switch__indicator),
245
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
246
+ color: GrayText;
247
+ border-color: GrayText;
248
+ }
249
+ }
250
+
251
+ @media (forced-colors: active) {
252
+ .input:disabled ~ :global(.fui-Switch__label),
253
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__label) {
254
+ color: GrayText;
255
+ }
256
+ }
257
+
258
+ @media (forced-colors: active) {
259
+ .input:hover {
260
+ color: CanvasText;
261
+ }
262
+ }
263
+
264
+ @media (forced-colors: active) {
265
+ .input:hover:active {
266
+ color: CanvasText;
267
+ }
268
+ }
269
+
270
+ @media (forced-colors: active) {
271
+ .input:enabled:checked:not([aria-disabled='true']):hover ~ :global(.fui-Switch__indicator) {
272
+ background-color: Highlight;
273
+ color: Canvas;
274
+ }
275
+ }
276
+
277
+ @media (forced-colors: active) {
278
+ .input:enabled:checked:not([aria-disabled='true']):hover:active ~ :global(.fui-Switch__indicator) {
279
+ background-color: Highlight;
280
+ color: Canvas;
281
+ }
282
+ }
283
+
284
+ @media (forced-colors: active) {
285
+ .input:enabled:checked:not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
286
+ background-color: Highlight;
287
+ color: Canvas;
288
+ }
289
+ }
@@ -4,7 +4,7 @@ import { useFieldControlProps_unstable } from "@fluentui/react-field";
4
4
  import { CircleFilled } from "@fluentui/react-icons";
5
5
  import { Label } from "@fluentui/react-label";
6
6
  import { useFocusWithin } from "@fluentui/react-tabster";
7
- import { getPartitionedNativeProps, mergeCallbacks, useId, slot } from "@fluentui/react-utilities";
7
+ import { getPartitionedNativeProps, mergeCallbacks, useId, useMergedRefs, slot } from "@fluentui/react-utilities";
8
8
  /**
9
9
  * Create the state required to render Switch.
10
10
  *
@@ -17,6 +17,10 @@ import { getPartitionedNativeProps, mergeCallbacks, useId, slot } from "@fluentu
17
17
  var _baseState_indicator, _children;
18
18
  const { size = 'medium', ...baseProps } = props;
19
19
  const baseState = useSwitchBase_unstable(baseProps, ref);
20
+ // Focus-within ref drives the styled focus outline; applied here rather than in the base hook
21
+ // so the base hook does not depend on react-tabster (keyborg).
22
+ // eslint-disable-next-line react-hooks/immutability
23
+ baseState.root.ref = useMergedRefs(baseState.root.ref, useFocusWithin());
20
24
  (_children = (_baseState_indicator = baseState.indicator).children) !== null && _children !== void 0 ? _children : _baseState_indicator.children = /*#__PURE__*/ React.createElement(CircleFilled, null);
21
25
  return {
22
26
  ...baseState,
@@ -59,10 +63,7 @@ import { getPartitionedNativeProps, mergeCallbacks, useId, slot } from "@fluentu
59
63
  });
60
64
  const id = useId('switch-', nativeProps.primary.id);
61
65
  const root = slot.always(props.root, {
62
- defaultProps: {
63
- ref: useFocusWithin(),
64
- ...nativeProps.root
65
- },
66
+ defaultProps: nativeProps.root,
66
67
  elementType: 'div'
67
68
  });
68
69
  const indicator = slot.always(props.indicator, {
@@ -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, 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 baseState.indicator.children ??= <CircleFilled />;\n\n return {\n ...baseState,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...baseState.components,\n label: Label,\n },\n size,\n label: slot.optional(props.label, {\n defaultProps: { size: 'medium', ...baseState.label },\n elementType: Label,\n }),\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 {\n checked,\n defaultChecked,\n disabled,\n disabledFocusable = false,\n labelPosition = 'after',\n onChange,\n required,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange', 'disabledFocusable'],\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 },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n disabled: disabled && !disabledFocusable,\n ...(disabledFocusable && { 'aria-disabled': true }),\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n input.onClick = mergeCallbacks(input.onClick, ev => {\n if (disabledFocusable) {\n ev.preventDefault();\n }\n });\n input.onKeyDown = mergeCallbacks(input.onKeyDown, ev => {\n if (disabledFocusable && (ev.key === ' ' || ev.key === 'Enter')) {\n ev.preventDefault();\n }\n });\n const label = slot.optional(props.label, {\n defaultProps: { disabled: disabled || disabledFocusable, htmlFor: id, required },\n elementType: 'label',\n });\n return {\n disabledFocusable,\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","baseState","size","baseProps","useSwitchBase_unstable","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","disabledFocusable","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","always","input","role","type","ev","currentTarget","onClick","preventDefault","onKeyDown","key","htmlFor"],"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,G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ACA,MAAMiB,QAAQ/B,KAAK8B,MAAM,CAAC5B,MAAM6B,KAAK,EAAE;QACrClB,cAAc;YACZI;YACAC;YACAS;YACAxB;YACA6B,MAAM;YACNC,MAAM;YACN,GAAGT,YAAYI,OAAO;YACtBT,UAAUA,YAAY,CAACC;YACvB,GAAIA,qBAAqB;gBAAE,iBAAiB;YAAK,CAAC;QACpD;QACAN,aAAa;IACf;IACAiB,MAAMT,QAAQ,GAAGxB,eAAeiC,MAAMT,QAAQ,EAAEY,CAAAA,KAAMZ,qBAAAA,+BAAAA,SAAWY,IAAI;YAAEjB,SAASiB,GAAGC,aAAa,CAAClB,OAAO;QAAC;IACzGc,MAAMK,OAAO,GAAGtC,eAAeiC,MAAMK,OAAO,EAAEF,CAAAA;QAC5C,IAAId,mBAAmB;YACrBc,GAAGG,cAAc;QACnB;IACF;IACAN,MAAMO,SAAS,GAAGxC,eAAeiC,MAAMO,SAAS,EAAEJ,CAAAA;QAChD,IAAId,qBAAsBc,CAAAA,GAAGK,GAAG,KAAK,OAAOL,GAAGK,GAAG,KAAK,OAAM,GAAI;YAC/DL,GAAGG,cAAc;QACnB;IACF;IACA,MAAM1B,QAAQX,KAAKY,QAAQ,CAACV,MAAMS,KAAK,EAAE;QACvCE,cAAc;YAAEM,UAAUA,YAAYC;YAAmBoB,SAASb;YAAIJ;QAAS;QAC/ET,aAAa;IACf;IACA,OAAO;QACLM;QACAC;QACAX,YAAY;YAAEmB,MAAM;YAAOrB,WAAW;YAAOuB,OAAO;YAASpB,OAAO;QAAQ;QAE5EkB;QACArB;QACAuB;QACApB;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, useMergedRefs, 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 // Focus-within ref drives the styled focus outline; applied here rather than in the base hook\n // so the base hook does not depend on react-tabster (keyborg).\n // eslint-disable-next-line react-hooks/immutability\n baseState.root.ref = useMergedRefs(baseState.root.ref, useFocusWithin<HTMLDivElement>());\n\n baseState.indicator.children ??= <CircleFilled />;\n\n return {\n ...baseState,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...baseState.components,\n label: Label,\n },\n size,\n label: slot.optional(props.label, {\n defaultProps: { size: 'medium', ...baseState.label },\n elementType: Label,\n }),\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 {\n checked,\n defaultChecked,\n disabled,\n disabledFocusable = false,\n labelPosition = 'after',\n onChange,\n required,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange', 'disabledFocusable'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = slot.always(props.root, {\n defaultProps: nativeProps.root,\n elementType: 'div',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n disabled: disabled && !disabledFocusable,\n ...(disabledFocusable && { 'aria-disabled': true }),\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n input.onClick = mergeCallbacks(input.onClick, ev => {\n if (disabledFocusable) {\n ev.preventDefault();\n }\n });\n input.onKeyDown = mergeCallbacks(input.onKeyDown, ev => {\n if (disabledFocusable && (ev.key === ' ' || ev.key === 'Enter')) {\n ev.preventDefault();\n }\n });\n const label = slot.optional(props.label, {\n defaultProps: { disabled: disabled || disabledFocusable, htmlFor: id, required },\n elementType: 'label',\n });\n return {\n disabledFocusable,\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","useMergedRefs","slot","useSwitch_unstable","props","ref","baseState","size","baseProps","useSwitchBase_unstable","root","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","disabledFocusable","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","always","input","role","type","ev","currentTarget","onClick","preventDefault","onKeyDown","key","htmlFor"],"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,aAAa,EAAEC,IAAI,QAAQ,4BAA4B;AAGlH;;;;;;;;CAQC,GACD,OAAO,MAAMC,qBAAqB,CAACC,O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AS,EAAE;QAC7CK,cAAc;YAAE,eAAe;QAAK;QACpCC,aAAa;IACf;IACA,MAAMgB,QAAQ/B,KAAK8B,MAAM,CAAC5B,MAAM6B,KAAK,EAAE;QACrCjB,cAAc;YACZI;YACAC;YACAS;YACAzB;YACA6B,MAAM;YACNC,MAAM;YACN,GAAGR,YAAYI,OAAO;YACtBT,UAAUA,YAAY,CAACC;YACvB,GAAIA,qBAAqB;gBAAE,iBAAiB;YAAK,CAAC;QACpD;QACAN,aAAa;IACf;IACAgB,MAAMR,QAAQ,GAAG1B,eAAekC,MAAMR,QAAQ,EAAEW,CAAAA,KAAMX,qBAAAA,+BAAAA,SAAWW,IAAI;YAAEhB,SAASgB,GAAGC,aAAa,CAACjB,OAAO;QAAC;IACzGa,MAAMK,OAAO,GAAGvC,eAAekC,MAAMK,OAAO,EAAEF,CAAAA;QAC5C,IAAIb,mBAAmB;YACrBa,GAAGG,cAAc;QACnB;IACF;IACAN,MAAMO,SAAS,GAAGzC,eAAekC,MAAMO,SAAS,EAAEJ,CAAAA;QAChD,IAAIb,qBAAsBa,CAAAA,GAAGK,GAAG,KAAK,OAAOL,GAAGK,GAAG,KAAK,OAAM,GAAI;YAC/DL,GAAGG,cAAc;QACnB;IACF;IACA,MAAMzB,QAAQZ,KAAKa,QAAQ,CAACX,MAAMU,KAAK,EAAE;QACvCE,cAAc;YAAEM,UAAUA,YAAYC;YAAmBmB,SAASZ;YAAIJ;QAAS;QAC/ET,aAAa;IACf;IACA,OAAO;QACLM;QACAC;QACAX,YAAY;YAAEH,MAAM;YAAOC,WAAW;YAAOsB,OAAO;YAASnB,OAAO;QAAQ;QAE5EJ;QACAC;QACAsB;QACAnB;IACF;AACF,EAAE"}
@@ -0,0 +1,18 @@
1
+ import { clsx } from "clsx";
2
+ import styles from "./Switch.module.css";
3
+ export const switchClassNames = {
4
+ root: 'fui-Switch',
5
+ indicator: 'fui-Switch__indicator',
6
+ input: 'fui-Switch__input',
7
+ label: 'fui-Switch__label'
8
+ };
9
+ /** @deprecated Use `switchClassNames.root` instead. */ export const switchClassName = switchClassNames.root;
10
+ export const useSwitchStyles_unstable = (state)=>{
11
+ state.root.className = clsx(switchClassNames.root, styles.root, styles[state.labelPosition], styles[state.size], state.label && styles.withLabel, state.root.className);
12
+ state.indicator.className = clsx(switchClassNames.indicator, styles.indicator, state.indicator.className);
13
+ state.input.className = clsx(switchClassNames.input, styles.input, state.input.className);
14
+ if (state.label) {
15
+ state.label.className = clsx(switchClassNames.label, styles.label, state.label.className);
16
+ }
17
+ return state;
18
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Switch/useSwitchStyles.styles.css.ts"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\nimport styles from './Switch.module.css';\n\nexport const switchClassNames: SlotClassNames<SwitchSlots> = {\n root: 'fui-Switch',\n indicator: 'fui-Switch__indicator',\n input: 'fui-Switch__input',\n label: 'fui-Switch__label',\n};\n\n/** @deprecated Use `switchClassNames.root` instead. */\nexport const switchClassName = switchClassNames.root;\n\nexport const useSwitchStyles_unstable = (state: SwitchState): SwitchState => {\n state.root.className = clsx(\n switchClassNames.root,\n styles.root,\n styles[state.labelPosition],\n styles[state.size],\n state.label && styles.withLabel,\n state.root.className,\n );\n state.indicator.className = clsx(switchClassNames.indicator, styles.indicator, state.indicator.className);\n state.input.className = clsx(switchClassNames.input, styles.input, state.input.className);\n if (state.label) {\n state.label.className = clsx(switchClassNames.label, styles.label, state.label.className);\n }\n return state;\n};\n"],"names":["clsx","styles","switchClassNames","root","indicator","input","label","switchClassName","useSwitchStyles_unstable","state","className","labelPosition","size","withLabel"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAG5B,OAAOC,YAAY,sBAAsB;AAEzC,OAAO,MAAMC,mBAAgD;IAC3DC,MAAM;IACNC,WAAW;IACXC,OAAO;IACPC,OAAO;AACT,EAAE;AAEF,qDAAqD,GACrD,OAAO,MAAMC,kBAAkBL,iBAAiBC,IAAI,CAAC;AAErD,OAAO,MAAMK,2BAA2B,CAACC;IACvCA,MAAMN,IAAI,CAACO,SAAS,GAAGV,KACrBE,iBAAiBC,IAAI,EACrBF,OAAOE,IAAI,EACXF,MAAM,CAACQ,MAAME,aAAa,CAAC,EAC3BV,MAAM,CAACQ,MAAMG,IAAI,CAAC,EAClBH,MAAMH,KAAK,IAAIL,OAAOY,SAAS,EAC/BJ,MAAMN,IAAI,CAACO,SAAS;IAEtBD,MAAML,SAAS,CAACM,SAAS,GAAGV,KAAKE,iBAAiBE,SAAS,EAAEH,OAAOG,SAAS,EAAEK,MAAML,SAAS,CAACM,SAAS;IACxGD,MAAMJ,KAAK,CAACK,SAAS,GAAGV,KAAKE,iBAAiBG,KAAK,EAAEJ,OAAOI,KAAK,EAAEI,MAAMJ,KAAK,CAACK,SAAS;IACxF,IAAID,MAAMH,KAAK,EAAE;QACfG,MAAMH,KAAK,CAACI,SAAS,GAAGV,KAAKE,iBAAiBI,KAAK,EAAEL,OAAOK,KAAK,EAAEG,MAAMH,KAAK,CAACI,SAAS;IAC1F;IACA,OAAOD;AACT,EAAE"}
@@ -0,0 +1,18 @@
1
+ import { clsx } from "clsx";
2
+ import styles from "./Switch.module.css";
3
+ export const switchClassNames = {
4
+ root: 'fui-Switch',
5
+ indicator: 'fui-Switch__indicator',
6
+ input: 'fui-Switch__input',
7
+ label: 'fui-Switch__label'
8
+ };
9
+ /** @deprecated Use `switchClassNames.root` instead. */ export const switchClassName = switchClassNames.root;
10
+ export const useSwitchStyles_unstable = (state)=>{
11
+ state.root.className = clsx(switchClassNames.root, styles.root, styles[state.labelPosition], styles[state.size], state.label && styles.withLabel, state.root.className);
12
+ state.indicator.className = clsx(switchClassNames.indicator, styles.indicator, state.indicator.className);
13
+ state.input.className = clsx(switchClassNames.input, styles.input, state.input.className);
14
+ if (state.label) {
15
+ state.label.className = clsx(switchClassNames.label, styles.label, state.label.className);
16
+ }
17
+ return state;
18
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Switch/useSwitchStyles.styles.css.ts"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\nimport styles from './Switch.module.css';\n\nexport const switchClassNames: SlotClassNames<SwitchSlots> = {\n root: 'fui-Switch',\n indicator: 'fui-Switch__indicator',\n input: 'fui-Switch__input',\n label: 'fui-Switch__label',\n};\n\n/** @deprecated Use `switchClassNames.root` instead. */\nexport const switchClassName = switchClassNames.root;\n\nexport const useSwitchStyles_unstable = (state: SwitchState): SwitchState => {\n state.root.className = clsx(\n switchClassNames.root,\n styles.root,\n styles[state.labelPosition],\n styles[state.size],\n state.label && styles.withLabel,\n state.root.className,\n );\n state.indicator.className = clsx(switchClassNames.indicator, styles.indicator, state.indicator.className);\n state.input.className = clsx(switchClassNames.input, styles.input, state.input.className);\n if (state.label) {\n state.label.className = clsx(switchClassNames.label, styles.label, state.label.className);\n }\n return state;\n};\n"],"names":["clsx","styles","switchClassNames","root","indicator","input","label","switchClassName","useSwitchStyles_unstable","state","className","labelPosition","size","withLabel"],"mappings":"AAAA,SAASA,IAAI,QAAQ,OAAO;AAG5B,OAAOC,YAAY,sBAAsB;AAEzC,OAAO,MAAMC,mBAAgD;IAC3DC,MAAM;IACNC,WAAW;IACXC,OAAO;IACPC,OAAO;AACT,EAAE;AAEF,qDAAqD,GACrD,OAAO,MAAMC,kBAAkBL,iBAAiBC,IAAI,CAAC;AAErD,OAAO,MAAMK,2BAA2B,CAACC;IACvCA,MAAMN,IAAI,CAACO,SAAS,GAAGV,KACrBE,iBAAiBC,IAAI,EACrBF,OAAOE,IAAI,EACXF,MAAM,CAACQ,MAAME,aAAa,CAAC,EAC3BV,MAAM,CAACQ,MAAMG,IAAI,CAAC,EAClBH,MAAMH,KAAK,IAAIL,OAAOY,SAAS,EAC/BJ,MAAMN,IAAI,CAACO,SAAS;IAEtBD,MAAML,SAAS,CAACM,SAAS,GAAGV,KAAKE,iBAAiBE,SAAS,EAAEH,OAAOG,SAAS,EAAEK,MAAML,SAAS,CAACM,SAAS;IACxGD,MAAMJ,KAAK,CAACK,SAAS,GAAGV,KAAKE,iBAAiBG,KAAK,EAAEJ,OAAOI,KAAK,EAAEI,MAAMJ,KAAK,CAACK,SAAS;IACxF,IAAID,MAAMH,KAAK,EAAE;QACfG,MAAMH,KAAK,CAACI,SAAS,GAAGV,KAAKE,iBAAiBI,KAAK,EAAEL,OAAOK,KAAK,EAAEG,MAAMH,KAAK,CAACI,SAAS;IAC1F;IACA,OAAOD;AACT,EAAE"}
@@ -0,0 +1,289 @@
1
+ /* @griffel-buckets reset: .root, .indicator, .input */
2
+ .root:focus {
3
+ outline-style: none;
4
+ }
5
+
6
+ .root:focus-visible {
7
+ outline-style: none;
8
+ }
9
+
10
+ .root[data-fui-focus-within]:focus-within::after {
11
+ content: '';
12
+ position: absolute;
13
+ pointer-events: none;
14
+ z-index: 1;
15
+ border: var(--strokeWidthThick) solid var(--colorStrokeFocus2);
16
+ border-radius: var(--borderRadiusMedium);
17
+ top: calc(var(--strokeWidthThick) * -1);
18
+ inset-inline-end: calc(var(--strokeWidthThick) * -1);
19
+ bottom: calc(var(--strokeWidthThick) * -1);
20
+ inset-inline-start: calc(var(--strokeWidthThick) * -1);
21
+ }
22
+
23
+ .root[data-fui-focus-within]:focus-within {
24
+ border-top-color: transparent;
25
+ border-inline-end-color: transparent;
26
+ border-bottom-color: transparent;
27
+ border-inline-start-color: transparent;
28
+ }
29
+
30
+ .root {
31
+ align-items: flex-start;
32
+ box-sizing: border-box;
33
+ display: inline-flex;
34
+ position: relative;
35
+ }
36
+
37
+ .above {
38
+ flex-direction: column;
39
+ }
40
+
41
+ .indicator > * {
42
+ transition-duration: var(--durationNormal);
43
+ transition-timing-function: var(--curveEasyEase);
44
+ transition-property: transform;
45
+ }
46
+
47
+ .indicator {
48
+ border-radius: var(--borderRadiusCircular);
49
+ border: var(--strokeWidthThin) solid;
50
+ line-height: 0;
51
+ box-sizing: border-box;
52
+ fill: currentColor;
53
+ flex-shrink: 0;
54
+ font-size: calc(var(--spacingHorizontalXS) * 4.5);
55
+ height: var(--spacingHorizontalXL);
56
+ margin: var(--spacingVerticalS) var(--spacingHorizontalS);
57
+ pointer-events: none;
58
+ transition-duration: var(--durationNormal);
59
+ transition-timing-function: var(--curveEasyEase);
60
+ transition-property: background, border, color;
61
+ width: calc(var(--spacingHorizontalXS) * 10);
62
+ }
63
+
64
+ :where(.withLabel.above) > .indicator {
65
+ margin-top: 0;
66
+ }
67
+
68
+ :where(.small) > .indicator {
69
+ font-size: var(--fontSizeBase300);
70
+ height: var(--spacingHorizontalL);
71
+ width: var(--spacingHorizontalXXXL);
72
+ }
73
+
74
+ .input:checked ~ :global(.fui-Switch__indicator) > * {
75
+ transform: translateX(var(--spacingHorizontalXL));
76
+ }
77
+
78
+ .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
79
+ transform: translateX(calc(var(--spacingHorizontalXL) * -1));
80
+ }
81
+
82
+ .input:disabled ~ :global(.fui-Switch__indicator),
83
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
84
+ color: var(--colorNeutralForegroundDisabled);
85
+ }
86
+
87
+ .input:disabled ~ :global(.fui-Switch__label),
88
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__label) {
89
+ cursor: default;
90
+ color: var(--colorNeutralForegroundDisabled);
91
+ }
92
+
93
+ .input:disabled,
94
+ .input[aria-disabled='true'] {
95
+ cursor: default;
96
+ }
97
+
98
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
99
+ color: var(--colorNeutralStrokeAccessible);
100
+ border-color: var(--colorNeutralStrokeAccessible);
101
+ }
102
+
103
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__label) {
104
+ color: var(--colorNeutralForeground1);
105
+ }
106
+
107
+ .input:enabled:not(:checked):not([aria-disabled='true']):hover ~ :global(.fui-Switch__indicator) {
108
+ color: var(--colorNeutralStrokeAccessibleHover);
109
+ border-color: var(--colorNeutralStrokeAccessibleHover);
110
+ }
111
+
112
+ .input:enabled:not(:checked):not([aria-disabled='true']):hover:active ~ :global(.fui-Switch__indicator) {
113
+ color: var(--colorNeutralStrokeAccessiblePressed);
114
+ border-color: var(--colorNeutralStrokeAccessiblePressed);
115
+ }
116
+
117
+ .input:enabled:checked:not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
118
+ background-color: var(--colorCompoundBrandBackground);
119
+ color: var(--colorNeutralForegroundInverted);
120
+ border-color: var(--colorTransparentStroke);
121
+ }
122
+
123
+ .input:enabled:checked:not([aria-disabled='true']):hover ~ :global(.fui-Switch__indicator) {
124
+ background-color: var(--colorCompoundBrandBackgroundHover);
125
+ border-color: var(--colorTransparentStrokeInteractive);
126
+ }
127
+
128
+ .input:enabled:checked:not([aria-disabled='true']):hover:active ~ :global(.fui-Switch__indicator) {
129
+ background-color: var(--colorCompoundBrandBackgroundPressed);
130
+ border-color: var(--colorTransparentStrokeInteractive);
131
+ }
132
+
133
+ .input:disabled:not(:checked) ~ :global(.fui-Switch__indicator),
134
+ .input[aria-disabled='true']:not(:checked) ~ :global(.fui-Switch__indicator) {
135
+ border-color: var(--colorNeutralStrokeDisabled);
136
+ }
137
+
138
+ .input:disabled:checked ~ :global(.fui-Switch__indicator),
139
+ .input[aria-disabled='true']:checked ~ :global(.fui-Switch__indicator) {
140
+ background-color: var(--colorNeutralBackgroundDisabled);
141
+ border-color: var(--colorTransparentStrokeDisabled);
142
+ }
143
+
144
+ .input {
145
+ box-sizing: border-box;
146
+ cursor: pointer;
147
+ height: 100%;
148
+ margin: 0;
149
+ opacity: 0;
150
+ position: absolute;
151
+ width: calc(calc(var(--spacingHorizontalXS) * 10) + 2 * var(--spacingHorizontalS));
152
+ }
153
+
154
+ :where(.withLabel.before) > .input {
155
+ inset-inline-end: 0;
156
+ top: 0;
157
+ }
158
+
159
+ :where(.withLabel.after) > .input {
160
+ inset-inline-start: 0;
161
+ top: 0;
162
+ }
163
+
164
+ :where(.withLabel.above) > .input {
165
+ bottom: 0;
166
+ height: calc(var(--spacingHorizontalXL) + var(--spacingVerticalS));
167
+ width: 100%;
168
+ }
169
+
170
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > * {
171
+ transform: translateX(var(--spacingHorizontalL));
172
+ }
173
+
174
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
175
+ transform: translateX(calc(var(--spacingHorizontalL) * -1));
176
+ }
177
+
178
+ :where(.small) > .input {
179
+ width: calc(var(--spacingHorizontalXXXL) + 2 * var(--spacingHorizontalS));
180
+ }
181
+
182
+ .label {
183
+ cursor: pointer;
184
+ margin-bottom: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
185
+ margin-top: calc((var(--spacingHorizontalXL) - var(--lineHeightBase300)) / 2);
186
+ padding: var(--spacingVerticalS) var(--spacingHorizontalS);
187
+ }
188
+
189
+ :where(.small) > .label {
190
+ font-size: var(--fontSizeBase200);
191
+ line-height: var(--lineHeightBase200);
192
+ margin-bottom: calc((var(--spacingHorizontalL) - var(--lineHeightBase200)) / 2);
193
+ margin-top: calc((var(--spacingHorizontalL) - var(--lineHeightBase200)) / 2);
194
+ }
195
+
196
+ :where(.above) > .label {
197
+ padding-top: var(--spacingVerticalXS);
198
+ padding-bottom: var(--spacingVerticalXS);
199
+ width: 100%;
200
+ }
201
+
202
+ :where(.after) > .label {
203
+ padding-inline-start: var(--spacingHorizontalXS);
204
+ }
205
+
206
+ :where(.before) > .label {
207
+ padding-inline-end: var(--spacingHorizontalXS);
208
+ }
209
+
210
+ @media (forced-colors: active) {
211
+ .root[data-fui-focus-within]:focus-within::after {
212
+ border-top-color: Highlight;
213
+ border-inline-end-color: Highlight;
214
+ border-bottom-color: Highlight;
215
+ border-inline-start-color: Highlight;
216
+ }
217
+ }
218
+
219
+ @media screen and (prefers-reduced-motion: reduce) {
220
+ .indicator {
221
+ transition-duration: 0.01ms;
222
+ }
223
+ }
224
+
225
+ @media (forced-colors: active) {
226
+ .indicator > i {
227
+ forced-color-adjust: none;
228
+ }
229
+ }
230
+
231
+ @media (forced-colors: active) {
232
+ .indicator {
233
+ color: CanvasText;
234
+ }
235
+ }
236
+
237
+ @media screen and (prefers-reduced-motion: reduce) {
238
+ .indicator > * {
239
+ transition-duration: 0.01ms;
240
+ }
241
+ }
242
+
243
+ @media (forced-colors: active) {
244
+ .input:disabled ~ :global(.fui-Switch__indicator),
245
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
246
+ color: GrayText;
247
+ border-color: GrayText;
248
+ }
249
+ }
250
+
251
+ @media (forced-colors: active) {
252
+ .input:disabled ~ :global(.fui-Switch__label),
253
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__label) {
254
+ color: GrayText;
255
+ }
256
+ }
257
+
258
+ @media (forced-colors: active) {
259
+ .input:hover {
260
+ color: CanvasText;
261
+ }
262
+ }
263
+
264
+ @media (forced-colors: active) {
265
+ .input:hover:active {
266
+ color: CanvasText;
267
+ }
268
+ }
269
+
270
+ @media (forced-colors: active) {
271
+ .input:enabled:checked:not([aria-disabled='true']):hover ~ :global(.fui-Switch__indicator) {
272
+ background-color: Highlight;
273
+ color: Canvas;
274
+ }
275
+ }
276
+
277
+ @media (forced-colors: active) {
278
+ .input:enabled:checked:not([aria-disabled='true']):hover:active ~ :global(.fui-Switch__indicator) {
279
+ background-color: Highlight;
280
+ color: Canvas;
281
+ }
282
+ }
283
+
284
+ @media (forced-colors: active) {
285
+ .input:enabled:checked:not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
286
+ background-color: Highlight;
287
+ color: Canvas;
288
+ }
289
+ }
@@ -28,6 +28,10 @@ const useSwitch_unstable = (props, ref)=>{
28
28
  var _baseState_indicator, _children;
29
29
  const { size = 'medium', ...baseProps } = props;
30
30
  const baseState = useSwitchBase_unstable(baseProps, ref);
31
+ // Focus-within ref drives the styled focus outline; applied here rather than in the base hook
32
+ // so the base hook does not depend on react-tabster (keyborg).
33
+ // eslint-disable-next-line react-hooks/immutability
34
+ baseState.root.ref = (0, _reactutilities.useMergedRefs)(baseState.root.ref, (0, _reacttabster.useFocusWithin)());
31
35
  (_children = (_baseState_indicator = baseState.indicator).children) !== null && _children !== void 0 ? _children : _baseState_indicator.children = /*#__PURE__*/ _react.createElement(_reacticons.CircleFilled, null);
32
36
  return {
33
37
  ...baseState,
@@ -65,10 +69,7 @@ const useSwitchBase_unstable = (props, ref)=>{
65
69
  });
66
70
  const id = (0, _reactutilities.useId)('switch-', nativeProps.primary.id);
67
71
  const root = _reactutilities.slot.always(props.root, {
68
- defaultProps: {
69
- ref: (0, _reacttabster.useFocusWithin)(),
70
- ...nativeProps.root
71
- },
72
+ defaultProps: nativeProps.root,
72
73
  elementType: 'div'
73
74
  });
74
75
  const indicator = _reactutilities.slot.always(props.indicator, {
@@ -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, 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 baseState.indicator.children ??= <CircleFilled />;\n\n return {\n ...baseState,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...baseState.components,\n label: Label,\n },\n size,\n label: slot.optional(props.label, {\n defaultProps: { size: 'medium', ...baseState.label },\n elementType: Label,\n }),\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 {\n checked,\n defaultChecked,\n disabled,\n disabledFocusable = false,\n labelPosition = 'after',\n onChange,\n required,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange', 'disabledFocusable'],\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 },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n disabled: disabled && !disabledFocusable,\n ...(disabledFocusable && { 'aria-disabled': true }),\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n input.onClick = mergeCallbacks(input.onClick, ev => {\n if (disabledFocusable) {\n ev.preventDefault();\n }\n });\n input.onKeyDown = mergeCallbacks(input.onKeyDown, ev => {\n if (disabledFocusable && (ev.key === ' ' || ev.key === 'Enter')) {\n ev.preventDefault();\n }\n });\n const label = slot.optional(props.label, {\n defaultProps: { disabled: disabled || disabledFocusable, htmlFor: id, required },\n elementType: 'label',\n });\n return {\n disabledFocusable,\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","baseState","size","baseProps","useSwitchBase_unstable","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","disabledFocusable","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","root","always","input","role","type","ev","currentTarget","onClick","preventDefault","onKeyDown","key","htmlFor"],"mappings":"AAAA;;;;;;;;;;;;;eA+Cae;;QA5BAN;;;;;iEAjBU,QAAQ;4BACe,wBAAwB;4BACzC,wBAAwB;4BAC/B,wBAAwB;8BACf,0BAA0B;gCACc,4BAA4B;AAY5F,2BAA2B,CAACC,OAAoBC;QAKrDC,sBAAAA;IAJA,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAE1C,MAAME,YAAYG,uBAAuBD,WAAWH;KAEpDC,YAAAA,CAAAA,uBAAAA,UAAUI,SAAAA,AAAS,EAACC,QAAAA,AAAQ,MAAA,QAA5BL,cAAAA,KAAAA,IAAAA,YAAAA,qBAAoBK,QAAQ,GAAA,WAAA,GAAK,OAAA,aAAA,CAACf,wBAAAA,EAAAA;IAElC,OAAO;QACL,GAAGU,SAAS;QACZM,YAAY;YACV,4DAA4D;YAC5D,GAAGN,UAAUM,UAAU;YACvBC,OAAOhB,iBAAAA;QACT;QACAU;QACAM,OAAOX,oBAAAA,CAAKY,QAAQ,CAACV,MAAMS,KAAK,EAAE;YAChCE,cAAc;gBAAER,MAAM;gBAAU,GAAGD,UAAUO,KAAK;YAAC;YACnDG,aAAanB,iBAAAA;QACf;IACF;AACF,EAAE;AAQK,+BAA+B,CAACO,OAAwBC;IAC7D,+CAA+C;IAC/CD,YAAQT,yCAAAA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;QACnB;IACF;IACAN,MAAMO,SAAS,OAAGxC,8BAAAA,EAAeiC,MAAMO,SAAS,EAAEJ,CAAAA;QAChD,IAAId,qBAAsBc,CAAAA,GAAGK,GAAG,KAAK,OAAOL,GAAGK,GAAG,KAAK,OAAA,CAAM,EAAI;YAC/DL,GAAGG,cAAc;QACnB;IACF;IACA,MAAM1B,QAAQX,oBAAAA,CAAKY,QAAQ,CAACV,MAAMS,KAAK,EAAE;QACvCE,cAAc;YAAEM,UAAUA,YAAYC;YAAmBoB,SAASb;YAAIJ;QAAS;QAC/ET,aAAa;IACf;IACA,OAAO;QACLM;QACAC;QACAX,YAAY;YAAEmB,MAAM;YAAOrB,WAAW;YAAOuB,OAAO;YAASpB,OAAO;QAAQ;QAE5EkB;QACArB;QACAuB;QACApB;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, useMergedRefs, 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 // Focus-within ref drives the styled focus outline; applied here rather than in the base hook\n // so the base hook does not depend on react-tabster (keyborg).\n // eslint-disable-next-line react-hooks/immutability\n baseState.root.ref = useMergedRefs(baseState.root.ref, useFocusWithin<HTMLDivElement>());\n\n baseState.indicator.children ??= <CircleFilled />;\n\n return {\n ...baseState,\n components: {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ...baseState.components,\n label: Label,\n },\n size,\n label: slot.optional(props.label, {\n defaultProps: { size: 'medium', ...baseState.label },\n elementType: Label,\n }),\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 {\n checked,\n defaultChecked,\n disabled,\n disabledFocusable = false,\n labelPosition = 'after',\n onChange,\n required,\n } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange', 'disabledFocusable'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = slot.always(props.root, {\n defaultProps: nativeProps.root,\n elementType: 'div',\n });\n const indicator = slot.always(props.indicator, {\n defaultProps: { 'aria-hidden': true },\n elementType: 'div',\n });\n const input = slot.always(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n disabled: disabled && !disabledFocusable,\n ...(disabledFocusable && { 'aria-disabled': true }),\n },\n elementType: 'input',\n });\n input.onChange = mergeCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n input.onClick = mergeCallbacks(input.onClick, ev => {\n if (disabledFocusable) {\n ev.preventDefault();\n }\n });\n input.onKeyDown = mergeCallbacks(input.onKeyDown, ev => {\n if (disabledFocusable && (ev.key === ' ' || ev.key === 'Enter')) {\n ev.preventDefault();\n }\n });\n const label = slot.optional(props.label, {\n defaultProps: { disabled: disabled || disabledFocusable, htmlFor: id, required },\n elementType: 'label',\n });\n return {\n disabledFocusable,\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","useMergedRefs","slot","useSwitch_unstable","props","ref","baseState","size","baseProps","useSwitchBase_unstable","root","indicator","children","components","label","optional","defaultProps","elementType","supportsLabelFor","supportsRequired","checked","defaultChecked","disabled","disabledFocusable","labelPosition","onChange","required","nativeProps","primarySlotTagName","excludedPropNames","id","primary","always","input","role","type","ev","currentTarget","onClick","preventDefault","onKeyDown","key","htmlFor"],"mappings":"AAAA;;;;;;;;;;;;QAoDagB;;;QAjCAN;;;;;iEAjBU,QAAQ;4BACe,wBAAwB;4BACzC,wBAAwB;4BAC/B,wBAAwB;8BACf,0BAA0B;gCAC6B,4BAA4B;AAY3G,2BAA2B,CAACC,OAAoBC;QAUrDC,sBAAAA;IATA,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAE1C,MAAME,YAAYG,uBAAuBD,WAAWH;IAEpD,8FAA8F;IAC9F,+DAA+D;IAC/D,oDAAoD;IACpDC,UAAUI,IAAI,CAACL,GAAG,OAAGJ,6BAAAA,EAAcK,UAAUI,IAAI,CAACL,GAAG,MAAER,4BAAAA;KAEvDS,YAAAA,CAAAA,uBAAAA,UAAUK,SAAAA,AAAS,EAACC,QAAAA,AAAQ,MAAA,QAA5BN,cAAAA,KAAAA,IAAAA,YAAAA,qBAAoBM,QAAQ,GAAA,WAAA,GAAK,OAAA,aAAA,CAACjB,wBAAAA,EAAAA;IAElC,OAAO;QACL,GAAGW,SAAS;QACZO,YAAY;YACV,4DAA4D;YAC5D,GAAGP,UAAUO,UAAU;YACvBC,OAAOlB,iBAAAA;QACT;QACAW;QACAO,OAAOZ,oBAAAA,CAAKa,QAAQ,CAACX,MAAMU,KAAK,EAAE;YAChCE,cAAc;gBA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zGa,MAAMK,OAAO,OAAGvC,8BAAAA,EAAekC,MAAMK,OAAO,EAAEF,CAAAA;QAC5C,IAAIb,mBAAmB;YACrBa,GAAGG,cAAc;QACnB;IACF;IACAN,MAAMO,SAAS,OAAGzC,8BAAAA,EAAekC,MAAMO,SAAS,EAAEJ,CAAAA;QAChD,IAAIb,qBAAsBa,CAAAA,GAAGK,GAAG,KAAK,OAAOL,GAAGK,GAAG,KAAK,OAAA,CAAM,EAAI;YAC/DL,GAAGG,cAAc;QACnB;IACF;IACA,MAAMzB,QAAQZ,oBAAAA,CAAKa,QAAQ,CAACX,MAAMU,KAAK,EAAE;QACvCE,cAAc;YAAEM,UAAUA,YAAYC;YAAmBmB,SAASZ;YAAIJ;QAAS;QAC/ET,aAAa;IACf;IACA,OAAO;QACLM;QACAC;QACAX,YAAY;YAAEH,MAAM;YAAOC,WAAW;YAAOsB,OAAO;YAASnB,OAAO;QAAQ;QAE5EJ;QACAC;QACAsB;QACAnB;IACF;AACF,EAAE"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get switchClassName () {
13
+ return switchClassName;
14
+ },
15
+ get switchClassNames () {
16
+ return switchClassNames;
17
+ },
18
+ get useSwitchStyles_unstable () {
19
+ return useSwitchStyles_unstable;
20
+ }
21
+ });
22
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
23
+ const _clsx = require("clsx");
24
+ const _Switchmodulecss = /*#__PURE__*/ _interop_require_default._(require("./Switch.module.css"));
25
+ const switchClassNames = {
26
+ root: 'fui-Switch',
27
+ indicator: 'fui-Switch__indicator',
28
+ input: 'fui-Switch__input',
29
+ label: 'fui-Switch__label'
30
+ };
31
+ const switchClassName = switchClassNames.root;
32
+ const useSwitchStyles_unstable = (state)=>{
33
+ state.root.className = (0, _clsx.clsx)(switchClassNames.root, _Switchmodulecss.default.root, _Switchmodulecss.default[state.labelPosition], _Switchmodulecss.default[state.size], state.label && _Switchmodulecss.default.withLabel, state.root.className);
34
+ state.indicator.className = (0, _clsx.clsx)(switchClassNames.indicator, _Switchmodulecss.default.indicator, state.indicator.className);
35
+ state.input.className = (0, _clsx.clsx)(switchClassNames.input, _Switchmodulecss.default.input, state.input.className);
36
+ if (state.label) {
37
+ state.label.className = (0, _clsx.clsx)(switchClassNames.label, _Switchmodulecss.default.label, state.label.className);
38
+ }
39
+ return state;
40
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Switch/useSwitchStyles.styles.css.ts"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\nimport styles from './Switch.module.css';\n\nexport const switchClassNames: SlotClassNames<SwitchSlots> = {\n root: 'fui-Switch',\n indicator: 'fui-Switch__indicator',\n input: 'fui-Switch__input',\n label: 'fui-Switch__label',\n};\n\n/** @deprecated Use `switchClassNames.root` instead. */\nexport const switchClassName = switchClassNames.root;\n\nexport const useSwitchStyles_unstable = (state: SwitchState): SwitchState => {\n state.root.className = clsx(\n switchClassNames.root,\n styles.root,\n styles[state.labelPosition],\n styles[state.size],\n state.label && styles.withLabel,\n state.root.className,\n );\n state.indicator.className = clsx(switchClassNames.indicator, styles.indicator, state.indicator.className);\n state.input.className = clsx(switchClassNames.input, styles.input, state.input.className);\n if (state.label) {\n state.label.className = clsx(switchClassNames.label, styles.label, state.label.className);\n }\n return state;\n};\n"],"names":["clsx","styles","switchClassNames","root","indicator","input","label","switchClassName","useSwitchStyles_unstable","state","className","labelPosition","size","withLabel"],"mappings":";;;;;;;;;;;QAaaO;;;QARAL;;;QAUAM;;;;;sBAfQ,OAAO;0EAGT,sBAAsB;AAElC,yBAAsD;IAC3DL,MAAM;IACNC,WAAW;IACXC,OAAO;IACPC,OAAO;AACT,EAAE;AAGK,wBAAwBJ,iBAAiBC,IAAI,CAAC;AAE9C,iCAAiC,CAACM;IACvCA,MAAMN,IAAI,CAACO,SAAS,OAAGV,UAAAA,EACrBE,iBAAiBC,IAAI,EACrBF,wBAAAA,CAAOE,IAAI,EACXF,wBAAM,CAACQ,MAAME,aAAa,CAAC,EAC3BV,wBAAM,CAACQ,MAAMG,IAAI,CAAC,EAClBH,MAAMH,KAAK,IAAIL,wBAAAA,CAAOY,SAAS,EAC/BJ,MAAMN,IAAI,CAACO,SAAS;IAEtBD,MAAML,SAAS,CAACM,SAAS,OAAGV,UAAAA,EAAKE,iBAAiBE,SAAS,EAAEH,wBAAAA,CAAOG,SAAS,EAAEK,MAAML,SAAS,CAACM,SAAS;IACxGD,MAAMJ,KAAK,CAACK,SAAS,OAAGV,UAAAA,EAAKE,iBAAiBG,KAAK,EAAEJ,wBAAAA,CAAOI,KAAK,EAAEI,MAAMJ,KAAK,CAACK,SAAS;IACxF,IAAID,MAAMH,KAAK,EAAE;QACfG,MAAMH,KAAK,CAACI,SAAS,OAAGV,UAAAA,EAAKE,iBAAiBI,KAAK,EAAEL,wBAAAA,CAAOK,KAAK,EAAEG,MAAMH,KAAK,CAACI,SAAS;IAC1F;IACA,OAAOD;AACT,EAAE"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get switchClassName () {
13
+ return switchClassName;
14
+ },
15
+ get switchClassNames () {
16
+ return switchClassNames;
17
+ },
18
+ get useSwitchStyles_unstable () {
19
+ return useSwitchStyles_unstable;
20
+ }
21
+ });
22
+ const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
23
+ const _clsx = require("clsx");
24
+ const _Switchmodulecss = /*#__PURE__*/ _interop_require_default._(require("./Switch.module.css"));
25
+ const switchClassNames = {
26
+ root: 'fui-Switch',
27
+ indicator: 'fui-Switch__indicator',
28
+ input: 'fui-Switch__input',
29
+ label: 'fui-Switch__label'
30
+ };
31
+ const switchClassName = switchClassNames.root;
32
+ const useSwitchStyles_unstable = (state)=>{
33
+ state.root.className = (0, _clsx.clsx)(switchClassNames.root, _Switchmodulecss.default.root, _Switchmodulecss.default[state.labelPosition], _Switchmodulecss.default[state.size], state.label && _Switchmodulecss.default.withLabel, state.root.className);
34
+ state.indicator.className = (0, _clsx.clsx)(switchClassNames.indicator, _Switchmodulecss.default.indicator, state.indicator.className);
35
+ state.input.className = (0, _clsx.clsx)(switchClassNames.input, _Switchmodulecss.default.input, state.input.className);
36
+ if (state.label) {
37
+ state.label.className = (0, _clsx.clsx)(switchClassNames.label, _Switchmodulecss.default.label, state.label.className);
38
+ }
39
+ return state;
40
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Switch/useSwitchStyles.styles.css.ts"],"sourcesContent":["import { clsx } from 'clsx';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\nimport styles from './Switch.module.css';\n\nexport const switchClassNames: SlotClassNames<SwitchSlots> = {\n root: 'fui-Switch',\n indicator: 'fui-Switch__indicator',\n input: 'fui-Switch__input',\n label: 'fui-Switch__label',\n};\n\n/** @deprecated Use `switchClassNames.root` instead. */\nexport const switchClassName = switchClassNames.root;\n\nexport const useSwitchStyles_unstable = (state: SwitchState): SwitchState => {\n state.root.className = clsx(\n switchClassNames.root,\n styles.root,\n styles[state.labelPosition],\n styles[state.size],\n state.label && styles.withLabel,\n state.root.className,\n );\n state.indicator.className = clsx(switchClassNames.indicator, styles.indicator, state.indicator.className);\n state.input.className = clsx(switchClassNames.input, styles.input, state.input.className);\n if (state.label) {\n state.label.className = clsx(switchClassNames.label, styles.label, state.label.className);\n }\n return state;\n};\n"],"names":["clsx","styles","switchClassNames","root","indicator","input","label","switchClassName","useSwitchStyles_unstable","state","className","labelPosition","size","withLabel"],"mappings":";;;;;;;;;;;QAaaO;;;QARAL;;;QAUAM;;;;;sBAfQ,OAAO;0EAGT,sBAAsB;AAElC,yBAAsD;IAC3DL,MAAM;IACNC,WAAW;IACXC,OAAO;IACPC,OAAO;AACT,EAAE;AAGK,wBAAwBJ,iBAAiBC,IAAI,CAAC;AAE9C,iCAAiC,CAACM;IACvCA,MAAMN,IAAI,CAACO,SAAS,OAAGV,UAAAA,EACrBE,iBAAiBC,IAAI,EACrBF,wBAAAA,CAAOE,IAAI,EACXF,wBAAM,CAACQ,MAAME,aAAa,CAAC,EAC3BV,wBAAM,CAACQ,MAAMG,IAAI,CAAC,EAClBH,MAAMH,KAAK,IAAIL,wBAAAA,CAAOY,SAAS,EAC/BJ,MAAMN,IAAI,CAACO,SAAS;IAEtBD,MAAML,SAAS,CAACM,SAAS,OAAGV,UAAAA,EAAKE,iBAAiBE,SAAS,EAAEH,wBAAAA,CAAOG,SAAS,EAAEK,MAAML,SAAS,CAACM,SAAS;IACxGD,MAAMJ,KAAK,CAACK,SAAS,OAAGV,UAAAA,EAAKE,iBAAiBG,KAAK,EAAEJ,wBAAAA,CAAOI,KAAK,EAAEI,MAAMJ,KAAK,CAACK,SAAS;IACxF,IAAID,MAAMH,KAAK,EAAE;QACfG,MAAMH,KAAK,CAACI,SAAS,OAAGV,UAAAA,EAAKE,iBAAiBI,KAAK,EAAEL,wBAAAA,CAAOK,KAAK,EAAEG,MAAMH,KAAK,CAACI,SAAS;IAC1F;IACA,OAAOD;AACT,EAAE"}
package/package.json CHANGED
@@ -1,27 +1,30 @@
1
1
  {
2
2
  "name": "@fluentui/react-switch",
3
- "version": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
3
+ "version": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
4
4
  "description": "Fluent UI React Switch component.",
5
5
  "main": "lib-commonjs/index.cjs",
6
6
  "module": "lib/index.js",
7
7
  "typings": "./dist/index.d.ts",
8
- "sideEffects": false,
8
+ "sideEffects": [
9
+ "**/*.css"
10
+ ],
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "https://github.com/microsoft/fluentui"
12
14
  },
13
15
  "license": "MIT",
14
16
  "dependencies": {
15
- "@fluentui/react-field": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
17
+ "@fluentui/react-field": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
16
18
  "@fluentui/react-icons": "^2.0.245",
17
- "@fluentui/react-jsx-runtime": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
18
- "@fluentui/react-label": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
19
- "@fluentui/react-shared-contexts": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
20
- "@fluentui/react-tabster": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
21
- "@fluentui/react-theme": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
22
- "@fluentui/react-utilities": "9.75.1-experimental.positioning-engine.20261103-19efe125d1.0",
19
+ "@fluentui/react-jsx-runtime": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
20
+ "@fluentui/react-label": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
21
+ "@fluentui/react-shared-contexts": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
22
+ "@fluentui/react-tabster": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
23
+ "@fluentui/react-theme": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
24
+ "@fluentui/react-utilities": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
23
25
  "@griffel/react": "^1.5.32",
24
- "@swc/helpers": "^0.5.1"
26
+ "@swc/helpers": "^0.5.1",
27
+ "clsx": "^2.1.1"
25
28
  },
26
29
  "peerDependencies": {
27
30
  "@types/react": ">=16.14.0 <20.0.0",