@nectary/components 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/card/index.js +1 -1
  2. package/checkbox/index.js +1 -1
  3. package/dialog/index.d.ts +4 -2
  4. package/dialog/index.js +78 -66
  5. package/dropdown/index.js +62 -82
  6. package/dropdown-option/index.js +1 -1
  7. package/icon/add-alert/index.d.ts +11 -0
  8. package/icon/add-alert/index.js +4 -0
  9. package/icon/app-settings-alt/index.d.ts +11 -0
  10. package/icon/app-settings-alt/index.js +4 -0
  11. package/icon/apps/index.d.ts +11 -0
  12. package/icon/apps/index.js +4 -0
  13. package/icon/arrow-drop-down/index.d.ts +11 -0
  14. package/icon/arrow-drop-down/index.js +4 -0
  15. package/icon/arrow-drop-down-circle/index.d.ts +11 -0
  16. package/icon/arrow-drop-down-circle/index.js +4 -0
  17. package/icon/arrow-drop-up/index.d.ts +11 -0
  18. package/icon/arrow-drop-up/index.js +4 -0
  19. package/icon/arrow-left/index.d.ts +11 -0
  20. package/icon/arrow-left/index.js +4 -0
  21. package/icon/arrow-right/index.d.ts +11 -0
  22. package/icon/arrow-right/index.js +4 -0
  23. package/icon/attach-email/index.d.ts +11 -0
  24. package/icon/attach-email/index.js +4 -0
  25. package/icon/attachment/index.d.ts +11 -0
  26. package/icon/attachment/index.js +4 -0
  27. package/icon/auto-delete/index.d.ts +11 -0
  28. package/icon/auto-delete/index.js +4 -0
  29. package/icon/campaign/index.d.ts +11 -0
  30. package/icon/campaign/index.js +4 -0
  31. package/icon/check/index.d.ts +11 -0
  32. package/icon/check/index.js +4 -0
  33. package/icon/cloud/index.d.ts +11 -0
  34. package/icon/cloud/index.js +4 -0
  35. package/icon/cloud-circle/index.d.ts +11 -0
  36. package/icon/cloud-circle/index.js +4 -0
  37. package/icon/cloud-done/index.d.ts +11 -0
  38. package/icon/cloud-done/index.js +4 -0
  39. package/icon/cloud-download/index.d.ts +11 -0
  40. package/icon/cloud-download/index.js +4 -0
  41. package/icon/cloud-off/index.d.ts +11 -0
  42. package/icon/cloud-off/index.js +4 -0
  43. package/icon/cloud-queue/index.d.ts +11 -0
  44. package/icon/cloud-queue/index.js +4 -0
  45. package/icon/cloud-upload/index.d.ts +11 -0
  46. package/icon/cloud-upload/index.js +4 -0
  47. package/icon/create-icon-class.d.ts +38 -36
  48. package/icon/create-new-folder/index.d.ts +11 -0
  49. package/icon/create-new-folder/index.js +4 -0
  50. package/icon/double-arrow/index.d.ts +11 -0
  51. package/icon/double-arrow/index.js +4 -0
  52. package/icon/download/index.d.ts +11 -0
  53. package/icon/download/index.js +4 -0
  54. package/icon/download-done/index.d.ts +11 -0
  55. package/icon/download-done/index.js +4 -0
  56. package/icon/error/index.d.ts +11 -0
  57. package/icon/error/index.js +4 -0
  58. package/icon/error-outline/index.d.ts +11 -0
  59. package/icon/error-outline/index.js +4 -0
  60. package/icon/first-page/index.d.ts +11 -0
  61. package/icon/first-page/index.js +4 -0
  62. package/icon/folder/index.d.ts +11 -0
  63. package/icon/folder/index.js +4 -0
  64. package/icon/folder-open/index.d.ts +11 -0
  65. package/icon/folder-open/index.js +4 -0
  66. package/icon/folder-shared/index.d.ts +11 -0
  67. package/icon/folder-shared/index.js +4 -0
  68. package/icon/fullscreen/index.d.ts +11 -0
  69. package/icon/fullscreen/index.js +4 -0
  70. package/icon/fullscreen-exit/index.d.ts +11 -0
  71. package/icon/fullscreen-exit/index.js +4 -0
  72. package/icon/home-work/index.d.ts +11 -0
  73. package/icon/home-work/index.js +4 -0
  74. package/icon/last-page/index.d.ts +11 -0
  75. package/icon/last-page/index.js +4 -0
  76. package/icon/legend-toggle/index.d.ts +11 -0
  77. package/icon/legend-toggle/index.js +4 -0
  78. package/icon/menu/index.d.ts +11 -0
  79. package/icon/menu/index.js +4 -0
  80. package/icon/menu-open/index.d.ts +11 -0
  81. package/icon/menu-open/index.js +4 -0
  82. package/icon/notification-important/index.d.ts +11 -0
  83. package/icon/notification-important/index.js +4 -0
  84. package/icon/payments/index.d.ts +11 -0
  85. package/icon/payments/index.js +4 -0
  86. package/icon/refresh/index.d.ts +11 -0
  87. package/icon/refresh/index.js +4 -0
  88. package/icon/request-quote/index.d.ts +11 -0
  89. package/icon/request-quote/index.js +4 -0
  90. package/icon/rule-folder/index.d.ts +11 -0
  91. package/icon/rule-folder/index.js +4 -0
  92. package/icon/snippet-folder/index.d.ts +11 -0
  93. package/icon/snippet-folder/index.js +4 -0
  94. package/icon/subdirectory-arrow-left/index.d.ts +11 -0
  95. package/icon/subdirectory-arrow-left/index.js +4 -0
  96. package/icon/subdirectory-arrow-right/index.d.ts +11 -0
  97. package/icon/subdirectory-arrow-right/index.js +4 -0
  98. package/icon/switch-left/index.d.ts +11 -0
  99. package/icon/switch-left/index.js +4 -0
  100. package/icon/switch-right/index.d.ts +11 -0
  101. package/icon/switch-right/index.js +4 -0
  102. package/icon/text-snippet/index.d.ts +11 -0
  103. package/icon/text-snippet/index.js +4 -0
  104. package/icon/topic/index.d.ts +11 -0
  105. package/icon/topic/index.js +4 -0
  106. package/icon/unfold-less/index.d.ts +11 -0
  107. package/icon/unfold-less/index.js +4 -0
  108. package/icon/unfold-more/index.d.ts +11 -0
  109. package/icon/unfold-more/index.js +4 -0
  110. package/icon/upload/index.d.ts +11 -0
  111. package/icon/upload/index.js +4 -0
  112. package/icon/warning/index.d.ts +11 -0
  113. package/icon/warning/index.js +4 -0
  114. package/icon/warning-amber/index.d.ts +11 -0
  115. package/icon/warning-amber/index.js +4 -0
  116. package/icon-branded/create-icon-class.d.ts +38 -36
  117. package/illustration/create-illustration-class.d.ts +38 -36
  118. package/index.d.ts +54 -0
  119. package/index.js +54 -0
  120. package/logo/create-logo-class.d.ts +38 -36
  121. package/package.json +3 -2
  122. package/radio-option/index.js +1 -1
  123. package/spinner/index.js +5 -0
  124. package/tooltip/index.js +1 -1
package/card/index.js CHANGED
@@ -10,7 +10,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
10
10
  import { isSinchCardButtonElement } from '../card-button';
11
11
  import { isSinchCardLinkElement } from '../card-link';
12
12
  import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, setClass } from '../utils';
13
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative}#card-body{padding:24px;box-sizing:border-box;display:flex;flex-direction:column;gap:16px;background-color:var(--sinch-color-snow-100);border-radius:8px;border:1px solid var(--sinch-color-snow-700)}#illustration-wrapper{display:none;flex-direction:column;align-items:center;border-top-left-radius:8px;border-top-right-radius:8px;overflow:hidden;background-color:var(--sinch-color-stormy-500);height:240px}#illustration-wrapper.active{display:flex}#illustration-wrapper.active+#card-body{border-top-left-radius:0;border-top-right-radius:0;border-top:none}#label{margin:0;font:var(--sinch-font-title-5);color:var(--sinch-color-stormy-300);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#label:empty{display:none}#header{display:flex;flex-direction:row;align-items:center;gap:8px;--sinch-size-icon:48px}#title{font:var(--sinch-font-title-3);color:var(--sinch-color-stormy-500);flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#description{margin:0;font:var(--sinch-font-body);color:var(--sinch-color-stormy-500);flex:1;min-height:0;max-height:120px;overflow-y:auto}#description:empty{display:none}:host([disabled]:not([disabled=false])) :is(#illustration-wrapper,#description,#header,#label){opacity:60%}::slotted(sinch-card-button),::slotted(sinch-card-link){margin-top:20px;align-self:flex-start;max-width:100%}</style><div id="wrapper"><div id="illustration-wrapper"><slot name="illustration"></slot></div><div id="card-body"><p id="label"></p><div id="header"><slot name="icon"></slot><span id="title"></span></div><p id="description"></p><slot name="action"></slot></div></div>';
13
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative}#card-body{padding:24px;box-sizing:border-box;display:flex;flex-direction:column;gap:16px;background-color:var(--sinch-color-snow-100);border-radius:8px;border:1px solid var(--sinch-color-snow-700)}#illustration-wrapper{display:none;flex-direction:column;align-items:center;border-top-left-radius:8px;border-top-right-radius:8px;overflow:hidden;background-color:var(--sinch-color-stormy-500);height:240px}#illustration-wrapper.active{display:flex}#illustration-wrapper.active+#card-body{border-top-left-radius:0;border-top-right-radius:0;border-top:none}#label{margin:0;font:var(--sinch-font-title-5);color:var(--sinch-color-stormy-300);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#label:empty{display:none}#header{display:flex;flex-direction:row;align-items:center;gap:8px;--sinch-size-icon:48px}#title{font:var(--sinch-font-title-3);color:var(--sinch-color-stormy-500);flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#description{margin:0;font:var(--sinch-font-body);color:var(--sinch-color-stormy-500);flex:1;min-height:0;max-height:120px;overflow-y:auto}#description:empty{display:none}:host([disabled]:not([disabled=false])) :is(#illustration-wrapper,#description,#header,#label){opacity:.6}::slotted(sinch-card-button),::slotted(sinch-card-link){margin-top:20px;align-self:flex-start;max-width:100%}</style><div id="wrapper"><div id="illustration-wrapper"><slot name="illustration"></slot></div><div id="card-body"><p id="label"></p><div id="header"><slot name="icon"></slot><span id="title"></span></div><p id="description"></p><slot name="action"></slot></div></div>';
14
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
16
16
  defineCustomElement('sinch-card', (_$text = new WeakMap(), _$label = new WeakMap(), _$title = new WeakMap(), _$illustrationSlot = new WeakMap(), _$actionSlot = new WeakMap(), _$illustrationSlotWrapper = new WeakMap(), _onIllustrationSlotChange = new WeakMap(), _updateDisabledAttributeInChildren = new WeakMap(), class extends HTMLElement {
package/checkbox/index.js CHANGED
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
10
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
11
- const templateHTML = '<style>:host{--sinch-color-checkbox-circle:var(--sinch-color-transparent);--sinch-color-checkbox-background:var(--sinch-color-snow-100);--sinch-color-checkbox-border:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-hover:var(--sinch-color-snow-500);--sinch-color-checkbox-background-hover:var(--sinch-color-snow-100);--sinch-color-checkbox-border-hover:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-tropical-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-focus:var(--sinch-color-snow-800);--sinch-color-checkbox-background-focus:var(--sinch-color-snow-100);--sinch-color-checkbox-border-focus:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-tropical-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-active:var(--sinch-color-stormy-100);--sinch-color-checkbox-background-active:var(--sinch-color-snow-100);--sinch-color-checkbox-border-active:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-tropical-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-disabled:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled:var(--sinch-color-snow-100);--sinch-color-checkbox-border-disabled:var(--sinch-color-stormy-100);--sinch-color-checkbox-circle-disabled-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-text:var(--sinch-color-text-default);--sinch-color-checkbox-text-disabled:var(--sinch-color-stormy-200);display:inline-block;vertical-align:middle;outline:0}:host([invalid]:not([invalid=false])){--sinch-color-checkbox-border:var(--sinch-color-raspberry-500);--sinch-color-checkbox-background-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-raspberry-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-raspberry-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-disabled:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-text:var(--sinch-color-text-invalid);--sinch-color-checkbox-text-disabled:var(--sinch-color-raspberry-200)}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px}#checkbox{all:initial;display:block;width:32px;height:32px;cursor:pointer}#checkbox:disabled{cursor:initial}#icon-container{position:relative;width:32px;height:32px}#checkbox::before{content:"";position:absolute;top:0;left:0;width:32px;height:32px;border-radius:16px;pointer-events:none;background-color:var(--sinch-color-checkbox-circle);transition:background-color .1s linear}#checkbox::after{content:"";position:absolute;top:7px;left:7px;width:18px;height:18px;border-radius:2px;pointer-events:none;background-color:var(--sinch-color-checkbox-background);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border) inset;transition:background-color .1s linear}#icon-checkmark{position:absolute;left:9px;top:10px;transition:opacity .1s linear;opacity:0%;pointer-events:none}#icon-indeterminate{position:absolute;left:10px;top:15px;transition:opacity .1s linear;opacity:0%;pointer-events:none}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{display:none;flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:6px;font:var(--sinch-font-body);color:var(--sinch-color-checkbox-text)}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-checkbox-text-disabled)}:host(:is(:not([indeterminate]),[indeterminate=false])) #checkbox:checked~#icon-checkmark{opacity:100%}:host([indeterminate]:not([indeterminate=false])) #checkbox:checked~#icon-indeterminate{opacity:100%}#checkbox:checked::before{background-color:var(--sinch-color-checkbox-circle-checked)}#checkbox:checked::after{background-color:var(--sinch-color-checkbox-background-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-checked) inset}#checkbox:focus::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus::after{background-color:var(--sinch-color-checkbox-background-focus);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-focus) inset}#checkbox:hover::before{background-color:var(--sinch-color-checkbox-circle-hover)}#checkbox:hover::after{background-color:var(--sinch-color-checkbox-background-hover);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-hover) inset}#checkbox:active::before{background-color:var(--sinch-color-checkbox-circle-active)}#checkbox:active::after{background-color:var(--sinch-color-checkbox-background-active);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-active) inset}#checkbox:disabled::before{background-color:var(--sinch-color-checkbox-circle-disabled)}#checkbox:disabled::after{background-color:var(--sinch-color-checkbox-background-disabled);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-disabled) inset}#checkbox:focus:checked::before{background-color:var(--sinch-color-checkbox-circle-focus-checked)}#checkbox:focus:checked::after{background-color:var(--sinch-color-checkbox-background-focus-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-focus-checked) inset}#checkbox:hover:checked::before{background-color:var(--sinch-color-checkbox-circle-hover-checked)}#checkbox:hover:checked::after{background-color:var(--sinch-color-checkbox-background-hover-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-hover-checked) inset}#checkbox:active:checked::before{background-color:var(--sinch-color-checkbox-circle-active-checked)}#checkbox:active:checked::after{background-color:var(--sinch-color-checkbox-background-active-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-active-checked) inset}#checkbox:disabled:checked::before{background-color:var(--sinch-color-checkbox-circle-disabled-checked)}#checkbox:disabled:checked::after{background-color:var(--sinch-color-checkbox-background-disabled-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-disabled-checked) inset}</style><div id="wrapper"><div id="icon-container"><input id="checkbox" type="checkbox"/> <svg id="icon-checkmark" width="14" height="11" aria-hidden="true"><path d="M14 1.99999L12.59 0.579987L4.98995 8.17L1.49997 4.5L0.0799694 5.91L4.98995 11L14 1.99999Z" fill="white"/></svg> <svg id="icon-indeterminate" width="12" height="2" aria-hidden="true"><line y1="1" x2="12" y2="1" stroke="white" stroke-width="2"/></svg></div><label for="checkbox" id="label"></label></div>';
11
+ const templateHTML = '<style>:host{--sinch-color-checkbox-circle:var(--sinch-color-transparent);--sinch-color-checkbox-background:var(--sinch-color-snow-100);--sinch-color-checkbox-border:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-hover:var(--sinch-color-snow-500);--sinch-color-checkbox-background-hover:var(--sinch-color-snow-100);--sinch-color-checkbox-border-hover:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-tropical-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-focus:var(--sinch-color-snow-800);--sinch-color-checkbox-background-focus:var(--sinch-color-snow-100);--sinch-color-checkbox-border-focus:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-tropical-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-active:var(--sinch-color-stormy-100);--sinch-color-checkbox-background-active:var(--sinch-color-snow-100);--sinch-color-checkbox-border-active:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-tropical-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-disabled:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled:var(--sinch-color-snow-100);--sinch-color-checkbox-border-disabled:var(--sinch-color-stormy-100);--sinch-color-checkbox-circle-disabled-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-text:var(--sinch-color-text-default);--sinch-color-checkbox-text-disabled:var(--sinch-color-stormy-200);display:inline-block;vertical-align:middle;outline:0}:host([invalid]:not([invalid=false])){--sinch-color-checkbox-border:var(--sinch-color-raspberry-500);--sinch-color-checkbox-background-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-raspberry-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-raspberry-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-disabled:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-text:var(--sinch-color-text-invalid);--sinch-color-checkbox-text-disabled:var(--sinch-color-raspberry-200)}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px}#checkbox{all:initial;display:block;width:32px;height:32px;cursor:pointer}#checkbox:disabled{cursor:initial}#icon-container{position:relative;width:32px;height:32px}#checkbox::before{content:"";position:absolute;top:0;left:0;width:32px;height:32px;border-radius:16px;pointer-events:none;background-color:var(--sinch-color-checkbox-circle);transition:background-color .1s linear}#checkbox::after{content:"";position:absolute;top:7px;left:7px;width:18px;height:18px;border-radius:2px;pointer-events:none;background-color:var(--sinch-color-checkbox-background);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border) inset;transition:background-color .1s linear}#icon-checkmark{position:absolute;left:9px;top:10px;transition:opacity .1s linear;opacity:0;pointer-events:none}#icon-indeterminate{position:absolute;left:10px;top:15px;transition:opacity .1s linear;opacity:0;pointer-events:none}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{display:none;flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:6px;font:var(--sinch-font-body);color:var(--sinch-color-checkbox-text)}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-checkbox-text-disabled)}:host(:is(:not([indeterminate]),[indeterminate=false])) #checkbox:checked~#icon-checkmark{opacity:1}:host([indeterminate]:not([indeterminate=false])) #checkbox:checked~#icon-indeterminate{opacity:1}#checkbox:checked::before{background-color:var(--sinch-color-checkbox-circle-checked)}#checkbox:checked::after{background-color:var(--sinch-color-checkbox-background-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-checked) inset}#checkbox:focus::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus::after{background-color:var(--sinch-color-checkbox-background-focus);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-focus) inset}#checkbox:hover::before{background-color:var(--sinch-color-checkbox-circle-hover)}#checkbox:hover::after{background-color:var(--sinch-color-checkbox-background-hover);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-hover) inset}#checkbox:active::before{background-color:var(--sinch-color-checkbox-circle-active)}#checkbox:active::after{background-color:var(--sinch-color-checkbox-background-active);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-active) inset}#checkbox:disabled::before{background-color:var(--sinch-color-checkbox-circle-disabled)}#checkbox:disabled::after{background-color:var(--sinch-color-checkbox-background-disabled);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-disabled) inset}#checkbox:focus:checked::before{background-color:var(--sinch-color-checkbox-circle-focus-checked)}#checkbox:focus:checked::after{background-color:var(--sinch-color-checkbox-background-focus-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-focus-checked) inset}#checkbox:hover:checked::before{background-color:var(--sinch-color-checkbox-circle-hover-checked)}#checkbox:hover:checked::after{background-color:var(--sinch-color-checkbox-background-hover-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-hover-checked) inset}#checkbox:active:checked::before{background-color:var(--sinch-color-checkbox-circle-active-checked)}#checkbox:active:checked::after{background-color:var(--sinch-color-checkbox-background-active-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-active-checked) inset}#checkbox:disabled:checked::before{background-color:var(--sinch-color-checkbox-circle-disabled-checked)}#checkbox:disabled:checked::after{background-color:var(--sinch-color-checkbox-background-disabled-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-disabled-checked) inset}</style><div id="wrapper"><div id="icon-container"><input id="checkbox" type="checkbox"/> <svg id="icon-checkmark" width="14" height="11" aria-hidden="true"><path d="M14 1.99999L12.59 0.579987L4.98995 8.17L1.49997 4.5L0.0799694 5.91L4.98995 11L14 1.99999Z" fill="white"/></svg> <svg id="icon-indeterminate" width="12" height="2" aria-hidden="true"><line y1="1" x2="12" y2="1" stroke="white" stroke-width="2"/></svg></div><label for="checkbox" id="label"></label></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
14
  defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new WeakMap(), _onCheckboxInput = new WeakMap(), class extends HTMLElement {
package/dialog/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
+ import '../icon-button';
1
2
  import '../icon/close';
2
3
  import type { TRect, TSinchElementReact } from '../types';
3
4
  import type { SyntheticEvent } from 'react';
4
5
  declare type TSinchDialogElement = HTMLElement & {
5
- title: string;
6
+ caption: string;
6
7
  readonly dialogRect: TRect;
7
8
  readonly closeButtonRect: TRect;
8
9
  };
9
10
  declare type TSinchDialogReact = TSinchElementReact<TSinchDialogElement> & {
10
- title: string;
11
+ open: boolean;
12
+ caption: string;
11
13
  'aria-label': string;
12
14
  onClose: (event: SyntheticEvent<TSinchDialogElement, CustomEvent<void>>) => void;
13
15
  };
package/dialog/index.js CHANGED
@@ -1,15 +1,21 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$main, _$closeButton, _$backDrop, _$title, _$prevActiveElement, _focusIn, _onCloseByMouse, _onCloseByEsc, _onClose, _onCloseReactHandler;
4
+ var _$dialog, _$closeButton, _$caption, _isConected, _onCancel, _onCloseClick, _onBackdropClick, _onCloseReactHandler, _dispatchCloseEvent, _setOpen;
5
+
6
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
5
7
 
6
8
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
9
 
8
10
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
11
 
10
- import { defineCustomElement, getAttribute, getRect, updateAttribute } from '../utils';
12
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
+
14
+ import dialogPolyfill from 'dialog-polyfill';
15
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttrTrue, updateAttribute } from '../utils';
16
+ import '../icon-button';
11
17
  import '../icon/close';
12
- const templateHTML = '<style>:host{outline:0}#wrapper{position:fixed;top:0;left:0;height:100vh;width:100vw;color:var(--sinch-color-text-default);font:var(--sinch-font-body);z-index:2147483647}#backdrop{background-color:#000;position:absolute;left:0;top:0;opacity:55%;width:100%;height:100%}#main{display:flex;flex-direction:column;position:relative;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);padding:24px;width:100%;max-width:512px;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100)}#header{display:flex;flex-direction:row;justify-content:space-between;align-content:center;margin-bottom:16px}#title{font:var(--sinch-font-title-3);color:var(--sinch-color-text-default)}#content-wrapper{max-height:50vh;overflow-y:auto;margin-top:16px}#close{all:initial;cursor:pointer;--sinch-size-icon:24px}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}</style><div id="wrapper"><div id="backdrop"></div><div id="main"><div id="header"><span id="title"></span> <button id="close"><sinch-icon-close></sinch-icon-close></button></div><div id="content-wrapper"><slot name="content"></slot></div><div id="buttons"><slot name="buttons"></slot></div></div></div>';
18
+ const templateHTML = '<style>dialog{position:absolute;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px;width:100%;max-width:512px;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px rgb(0 0 0 / 10%)}dialog:not([open]){display:none}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:#000;opacity:.55}dialog::backdrop{background-color:#000;opacity:.55}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}dialog.fixed{position:fixed;top:50%;transform:translate(0,-50%)}#header{display:flex;flex-direction:row;justify-content:space-between;align-content:center;margin-bottom:16px}#caption{font:var(--sinch-font-title-3);color:var(--sinch-color-text-default)}#content-wrapper{max-height:50vh;overflow-y:auto}#close{all:initial;cursor:pointer;--sinch-size-icon:24px}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}</style><dialog><div id="header"><span id="caption"></span> <button id="close"><sinch-icon-close></sinch-icon-close></button></div><div id="content-wrapper"><slot name="content"></slot></div><div id="buttons"><slot name="buttons"></slot></div></dialog>';
13
19
  const template = document.createElement('template');
14
20
  template.innerHTML = templateHTML;
15
21
 
@@ -23,84 +29,65 @@ const getReactEventHandler = ($element, handlerName) => {
23
29
  return null;
24
30
  };
25
31
 
26
- defineCustomElement('sinch-dialog', (_$main = new WeakMap(), _$closeButton = new WeakMap(), _$backDrop = new WeakMap(), _$title = new WeakMap(), _$prevActiveElement = new WeakMap(), _focusIn = new WeakMap(), _onCloseByMouse = new WeakMap(), _onCloseByEsc = new WeakMap(), _onClose = new WeakMap(), _onCloseReactHandler = new WeakMap(), class extends HTMLElement {
32
+ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = new WeakMap(), _$caption = new WeakMap(), _isConected = new WeakMap(), _onCancel = new WeakMap(), _onCloseClick = new WeakMap(), _onBackdropClick = new WeakMap(), _onCloseReactHandler = new WeakMap(), _dispatchCloseEvent = new WeakSet(), _setOpen = new WeakSet(), class extends HTMLElement {
27
33
  constructor() {
28
34
  super();
29
35
 
30
- _classPrivateFieldInitSpec(this, _$main, {
31
- writable: true,
32
- value: void 0
33
- });
36
+ _classPrivateMethodInitSpec(this, _setOpen);
34
37
 
35
- _classPrivateFieldInitSpec(this, _$closeButton, {
38
+ _classPrivateMethodInitSpec(this, _dispatchCloseEvent);
39
+
40
+ _classPrivateFieldInitSpec(this, _$dialog, {
36
41
  writable: true,
37
42
  value: void 0
38
43
  });
39
44
 
40
- _classPrivateFieldInitSpec(this, _$backDrop, {
45
+ _classPrivateFieldInitSpec(this, _$closeButton, {
41
46
  writable: true,
42
47
  value: void 0
43
48
  });
44
49
 
45
- _classPrivateFieldInitSpec(this, _$title, {
50
+ _classPrivateFieldInitSpec(this, _$caption, {
46
51
  writable: true,
47
52
  value: void 0
48
53
  });
49
54
 
50
- _classPrivateFieldInitSpec(this, _$prevActiveElement, {
55
+ _classPrivateFieldInitSpec(this, _isConected, {
51
56
  writable: true,
52
- value: null
57
+ value: false
53
58
  });
54
59
 
55
- _classPrivateFieldInitSpec(this, _focusIn, {
60
+ _classPrivateFieldInitSpec(this, _onCancel, {
56
61
  writable: true,
57
62
  value: e => {
58
- if (e.target === this) {
59
- return;
60
- }
63
+ e.preventDefault();
61
64
 
62
- if (!this.contains(e.target)) {
63
- _classPrivateFieldGet(this, _$closeButton).focus();
64
- }
65
+ _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
65
66
  }
66
67
  });
67
68
 
68
- _classPrivateFieldInitSpec(this, _onCloseByMouse, {
69
+ _classPrivateFieldInitSpec(this, _onCloseClick, {
69
70
  writable: true,
70
71
  value: e => {
71
72
  e.stopPropagation();
72
73
 
73
- _classPrivateFieldGet(this, _onClose).call(this);
74
+ _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
74
75
  }
75
76
  });
76
77
 
77
- _classPrivateFieldInitSpec(this, _onCloseByEsc, {
78
+ _classPrivateFieldInitSpec(this, _onBackdropClick, {
78
79
  writable: true,
79
80
  value: e => {
80
- switch (e.key) {
81
- case 'Escape':
82
- {
83
- e.preventDefault();
84
- e.stopPropagation();
85
-
86
- _classPrivateFieldGet(this, _onClose).call(this);
81
+ e.stopPropagation();
82
+ const rect = this.dialogRect;
83
+ const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
87
84
 
88
- break;
89
- }
85
+ if (!isInside) {
86
+ _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
90
87
  }
91
88
  }
92
89
  });
93
90
 
94
- _classPrivateFieldInitSpec(this, _onClose, {
95
- writable: true,
96
- value: () => {
97
- _classPrivateFieldGet(this, _$prevActiveElement)?.focus();
98
- this.dispatchEvent(new CustomEvent('close', {
99
- bubbles: true
100
- }));
101
- }
102
- });
103
-
104
91
  _classPrivateFieldInitSpec(this, _onCloseReactHandler, {
105
92
  writable: true,
106
93
  value: () => {
@@ -114,69 +101,94 @@ defineCustomElement('sinch-dialog', (_$main = new WeakMap(), _$closeButton = new
114
101
  });
115
102
  shadowRoot.appendChild(template.content.cloneNode(true));
116
103
 
117
- _classPrivateFieldSet(this, _$main, shadowRoot.querySelector('#main'));
104
+ _classPrivateFieldSet(this, _$dialog, shadowRoot.querySelector('dialog'));
118
105
 
119
106
  _classPrivateFieldSet(this, _$closeButton, shadowRoot.querySelector('#close'));
120
107
 
121
- _classPrivateFieldSet(this, _$backDrop, shadowRoot.querySelector('#backdrop'));
108
+ _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
122
109
 
123
- _classPrivateFieldSet(this, _$title, shadowRoot.querySelector('#title'));
110
+ dialogPolyfill.registerDialog(_classPrivateFieldGet(this, _$dialog));
124
111
  }
125
112
 
126
113
  static get observedAttributes() {
127
- return ['title'];
114
+ return ['caption', 'open'];
128
115
  }
129
116
 
130
117
  attributeChangedCallback(name, _, newVal) {
131
118
  switch (name) {
132
- case 'title':
119
+ case 'caption':
120
+ {
121
+ _classPrivateFieldGet(this, _$caption).textContent = newVal;
122
+ break;
123
+ }
124
+
125
+ case 'open':
133
126
  {
134
- _classPrivateFieldGet(this, _$title).textContent = newVal;
127
+ if (_classPrivateFieldGet(this, _isConected)) {
128
+ _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, isAttrTrue(newVal));
129
+ }
130
+
135
131
  break;
136
132
  }
137
133
  }
138
134
  }
139
135
 
140
- set title(title) {
141
- updateAttribute(this, 'title', title);
136
+ set caption(caption) {
137
+ updateAttribute(this, 'caption', caption);
142
138
  }
143
139
 
144
- get title() {
145
- return getAttribute(this, 'title', '');
140
+ get caption() {
141
+ return getAttribute(this, 'caption', '');
146
142
  }
147
143
 
148
144
  connectedCallback() {
149
145
  this.setAttribute('role', 'dialog');
150
146
 
151
- _classPrivateFieldSet(this, _$prevActiveElement, document.activeElement);
147
+ _classPrivateFieldGet(this, _$closeButton).addEventListener('click', _classPrivateFieldGet(this, _onCloseClick));
152
148
 
153
- _classPrivateFieldGet(this, _$closeButton).addEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
149
+ this.addEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
150
+ this.addEventListener('click', _classPrivateFieldGet(this, _onBackdropClick));
154
151
 
155
- _classPrivateFieldGet(this, _$backDrop).addEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
152
+ _classPrivateFieldGet(this, _$dialog).addEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
156
153
 
157
- this.addEventListener('keydown', _classPrivateFieldGet(this, _onCloseByEsc));
158
- this.addEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
159
- document.addEventListener('focusin', _classPrivateFieldGet(this, _focusIn));
154
+ _classPrivateFieldSet(this, _isConected, true);
155
+
156
+ if (getBooleanAttribute(this, 'open')) {
157
+ _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, true);
158
+ }
160
159
  }
161
160
 
162
161
  disconnectedCallback() {
163
- _classPrivateFieldSet(this, _$prevActiveElement, null);
162
+ _classPrivateFieldGet(this, _$closeButton).removeEventListener('click', _classPrivateFieldGet(this, _onCloseClick));
164
163
 
165
- _classPrivateFieldGet(this, _$closeButton).removeEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
164
+ this.removeEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
165
+ this.removeEventListener('click', _classPrivateFieldGet(this, _onBackdropClick));
166
166
 
167
- _classPrivateFieldGet(this, _$backDrop).removeEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
167
+ _classPrivateFieldGet(this, _$dialog).removeEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
168
168
 
169
- this.removeEventListener('keydown', _classPrivateFieldGet(this, _onCloseByEsc));
170
- this.removeEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
171
- document.removeEventListener('focusin', _classPrivateFieldGet(this, _focusIn));
169
+ _classPrivateFieldSet(this, _isConected, false);
172
170
  }
173
171
 
174
172
  get dialogRect() {
175
- return getRect(_classPrivateFieldGet(this, _$main));
173
+ return getRect(_classPrivateFieldGet(this, _$dialog));
176
174
  }
177
175
 
178
176
  get closeButtonRect() {
179
177
  return getRect(_classPrivateFieldGet(this, _$closeButton));
180
178
  }
181
179
 
182
- }));
180
+ }));
181
+
182
+ function _dispatchCloseEvent2() {
183
+ this.dispatchEvent(new CustomEvent('close', {
184
+ bubbles: true
185
+ }));
186
+ }
187
+
188
+ function _setOpen2(isOpen) {
189
+ if (isOpen) {
190
+ _classPrivateFieldGet(this, _$dialog).showModal();
191
+ } else {
192
+ _classPrivateFieldGet(this, _$dialog).close();
193
+ }
194
+ }
package/dropdown/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$button, _$optionSlot, _$listbox, _$targetElement, _$targetSlot, _onTargetFocusin, _onButtonClick, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _onTargetSlotChange, _onListboxBlur, _onExpand, _onCollapse, _onValueChange, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionWithValue, _getOptionElements, _getEnabledOptionElements, _dispatchChangeEvent, _focusTargetElement;
4
+ var _$button, _$optionSlot, _$listbox, _onButtonClick, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _setOpen, _onExpand, _onCollapse, _onValueChange, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionWithValue, _getOptionElements, _getEnabledOptionElements, _dispatchChangeEvent;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -13,9 +13,9 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
13
13
 
14
14
  import { isDropdownOptionElement } from '../dropdown-option';
15
15
  import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getLiteralAttribute, getRect, updateAttribute, updateBooleanAttribute, updateIntegerAttribute, updateLiteralAttribute } from '../utils';
16
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box}#listbox{display:none;position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;box-sizing:border-box;outline:0}#listbox-body{position:absolute;left:0;top:calc(100% + 8px);min-width:100%;width:max-content;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgb(0 0 0 / 15%);overflow-y:auto;contain:content}:host([orientation=bottom-left]) #listbox-body{left:unset;right:0}:host([orientation=top-right]) #listbox-body{top:-8px;transform:translateY(-100%)}:host([orientation=top-left]) #listbox-body{top:-8px;transform:translateY(-100%);left:unset;right:0}#button[aria-expanded=true]~#listbox{display:block}::slotted(*){display:block}</style><div id="wrapper"><div id="button" aria-haspopup="listbox" aria-expanded="false"><slot name="target"></slot></div><div id="listbox" tabindex="-1"><div id="listbox-body"><slot name="option"></slot></div></div></div>';
16
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box}dialog{outline:0;border:none;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgb(0 0 0 / 15%);overflow-y:auto;contain:content;padding:0;border-radius:4px;cursor:pointer}dialog::backdrop{background-color:transparent}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:transparent}dialog.fixed{position:fixed;top:50%;transform:translate(0,-50%)}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}::slotted(*){display:block}</style><div id="wrapper"><div id="button" aria-haspopup="listbox" aria-expanded="false"><slot name="target"></slot></div><dialog id="listbox" tabindex="-1"><slot name="option"></slot></dialog></div>';
17
17
  const orientationValues = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
18
- const ITEM_HEIGHT = 36;
18
+ const ITEM_HEIGHT = 40;
19
19
 
20
20
  const findSelectedOption = elements => {
21
21
  for (const el of elements) {
@@ -29,12 +29,10 @@ const findSelectedOption = elements => {
29
29
 
30
30
  const template = document.createElement('template');
31
31
  template.innerHTML = templateHTML;
32
- defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$targetElement = new WeakMap(), _$targetSlot = new WeakMap(), _onTargetFocusin = new WeakMap(), _onButtonClick = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyPress = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onTargetSlotChange = new WeakMap(), _onListboxBlur = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _onValueChange = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionWithValue = new WeakSet(), _getOptionElements = new WeakSet(), _getEnabledOptionElements = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _focusTargetElement = new WeakSet(), class extends HTMLElement {
32
+ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _onButtonClick = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyPress = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _setOpen = new WeakSet(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _onValueChange = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionWithValue = new WeakSet(), _getOptionElements = new WeakSet(), _getEnabledOptionElements = new WeakSet(), _dispatchChangeEvent = new WeakSet(), class extends HTMLElement {
33
33
  constructor() {
34
34
  super();
35
35
 
36
- _classPrivateMethodInitSpec(this, _focusTargetElement);
37
-
38
36
  _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
39
37
 
40
38
  _classPrivateMethodInitSpec(this, _getEnabledOptionElements);
@@ -59,6 +57,8 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
59
57
 
60
58
  _classPrivateMethodInitSpec(this, _onExpand);
61
59
 
60
+ _classPrivateMethodInitSpec(this, _setOpen);
61
+
62
62
  _classPrivateFieldInitSpec(this, _$button, {
63
63
  writable: true,
64
64
  value: void 0
@@ -74,23 +74,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
74
74
  value: void 0
75
75
  });
76
76
 
77
- _classPrivateFieldInitSpec(this, _$targetElement, {
78
- writable: true,
79
- value: null
80
- });
81
-
82
- _classPrivateFieldInitSpec(this, _$targetSlot, {
83
- writable: true,
84
- value: void 0
85
- });
86
-
87
- _classPrivateFieldInitSpec(this, _onTargetFocusin, {
88
- writable: true,
89
- value: e => {
90
- _classPrivateFieldSet(this, _$targetElement, e.target);
91
- }
92
- });
93
-
94
77
  _classPrivateFieldInitSpec(this, _onButtonClick, {
95
78
  writable: true,
96
79
  value: e => {
@@ -117,8 +100,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
117
100
  }
118
101
 
119
102
  _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
120
-
121
- _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
122
103
  }
123
104
  });
124
105
 
@@ -135,8 +116,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
135
116
 
136
117
  _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
137
118
 
138
- _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
139
-
140
119
  break;
141
120
  }
142
121
  }
@@ -173,8 +152,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
173
152
 
174
153
  _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
175
154
 
176
- _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
177
-
178
155
  break;
179
156
  }
180
157
  }
@@ -190,22 +167,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
190
167
  }
191
168
  });
192
169
 
193
- _classPrivateFieldInitSpec(this, _onTargetSlotChange, {
194
- writable: true,
195
- value: () => {
196
- _classPrivateFieldSet(this, _$targetElement, null);
197
- }
198
- });
199
-
200
- _classPrivateFieldInitSpec(this, _onListboxBlur, {
201
- writable: true,
202
- value: e => {
203
- e.stopPropagation();
204
-
205
- _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
206
- }
207
- });
208
-
209
170
  const shadowRoot = this.attachShadow({
210
171
  mode: 'closed',
211
172
  delegatesFocus: true
@@ -217,8 +178,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
217
178
  _classPrivateFieldSet(this, _$listbox, shadowRoot.querySelector('#listbox'));
218
179
 
219
180
  _classPrivateFieldSet(this, _$optionSlot, shadowRoot.querySelector('slot[name="option"]'));
220
-
221
- _classPrivateFieldSet(this, _$targetSlot, shadowRoot.querySelector('slot[name="target"]'));
222
181
  }
223
182
 
224
183
  connectedCallback() {
@@ -226,10 +185,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
226
185
 
227
186
  _classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
228
187
 
229
- _classPrivateFieldGet(this, _$button).addEventListener('focusin', _classPrivateFieldGet(this, _onTargetFocusin));
230
-
231
- _classPrivateFieldGet(this, _$listbox).addEventListener('blur', _classPrivateFieldGet(this, _onListboxBlur));
232
-
233
188
  _classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
234
189
 
235
190
  _classPrivateFieldGet(this, _$listbox).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
@@ -237,17 +192,11 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
237
192
  _classPrivateFieldGet(this, _$listbox).addEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
238
193
 
239
194
  _classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
240
-
241
- _classPrivateFieldGet(this, _$targetSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onTargetSlotChange));
242
195
  }
243
196
 
244
197
  disconnectedCallback() {
245
198
  _classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
246
199
 
247
- _classPrivateFieldGet(this, _$button).removeEventListener('focusin', _classPrivateFieldGet(this, _onTargetFocusin));
248
-
249
- _classPrivateFieldGet(this, _$listbox).removeEventListener('blur', _classPrivateFieldGet(this, _onListboxBlur));
250
-
251
200
  _classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
252
201
 
253
202
  _classPrivateFieldGet(this, _$listbox).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
@@ -255,8 +204,6 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
255
204
  _classPrivateFieldGet(this, _$listbox).removeEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
256
205
 
257
206
  _classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
258
-
259
- _classPrivateFieldGet(this, _$targetSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onTargetSlotChange));
260
207
  }
261
208
 
262
209
  static get observedAttributes() {
@@ -300,7 +247,7 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
300
247
  }
301
248
 
302
249
  get dropdownRect() {
303
- return getRect(_classPrivateFieldGet(this, _$listbox).firstElementChild);
250
+ return getRect(_classPrivateFieldGet(this, _$listbox));
304
251
  }
305
252
 
306
253
  attributeChangedCallback(name, oldVal, newVal) {
@@ -314,39 +261,80 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
314
261
 
315
262
  case 'maxvisibleitems':
316
263
  {
317
- const $list = _classPrivateFieldGet(this, _$listbox).firstElementChild;
264
+ const $list = _classPrivateFieldGet(this, _$listbox);
265
+
266
+ if (newVal === '0') {
267
+ $list.style.maxHeight = 'unset';
268
+ } else {
269
+ $list.style.maxHeight = attrValueToPixels(newVal, {
270
+ min: 2,
271
+ multiplier: ITEM_HEIGHT
272
+ });
273
+ }
318
274
 
319
- $list.style.maxHeight = attrValueToPixels(newVal, {
320
- min: 2,
321
- multiplier: ITEM_HEIGHT
322
- });
323
275
  break;
324
276
  }
325
277
  }
326
278
  }
327
279
 
328
- focus() {
329
- _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
330
- }
331
-
332
- blur() {
333
- _classPrivateFieldGet(this, _$button).blur();
280
+ focus() {}
334
281
 
335
- _classPrivateFieldGet(this, _$listbox).blur();
336
- }
282
+ blur() {}
337
283
 
338
284
  }));
339
285
 
286
+ function _setOpen2(isOpen) {
287
+ if (isOpen) {
288
+ _classPrivateFieldGet(this, _$listbox).showModal();
289
+ } else {
290
+ _classPrivateFieldGet(this, _$listbox).close();
291
+ }
292
+ }
293
+
340
294
  function _onExpand2() {
341
295
  _classPrivateFieldGet(this, _$button).setAttribute('aria-expanded', 'true');
342
296
 
343
- _classPrivateFieldGet(this, _$listbox).focus();
297
+ _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, true);
298
+
299
+ const buttonRect = _classPrivateFieldGet(this, _$button).getBoundingClientRect();
300
+
301
+ const modalRect = _classPrivateFieldGet(this, _$listbox).getBoundingClientRect();
302
+
303
+ const width = Math.max(modalRect.width, buttonRect.width);
304
+ const widthDiff = Math.max(buttonRect.width - modalRect.width, 0);
305
+ let leftOffset = 0;
306
+ let topOffset = 0;
307
+ const orient = this.orientation;
308
+
309
+ if (orient === 'bottom-right' || orient === 'top-right') {
310
+ leftOffset = Math.min(modalRect.x, Math.max(-modalRect.x, buttonRect.x - modalRect.x + widthDiff * 0.5));
311
+ }
312
+
313
+ if (orient === 'bottom-left' || orient === 'top-left') {
314
+ leftOffset = Math.min(modalRect.x, Math.max(-modalRect.x, buttonRect.x + buttonRect.width - modalRect.x - modalRect.width - widthDiff * 0.5));
315
+ }
316
+
317
+ if (orient === 'bottom-left' || orient === 'bottom-right') {
318
+ topOffset = Math.min(modalRect.y, Math.max(-modalRect.y, buttonRect.y + buttonRect.height - modalRect.y + 8));
319
+ }
320
+
321
+ if (orient === 'top-left' || orient === 'top-right') {
322
+ topOffset = Math.min(modalRect.y, Math.max(-modalRect.y, buttonRect.y - modalRect.y - modalRect.height - 8));
323
+ }
324
+
325
+ _classPrivateFieldGet(this, _$listbox).style.transform = `translateX(${leftOffset}px) translateY(${topOffset}px)`;
326
+ _classPrivateFieldGet(this, _$listbox).style.width = `${width}px`;
344
327
 
345
328
  _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getOptionWithValue, _getOptionWithValue2).call(this, this.value) ?? _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
346
329
  }
347
330
 
348
331
  function _onCollapse2() {
349
332
  _classPrivateFieldGet(this, _$button).setAttribute('aria-expanded', 'false');
333
+
334
+ _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, false);
335
+
336
+ _classPrivateFieldGet(this, _$listbox).style.transform = `initial`;
337
+ _classPrivateFieldGet(this, _$listbox).style.width = `max-content`;
350
338
  }
351
339
 
352
340
  function _onValueChange2(value) {
@@ -440,12 +428,4 @@ function _dispatchChangeEvent2($opt) {
440
428
  bubbles: true
441
429
  }));
442
430
  }
443
- }
444
-
445
- function _focusTargetElement2() {
446
- const el = _classPrivateFieldGet(this, _$targetElement);
447
-
448
- _classPrivateFieldSet(this, _$targetElement, null);
449
-
450
- el?.focus();
451
431
  }
@@ -6,7 +6,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
6
6
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
7
7
 
8
8
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
9
- const templateHTML = '<style>:host{display:block}*{pointer-events:none}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:6px 12px;width:100%;align-items:center;gap:12px;--sinch-size-icon:24px}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([checked])>#wrapper{padding-right:36px}:host([checked])>#wrapper::after{content:"";position:absolute;top:10px;right:11px;width:18px;height:14px;background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M6 11.17 1.83 7 .41 8.41 6 14 18 2 16.59.59 6 11.17Z\' fill=\'%230A273D\'/%3E%3C/svg%3E");background-size:cover;background-repeat:no-repeat}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span></div>';
9
+ const templateHTML = '<style>:host{display:block}*{pointer-events:none}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:6px 12px;width:100%;align-items:center;gap:12px;--sinch-size-icon:24px}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([checked])>#wrapper{padding-right:36px}:host([checked])>#wrapper::after{content:"";position:absolute;top:12px;right:11px;width:18px;height:14px;background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M6 11.17 1.83 7 .41 8.41 6 14 18 2 16.59.59 6 11.17Z\' fill=\'%230A273D\'/%3E%3C/svg%3E");background-size:cover;background-repeat:no-repeat}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span></div>';
10
10
  const template = document.createElement('template');
11
11
  template.innerHTML = templateHTML;
12
12
 
@@ -0,0 +1,11 @@
1
+ import type { TSinchIconElement, TSinchIconReact } from '../types';
2
+ declare global {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ 'sinch-icon-add-alert': TSinchIconReact;
6
+ }
7
+ }
8
+ interface HTMLElementTagNameMap {
9
+ 'sinch-icon-add-alert': TSinchIconElement;
10
+ }
11
+ }