@nectary/components 0.39.0 → 0.41.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 (142) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +30 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +177 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +52 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +46 -92
  16. package/button/types.d.ts +1 -1
  17. package/card/index.js +21 -59
  18. package/chat-avatar/index.js +8 -22
  19. package/chat-block/index.js +29 -69
  20. package/chat-bubble/index.js +6 -20
  21. package/checkbox/index.js +59 -107
  22. package/chip/index.d.ts +13 -0
  23. package/chip/index.js +140 -0
  24. package/chip/types.d.ts +37 -0
  25. package/color-menu/index.d.ts +14 -0
  26. package/color-menu/index.js +450 -0
  27. package/color-menu/types.d.ts +36 -0
  28. package/color-menu/utils.d.ts +1 -0
  29. package/color-menu/utils.js +15 -0
  30. package/color-swatch/index.d.ts +13 -0
  31. package/color-swatch/index.js +60 -0
  32. package/color-swatch/types.d.ts +11 -0
  33. package/colors.json +61 -49
  34. package/date-picker/index.js +162 -293
  35. package/dialog/index.js +70 -142
  36. package/field/index.js +44 -65
  37. package/file-drop/index.js +123 -200
  38. package/file-picker/index.d.ts +0 -1
  39. package/file-picker/index.js +55 -108
  40. package/file-status/index.js +15 -39
  41. package/help-tooltip/index.js +11 -28
  42. package/horizontal-stepper/index.js +33 -59
  43. package/horizontal-stepper-item/index.js +13 -37
  44. package/icon-button/index.d.ts +1 -0
  45. package/icon-button/index.js +51 -85
  46. package/icon-button/types.d.ts +16 -2
  47. package/icons-channel/notify/index.d.ts +11 -0
  48. package/icons-channel/notify/index.js +4 -0
  49. package/illustrations/create-illustration-class.js +1 -1
  50. package/inline-alert/index.js +29 -81
  51. package/input/index.js +117 -222
  52. package/link/index.js +51 -97
  53. package/list-item/index.js +1 -1
  54. package/package.json +12 -14
  55. package/pagination/index.js +113 -163
  56. package/pop/index.d.ts +11 -0
  57. package/pop/index.js +391 -0
  58. package/pop/types.d.ts +35 -0
  59. package/pop/utils.d.ts +7 -0
  60. package/pop/utils.js +18 -0
  61. package/popover/index.d.ts +1 -0
  62. package/popover/index.js +105 -314
  63. package/popover/types.d.ts +8 -1
  64. package/popover/utils.d.ts +5 -0
  65. package/popover/utils.js +17 -1
  66. package/progress/index.js +9 -28
  67. package/radio/index.js +103 -169
  68. package/radio-option/index.js +28 -48
  69. package/segment/index.js +49 -130
  70. package/segment-collapse/index.js +28 -49
  71. package/segmented-control/index.js +36 -73
  72. package/segmented-control-option/index.js +45 -87
  73. package/segmented-icon-control/index.js +47 -84
  74. package/segmented-icon-control-option/index.js +42 -79
  75. package/select-button/index.d.ts +13 -0
  76. package/select-button/index.js +158 -0
  77. package/select-button/types.d.ts +43 -0
  78. package/select-menu/index.d.ts +11 -0
  79. package/select-menu/index.js +345 -0
  80. package/select-menu/types.d.ts +29 -0
  81. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  82. package/select-menu-option/index.js +76 -0
  83. package/{select-option → select-menu-option}/types.d.ts +8 -9
  84. package/stop-events/index.js +7 -20
  85. package/table-head-cell/index.js +7 -21
  86. package/tabs/index.js +103 -165
  87. package/tabs-option/index.js +24 -44
  88. package/tag/index.d.ts +0 -1
  89. package/tag/index.js +35 -38
  90. package/tag/types.d.ts +12 -7
  91. package/textarea/index.js +96 -167
  92. package/theme.css +146 -49
  93. package/tile-control/index.js +55 -96
  94. package/tile-control-option/index.js +45 -87
  95. package/time-picker/index.js +216 -368
  96. package/title/index.js +6 -20
  97. package/toast/index.js +32 -70
  98. package/toast-manager/index.js +141 -217
  99. package/toggle/index.js +59 -107
  100. package/tooltip/index.d.ts +2 -0
  101. package/tooltip/index.js +160 -17
  102. package/tooltip/types.d.ts +13 -0
  103. package/tooltip/utils.d.ts +5 -0
  104. package/tooltip/utils.js +25 -1
  105. package/utils/animation.d.ts +17 -0
  106. package/utils/animation.js +142 -0
  107. package/utils/colors.d.ts +5 -0
  108. package/utils/colors.js +5 -0
  109. package/utils/context.d.ts +15 -0
  110. package/utils/context.js +57 -0
  111. package/{utils.d.ts → utils/index.d.ts} +15 -11
  112. package/{utils.js → utils/index.js} +104 -48
  113. package/vertical-stepper/index.js +29 -50
  114. package/vertical-stepper-item/index.js +13 -37
  115. package/dropdown/index.d.ts +0 -12
  116. package/dropdown/index.js +0 -415
  117. package/dropdown/types.d.ts +0 -32
  118. package/dropdown-checkbox-option/index.d.ts +0 -11
  119. package/dropdown-checkbox-option/index.js +0 -88
  120. package/dropdown-checkbox-option/types.d.ts +0 -15
  121. package/dropdown-radio-option/index.d.ts +0 -11
  122. package/dropdown-radio-option/index.js +0 -88
  123. package/dropdown-radio-option/types.d.ts +0 -15
  124. package/dropdown-text-option/index.js +0 -104
  125. package/dropdown-text-option/types.d.ts +0 -16
  126. package/select/index.d.ts +0 -13
  127. package/select/index.js +0 -316
  128. package/select/types.d.ts +0 -53
  129. package/select-option/index.d.ts +0 -11
  130. package/select-option/index.js +0 -8
  131. package/tag/utils.d.ts +0 -5
  132. package/tag/utils.js +0 -6
  133. package/tag-close/index.d.ts +0 -12
  134. package/tag-close/index.js +0 -42
  135. package/tag-close/types.d.ts +0 -5
  136. /package/{dropdown-checkbox-option → chip}/types.js +0 -0
  137. /package/{dropdown-radio-option → color-menu}/types.js +0 -0
  138. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  139. /package/{dropdown → pop}/types.js +0 -0
  140. /package/{select-option → select-button}/types.js +0 -0
  141. /package/{tag-close → select-menu}/types.js +0 -0
  142. /package/{select → select-menu-option}/types.js +0 -0
package/dialog/index.js CHANGED
@@ -1,16 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$dialog, _$closeButton, _$caption, _isConnected, _prevOverflowValue, _onCancel, _onCloseClick, _onBackdropClick, _onCloseReactHandler, _dispatchCloseEvent, _setOpen;
5
-
6
- function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
-
8
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
-
10
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
-
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
1
  import dialogPolyfill from 'dialog-polyfill';
15
2
  import '../icon-button';
16
3
  import '../icons/close';
@@ -20,119 +7,40 @@ import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttr
20
7
  const templateHTML = '<style>:host{display:inline-block}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{color:var(--sinch-color-text-default)}#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"><sinch-title id="caption" type="m" level="3" ellipsis></sinch-title><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>';
21
8
  const template = document.createElement('template');
22
9
  template.innerHTML = templateHTML;
23
- 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 {
10
+ defineCustomElement('sinch-dialog', class extends NectaryElement {
11
+ #$dialog;
12
+ #$closeButton;
13
+ #$caption;
14
+ #isConnected = false;
15
+ #prevOverflowValue = '';
16
+
24
17
  constructor() {
25
18
  super();
26
-
27
- _classPrivateMethodInitSpec(this, _setOpen);
28
-
29
- _classPrivateMethodInitSpec(this, _dispatchCloseEvent);
30
-
31
- _classPrivateFieldInitSpec(this, _$dialog, {
32
- writable: true,
33
- value: void 0
34
- });
35
-
36
- _classPrivateFieldInitSpec(this, _$closeButton, {
37
- writable: true,
38
- value: void 0
39
- });
40
-
41
- _classPrivateFieldInitSpec(this, _$caption, {
42
- writable: true,
43
- value: void 0
44
- });
45
-
46
- _classPrivateFieldInitSpec(this, _isConnected, {
47
- writable: true,
48
- value: false
49
- });
50
-
51
- _classPrivateFieldInitSpec(this, _prevOverflowValue, {
52
- writable: true,
53
- value: ''
54
- });
55
-
56
- _classPrivateFieldInitSpec(this, _onCancel, {
57
- writable: true,
58
- value: e => {
59
- e.preventDefault();
60
-
61
- _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
62
- }
63
- });
64
-
65
- _classPrivateFieldInitSpec(this, _onCloseClick, {
66
- writable: true,
67
- value: () => {
68
- _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
69
- }
70
- });
71
-
72
- _classPrivateFieldInitSpec(this, _onBackdropClick, {
73
- writable: true,
74
- value: e => {
75
- if (e.target !== _classPrivateFieldGet(this, _$dialog)) {
76
- return;
77
- }
78
-
79
- const rect = this.dialogRect;
80
- const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
81
-
82
- if (!isInside) {
83
- _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
84
- }
85
- }
86
- });
87
-
88
- _classPrivateFieldInitSpec(this, _onCloseReactHandler, {
89
- writable: true,
90
- value: e => {
91
- getReactEventHandler(this, 'onClose')?.();
92
- getReactEventHandler(this, 'on-close')?.(e);
93
- }
94
- });
95
-
96
19
  const shadowRoot = this.attachShadow();
97
20
  shadowRoot.appendChild(template.content.cloneNode(true));
98
-
99
- _classPrivateFieldSet(this, _$dialog, shadowRoot.querySelector('dialog'));
100
-
101
- _classPrivateFieldSet(this, _$closeButton, shadowRoot.querySelector('#close'));
102
-
103
- _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
104
-
105
- dialogPolyfill.registerDialog(_classPrivateFieldGet(this, _$dialog));
21
+ this.#$dialog = shadowRoot.querySelector('dialog');
22
+ this.#$closeButton = shadowRoot.querySelector('#close');
23
+ this.#$caption = shadowRoot.querySelector('#caption');
24
+ dialogPolyfill.registerDialog(this.#$dialog);
106
25
  }
107
26
 
108
27
  connectedCallback() {
109
28
  this.setAttribute('role', 'dialog');
110
-
111
- _classPrivateFieldGet(this, _$closeButton).addEventListener('click', _classPrivateFieldGet(this, _onCloseClick));
112
-
113
- _classPrivateFieldGet(this, _$dialog).addEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
114
-
115
- _classPrivateFieldGet(this, _$dialog).addEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
116
-
117
- this.addEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
118
-
119
- _classPrivateFieldSet(this, _isConnected, true);
120
-
121
- _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, getBooleanAttribute(this, 'open'));
29
+ this.#$closeButton.addEventListener('click', this.#onCloseClick);
30
+ this.#$dialog.addEventListener('mousedown', this.#onBackdropClick);
31
+ this.#$dialog.addEventListener('cancel', this.#onCancel);
32
+ this.addEventListener('-close', this.#onCloseReactHandler);
33
+ this.#isConnected = true;
34
+ this.#setOpen(getBooleanAttribute(this, 'open'));
122
35
  }
123
36
 
124
37
  disconnectedCallback() {
125
- _classPrivateFieldGet(this, _$closeButton).removeEventListener('click', _classPrivateFieldGet(this, _onCloseClick));
126
-
127
- _classPrivateFieldGet(this, _$dialog).removeEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
128
-
129
- _classPrivateFieldGet(this, _$dialog).removeEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
130
-
131
- this.removeEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
132
-
133
- _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, false);
134
-
135
- _classPrivateFieldSet(this, _isConnected, false);
38
+ this.#$closeButton.removeEventListener('click', this.#onCloseClick);
39
+ this.#$dialog.removeEventListener('mousedown', this.#onBackdropClick);
40
+ this.#$dialog.removeEventListener('cancel', this.#onCancel);
41
+ this.removeEventListener('-close', this.#onCloseReactHandler);
42
+ this.#setOpen(false);
43
+ this.#isConnected = false;
136
44
  }
137
45
 
138
46
  static get observedAttributes() {
@@ -143,23 +51,21 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
143
51
  switch (name) {
144
52
  case 'caption':
145
53
  {
146
- updateAttribute(_classPrivateFieldGet(this, _$caption), 'text', newVal);
54
+ updateAttribute(this.#$caption, 'text', newVal);
147
55
  break;
148
56
  }
149
57
 
150
58
  case 'open':
151
59
  {
152
60
  const shouldOpen = isAttrTrue(newVal);
153
-
154
- _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, shouldOpen);
155
-
61
+ this.#setOpen(shouldOpen);
156
62
  updateBooleanAttribute(this, 'open', shouldOpen);
157
63
  break;
158
64
  }
159
65
 
160
66
  case 'close-aria-label':
161
67
  {
162
- updateAttribute(_classPrivateFieldGet(this, _$closeButton), 'aria-label', newVal);
68
+ updateAttribute(this.#$closeButton, 'aria-label', newVal);
163
69
  break;
164
70
  }
165
71
  }
@@ -173,31 +79,53 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
173
79
  return getAttribute(this, 'caption', '');
174
80
  }
175
81
 
176
- get dialogRect() {
177
- return getRect(_classPrivateFieldGet(this, _$dialog));
178
- }
179
-
180
- get closeButtonRect() {
181
- return getRect(_classPrivateFieldGet(this, _$closeButton));
182
- }
82
+ #onCancel = e => {
83
+ e.preventDefault();
84
+ this.#dispatchCloseEvent();
85
+ };
86
+ #onCloseClick = () => {
87
+ this.#dispatchCloseEvent();
88
+ };
89
+ #onBackdropClick = e => {
90
+ if (e.target !== this.#$dialog) {
91
+ return;
92
+ }
183
93
 
184
- }));
94
+ const rect = this.dialogRect;
95
+ const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
185
96
 
186
- function _dispatchCloseEvent2() {
187
- this.dispatchEvent(new CustomEvent('-close'));
188
- }
97
+ if (!isInside) {
98
+ this.#dispatchCloseEvent();
99
+ }
100
+ };
101
+ #onCloseReactHandler = e => {
102
+ getReactEventHandler(this, 'onClose')?.();
103
+ getReactEventHandler(this, 'on-close')?.(e);
104
+ };
105
+
106
+ #dispatchCloseEvent() {
107
+ this.dispatchEvent(new CustomEvent('-close'));
108
+ }
189
109
 
190
- function _setOpen2(shouldOpen) {
191
- if (shouldOpen) {
192
- if (_classPrivateFieldGet(this, _isConnected) && !getBooleanAttribute(_classPrivateFieldGet(this, _$dialog), 'open')) {
193
- _classPrivateFieldSet(this, _prevOverflowValue, document.body.style.overflow);
110
+ #setOpen(shouldOpen) {
111
+ if (shouldOpen) {
112
+ if (this.#isConnected && !getBooleanAttribute(this.#$dialog, 'open')) {
113
+ this.#prevOverflowValue = document.body.style.overflow;
114
+ document.body.style.overflow = 'hidden';
115
+ this.#$dialog.showModal();
116
+ }
117
+ } else {
118
+ this.#$dialog.close?.();
119
+ document.body.style.overflow = this.#prevOverflowValue;
120
+ }
121
+ }
194
122
 
195
- document.body.style.overflow = 'hidden';
123
+ get dialogRect() {
124
+ return getRect(this.#$dialog);
125
+ }
196
126
 
197
- _classPrivateFieldGet(this, _$dialog).showModal();
198
- }
199
- } else {
200
- _classPrivateFieldGet(this, _$dialog).close?.();
201
- document.body.style.overflow = _classPrivateFieldGet(this, _prevOverflowValue);
127
+ get closeButtonRect() {
128
+ return getRect(this.#$closeButton);
202
129
  }
203
- }
130
+
131
+ });
package/field/index.js CHANGED
@@ -1,72 +1,45 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$label, _$optionalText, _$additionalText, _$invalidText, _$inputSlot, _onLabelClick;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
- import { defineCustomElement, getAttribute, getBooleanAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{display:flex;flex-direction:column;width:100%}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px;--sinch-color-icon:var(--sinch-color-stormy-500)}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])) #top{--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><slot name="input"></slot><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getFirstSlotElement, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{display:flex;flex-direction:column;width:100%}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px;--sinch-color-icon:var(--sinch-color-stormy-500)}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])) #top{--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><div id="tooltip"><slot name="tooltip"></slot></div><span id="optional"></span></div><slot name="input"></slot><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
12
3
  const template = document.createElement('template');
13
4
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$inputSlot = new WeakMap(), _onLabelClick = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-field', class extends NectaryElement {
6
+ #$label;
7
+ #$optionalText;
8
+ #$additionalText;
9
+ #$invalidText;
10
+ #$inputSlot;
11
+ #$tooltipWrapper;
12
+ #$tooltipSlot;
13
+ #controller = null;
14
+
15
15
  constructor() {
16
16
  super();
17
-
18
- _classPrivateFieldInitSpec(this, _$label, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
- _classPrivateFieldInitSpec(this, _$optionalText, {
24
- writable: true,
25
- value: void 0
26
- });
27
-
28
- _classPrivateFieldInitSpec(this, _$additionalText, {
29
- writable: true,
30
- value: void 0
31
- });
32
-
33
- _classPrivateFieldInitSpec(this, _$invalidText, {
34
- writable: true,
35
- value: void 0
36
- });
37
-
38
- _classPrivateFieldInitSpec(this, _$inputSlot, {
39
- writable: true,
40
- value: void 0
41
- });
42
-
43
- _classPrivateFieldInitSpec(this, _onLabelClick, {
44
- writable: true,
45
- value: () => {
46
- _classPrivateFieldGet(this, _$inputSlot).assignedElements()[0]?.focus?.();
47
- }
48
- });
49
-
50
17
  const shadowRoot = this.attachShadow();
51
18
  shadowRoot.appendChild(template.content.cloneNode(true));
52
-
53
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
54
-
55
- _classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
56
-
57
- _classPrivateFieldSet(this, _$additionalText, shadowRoot.querySelector('#additional'));
58
-
59
- _classPrivateFieldSet(this, _$invalidText, shadowRoot.querySelector('#invalid'));
60
-
61
- _classPrivateFieldSet(this, _$inputSlot, shadowRoot.querySelector('slot[name="input"]'));
19
+ this.#$label = shadowRoot.querySelector('#label');
20
+ this.#$optionalText = shadowRoot.querySelector('#optional');
21
+ this.#$additionalText = shadowRoot.querySelector('#additional');
22
+ this.#$invalidText = shadowRoot.querySelector('#invalid');
23
+ this.#$inputSlot = shadowRoot.querySelector('slot[name="input"]');
24
+ this.#$tooltipSlot = shadowRoot.querySelector('slot[name="tooltip"]');
25
+ this.#$tooltipWrapper = shadowRoot.querySelector('#tooltip');
62
26
  }
63
27
 
64
28
  connectedCallback() {
65
- _classPrivateFieldGet(this, _$label).addEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
29
+ this.#controller = new AbortController();
30
+ const {
31
+ signal
32
+ } = this.#controller;
33
+ this.#$label.addEventListener('click', this.#onLabelClick, {
34
+ signal
35
+ });
36
+ this.#$tooltipSlot.addEventListener('slotchange', this.#onTooltipSlotChange, {
37
+ signal
38
+ });
66
39
  }
67
40
 
68
41
  disconnectedCallback() {
69
- _classPrivateFieldGet(this, _$label).removeEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
42
+ this.#controller.abort();
70
43
  }
71
44
 
72
45
  static get observedAttributes() {
@@ -86,7 +59,7 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
86
59
  }
87
60
 
88
61
  get optionalText() {
89
- return getAttribute(this, 'optionaltext', null);
62
+ return getAttribute(this, 'optionaltext');
90
63
  }
91
64
 
92
65
  set additionalText(value) {
@@ -94,7 +67,7 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
94
67
  }
95
68
 
96
69
  get additionalText() {
97
- return getAttribute(this, 'additionaltext', null);
70
+ return getAttribute(this, 'additionaltext');
98
71
  }
99
72
 
100
73
  set invalidText(value) {
@@ -102,7 +75,7 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
102
75
  }
103
76
 
104
77
  get invalidText() {
105
- return getAttribute(this, 'invalidtext', null);
78
+ return getAttribute(this, 'invalidtext');
106
79
  }
107
80
 
108
81
  set disabled(isDisabled) {
@@ -117,28 +90,34 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
117
90
  switch (name) {
118
91
  case 'label':
119
92
  {
120
- _classPrivateFieldGet(this, _$label).textContent = newVal;
93
+ this.#$label.textContent = newVal;
121
94
  break;
122
95
  }
123
96
 
124
97
  case 'optionaltext':
125
98
  {
126
- _classPrivateFieldGet(this, _$optionalText).textContent = newVal;
99
+ this.#$optionalText.textContent = newVal;
127
100
  break;
128
101
  }
129
102
 
130
103
  case 'additionaltext':
131
104
  {
132
- _classPrivateFieldGet(this, _$additionalText).textContent = newVal;
105
+ this.#$additionalText.textContent = newVal;
133
106
  break;
134
107
  }
135
108
 
136
109
  case 'invalidtext':
137
110
  {
138
- _classPrivateFieldGet(this, _$invalidText).textContent = newVal;
111
+ this.#$invalidText.textContent = newVal;
139
112
  break;
140
113
  }
141
114
  }
142
115
  }
143
116
 
144
- }));
117
+ #onLabelClick = () => {
118
+ getFirstSlotElement(this.#$inputSlot)?.focus?.();
119
+ };
120
+ #onTooltipSlotChange = () => {
121
+ setClass(this.#$tooltipWrapper, 'empty', this.#$tooltipSlot.assignedElements().length === 0);
122
+ };
123
+ });