@nectary/components 0.39.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 (115) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +26 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +179 -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 +51 -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 +42 -92
  16. package/card/index.js +21 -59
  17. package/chat-avatar/index.js +8 -22
  18. package/chat-block/index.js +29 -69
  19. package/chat-bubble/index.js +6 -20
  20. package/checkbox/index.js +55 -107
  21. package/chip/index.d.ts +13 -0
  22. package/chip/index.js +137 -0
  23. package/chip/types.d.ts +38 -0
  24. package/color-menu/index.d.ts +13 -0
  25. package/color-menu/index.js +464 -0
  26. package/color-menu/types.d.ts +37 -0
  27. package/color-swatch/index.d.ts +13 -0
  28. package/color-swatch/index.js +59 -0
  29. package/color-swatch/types.d.ts +12 -0
  30. package/colors.json +57 -49
  31. package/date-picker/index.js +161 -292
  32. package/dialog/index.js +70 -142
  33. package/dropdown-checkbox-option/index.js +6 -20
  34. package/dropdown-radio-option/index.js +6 -20
  35. package/field/index.js +25 -63
  36. package/file-drop/index.js +123 -200
  37. package/file-picker/index.d.ts +0 -1
  38. package/file-picker/index.js +55 -108
  39. package/file-status/index.js +15 -39
  40. package/help-tooltip/index.js +1 -1
  41. package/horizontal-stepper/index.js +33 -59
  42. package/horizontal-stepper-item/index.js +13 -37
  43. package/icon-button/index.js +39 -84
  44. package/icons-channel/notify/index.d.ts +11 -0
  45. package/icons-channel/notify/index.js +4 -0
  46. package/illustrations/create-illustration-class.js +1 -1
  47. package/inline-alert/index.js +29 -81
  48. package/input/index.js +113 -222
  49. package/link/index.js +46 -96
  50. package/list-item/index.js +1 -1
  51. package/package.json +12 -14
  52. package/pagination/index.js +109 -163
  53. package/popover/index.js +224 -294
  54. package/progress/index.js +9 -28
  55. package/radio/index.js +103 -169
  56. package/radio-option/index.js +24 -48
  57. package/segment/index.js +49 -130
  58. package/segment-collapse/index.js +24 -49
  59. package/segmented-control/index.js +36 -73
  60. package/segmented-control-option/index.js +41 -87
  61. package/segmented-icon-control/index.js +47 -84
  62. package/segmented-icon-control-option/index.js +38 -79
  63. package/select-button/index.d.ts +13 -0
  64. package/select-button/index.js +153 -0
  65. package/select-button/types.d.ts +43 -0
  66. package/select-menu/index.d.ts +11 -0
  67. package/select-menu/index.js +346 -0
  68. package/select-menu/types.d.ts +29 -0
  69. package/select-menu/types.js +1 -0
  70. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  71. package/select-menu-option/index.js +76 -0
  72. package/{select-option → select-menu-option}/types.d.ts +8 -9
  73. package/stop-events/index.js +7 -20
  74. package/table-head-cell/index.js +7 -21
  75. package/tabs/index.js +103 -165
  76. package/tabs-option/index.js +20 -44
  77. package/tag/index.d.ts +0 -1
  78. package/tag/index.js +37 -38
  79. package/tag/types.d.ts +13 -7
  80. package/textarea/index.js +92 -167
  81. package/theme.css +80 -49
  82. package/tile-control/index.js +55 -96
  83. package/tile-control-option/index.js +40 -86
  84. package/time-picker/index.js +216 -368
  85. package/title/index.js +6 -20
  86. package/toast/index.js +32 -70
  87. package/toast-manager/index.js +141 -217
  88. package/toggle/index.js +54 -106
  89. package/types.d.ts +7 -0
  90. package/utils/colors.d.ts +10 -0
  91. package/utils/colors.js +121 -0
  92. package/{utils.d.ts → utils/index.d.ts} +17 -9
  93. package/{utils.js → utils/index.js} +96 -39
  94. package/vertical-stepper/index.js +29 -50
  95. package/vertical-stepper-item/index.js +13 -37
  96. package/dropdown/index.d.ts +0 -12
  97. package/dropdown/index.js +0 -415
  98. package/dropdown/types.d.ts +0 -32
  99. package/dropdown-text-option/index.js +0 -104
  100. package/dropdown-text-option/types.d.ts +0 -16
  101. package/select/index.d.ts +0 -13
  102. package/select/index.js +0 -316
  103. package/select/types.d.ts +0 -53
  104. package/select-option/index.d.ts +0 -11
  105. package/select-option/index.js +0 -8
  106. package/tag/utils.d.ts +0 -5
  107. package/tag/utils.js +0 -6
  108. package/tag-close/index.d.ts +0 -12
  109. package/tag-close/index.js +0 -42
  110. package/tag-close/types.d.ts +0 -5
  111. /package/{dropdown-text-option → chip}/types.js +0 -0
  112. /package/{dropdown → color-menu}/types.js +0 -0
  113. /package/{select-option → color-swatch}/types.js +0 -0
  114. /package/{select → select-button}/types.js +0 -0
  115. /package/{tag-close → 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
+ });
@@ -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
+ });