@fluentui/web-components 3.0.0-beta.2 → 3.0.0-beta.4

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/dist/dts/index.d.ts +1 -0
  3. package/dist/dts/menu/define.d.ts +1 -0
  4. package/dist/dts/menu/index.d.ts +4 -0
  5. package/dist/dts/menu/menu.d.ts +194 -0
  6. package/dist/dts/menu/menu.definition.d.ts +9 -0
  7. package/dist/dts/menu/menu.styles.d.ts +4 -0
  8. package/dist/dts/menu/menu.template.d.ts +4 -0
  9. package/dist/esm/index.js +1 -0
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/menu/define.js +4 -0
  12. package/dist/esm/menu/define.js.map +1 -0
  13. package/dist/esm/menu/index.js +5 -0
  14. package/dist/esm/menu/index.js.map +1 -0
  15. package/dist/esm/menu/menu.definition.js +17 -0
  16. package/dist/esm/menu/menu.definition.js.map +1 -0
  17. package/dist/esm/menu/menu.js +413 -0
  18. package/dist/esm/menu/menu.js.map +1 -0
  19. package/dist/esm/menu/menu.styles.js +17 -0
  20. package/dist/esm/menu/menu.styles.js.map +1 -0
  21. package/dist/esm/menu/menu.template.js +24 -0
  22. package/dist/esm/menu/menu.template.js.map +1 -0
  23. package/dist/esm/switch/switch.styles.js +3 -2
  24. package/dist/esm/switch/switch.styles.js.map +1 -1
  25. package/dist/fluent-web-components.api.json +1081 -0
  26. package/dist/storybook/{651.e36cf1e8.iframe.bundle.js → 677.939f187f.iframe.bundle.js} +5 -5
  27. package/dist/storybook/{651.e36cf1e8.iframe.bundle.js.map → 677.939f187f.iframe.bundle.js.map} +1 -1
  28. package/dist/storybook/iframe.html +1 -1
  29. package/dist/storybook/main.c98b42a5.iframe.bundle.js +2 -0
  30. package/dist/storybook/main.c98b42a5.iframe.bundle.js.LICENSE.txt +1 -0
  31. package/dist/storybook/project.json +1 -1
  32. package/dist/web-components.d.ts +209 -0
  33. package/dist/web-components.js +559 -223
  34. package/dist/web-components.min.js +67 -66
  35. package/docs/api-report.md +40 -0
  36. package/package.json +5 -1
  37. package/dist/storybook/main.696937e6.iframe.bundle.js +0 -1
  38. /package/dist/storybook/{651.e36cf1e8.iframe.bundle.js.LICENSE.txt → 677.939f187f.iframe.bundle.js.LICENSE.txt} +0 -0
@@ -0,0 +1,413 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { attr, FASTElement, observable, Updates } from '@microsoft/fast-element';
8
+ import { autoUpdate, computePosition, flip, hide, size } from '@floating-ui/dom';
9
+ import { keyEnter, keyEscape, keySpace, keyTab } from '@microsoft/fast-web-utilities';
10
+ /**
11
+ * The Menu class represents a menu component.
12
+ * @public
13
+ */
14
+ export class Menu extends FASTElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ /**
18
+ * Determines if the menu should open on hover.
19
+ * @public
20
+ */
21
+ this.openOnHover = false;
22
+ /**
23
+ * Determines if the menu should open on right click.
24
+ * @public
25
+ */
26
+ this.openOnContext = false;
27
+ /**
28
+ * Determines if the menu should close on scroll.
29
+ * @public
30
+ */
31
+ this.closeOnScroll = false;
32
+ /**
33
+ * Determines if the menu open state should persis on click of menu item
34
+ * @public
35
+ */
36
+ this.persistOnItemClick = false;
37
+ /**
38
+ * Defines whether the menu is open or not.
39
+ * @public
40
+ */
41
+ this.open = false;
42
+ /**
43
+ * Holds the slotted menu list.
44
+ * @public
45
+ */
46
+ this.slottedMenuList = [];
47
+ /**
48
+ * Holds the slotted triggers.
49
+ * @public
50
+ */
51
+ this.slottedTriggers = [];
52
+ /**
53
+ * Toggles the open state of the menu.
54
+ * @public
55
+ */
56
+ this.toggleMenu = () => {
57
+ if (this.open) {
58
+ this.closeMenu();
59
+ }
60
+ else {
61
+ this.openMenu();
62
+ }
63
+ };
64
+ /**
65
+ * Closes the menu.
66
+ * @public
67
+ */
68
+ this.closeMenu = () => {
69
+ this.open = false;
70
+ if (this.closeOnScroll) {
71
+ document.removeEventListener('scroll', this.closeMenu);
72
+ }
73
+ };
74
+ /**
75
+ * Opens the menu.
76
+ * @public
77
+ */
78
+ this.openMenu = (e) => {
79
+ this.open = true;
80
+ if (e && this.openOnContext) {
81
+ e.preventDefault();
82
+ }
83
+ if (this.closeOnScroll) {
84
+ document.addEventListener('scroll', this.closeMenu);
85
+ }
86
+ };
87
+ /**
88
+ * The task to set the positioning of the menu.
89
+ * @protected
90
+ */
91
+ this.setPositioningTask = () => {
92
+ this.setPositioning();
93
+ };
94
+ /**
95
+ * Handles keyboard interaction for the trigger.
96
+ * Toggles the menu when the Space or Enter key is pressed.
97
+ * If the menu is open, focuses on the menu list.
98
+ * @public
99
+ * @param {KeyboardEvent} e - the keyboard event
100
+ */
101
+ this.handleTriggerKeydown = (e) => {
102
+ if (e.defaultPrevented) {
103
+ return;
104
+ }
105
+ const key = e.key;
106
+ switch (key) {
107
+ case keySpace:
108
+ case keyEnter:
109
+ e.preventDefault();
110
+ this.toggleMenu();
111
+ if (this.open) {
112
+ this.focusMenuList();
113
+ }
114
+ break;
115
+ default:
116
+ return true;
117
+ }
118
+ };
119
+ /**
120
+ * Handles document click events to close the menu when a click occurs outside of the menu or the trigger.
121
+ * @private
122
+ * @param {Event} e - The event triggered on document click.
123
+ */
124
+ this.handleDocumentClick = (e) => {
125
+ if (e && !e.composedPath().includes(this._menuList) && !e.composedPath().includes(this._trigger)) {
126
+ this.closeMenu();
127
+ }
128
+ };
129
+ }
130
+ /**
131
+ * Called when the element is connected to the DOM.
132
+ * Sets up the component.
133
+ * @public
134
+ */
135
+ connectedCallback() {
136
+ super.connectedCallback();
137
+ Updates.enqueue(() => this.setComponent());
138
+ }
139
+ /**
140
+ * Called when the element is disconnected from the DOM.
141
+ * Removes event listeners.
142
+ * @public
143
+ */
144
+ disconnectedCallback() {
145
+ var _a;
146
+ super.disconnectedCallback();
147
+ (_a = this.cleanup) === null || _a === void 0 ? void 0 : _a.call(this);
148
+ this.removeListeners();
149
+ }
150
+ /**
151
+ * Sets the component.
152
+ * Sets the trigger and menu list elements and adds event listeners.
153
+ * @public
154
+ */
155
+ setComponent() {
156
+ if (this.$fastController.isConnected && this.slottedMenuList.length && this.slottedTriggers.length) {
157
+ this._trigger = this.slottedTriggers[0];
158
+ this._menuList = this.slottedMenuList[0];
159
+ this._trigger.setAttribute('aria-haspopup', 'true');
160
+ this._trigger.setAttribute('aria-expanded', `${this.open}`);
161
+ this.addListeners();
162
+ }
163
+ }
164
+ /**
165
+ * Focuses on the menu list.
166
+ * @public
167
+ */
168
+ focusMenuList() {
169
+ if (this.open && this._menuList) {
170
+ Updates.enqueue(() => {
171
+ this._menuList.focus();
172
+ });
173
+ }
174
+ }
175
+ /**
176
+ * Focuses on the menu trigger.
177
+ * @public
178
+ */
179
+ focusTrigger() {
180
+ if (!this.open && this._trigger) {
181
+ Updates.enqueue(() => {
182
+ this._trigger.focus();
183
+ });
184
+ }
185
+ }
186
+ /**
187
+ * Called whenever the open state changes.
188
+ * Updates the 'aria-expanded' attribute and sets the positioning of the menu.
189
+ * Sets menu list position
190
+ * emits openChanged event
191
+ * @public
192
+ * @param {boolean} oldValue - The previous value of 'open'.
193
+ * @param {boolean} newValue - The new value of 'open'.
194
+ */
195
+ openChanged(oldValue, newValue) {
196
+ var _a;
197
+ if (this.$fastController.isConnected && this._trigger instanceof HTMLElement) {
198
+ this._trigger.setAttribute('aria-expanded', `${this.open}`);
199
+ if (this._menuList && this.open) {
200
+ Updates.enqueue(this.setPositioningTask);
201
+ }
202
+ }
203
+ (_a = this.cleanup) === null || _a === void 0 ? void 0 : _a.call(this);
204
+ this.$emit('onOpenChange', { open: newValue });
205
+ }
206
+ /**
207
+ * Called whenever the 'openOnHover' property changes.
208
+ * Adds or removes a 'mouseover' event listener to the trigger based on the new value.
209
+ * @public
210
+ * @param {boolean} oldValue - The previous value of 'openOnHover'.
211
+ * @param {boolean} newValue - The new value of 'openOnHover'.
212
+ */
213
+ openOnHoverChanged(oldValue, newValue) {
214
+ var _a, _b;
215
+ if (newValue) {
216
+ (_a = this._trigger) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseover', this.openMenu);
217
+ }
218
+ else {
219
+ (_b = this._trigger) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseover', this.openMenu);
220
+ }
221
+ }
222
+ /**
223
+ * Called whenever the 'persistOnItemClick' property changes.
224
+ * Adds or removes a 'click' event listener to the menu list based on the new value.
225
+ * @public
226
+ * @param {boolean} oldValue - The previous value of 'persistOnItemClick'.
227
+ * @param {boolean} newValue - The new value of 'persistOnItemClick'.
228
+ */
229
+ persistOnItemClickChanged(oldValue, newValue) {
230
+ var _a, _b;
231
+ if (!newValue) {
232
+ (_a = this._menuList) === null || _a === void 0 ? void 0 : _a.addEventListener('click', this.closeMenu);
233
+ }
234
+ else {
235
+ (_b = this._menuList) === null || _b === void 0 ? void 0 : _b.removeEventListener('click', this.closeMenu);
236
+ }
237
+ }
238
+ /**
239
+ * Called whenever the 'openOnContext' property changes.
240
+ * Adds or removes a 'contextmenu' event listener to the trigger based on the new value.
241
+ * @public
242
+ * @param {boolean} oldValue - The previous value of 'openOnContext'.
243
+ * @param {boolean} newValue - The new value of 'openOnContext'.
244
+ */
245
+ openOnContextChanged(oldValue, newValue) {
246
+ var _a, _b;
247
+ if (newValue) {
248
+ (_a = this._trigger) === null || _a === void 0 ? void 0 : _a.addEventListener('contextmenu', this.openMenu);
249
+ }
250
+ else {
251
+ (_b = this._trigger) === null || _b === void 0 ? void 0 : _b.removeEventListener('contextmenu', this.openMenu);
252
+ }
253
+ }
254
+ /**
255
+ * Called whenever the 'closeOnScroll' property changes.
256
+ * Adds or removes a 'closeOnScroll' event listener to the trigger based on the new value.
257
+ * @public
258
+ * @param {boolean} oldValue - The previous value of 'closeOnScroll'.
259
+ * @param {boolean} newValue - The new value of 'closeOnScroll'.
260
+ */
261
+ closeOnScrollChanged(oldValue, newValue) {
262
+ if (newValue) {
263
+ document.addEventListener('scroll', this.closeMenu);
264
+ }
265
+ else {
266
+ document.removeEventListener('scroll', this.closeMenu);
267
+ }
268
+ }
269
+ /**
270
+ * Sets the positioning of the menu.
271
+ * @protected
272
+ */
273
+ setPositioning() {
274
+ if (this.$fastController.isConnected && this._menuList && this.open && this._trigger) {
275
+ this.cleanup = autoUpdate(this, this.positioningContainer, async () => {
276
+ var _a, _b;
277
+ const { middlewareData, x, y } = await computePosition(this._trigger, this.positioningContainer, {
278
+ placement: 'bottom',
279
+ strategy: 'fixed',
280
+ middleware: [
281
+ flip(),
282
+ size({
283
+ apply: ({ availableHeight, rects }) => {
284
+ var _a;
285
+ ((_a = this.positioningContainer) === null || _a === void 0 ? void 0 : _a.style) &&
286
+ Object.assign(this.positioningContainer.style, {
287
+ maxHeight: `${availableHeight}px`,
288
+ width: `${rects.reference.width}px`,
289
+ });
290
+ },
291
+ }),
292
+ hide(),
293
+ ],
294
+ });
295
+ if ((_a = middlewareData.hide) === null || _a === void 0 ? void 0 : _a.referenceHidden) {
296
+ this.open = false;
297
+ return;
298
+ }
299
+ ((_b = this.positioningContainer) === null || _b === void 0 ? void 0 : _b.style) &&
300
+ Object.assign(this.positioningContainer.style, {
301
+ position: 'fixed',
302
+ top: '0',
303
+ left: '0',
304
+ transform: `translate(${x}px, ${y}px)`,
305
+ });
306
+ });
307
+ }
308
+ }
309
+ /**
310
+ * Adds event listeners.
311
+ * Adds click and keydown event listeners to the trigger and a click event listener to the document.
312
+ * If 'openOnHover' is true, adds a 'mouseover' event listener to the trigger.
313
+ * @public
314
+ */
315
+ addListeners() {
316
+ var _a, _b, _c, _d, _e;
317
+ document.addEventListener('click', this.handleDocumentClick);
318
+ (_a = this._trigger) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', this.handleTriggerKeydown);
319
+ if (!this.persistOnItemClick) {
320
+ (_b = this._menuList) === null || _b === void 0 ? void 0 : _b.addEventListener('click', this.closeMenu);
321
+ }
322
+ if (this.openOnHover) {
323
+ (_c = this._trigger) === null || _c === void 0 ? void 0 : _c.addEventListener('mouseover', this.openMenu);
324
+ }
325
+ else if (this.openOnContext) {
326
+ (_d = this._trigger) === null || _d === void 0 ? void 0 : _d.addEventListener('contextmenu', this.openMenu);
327
+ }
328
+ else {
329
+ (_e = this._trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('click', this.toggleMenu);
330
+ }
331
+ }
332
+ /**
333
+ * Removes event listeners.
334
+ * Removes click and keydown event listeners from the trigger and a click event listener from the document.
335
+ * Also removes 'mouseover' event listeners from the trigger.
336
+ * @private
337
+ */
338
+ removeListeners() {
339
+ var _a, _b, _c, _d, _e;
340
+ document.removeEventListener('click', this.handleDocumentClick);
341
+ (_a = this._trigger) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', this.handleTriggerKeydown);
342
+ if (!this.persistOnItemClick) {
343
+ (_b = this._menuList) === null || _b === void 0 ? void 0 : _b.removeEventListener('click', this.closeMenu);
344
+ }
345
+ if (this.openOnHover) {
346
+ (_c = this._trigger) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseover', this.openMenu);
347
+ }
348
+ if (this.openOnContext) {
349
+ (_d = this._trigger) === null || _d === void 0 ? void 0 : _d.removeEventListener('contextmenu', this.openMenu);
350
+ }
351
+ else {
352
+ (_e = this._trigger) === null || _e === void 0 ? void 0 : _e.removeEventListener('click', this.toggleMenu);
353
+ }
354
+ }
355
+ /**
356
+ * Handles keyboard interaction for the menu.
357
+ * Closes the menu and focuses on the trigger when the Escape key is pressed.
358
+ * Closes the menu when the Tab key is pressed.
359
+ * @public
360
+ * @param {KeyboardEvent} e - the keyboard event
361
+ */
362
+ handleMenuKeydown(e) {
363
+ if (e.defaultPrevented) {
364
+ return;
365
+ }
366
+ const key = e.key;
367
+ switch (key) {
368
+ case keyEscape:
369
+ e.preventDefault();
370
+ if (this.open) {
371
+ this.closeMenu();
372
+ this.focusTrigger();
373
+ }
374
+ break;
375
+ case keyTab:
376
+ if (this.open) {
377
+ this.closeMenu();
378
+ }
379
+ if (e.shiftKey) {
380
+ this.focusTrigger();
381
+ }
382
+ default:
383
+ return true;
384
+ }
385
+ }
386
+ }
387
+ __decorate([
388
+ observable,
389
+ attr({ attribute: 'open-on-hover', mode: 'boolean' })
390
+ ], Menu.prototype, "openOnHover", void 0);
391
+ __decorate([
392
+ observable,
393
+ attr({ attribute: 'open-on-context', mode: 'boolean' })
394
+ ], Menu.prototype, "openOnContext", void 0);
395
+ __decorate([
396
+ observable,
397
+ attr({ attribute: 'close-on-scroll', mode: 'boolean' })
398
+ ], Menu.prototype, "closeOnScroll", void 0);
399
+ __decorate([
400
+ observable,
401
+ attr({ attribute: 'persist-on-item-click', mode: 'boolean' })
402
+ ], Menu.prototype, "persistOnItemClick", void 0);
403
+ __decorate([
404
+ observable,
405
+ attr({ mode: 'boolean' })
406
+ ], Menu.prototype, "open", void 0);
407
+ __decorate([
408
+ observable
409
+ ], Menu.prototype, "slottedMenuList", void 0);
410
+ __decorate([
411
+ observable
412
+ ], Menu.prototype, "slottedTriggers", void 0);
413
+ //# sourceMappingURL=menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.js","sourceRoot":"","sources":["../../../src/menu/menu.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE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QvC;IAFC,UAAU;IACV,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;2CACjB;AAQvC;IAFC,UAAU;IACV,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;gDAClB;AAQ5C;IAFC,UAAU;IACV,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;kCACG;AAO7B;IADC,UAAU;6CAC6B;AAOxC;IADC,UAAU;6CACgC"}
@@ -0,0 +1,17 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ /** Menu styles
3
+ * @public
4
+ */
5
+ export const styles = css `
6
+ :host {
7
+ position: relative;
8
+ z-index: var(--z-index-menu, 1);
9
+ }
10
+ .positioning-container {
11
+ position: fixed;
12
+ top: 0;
13
+ left: 0;
14
+ transform: translate(0, 0);
15
+ }
16
+ `;
17
+ //# sourceMappingURL=menu.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.styles.js","sourceRoot":"","sources":["../../../src/menu/menu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAG9C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;CAWxB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { elements, html, ref, slotted } from '@microsoft/fast-element';
2
+ export function menuTemplate() {
3
+ return html `
4
+ <template
5
+ ?open-on-hover="${x => x.openOnHover}"
6
+ ?open-on-context="${x => x.openOnContext}"
7
+ ?close-on-scroll="${x => x.closeOnScroll}"
8
+ ?persist-on-item-click="${x => x.persistOnItemClick}"
9
+ @keydown="${(x, c) => x.handleMenuKeydown(c.event)}"
10
+ >
11
+ <slot name="trigger" ${slotted({ property: 'slottedTriggers', filter: elements() })}></slot>
12
+ <span
13
+ ${ref('positioningContainer')}
14
+ part="positioning-container"
15
+ class="positioning-container"
16
+ ?hidden="${x => !x.open}"
17
+ >
18
+ <slot ${slotted({ property: 'slottedMenuList', filter: elements() })}></slot>
19
+ </span>
20
+ </template>
21
+ `;
22
+ }
23
+ export const template = menuTemplate();
24
+ //# sourceMappingURL=menu.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.template.js","sourceRoot":"","sources":["../../../src/menu/menu.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAG5F,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,CAAG;;wBAEQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW;0BAChB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa;0BACpB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa;gCACd,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB;kBACvC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAsB,CAAC;;6BAE5C,OAAO,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;;UAE/E,GAAG,CAAC,sBAAsB,CAAC;;;mBAGlB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;;gBAEf,OAAO,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;;;GAGzE,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAA8B,YAAY,EAAE,CAAC"}
@@ -83,14 +83,15 @@ export const styles = css `
83
83
  height: 14px;
84
84
  width: 14px;
85
85
  border-radius: 50%;
86
+ margin-inline-start: 0;
86
87
  background-color: ${colorNeutralForeground3};
87
88
  transition-duration: ${durationNormal};
88
89
  transition-timing-function: ${curveEasyEase};
89
- transition-property: transform;
90
+ transition-property: margin-inline-start;
90
91
  }
91
92
  :host([aria-checked='true']) .checked-indicator {
92
93
  background-color: ${colorNeutralForegroundInverted};
93
- transform: translateX(20px);
94
+ margin-inline-start: calc(100% - 14px);
94
95
  }
95
96
  :host([aria-checked='true']:hover) .checked-indicator {
96
97
  background: ${colorNeutralForegroundInvertedHover};
@@ -1 +1 @@
1
- {"version":3,"file":"switch.styles.js","sourceRoot":"","sources":["../../../src/switch/switch.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAClG,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,EACjC,mCAAmC,EACnC,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAC9B,mCAAmC,EACnC,qCAAqC,EACrC,4BAA4B,EAC5B,iCAAiC,EACjC,mCAAmC,EACnC,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;IACrB,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;aAwBb,uBAAuB;mBACjB,iBAAiB;iBACnB,eAAe;mBACb,iBAAiB;mBACjB,cAAc;eAClB,iBAAiB,IAAI,mBAAmB;;;;;;;;;iBAStC,oBAAoB;;;;wBAIb,0BAA0B;wBAC1B,4BAA4B;qBAC/B,oBAAoB;;;c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