@nectary/components 0.33.0 → 0.35.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 (91) hide show
  1. package/accordion/index.js +35 -10
  2. package/accordion/types.d.ts +3 -2
  3. package/accordion-item/index.js +8 -4
  4. package/action-menu/index.js +7 -8
  5. package/action-menu/types.d.ts +3 -3
  6. package/action-menu-option/index.js +23 -3
  7. package/action-menu-option/types.d.ts +2 -0
  8. package/alert/index.js +1 -1
  9. package/avatar/index.js +1 -1
  10. package/button/index.js +68 -4
  11. package/button/types.d.ts +6 -0
  12. package/checkbox/index.js +64 -6
  13. package/checkbox/types.d.ts +8 -2
  14. package/date-picker/index.js +37 -12
  15. package/date-picker/types.d.ts +4 -2
  16. package/dialog/index.d.ts +1 -0
  17. package/dialog/index.js +8 -12
  18. package/dialog/types.d.ts +3 -3
  19. package/dropdown/index.js +44 -28
  20. package/dropdown/types.d.ts +6 -4
  21. package/dropdown-checkbox-option/index.js +1 -1
  22. package/dropdown-checkbox-option/types.d.ts +0 -2
  23. package/dropdown-radio-option/index.js +1 -1
  24. package/dropdown-radio-option/types.d.ts +0 -2
  25. package/dropdown-text-option/index.js +1 -1
  26. package/dropdown-text-option/types.d.ts +0 -2
  27. package/horizontal-stepper/index.d.ts +13 -0
  28. package/horizontal-stepper/index.js +104 -0
  29. package/horizontal-stepper/types.d.ts +9 -0
  30. package/horizontal-stepper/types.js +1 -0
  31. package/horizontal-stepper-item/index.d.ts +13 -0
  32. package/horizontal-stepper-item/index.js +100 -0
  33. package/horizontal-stepper-item/types.d.ts +15 -0
  34. package/horizontal-stepper-item/types.js +1 -0
  35. package/horizontal-stepper-item/utils.d.ts +2 -0
  36. package/horizontal-stepper-item/utils.js +1 -0
  37. package/icon-button/index.js +67 -3
  38. package/icon-button/types.d.ts +6 -0
  39. package/icons/create-icon-class.js +1 -1
  40. package/icons/exclamation/index.d.ts +11 -0
  41. package/icons/exclamation/index.js +4 -0
  42. package/icons-branded/create-icon-class.js +3 -7
  43. package/icons-branded/types.d.ts +3 -0
  44. package/icons-channel/create-icon-class.js +3 -7
  45. package/icons-channel/types.d.ts +3 -0
  46. package/input/index.js +50 -19
  47. package/input/types.d.ts +8 -2
  48. package/link/index.js +81 -3
  49. package/link/types.d.ts +9 -0
  50. package/package.json +1 -1
  51. package/pagination/index.js +24 -8
  52. package/pagination/types.d.ts +3 -1
  53. package/popover/index.js +10 -13
  54. package/popover/types.d.ts +4 -3
  55. package/radio/index.js +36 -8
  56. package/radio/types.d.ts +3 -1
  57. package/radio-option/index.js +1 -1
  58. package/search/types.d.ts +0 -1
  59. package/segment-collapse/index.js +28 -12
  60. package/segment-collapse/types.d.ts +3 -1
  61. package/segmented-control/index.js +28 -23
  62. package/segmented-control/types.d.ts +3 -2
  63. package/segmented-control-option/index.js +59 -13
  64. package/segmented-control-option/types.d.ts +4 -0
  65. package/segmented-icon-control/index.js +27 -16
  66. package/segmented-icon-control/types.d.ts +5 -2
  67. package/segmented-icon-control-option/index.js +54 -12
  68. package/segmented-icon-control-option/types.d.ts +4 -0
  69. package/select/index.js +68 -9
  70. package/select/types.d.ts +41 -7
  71. package/stop-events/index.d.ts +1 -0
  72. package/stop-events/index.js +40 -0
  73. package/tabs/index.js +32 -8
  74. package/tabs/types.d.ts +3 -2
  75. package/tabs-option/index.js +2 -2
  76. package/textarea/index.js +58 -4
  77. package/textarea/types.d.ts +7 -2
  78. package/tile-control/index.d.ts +11 -0
  79. package/tile-control/index.js +181 -0
  80. package/tile-control/types.d.ts +38 -0
  81. package/tile-control/types.js +1 -0
  82. package/tile-control-option/index.d.ts +11 -0
  83. package/tile-control-option/index.js +161 -0
  84. package/tile-control-option/types.d.ts +37 -0
  85. package/tile-control-option/types.js +1 -0
  86. package/time-picker/index.js +17 -3
  87. package/time-picker/types.d.ts +4 -2
  88. package/toggle/index.js +63 -5
  89. package/toggle/types.d.ts +3 -1
  90. package/utils.d.ts +1 -0
  91. package/utils.js +3 -0
package/checkbox/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$input, _$label, _onCheckboxInput;
4
+ var _$input, _$label, _onCheckboxInput, _onCheckboxFocus, _onCheckboxBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
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
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } 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:var(--sinch-shape-radius-xs);pointer-events:none;background-color:var(--sinch-color-checkbox-background);border:2px solid var(--sinch-color-checkbox-border);transition:background-color .1s linear;box-sizing:border-box}#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);border-color:var(--sinch-color-checkbox-border-checked)}#checkbox:focus::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus::after{background-color:var(--sinch-color-checkbox-background-focus);border-color:var(--sinch-color-checkbox-border-focus)}#checkbox:hover::before{background-color:var(--sinch-color-checkbox-circle-hover)}#checkbox:hover::after{background-color:var(--sinch-color-checkbox-background-hover);border-color:var(--sinch-color-checkbox-border-hover)}#checkbox:active::before{background-color:var(--sinch-color-checkbox-circle-active)}#checkbox:active::after{background-color:var(--sinch-color-checkbox-background-active);border-color:var(--sinch-color-checkbox-border-active)}#checkbox:disabled::before{background-color:var(--sinch-color-checkbox-circle-disabled)}#checkbox:disabled::after{background-color:var(--sinch-color-checkbox-background-disabled);border-color:var(--sinch-color-checkbox-border-disabled)}#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);border-color:var(--sinch-color-checkbox-border-focus-checked)}#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);border-color:var(--sinch-color-checkbox-border-hover-checked)}#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);border-color:var(--sinch-color-checkbox-border-active-checked)}#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);border-color:var(--sinch-color-checkbox-border-disabled-checked)}</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>';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } 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:var(--sinch-shape-radius-xs);pointer-events:none;background-color:var(--sinch-color-checkbox-background);border:2px solid var(--sinch-color-checkbox-border);transition:background-color .1s linear;box-sizing:border-box}#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);border-color:var(--sinch-color-checkbox-border-checked)}#checkbox:focus::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus::after{background-color:var(--sinch-color-checkbox-background-focus);border-color:var(--sinch-color-checkbox-border-focus)}#checkbox:hover::before{background-color:var(--sinch-color-checkbox-circle-hover)}#checkbox:hover::after{background-color:var(--sinch-color-checkbox-background-hover);border-color:var(--sinch-color-checkbox-border-hover)}#checkbox:active::before{background-color:var(--sinch-color-checkbox-circle-active)}#checkbox:active::after{background-color:var(--sinch-color-checkbox-background-active);border-color:var(--sinch-color-checkbox-border-active)}#checkbox:disabled::before{background-color:var(--sinch-color-checkbox-circle-disabled)}#checkbox:disabled::after{background-color:var(--sinch-color-checkbox-background-disabled);border-color:var(--sinch-color-checkbox-border-disabled)}#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);border-color:var(--sinch-color-checkbox-border-focus-checked)}#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);border-color:var(--sinch-color-checkbox-border-hover-checked)}#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);border-color:var(--sinch-color-checkbox-border-active-checked)}#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);border-color:var(--sinch-color-checkbox-border-disabled-checked)}</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
- defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new WeakMap(), _onCheckboxInput = new WeakMap(), class extends NectaryElement {
14
+ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new WeakMap(), _onCheckboxInput = new WeakMap(), _onCheckboxFocus = new WeakMap(), _onCheckboxBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -37,6 +37,44 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
37
37
  detail: isChecked,
38
38
  bubbles: true
39
39
  }));
40
+ this.dispatchEvent(new CustomEvent('-change', {
41
+ detail: isChecked
42
+ }));
43
+ }
44
+ });
45
+
46
+ _classPrivateFieldInitSpec(this, _onCheckboxFocus, {
47
+ writable: true,
48
+ value: () => {
49
+ this.dispatchEvent(new CustomEvent('-focus'));
50
+ }
51
+ });
52
+
53
+ _classPrivateFieldInitSpec(this, _onCheckboxBlur, {
54
+ writable: true,
55
+ value: () => {
56
+ this.dispatchEvent(new CustomEvent('-blur'));
57
+ }
58
+ });
59
+
60
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
61
+ writable: true,
62
+ value: e => {
63
+ getReactEventHandler(this, 'on-change')?.(e);
64
+ }
65
+ });
66
+
67
+ _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
68
+ writable: true,
69
+ value: e => {
70
+ getReactEventHandler(this, 'on-focus')?.(e);
71
+ }
72
+ });
73
+
74
+ _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
75
+ writable: true,
76
+ value: e => {
77
+ getReactEventHandler(this, 'on-blur')?.(e);
40
78
  }
41
79
  });
42
80
 
@@ -46,12 +84,32 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
46
84
  _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
47
85
 
48
86
  _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
49
-
50
- _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onCheckboxInput));
51
87
  }
52
88
 
53
89
  connectedCallback() {
54
90
  this.setAttribute('role', 'checkbox');
91
+
92
+ _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onCheckboxInput));
93
+
94
+ _classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onCheckboxFocus));
95
+
96
+ _classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onCheckboxBlur));
97
+
98
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
99
+ this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
100
+ this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
101
+ }
102
+
103
+ disconnectedCallback() {
104
+ _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onCheckboxInput));
105
+
106
+ _classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onCheckboxFocus));
107
+
108
+ _classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onCheckboxBlur));
109
+
110
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
111
+ this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
112
+ this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
55
113
  }
56
114
 
57
115
  static get observedAttributes() {
@@ -6,7 +6,9 @@ export declare type TSinchCheckboxElement = HTMLElement & {
6
6
  disabled: boolean;
7
7
  invalid: boolean;
8
8
  text: string | null;
9
- addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
9
+ addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
10
+ addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
11
+ addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
10
12
  setAttribute(name: 'checked', value: ''): void;
11
13
  setAttribute(name: 'indeterminate', value: ''): void;
12
14
  setAttribute(name: 'disabled', value: ''): void;
@@ -20,5 +22,9 @@ export declare type TSinchCheckboxReact = TSinchElementReact<TSinchCheckboxEleme
20
22
  invalid?: boolean;
21
23
  text?: string;
22
24
  'aria-label': string;
23
- onChange: (event: SyntheticEvent<TSinchCheckboxElement, CustomEvent<boolean>>) => void;
25
+ /** @deprecated */
26
+ onChange?: (event: SyntheticEvent<TSinchCheckboxElement, CustomEvent<boolean>>) => void;
27
+ 'on-change'?: (e: CustomEvent<boolean>) => void;
28
+ 'on-focus'?: (e: CustomEvent<void>) => void;
29
+ 'on-blur'?: (e: CustomEvent<void>) => void;
24
30
  };
@@ -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 _$month, _$weeks, _$days, _$weekDayNames, _date, _minDate, _maxDate, _$prevMonth, _$nextMonth, _$prevYear, _$nextYear, _$date, _monthNames, _onPrevMonthClick, _onNextMonthClick, _onPrevYearClick, _onNextYearClick, _onDateClick, _render;
4
+ var _$month, _$weeks, _$days, _$weekDayNames, _date, _minDate, _maxDate, _$prevMonth, _$nextMonth, _$prevYear, _$nextYear, _$date, _monthNames, _onPrevMonthClick, _onNextMonthClick, _onPrevYearClick, _onNextYearClick, _onDateClick, _render, _dispatchChangeEvent, _onChangeReactHandler;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -19,15 +19,17 @@ import '../icons/keyboard-double-arrow-left';
19
19
  import '../icons/delete-outline';
20
20
  import '../icons/today';
21
21
  import '../text';
22
- import { defineCustomElement, getAttribute, getRect, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
23
- const templateHTML = '<style>:host{display:block;outline:0}#content{width:fit-content;box-sizing:border-box;padding:16px;display:flex;flex-direction:column;gap:8px}#month{display:flex;flex-direction:column;row-gap:8px}.week{display:flex;flex-direction:row;column-gap:8px}.week.empty{display:none}.day{all:initial;font:var(--sinch-font-text-xs);color:var(--sinch-color-text-default);text-align:center;border-radius:var(--sinch-shape-radius-m);width:24px;height:24px;line-height:22px;cursor:pointer;border:1px solid transparent;background-color:transparent;box-sizing:border-box;user-select:none}.day.today{border:1px solid var(--sinch-color-stormy-500)}.day:disabled{cursor:initial;color:var(--sinch-color-snow-700)}.day:focus-visible{outline:1px solid var(--sinch-color-aqua-400);outline-offset:1px}@supports not selector(:focus-visible){.day:focus{outline:1px solid var(--sinch-color-aqua-400);outline-offset:1px}}.day.selected{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100)}.day:hover:not(:disabled):not(.selected){background-color:var(--sinch-color-snow-600)}#week-day-names{display:flex;flex-direction:row;gap:8px;height:24px}.week-day-name{font:var(--sinch-font-text-xs);font-weight:var(--sinch-font-weight-emphasized);color:var(--sinch-color-text-default);text-align:center;width:24px;height:24px;line-height:24px;user-select:none;text-transform:uppercase}#content-header{display:flex;flex-direction:row;height:32px;align-items:center}#date{flex:1;text-align:center;text-transform:capitalize}#prev-year{margin-left:-4px}#next-year{margin-right:-4px}</style><div id="content"><div id="content-header"><sinch-icon-button small id="prev-year"><sinch-icon-keyboard-double-arrow-left slot="icon"></sinch-icon-keyboard-double-arrow-left></sinch-icon-button><sinch-icon-button small id="prev-month"><sinch-icon-keyboard-arrow-left slot="icon"></sinch-icon-keyboard-arrow-left></sinch-icon-button><sinch-text type="m" emphasized id="date"></sinch-text><sinch-icon-button small id="next-month"><sinch-icon-keyboard-arrow-right slot="icon"></sinch-icon-keyboard-arrow-right></sinch-icon-button><sinch-icon-button small id="next-year"><sinch-icon-keyboard-double-arrow-right slot="icon"></sinch-icon-keyboard-double-arrow-right></sinch-icon-button></div><div id="week-day-names"><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div></div><div id="month"><div class="week"><button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button></div><div class="week"><button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button></div><div class="week"><button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button></div><div class="week"><button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button></div><div class="week"><button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button></div><div class="week"><button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button> <button class="day"></button></div></div></div>';
22
+ import { defineCustomElement, getAttribute, getReactEventHandler, getRect, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
23
+ const templateHTML = '<style>:host{display:block;outline:0}#content{width:fit-content;box-sizing:border-box;padding:16px;display:flex;flex-direction:column;gap:8px}#month{display:flex;flex-direction:column;row-gap:8px}.week{display:flex;flex-direction:row;column-gap:8px}.week.empty{display:none}.day{all:initial;font:var(--sinch-font-text-xs);color:var(--sinch-color-text-default);text-align:center;border-radius:var(--sinch-shape-radius-m);width:24px;height:24px;line-height:22px;cursor:pointer;border:1px solid transparent;background-color:transparent;box-sizing:border-box;user-select:none}.day.today{border:1px solid var(--sinch-color-stormy-500)}.day:disabled{cursor:initial;color:var(--sinch-color-snow-700)}.day:focus-visible{outline:1px solid var(--sinch-color-aqua-400);outline-offset:1px}@supports not selector(:focus-visible){.day:focus{outline:1px solid var(--sinch-color-aqua-400);outline-offset:1px}}.day.selected{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100)}.day:hover:not(:disabled):not(.selected){background-color:var(--sinch-color-snow-600)}#week-day-names{display:flex;flex-direction:row;gap:8px;height:24px}.week-day-name{font:var(--sinch-font-text-xs);font-weight:var(--sinch-font-weight-emphasized);color:var(--sinch-color-text-default);text-align:center;width:24px;height:24px;line-height:24px;user-select:none;text-transform:uppercase}#content-header{display:flex;flex-direction:row;height:32px;align-items:center}#date{flex:1;text-align:center;text-transform:capitalize}#prev-year{margin-left:-4px}#next-year{margin-right:-4px}</style><div id="content"><div id="content-header"><sinch-icon-button small id="prev-year"><sinch-icon-keyboard-double-arrow-left slot="icon"></sinch-icon-keyboard-double-arrow-left></sinch-icon-button><sinch-icon-button small id="prev-month"><sinch-icon-keyboard-arrow-left slot="icon"></sinch-icon-keyboard-arrow-left></sinch-icon-button><sinch-text type="m" emphasized id="date"></sinch-text><sinch-icon-button small id="next-month"><sinch-icon-keyboard-arrow-right slot="icon"></sinch-icon-keyboard-arrow-right></sinch-icon-button><sinch-icon-button small id="next-year"><sinch-icon-keyboard-double-arrow-right slot="icon"></sinch-icon-keyboard-double-arrow-right></sinch-icon-button></div><div id="week-day-names"><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div><div class="week-day-name"></div></div><div id="month"><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div><div class="week"><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button><button class="day"></button></div></div></div>';
24
24
  import { areDatesEqual, assertDate, assertLocale, assertMinMax, assertValue, canGoNextMonth, canGoNextYear, canGoPrevMonth, canGoPrevYear, clampMaxDate, clampMinDate, dateToIso, decMonth, decYear, getCalendarMonth, getDayNames, getMonthNames, incMonth, incYear, isDateBetween, isoToDate, isValidDate, today } from './utils';
25
25
  const template = document.createElement('template');
26
26
  template.innerHTML = templateHTML;
27
- defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new WeakMap(), _$days = new WeakMap(), _$weekDayNames = new WeakMap(), _date = new WeakMap(), _minDate = new WeakMap(), _maxDate = new WeakMap(), _$prevMonth = new WeakMap(), _$nextMonth = new WeakMap(), _$prevYear = new WeakMap(), _$nextYear = new WeakMap(), _$date = new WeakMap(), _monthNames = new WeakMap(), _onPrevMonthClick = new WeakMap(), _onNextMonthClick = new WeakMap(), _onPrevYearClick = new WeakMap(), _onNextYearClick = new WeakMap(), _onDateClick = new WeakMap(), _render = new WeakSet(), class extends NectaryElement {
27
+ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new WeakMap(), _$days = new WeakMap(), _$weekDayNames = new WeakMap(), _date = new WeakMap(), _minDate = new WeakMap(), _maxDate = new WeakMap(), _$prevMonth = new WeakMap(), _$nextMonth = new WeakMap(), _$prevYear = new WeakMap(), _$nextYear = new WeakMap(), _$date = new WeakMap(), _monthNames = new WeakMap(), _onPrevMonthClick = new WeakMap(), _onNextMonthClick = new WeakMap(), _onPrevYearClick = new WeakMap(), _onNextYearClick = new WeakMap(), _onDateClick = new WeakMap(), _render = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
28
28
  constructor() {
29
29
  super();
30
30
 
31
+ _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
32
+
31
33
  _classPrivateMethodInitSpec(this, _render);
32
34
 
33
35
  _classPrivateFieldInitSpec(this, _$month, {
@@ -97,7 +99,8 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
97
99
 
98
100
  _classPrivateFieldInitSpec(this, _onPrevMonthClick, {
99
101
  writable: true,
100
- value: () => {
102
+ value: e => {
103
+ e.stopPropagation();
101
104
  decMonth(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _minDate));
102
105
 
103
106
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -106,7 +109,8 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
106
109
 
107
110
  _classPrivateFieldInitSpec(this, _onNextMonthClick, {
108
111
  writable: true,
109
- value: () => {
112
+ value: e => {
113
+ e.stopPropagation();
110
114
  incMonth(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _maxDate));
111
115
 
112
116
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -115,7 +119,8 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
115
119
 
116
120
  _classPrivateFieldInitSpec(this, _onPrevYearClick, {
117
121
  writable: true,
118
- value: () => {
122
+ value: e => {
123
+ e.stopPropagation();
119
124
  decYear(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _minDate));
120
125
 
121
126
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -124,7 +129,8 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
124
129
 
125
130
  _classPrivateFieldInitSpec(this, _onNextYearClick, {
126
131
  writable: true,
127
- value: () => {
132
+ value: e => {
133
+ e.stopPropagation();
128
134
  incYear(_classPrivateFieldGet(this, _date), _classPrivateFieldGet(this, _maxDate));
129
135
 
130
136
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -134,16 +140,21 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
134
140
  _classPrivateFieldInitSpec(this, _onDateClick, {
135
141
  writable: true,
136
142
  value: e => {
143
+ e.stopPropagation();
137
144
  const dateIso = e.target.getAttribute('data-date');
138
145
 
139
146
  if (dateIso === null || dateIso.length === 0) {
140
147
  return;
141
148
  }
142
149
 
143
- this.dispatchEvent(new CustomEvent('change', {
144
- detail: dateIso,
145
- bubbles: true
146
- }));
150
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, dateIso);
151
+ }
152
+ });
153
+
154
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
155
+ writable: true,
156
+ value: e => {
157
+ getReactEventHandler(this, 'on-change')?.(e);
147
158
  }
148
159
  });
149
160
 
@@ -190,6 +201,8 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
190
201
  _classPrivateFieldGet(this, _$nextYear).addEventListener('click', _classPrivateFieldGet(this, _onNextYearClick));
191
202
 
192
203
  _classPrivateFieldGet(this, _$month).addEventListener('click', _classPrivateFieldGet(this, _onDateClick));
204
+
205
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
193
206
  }
194
207
 
195
208
  disconnectedCallback() {
@@ -202,6 +215,8 @@ defineCustomElement('sinch-date-picker', (_$month = new WeakMap(), _$weeks = new
202
215
  _classPrivateFieldGet(this, _$nextYear).removeEventListener('click', _classPrivateFieldGet(this, _onNextYearClick));
203
216
 
204
217
  _classPrivateFieldGet(this, _$month).removeEventListener('click', _classPrivateFieldGet(this, _onDateClick));
218
+
219
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
205
220
  }
206
221
 
207
222
  static get observedAttributes() {
@@ -416,4 +431,14 @@ function _render2() {
416
431
  });
417
432
  setClass(_classPrivateFieldGet(this, _$weeks)[wi], 'empty', isEmptyWeek);
418
433
  });
434
+ }
435
+
436
+ function _dispatchChangeEvent2(value) {
437
+ this.dispatchEvent(new CustomEvent('change', {
438
+ detail: value,
439
+ bubbles: true
440
+ }));
441
+ this.dispatchEvent(new CustomEvent('-change', {
442
+ detail: value
443
+ }));
419
444
  }
@@ -15,7 +15,7 @@ export declare type TSinchDatePickerElement = HTMLElement & {
15
15
  readonly nextMonthButtonRect: TRect;
16
16
  nthButtonRect(index: number): TRect | null;
17
17
  /** Change value handler, return date in ISO 8601 format */
18
- addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
18
+ addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
19
19
  /** Date value in ISO 8601 format */
20
20
  setAttribute(name: 'value', value: string): void;
21
21
  /** Date min limit in ISO 8601 format */
@@ -37,5 +37,7 @@ export declare type TSinchDatePickerReact = TSinchElementReact<TSinchDatePickerE
37
37
  /** Label that is used for a11y */
38
38
  'aria-label': string;
39
39
  /** Change value handler, return date in ISO 8601 format */
40
- onChange: (e: SyntheticEvent<TSinchDatePickerElement, CustomEvent<string>>) => void;
40
+ onChange?: (e: SyntheticEvent<TSinchDatePickerElement, CustomEvent<string>>) => void;
41
+ /** Change value handler, return date in ISO 8601 format */
42
+ 'on-change'?: (e: CustomEvent<string>) => void;
41
43
  };
package/dialog/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import '../icon-button';
2
2
  import '../icons/close';
3
+ import '../stop-events';
3
4
  import type { TSinchDialogElement, TSinchDialogReact } from './types';
4
5
  declare global {
5
6
  namespace JSX {
package/dialog/index.js CHANGED
@@ -14,8 +14,9 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
14
14
  import dialogPolyfill from 'dialog-polyfill';
15
15
  import '../icon-button';
16
16
  import '../icons/close';
17
+ import '../stop-events';
17
18
  import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttrTrue, updateAttribute, getReactEventHandler, NectaryElement, updateBooleanAttribute } from '../utils';
18
- const templateHTML = '<style>dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px;max-width:var(--sinch-dialog-max-width,512px);max-height:unset;border-radius:var(--sinch-shape-radius-l);box-sizing:border-box;contain:content;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:var(--sinch-elevation-level-3)}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-items:flex-start;margin-bottom:16px}#caption{font:var(--sinch-font-title-m);color:var(--sinch-color-text-default);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#content-wrapper{min-height:0;overflow:auto;max-height:var(--sinch-dialog-max-height,50vh)}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}sinch-icon-button{transform:translate(4px,-4px)}</style><dialog><div id="header"><span id="caption"></span><sinch-icon-button id="close" small tabindex="0"><sinch-icon-close slot="icon"></sinch-icon-close></sinch-icon-button></div><div id="content-wrapper"><slot name="content"></slot></div><div id="buttons"><slot name="buttons"></slot></div></dialog>';
19
+ const templateHTML = '<style>dialog{position:fixed;left:0;right:0;margin:auto;display:flex;flex-direction:column;padding:24px;max-width:var(--sinch-dialog-max-width,512px);max-height:unset;border-radius:var(--sinch-shape-radius-l);box-sizing:border-box;contain:content;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:var(--sinch-elevation-level-3)}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-items:flex-start;margin-bottom:16px}#caption{font:var(--sinch-font-title-m);color:var(--sinch-color-text-default);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#content{min-height:0;overflow:auto;max-height:var(--sinch-dialog-max-height,50vh)}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}sinch-icon-button{transform:translate(4px,-4px)}</style><dialog><div id="header"><span id="caption"></span><sinch-icon-button id="close" small tabindex="0"><sinch-icon-close slot="icon"></sinch-icon-close></sinch-icon-button></div><div id="content"><sinch-stop-events events="close"><slot name="content"></slot></sinch-stop-events></div><div id="buttons"><sinch-stop-events events="close"><slot name="buttons"></slot></sinch-stop-events></div></dialog>';
19
20
  const template = document.createElement('template');
20
21
  template.innerHTML = templateHTML;
21
22
  defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = new WeakMap(), _$caption = new WeakMap(), _isConnected = new WeakMap(), _prevOverflowValue = new WeakMap(), _onCancel = new WeakMap(), _onCloseClick = new WeakMap(), _onBackdropClick = new WeakMap(), _onCloseReactHandler = new WeakMap(), _dispatchCloseEvent = new WeakSet(), _setOpen = new WeakSet(), class extends NectaryElement {
@@ -62,9 +63,7 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
62
63
 
63
64
  _classPrivateFieldInitSpec(this, _onCloseClick, {
64
65
  writable: true,
65
- value: e => {
66
- e.stopPropagation();
67
-
66
+ value: () => {
68
67
  _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
69
68
  }
70
69
  });
@@ -80,8 +79,6 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
80
79
  const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
81
80
 
82
81
  if (!isInside) {
83
- e.stopPropagation();
84
-
85
82
  _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
86
83
  }
87
84
  }
@@ -89,8 +86,9 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
89
86
 
90
87
  _classPrivateFieldInitSpec(this, _onCloseReactHandler, {
91
88
  writable: true,
92
- value: () => {
89
+ value: e => {
93
90
  getReactEventHandler(this, 'onClose')?.();
91
+ getReactEventHandler(this, 'on-close')?.(e);
94
92
  }
95
93
  });
96
94
 
@@ -115,7 +113,7 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
115
113
 
116
114
  _classPrivateFieldGet(this, _$dialog).addEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
117
115
 
118
- this.addEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
116
+ this.addEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
119
117
 
120
118
  _classPrivateFieldSet(this, _isConnected, true);
121
119
 
@@ -129,7 +127,7 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
129
127
 
130
128
  _classPrivateFieldGet(this, _$dialog).removeEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
131
129
 
132
- this.removeEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
130
+ this.removeEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
133
131
 
134
132
  _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, false);
135
133
 
@@ -185,9 +183,7 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
185
183
  }));
186
184
 
187
185
  function _dispatchCloseEvent2() {
188
- this.dispatchEvent(new CustomEvent('close', {
189
- bubbles: true
190
- }));
186
+ this.dispatchEvent(new CustomEvent('-close'));
191
187
  }
192
188
 
193
189
  function _setOpen2(shouldOpen) {
package/dialog/types.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
- import type { SyntheticEvent } from 'react';
3
2
  export declare type TSinchDialogElement = HTMLElement & {
4
3
  caption: string;
5
4
  readonly dialogRect: TRect;
6
5
  readonly closeButtonRect: TRect;
7
- addEventListener(type: 'close', listener: (e: CustomEvent<void>) => void): void;
6
+ addEventListener(type: '-close', listener: (e: CustomEvent<void>) => void): void;
8
7
  setAttribute(name: 'caption', value: string): void;
9
8
  setAttribute(name: 'close-aria-label', value: string): void;
10
9
  };
@@ -13,5 +12,6 @@ export declare type TSinchDialogReact = TSinchElementReact<TSinchDialogElement>
13
12
  caption: string;
14
13
  'aria-label': string;
15
14
  'close-aria-label': string;
16
- onClose: (event: SyntheticEvent<TSinchDialogElement, CustomEvent<void>>) => void;
15
+ onClose?: () => void;
16
+ 'on-close'?: (e: CustomEvent<void>) => void;
17
17
  };
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 _$optionSlot, _$listbox, _$popover, _onListboxClick, _onListboxKeyDown, _onOptionSlotChange, _onValueChange, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionWithValue, _getOptionElements, _findSelectedOption, _getEnabledOptionElements, _dispatchChangeEvent, _onOpen, _onClose, _onReactClose;
4
+ var _$optionSlot, _$listbox, _$popover, _onListboxClick, _onListboxKeyDown, _onOptionSlotChange, _onValueChange, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionWithValue, _getOptionElements, _findSelectedOption, _getEnabledOptionElements, _dispatchChangeEvent, _onClose, _onCloseReactHandler, _onChangeReactHandler;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -18,12 +18,10 @@ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;ou
18
18
  const ITEM_HEIGHT = 40;
19
19
  const template = document.createElement('template');
20
20
  template.innerHTML = templateHTML;
21
- defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$popover = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onValueChange = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionWithValue = new WeakSet(), _getOptionElements = new WeakSet(), _findSelectedOption = new WeakSet(), _getEnabledOptionElements = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onOpen = new WeakSet(), _onClose = new WeakMap(), _onReactClose = new WeakMap(), class extends NectaryElement {
21
+ defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$popover = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onValueChange = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionWithValue = new WeakSet(), _getOptionElements = new WeakSet(), _findSelectedOption = new WeakSet(), _getEnabledOptionElements = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onClose = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
22
22
  constructor() {
23
23
  super();
24
24
 
25
- _classPrivateMethodInitSpec(this, _onOpen);
26
-
27
25
  _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
28
26
 
29
27
  _classPrivateMethodInitSpec(this, _getEnabledOptionElements);
@@ -66,11 +64,13 @@ defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox =
66
64
  value: e => {
67
65
  const $elem = e.target;
68
66
 
69
- if (!$elem.disabled) {
70
- e.stopPropagation();
71
-
72
- _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $elem);
67
+ if (getBooleanAttribute($elem, 'disabled')) {
68
+ return;
73
69
  }
70
+
71
+ e.stopPropagation();
72
+
73
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $elem);
74
74
  }
75
75
  });
76
76
 
@@ -125,16 +125,22 @@ defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox =
125
125
  _classPrivateFieldInitSpec(this, _onClose, {
126
126
  writable: true,
127
127
  value: () => {
128
- this.dispatchEvent(new CustomEvent('close', {
129
- bubbles: true
130
- }));
128
+ this.dispatchEvent(new CustomEvent('-close'));
131
129
  }
132
130
  });
133
131
 
134
- _classPrivateFieldInitSpec(this, _onReactClose, {
132
+ _classPrivateFieldInitSpec(this, _onCloseReactHandler, {
135
133
  writable: true,
136
- value: () => {
134
+ value: e => {
137
135
  getReactEventHandler(this, 'onClose')?.();
136
+ getReactEventHandler(this, 'on-close')?.(e);
137
+ }
138
+ });
139
+
140
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
141
+ writable: true,
142
+ value: e => {
143
+ getReactEventHandler(this, 'on-change')?.(e);
138
144
  }
139
145
  });
140
146
 
@@ -153,17 +159,19 @@ defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox =
153
159
 
154
160
  _classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
155
161
 
156
- this.addEventListener('close', _classPrivateFieldGet(this, _onReactClose));
162
+ this.addEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
163
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
157
164
  }
158
165
 
159
166
  disconnectedCallback() {
160
167
  _classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
161
168
 
162
- this.removeEventListener('close', _classPrivateFieldGet(this, _onReactClose));
169
+ this.removeEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
170
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
163
171
  }
164
172
 
165
173
  static get observedAttributes() {
166
- return ['open', 'value', 'orientation', 'maxvisibleitems'];
174
+ return ['open', 'value', 'orientation', 'maxvisibleitems', 'multiple'];
167
175
  }
168
176
 
169
177
  get nodeName() {
@@ -215,30 +223,41 @@ defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox =
215
223
  }
216
224
 
217
225
  attributeChangedCallback(name, oldVal, newVal) {
226
+ if (oldVal === newVal) {
227
+ return;
228
+ }
229
+
218
230
  switch (name) {
219
231
  case 'open':
220
232
  {
221
233
  updateAttribute(_classPrivateFieldGet(this, _$popover), 'open', newVal);
222
234
 
223
235
  if (isAttrTrue(newVal)) {
224
- _classPrivateMethodGet(this, _onOpen, _onOpen2).call(this);
236
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getOptionWithValue, _getOptionWithValue2).call(this, getFirstCsvValue(this.value)) ?? _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
225
237
 
226
238
  _classPrivateFieldGet(this, _$popover).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
227
239
 
228
240
  _classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
229
241
 
230
- _classPrivateFieldGet(this, _$popover).addEventListener('close', _classPrivateFieldGet(this, _onClose));
242
+ _classPrivateFieldGet(this, _$popover).addEventListener('-close', _classPrivateFieldGet(this, _onClose));
231
243
  } else {
232
244
  _classPrivateFieldGet(this, _$popover).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
233
245
 
234
246
  _classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
235
247
 
236
- _classPrivateFieldGet(this, _$popover).removeEventListener('close', _classPrivateFieldGet(this, _onClose));
248
+ _classPrivateFieldGet(this, _$popover).removeEventListener('-close', _classPrivateFieldGet(this, _onClose));
237
249
  }
238
250
 
239
251
  break;
240
252
  }
241
253
 
254
+ case 'multiple':
255
+ {
256
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
257
+
258
+ break;
259
+ }
260
+
242
261
  case 'orientation':
243
262
  {
244
263
  updateAttribute(_classPrivateFieldGet(this, _$popover), 'orientation', newVal);
@@ -278,14 +297,14 @@ function _onValueChange2(csv) {
278
297
 
279
298
  for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
280
299
  const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
281
- updateBooleanAttribute($option, 'checked', isChecked);
300
+ updateBooleanAttribute($option, 'data-checked', isChecked);
282
301
  }
283
302
  } else {
284
303
  const value = getFirstCsvValue(csv);
285
304
 
286
305
  for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
287
306
  const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
288
- updateBooleanAttribute($option, 'checked', isChecked);
307
+ updateBooleanAttribute($option, 'data-checked', isChecked);
289
308
  }
290
309
  }
291
310
  }
@@ -385,15 +404,12 @@ function _dispatchChangeEvent2($opt) {
385
404
  }
386
405
 
387
406
  const value = $opt.value;
388
- const result = this.multiple ? updateCsv(this.value, value, !$opt.checked) : value;
407
+ const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($opt, 'data-checked')) : value;
389
408
  this.dispatchEvent(new CustomEvent('change', {
390
409
  detail: result,
391
410
  bubbles: true
392
411
  }));
393
- }
394
-
395
- function _onOpen2() {
396
- const $opt = _classPrivateMethodGet(this, _getOptionWithValue, _getOptionWithValue2).call(this, getFirstCsvValue(this.value));
397
-
398
- _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, $opt ?? _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
412
+ this.dispatchEvent(new CustomEvent('-change', {
413
+ detail: result
414
+ }));
399
415
  }
@@ -8,8 +8,8 @@ export declare type TSinchDropdownElement = HTMLElement & {
8
8
  value: string;
9
9
  maxVisibleItems: number | null;
10
10
  readonly dropdownRect: TRect;
11
- addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
12
- addEventListener(type: 'close', listener: (e: CustomEvent<void>) => void): void;
11
+ addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
12
+ addEventListener(type: '-close', listener: (e: CustomEvent<void>) => void): void;
13
13
  setAttribute(name: 'open', value: ''): void;
14
14
  setAttribute(name: 'multiple', value: ''): void;
15
15
  setAttribute(name: 'orientation', value: TSinchPopoverOrientation): void;
@@ -23,6 +23,8 @@ export declare type TSinchDropdownReact = TSinchElementReact<TSinchDropdownEleme
23
23
  value: string;
24
24
  maxVisibleItems?: number;
25
25
  'aria-label': string;
26
- onClose: (event: SyntheticEvent<TSinchDropdownElement, CustomEvent<void>>) => void;
27
- onChange: (e: SyntheticEvent<TSinchDropdownElement, CustomEvent<string>>) => void;
26
+ onClose?: () => void;
27
+ 'on-close'?: (e: CustomEvent<void>) => void;
28
+ onChange?: (e: SyntheticEvent<TSinchDropdownElement, CustomEvent<string>>) => void;
29
+ 'on-change'?: (e: CustomEvent<string>) => void;
28
30
  };