@fluentui/react-switch 9.75.1-experimental.css-modules.20261103-d6c85ee2a9.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:03:01 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.css-modules.20261103-d6c85ee2a9.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-switch_v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.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:03:01 GMT
9
+ Fri, 13 Nov 2026 20:37:00 GMT
10
10
 
11
11
  ### Changes
12
12
 
13
- - Release 9.75.1-experimental.css-modules.20261103-d6c85ee2a9 ([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.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
- - Bump @fluentui/react-jsx-runtime to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
- - Bump @fluentui/react-label to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
- - Bump @fluentui/react-shared-contexts to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
- - Bump @fluentui/react-tabster to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
19
- - Bump @fluentui/react-theme to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
20
- - Bump @fluentui/react-utilities to v9.75.1-experimental.css-modules.20261103-d6c85ee2a9.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,16 +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
39
 
40
40
  ## Opt-in CSS Modules styles
41
41
 
42
42
  CSS Modules alternatives are available for `Switch`. The default exports and component imports continue to use Griffel.
43
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. All component rules are in `@layer fluent` and use the theme custom properties supplied by `FluentProvider`.
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
45
 
46
- For composed labels, also select the CSS Modules alternative for `@fluentui/react-label`. Mixing its default unlayered Griffel styles with these layered alternatives can override label typography.
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.
@@ -1,290 +1,289 @@
1
- @layer fluent {
2
- .root:focus {
3
- outline-style: none;
4
- }
1
+ /* @griffel-buckets reset: .root, .indicator, .input */
2
+ .root:focus {
3
+ outline-style: none;
4
+ }
5
5
 
6
- .root:focus-visible {
7
- outline-style: none;
8
- }
6
+ .root:focus-visible {
7
+ outline-style: none;
8
+ }
9
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
- }
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
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
- }
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
29
 
30
- .root {
31
- align-items: flex-start;
32
- box-sizing: border-box;
33
- display: inline-flex;
34
- position: relative;
35
- }
30
+ .root {
31
+ align-items: flex-start;
32
+ box-sizing: border-box;
33
+ display: inline-flex;
34
+ position: relative;
35
+ }
36
36
 
37
- .above {
38
- flex-direction: column;
39
- }
37
+ .above {
38
+ flex-direction: column;
39
+ }
40
40
 
41
- .indicator > * {
42
- transition-duration: var(--durationNormal);
43
- transition-timing-function: var(--curveEasyEase);
44
- transition-property: transform;
45
- }
41
+ .indicator > * {
42
+ transition-duration: var(--durationNormal);
43
+ transition-timing-function: var(--curveEasyEase);
44
+ transition-property: transform;
45
+ }
46
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
- }
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
63
 
64
- :where(.withLabel.above) > .indicator {
65
- margin-top: 0;
66
- }
64
+ :where(.withLabel.above) > .indicator {
65
+ margin-top: 0;
66
+ }
67
67
 
68
- :where(.small) > .indicator {
69
- font-size: var(--fontSizeBase300);
70
- height: var(--spacingHorizontalL);
71
- width: var(--spacingHorizontalXXXL);
72
- }
68
+ :where(.small) > .indicator {
69
+ font-size: var(--fontSizeBase300);
70
+ height: var(--spacingHorizontalL);
71
+ width: var(--spacingHorizontalXXXL);
72
+ }
73
73
 
74
- .input:checked ~ :global(.fui-Switch__indicator) > * {
75
- transform: translateX(var(--spacingHorizontalXL));
76
- }
74
+ .input:checked ~ :global(.fui-Switch__indicator) > * {
75
+ transform: translateX(var(--spacingHorizontalXL));
76
+ }
77
77
 
78
- .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
79
- transform: translateX(calc(var(--spacingHorizontalXL) * -1));
80
- }
78
+ .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
79
+ transform: translateX(calc(var(--spacingHorizontalXL) * -1));
80
+ }
81
81
 
82
- .input:disabled ~ :global(.fui-Switch__indicator),
83
- .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
84
- color: var(--colorNeutralForegroundDisabled);
85
- }
82
+ .input:disabled ~ :global(.fui-Switch__indicator),
83
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
84
+ color: var(--colorNeutralForegroundDisabled);
85
+ }
86
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
- }
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
92
 
93
- .input:disabled,
94
- .input[aria-disabled='true'] {
95
- cursor: default;
96
- }
93
+ .input:disabled,
94
+ .input[aria-disabled='true'] {
95
+ cursor: default;
96
+ }
97
97
 
98
- .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
99
- color: var(--colorNeutralStrokeAccessible);
100
- border-color: var(--colorNeutralStrokeAccessible);
101
- }
98
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
99
+ color: var(--colorNeutralStrokeAccessible);
100
+ border-color: var(--colorNeutralStrokeAccessible);
101
+ }
102
102
 
103
- .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__label) {
104
- color: var(--colorNeutralForeground1);
105
- }
103
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__label) {
104
+ color: var(--colorNeutralForeground1);
105
+ }
106
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
153
 
154
- :where(.withLabel.before) > .input {
155
- inset-inline-end: 0;
156
- top: 0;
157
- }
154
+ :where(.withLabel.before) > .input {
155
+ inset-inline-end: 0;
156
+ top: 0;
157
+ }
158
158
 
159
- :where(.withLabel.after) > .input {
160
- inset-inline-start: 0;
161
- top: 0;
162
- }
159
+ :where(.withLabel.after) > .input {
160
+ inset-inline-start: 0;
161
+ top: 0;
162
+ }
163
163
 
164
- :where(.withLabel.above) > .input {
165
- bottom: 0;
166
- height: calc(var(--spacingHorizontalXL) + var(--spacingVerticalS));
167
- width: 100%;
168
- }
164
+ :where(.withLabel.above) > .input {
165
+ bottom: 0;
166
+ height: calc(var(--spacingHorizontalXL) + var(--spacingVerticalS));
167
+ width: 100%;
168
+ }
169
169
 
170
- :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > * {
171
- transform: translateX(var(--spacingHorizontalL));
172
- }
170
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > * {
171
+ transform: translateX(var(--spacingHorizontalL));
172
+ }
173
173
 
174
- :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
175
- transform: translateX(calc(var(--spacingHorizontalL) * -1));
176
- }
174
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
175
+ transform: translateX(calc(var(--spacingHorizontalL) * -1));
176
+ }
177
177
 
178
- :where(.small) > .input {
179
- width: calc(var(--spacingHorizontalXXXL) + 2 * var(--spacingHorizontalS));
180
- }
178
+ :where(.small) > .input {
179
+ width: calc(var(--spacingHorizontalXXXL) + 2 * var(--spacingHorizontalS));
180
+ }
181
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
- }
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
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
- }
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
195
 
196
- :where(.above) > .label {
197
- padding-top: var(--spacingVerticalXS);
198
- padding-bottom: var(--spacingVerticalXS);
199
- width: 100%;
200
- }
196
+ :where(.above) > .label {
197
+ padding-top: var(--spacingVerticalXS);
198
+ padding-bottom: var(--spacingVerticalXS);
199
+ width: 100%;
200
+ }
201
201
 
202
- :where(.after) > .label {
203
- padding-inline-start: var(--spacingHorizontalXS);
204
- }
202
+ :where(.after) > .label {
203
+ padding-inline-start: var(--spacingHorizontalXS);
204
+ }
205
205
 
206
- :where(.before) > .label {
207
- padding-inline-end: var(--spacingHorizontalXS);
208
- }
206
+ :where(.before) > .label {
207
+ padding-inline-end: var(--spacingHorizontalXS);
208
+ }
209
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
- }
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;
217
216
  }
217
+ }
218
218
 
219
- @media screen and (prefers-reduced-motion: reduce) {
220
- .indicator {
221
- transition-duration: 0.01ms;
222
- }
219
+ @media screen and (prefers-reduced-motion: reduce) {
220
+ .indicator {
221
+ transition-duration: 0.01ms;
223
222
  }
223
+ }
224
224
 
225
- @media (forced-colors: active) {
226
- .indicator > i {
227
- forced-color-adjust: none;
228
- }
225
+ @media (forced-colors: active) {
226
+ .indicator > i {
227
+ forced-color-adjust: none;
229
228
  }
229
+ }
230
230
 
231
- @media (forced-colors: active) {
232
- .indicator {
233
- color: CanvasText;
234
- }
231
+ @media (forced-colors: active) {
232
+ .indicator {
233
+ color: CanvasText;
235
234
  }
235
+ }
236
236
 
237
- @media screen and (prefers-reduced-motion: reduce) {
238
- .indicator > * {
239
- transition-duration: 0.01ms;
240
- }
237
+ @media screen and (prefers-reduced-motion: reduce) {
238
+ .indicator > * {
239
+ transition-duration: 0.01ms;
241
240
  }
241
+ }
242
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
- }
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;
249
248
  }
249
+ }
250
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
- }
251
+ @media (forced-colors: active) {
252
+ .input:disabled ~ :global(.fui-Switch__label),
253
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__label) {
254
+ color: GrayText;
256
255
  }
256
+ }
257
257
 
258
- @media (forced-colors: active) {
259
- .input:hover {
260
- color: CanvasText;
261
- }
258
+ @media (forced-colors: active) {
259
+ .input:hover {
260
+ color: CanvasText;
262
261
  }
262
+ }
263
263
 
264
- @media (forced-colors: active) {
265
- .input:hover:active {
266
- color: CanvasText;
267
- }
264
+ @media (forced-colors: active) {
265
+ .input:hover:active {
266
+ color: CanvasText;
268
267
  }
268
+ }
269
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
- }
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;
275
274
  }
275
+ }
276
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
- }
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;
282
281
  }
282
+ }
283
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
- }
284
+ @media (forced-colors: active) {
285
+ .input:enabled:checked:not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
286
+ background-color: Highlight;
287
+ color: Canvas;
289
288
  }
290
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,GACD,OAAO,MAAMC,qBAAqB,CAACC,OAAoBC;QAKrDC,sBAAAA;IAJA,MAAM,EAAEC,OAAO,QAAQ,EAAE,GAAGC,WAAW,GAAGJ;IAE1C,MAAME,YAAYG,uBAAuBD,WAAWH;KAEpDC,YAAAA,CAAAA,uBAAAA,UAAUI,SAAS,EAACC,QAAQ,cAA5BL,uBAAAA,YAAAA,qBAAoBK,QAAQ,iBAAK,oBAACf;IAElC,OAAO;QACL,GAAGU,SAAS;QACZM,YAAY;YACV,4DAA4D;YAC5D,GAAGN,UAAUM,UAAU;YACvBC,OAAOhB;QACT;QACAU;QACAM,OAAOX,KAAKY,QAAQ,CAACV,MAAMS,KAAK,EAAE;YAChCE,cAAc;gBAAER,MAAM;gBAAU,GAAGD,UAAUO,KAAK;YAAC;YACnDG,aAAanB;QACf;IACF;AACF,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAMY,yBAAyB,CAACL,OAAwBC;IAC7D,+CAA+C;IAC/CD,QAAQT,8BAA8BS,OAAO;QAAEa,kBAAkB;QAAMC,kBAAkB;IAAK;IAE9F,MAAM,EACJC,OAAO,EACPC,cA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nB;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,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,GAAGJ,cAAcK,UAAUI,IAAI,CAACL,GAAG,EAAER;KAEvDS,YAAAA,CAAAA,uBAAAA,UAAUK,SAAS,EAACC,QAAQ,cAA5BN,uBAAAA,YAAAA,qBAAoBM,QAAQ,iBAAK,oBAACjB;IAElC,OAAO;QACL,GAAGW,SAAS;QACZO,YAAY;YACV,4DAA4D;YAC5D,GAAGP,UAAUO,UAAU;YACvBC,OAAOlB;QACT;QACAW;QACAO,OAAOZ,KAAKa,QAAQ,CAACX,MAAMU,KAAK,EAAE;YAChCE,cAAc;gBAAET,MAAM;gBAAU,GAAGD,UAAUQ,KAAK;YAAC;YACnDG,aAAarB;QACf;IACF;AACF,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAMa,yBAAyB,CAACL,OAAwBC;IAC7D,+CAA+C;IAC/C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AOL,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"}
@@ -1,290 +1,289 @@
1
- @layer fluent {
2
- .root:focus {
3
- outline-style: none;
4
- }
1
+ /* @griffel-buckets reset: .root, .indicator, .input */
2
+ .root:focus {
3
+ outline-style: none;
4
+ }
5
5
 
6
- .root:focus-visible {
7
- outline-style: none;
8
- }
6
+ .root:focus-visible {
7
+ outline-style: none;
8
+ }
9
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
- }
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
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
- }
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
29
 
30
- .root {
31
- align-items: flex-start;
32
- box-sizing: border-box;
33
- display: inline-flex;
34
- position: relative;
35
- }
30
+ .root {
31
+ align-items: flex-start;
32
+ box-sizing: border-box;
33
+ display: inline-flex;
34
+ position: relative;
35
+ }
36
36
 
37
- .above {
38
- flex-direction: column;
39
- }
37
+ .above {
38
+ flex-direction: column;
39
+ }
40
40
 
41
- .indicator > * {
42
- transition-duration: var(--durationNormal);
43
- transition-timing-function: var(--curveEasyEase);
44
- transition-property: transform;
45
- }
41
+ .indicator > * {
42
+ transition-duration: var(--durationNormal);
43
+ transition-timing-function: var(--curveEasyEase);
44
+ transition-property: transform;
45
+ }
46
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
- }
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
63
 
64
- :where(.withLabel.above) > .indicator {
65
- margin-top: 0;
66
- }
64
+ :where(.withLabel.above) > .indicator {
65
+ margin-top: 0;
66
+ }
67
67
 
68
- :where(.small) > .indicator {
69
- font-size: var(--fontSizeBase300);
70
- height: var(--spacingHorizontalL);
71
- width: var(--spacingHorizontalXXXL);
72
- }
68
+ :where(.small) > .indicator {
69
+ font-size: var(--fontSizeBase300);
70
+ height: var(--spacingHorizontalL);
71
+ width: var(--spacingHorizontalXXXL);
72
+ }
73
73
 
74
- .input:checked ~ :global(.fui-Switch__indicator) > * {
75
- transform: translateX(var(--spacingHorizontalXL));
76
- }
74
+ .input:checked ~ :global(.fui-Switch__indicator) > * {
75
+ transform: translateX(var(--spacingHorizontalXL));
76
+ }
77
77
 
78
- .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
79
- transform: translateX(calc(var(--spacingHorizontalXL) * -1));
80
- }
78
+ .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
79
+ transform: translateX(calc(var(--spacingHorizontalXL) * -1));
80
+ }
81
81
 
82
- .input:disabled ~ :global(.fui-Switch__indicator),
83
- .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
84
- color: var(--colorNeutralForegroundDisabled);
85
- }
82
+ .input:disabled ~ :global(.fui-Switch__indicator),
83
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__indicator) {
84
+ color: var(--colorNeutralForegroundDisabled);
85
+ }
86
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
- }
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
92
 
93
- .input:disabled,
94
- .input[aria-disabled='true'] {
95
- cursor: default;
96
- }
93
+ .input:disabled,
94
+ .input[aria-disabled='true'] {
95
+ cursor: default;
96
+ }
97
97
 
98
- .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
99
- color: var(--colorNeutralStrokeAccessible);
100
- border-color: var(--colorNeutralStrokeAccessible);
101
- }
98
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
99
+ color: var(--colorNeutralStrokeAccessible);
100
+ border-color: var(--colorNeutralStrokeAccessible);
101
+ }
102
102
 
103
- .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__label) {
104
- color: var(--colorNeutralForeground1);
105
- }
103
+ .input:enabled:not(:checked):not([aria-disabled='true']) ~ :global(.fui-Switch__label) {
104
+ color: var(--colorNeutralForeground1);
105
+ }
106
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
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
- }
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
153
 
154
- :where(.withLabel.before) > .input {
155
- inset-inline-end: 0;
156
- top: 0;
157
- }
154
+ :where(.withLabel.before) > .input {
155
+ inset-inline-end: 0;
156
+ top: 0;
157
+ }
158
158
 
159
- :where(.withLabel.after) > .input {
160
- inset-inline-start: 0;
161
- top: 0;
162
- }
159
+ :where(.withLabel.after) > .input {
160
+ inset-inline-start: 0;
161
+ top: 0;
162
+ }
163
163
 
164
- :where(.withLabel.above) > .input {
165
- bottom: 0;
166
- height: calc(var(--spacingHorizontalXL) + var(--spacingVerticalS));
167
- width: 100%;
168
- }
164
+ :where(.withLabel.above) > .input {
165
+ bottom: 0;
166
+ height: calc(var(--spacingHorizontalXL) + var(--spacingVerticalS));
167
+ width: 100%;
168
+ }
169
169
 
170
- :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > * {
171
- transform: translateX(var(--spacingHorizontalL));
172
- }
170
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > * {
171
+ transform: translateX(var(--spacingHorizontalL));
172
+ }
173
173
 
174
- :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
175
- transform: translateX(calc(var(--spacingHorizontalL) * -1));
176
- }
174
+ :where(.small) > .input:checked ~ :global(.fui-Switch__indicator) > *:where(:dir(rtl)) {
175
+ transform: translateX(calc(var(--spacingHorizontalL) * -1));
176
+ }
177
177
 
178
- :where(.small) > .input {
179
- width: calc(var(--spacingHorizontalXXXL) + 2 * var(--spacingHorizontalS));
180
- }
178
+ :where(.small) > .input {
179
+ width: calc(var(--spacingHorizontalXXXL) + 2 * var(--spacingHorizontalS));
180
+ }
181
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
- }
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
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
- }
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
195
 
196
- :where(.above) > .label {
197
- padding-top: var(--spacingVerticalXS);
198
- padding-bottom: var(--spacingVerticalXS);
199
- width: 100%;
200
- }
196
+ :where(.above) > .label {
197
+ padding-top: var(--spacingVerticalXS);
198
+ padding-bottom: var(--spacingVerticalXS);
199
+ width: 100%;
200
+ }
201
201
 
202
- :where(.after) > .label {
203
- padding-inline-start: var(--spacingHorizontalXS);
204
- }
202
+ :where(.after) > .label {
203
+ padding-inline-start: var(--spacingHorizontalXS);
204
+ }
205
205
 
206
- :where(.before) > .label {
207
- padding-inline-end: var(--spacingHorizontalXS);
208
- }
206
+ :where(.before) > .label {
207
+ padding-inline-end: var(--spacingHorizontalXS);
208
+ }
209
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
- }
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;
217
216
  }
217
+ }
218
218
 
219
- @media screen and (prefers-reduced-motion: reduce) {
220
- .indicator {
221
- transition-duration: 0.01ms;
222
- }
219
+ @media screen and (prefers-reduced-motion: reduce) {
220
+ .indicator {
221
+ transition-duration: 0.01ms;
223
222
  }
223
+ }
224
224
 
225
- @media (forced-colors: active) {
226
- .indicator > i {
227
- forced-color-adjust: none;
228
- }
225
+ @media (forced-colors: active) {
226
+ .indicator > i {
227
+ forced-color-adjust: none;
229
228
  }
229
+ }
230
230
 
231
- @media (forced-colors: active) {
232
- .indicator {
233
- color: CanvasText;
234
- }
231
+ @media (forced-colors: active) {
232
+ .indicator {
233
+ color: CanvasText;
235
234
  }
235
+ }
236
236
 
237
- @media screen and (prefers-reduced-motion: reduce) {
238
- .indicator > * {
239
- transition-duration: 0.01ms;
240
- }
237
+ @media screen and (prefers-reduced-motion: reduce) {
238
+ .indicator > * {
239
+ transition-duration: 0.01ms;
241
240
  }
241
+ }
242
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
- }
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;
249
248
  }
249
+ }
250
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
- }
251
+ @media (forced-colors: active) {
252
+ .input:disabled ~ :global(.fui-Switch__label),
253
+ .input[aria-disabled='true'] ~ :global(.fui-Switch__label) {
254
+ color: GrayText;
256
255
  }
256
+ }
257
257
 
258
- @media (forced-colors: active) {
259
- .input:hover {
260
- color: CanvasText;
261
- }
258
+ @media (forced-colors: active) {
259
+ .input:hover {
260
+ color: CanvasText;
262
261
  }
262
+ }
263
263
 
264
- @media (forced-colors: active) {
265
- .input:hover:active {
266
- color: CanvasText;
267
- }
264
+ @media (forced-colors: active) {
265
+ .input:hover:active {
266
+ color: CanvasText;
268
267
  }
268
+ }
269
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
- }
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;
275
274
  }
275
+ }
276
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
- }
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;
282
281
  }
282
+ }
283
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
- }
284
+ @media (forced-colors: active) {
285
+ .input:enabled:checked:not([aria-disabled='true']) ~ :global(.fui-Switch__indicator) {
286
+ background-color: Highlight;
287
+ color: Canvas;
289
288
  }
290
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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AAGC,aAAa,CAAClB,OAAO;QAAC;IACzGc,MAAMK,OAAO,OAAGtC,8BAAAA,EAAeiC,MAAMK,OAAO,EAAEF,CAAAA;QAC5C,IAAId,mBAAmB;YACrBc,GAAGG,cAAc;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,4DAA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R,QAAQ,EAAEW,CAAAA,KAAMX,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,KAAAA,IAAAA,SAAWW,IAAI;YAAEhB,SAASgB,GAAGC,aAAa,CAACjB,OAAO;QAAC;IACzGa,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-switch",
3
- "version": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.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",
@@ -14,14 +14,14 @@
14
14
  },
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@fluentui/react-field": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
17
+ "@fluentui/react-field": "9.75.2-experimental.css-modules.20261113-ba13c87438.0",
18
18
  "@fluentui/react-icons": "^2.0.245",
19
- "@fluentui/react-jsx-runtime": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
20
- "@fluentui/react-label": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
21
- "@fluentui/react-shared-contexts": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
22
- "@fluentui/react-tabster": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
23
- "@fluentui/react-theme": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.0",
24
- "@fluentui/react-utilities": "9.75.1-experimental.css-modules.20261103-d6c85ee2a9.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",
25
25
  "@griffel/react": "^1.5.32",
26
26
  "@swc/helpers": "^0.5.1",
27
27
  "clsx": "^2.1.1"