@nectary/components 0.38.0 → 0.40.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 (148) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion/types.d.ts +1 -0
  3. package/accordion-item/index.js +26 -53
  4. package/action-menu/index.d.ts +0 -1
  5. package/action-menu/index.js +179 -223
  6. package/action-menu/types.d.ts +8 -18
  7. package/action-menu-option/index.d.ts +1 -0
  8. package/action-menu-option/index.js +51 -62
  9. package/action-menu-option/types.d.ts +9 -0
  10. package/action-menu-option/utils.d.ts +2 -0
  11. package/action-menu-option/utils.js +3 -0
  12. package/alert/index.js +6 -20
  13. package/avatar/index.js +12 -31
  14. package/avatar-badge/index.js +8 -22
  15. package/avatar-status/index.js +1 -1
  16. package/button/index.js +42 -92
  17. package/card/index.d.ts +2 -0
  18. package/card/index.js +24 -87
  19. package/chat-avatar/index.js +8 -22
  20. package/chat-block/index.js +29 -69
  21. package/chat-bubble/index.js +6 -20
  22. package/checkbox/index.js +55 -107
  23. package/chip/index.d.ts +13 -0
  24. package/chip/index.js +137 -0
  25. package/chip/types.d.ts +38 -0
  26. package/color-menu/index.d.ts +13 -0
  27. package/color-menu/index.js +464 -0
  28. package/color-menu/types.d.ts +37 -0
  29. package/color-swatch/index.d.ts +13 -0
  30. package/color-swatch/index.js +59 -0
  31. package/color-swatch/types.d.ts +12 -0
  32. package/colors.json +57 -49
  33. package/date-picker/index.js +196 -287
  34. package/date-picker/types.d.ts +25 -1
  35. package/dialog/index.d.ts +1 -0
  36. package/dialog/index.js +72 -143
  37. package/dropdown-checkbox-option/index.js +6 -20
  38. package/dropdown-radio-option/index.js +6 -20
  39. package/field/index.js +25 -63
  40. package/file-drop/index.js +123 -200
  41. package/file-picker/index.d.ts +0 -1
  42. package/file-picker/index.js +55 -108
  43. package/file-status/index.js +15 -39
  44. package/help-tooltip/index.js +1 -1
  45. package/horizontal-stepper/index.js +33 -59
  46. package/horizontal-stepper-item/index.js +13 -37
  47. package/icon-button/index.js +39 -84
  48. package/icons-channel/notify/index.d.ts +11 -0
  49. package/icons-channel/notify/index.js +4 -0
  50. package/illustrations/create-illustration-class.js +1 -1
  51. package/inline-alert/index.js +30 -82
  52. package/input/index.js +113 -222
  53. package/link/index.js +46 -96
  54. package/list-item/index.js +1 -1
  55. package/package.json +12 -14
  56. package/pagination/index.js +109 -163
  57. package/pagination/types.d.ts +1 -0
  58. package/popover/index.js +224 -294
  59. package/progress/index.js +9 -28
  60. package/radio/index.js +103 -169
  61. package/radio/types.d.ts +1 -0
  62. package/radio-option/index.js +24 -48
  63. package/segment/index.js +50 -131
  64. package/segment-collapse/index.js +24 -49
  65. package/segment-collapse/types.d.ts +1 -0
  66. package/segmented-control/index.js +36 -73
  67. package/segmented-control/types.d.ts +1 -0
  68. package/segmented-control-option/index.js +41 -87
  69. package/segmented-icon-control/index.js +47 -84
  70. package/segmented-icon-control/types.d.ts +1 -0
  71. package/segmented-icon-control-option/index.js +38 -79
  72. package/select-button/index.d.ts +13 -0
  73. package/select-button/index.js +153 -0
  74. package/select-button/types.d.ts +43 -0
  75. package/select-menu/index.d.ts +11 -0
  76. package/select-menu/index.js +346 -0
  77. package/select-menu/types.d.ts +29 -0
  78. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  79. package/select-menu-option/index.js +76 -0
  80. package/{select-option → select-menu-option}/types.d.ts +8 -9
  81. package/stop-events/index.js +7 -20
  82. package/table-head-cell/index.js +7 -21
  83. package/tabs/index.js +103 -165
  84. package/tabs/types.d.ts +1 -0
  85. package/tabs-option/index.js +20 -44
  86. package/tag/index.d.ts +1 -1
  87. package/tag/index.js +42 -36
  88. package/tag/types.d.ts +13 -7
  89. package/textarea/index.js +92 -167
  90. package/theme.css +80 -49
  91. package/tile-control/index.js +55 -96
  92. package/tile-control-option/index.js +40 -86
  93. package/time-picker/index.js +224 -368
  94. package/time-picker/types.d.ts +5 -1
  95. package/title/index.js +6 -20
  96. package/toast/index.d.ts +17 -0
  97. package/toast/index.js +115 -0
  98. package/toast/types.d.ts +28 -0
  99. package/toast/utils.d.ts +5 -0
  100. package/toast/utils.js +6 -0
  101. package/toast-manager/index.d.ts +17 -0
  102. package/toast-manager/index.js +195 -0
  103. package/toast-manager/types.d.ts +7 -0
  104. package/toggle/index.js +55 -108
  105. package/toggle/types.d.ts +1 -0
  106. package/types.d.ts +7 -0
  107. package/utils/colors.d.ts +10 -0
  108. package/utils/colors.js +121 -0
  109. package/{utils.d.ts → utils/index.d.ts} +18 -9
  110. package/{utils.js → utils/index.js} +118 -39
  111. package/vertical-stepper/index.js +29 -50
  112. package/vertical-stepper-item/index.js +13 -37
  113. package/card-button/index.d.ts +0 -11
  114. package/card-button/index.js +0 -77
  115. package/card-button/types.d.ts +0 -12
  116. package/card-link/index.d.ts +0 -12
  117. package/card-link/index.js +0 -115
  118. package/card-link/types.d.ts +0 -14
  119. package/dropdown/index.d.ts +0 -12
  120. package/dropdown/index.js +0 -415
  121. package/dropdown/types.d.ts +0 -30
  122. package/dropdown-text-option/index.js +0 -104
  123. package/dropdown-text-option/types.d.ts +0 -16
  124. package/search/index.d.ts +0 -14
  125. package/search/index.js +0 -523
  126. package/search/types.d.ts +0 -25
  127. package/search-option/index.d.ts +0 -11
  128. package/search-option/index.js +0 -55
  129. package/search-option/types.d.ts +0 -9
  130. package/select/index.d.ts +0 -13
  131. package/select/index.js +0 -316
  132. package/select/types.d.ts +0 -53
  133. package/select-option/index.d.ts +0 -11
  134. package/select-option/index.js +0 -8
  135. package/tag/utils.d.ts +0 -2
  136. package/tag/utils.js +0 -1
  137. package/tag-close/index.d.ts +0 -12
  138. package/tag-close/index.js +0 -38
  139. package/tag-close/types.d.ts +0 -3
  140. package/tag-close/types.js +0 -1
  141. /package/{card-button → chip}/types.js +0 -0
  142. /package/{card-link → color-menu}/types.js +0 -0
  143. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  144. /package/{dropdown → select-button}/types.js +0 -0
  145. /package/{search → select-menu}/types.js +0 -0
  146. /package/{search-option → select-menu-option}/types.js +0 -0
  147. /package/{select → toast}/types.js +0 -0
  148. /package/{select-option → toast-manager}/types.js +0 -0
package/dialog/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import '../icon-button';
2
2
  import '../icons/close';
3
3
  import '../stop-events';
4
+ import '../title';
4
5
  import type { TSinchDialogElement, TSinchDialogReact } from './types';
5
6
  declare global {
6
7
  namespace JSX {
package/dialog/index.js CHANGED
@@ -1,137 +1,46 @@
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';
17
4
  import '../stop-events';
5
+ import '../title';
18
6
  import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, isAttrTrue, updateAttribute, getReactEventHandler, NectaryElement, updateBooleanAttribute } from '../utils';
19
- 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{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>';
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>';
20
8
  const template = document.createElement('template');
21
9
  template.innerHTML = templateHTML;
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 {
10
+ defineCustomElement('sinch-dialog', class extends NectaryElement {
11
+ #$dialog;
12
+ #$closeButton;
13
+ #$caption;
14
+ #isConnected = false;
15
+ #prevOverflowValue = '';
16
+
23
17
  constructor() {
24
18
  super();
25
-
26
- _classPrivateMethodInitSpec(this, _setOpen);
27
-
28
- _classPrivateMethodInitSpec(this, _dispatchCloseEvent);
29
-
30
- _classPrivateFieldInitSpec(this, _$dialog, {
31
- writable: true,
32
- value: void 0
33
- });
34
-
35
- _classPrivateFieldInitSpec(this, _$closeButton, {
36
- writable: true,
37
- value: void 0
38
- });
39
-
40
- _classPrivateFieldInitSpec(this, _$caption, {
41
- writable: true,
42
- value: void 0
43
- });
44
-
45
- _classPrivateFieldInitSpec(this, _isConnected, {
46
- writable: true,
47
- value: false
48
- });
49
-
50
- _classPrivateFieldInitSpec(this, _prevOverflowValue, {
51
- writable: true,
52
- value: ''
53
- });
54
-
55
- _classPrivateFieldInitSpec(this, _onCancel, {
56
- writable: true,
57
- value: e => {
58
- e.preventDefault();
59
-
60
- _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
61
- }
62
- });
63
-
64
- _classPrivateFieldInitSpec(this, _onCloseClick, {
65
- writable: true,
66
- value: () => {
67
- _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
68
- }
69
- });
70
-
71
- _classPrivateFieldInitSpec(this, _onBackdropClick, {
72
- writable: true,
73
- value: e => {
74
- if (e.target !== _classPrivateFieldGet(this, _$dialog)) {
75
- return;
76
- }
77
-
78
- const rect = this.dialogRect;
79
- const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
80
-
81
- if (!isInside) {
82
- _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
83
- }
84
- }
85
- });
86
-
87
- _classPrivateFieldInitSpec(this, _onCloseReactHandler, {
88
- writable: true,
89
- value: e => {
90
- getReactEventHandler(this, 'onClose')?.();
91
- getReactEventHandler(this, 'on-close')?.(e);
92
- }
93
- });
94
-
95
19
  const shadowRoot = this.attachShadow();
96
20
  shadowRoot.appendChild(template.content.cloneNode(true));
97
-
98
- _classPrivateFieldSet(this, _$dialog, shadowRoot.querySelector('dialog'));
99
-
100
- _classPrivateFieldSet(this, _$closeButton, shadowRoot.querySelector('#close'));
101
-
102
- _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
103
-
104
- 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);
105
25
  }
106
26
 
107
27
  connectedCallback() {
108
28
  this.setAttribute('role', 'dialog');
109
-
110
- _classPrivateFieldGet(this, _$closeButton).addEventListener('click', _classPrivateFieldGet(this, _onCloseClick));
111
-
112
- _classPrivateFieldGet(this, _$dialog).addEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
113
-
114
- _classPrivateFieldGet(this, _$dialog).addEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
115
-
116
- this.addEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
117
-
118
- _classPrivateFieldSet(this, _isConnected, true);
119
-
120
- _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'));
121
35
  }
122
36
 
123
37
  disconnectedCallback() {
124
- _classPrivateFieldGet(this, _$closeButton).removeEventListener('click', _classPrivateFieldGet(this, _onCloseClick));
125
-
126
- _classPrivateFieldGet(this, _$dialog).removeEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
127
-
128
- _classPrivateFieldGet(this, _$dialog).removeEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
129
-
130
- this.removeEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
131
-
132
- _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, false);
133
-
134
- _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;
135
44
  }
136
45
 
137
46
  static get observedAttributes() {
@@ -142,23 +51,21 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
142
51
  switch (name) {
143
52
  case 'caption':
144
53
  {
145
- _classPrivateFieldGet(this, _$caption).textContent = newVal;
54
+ updateAttribute(this.#$caption, 'text', newVal);
146
55
  break;
147
56
  }
148
57
 
149
58
  case 'open':
150
59
  {
151
60
  const shouldOpen = isAttrTrue(newVal);
152
-
153
- _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, shouldOpen);
154
-
61
+ this.#setOpen(shouldOpen);
155
62
  updateBooleanAttribute(this, 'open', shouldOpen);
156
63
  break;
157
64
  }
158
65
 
159
66
  case 'close-aria-label':
160
67
  {
161
- updateAttribute(_classPrivateFieldGet(this, _$closeButton), 'aria-label', newVal);
68
+ updateAttribute(this.#$closeButton, 'aria-label', newVal);
162
69
  break;
163
70
  }
164
71
  }
@@ -172,31 +79,53 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
172
79
  return getAttribute(this, 'caption', '');
173
80
  }
174
81
 
175
- get dialogRect() {
176
- return getRect(_classPrivateFieldGet(this, _$dialog));
177
- }
178
-
179
- get closeButtonRect() {
180
- return getRect(_classPrivateFieldGet(this, _$closeButton));
181
- }
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
+ }
182
93
 
183
- }));
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;
184
96
 
185
- function _dispatchCloseEvent2() {
186
- this.dispatchEvent(new CustomEvent('-close'));
187
- }
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
+ }
188
109
 
189
- function _setOpen2(shouldOpen) {
190
- if (shouldOpen) {
191
- if (_classPrivateFieldGet(this, _isConnected) && !getBooleanAttribute(_classPrivateFieldGet(this, _$dialog), 'open')) {
192
- _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
+ }
193
122
 
194
- document.body.style.overflow = 'hidden';
123
+ get dialogRect() {
124
+ return getRect(this.#$dialog);
125
+ }
195
126
 
196
- _classPrivateFieldGet(this, _$dialog).showModal();
197
- }
198
- } else {
199
- _classPrivateFieldGet(this, _$dialog).close?.();
200
- document.body.style.overflow = _classPrivateFieldGet(this, _prevOverflowValue);
127
+ get closeButtonRect() {
128
+ return getRect(this.#$closeButton);
201
129
  }
202
- }
130
+
131
+ });
@@ -1,29 +1,15 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text;
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
1
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
11
2
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:4px 10px 4px 6px;align-items:center;gap:6px;user-select:none;cursor:pointer}#text{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-container{position:relative;width:32px;height:32px}#icon-container::before{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-snow-100);border:2px solid var(--sinch-color-stormy-300);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;fill:var(--sinch-color-snow-100)}:host([data-checked]) #icon-container::before{background-color:var(--sinch-color-tropical-500);border-color:var(--sinch-color-tropical-500)}:host([data-checked]) #icon-checkmark{opacity:1}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);cursor:initial}:host([disabled]:not([disabled=false])) #icon-container::before{border-color:var(--sinch-color-stormy-100)}@media (prefers-reduced-motion){#icon-checkmark,#icon-container::before{transition:none}}</style><div id="wrapper"><div id="icon-container"><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"/></svg></div><span id="text"></span></div>';
12
3
  const template = document.createElement('template');
13
4
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-dropdown-checkbox-option', (_$text = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-dropdown-checkbox-option', class extends NectaryElement {
6
+ #$text;
7
+
15
8
  constructor() {
16
9
  super();
17
-
18
- _classPrivateFieldInitSpec(this, _$text, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
10
  const shadowRoot = this.attachShadow();
24
11
  shadowRoot.appendChild(template.content.cloneNode(true));
25
-
26
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
12
+ this.#$text = shadowRoot.querySelector('#text');
27
13
  }
28
14
 
29
15
  connectedCallback() {
@@ -42,7 +28,7 @@ defineCustomElement('sinch-dropdown-checkbox-option', (_$text = new WeakMap(), c
42
28
  switch (name) {
43
29
  case 'text':
44
30
  {
45
- _classPrivateFieldGet(this, _$text).textContent = newVal;
31
+ this.#$text.textContent = newVal;
46
32
  break;
47
33
  }
48
34
 
@@ -85,4 +71,4 @@ defineCustomElement('sinch-dropdown-checkbox-option', (_$text = new WeakMap(), c
85
71
  return getBooleanAttribute(this, 'checked');
86
72
  }
87
73
 
88
- }));
74
+ });
@@ -1,29 +1,15 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text;
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
1
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
11
2
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:4px 10px 4px 6px;align-items:center;gap:6px;user-select:none;cursor:pointer}#text{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-container{position:relative;width:32px;height:32px}#icon-container::before{content:"";position:absolute;top:6px;left:6px;width:20px;height:20px;border-radius:50%;pointer-events:none;background-color:var(--sinch-color-snow-100);border:2px solid var(--sinch-color-stormy-300);transition:background-color .1s linear;box-sizing:border-box}#icon-knob{position:absolute;left:11px;top:11px;width:10px;height:10px;border-radius:50%;transition:opacity .1s linear;opacity:0;background-color:var(--sinch-color-tropical-500);pointer-events:none}:host([data-checked]) #icon-container::before{border-color:var(--sinch-color-tropical-500)}:host([data-checked]) #icon-knob{opacity:1}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);cursor:initial}:host([disabled]:not([disabled=false])) #icon-container::before{border-color:var(--sinch-color-stormy-100)}@media (prefers-reduced-motion){#icon-container::before,#icon-knob{transition:none}}</style><div id="wrapper"><div id="icon-container"><div id="icon-knob"></div></div><span id="text"></span></div>';
12
3
  const template = document.createElement('template');
13
4
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-dropdown-radio-option', (_$text = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-dropdown-radio-option', class extends NectaryElement {
6
+ #$text;
7
+
15
8
  constructor() {
16
9
  super();
17
-
18
- _classPrivateFieldInitSpec(this, _$text, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
10
  const shadowRoot = this.attachShadow();
24
11
  shadowRoot.appendChild(template.content.cloneNode(true));
25
-
26
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
12
+ this.#$text = shadowRoot.querySelector('#text');
27
13
  }
28
14
 
29
15
  connectedCallback() {
@@ -42,7 +28,7 @@ defineCustomElement('sinch-dropdown-radio-option', (_$text = new WeakMap(), clas
42
28
  switch (name) {
43
29
  case 'text':
44
30
  {
45
- _classPrivateFieldGet(this, _$text).textContent = newVal;
31
+ this.#$text.textContent = newVal;
46
32
  break;
47
33
  }
48
34
 
@@ -85,4 +71,4 @@ defineCustomElement('sinch-dropdown-radio-option', (_$text = new WeakMap(), clas
85
71
  return getBooleanAttribute(this, 'checked');
86
72
  }
87
73
 
88
- }));
74
+ });
package/field/index.js CHANGED
@@ -1,72 +1,31 @@
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
1
  import { defineCustomElement, getAttribute, getBooleanAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
11
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}::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>';
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
+
15
12
  constructor() {
16
13
  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
14
  const shadowRoot = this.attachShadow();
51
15
  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"]'));
16
+ this.#$label = shadowRoot.querySelector('#label');
17
+ this.#$optionalText = shadowRoot.querySelector('#optional');
18
+ this.#$additionalText = shadowRoot.querySelector('#additional');
19
+ this.#$invalidText = shadowRoot.querySelector('#invalid');
20
+ this.#$inputSlot = shadowRoot.querySelector('slot[name="input"]');
62
21
  }
63
22
 
64
23
  connectedCallback() {
65
- _classPrivateFieldGet(this, _$label).addEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
24
+ this.#$label.addEventListener('click', this.#onLabelClick);
66
25
  }
67
26
 
68
27
  disconnectedCallback() {
69
- _classPrivateFieldGet(this, _$label).removeEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
28
+ this.#$label.removeEventListener('click', this.#onLabelClick);
70
29
  }
71
30
 
72
31
  static get observedAttributes() {
@@ -86,7 +45,7 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
86
45
  }
87
46
 
88
47
  get optionalText() {
89
- return getAttribute(this, 'optionaltext', null);
48
+ return getAttribute(this, 'optionaltext');
90
49
  }
91
50
 
92
51
  set additionalText(value) {
@@ -94,7 +53,7 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
94
53
  }
95
54
 
96
55
  get additionalText() {
97
- return getAttribute(this, 'additionaltext', null);
56
+ return getAttribute(this, 'additionaltext');
98
57
  }
99
58
 
100
59
  set invalidText(value) {
@@ -102,7 +61,7 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
102
61
  }
103
62
 
104
63
  get invalidText() {
105
- return getAttribute(this, 'invalidtext', null);
64
+ return getAttribute(this, 'invalidtext');
106
65
  }
107
66
 
108
67
  set disabled(isDisabled) {
@@ -117,28 +76,31 @@ defineCustomElement('sinch-field', (_$label = new WeakMap(), _$optionalText = ne
117
76
  switch (name) {
118
77
  case 'label':
119
78
  {
120
- _classPrivateFieldGet(this, _$label).textContent = newVal;
79
+ this.#$label.textContent = newVal;
121
80
  break;
122
81
  }
123
82
 
124
83
  case 'optionaltext':
125
84
  {
126
- _classPrivateFieldGet(this, _$optionalText).textContent = newVal;
85
+ this.#$optionalText.textContent = newVal;
127
86
  break;
128
87
  }
129
88
 
130
89
  case 'additionaltext':
131
90
  {
132
- _classPrivateFieldGet(this, _$additionalText).textContent = newVal;
91
+ this.#$additionalText.textContent = newVal;
133
92
  break;
134
93
  }
135
94
 
136
95
  case 'invalidtext':
137
96
  {
138
- _classPrivateFieldGet(this, _$invalidText).textContent = newVal;
97
+ this.#$invalidText.textContent = newVal;
139
98
  break;
140
99
  }
141
100
  }
142
101
  }
143
102
 
144
- }));
103
+ #onLabelClick = () => {
104
+ this.#$inputSlot.assignedElements()[0]?.focus?.();
105
+ };
106
+ });