@fluentui/react-switch 9.74.7-experimental.cli-api.20261006-ccaa611d58.0 → 9.75.0-experimental.css-modules.20261031-810ab07afb.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 +38 -12
- package/README.md +8 -0
- package/lib/components/Switch/Switch.js.map +1 -1
- package/lib/components/Switch/Switch.module.css +290 -0
- package/lib/components/Switch/Switch.types.js.map +1 -1
- package/lib/components/Switch/index.js.map +1 -1
- package/lib/components/Switch/renderSwitch.js +2 -2
- package/lib/components/Switch/renderSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitch.js +1 -2
- package/lib/components/Switch/useSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitchStyles.styles.css.js +18 -0
- package/lib/components/Switch/useSwitchStyles.styles.css.js.map +1 -0
- package/lib/components/Switch/useSwitchStyles.styles.raw.css.js +18 -0
- package/lib/components/Switch/useSwitchStyles.styles.raw.css.js.map +1 -0
- package/lib/components/Switch/useSwitchStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/Switch.cjs +8 -8
- package/lib-commonjs/components/Switch/Switch.cjs.map +1 -1
- package/lib-commonjs/components/Switch/Switch.module.css +290 -0
- package/lib-commonjs/components/Switch/Switch.types.cjs.map +1 -1
- package/lib-commonjs/components/Switch/index.cjs +8 -8
- package/lib-commonjs/components/Switch/index.cjs.map +1 -1
- package/lib-commonjs/components/Switch/renderSwitch.cjs.map +1 -1
- package/lib-commonjs/components/Switch/useSwitch.cjs +4 -5
- package/lib-commonjs/components/Switch/useSwitch.cjs.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.cjs +4 -4
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.css.cjs +40 -0
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.css.cjs.map +1 -0
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.raw.cjs +4 -4
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.raw.css.cjs +40 -0
- package/lib-commonjs/components/Switch/useSwitchStyles.styles.raw.css.cjs.map +1 -0
- package/lib-commonjs/index.cjs +8 -8
- package/package.json +15 -15
- package/dist/metadata/api/api-root.json +0 -1
- package/dist/metadata/index.json +0 -1
package/lib-commonjs/Switch.cjs
CHANGED
|
@@ -5,29 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
Switch
|
|
12
|
+
get Switch () {
|
|
13
13
|
return _index.Switch;
|
|
14
14
|
},
|
|
15
|
-
renderSwitch_unstable
|
|
15
|
+
get renderSwitch_unstable () {
|
|
16
16
|
return _index.renderSwitch_unstable;
|
|
17
17
|
},
|
|
18
|
-
switchClassName
|
|
18
|
+
get switchClassName () {
|
|
19
19
|
return _index.switchClassName;
|
|
20
20
|
},
|
|
21
|
-
switchClassNames
|
|
21
|
+
get switchClassNames () {
|
|
22
22
|
return _index.switchClassNames;
|
|
23
23
|
},
|
|
24
|
-
useSwitchBase_unstable
|
|
24
|
+
get useSwitchBase_unstable () {
|
|
25
25
|
return _index.useSwitchBase_unstable;
|
|
26
26
|
},
|
|
27
|
-
useSwitchStyles_unstable
|
|
27
|
+
get useSwitchStyles_unstable () {
|
|
28
28
|
return _index.useSwitchStyles_unstable;
|
|
29
29
|
},
|
|
30
|
-
useSwitch_unstable
|
|
30
|
+
get useSwitch_unstable () {
|
|
31
31
|
return _index.useSwitch_unstable;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useSwitch_unstable } from './useSwitch';\nimport { renderSwitch_unstable } from './renderSwitch';\nimport { useSwitchStyles_unstable } from './useSwitchStyles.styles';\nimport type { SwitchProps } from './Switch.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Switches enable users to trigger an option on or off through pressing the component.\n */\nexport const Switch: ForwardRefComponent<SwitchProps> = React.forwardRef((props, ref) => {\n const state = useSwitch_unstable(props, ref);\n\n useSwitchStyles_unstable(state);\n\n useCustomStyleHook_unstable('useSwitchStyles_unstable')(state);\n\n return renderSwitch_unstable(state);\n});\n\nSwitch.displayName = 'Switch';\n"],"names":["React","useSwitch_unstable","renderSwitch_unstable","useSwitchStyles_unstable","useCustomStyleHook_unstable","Switch","forwardRef","props","ref","state","displayName"],"mappings":"AAAA;;;;;;;;;;;;iEAEuB,QAAQ;2BACI,iBAAc;8BACX,oBAAiB;uCACd,8BAA2B;qCAGxB,kCAAkC;AAKvE,MAAMK,SAAAA,WAAAA,GAA2CL,OAAMM,UAAU,CAAC,CAACC,OAAOC;IAC/E,MAAMC,YAAQR,6BAAAA,EAAmBM,OAAOC;QAExCL,+CAAAA,EAAyBM;QAEzBL,gDAAAA,EAA4B,4BAA4BK;IAExD,WAAOP,mCAAAA,EAAsBO;AAC/B,GAAG;AAEHJ,OAAOK,WAAW,GAAG"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
@layer fluentui {
|
|
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
|
+
}
|
|
290
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/Switch.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { Label } from '@fluentui/react-label';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type SwitchSlots = {\n /**\n * The root element of the Switch.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.\n * All other native props will be applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The track and the thumb sliding over it indicating the on and off status of the Switch.\n */\n indicator: NonNullable<Slot<'div'>>;\n\n /**\n * Hidden input that handles the Switch's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this\n * slot, except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The Switch's label.\n */\n label?: Slot<typeof Label>;\n};\n\nexport type SwitchOnChangeData = {\n checked: boolean;\n};\n\n/**\n * Switch Props\n */\nexport type SwitchProps = Omit<\n ComponentProps<Partial<SwitchSlots>, 'input'>,\n 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> & {\n /**\n * Defines the controlled checked state of the Switch.\n * If passed, Switch ignores the `defaultChecked` property.\n * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the\n * correct value based on handling `onChange` events and re-rendering.\n *\n * @default false\n */\n checked?: boolean;\n\n /**\n * When set, allows the Switch to be focusable even when it has been disabled. This is used in scenarios where it is\n * important to keep a consistent tab order for screen reader and keyboard users.\n *\n * @default false\n */\n disabledFocusable?: boolean;\n\n /**\n * Defines whether the Switch is initially in a checked state or not when rendered.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The position of the label relative to the Switch.\n *\n * @default after\n */\n labelPosition?: 'above' | 'after' | 'before';\n\n /**\n * The size of the Switch.\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n\n /**\n * Callback to be called when the checked state value changes.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SwitchOnChangeData) => void;\n};\n\n/**\n * Switch base props, excluding design-related props like size\n */\nexport type SwitchBaseProps = Omit<SwitchProps, 'size'>;\n\n/**\n * State used in rendering Switch\n */\nexport type SwitchState = ComponentState<SwitchSlots> &\n Required<Pick<SwitchProps, 'disabledFocusable' | 'labelPosition' | 'size'>>;\n\n/**\n * Switch base state, excluding design-related state like size\n */\nexport type SwitchBaseState = Omit<SwitchState, 'size'>;\n"],"names":[],"mappings":"AAoGA;;CAEC,GACD,WAAwD"}
|
|
@@ -5,29 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
Switch
|
|
12
|
+
get Switch () {
|
|
13
13
|
return _Switch.Switch;
|
|
14
14
|
},
|
|
15
|
-
renderSwitch_unstable
|
|
15
|
+
get renderSwitch_unstable () {
|
|
16
16
|
return _renderSwitch.renderSwitch_unstable;
|
|
17
17
|
},
|
|
18
|
-
switchClassName
|
|
18
|
+
get switchClassName () {
|
|
19
19
|
return _useSwitchStylesstyles.switchClassName;
|
|
20
20
|
},
|
|
21
|
-
switchClassNames
|
|
21
|
+
get switchClassNames () {
|
|
22
22
|
return _useSwitchStylesstyles.switchClassNames;
|
|
23
23
|
},
|
|
24
|
-
useSwitchBase_unstable
|
|
24
|
+
get useSwitchBase_unstable () {
|
|
25
25
|
return _useSwitch.useSwitchBase_unstable;
|
|
26
26
|
},
|
|
27
|
-
useSwitchStyles_unstable
|
|
27
|
+
get useSwitchStyles_unstable () {
|
|
28
28
|
return _useSwitchStylesstyles.useSwitchStyles_unstable;
|
|
29
29
|
},
|
|
30
|
-
useSwitch_unstable
|
|
30
|
+
get useSwitch_unstable () {
|
|
31
31
|
return _useSwitch.useSwitch_unstable;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/index.ts"],"sourcesContent":["export { Switch } from './Switch';\nexport type {\n SwitchBaseProps,\n SwitchBaseState,\n SwitchOnChangeData,\n SwitchProps,\n SwitchSlots,\n SwitchState,\n} from './Switch.types';\nexport { renderSwitch_unstable } from './renderSwitch';\nexport { useSwitch_unstable, useSwitchBase_unstable } from './useSwitch';\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n switchClassName,\n switchClassNames,\n useSwitchStyles_unstable,\n} from './useSwitchStyles.styles';\n"],"names":["Switch","renderSwitch_unstable","useSwitch_unstable","useSwitchBase_unstable","switchClassName","switchClassNames","useSwitchStyles_unstable"],"mappings":";;;;;;;;;;;;eAASA,cAAM;;;eASNC,mCAAqB;;;eAI5BG,sCAAe;;;eACfC,uCAAgB;;;eAJWF,iCAAsB;;;eAKjDG,+CAAwB;;;eALjBJ,6BAAkB;;;wBAVJ,cAAW;8BASI,oBAAiB;2BACI,iBAAc;uCAMlE,8BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Switch/renderSwitch.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { SwitchBaseState, SwitchSlots } from './Switch.types';\n\n/**\n * Render a Switch component by passing the state defined props to the appropriate slots.\n */\nexport const renderSwitch_unstable = (state: SwitchBaseState): JSXElement => {\n assertSlots<SwitchSlots>(state);\n const { labelPosition } = state;\n\n return (\n <state.root>\n <state.input />\n {labelPosition !== 'after' && state.label && <state.label />}\n <state.indicator />\n {labelPosition === 'after' && state.label && <state.label />}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderSwitch_unstable","state","labelPosition","root","input","label","indicator"],"mappings":";;;;+BAUaC;;;;;;;gCATb,gDAAiD,GAEjD,SAASD,WAAW,QAAQ,4BAA4B;AAOjD,8BAA8B,CAACE;QACpCF,2BAAAA,EAAyBE;IACzB,MAAM,EAAEC,aAAa,EAAE,GAAGD;IAE1B,OAAA,WAAA,OACE,gBAAA,EAACA,MAAME,IAAI,EAAA;;8BACT,eAAA,EAACF,MAAMG,KAAK,EAAA,CAAA;YACXF,kBAAkB,WAAWD,MAAMI,KAAK,IAAA,WAAA,OAAI,eAAA,EAACJ,MAAMI,KAAK,EAAA,CAAA;8BACzD,eAAA,EAACJ,MAAMK,SAAS,EAAA,CAAA;YACfJ,kBAAkB,WAAWD,MAAMI,KAAK,IAAA,WAAA,OAAI,eAAA,EAACJ,MAAMI,KAAK,EAAA,CAAA;;;AAG/D,EAAE"}
|
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
function _export(target, all) {
|
|
7
7
|
for(var name in all)Object.defineProperty(target, name, {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: all
|
|
9
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
useSwitchBase_unstable
|
|
13
|
+
get useSwitchBase_unstable () {
|
|
14
14
|
return useSwitchBase_unstable;
|
|
15
15
|
},
|
|
16
|
-
useSwitch_unstable
|
|
16
|
+
get useSwitch_unstable () {
|
|
17
17
|
return useSwitch_unstable;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
@@ -25,10 +25,9 @@ const _reactlabel = require("@fluentui/react-label");
|
|
|
25
25
|
const _reacttabster = require("@fluentui/react-tabster");
|
|
26
26
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
27
27
|
const useSwitch_unstable = (props, ref)=>{
|
|
28
|
-
var _baseState_indicator;
|
|
28
|
+
var _baseState_indicator, _children;
|
|
29
29
|
const { size = 'medium', ...baseProps } = props;
|
|
30
30
|
const baseState = useSwitchBase_unstable(baseProps, ref);
|
|
31
|
-
var _children;
|
|
32
31
|
(_children = (_baseState_indicator = baseState.indicator).children) !== null && _children !== void 0 ? _children : _baseState_indicator.children = /*#__PURE__*/ _react.createElement(_reacticons.CircleFilled, null);
|
|
33
32
|
return {
|
|
34
33
|
...baseState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
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,EAA8BS,OAAO;QAAEa,kBAAkB;QAAMC,kBAAkB;IAAK;IAE9F,MAAM,EACJC,OAAO,EACPC,cAAc,EACdC,QAAQ,EACRC,oBAAoB,KAAK,EACzBC,gBAAgB,OAAO,EACvBC,QAAQ,EACRC,QAAQ,EACT,GAAGrB;IAEJ,M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AAc;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"}
|
|
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
function _export(target, all) {
|
|
7
7
|
for(var name in all)Object.defineProperty(target, name, {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: all
|
|
9
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
switchClassName
|
|
13
|
+
get switchClassName () {
|
|
14
14
|
return switchClassName;
|
|
15
15
|
},
|
|
16
|
-
switchClassNames
|
|
16
|
+
get switchClassNames () {
|
|
17
17
|
return switchClassNames;
|
|
18
18
|
},
|
|
19
|
-
useSwitchStyles_unstable
|
|
19
|
+
get useSwitchStyles_unstable () {
|
|
20
20
|
return useSwitchStyles_unstable;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useSwitchStyles.styles.js"],"sourcesContent":["'use client';\nimport { createFocusOutlineStyle } from \"@fluentui/react-tabster\";\nimport { tokens } from \"@fluentui/react-theme\";\nimport { makeResetStyles, makeStyles, mergeClasses } from \"@griffel/react\";\nexport const switchClassNames = {\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.\n */ export const switchClassName = switchClassNames.root;\n// Thumb and track sizes used by the component.\nconst spaceBetweenThumbAndTrack = 2;\n// Medium size dimensions\nconst trackHeightMedium = 20;\nconst trackWidthMedium = 40;\nconst thumbSizeMedium = trackHeightMedium - spaceBetweenThumbAndTrack;\n// Small size dimensions (from design mockup)\nconst trackHeightSmall = 16;\nconst trackWidthSmall = 32;\nconst thumbSizeSmall = trackHeightSmall - spaceBetweenThumbAndTrack;\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'flex-start',\n boxSizing: 'border-box',\n display: 'inline-flex',\n position: 'relative',\n ...createFocusOutlineStyle({\n style: {},\n selector: 'focus-within'\n })\n});\nconst useRootStyles = makeStyles({\n vertical: {\n flexDirection: 'column'\n }\n});\nconst useIndicatorBaseClassName = makeResetStyles({\n borderRadius: tokens.borderRadiusCircular,\n border: '1px solid',\n lineHeight: 0,\n boxSizing: 'border-box',\n fill: 'currentColor',\n flexShrink: 0,\n fontSize: `${thumbSizeMedium}px`,\n height: `${trackHeightMedium}px`,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n pointerEvents: 'none',\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'background, border, color',\n width: `${trackWidthMedium}px`,\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms'\n },\n '@media (forced-colors: active)': {\n color: 'CanvasText',\n '> i': {\n forcedColorAdjust: 'none'\n }\n },\n '> *': {\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'transform',\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms'\n }\n }\n});\nconst useIndicatorStyles = makeStyles({\n labelAbove: {\n marginTop: 0\n },\n sizeSmall: {\n fontSize: `${thumbSizeSmall}px`,\n height: `${trackHeightSmall}px`,\n width: `${trackWidthSmall}px`\n }\n});\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'pointer',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the switch.\n width: `calc(${trackWidthMedium}px + 2 * ${tokens.spacingHorizontalS})`,\n // Checked (both enabled and disabled)\n ':checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n '> *': {\n transform: `translateX(${trackWidthMedium - thumbSizeMedium - spaceBetweenThumbAndTrack}px)`\n }\n }\n },\n // Disabled (both checked and unchecked)\n ':disabled, &[aria-disabled=\"true\"]': {\n cursor: 'default',\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralForegroundDisabled\n },\n [`& ~ .${switchClassNames.label}`]: {\n cursor: 'default',\n color: tokens.colorNeutralForegroundDisabled\n }\n },\n // Enabled and unchecked\n ':enabled:not(:checked):not([aria-disabled=\"true\"])': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessible,\n borderColor: tokens.colorNeutralStrokeAccessible\n },\n [`& ~ .${switchClassNames.label}`]: {\n color: tokens.colorNeutralForeground1\n },\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessibleHover,\n borderColor: tokens.colorNeutralStrokeAccessibleHover\n }\n },\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessiblePressed,\n borderColor: tokens.colorNeutralStrokeAccessiblePressed\n }\n }\n },\n // Enabled and checked\n ':enabled:checked:not([aria-disabled=\"true\"])': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n borderColor: tokens.colorTransparentStroke\n },\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n borderColor: tokens.colorTransparentStrokeInteractive\n }\n },\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n borderColor: tokens.colorTransparentStrokeInteractive\n }\n }\n },\n // Disabled and unchecked\n ':disabled:not(:checked), &[aria-disabled=\"true\"]:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeDisabled\n }\n },\n // Disabled and checked\n ':disabled:checked, &[aria-disabled=\"true\"]:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n borderColor: tokens.colorTransparentStrokeDisabled\n }\n },\n '@media (forced-colors: active)': {\n ':disabled, &[aria-disabled=\"true\"]': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: 'GrayText',\n borderColor: 'GrayText'\n },\n [`& ~ .${switchClassNames.label}`]: {\n color: 'GrayText'\n }\n },\n ':hover': {\n color: 'CanvasText'\n },\n ':hover:active': {\n color: 'CanvasText'\n },\n ':enabled:checked:not([aria-disabled=\"true\"])': {\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas'\n }\n },\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas'\n }\n },\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas'\n }\n }\n }\n});\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n top: 0\n },\n after: {\n left: 0,\n top: 0\n },\n above: {\n bottom: 0,\n height: `calc(${trackHeightMedium}px + ${tokens.spacingVerticalS})`,\n width: '100%'\n },\n sizeSmall: {\n width: `calc(${trackWidthSmall}px + 2 * ${tokens.spacingHorizontalS})`,\n ':checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n '> *': {\n transform: `translateX(${trackWidthSmall - thumbSizeSmall - spaceBetweenThumbAndTrack}px)`\n }\n }\n }\n }\n});\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n cursor: 'pointer',\n // Use a (negative) margin to account for the difference between the track's height and the label's line height.\n // This prevents the label from expanding the height of the switch, but preserves line height if the label wraps.\n marginBottom: `calc((${trackHeightMedium}px - ${tokens.lineHeightBase300}) / 2)`,\n marginTop: `calc((${trackHeightMedium}px - ${tokens.lineHeightBase300}) / 2)`,\n padding: `${tokens.spacingVerticalS} ${tokens.spacingHorizontalS}`\n },\n sizeSmall: {\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n marginBottom: `calc((${trackHeightSmall}px - ${tokens.lineHeightBase200}) / 2)`,\n marginTop: `calc((${trackHeightSmall}px - ${tokens.lineHeightBase200}) / 2)`\n },\n above: {\n paddingTop: tokens.spacingVerticalXS,\n paddingBottom: tokens.spacingVerticalXS,\n width: '100%'\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS\n },\n before: {\n paddingRight: tokens.spacingHorizontalXS\n }\n});\n/**\n * Apply styling to the Switch slots based on the state\n */ export const useSwitchStyles_unstable = (state)=>{\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n const labelStyles = useLabelStyles();\n const { label, labelPosition, size } = state;\n // eslint-disable-next-line react-hooks/immutability\n state.root.className = mergeClasses(switchClassNames.root, rootBaseClassName, labelPosition === 'above' && rootStyles.vertical, state.root.className);\n // eslint-disable-next-line react-hooks/immutability\n state.indicator.className = mergeClasses(switchClassNames.indicator, indicatorBaseClassName, label && labelPosition === 'above' && indicatorStyles.labelAbove, size === 'small' && indicatorStyles.sizeSmall, state.indicator.className);\n // eslint-disable-next-line react-hooks/immutability\n state.input.className = mergeClasses(switchClassNames.input, inputBaseClassName, label && inputStyles[labelPosition], size === 'small' && inputStyles.sizeSmall, state.input.className);\n if (state.label) {\n // eslint-disable-next-line react-hooks/immutability\n state.label.className = mergeClasses(switchClassNames.label, labelStyles.base, labelStyles[labelPosition], size === 'small' && labelStyles.sizeSmall, state.label.className);\n }\n return state;\n};\n"],"names":["createFocusOutlineStyle","tokens","__resetStyles","__styles","mergeClasses","switchClassNames","root","indicator","input","label","switchClassName","spaceBetweenThumbAndTrack","trackHeightMedium","trackWidthMedium","thumbSizeMedium","trackHeightSmall","trackWidthSmall","thumbSizeSmall","useRootBaseClassName","r","s","useRootStyles","vertical","Beiy3e4","d","useIndicatorBaseClassName","useIndicatorStyles","labelAbove","B6of3ja","sizeSmall","Be2twd7","Bqenvij","a9b677","useInputBaseClassName","useInputStyles","before","j35jbq","Bhzewxz","after","oyh7mz","above","B5kzvoi","oedwrj","useLabelStyles","base","Bceei9c","jrapky","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","Bg96gwp","p","useSwitchStyles_unstable","state","rootBaseClassName","rootStyles","indicatorBaseClassName","indicatorStyles","inputBaseClassName","inputStyles","labelStyles","labelPosition","size","className"],"mappings":"AAAA,YAAY;;;;;;;;;;;;IAYKU,eAAe;;;IARnBL,gBAAgB;;;IA4PZiD,wBAAwB;;;;uBA7PiB,gBAAgB;AACnE,yBAAyB;IAC5BhD,IAAI,EAAE,YAAY;IAClBC,SAAS,EAAE,uBAAuB;IAClCC,KAAK,EAAE,mBAAmB;IAC1BC,KAAK,EAAE;AACX,CAAC;AAGU,wBAAwBJ,gBAAgB,CAACC,IAAI;AACxD,+CAAA;AACA,MAAMK,yBAAyB,GAAG,CAAC;AACnC,yBAAA;AACA,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,gBAAgB,GAAG,EAAE;AAC3B,MAAMC,eAAe,GAAGF,iBAAiB,GAAGD,yBAAyB;AACrE,6CAAA;AACA,MAAMI,gBAAgB,GAAG,EAAE;AAC3B,MAAMC,eAAe,GAAG,EAAE;AAC1B,MAAMC,cAAc,GAAGF,gBAAgB,GAAGJ,yBAAyB;AACnE,MAAMO,oBAAoB,GAAA,WAAA,OAAGhB,oBAAA,EAAA,WAAA,WAAA;IAAAiB,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I,KAAK,OAAO,IAAIF,WAAW,CAACjC,SAAS,EAAE0B,KAAK,CAAC9C,KAAK,CAACwD,SAAS,CAAC;IAChL;IACA,OAAOV,KAAK;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"sources":["useSwitchStyles.styles.js"],"sourcesContent":["'use client';\nimport { createFocusOutlineStyle } from \"@fluentui/react-tabster\";\nimport { tokens } from \"@fluentui/react-theme\";\nimport { makeResetStyles, makeStyles, mergeClasses } from \"@griffel/react\";\nexport const switchClassNames = {\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.\n */ export const switchClassName = switchClassNames.root;\n// Thumb and track sizes used by the component.\nconst spaceBetweenThumbAndTrack = 2;\n// Medium size dimensions\nconst trackHeightMedium = 20;\nconst trackWidthMedium = 40;\nconst thumbSizeMedium = trackHeightMedium - spaceBetweenThumbAndTrack;\n// Small size dimensions (from design mockup)\nconst trackHeightSmall = 16;\nconst trackWidthSmall = 32;\nconst thumbSizeSmall = trackHeightSmall - spaceBetweenThumbAndTrack;\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'flex-start',\n boxSizing: 'border-box',\n display: 'inline-flex',\n position: 'relative',\n ...createFocusOutlineStyle({\n style: {},\n selector: 'focus-within'\n })\n});\nconst useRootStyles = makeStyles({\n vertical: {\n flexDirection: 'column'\n }\n});\nconst useIndicatorBaseClassName = makeResetStyles({\n borderRadius: tokens.borderRadiusCircular,\n border: '1px solid',\n lineHeight: 0,\n boxSizing: 'border-box',\n fill: 'currentColor',\n flexShrink: 0,\n fontSize: `${thumbSizeMedium}px`,\n height: `${trackHeightMedium}px`,\n margin: tokens.spacingVerticalS + ' ' + tokens.spacingHorizontalS,\n pointerEvents: 'none',\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'background, border, color',\n width: `${trackWidthMedium}px`,\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms'\n },\n '@media (forced-colors: active)': {\n color: 'CanvasText',\n '> i': {\n forcedColorAdjust: 'none'\n }\n },\n '> *': {\n transitionDuration: tokens.durationNormal,\n transitionTimingFunction: tokens.curveEasyEase,\n transitionProperty: 'transform',\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms'\n }\n }\n});\nconst useIndicatorStyles = makeStyles({\n labelAbove: {\n marginTop: 0\n },\n sizeSmall: {\n fontSize: `${thumbSizeSmall}px`,\n height: `${trackHeightSmall}px`,\n width: `${trackWidthSmall}px`\n }\n});\nconst useInputBaseClassName = makeResetStyles({\n boxSizing: 'border-box',\n cursor: 'pointer',\n height: '100%',\n margin: 0,\n opacity: 0,\n position: 'absolute',\n // Calculate the width of the hidden input by taking into account the size of the indicator + the padding around it.\n // This is done so that clicking on that \"empty space\" still toggles the switch.\n width: `calc(${trackWidthMedium}px + 2 * ${tokens.spacingHorizontalS})`,\n // Checked (both enabled and disabled)\n ':checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n '> *': {\n transform: `translateX(${trackWidthMedium - thumbSizeMedium - spaceBetweenThumbAndTrack}px)`\n }\n }\n },\n // Disabled (both checked and unchecked)\n ':disabled, &[aria-disabled=\"true\"]': {\n cursor: 'default',\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralForegroundDisabled\n },\n [`& ~ .${switchClassNames.label}`]: {\n cursor: 'default',\n color: tokens.colorNeutralForegroundDisabled\n }\n },\n // Enabled and unchecked\n ':enabled:not(:checked):not([aria-disabled=\"true\"])': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessible,\n borderColor: tokens.colorNeutralStrokeAccessible\n },\n [`& ~ .${switchClassNames.label}`]: {\n color: tokens.colorNeutralForeground1\n },\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessibleHover,\n borderColor: tokens.colorNeutralStrokeAccessibleHover\n }\n },\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: tokens.colorNeutralStrokeAccessiblePressed,\n borderColor: tokens.colorNeutralStrokeAccessiblePressed\n }\n }\n },\n // Enabled and checked\n ':enabled:checked:not([aria-disabled=\"true\"])': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackground,\n color: tokens.colorNeutralForegroundInverted,\n borderColor: tokens.colorTransparentStroke\n },\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundHover,\n borderColor: tokens.colorTransparentStrokeInteractive\n }\n },\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorCompoundBrandBackgroundPressed,\n borderColor: tokens.colorTransparentStrokeInteractive\n }\n }\n },\n // Disabled and unchecked\n ':disabled:not(:checked), &[aria-disabled=\"true\"]:not(:checked)': {\n [`& ~ .${switchClassNames.indicator}`]: {\n borderColor: tokens.colorNeutralStrokeDisabled\n }\n },\n // Disabled and checked\n ':disabled:checked, &[aria-disabled=\"true\"]:checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n borderColor: tokens.colorTransparentStrokeDisabled\n }\n },\n '@media (forced-colors: active)': {\n ':disabled, &[aria-disabled=\"true\"]': {\n [`& ~ .${switchClassNames.indicator}`]: {\n color: 'GrayText',\n borderColor: 'GrayText'\n },\n [`& ~ .${switchClassNames.label}`]: {\n color: 'GrayText'\n }\n },\n ':hover': {\n color: 'CanvasText'\n },\n ':hover:active': {\n color: 'CanvasText'\n },\n ':enabled:checked:not([aria-disabled=\"true\"])': {\n ':hover': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas'\n }\n },\n ':hover:active': {\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas'\n }\n },\n [`& ~ .${switchClassNames.indicator}`]: {\n backgroundColor: 'Highlight',\n color: 'Canvas'\n }\n }\n }\n});\nconst useInputStyles = makeStyles({\n before: {\n right: 0,\n top: 0\n },\n after: {\n left: 0,\n top: 0\n },\n above: {\n bottom: 0,\n height: `calc(${trackHeightMedium}px + ${tokens.spacingVerticalS})`,\n width: '100%'\n },\n sizeSmall: {\n width: `calc(${trackWidthSmall}px + 2 * ${tokens.spacingHorizontalS})`,\n ':checked': {\n [`& ~ .${switchClassNames.indicator}`]: {\n '> *': {\n transform: `translateX(${trackWidthSmall - thumbSizeSmall - spaceBetweenThumbAndTrack}px)`\n }\n }\n }\n }\n});\n// Can't use makeResetStyles here because Label is a component that may itself use makeResetStyles.\nconst useLabelStyles = makeStyles({\n base: {\n cursor: 'pointer',\n // Use a (negative) margin to account for the difference between the track's height and the label's line height.\n // This prevents the label from expanding the height of the switch, but preserves line height if the label wraps.\n marginBottom: `calc((${trackHeightMedium}px - ${tokens.lineHeightBase300}) / 2)`,\n marginTop: `calc((${trackHeightMedium}px - ${tokens.lineHeightBase300}) / 2)`,\n padding: `${tokens.spacingVerticalS} ${tokens.spacingHorizontalS}`\n },\n sizeSmall: {\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n marginBottom: `calc((${trackHeightSmall}px - ${tokens.lineHeightBase200}) / 2)`,\n marginTop: `calc((${trackHeightSmall}px - ${tokens.lineHeightBase200}) / 2)`\n },\n above: {\n paddingTop: tokens.spacingVerticalXS,\n paddingBottom: tokens.spacingVerticalXS,\n width: '100%'\n },\n after: {\n paddingLeft: tokens.spacingHorizontalXS\n },\n before: {\n paddingRight: tokens.spacingHorizontalXS\n }\n});\n/**\n * Apply styling to the Switch slots based on the state\n */ export const useSwitchStyles_unstable = (state)=>{\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n const indicatorBaseClassName = useIndicatorBaseClassName();\n const indicatorStyles = useIndicatorStyles();\n const inputBaseClassName = useInputBaseClassName();\n const inputStyles = useInputStyles();\n const labelStyles = useLabelStyles();\n const { label, labelPosition, size } = state;\n // eslint-disable-next-line react-hooks/immutability\n state.root.className = mergeClasses(switchClassNames.root, rootBaseClassName, labelPosition === 'above' && rootStyles.vertical, state.root.className);\n // eslint-disable-next-line react-hooks/immutability\n state.indicator.className = mergeClasses(switchClassNames.indicator, indicatorBaseClassName, label && labelPosition === 'above' && indicatorStyles.labelAbove, size === 'small' && indicatorStyles.sizeSmall, state.indicator.className);\n // eslint-disable-next-line react-hooks/immutability\n state.input.className = mergeClasses(switchClassNames.input, inputBaseClassName, label && inputStyles[labelPosition], size === 'small' && inputStyles.sizeSmall, state.input.className);\n if (state.label) {\n // eslint-disable-next-line react-hooks/immutability\n state.label.className = mergeClasses(switchClassNames.label, labelStyles.base, labelStyles[labelPosition], size === 'small' && labelStyles.sizeSmall, state.label.className);\n }\n return state;\n};\n"],"names":["createFocusOutlineStyle","tokens","__resetStyles","__styles","mergeClasses","switchClassNames","root","indicator","input","label","switchClassName","spaceBetweenThumbAndTrack","trackHeightMedium","trackWidthMedium","thumbSizeMedium","trackHeightSmall","trackWidthSmall","thumbSizeSmall","useRootBaseClassName","r","s","useRootStyles","vertical","Beiy3e4","d","useIndicatorBaseClassName","useIndicatorStyles","labelAbove","B6of3ja","sizeSmall","Be2twd7","Bqenvij","a9b677","useInputBaseClassName","useInputStyles","before","j35jbq","Bhzewxz","after","oyh7mz","above","B5kzvoi","oedwrj","useLabelStyles","base","Bceei9c","jrapky","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","Bg96gwp","p","useSwitchStyles_unstable","state","rootBaseClassName","rootStyles","indicatorBaseClassName","indicatorStyles","inputBaseClassName","inputStyles","labelStyles","labelPosition","size","className"],"mappings":"AAAA,YAAY;;;;;;;;;;;;QAYKU,eAAe;;;QARnBL,gBAAgB;;;QA4PZiD,wBAAwB;;;;uBA7PiB,gBAAgB;AACnE,yBAAyB;IAC5BhD,IAAI,EAAE,YAAY;IAClBC,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AAK,CAAChD,SAAS,CAAC0D,SAAS,CAAC;IACxO,oDAAA;IACAV,KAAK,CAAC/C,KAAK,CAACyD,SAAS,OAAG7D,mBAAY,EAACC,gBAAgB,CAACG,KAAK,EAAEoD,kBAAkB,EAAEnD,KAAK,IAAIoD,WAAW,CAACE,aAAa,CAAC,EAAEC,IAAI,KAAK,OAAO,IAAIH,WAAW,CAAChC,SAAS,EAAE0B,KAAK,CAAC/C,KAAK,CAACyD,SAAS,CAAC;IACvL,IAAIV,KAAK,CAAC9C,KAAK,EAAE;QACb,oDAAA;QACA8C,KAAK,CAAC9C,KAAK,CAACwD,SAAS,OAAG7D,mBAAY,EAACC,gBAAgB,CAACI,KAAK,EAAEqD,WAAW,CAAClB,IAAI,EAAEkB,WAAW,CAACC,aAAa,CAAC,EAAEC,IAAI,KAAK,OAAO,IAAIF,WAAW,CAACjC,SAAS,EAAE0B,KAAK,CAAC9C,KAAK,CAACwD,SAAS,CAAC;IAChL;IACA,OAAOV,KAAK;AAChB,CAAC"}
|
|
@@ -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"}
|