@getflip/swirl-components 0.95.0 → 0.95.2

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 (41) hide show
  1. package/components.json +1 -1
  2. package/dist/cjs/swirl-action-list_3.cjs.entry.js +10 -20
  3. package/dist/cjs/swirl-app-layout_7.cjs.entry.js +20 -9
  4. package/dist/cjs/swirl-autocomplete.cjs.entry.js +10 -2
  5. package/dist/cjs/swirl-modal.cjs.entry.js +1 -1
  6. package/dist/cjs/swirl-option-list_2.cjs.entry.js +5 -3
  7. package/dist/cjs/swirl-select.cjs.entry.js +4 -2
  8. package/dist/collection/assets/pdfjs/pdf.worker.min.js +22 -0
  9. package/dist/collection/components/swirl-action-list/swirl-action-list.js +10 -20
  10. package/dist/collection/components/swirl-autocomplete/swirl-autocomplete.js +10 -2
  11. package/dist/collection/components/swirl-modal/swirl-modal.css +1 -0
  12. package/dist/collection/components/swirl-option-list/swirl-option-list.js +5 -3
  13. package/dist/collection/components/swirl-resource-list/swirl-resource-list.js +20 -9
  14. package/dist/collection/components/swirl-resource-list/swirl-resource-list.spec.js +8 -9
  15. package/dist/collection/components/swirl-select/swirl-select.js +4 -2
  16. package/dist/components/assets/pdfjs/pdf.worker.min.js +22 -0
  17. package/dist/components/swirl-action-list2.js +10 -20
  18. package/dist/components/swirl-autocomplete.js +10 -2
  19. package/dist/components/swirl-modal.js +1 -1
  20. package/dist/components/swirl-option-list2.js +5 -3
  21. package/dist/components/swirl-resource-list2.js +20 -9
  22. package/dist/components/swirl-select.js +4 -2
  23. package/dist/esm/swirl-action-list_3.entry.js +10 -20
  24. package/dist/esm/swirl-app-layout_7.entry.js +20 -9
  25. package/dist/esm/swirl-autocomplete.entry.js +10 -2
  26. package/dist/esm/swirl-modal.entry.js +1 -1
  27. package/dist/esm/swirl-option-list_2.entry.js +5 -3
  28. package/dist/esm/swirl-select.entry.js +4 -2
  29. package/dist/swirl-components/{p-89898ac6.entry.js → p-057b650a.entry.js} +1 -1
  30. package/dist/swirl-components/p-0e6c2f2b.entry.js +1 -0
  31. package/dist/swirl-components/{p-789efdba.entry.js → p-0fc0cd2c.entry.js} +1 -1
  32. package/dist/swirl-components/p-59408f77.entry.js +1 -0
  33. package/dist/swirl-components/p-6f07c958.entry.js +1 -0
  34. package/dist/swirl-components/{p-1d1edae3.entry.js → p-8a00faee.entry.js} +1 -1
  35. package/dist/swirl-components/swirl-components.esm.js +1 -1
  36. package/dist/types/components/swirl-action-list/swirl-action-list.d.ts +1 -6
  37. package/dist/types/components/swirl-select/swirl-select.d.ts +2 -0
  38. package/package.json +1 -1
  39. package/dist/swirl-components/p-0067f11b.entry.js +0 -1
  40. package/dist/swirl-components/p-56fa872b.entry.js +0 -1
  41. package/dist/swirl-components/p-bf258885.entry.js +0 -1
@@ -19,35 +19,25 @@ const SwirlActionList = /*@__PURE__*/ proxyCustomElement(class SwirlActionList e
19
19
  }
20
20
  };
21
21
  }
22
- componentDidLoad() {
23
- this.updateItems();
24
- this.observeSlotChanges();
25
- }
26
- disconnectedCallback() {
27
- this.observer?.disconnect();
28
- }
29
- observeSlotChanges() {
30
- this.observer = new MutationObserver(() => {
31
- this.updateItems();
32
- });
33
- this.observer.observe(this.el, { childList: true });
34
- }
35
- updateItems() {
36
- this.items = querySelectorAllDeep(this.el, '[role="menuitem"]');
22
+ getItems() {
23
+ return querySelectorAllDeep(this.el, '[role="menuitem"]');
37
24
  }
38
25
  focusNextItem() {
26
+ const items = this.getItems();
39
27
  const activeItemIndex = this.getActiveItemIndex();
40
- const newIndex = (activeItemIndex + 1) % this.items.length;
41
- this.items[newIndex].focus();
28
+ const newIndex = (activeItemIndex + 1) % items.length;
29
+ items[newIndex].focus();
42
30
  }
43
31
  focusPreviousItem() {
32
+ const items = this.getItems();
44
33
  const activeItemIndex = this.getActiveItemIndex();
45
- const newIndex = activeItemIndex === 0 ? this.items.length - 1 : activeItemIndex - 1;
46
- this.items[newIndex]?.focus();
34
+ const newIndex = activeItemIndex === 0 ? items.length - 1 : activeItemIndex - 1;
35
+ items[newIndex]?.focus();
47
36
  }
48
37
  getActiveItemIndex() {
38
+ const items = this.getItems();
49
39
  const activeElement = getActiveElement();
50
- return this.items.findIndex((item) => item === activeElement ||
40
+ return items.findIndex((item) => item === activeElement ||
51
41
  item === activeElement?.querySelector('[role="menuitem"]'));
52
42
  }
53
43
  render() {
@@ -54,8 +54,16 @@ const SwirlAutocomplete$1 = /*@__PURE__*/ proxyCustomElement(class SwirlAutocomp
54
54
  !this.value.some((item) => item.id === suggestion.id)),
55
55
  ];
56
56
  this.valueChange.emit(this.value);
57
- this.inputEl.querySelector("input")?.focus();
58
- await this.updateSuggestions(this.inputEl.querySelector("input").value);
57
+ this.inputEl.value = "";
58
+ const input = this.inputEl.querySelector("input");
59
+ if (Boolean(input)) {
60
+ input.value = "";
61
+ queueMicrotask(() => {
62
+ input.focus();
63
+ this.close();
64
+ });
65
+ this.updateSuggestions(input.value);
66
+ }
59
67
  }
60
68
  else {
61
69
  if (Boolean(event.detail[0])) {
@@ -1148,7 +1148,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
1148
1148
  return trap;
1149
1149
  };
1150
1150
 
1151
- const swirlModalCss = ":host{display:block}:host *{box-sizing:border-box}.modal{--swirl-ghost-button-background-default:var(--s-surface-overlay-default);--swirl-ghost-button-background-hovered:var(--s-surface-overlay-hovered);--swirl-ghost-button-background-pressed:var(--s-surface-overlay-pressed);--swirl-resource-list-item-background-default:var(\n --s-surface-overlay-default\n );--swirl-resource-list-item-background-hovered:var(\n --s-surface-overlay-hovered\n );--swirl-resource-list-item-background-pressed:var(\n --s-surface-overlay-pressed\n );--swirl-modal-height:auto;--swirl-modal-max-height:90vh;position:fixed;z-index:var(--s-z-40);display:flex;justify-content:center;align-items:center;inset:0}.modal[aria-hidden=\"true\"]{display:none}.modal--variant-default.modal--closing{animation:0.15s modal-fade-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-default.modal--closing{animation:none}}.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:0.15s modal-backdrop-fade-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:none}}.modal--variant-default:not(.modal--closing) .modal__body{animation:0.15s modal-scale-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__body{animation:none}}.modal--variant-drawer{justify-content:end;align-items:stretch}.modal--variant-drawer.modal--closing{animation:0.15s modal-drawer-slide-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-drawer.modal--closing{animation:none}}@media (min-width: 768px){.modal--variant-drawer.modal--hide-label .modal__header-bar{height:auto;padding-top:var(--s-space-4);padding-bottom:var(--s-space-4)}}.modal--variant-drawer .modal__backdrop{background-color:transparent;animation:none}.modal--variant-drawer .modal__body{height:100%;max-height:none;border-radius:0;animation:0.15s modal-drawer-slide-in;box-shadow:var(--s-shadow-level-3)}@media (prefers-reduced-motion){.modal--variant-drawer .modal__body{animation:none}}.modal--variant-drawer .modal__header-bar{background-color:var(--s-surface-overlay-default)}.modal--variant-drawer .modal__header-bar .modal__close-button{margin-left:calc(-1 * var(--s-space-8))}@media (min-width: 768px){.modal--variant-drawer .modal__header-bar{flex-direction:row}}@media (min-width: 768px){.modal--variant-drawer.modal--padded .modal__content{padding-top:var(--s-space-8)}}.modal--padded .modal__content{padding-top:var(--s-space-24);padding-right:var(--s-space-16);padding-bottom:var(--s-space-24);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal--padded .modal__content{padding-top:0;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}}@media (min-width: 768px){.modal--scrollable .modal__content{padding-bottom:0}}.modal--scrollable:not(.modal--scrolled-down).modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--scrollable:not(.modal--scrolled-down):not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-custom-header .modal__content{padding-top:var(--s-space-16)}.modal--has-custom-footer .modal__custom-footer{padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}.modal--has-header-tools .modal__header{border-bottom-color:transparent}.modal--has-header-tools .modal__header-tools{display:block}.modal--has-secondary-content .modal__body{max-width:64rem}.modal--has-secondary-content:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-secondary-content:not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 992px){.modal--has-secondary-content .modal__header-tools,.modal--has-secondary-content .modal__content{padding-right:0}}.modal--has-secondary-content .modal__primary-content{overflow:visible;max-height:60%;flex-basis:auto}@media (min-width: 992px){.modal--has-secondary-content .modal__primary-content{max-height:none;flex-basis:calc(100% - 24rem)}}.modal--has-secondary-content .modal__secondary-content{display:block}@media (min-width: 768px){.modal--scrolled:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--scrolled.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}}.modal__backdrop{position:fixed;background-color:rgba(0, 0, 0, 0.2);inset:0}.modal__body{position:relative;z-index:var(--s-z-40);display:flex;overflow:hidden;width:100vw;max-width:40rem;height:100vh;background-color:var(--s-surface-overlay-default);flex-direction:column}@media (min-width: 768px){.modal__body{width:90vw;max-height:var(--swirl-modal-max-height);border-radius:var(--s-border-radius-base);box-shadow:var(--s-shadow-level-3)}}@media (min-width: 992px){.modal__body{height:var(--swirl-modal-height)}}.modal__header{border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header{border-bottom:var(--s-border-width-default) solid transparent}}.modal__header-bar{display:flex;height:3.5rem;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-shrink:0;align-items:center;gap:var(--s-space-8)}@media (min-width: 768px){.modal__header-bar{height:4.125rem;padding-top:var(--s-space-24);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-direction:row-reverse;gap:var(--s-space-16)}}.modal__header-tools{display:none;padding-right:var(--s-space-16);padding-left:var(--s-space-16);border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header-tools{padding-right:var(--s-space-24);padding-left:var(--s-space-24);border-bottom-color:transparent}}.modal__custom-header{flex-shrink:0;border-bottom:var(--s-border-width-default) solid var(--s-border-default)}.modal__heading{overflow:hidden}.modal__heading .heading{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.modal__content-container{display:flex;overflow:hidden;flex-grow:1;flex-direction:column;gap:var(--s-space-24)}@media (min-width: 992px){.modal__content-container{flex-direction:row}}.modal__primary-content{display:flex;overflow:hidden;flex-basis:100%;flex-direction:column}.modal__content{overflow-x:hidden;overflow-y:auto}.modal__content ::slotted(*){margin:0}.modal__secondary-content{display:none;overflow:visible;overflow-x:hidden;overflow-y:auto;max-width:none;max-height:40%;padding-right:var(--s-space-16);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal__secondary-content{padding-left:var(--s-space-24)}}@media (min-width: 992px){.modal__secondary-content{overflow-x:hidden;overflow-y:auto;max-width:24rem;max-height:none;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:0;flex-basis:50%}}.modal__custom-footer{flex-shrink:0}.modal__controls{display:flex;padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-shrink:0;justify-content:flex-end}@keyframes modal-scale-in{from{transform:scale(0)}to{transform:scale(1)}}@keyframes modal-backdrop-fade-in{from{opacity:0}to{opacity:1}}@keyframes modal-fade-out{from{opacity:1}to{opacity:0}}@keyframes modal-drawer-slide-in{from{transform:translate3d(100%, 0, 0)}to{transform:translate3d(0, 0, 0)}}@keyframes modal-drawer-slide-out{from{transform:translate3d(0, 0, 0)}to{transform:translate3d(100%, 0, 0)}}";
1151
+ const swirlModalCss = ":host{display:block}:host *{box-sizing:border-box}.modal{--swirl-ghost-button-background-default:var(--s-surface-overlay-default);--swirl-ghost-button-background-hovered:var(--s-surface-overlay-hovered);--swirl-ghost-button-background-pressed:var(--s-surface-overlay-pressed);--swirl-resource-list-item-background-default:var(\n --s-surface-overlay-default\n );--swirl-resource-list-item-background-hovered:var(\n --s-surface-overlay-hovered\n );--swirl-resource-list-item-background-pressed:var(\n --s-surface-overlay-pressed\n );--swirl-modal-height:auto;--swirl-modal-max-height:90vh;position:fixed;z-index:var(--s-z-40);display:flex;justify-content:center;align-items:center;inset:0}.modal[aria-hidden=\"true\"]{display:none}.modal--variant-default.modal--closing{animation:0.15s modal-fade-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-default.modal--closing{animation:none}}.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:0.15s modal-backdrop-fade-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:none}}.modal--variant-default:not(.modal--closing) .modal__body{animation:0.15s modal-scale-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__body{animation:none}}.modal--variant-drawer{justify-content:end;align-items:stretch}.modal--variant-drawer.modal--closing{animation:0.15s modal-drawer-slide-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-drawer.modal--closing{animation:none}}@media (min-width: 768px){.modal--variant-drawer.modal--hide-label .modal__header-bar{height:auto;padding-top:var(--s-space-4);padding-bottom:var(--s-space-4)}}.modal--variant-drawer .modal__backdrop{background-color:transparent;animation:none}.modal--variant-drawer .modal__body{height:100%;max-height:none;border-radius:0;animation:0.15s modal-drawer-slide-in;box-shadow:var(--s-shadow-level-3)}@media (prefers-reduced-motion){.modal--variant-drawer .modal__body{animation:none}}.modal--variant-drawer .modal__header-bar{background-color:var(--s-surface-overlay-default)}.modal--variant-drawer .modal__header-bar .modal__close-button{margin-left:calc(-1 * var(--s-space-8))}@media (min-width: 768px){.modal--variant-drawer .modal__header-bar{flex-direction:row}}@media (min-width: 768px){.modal--variant-drawer.modal--padded .modal__content{padding-top:var(--s-space-8)}}.modal--padded .modal__content{padding-top:var(--s-space-24);padding-right:var(--s-space-16);padding-bottom:var(--s-space-24);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal--padded .modal__content{padding-top:0;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}}@media (min-width: 768px){.modal--scrollable .modal__content{padding-bottom:0}}.modal--scrollable:not(.modal--scrolled-down).modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--scrollable:not(.modal--scrolled-down):not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-custom-header .modal__content{padding-top:var(--s-space-16)}.modal--has-custom-footer .modal__custom-footer{padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}.modal--has-header-tools .modal__header{border-bottom-color:transparent}.modal--has-header-tools .modal__header-tools{display:block}.modal--has-secondary-content .modal__body{max-width:64rem}.modal--has-secondary-content:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-secondary-content:not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 992px){.modal--has-secondary-content .modal__header-tools,.modal--has-secondary-content .modal__content{padding-right:0}}.modal--has-secondary-content .modal__primary-content{overflow:visible;max-height:60%;flex-basis:auto}@media (min-width: 992px){.modal--has-secondary-content .modal__primary-content{max-width:calc(100% - 24rem);max-height:none;flex-basis:calc(100% - 24rem)}}.modal--has-secondary-content .modal__secondary-content{display:block}@media (min-width: 768px){.modal--scrolled:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--scrolled.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}}.modal__backdrop{position:fixed;background-color:rgba(0, 0, 0, 0.2);inset:0}.modal__body{position:relative;z-index:var(--s-z-40);display:flex;overflow:hidden;width:100vw;max-width:40rem;height:100vh;background-color:var(--s-surface-overlay-default);flex-direction:column}@media (min-width: 768px){.modal__body{width:90vw;max-height:var(--swirl-modal-max-height);border-radius:var(--s-border-radius-base);box-shadow:var(--s-shadow-level-3)}}@media (min-width: 992px){.modal__body{height:var(--swirl-modal-height)}}.modal__header{border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header{border-bottom:var(--s-border-width-default) solid transparent}}.modal__header-bar{display:flex;height:3.5rem;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-shrink:0;align-items:center;gap:var(--s-space-8)}@media (min-width: 768px){.modal__header-bar{height:4.125rem;padding-top:var(--s-space-24);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-direction:row-reverse;gap:var(--s-space-16)}}.modal__header-tools{display:none;padding-right:var(--s-space-16);padding-left:var(--s-space-16);border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header-tools{padding-right:var(--s-space-24);padding-left:var(--s-space-24);border-bottom-color:transparent}}.modal__custom-header{flex-shrink:0;border-bottom:var(--s-border-width-default) solid var(--s-border-default)}.modal__heading{overflow:hidden}.modal__heading .heading{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.modal__content-container{display:flex;overflow:hidden;flex-grow:1;flex-direction:column;gap:var(--s-space-24)}@media (min-width: 992px){.modal__content-container{flex-direction:row}}.modal__primary-content{display:flex;overflow:hidden;flex-basis:100%;flex-direction:column}.modal__content{overflow-x:hidden;overflow-y:auto}.modal__content ::slotted(*){margin:0}.modal__secondary-content{display:none;overflow:visible;overflow-x:hidden;overflow-y:auto;max-width:none;max-height:40%;padding-right:var(--s-space-16);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal__secondary-content{padding-left:var(--s-space-24)}}@media (min-width: 992px){.modal__secondary-content{overflow-x:hidden;overflow-y:auto;max-width:24rem;max-height:none;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:0;flex-basis:50%}}.modal__custom-footer{flex-shrink:0}.modal__controls{display:flex;padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-shrink:0;justify-content:flex-end}@keyframes modal-scale-in{from{transform:scale(0)}to{transform:scale(1)}}@keyframes modal-backdrop-fade-in{from{opacity:0}to{opacity:1}}@keyframes modal-fade-out{from{opacity:1}to{opacity:0}}@keyframes modal-drawer-slide-in{from{transform:translate3d(100%, 0, 0)}to{transform:translate3d(0, 0, 0)}}@keyframes modal-drawer-slide-out{from{transform:translate3d(0, 0, 0)}to{transform:translate3d(100%, 0, 0)}}";
1152
1152
 
1153
1153
  const SwirlModal$1 = /*@__PURE__*/ proxyCustomElement(class SwirlModal extends HTMLElement {
1154
1154
  constructor() {
@@ -302,9 +302,11 @@ const SwirlOptionList = /*@__PURE__*/ proxyCustomElement(class SwirlOptionList e
302
302
  this.focusItem(newIndex);
303
303
  }
304
304
  getActiveItemIndex() {
305
- return this.items
306
- .map((item) => item.querySelector('[role="option"]'))
307
- .findIndex((item) => item === this.focusedItem);
305
+ return Boolean(this.focusedItem)
306
+ ? this.items
307
+ .map((item) => item.querySelector('[role="option"]'))
308
+ .findIndex((item) => item === this.focusedItem)
309
+ : 0;
308
310
  }
309
311
  getItemIndex(item) {
310
312
  return this.items.map((i) => i).findIndex((i) => i === item);
@@ -37,7 +37,7 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
37
37
  this.draggingStartIndex = undefined;
38
38
  };
39
39
  this.onKeyDown = (event) => {
40
- if (event.key === "ArrowDown") {
40
+ if (event.code === "ArrowDown") {
41
41
  event.preventDefault();
42
42
  if (!Boolean(this.dragging)) {
43
43
  this.focusItemAtIndex((this.focusedIndex + 1) % this.items.length);
@@ -46,7 +46,7 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
46
46
  this.moveDraggedItemDown();
47
47
  }
48
48
  }
49
- else if (event.key === "ArrowUp") {
49
+ else if (event.code === "ArrowUp") {
50
50
  event.preventDefault();
51
51
  if (!Boolean(this.dragging)) {
52
52
  const prevIndex = this.focusedIndex === 0
@@ -58,7 +58,7 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
58
58
  this.moveDraggedItemUp();
59
59
  }
60
60
  }
61
- else if (event.key === "Space" || event.key === "Enter") {
61
+ else if (event.code === "Space" || event.code === "Enter") {
62
62
  const target = event.composedPath()[0];
63
63
  if (Boolean(this.dragging) &&
64
64
  !target?.classList.contains("resource-list-item__drag-handle")) {
@@ -66,11 +66,11 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
66
66
  this.stopDrag(this.dragging);
67
67
  }
68
68
  }
69
- else if (event.key === "Home") {
69
+ else if (event.code === "Home") {
70
70
  event.preventDefault();
71
71
  this.focusItemAtIndex(0);
72
72
  }
73
- else if (event.key === "End") {
73
+ else if (event.code === "End") {
74
74
  event.preventDefault();
75
75
  this.focusItemAtIndex(this.items.length - 1);
76
76
  }
@@ -98,7 +98,11 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
98
98
  this.setItemAllowDragState();
99
99
  this.setupDragDrop();
100
100
  });
101
- this.observer.observe(this.el, { childList: true });
101
+ this.observer.observe(this.el, {
102
+ childList: true,
103
+ characterData: true,
104
+ subtree: true,
105
+ });
102
106
  }
103
107
  watchAllowDrag() {
104
108
  this.setItemAllowDragState();
@@ -113,9 +117,12 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
113
117
  return this.items.map((i) => i).findIndex((i) => i === item);
114
118
  }
115
119
  removeItemsFromTabOrder() {
116
- this.items.forEach((item) => item
117
- ?.querySelector(".resource-list-item__content, .resource-list-file-item")
118
- ?.setAttribute("tabIndex", "-1"));
120
+ this.items.forEach((item) => {
121
+ const focusableEl = item?.querySelector(".resource-list-item__content, .resource-list-file-item");
122
+ const dragHandle = item?.querySelector(".resource-list-item__drag-handle");
123
+ focusableEl?.setAttribute("tabIndex", "-1");
124
+ dragHandle?.setAttribute("tabIndex", "-1");
125
+ });
119
126
  }
120
127
  setItemAllowDragState() {
121
128
  if (this.allowDrag) {
@@ -156,6 +163,10 @@ const SwirlResourceList = /*@__PURE__*/ proxyCustomElement(class SwirlResourceLi
156
163
  return;
157
164
  }
158
165
  const interactiveElement = item.querySelector(".resource-list-item__content, .resource-list-file-item");
166
+ const dragHandle = item.querySelector(".resource-list-item__drag-handle");
167
+ if (Boolean(dragHandle)) {
168
+ dragHandle.setAttribute("tabIndex", "0");
169
+ }
159
170
  if (!Boolean(interactiveElement)) {
160
171
  return;
161
172
  }
@@ -37,9 +37,11 @@ const SwirlSelect$1 = /*@__PURE__*/ proxyCustomElement(class SwirlSelect extends
37
37
  this.onOpen = (event) => {
38
38
  this.placement = event.detail.position?.placement;
39
39
  this.open = true;
40
+ this.optionList.querySelector('[tabIndex="0"]')?.focus();
40
41
  };
41
42
  this.onClose = () => {
42
43
  this.open = false;
44
+ this.input.focus();
43
45
  };
44
46
  this.onKeyDown = (event) => {
45
47
  if (event.code === "Space" || event.code === "Enter") {
@@ -92,11 +94,11 @@ const SwirlSelect$1 = /*@__PURE__*/ proxyCustomElement(class SwirlSelect extends
92
94
  "select--inline": this.inline,
93
95
  "select--multi": this.multiSelect,
94
96
  });
95
- return (h(Host, { onKeyDown: this.onKeyDown }, h("div", { class: className }, h("swirl-popover-trigger", { popover: this.popover, setAriaAttributes: false }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled, readOnly: true, type: "text", value: label })), h("span", { class: "select__multi-select-values" }, this.value
97
+ return (h(Host, { onKeyDown: this.onKeyDown }, h("div", { class: className }, h("swirl-popover-trigger", { popover: this.popover, setAriaAttributes: false }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled, readOnly: true, ref: (el) => (this.input = el), type: "text", value: label })), h("span", { class: "select__multi-select-values" }, this.value
96
98
  ?.map((value) => this.options.find((option) => option.value === value))
97
99
  ?.map((option) => (h("swirl-tag", { "aria-hidden": "true", label: option?.label,
98
100
  // eslint-disable-next-line react/jsx-no-bind
99
- onRemove: () => this.unselectOption(option?.value), removable: !this.disabled && this.allowDeselect })))), h("span", { class: "select__indicator" }, this.open ? (h("swirl-icon-expand-less", null)) : (h("swirl-icon-expand-more", null))), h("swirl-popover", { animation: "scale-in-y", class: "select__popover", id: `select-options-${this.selectId}`, label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen, ref: (el) => (this.popover = el), useContainerWidth: "swirl-form-control" }, h("swirl-option-list", { allowDeselect: this.allowDeselect, onValueChange: this.select, multiSelect: this.multiSelect, value: this.value }, h("slot", { onSlotchange: this.onSlotChange }))))));
101
+ onRemove: () => this.unselectOption(option?.value), removable: !this.disabled && this.allowDeselect })))), h("span", { class: "select__indicator" }, this.open ? (h("swirl-icon-expand-less", null)) : (h("swirl-icon-expand-more", null))), h("swirl-popover", { animation: "scale-in-y", class: "select__popover", id: `select-options-${this.selectId}`, label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen, ref: (el) => (this.popover = el), useContainerWidth: "swirl-form-control" }, h("swirl-option-list", { allowDeselect: this.allowDeselect, onValueChange: this.select, multiSelect: this.multiSelect, ref: (el) => (this.optionList = el), value: this.value }, h("slot", { onSlotchange: this.onSlotChange }))))));
100
102
  }
101
103
  get el() { return this; }
102
104
  static get style() { return swirlSelectCss; }
@@ -18,35 +18,25 @@ const SwirlActionList = class {
18
18
  }
19
19
  };
20
20
  }
21
- componentDidLoad() {
22
- this.updateItems();
23
- this.observeSlotChanges();
24
- }
25
- disconnectedCallback() {
26
- this.observer?.disconnect();
27
- }
28
- observeSlotChanges() {
29
- this.observer = new MutationObserver(() => {
30
- this.updateItems();
31
- });
32
- this.observer.observe(this.el, { childList: true });
33
- }
34
- updateItems() {
35
- this.items = querySelectorAllDeep(this.el, '[role="menuitem"]');
21
+ getItems() {
22
+ return querySelectorAllDeep(this.el, '[role="menuitem"]');
36
23
  }
37
24
  focusNextItem() {
25
+ const items = this.getItems();
38
26
  const activeItemIndex = this.getActiveItemIndex();
39
- const newIndex = (activeItemIndex + 1) % this.items.length;
40
- this.items[newIndex].focus();
27
+ const newIndex = (activeItemIndex + 1) % items.length;
28
+ items[newIndex].focus();
41
29
  }
42
30
  focusPreviousItem() {
31
+ const items = this.getItems();
43
32
  const activeItemIndex = this.getActiveItemIndex();
44
- const newIndex = activeItemIndex === 0 ? this.items.length - 1 : activeItemIndex - 1;
45
- this.items[newIndex]?.focus();
33
+ const newIndex = activeItemIndex === 0 ? items.length - 1 : activeItemIndex - 1;
34
+ items[newIndex]?.focus();
46
35
  }
47
36
  getActiveItemIndex() {
37
+ const items = this.getItems();
48
38
  const activeElement = getActiveElement();
49
- return this.items.findIndex((item) => item === activeElement ||
39
+ return items.findIndex((item) => item === activeElement ||
50
40
  item === activeElement?.querySelector('[role="menuitem"]'));
51
41
  }
52
42
  render() {
@@ -311,7 +311,7 @@ const SwirlResourceList = class {
311
311
  this.draggingStartIndex = undefined;
312
312
  };
313
313
  this.onKeyDown = (event) => {
314
- if (event.key === "ArrowDown") {
314
+ if (event.code === "ArrowDown") {
315
315
  event.preventDefault();
316
316
  if (!Boolean(this.dragging)) {
317
317
  this.focusItemAtIndex((this.focusedIndex + 1) % this.items.length);
@@ -320,7 +320,7 @@ const SwirlResourceList = class {
320
320
  this.moveDraggedItemDown();
321
321
  }
322
322
  }
323
- else if (event.key === "ArrowUp") {
323
+ else if (event.code === "ArrowUp") {
324
324
  event.preventDefault();
325
325
  if (!Boolean(this.dragging)) {
326
326
  const prevIndex = this.focusedIndex === 0
@@ -332,7 +332,7 @@ const SwirlResourceList = class {
332
332
  this.moveDraggedItemUp();
333
333
  }
334
334
  }
335
- else if (event.key === "Space" || event.key === "Enter") {
335
+ else if (event.code === "Space" || event.code === "Enter") {
336
336
  const target = event.composedPath()[0];
337
337
  if (Boolean(this.dragging) &&
338
338
  !target?.classList.contains("resource-list-item__drag-handle")) {
@@ -340,11 +340,11 @@ const SwirlResourceList = class {
340
340
  this.stopDrag(this.dragging);
341
341
  }
342
342
  }
343
- else if (event.key === "Home") {
343
+ else if (event.code === "Home") {
344
344
  event.preventDefault();
345
345
  this.focusItemAtIndex(0);
346
346
  }
347
- else if (event.key === "End") {
347
+ else if (event.code === "End") {
348
348
  event.preventDefault();
349
349
  this.focusItemAtIndex(this.items.length - 1);
350
350
  }
@@ -372,7 +372,11 @@ const SwirlResourceList = class {
372
372
  this.setItemAllowDragState();
373
373
  this.setupDragDrop();
374
374
  });
375
- this.observer.observe(this.el, { childList: true });
375
+ this.observer.observe(this.el, {
376
+ childList: true,
377
+ characterData: true,
378
+ subtree: true,
379
+ });
376
380
  }
377
381
  watchAllowDrag() {
378
382
  this.setItemAllowDragState();
@@ -387,9 +391,12 @@ const SwirlResourceList = class {
387
391
  return this.items.map((i) => i).findIndex((i) => i === item);
388
392
  }
389
393
  removeItemsFromTabOrder() {
390
- this.items.forEach((item) => item
391
- ?.querySelector(".resource-list-item__content, .resource-list-file-item")
392
- ?.setAttribute("tabIndex", "-1"));
394
+ this.items.forEach((item) => {
395
+ const focusableEl = item?.querySelector(".resource-list-item__content, .resource-list-file-item");
396
+ const dragHandle = item?.querySelector(".resource-list-item__drag-handle");
397
+ focusableEl?.setAttribute("tabIndex", "-1");
398
+ dragHandle?.setAttribute("tabIndex", "-1");
399
+ });
393
400
  }
394
401
  setItemAllowDragState() {
395
402
  if (this.allowDrag) {
@@ -430,6 +437,10 @@ const SwirlResourceList = class {
430
437
  return;
431
438
  }
432
439
  const interactiveElement = item.querySelector(".resource-list-item__content, .resource-list-file-item");
440
+ const dragHandle = item.querySelector(".resource-list-item__drag-handle");
441
+ if (Boolean(dragHandle)) {
442
+ dragHandle.setAttribute("tabIndex", "0");
443
+ }
433
444
  if (!Boolean(interactiveElement)) {
434
445
  return;
435
446
  }
@@ -37,8 +37,16 @@ const SwirlAutocomplete = class {
37
37
  !this.value.some((item) => item.id === suggestion.id)),
38
38
  ];
39
39
  this.valueChange.emit(this.value);
40
- this.inputEl.querySelector("input")?.focus();
41
- await this.updateSuggestions(this.inputEl.querySelector("input").value);
40
+ this.inputEl.value = "";
41
+ const input = this.inputEl.querySelector("input");
42
+ if (Boolean(input)) {
43
+ input.value = "";
44
+ queueMicrotask(() => {
45
+ input.focus();
46
+ this.close();
47
+ });
48
+ this.updateSuggestions(input.value);
49
+ }
42
50
  }
43
51
  else {
44
52
  if (Boolean(event.detail[0])) {
@@ -1144,7 +1144,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
1144
1144
  return trap;
1145
1145
  };
1146
1146
 
1147
- const swirlModalCss = ":host{display:block}:host *{box-sizing:border-box}.modal{--swirl-ghost-button-background-default:var(--s-surface-overlay-default);--swirl-ghost-button-background-hovered:var(--s-surface-overlay-hovered);--swirl-ghost-button-background-pressed:var(--s-surface-overlay-pressed);--swirl-resource-list-item-background-default:var(\n --s-surface-overlay-default\n );--swirl-resource-list-item-background-hovered:var(\n --s-surface-overlay-hovered\n );--swirl-resource-list-item-background-pressed:var(\n --s-surface-overlay-pressed\n );--swirl-modal-height:auto;--swirl-modal-max-height:90vh;position:fixed;z-index:var(--s-z-40);display:flex;justify-content:center;align-items:center;inset:0}.modal[aria-hidden=\"true\"]{display:none}.modal--variant-default.modal--closing{animation:0.15s modal-fade-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-default.modal--closing{animation:none}}.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:0.15s modal-backdrop-fade-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:none}}.modal--variant-default:not(.modal--closing) .modal__body{animation:0.15s modal-scale-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__body{animation:none}}.modal--variant-drawer{justify-content:end;align-items:stretch}.modal--variant-drawer.modal--closing{animation:0.15s modal-drawer-slide-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-drawer.modal--closing{animation:none}}@media (min-width: 768px){.modal--variant-drawer.modal--hide-label .modal__header-bar{height:auto;padding-top:var(--s-space-4);padding-bottom:var(--s-space-4)}}.modal--variant-drawer .modal__backdrop{background-color:transparent;animation:none}.modal--variant-drawer .modal__body{height:100%;max-height:none;border-radius:0;animation:0.15s modal-drawer-slide-in;box-shadow:var(--s-shadow-level-3)}@media (prefers-reduced-motion){.modal--variant-drawer .modal__body{animation:none}}.modal--variant-drawer .modal__header-bar{background-color:var(--s-surface-overlay-default)}.modal--variant-drawer .modal__header-bar .modal__close-button{margin-left:calc(-1 * var(--s-space-8))}@media (min-width: 768px){.modal--variant-drawer .modal__header-bar{flex-direction:row}}@media (min-width: 768px){.modal--variant-drawer.modal--padded .modal__content{padding-top:var(--s-space-8)}}.modal--padded .modal__content{padding-top:var(--s-space-24);padding-right:var(--s-space-16);padding-bottom:var(--s-space-24);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal--padded .modal__content{padding-top:0;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}}@media (min-width: 768px){.modal--scrollable .modal__content{padding-bottom:0}}.modal--scrollable:not(.modal--scrolled-down).modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--scrollable:not(.modal--scrolled-down):not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-custom-header .modal__content{padding-top:var(--s-space-16)}.modal--has-custom-footer .modal__custom-footer{padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}.modal--has-header-tools .modal__header{border-bottom-color:transparent}.modal--has-header-tools .modal__header-tools{display:block}.modal--has-secondary-content .modal__body{max-width:64rem}.modal--has-secondary-content:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-secondary-content:not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 992px){.modal--has-secondary-content .modal__header-tools,.modal--has-secondary-content .modal__content{padding-right:0}}.modal--has-secondary-content .modal__primary-content{overflow:visible;max-height:60%;flex-basis:auto}@media (min-width: 992px){.modal--has-secondary-content .modal__primary-content{max-height:none;flex-basis:calc(100% - 24rem)}}.modal--has-secondary-content .modal__secondary-content{display:block}@media (min-width: 768px){.modal--scrolled:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--scrolled.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}}.modal__backdrop{position:fixed;background-color:rgba(0, 0, 0, 0.2);inset:0}.modal__body{position:relative;z-index:var(--s-z-40);display:flex;overflow:hidden;width:100vw;max-width:40rem;height:100vh;background-color:var(--s-surface-overlay-default);flex-direction:column}@media (min-width: 768px){.modal__body{width:90vw;max-height:var(--swirl-modal-max-height);border-radius:var(--s-border-radius-base);box-shadow:var(--s-shadow-level-3)}}@media (min-width: 992px){.modal__body{height:var(--swirl-modal-height)}}.modal__header{border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header{border-bottom:var(--s-border-width-default) solid transparent}}.modal__header-bar{display:flex;height:3.5rem;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-shrink:0;align-items:center;gap:var(--s-space-8)}@media (min-width: 768px){.modal__header-bar{height:4.125rem;padding-top:var(--s-space-24);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-direction:row-reverse;gap:var(--s-space-16)}}.modal__header-tools{display:none;padding-right:var(--s-space-16);padding-left:var(--s-space-16);border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header-tools{padding-right:var(--s-space-24);padding-left:var(--s-space-24);border-bottom-color:transparent}}.modal__custom-header{flex-shrink:0;border-bottom:var(--s-border-width-default) solid var(--s-border-default)}.modal__heading{overflow:hidden}.modal__heading .heading{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.modal__content-container{display:flex;overflow:hidden;flex-grow:1;flex-direction:column;gap:var(--s-space-24)}@media (min-width: 992px){.modal__content-container{flex-direction:row}}.modal__primary-content{display:flex;overflow:hidden;flex-basis:100%;flex-direction:column}.modal__content{overflow-x:hidden;overflow-y:auto}.modal__content ::slotted(*){margin:0}.modal__secondary-content{display:none;overflow:visible;overflow-x:hidden;overflow-y:auto;max-width:none;max-height:40%;padding-right:var(--s-space-16);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal__secondary-content{padding-left:var(--s-space-24)}}@media (min-width: 992px){.modal__secondary-content{overflow-x:hidden;overflow-y:auto;max-width:24rem;max-height:none;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:0;flex-basis:50%}}.modal__custom-footer{flex-shrink:0}.modal__controls{display:flex;padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-shrink:0;justify-content:flex-end}@keyframes modal-scale-in{from{transform:scale(0)}to{transform:scale(1)}}@keyframes modal-backdrop-fade-in{from{opacity:0}to{opacity:1}}@keyframes modal-fade-out{from{opacity:1}to{opacity:0}}@keyframes modal-drawer-slide-in{from{transform:translate3d(100%, 0, 0)}to{transform:translate3d(0, 0, 0)}}@keyframes modal-drawer-slide-out{from{transform:translate3d(0, 0, 0)}to{transform:translate3d(100%, 0, 0)}}";
1147
+ const swirlModalCss = ":host{display:block}:host *{box-sizing:border-box}.modal{--swirl-ghost-button-background-default:var(--s-surface-overlay-default);--swirl-ghost-button-background-hovered:var(--s-surface-overlay-hovered);--swirl-ghost-button-background-pressed:var(--s-surface-overlay-pressed);--swirl-resource-list-item-background-default:var(\n --s-surface-overlay-default\n );--swirl-resource-list-item-background-hovered:var(\n --s-surface-overlay-hovered\n );--swirl-resource-list-item-background-pressed:var(\n --s-surface-overlay-pressed\n );--swirl-modal-height:auto;--swirl-modal-max-height:90vh;position:fixed;z-index:var(--s-z-40);display:flex;justify-content:center;align-items:center;inset:0}.modal[aria-hidden=\"true\"]{display:none}.modal--variant-default.modal--closing{animation:0.15s modal-fade-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-default.modal--closing{animation:none}}.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:0.15s modal-backdrop-fade-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:none}}.modal--variant-default:not(.modal--closing) .modal__body{animation:0.15s modal-scale-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__body{animation:none}}.modal--variant-drawer{justify-content:end;align-items:stretch}.modal--variant-drawer.modal--closing{animation:0.15s modal-drawer-slide-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-drawer.modal--closing{animation:none}}@media (min-width: 768px){.modal--variant-drawer.modal--hide-label .modal__header-bar{height:auto;padding-top:var(--s-space-4);padding-bottom:var(--s-space-4)}}.modal--variant-drawer .modal__backdrop{background-color:transparent;animation:none}.modal--variant-drawer .modal__body{height:100%;max-height:none;border-radius:0;animation:0.15s modal-drawer-slide-in;box-shadow:var(--s-shadow-level-3)}@media (prefers-reduced-motion){.modal--variant-drawer .modal__body{animation:none}}.modal--variant-drawer .modal__header-bar{background-color:var(--s-surface-overlay-default)}.modal--variant-drawer .modal__header-bar .modal__close-button{margin-left:calc(-1 * var(--s-space-8))}@media (min-width: 768px){.modal--variant-drawer .modal__header-bar{flex-direction:row}}@media (min-width: 768px){.modal--variant-drawer.modal--padded .modal__content{padding-top:var(--s-space-8)}}.modal--padded .modal__content{padding-top:var(--s-space-24);padding-right:var(--s-space-16);padding-bottom:var(--s-space-24);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal--padded .modal__content{padding-top:0;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}}@media (min-width: 768px){.modal--scrollable .modal__content{padding-bottom:0}}.modal--scrollable:not(.modal--scrolled-down).modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--scrollable:not(.modal--scrolled-down):not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-custom-header .modal__content{padding-top:var(--s-space-16)}.modal--has-custom-footer .modal__custom-footer{padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}.modal--has-header-tools .modal__header{border-bottom-color:transparent}.modal--has-header-tools .modal__header-tools{display:block}.modal--has-secondary-content .modal__body{max-width:64rem}.modal--has-secondary-content:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-secondary-content:not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 992px){.modal--has-secondary-content .modal__header-tools,.modal--has-secondary-content .modal__content{padding-right:0}}.modal--has-secondary-content .modal__primary-content{overflow:visible;max-height:60%;flex-basis:auto}@media (min-width: 992px){.modal--has-secondary-content .modal__primary-content{max-width:calc(100% - 24rem);max-height:none;flex-basis:calc(100% - 24rem)}}.modal--has-secondary-content .modal__secondary-content{display:block}@media (min-width: 768px){.modal--scrolled:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--scrolled.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}}.modal__backdrop{position:fixed;background-color:rgba(0, 0, 0, 0.2);inset:0}.modal__body{position:relative;z-index:var(--s-z-40);display:flex;overflow:hidden;width:100vw;max-width:40rem;height:100vh;background-color:var(--s-surface-overlay-default);flex-direction:column}@media (min-width: 768px){.modal__body{width:90vw;max-height:var(--swirl-modal-max-height);border-radius:var(--s-border-radius-base);box-shadow:var(--s-shadow-level-3)}}@media (min-width: 992px){.modal__body{height:var(--swirl-modal-height)}}.modal__header{border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header{border-bottom:var(--s-border-width-default) solid transparent}}.modal__header-bar{display:flex;height:3.5rem;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-shrink:0;align-items:center;gap:var(--s-space-8)}@media (min-width: 768px){.modal__header-bar{height:4.125rem;padding-top:var(--s-space-24);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-direction:row-reverse;gap:var(--s-space-16)}}.modal__header-tools{display:none;padding-right:var(--s-space-16);padding-left:var(--s-space-16);border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header-tools{padding-right:var(--s-space-24);padding-left:var(--s-space-24);border-bottom-color:transparent}}.modal__custom-header{flex-shrink:0;border-bottom:var(--s-border-width-default) solid var(--s-border-default)}.modal__heading{overflow:hidden}.modal__heading .heading{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.modal__content-container{display:flex;overflow:hidden;flex-grow:1;flex-direction:column;gap:var(--s-space-24)}@media (min-width: 992px){.modal__content-container{flex-direction:row}}.modal__primary-content{display:flex;overflow:hidden;flex-basis:100%;flex-direction:column}.modal__content{overflow-x:hidden;overflow-y:auto}.modal__content ::slotted(*){margin:0}.modal__secondary-content{display:none;overflow:visible;overflow-x:hidden;overflow-y:auto;max-width:none;max-height:40%;padding-right:var(--s-space-16);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal__secondary-content{padding-left:var(--s-space-24)}}@media (min-width: 992px){.modal__secondary-content{overflow-x:hidden;overflow-y:auto;max-width:24rem;max-height:none;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:0;flex-basis:50%}}.modal__custom-footer{flex-shrink:0}.modal__controls{display:flex;padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-shrink:0;justify-content:flex-end}@keyframes modal-scale-in{from{transform:scale(0)}to{transform:scale(1)}}@keyframes modal-backdrop-fade-in{from{opacity:0}to{opacity:1}}@keyframes modal-fade-out{from{opacity:1}to{opacity:0}}@keyframes modal-drawer-slide-in{from{transform:translate3d(100%, 0, 0)}to{transform:translate3d(0, 0, 0)}}@keyframes modal-drawer-slide-out{from{transform:translate3d(0, 0, 0)}to{transform:translate3d(100%, 0, 0)}}";
1148
1148
 
1149
1149
  const SwirlModal = class {
1150
1150
  constructor(hostRef) {
@@ -301,9 +301,11 @@ const SwirlOptionList = class {
301
301
  this.focusItem(newIndex);
302
302
  }
303
303
  getActiveItemIndex() {
304
- return this.items
305
- .map((item) => item.querySelector('[role="option"]'))
306
- .findIndex((item) => item === this.focusedItem);
304
+ return Boolean(this.focusedItem)
305
+ ? this.items
306
+ .map((item) => item.querySelector('[role="option"]'))
307
+ .findIndex((item) => item === this.focusedItem)
308
+ : 0;
307
309
  }
308
310
  getItemIndex(item) {
309
311
  return this.items.map((i) => i).findIndex((i) => i === item);
@@ -28,9 +28,11 @@ const SwirlSelect = class {
28
28
  this.onOpen = (event) => {
29
29
  this.placement = event.detail.position?.placement;
30
30
  this.open = true;
31
+ this.optionList.querySelector('[tabIndex="0"]')?.focus();
31
32
  };
32
33
  this.onClose = () => {
33
34
  this.open = false;
35
+ this.input.focus();
34
36
  };
35
37
  this.onKeyDown = (event) => {
36
38
  if (event.code === "Space" || event.code === "Enter") {
@@ -83,11 +85,11 @@ const SwirlSelect = class {
83
85
  "select--inline": this.inline,
84
86
  "select--multi": this.multiSelect,
85
87
  });
86
- return (h(Host, { onKeyDown: this.onKeyDown }, h("div", { class: className }, h("swirl-popover-trigger", { popover: this.popover, setAriaAttributes: false }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled, readOnly: true, type: "text", value: label })), h("span", { class: "select__multi-select-values" }, this.value
88
+ return (h(Host, { onKeyDown: this.onKeyDown }, h("div", { class: className }, h("swirl-popover-trigger", { popover: this.popover, setAriaAttributes: false }, h("input", { "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, class: "select__input", disabled: this.disabled, readOnly: true, ref: (el) => (this.input = el), type: "text", value: label })), h("span", { class: "select__multi-select-values" }, this.value
87
89
  ?.map((value) => this.options.find((option) => option.value === value))
88
90
  ?.map((option) => (h("swirl-tag", { "aria-hidden": "true", label: option?.label,
89
91
  // eslint-disable-next-line react/jsx-no-bind
90
- onRemove: () => this.unselectOption(option?.value), removable: !this.disabled && this.allowDeselect })))), h("span", { class: "select__indicator" }, this.open ? (h("swirl-icon-expand-less", null)) : (h("swirl-icon-expand-more", null))), h("swirl-popover", { animation: "scale-in-y", class: "select__popover", id: `select-options-${this.selectId}`, label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen, ref: (el) => (this.popover = el), useContainerWidth: "swirl-form-control" }, h("swirl-option-list", { allowDeselect: this.allowDeselect, onValueChange: this.select, multiSelect: this.multiSelect, value: this.value }, h("slot", { onSlotchange: this.onSlotChange }))))));
92
+ onRemove: () => this.unselectOption(option?.value), removable: !this.disabled && this.allowDeselect })))), h("span", { class: "select__indicator" }, this.open ? (h("swirl-icon-expand-less", null)) : (h("swirl-icon-expand-more", null))), h("swirl-popover", { animation: "scale-in-y", class: "select__popover", id: `select-options-${this.selectId}`, label: this.label, offset: [0, offset], onPopoverClose: this.onClose, onPopoverOpen: this.onOpen, ref: (el) => (this.popover = el), useContainerWidth: "swirl-form-control" }, h("swirl-option-list", { allowDeselect: this.allowDeselect, onValueChange: this.select, multiSelect: this.multiSelect, ref: (el) => (this.optionList = el), value: this.value }, h("slot", { onSlotchange: this.onSlotChange }))))));
91
93
  }
92
94
  get el() { return getElement(this); }
93
95
  };
@@ -1 +1 @@
1
- import{r as t,c as i,h as s,H as o,g as e}from"./p-3fca9a05.js";import{c as a,q as n}from"./p-646e00de.js";import{S as h}from"./p-1486d7ea.js";import{c as r}from"./p-b7898321.js";const l=class{constructor(s){t(this,s),this.itemDrop=i(this,"itemDrop",7),this.valueChange=i(this,"valueChange",7),this.onClick=t=>{t.preventDefault();const i=t.target,s=i?.closest("swirl-option-list-item"),o=t.composedPath()[0],e=Boolean(a(o,'[role="option"]'));Boolean(s)&&e?this.selectItem(this.items.findIndex((t=>t.value===s.value))):t.preventDefault()},this.onKeyDown=t=>{if("ArrowDown"===t.code)t.preventDefault(),Boolean(this.dragging)?this.moveDraggedItemDown():this.focusNextItem();else if("ArrowUp"===t.code)t.preventDefault(),Boolean(this.dragging)?this.moveDraggedItemUp():this.focusPreviousItem();else if("Space"===t.code||"Enter"===t.code){if(!t.target.classList.contains("option-list-item__drag-handle")&&Boolean(this.dragging))return t.preventDefault(),void this.stopDrag(this.dragging);const i=t.composedPath()[0];if(!Boolean(a(i,'[role="option"]')))return;t.preventDefault(),Boolean(this.dragging)?this.stopDrag(this.dragging):this.selectFocusedItem()}else"Home"===t.code?(t.preventDefault(),this.focusItem(0)):"End"===t.code?(t.preventDefault(),this.focusItem(this.items.length-1)):"KeyA"===t.code&&(t.metaKey||t.ctrlKey)&&this.multiSelect?(t.preventDefault(),this.selectAllItems()):"Tab"===t.code&&Boolean(this.dragging)&&t.preventDefault()},this.toggleDrag=t=>{const i=t.detail;Boolean(this.dragging)?this.stopDrag(i):this.startDrag(i)},this.startDrag=t=>{this.dragging=t,this.draggingStartIndex=this.getItemIndex(this.dragging),t.setAttribute("dragging","true");const i=this.getItemIndex(this.dragging);this.focusItem(i),this.assistiveText=this.assistiveTextItemGrabbed},this.stopDrag=t=>{this.dragging=void 0,t.removeAttribute("dragging");const i=this.getActiveItemIndex();this.assistiveText=`${this.assistiveTextItemMoved} ${i+1}`,this.itemDrop.emit({item:t,oldIndex:this.draggingStartIndex,newIndex:i}),this.draggingStartIndex=void 0,this.focusItem(i)},this.allowDeselect=!0,this.allowDrag=void 0,this.assistiveTextItemGrabbed="Item grabbed. Use arrow keys to move item up or down. Use spacebar to save position.",this.assistiveTextItemMoving="Current position:",this.assistiveTextItemMoved="Item moved. New position:",this.disabled=void 0,this.label=void 0,this.optionListId=void 0,this.multiSelect=void 0,this.value=[],this.assistiveText=void 0}componentDidLoad(){this.updateItems(),this.observeSlotChanges(),this.setItemAllowDragState(),this.setItemDisabledState(),this.setItemContext(),this.syncItemsWithValue(),this.setupDragDrop()}componentDidRender(){this.setupDragDrop()}disconnectedCallback(){this.observer?.disconnect(),this.sortable?.destroy()}watchAllowDrag(){this.setItemAllowDragState(),this.setupDragDrop()}watchDisabled(){this.setItemDisabledState()}watchMultiSelect(){this.setItemContext()}watchValue(){this.syncItemsWithValue()}observeSlotChanges(){this.observer=new MutationObserver((()=>{this.updateItems(),this.setItemAllowDragState(),this.setItemDisabledState(),this.setItemContext(),this.syncItemsWithValue()})),this.observer.observe(this.listboxEl,{childList:!0})}updateItems(){this.items=n(this.el,"swirl-option-list-item"),this.items.forEach((t=>t.querySelector('[role="option"]')?.removeAttribute("tabIndex")));const t=this.items[0]?.querySelector('[role="option"]');Boolean(t)&&t.setAttribute("tabIndex","0")}setItemDisabledState(){this.disabled&&this.items.forEach((t=>t.disabled=!0))}setItemContext(){this.multiSelect?this.items.forEach((t=>t.context="multi-select")):(this.items.forEach((t=>t.context="single-select")),this.value.length>1&&this.updateValue([this.value[0]]))}setupDragDrop(){Boolean(this.sortable)&&this.sortable.destroy(),this.allowDrag&&(this.sortable=h.create(this.listboxEl,{animation:150,draggable:"swirl-option-list-item",handle:".option-list-item__drag-handle",onEnd:t=>{this.itemDrop.emit({item:t.item,oldIndex:t.oldIndex,newIndex:t.newIndex})}}))}setItemAllowDragState(){if(this.allowDrag&&!this.multiSelect)return void console.error("[SwirlOptionList] Drag can only be allowed for multi select lists.");const t=n(this.el,"swirl-option-list-section");this.allowDrag&&t.length>0?console.error("[SwirlOptionList] Drag can only be allowed for lists without sections."):this.items.forEach(this.allowDrag?t=>{t.setAttribute("allow-drag","true"),t.addEventListener("toggleDrag",this.toggleDrag)}:t=>{t.removeAttribute("allow-drag"),t.removeEventListener("toggleDrag",this.toggleDrag)})}selectItem(t){if(this.disabled)return;const i=this.items[t];if(i.disabled)return;const s=this.value.includes(i.value);s&&!this.allowDeselect||(this.multiSelect||(this.value=[]),this.updateValue(s?this.value.filter((t=>t!==i.value)):[...this.value,i.value]),this.focusItem(t))}updateValue(t){this.value=t,this.valueChange.emit(this.value)}selectFocusedItem(){this.disabled||-1===this.getActiveItemIndex()||this.selectItem(this.getActiveItemIndex())}selectAllItems(){if(this.disabled)return;const t=this.items.every((t=>this.value.includes(t.value)));this.updateValue(t?[]:this.items.map((t=>t.value)))}syncItemsWithValue(){this.items?.forEach((t=>t.selected=this.value.includes(t.value)))}focusItem(t){if(this.disabled)return;this.items.forEach((t=>t.querySelector('[role="option"]').removeAttribute("tabIndex")));const i=this.items[t]?.querySelector('[role="option"]');Boolean(i)&&(i.setAttribute("tabIndex","0"),i.focus(),this.focusedItem=i)}focusNextItem(){if(this.disabled)return;const t=this.getActiveItemIndex(),i=Math.min(t+1,this.items.length-1);this.focusItem(i)}focusPreviousItem(){const t=this.getActiveItemIndex(),i=Math.max(t-1,0);this.focusItem(i)}getActiveItemIndex(){return this.items.map((t=>t.querySelector('[role="option"]'))).findIndex((t=>t===this.focusedItem))}getItemIndex(t){return this.items.map((t=>t)).findIndex((i=>i===t))}moveDraggedItemDown(){const t=this.dragging.nextElementSibling;Boolean(t)&&(t.after(this.dragging),this.updateItems(),this.listboxEl.focus(),this.assistiveText=`${this.assistiveTextItemMoving} ${this.getActiveItemIndex()+1}`)}moveDraggedItemUp(){const t=this.dragging.previousElementSibling;Boolean(t)&&(t.before(this.dragging),this.updateItems(),this.listboxEl.focus(),this.assistiveText=`${this.assistiveTextItemMoving} ${this.getItemIndex(this.dragging)+1}`)}render(){const t=this.multiSelect?"true":void 0,i=Boolean(this.dragging)?0:void 0;return s(o,null,s("swirl-visually-hidden",{role:"alert"},this.assistiveText),s("div",{"aria-label":this.label,"aria-multiselectable":t,class:"option-list",id:this.optionListId,onClick:this.onClick,onKeyDown:this.onKeyDown,ref:t=>this.listboxEl=t,role:"listbox",tabIndex:i},s("slot",null)))}get el(){return e(this)}static get watchers(){return{allowDrag:["watchAllowDrag"],disabled:["watchDisabled"],multiSelect:["watchMultiSelect"],value:["watchValue"]}}};l.style=".sc-swirl-option-list-h{display:block}.sc-swirl-option-list-h *.sc-swirl-option-list{box-sizing:border-box}";const c=class{constructor(s){t(this,s),this.remove=i(this,"remove",7),this.onRemove=t=>{this.remove?.emit(t)},this.intent="default",this.label=void 0,this.removable=void 0,this.removalButtonLabel="Remove"}render(){const t=r("tag",`tag--intent-${this.intent}`);return s(o,null,s("span",{class:t,part:"tag"},s("span",{class:"tag__label"},this.label),this.removable&&s("button",{"aria-label":this.removalButtonLabel,class:"tag__removal-button",onClick:this.onRemove,tabIndex:"true"===this.el.ariaHidden?-1:void 0,type:"button"},s("swirl-icon-close",{size:16}))))}get el(){return e(this)}};c.style=":host{display:inline-flex;max-width:100%}:host *{box-sizing:border-box}.tag{display:inline-flex;max-width:100%;padding:var(--s-space-2) var(--s-space-8);align-items:center;border-radius:var(--s-border-radius-s);color:var(--s-text-default);background-color:var(--s-surface-neutral-subdued);font-size:var(--s-font-size-sm);font-weight:var(--s-font-weight-medium);line-height:var(--s-line-height-sm);white-space:nowrap;gap:var(--s-space-4)}.tag--intent-info{color:var(--s-text-info);background-color:var(--s-surface-info-subdued)}.tag--intent-info .tag__removal-button{color:var(--icon-info)}.tag--intent-critical{color:var(--s-text-critical);background-color:var(--s-surface-critical-subdued)}.tag--intent-critical .tag__removal-button{color:var(--icon-critical)}.tag--intent-warning{color:var(--s-text-warning);background-color:var(--s-surface-warning-subdued)}.tag--intent-warning .tag__removal-button{color:var(--icon-warning)}.tag--intent-success{color:var(--s-text-success);background-color:var(--s-surface-success-subdued)}.tag--intent-success .tag__removal-button{color:var(--icon-success)}.tag__label{overflow:hidden;min-width:0;white-space:nowrap;text-overflow:ellipsis}.tag__removal-button{display:inline-flex;margin-right:calc(-1 * var(--s-space-4));padding:0;border:none;color:var(--s-icon-strong);background-color:transparent;cursor:pointer}.tag__removal-button:focus:not(:focus-visible){outline:none}.tag__removal-button:focus-visible{outline-color:var(--s-focus-default)}";export{l as swirl_option_list,c as swirl_tag}
1
+ import{r as t,c as i,h as s,H as o,g as e}from"./p-3fca9a05.js";import{c as a,q as n}from"./p-646e00de.js";import{S as h}from"./p-1486d7ea.js";import{c as r}from"./p-b7898321.js";const l=class{constructor(s){t(this,s),this.itemDrop=i(this,"itemDrop",7),this.valueChange=i(this,"valueChange",7),this.onClick=t=>{t.preventDefault();const i=t.target,s=i?.closest("swirl-option-list-item"),o=t.composedPath()[0],e=Boolean(a(o,'[role="option"]'));Boolean(s)&&e?this.selectItem(this.items.findIndex((t=>t.value===s.value))):t.preventDefault()},this.onKeyDown=t=>{if("ArrowDown"===t.code)t.preventDefault(),Boolean(this.dragging)?this.moveDraggedItemDown():this.focusNextItem();else if("ArrowUp"===t.code)t.preventDefault(),Boolean(this.dragging)?this.moveDraggedItemUp():this.focusPreviousItem();else if("Space"===t.code||"Enter"===t.code){if(!t.target.classList.contains("option-list-item__drag-handle")&&Boolean(this.dragging))return t.preventDefault(),void this.stopDrag(this.dragging);const i=t.composedPath()[0];if(!Boolean(a(i,'[role="option"]')))return;t.preventDefault(),Boolean(this.dragging)?this.stopDrag(this.dragging):this.selectFocusedItem()}else"Home"===t.code?(t.preventDefault(),this.focusItem(0)):"End"===t.code?(t.preventDefault(),this.focusItem(this.items.length-1)):"KeyA"===t.code&&(t.metaKey||t.ctrlKey)&&this.multiSelect?(t.preventDefault(),this.selectAllItems()):"Tab"===t.code&&Boolean(this.dragging)&&t.preventDefault()},this.toggleDrag=t=>{const i=t.detail;Boolean(this.dragging)?this.stopDrag(i):this.startDrag(i)},this.startDrag=t=>{this.dragging=t,this.draggingStartIndex=this.getItemIndex(this.dragging),t.setAttribute("dragging","true");const i=this.getItemIndex(this.dragging);this.focusItem(i),this.assistiveText=this.assistiveTextItemGrabbed},this.stopDrag=t=>{this.dragging=void 0,t.removeAttribute("dragging");const i=this.getActiveItemIndex();this.assistiveText=`${this.assistiveTextItemMoved} ${i+1}`,this.itemDrop.emit({item:t,oldIndex:this.draggingStartIndex,newIndex:i}),this.draggingStartIndex=void 0,this.focusItem(i)},this.allowDeselect=!0,this.allowDrag=void 0,this.assistiveTextItemGrabbed="Item grabbed. Use arrow keys to move item up or down. Use spacebar to save position.",this.assistiveTextItemMoving="Current position:",this.assistiveTextItemMoved="Item moved. New position:",this.disabled=void 0,this.label=void 0,this.optionListId=void 0,this.multiSelect=void 0,this.value=[],this.assistiveText=void 0}componentDidLoad(){this.updateItems(),this.observeSlotChanges(),this.setItemAllowDragState(),this.setItemDisabledState(),this.setItemContext(),this.syncItemsWithValue(),this.setupDragDrop()}componentDidRender(){this.setupDragDrop()}disconnectedCallback(){this.observer?.disconnect(),this.sortable?.destroy()}watchAllowDrag(){this.setItemAllowDragState(),this.setupDragDrop()}watchDisabled(){this.setItemDisabledState()}watchMultiSelect(){this.setItemContext()}watchValue(){this.syncItemsWithValue()}observeSlotChanges(){this.observer=new MutationObserver((()=>{this.updateItems(),this.setItemAllowDragState(),this.setItemDisabledState(),this.setItemContext(),this.syncItemsWithValue()})),this.observer.observe(this.listboxEl,{childList:!0})}updateItems(){this.items=n(this.el,"swirl-option-list-item"),this.items.forEach((t=>t.querySelector('[role="option"]')?.removeAttribute("tabIndex")));const t=this.items[0]?.querySelector('[role="option"]');Boolean(t)&&t.setAttribute("tabIndex","0")}setItemDisabledState(){this.disabled&&this.items.forEach((t=>t.disabled=!0))}setItemContext(){this.multiSelect?this.items.forEach((t=>t.context="multi-select")):(this.items.forEach((t=>t.context="single-select")),this.value.length>1&&this.updateValue([this.value[0]]))}setupDragDrop(){Boolean(this.sortable)&&this.sortable.destroy(),this.allowDrag&&(this.sortable=h.create(this.listboxEl,{animation:150,draggable:"swirl-option-list-item",handle:".option-list-item__drag-handle",onEnd:t=>{this.itemDrop.emit({item:t.item,oldIndex:t.oldIndex,newIndex:t.newIndex})}}))}setItemAllowDragState(){if(this.allowDrag&&!this.multiSelect)return void console.error("[SwirlOptionList] Drag can only be allowed for multi select lists.");const t=n(this.el,"swirl-option-list-section");this.allowDrag&&t.length>0?console.error("[SwirlOptionList] Drag can only be allowed for lists without sections."):this.items.forEach(this.allowDrag?t=>{t.setAttribute("allow-drag","true"),t.addEventListener("toggleDrag",this.toggleDrag)}:t=>{t.removeAttribute("allow-drag"),t.removeEventListener("toggleDrag",this.toggleDrag)})}selectItem(t){if(this.disabled)return;const i=this.items[t];if(i.disabled)return;const s=this.value.includes(i.value);s&&!this.allowDeselect||(this.multiSelect||(this.value=[]),this.updateValue(s?this.value.filter((t=>t!==i.value)):[...this.value,i.value]),this.focusItem(t))}updateValue(t){this.value=t,this.valueChange.emit(this.value)}selectFocusedItem(){this.disabled||-1===this.getActiveItemIndex()||this.selectItem(this.getActiveItemIndex())}selectAllItems(){if(this.disabled)return;const t=this.items.every((t=>this.value.includes(t.value)));this.updateValue(t?[]:this.items.map((t=>t.value)))}syncItemsWithValue(){this.items?.forEach((t=>t.selected=this.value.includes(t.value)))}focusItem(t){if(this.disabled)return;this.items.forEach((t=>t.querySelector('[role="option"]').removeAttribute("tabIndex")));const i=this.items[t]?.querySelector('[role="option"]');Boolean(i)&&(i.setAttribute("tabIndex","0"),i.focus(),this.focusedItem=i)}focusNextItem(){if(this.disabled)return;const t=this.getActiveItemIndex(),i=Math.min(t+1,this.items.length-1);this.focusItem(i)}focusPreviousItem(){const t=this.getActiveItemIndex(),i=Math.max(t-1,0);this.focusItem(i)}getActiveItemIndex(){return Boolean(this.focusedItem)?this.items.map((t=>t.querySelector('[role="option"]'))).findIndex((t=>t===this.focusedItem)):0}getItemIndex(t){return this.items.map((t=>t)).findIndex((i=>i===t))}moveDraggedItemDown(){const t=this.dragging.nextElementSibling;Boolean(t)&&(t.after(this.dragging),this.updateItems(),this.listboxEl.focus(),this.assistiveText=`${this.assistiveTextItemMoving} ${this.getActiveItemIndex()+1}`)}moveDraggedItemUp(){const t=this.dragging.previousElementSibling;Boolean(t)&&(t.before(this.dragging),this.updateItems(),this.listboxEl.focus(),this.assistiveText=`${this.assistiveTextItemMoving} ${this.getItemIndex(this.dragging)+1}`)}render(){const t=this.multiSelect?"true":void 0,i=Boolean(this.dragging)?0:void 0;return s(o,null,s("swirl-visually-hidden",{role:"alert"},this.assistiveText),s("div",{"aria-label":this.label,"aria-multiselectable":t,class:"option-list",id:this.optionListId,onClick:this.onClick,onKeyDown:this.onKeyDown,ref:t=>this.listboxEl=t,role:"listbox",tabIndex:i},s("slot",null)))}get el(){return e(this)}static get watchers(){return{allowDrag:["watchAllowDrag"],disabled:["watchDisabled"],multiSelect:["watchMultiSelect"],value:["watchValue"]}}};l.style=".sc-swirl-option-list-h{display:block}.sc-swirl-option-list-h *.sc-swirl-option-list{box-sizing:border-box}";const c=class{constructor(s){t(this,s),this.remove=i(this,"remove",7),this.onRemove=t=>{this.remove?.emit(t)},this.intent="default",this.label=void 0,this.removable=void 0,this.removalButtonLabel="Remove"}render(){const t=r("tag",`tag--intent-${this.intent}`);return s(o,null,s("span",{class:t,part:"tag"},s("span",{class:"tag__label"},this.label),this.removable&&s("button",{"aria-label":this.removalButtonLabel,class:"tag__removal-button",onClick:this.onRemove,tabIndex:"true"===this.el.ariaHidden?-1:void 0,type:"button"},s("swirl-icon-close",{size:16}))))}get el(){return e(this)}};c.style=":host{display:inline-flex;max-width:100%}:host *{box-sizing:border-box}.tag{display:inline-flex;max-width:100%;padding:var(--s-space-2) var(--s-space-8);align-items:center;border-radius:var(--s-border-radius-s);color:var(--s-text-default);background-color:var(--s-surface-neutral-subdued);font-size:var(--s-font-size-sm);font-weight:var(--s-font-weight-medium);line-height:var(--s-line-height-sm);white-space:nowrap;gap:var(--s-space-4)}.tag--intent-info{color:var(--s-text-info);background-color:var(--s-surface-info-subdued)}.tag--intent-info .tag__removal-button{color:var(--icon-info)}.tag--intent-critical{color:var(--s-text-critical);background-color:var(--s-surface-critical-subdued)}.tag--intent-critical .tag__removal-button{color:var(--icon-critical)}.tag--intent-warning{color:var(--s-text-warning);background-color:var(--s-surface-warning-subdued)}.tag--intent-warning .tag__removal-button{color:var(--icon-warning)}.tag--intent-success{color:var(--s-text-success);background-color:var(--s-surface-success-subdued)}.tag--intent-success .tag__removal-button{color:var(--icon-success)}.tag__label{overflow:hidden;min-width:0;white-space:nowrap;text-overflow:ellipsis}.tag__removal-button{display:inline-flex;margin-right:calc(-1 * var(--s-space-4));padding:0;border:none;color:var(--s-icon-strong);background-color:transparent;cursor:pointer}.tag__removal-button:focus:not(:focus-visible){outline:none}.tag__removal-button:focus-visible{outline-color:var(--s-focus-default)}";export{l as swirl_option_list,c as swirl_tag}
@@ -0,0 +1 @@
1
+ import{r as t,c as i,h as s,H as e,g as o}from"./p-3fca9a05.js";import{a,c as h,o as l}from"./p-ecb8b7f5.js";import{c as n}from"./p-b7898321.js";import{d as r}from"./p-646e00de.js";const c=class{constructor(s){t(this,s),this.valueChange=i(this,"valueChange",7),this.onChange=t=>{t.stopPropagation(),this.updateTerm(t)},this.updateTerm=r((async t=>{this.updateSuggestions(t.detail),this.open(),this.multiSelect||Boolean(t.detail)&&""!==t.detail||(this.value=void 0,this.valueChange.emit(this.value))}),250,!1),this.onSelect=async t=>{if(t.stopPropagation(),this.multiSelect){const i=t.detail,s=this.suggestions.filter((t=>!i.includes(t.id))).map((t=>t.id));this.value=[...this.value.filter((t=>!s.includes(t.id))),...this.suggestions.filter((t=>i.includes(t.id)&&!this.value.some((i=>i.id===t.id))))],this.valueChange.emit(this.value),this.inputEl.value="";const e=this.inputEl.querySelector("input");Boolean(e)&&(e.value="",queueMicrotask((()=>{e.focus(),this.close()})),this.updateSuggestions(e.value))}else if(Boolean(t.detail[0])){const i=t.detail[0],s=this.suggestions.find((t=>t.id===i));if(!Boolean(s))return;this.value=s,this.valueChange.emit(this.value),queueMicrotask((()=>{this.inputEl.querySelector("input")?.focus(),this.close()}))}},this.onRemoveValue=t=>{Array.isArray(this.value)&&(this.value=this.value.filter((i=>i.id!==t)),this.valueChange.emit(this.value))},this.onFocusOut=t=>{const i=t.relatedTarget;Boolean(i)&&!this.el.contains(i)&&this.close()},this.onFocus=()=>{this.updateSuggestions(),this.open()},this.onKeyDown=t=>{"Escape"===t.code&&(t.preventDefault(),t.stopPropagation(),this.inputEl.querySelector("input").focus(),this.close())},this.onInputKeyDown=t=>{"ArrowDown"===t.code&&(t.preventDefault(),this.listboxEl.querySelector('[role="listbox"]')?.querySelector('[tabIndex="0"]')?.focus())},this.autoSelect=void 0,this.clearable=!0,this.clearButtonLabel="Clear input",this.disabled=void 0,this.generateSuggestions=async()=>[],this.inline=void 0,this.invalid=void 0,this.maxLength=void 0,this.menuLabel="Suggestions",this.mode=void 0,this.multiSelect=void 0,this.placeholder=void 0,this.required=void 0,this.spellCheck=void 0,this.swirlAriaDescribedby=void 0,this.value=void 0,this.active=!1,this.loading=!1,this.position=void 0,this.suggestions=[]}componentWillLoad(){const t=document.querySelectorAll("swirl-datepicker").length;this.id=`autocomplete-${t}`,this.handleInitialValue()}onWindowClick(t){this.el.contains(t.target)||this.close()}watchMultiSelect(){this.handleInitialValue()}async close(){if(!this.active)return;this.disableAutoUpdate&&this.disableAutoUpdate();const t=this.inputEl.querySelector("input");Boolean(t)&&(t.value=this.multiSelect?"":this.value?.label||""),this.active=!1}async open(){this.active||(this.active=!0,requestAnimationFrame((async()=>{await this.reposition(),this.disableAutoUpdate&&this.disableAutoUpdate(),this.disableAutoUpdate=a(this.inputEl,this.listboxContainerEl,this.reposition.bind(this),{animationFrame:!0}),this.listboxContainerEl.scrollTop=0,this.updateSuggestions(this.inputEl.querySelector("input").value)})))}async reposition(){Boolean(this.listboxContainerEl)&&(this.position=await h(this.inputEl,this.listboxContainerEl,{middleware:[l({crossAxis:-16,mainAxis:16})],placement:"bottom-start",strategy:"fixed"}))}async updateSuggestions(t){this.loading=!0,this.suggestions=[],this.suggestions=await this.generateSuggestions(t),this.loading=!1}handleInitialValue(){this.multiSelect&&!Array.isArray(this.value)&&(this.value=[]),!this.multiSelect&&Array.isArray(this.value)&&(this.value=void 0)}render(){const t=`${this.id}-suggestions`,i=this.clearable&&!this.multiSelect,o=this.multiSelect?this.value.map((t=>t.id)):Boolean(this.value)?[this.value.id]:[],a=this.multiSelect?void 0:this.value?.label||"",h=n("autocomplete",{"autocomplete--inactive":!this.active});return s(e,null,s("div",{class:h,onKeyDown:this.onKeyDown},this.multiSelect&&Array.isArray(this.value)&&this.value.length>0&&s("div",{class:"autocomplete__multi-select-tags"},s("swirl-stack",{orientation:"horizontal",spacing:"8",wrap:!0},this.value.map((t=>s("swirl-tag",{key:t.id,label:t.label,onRemove:()=>this.onRemoveValue(t.id),removable:!this.disabled}))))),s("swirl-text-input",{autoSelect:this.autoSelect,class:"autocomplete__input",clearable:i,clearButtonLabel:this.clearButtonLabel,disabled:this.disabled,disableDynamicWidth:!0,id:this.id,inline:this.inline,invalid:this.invalid,onInputFocus:this.onFocus,onKeyDown:this.onInputKeyDown,onValueChange:this.onChange,maxLength:this.maxLength,mode:this.mode,placeholder:this.placeholder,ref:t=>this.inputEl=t,required:this.required,spellCheck:this.spellCheck,swirlAriaAutocomplete:"list",swirlAriaControls:t,swirlAriaDescribedby:this.swirlAriaDescribedby,swirlAriaExpanded:String(this.active),swirlRole:"combobox",value:a}),s("div",{class:"autocomplete__listbox-container",onFocusout:this.onFocusOut,ref:t=>this.listboxContainerEl=t,style:{top:Boolean(this.position)?`${this.position?.y}px`:"",left:Boolean(this.position)?`${this.position?.x}px`:"",width:`${this.inputEl?.getBoundingClientRect().width+32}px`}},this.loading&&s("div",{class:"autocomplete__spinner"},s("swirl-spinner",null)),this.suggestions.length>0&&s("swirl-option-list",{allowDeselect:!0===this.multiSelect,label:this.menuLabel,multiSelect:this.multiSelect,onValueChange:this.onSelect,optionListId:t,ref:t=>this.listboxEl=t,value:o},this.suggestions.map((t=>s("swirl-option-list-item",{selected:Array.isArray(this.value)?this.value.some((i=>i.id===t.id)):this.value?.id===t.id,key:t.id,disabled:t.disabled,label:t.label,value:t.id})))))))}get el(){return o(this)}static get watchers(){return{multiSelect:["watchMultiSelect"]}}};c.style=".sc-swirl-autocomplete-h{display:block}.sc-swirl-autocomplete-h *.sc-swirl-autocomplete{box-sizing:border-box}.autocomplete--inactive.sc-swirl-autocomplete .autocomplete__listbox-container.sc-swirl-autocomplete{display:none}.autocomplete__listbox-container.sc-swirl-autocomplete{position:fixed;z-index:var(--s-z-40);overflow-x:hidden;overflow-y:auto;max-height:18rem;padding-top:var(--s-space-8);padding-bottom:var(--s-space-8);border-radius:var(--s-border-radius-sm);background-color:var(--s-surface-overlay-default);animation:autocomplete-enter 0.1s;box-shadow:var(--s-shadow-level-1)}.autocomplete__listbox-container.sc-swirl-autocomplete:empty{display:none}.autocomplete__spinner.sc-swirl-autocomplete{display:flex;padding:var(--s-space-16);justify-content:center;align-items:center}.autocomplete__multi-select-tags.sc-swirl-autocomplete{margin-top:var(--swirl-autocomplete-tags-margin-top);margin-bottom:var(--s-space-4)}@keyframes autocomplete-enter{from{opacity:0}to{opacity:1}}";export{c as swirl_autocomplete}