@nectary/components 0.35.0 → 0.36.1

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 (39) hide show
  1. package/alert/index.d.ts +4 -0
  2. package/alert/index.js +17 -32
  3. package/alert/types.d.ts +1 -7
  4. package/alert/utils.d.ts +3 -0
  5. package/alert/utils.js +6 -1
  6. package/button/index.js +2 -2
  7. package/horizontal-stepper/types.d.ts +4 -0
  8. package/horizontal-stepper-item/types.d.ts +9 -0
  9. package/icon-button/index.js +9 -3
  10. package/inline-alert/index.d.ts +17 -0
  11. package/inline-alert/index.js +154 -0
  12. package/inline-alert/types.d.ts +15 -0
  13. package/inline-alert/utils.d.ts +5 -0
  14. package/inline-alert/utils.js +6 -0
  15. package/package.json +1 -1
  16. package/popover/index.js +82 -72
  17. package/select/index.js +1 -1
  18. package/select/types.d.ts +4 -0
  19. package/select-option/types.d.ts +26 -3
  20. package/tag/index.js +1 -1
  21. package/text/index.js +1 -1
  22. package/time-picker/index.js +9 -1
  23. package/vertical-stepper/index.d.ts +13 -0
  24. package/vertical-stepper/index.js +95 -0
  25. package/vertical-stepper/types.d.ts +13 -0
  26. package/vertical-stepper/types.js +1 -0
  27. package/vertical-stepper-item/index.d.ts +13 -0
  28. package/vertical-stepper-item/index.js +100 -0
  29. package/vertical-stepper-item/types.d.ts +24 -0
  30. package/vertical-stepper-item/utils.d.ts +2 -0
  31. package/vertical-stepper-item/utils.js +1 -0
  32. package/alert-button/index.d.ts +0 -11
  33. package/alert-button/index.js +0 -59
  34. package/alert-button/types.d.ts +0 -8
  35. package/alert-close/index.d.ts +0 -12
  36. package/alert-close/index.js +0 -38
  37. package/alert-close/types.d.ts +0 -3
  38. /package/{alert-button → inline-alert}/types.js +0 -0
  39. /package/{alert-close → vertical-stepper-item}/types.js +0 -0
package/popover/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$target, _$dialog, _isConnected, _resizeThrottle, _prevOverflowValue, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _updateOrientationModal, _onBackdropMouseDown, _onCancel, _onCloseReactHandler, _onTargetKeydown, _dispatchCloseEvent;
4
+ var _$target, _$dialog, _isConnected, _resizeThrottle, _originalOverflowValue, _$targetSlot, _$targetOpenSlot, _$targetOpenWrapper, _targetActiveElement, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _onBackdropMouseDown, _onCancel, _onCloseReactHandler, _dispatchCloseEvent, _onTargetBlur, _onTargetFocus;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -13,12 +13,12 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
13
13
 
14
14
  import dialogPolyfill from 'dialog-polyfill';
15
15
  import { defineCustomElement, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, updateLiteralAttribute, getReactEventHandler, updateBooleanAttribute, NectaryElement, throttleAnimationFrame } from '../utils';
16
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative}dialog{position:fixed;top:0;left:0;margin:0;outline:0;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-level-2);border:1px solid var(--sinch-color-snow-500);border-radius:var(--sinch-popover-shape-radius,var(--sinch-shape-radius-l));contain:content;padding:0;box-sizing:border-box;max-width:unset;max-height:unset;z-index:1}dialog:not([open]){display:none}dialog::backdrop{background-color:transparent}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:transparent}dialog.fixed{position:fixed;top:50%;transform:translate(0,-50%)}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}#target{display:flex;flex-direction:column}</style><div id="wrapper"><div id="target" aria-haspopup="dialog" aria-expanded="false"><slot name="target"></slot></div><dialog id="dialog" tabindex="-1"><slot name="content"></slot></dialog></div>';
16
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative}dialog{position:fixed;top:0;left:0;margin:0;outline:0;padding:0;border:none;box-sizing:border-box;max-width:unset;max-height:unset;z-index:1;background:0 0;overflow:visible}dialog:not([open]){display:none}dialog::backdrop{background-color:transparent}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:transparent}dialog.fixed{position:fixed;top:50%;transform:translate(0,-50%)}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}#target{display:flex;flex-direction:column}#content{position:relative;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-level-2);border:1px solid var(--sinch-color-snow-500);border-radius:var(--sinch-popover-shape-radius,var(--sinch-shape-radius-l));outline:0}#target-open{display:flex;flex-direction:column;position:absolute;left:0;top:0}</style><div id="wrapper"><div id="target" aria-haspopup="dialog" aria-expanded="false"><slot name="target"></slot></div><dialog id="dialog"><div id="target-open"><slot name="target-open"></slot></div><div id="content" tabindex="-1"><slot name="content"></slot></div></dialog></div>';
17
17
  import { orientationValues } from './utils';
18
18
  const template = document.createElement('template');
19
19
  template.innerHTML = templateHTML;
20
20
  const POPOVER_OFFSET = 4;
21
- defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _prevOverflowValue = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _updateOrientationModal = new WeakMap(), _onBackdropMouseDown = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onTargetKeydown = new WeakMap(), _dispatchCloseEvent = new WeakSet(), class extends NectaryElement {
21
+ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _originalOverflowValue = new WeakMap(), _$targetSlot = new WeakMap(), _$targetOpenSlot = new WeakMap(), _$targetOpenWrapper = new WeakMap(), _targetActiveElement = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _onBackdropMouseDown = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _dispatchCloseEvent = new WeakSet(), _onTargetBlur = new WeakMap(), _onTargetFocus = new WeakMap(), class extends NectaryElement {
22
22
  constructor() {
23
23
  super();
24
24
 
@@ -50,52 +50,39 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
50
50
  value: void 0
51
51
  });
52
52
 
53
- _classPrivateFieldInitSpec(this, _prevOverflowValue, {
53
+ _classPrivateFieldInitSpec(this, _originalOverflowValue, {
54
54
  writable: true,
55
55
  value: ''
56
56
  });
57
57
 
58
- _classPrivateFieldInitSpec(this, _onResize, {
58
+ _classPrivateFieldInitSpec(this, _$targetSlot, {
59
59
  writable: true,
60
- value: () => {
61
- _classPrivateFieldGet(this, _resizeThrottle).fn();
62
- }
60
+ value: void 0
63
61
  });
64
62
 
65
- _classPrivateFieldInitSpec(this, _updateOrientation, {
63
+ _classPrivateFieldInitSpec(this, _$targetOpenSlot, {
66
64
  writable: true,
67
- value: () => {
68
- _classPrivateFieldGet(this, _$dialog).style.width = 'max-content';
69
-
70
- const targetRect = _classPrivateFieldGet(this, _$target).getBoundingClientRect();
71
-
72
- const modalRect = _classPrivateFieldGet(this, _$dialog).getBoundingClientRect();
73
-
74
- let leftPos = 0;
75
- let topPos = 0;
76
- const orient = this.orientation;
77
- const shouldExpandWidthToTarget = orient === 'top' || orient === 'bottom';
78
- const resultWidth = shouldExpandWidthToTarget ? Math.max(modalRect.width, targetRect.width) : modalRect.width;
79
-
80
- if (orient === 'bottom-left' || orient === 'top-left') {
81
- leftPos = targetRect.width - resultWidth;
82
- }
65
+ value: void 0
66
+ });
83
67
 
84
- if (orient === 'bottom-left' || orient === 'bottom-right' || orient === 'bottom') {
85
- topPos = targetRect.height + POPOVER_OFFSET;
86
- }
68
+ _classPrivateFieldInitSpec(this, _$targetOpenWrapper, {
69
+ writable: true,
70
+ value: void 0
71
+ });
87
72
 
88
- if (orient === 'top-left' || orient === 'top-right' || orient === 'top') {
89
- topPos = -(modalRect.height + POPOVER_OFFSET);
90
- }
73
+ _classPrivateFieldInitSpec(this, _targetActiveElement, {
74
+ writable: true,
75
+ value: null
76
+ });
91
77
 
92
- _classPrivateFieldGet(this, _$dialog).style.left = `${leftPos}px`;
93
- _classPrivateFieldGet(this, _$dialog).style.top = `${topPos}px`;
94
- _classPrivateFieldGet(this, _$dialog).style.width = `${resultWidth}px`;
78
+ _classPrivateFieldInitSpec(this, _onResize, {
79
+ writable: true,
80
+ value: () => {
81
+ _classPrivateFieldGet(this, _resizeThrottle).fn();
95
82
  }
96
83
  });
97
84
 
98
- _classPrivateFieldInitSpec(this, _updateOrientationModal, {
85
+ _classPrivateFieldInitSpec(this, _updateOrientation, {
99
86
  writable: true,
100
87
  value: () => {
101
88
  _classPrivateFieldGet(this, _$dialog).style.width = 'max-content';
@@ -129,6 +116,13 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
129
116
  _classPrivateFieldGet(this, _$dialog).style.left = `${leftPos}px`;
130
117
  _classPrivateFieldGet(this, _$dialog).style.top = `${topPos}px`;
131
118
  _classPrivateFieldGet(this, _$dialog).style.width = `${resultWidth}px`;
119
+
120
+ if (!this.modal) {
121
+ const targetLeftPos = targetRect.left - leftPos;
122
+ const targetTopPos = targetRect.top - topPos;
123
+ _classPrivateFieldGet(this, _$targetOpenWrapper).style.left = `${targetLeftPos}px`;
124
+ _classPrivateFieldGet(this, _$targetOpenWrapper).style.top = `${targetTopPos}px`;
125
+ }
132
126
  }
133
127
  });
134
128
 
@@ -165,19 +159,23 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
165
159
  }
166
160
  });
167
161
 
168
- _classPrivateFieldInitSpec(this, _onTargetKeydown, {
162
+ _classPrivateFieldInitSpec(this, _onTargetBlur, {
169
163
  writable: true,
170
164
  value: e => {
171
- switch (e.key) {
172
- case 'Escape':
173
- {
174
- e.preventDefault();
165
+ e.stopPropagation();
175
166
 
176
- _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
167
+ _classPrivateFieldSet(this, _targetActiveElement, e.target);
177
168
 
178
- break;
179
- }
180
- }
169
+ _classPrivateFieldGet(this, _$targetOpenSlot).removeEventListener('blur', _classPrivateFieldGet(this, _onTargetBlur), true);
170
+ }
171
+ });
172
+
173
+ _classPrivateFieldInitSpec(this, _onTargetFocus, {
174
+ writable: true,
175
+ value: e => {
176
+ e.stopPropagation();
177
+
178
+ _classPrivateFieldGet(this, _$targetOpenSlot).removeEventListener('focus', _classPrivateFieldGet(this, _onTargetFocus), true);
181
179
  }
182
180
  });
183
181
 
@@ -188,11 +186,19 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
188
186
 
189
187
  _classPrivateFieldSet(this, _$dialog, shadowRoot.querySelector('#dialog'));
190
188
 
189
+ _classPrivateFieldSet(this, _$targetSlot, shadowRoot.querySelector('slot[name="target"]'));
190
+
191
+ _classPrivateFieldSet(this, _$targetOpenSlot, shadowRoot.querySelector('slot[name="target-open"]'));
192
+
193
+ _classPrivateFieldSet(this, _$targetOpenWrapper, shadowRoot.querySelector('#target-open'));
194
+
191
195
  _classPrivateFieldSet(this, _isConnected, false);
192
196
 
193
- _classPrivateFieldSet(this, _resizeThrottle, throttleAnimationFrame(_classPrivateFieldGet(this, _updateOrientationModal)));
197
+ _classPrivateFieldSet(this, _resizeThrottle, throttleAnimationFrame(_classPrivateFieldGet(this, _updateOrientation)));
194
198
 
195
199
  dialogPolyfill.registerDialog(_classPrivateFieldGet(this, _$dialog));
200
+
201
+ dialogPolyfill.dm.handleFocus_ = function () {};
196
202
  }
197
203
 
198
204
  connectedCallback() {
@@ -278,11 +284,7 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
278
284
  case 'orientation':
279
285
  {
280
286
  if (_classPrivateMethodGet(this, _isOpen, _isOpen2).call(this)) {
281
- if (this.modal) {
282
- _classPrivateFieldGet(this, _updateOrientationModal).call(this);
283
- } else {
284
- _classPrivateFieldGet(this, _updateOrientation).call(this);
285
- }
287
+ _classPrivateFieldGet(this, _updateOrientation).call(this);
286
288
  }
287
289
 
288
290
  break;
@@ -306,29 +308,38 @@ function _onExpand2() {
306
308
  return;
307
309
  }
308
310
 
309
- if (this.modal) {
310
- _classPrivateFieldGet(this, _$dialog).style.position = 'fixed';
311
+ if (!this.modal) {
312
+ _classPrivateFieldGet(this, _$targetOpenSlot).addEventListener('blur', _classPrivateFieldGet(this, _onTargetBlur), true);
313
+
314
+ _classPrivateFieldGet(this, _$targetOpenSlot).addEventListener('focus', _classPrivateFieldGet(this, _onTargetFocus), true);
311
315
 
312
- _classPrivateFieldGet(this, _$dialog).showModal();
316
+ const targetRect = _classPrivateFieldGet(this, _$target).getBoundingClientRect();
313
317
 
314
- _classPrivateFieldGet(this, _updateOrientationModal).call(this);
318
+ const widthPx = `${targetRect.width}px`;
319
+ const heightPx = `${targetRect.height}px`;
320
+ _classPrivateFieldGet(this, _$target).style.width = widthPx;
321
+ _classPrivateFieldGet(this, _$target).style.height = heightPx;
322
+ _classPrivateFieldGet(this, _$targetOpenWrapper).style.width = widthPx;
323
+ _classPrivateFieldGet(this, _$targetOpenWrapper).style.height = heightPx;
324
+ _classPrivateFieldGet(this, _$targetSlot).assignedElements()[0]?.setAttribute('slot', 'target-open');
325
+ }
315
326
 
316
- _classPrivateFieldGet(this, _$target).setAttribute('aria-expanded', 'true');
327
+ _classPrivateFieldGet(this, _$dialog).showModal();
317
328
 
318
- _classPrivateFieldSet(this, _prevOverflowValue, document.body.style.overflow);
329
+ _classPrivateFieldGet(this, _updateOrientation).call(this);
319
330
 
320
- document.body.style.overflow = 'hidden';
321
- window.addEventListener('resize', _classPrivateFieldGet(this, _onResize));
322
- } else {
323
- this.addEventListener('keydown', _classPrivateFieldGet(this, _onTargetKeydown));
324
- _classPrivateFieldGet(this, _$dialog).style.position = 'absolute';
331
+ _classPrivateFieldGet(this, _$target).setAttribute('aria-expanded', 'true');
325
332
 
326
- _classPrivateFieldGet(this, _$dialog).setAttribute('open', '');
333
+ requestAnimationFrame(() => {
334
+ _classPrivateFieldGet(this, _targetActiveElement)?.focus();
327
335
 
328
- _classPrivateFieldGet(this, _updateOrientation).call(this);
336
+ _classPrivateFieldSet(this, _targetActiveElement, null);
337
+ });
329
338
 
330
- _classPrivateFieldGet(this, _$target).setAttribute('aria-expanded', 'true');
331
- }
339
+ _classPrivateFieldSet(this, _originalOverflowValue, document.body.style.overflow);
340
+
341
+ document.body.style.overflow = 'hidden';
342
+ window.addEventListener('resize', _classPrivateFieldGet(this, _onResize));
332
343
  }
333
344
 
334
345
  function _onCollapse2() {
@@ -336,20 +347,19 @@ function _onCollapse2() {
336
347
  return;
337
348
  }
338
349
 
339
- if (this.modal) {
340
- _classPrivateFieldGet(this, _$dialog).close?.();
341
- } else {
342
- _classPrivateFieldGet(this, _$dialog).removeAttribute('open');
343
- }
350
+ _classPrivateFieldGet(this, _$targetOpenSlot).assignedElements()[0]?.setAttribute('slot', 'target');
351
+ _classPrivateFieldGet(this, _$target).style.width = 'unset';
352
+ _classPrivateFieldGet(this, _$target).style.height = 'unset';
353
+
354
+ _classPrivateFieldGet(this, _$dialog).close();
344
355
 
345
356
  _classPrivateFieldGet(this, _$target).setAttribute('aria-expanded', 'false');
346
357
 
347
- document.body.style.overflow = _classPrivateFieldGet(this, _prevOverflowValue);
358
+ document.body.style.overflow = _classPrivateFieldGet(this, _originalOverflowValue);
348
359
 
349
360
  _classPrivateFieldGet(this, _resizeThrottle).cancel();
350
361
 
351
362
  window.removeEventListener('resize', _classPrivateFieldGet(this, _onResize));
352
- this.removeEventListener('keydown', _classPrivateFieldGet(this, _onTargetKeydown));
353
363
  }
354
364
 
355
365
  function _isOpen2() {
package/select/index.js CHANGED
@@ -13,7 +13,7 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
13
13
 
14
14
  import '../dropdown';
15
15
  import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
16
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#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])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" modal orientation="bottom"><button slot="target" id="button"><span id="content"></span><svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span><span id="additional"></span></div></div>';
16
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#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])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" orientation="bottom"><button slot="target" id="button"><span id="content"></span><svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span><span id="additional"></span></div></div>';
17
17
  const template = document.createElement('template');
18
18
  template.innerHTML = templateHTML;
19
19
  defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
package/select/types.d.ts CHANGED
@@ -20,7 +20,9 @@ export declare type TSinchSelectElement = HTMLElement & {
20
20
  readonly dropdownRect: TRect;
21
21
  /** Change value event */
22
22
  addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
23
+ /** Focus event */
23
24
  addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
25
+ /** Blur event */
24
26
  addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
25
27
  /** Value that matches one of the options `value` */
26
28
  setAttribute(name: 'value', value: string): void;
@@ -62,6 +64,8 @@ export declare type TSinchSelectReact = TSinchElementReact<TSinchSelectElement>
62
64
  onChange?: (e: SyntheticEvent<TSinchSelectElement, CustomEvent<string>>) => void;
63
65
  /** Change value handler */
64
66
  'on-change'?: (e: CustomEvent<string>) => void;
67
+ /** Focus handler */
65
68
  'on-focus'?: (e: CustomEvent<void>) => void;
69
+ /** Blur handler */
66
70
  'on-blur'?: (e: CustomEvent<void>) => void;
67
71
  };
@@ -1,3 +1,26 @@
1
- import type { TSinchDropdownTextOptionElement, TSinchDropdownTextOptionReact } from '../dropdown-text-option/types';
2
- export declare type TSinchSelectOptionElement = TSinchDropdownTextOptionElement;
3
- export declare type TSinchSelectOptionReact = TSinchDropdownTextOptionReact;
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchSelectOptionElement = HTMLElement & {
3
+ /** Value */
4
+ value: string;
5
+ /** Text */
6
+ text: string;
7
+ /** Disabled */
8
+ disabled: boolean;
9
+ readonly icon: Element | null;
10
+ /** Value */
11
+ setAttribute(name: 'value', value: string): void;
12
+ /** Text */
13
+ setAttribute(name: 'text', value: string): void;
14
+ /** Disabled */
15
+ setAttribute(name: 'disabled', value: ''): void;
16
+ };
17
+ export declare type TSinchSelectOptionReact = TSinchElementReact<TSinchSelectOptionElement> & {
18
+ /** Value */
19
+ value: string;
20
+ /** Text */
21
+ text: string;
22
+ /** Disabled */
23
+ disabled?: boolean;
24
+ /** Label that is used for a11y */
25
+ 'aria-label': string;
26
+ };
package/tag/index.js CHANGED
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icons/cancel';
11
11
  import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
12
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:24px;padding:2px 8px;border-radius:12px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);box-sizing:border-box;--sinch-color-icon:var(--sinch-color-stormy-400);--sinch-size-icon:16px}:host([category=candy])>#wrapper{background-color:var(--sinch-color-candy-200)}:host([category=bolt])>#wrapper{background-color:var(--sinch-color-bolt-200)}:host([category=aqua])>#wrapper{background-color:var(--sinch-color-aqua-200)}:host([category=grass])>#wrapper{background-color:var(--sinch-color-grass-200)}:host([category=berry])>#wrapper{background-color:var(--sinch-color-berry-200)}:host([category=orange])>#wrapper{background-color:var(--sinch-color-orange-200)}:host([category=night])>#wrapper{background-color:var(--sinch-color-night-200)}:host([category=mud])>#wrapper{background-color:var(--sinch-color-mud-200)}:host([category=dirt])>#wrapper{background-color:var(--sinch-color-dirt-200)}:host([inverted]:not([inverted=false]))>#wrapper{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-snow-100)}:host([small]:not([small=false])) #wrapper{height:20px;border-radius:10px;padding:0 8px;--sinch-size-icon:14px}#text{text-overflow:ellipsis;white-space:nowrap;overflow:auto;flex:1}</style><div id="wrapper"><slot name="icon"></slot><span id="text"></span><slot name="close"></slot></div>';
12
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:24px;padding:2px 8px;border-radius:12px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);box-sizing:border-box;--sinch-color-icon:var(--sinch-color-stormy-400);--sinch-size-icon:16px}:host([category=candy])>#wrapper{background-color:var(--sinch-color-candy-200)}:host([category=bolt])>#wrapper{background-color:var(--sinch-color-bolt-200)}:host([category=aqua])>#wrapper{background-color:var(--sinch-color-aqua-200)}:host([category=grass])>#wrapper{background-color:var(--sinch-color-grass-200)}:host([category=berry])>#wrapper{background-color:var(--sinch-color-berry-200)}:host([category=orange])>#wrapper{background-color:var(--sinch-color-orange-200)}:host([category=night])>#wrapper{background-color:var(--sinch-color-night-200)}:host([category=mud])>#wrapper{background-color:var(--sinch-color-mud-200)}:host([category=dirt])>#wrapper{background-color:var(--sinch-color-dirt-200)}:host([inverted]:not([inverted=false]))>#wrapper{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-snow-100)}:host([small]:not([small=false])) #wrapper{height:20px;border-radius:10px;padding:0 8px;--sinch-size-icon:14px}#text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;flex:1}</style><div id="wrapper"><slot name="icon"></slot><span id="text"></span><slot name="close"></slot></div>';
13
13
  import { categoryValues } from './utils';
14
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
package/text/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../icons/cancel';
2
2
  import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue } from '../utils';
3
- const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}</style><slot></slot>';
3
+ const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}</style><slot></slot>';
4
4
  import { assertType, typeValues } from './utils';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
@@ -18,7 +18,7 @@ import '../icons/arrow-drop-down';
18
18
  import '../segmented-control';
19
19
  import '../segmented-control-option';
20
20
  import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
21
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-font-title-xl);line-height:48px}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-color-stormy-500)}#digit-minutes,#picker-hours{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;font:var(--sinch-font-text-s);line-height:28px;text-align:center;color:var(--sinch-color-text-default);top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-24{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-minute{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-hour-12:hover,.digit-hour-24:hover,.digit-minute:hover{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected,.digit-hour-24.selected,.digit-minute.selected{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected{font-size:16px}.digit-hour-24.selected{font-size:16px}.digit-minute.selected{font-size:16px}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-color-stormy-500)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-color-tropical-500)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0;--sinch-icon-size:24px}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-hours::before,#header-minutes::before{content:"";display:none;position:absolute;border-radius:12px;left:50%;top:50%;width:100%;height:100%;transform:translate(-50%,-50%);padding:1px;border:1px solid var(--sinch-color-aqua-400)}#header-hours-down,#header-hours-up,#header-minutes-down,#header-minutes-up{display:none;position:absolute;left:50%;transform:translateX(-50%)}#header-hours-up,#header-minutes-up{top:-18px}#header-hours-down,#header-minutes-down{bottom:-18px}#header-hours:focus #header-hours-down,#header-hours:focus #header-hours-up,#header-hours:focus::before{display:block}#header-minutes:focus #header-minutes-down,#header-minutes:focus #header-minutes-up,#header-minutes:focus::before{display:block}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-hours-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-hours-down"></sinch-icon-arrow-drop-down></div><div id="header-colon">&colon;</div><div id="header-minutes" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-minutes-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-minutes-down"></sinch-icon-arrow-drop-down></div><sinch-icon-button id="submit" small aria-label="Submit"><sinch-icon-done slot="icon"></sinch-icon-done></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour"></div><div id="needle-minute"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
21
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-font-title-xl);line-height:48px}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-color-stormy-500)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;font:var(--sinch-font-text-s);line-height:28px;text-align:center;color:var(--sinch-color-text-default);top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-24{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-minute{font:var(--sinch-font-text-xs);line-height:28px;color:var(--sinch-color-text-muted)}.digit-hour-12:hover,.digit-hour-24:hover,.digit-minute:hover{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected,.digit-hour-24.selected,.digit-minute.selected{color:var(--sinch-color-tropical-500)}.digit-hour-12.selected{font-size:16px}.digit-hour-24.selected{font-size:16px}.digit-minute.selected{font-size:16px}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-color-stormy-500)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-color-tropical-500)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0;--sinch-icon-size:24px}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-hours::before,#header-minutes::before{content:"";display:none;position:absolute;border-radius:12px;left:50%;top:50%;width:100%;height:100%;transform:translate(-50%,-50%);padding:1px;border:1px solid var(--sinch-color-aqua-400)}#header-hours-down,#header-hours-up,#header-minutes-down,#header-minutes-up{display:none;position:absolute;left:50%;transform:translateX(-50%)}#header-hours-up,#header-minutes-up{top:-18px}#header-hours-down,#header-minutes-down{bottom:-18px}#header-hours:focus #header-hours-down,#header-hours:focus #header-hours-up,#header-hours:focus::before{display:block}#header-minutes:focus #header-minutes-down,#header-minutes:focus #header-minutes-up,#header-minutes:focus::before{display:block}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-hours-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-hours-down"></sinch-icon-arrow-drop-down></div><div id="header-colon">&colon;</div><div id="header-minutes" tabindex="0" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span><sinch-icon-arrow-drop-up id="header-minutes-up"></sinch-icon-arrow-drop-up><sinch-icon-arrow-drop-down id="header-minutes-down"></sinch-icon-arrow-drop-down></div><sinch-icon-button id="submit" small aria-label="Submit"><sinch-icon-done slot="icon"></sinch-icon-done></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour"></div><div id="needle-minute"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
22
22
  import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
23
23
  const template = document.createElement('template');
24
24
  template.innerHTML = templateHTML;
@@ -194,6 +194,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
194
194
  switch (e.key) {
195
195
  case 'ArrowUp':
196
196
  {
197
+ e.preventDefault();
198
+
197
199
  _classPrivateFieldSet(this, _hour, (_classPrivateFieldGet(this, _hour) + 1) % 24);
198
200
 
199
201
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -203,6 +205,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
203
205
 
204
206
  case 'ArrowDown':
205
207
  {
208
+ e.preventDefault();
209
+
206
210
  _classPrivateFieldSet(this, _hour, (_classPrivateFieldGet(this, _hour) + 23) % 24);
207
211
 
208
212
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -219,6 +223,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
219
223
  switch (e.key) {
220
224
  case 'ArrowUp':
221
225
  {
226
+ e.preventDefault();
227
+
222
228
  _classPrivateFieldSet(this, _minute, (_classPrivateFieldGet(this, _minute) + 1) % 60);
223
229
 
224
230
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -228,6 +234,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
228
234
 
229
235
  case 'ArrowDown':
230
236
  {
237
+ e.preventDefault();
238
+
231
239
  _classPrivateFieldSet(this, _minute, (_classPrivateFieldGet(this, _minute) + 59) % 60);
232
240
 
233
241
  _classPrivateMethodGet(this, _render, _render2).call(this);
@@ -0,0 +1,13 @@
1
+ import '../icons/check';
2
+ import '../icons/error-outline';
3
+ import type { TSinchVerticalStepperElement, TSinchVerticalStepperReact } from './types';
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-vertical-stepper': TSinchVerticalStepperReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-vertical-stepper': TSinchVerticalStepperElement;
12
+ }
13
+ }
@@ -0,0 +1,95 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$itemsSlot, _updateItems;
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 '../icons/check';
11
+ import '../icons/error-outline';
12
+ import { clampNumber, defineCustomElement, getAttribute, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
13
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;width:100%}#progress{position:absolute;height:1px;background-color:var(--sinch-color-snow-700);left:72px;right:72px;top:16px;transform:translateY(-50%)}#bar{position:absolute;height:1px;background-color:var(--sinch-color-stormy-400);left:0;top:0}</style><div id="wrapper"><slot></slot></div>';
14
+ const template = document.createElement('template');
15
+ template.innerHTML = templateHTML;
16
+ defineCustomElement('sinch-vertical-stepper', (_$itemsSlot = new WeakMap(), _updateItems = new WeakMap(), class extends NectaryElement {
17
+ constructor() {
18
+ super();
19
+
20
+ _classPrivateFieldInitSpec(this, _$itemsSlot, {
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+
25
+ _classPrivateFieldInitSpec(this, _updateItems, {
26
+ writable: true,
27
+ value: () => {
28
+ const $items = _classPrivateFieldGet(this, _$itemsSlot).assignedElements();
29
+
30
+ const activeIndex = clampNumber(getIntegerAttribute(this, 'index', 0), 0, $items.length + 1);
31
+
32
+ for (let i = 0; i < $items.length; i++) {
33
+ const $el = $items[i];
34
+ const itemIndex = i + 1;
35
+ $el.setAttribute('data-index', String(itemIndex));
36
+
37
+ if (itemIndex === activeIndex) {
38
+ $el.setAttribute('data-progress', 'active');
39
+ } else if (itemIndex < activeIndex) {
40
+ $el.setAttribute('data-progress', 'done');
41
+ } else {
42
+ $el.removeAttribute('data-progress');
43
+ }
44
+ }
45
+
46
+ this.setAttribute('aria-valuemax', String($items.length));
47
+ this.setAttribute('aria-valuenow', String(clampNumber(activeIndex, 0, $items.length)));
48
+ }
49
+ });
50
+
51
+ const shadowRoot = this.attachShadow();
52
+ shadowRoot.appendChild(template.content.cloneNode(true));
53
+
54
+ _classPrivateFieldSet(this, _$itemsSlot, shadowRoot.querySelector('slot'));
55
+ }
56
+
57
+ connectedCallback() {
58
+ this.setAttribute('role', 'progressbar');
59
+ this.setAttribute('aria-valuemin', '0');
60
+
61
+ _classPrivateFieldGet(this, _$itemsSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _updateItems));
62
+ }
63
+
64
+ disconnectedCallback() {
65
+ _classPrivateFieldGet(this, _$itemsSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _updateItems));
66
+ }
67
+
68
+ static get observedAttributes() {
69
+ return ['index'];
70
+ }
71
+
72
+ attributeChangedCallback(name, oldVal, newVal) {
73
+ if (oldVal === newVal) {
74
+ return;
75
+ }
76
+
77
+ switch (name) {
78
+ case 'index':
79
+ {
80
+ _classPrivateFieldGet(this, _updateItems).call(this);
81
+
82
+ break;
83
+ }
84
+ }
85
+ }
86
+
87
+ set index(value) {
88
+ updateAttribute(this, 'index', value);
89
+ }
90
+
91
+ get index() {
92
+ return getAttribute(this, 'index', '1');
93
+ }
94
+
95
+ }));
@@ -0,0 +1,13 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchVerticalStepperElement = HTMLElement & {
3
+ /** Current item index, starting from 1 */
4
+ index: string;
5
+ /** Current item index, starting from 1 */
6
+ setAttribute(name: 'index', value: string): void;
7
+ };
8
+ export declare type TSinchVerticalStepperReact = TSinchElementReact<TSinchVerticalStepperElement> & {
9
+ /** Current item index, starting from 1 */
10
+ index: string;
11
+ /** Label that is used for a11y */
12
+ 'aria-label': string;
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import '../icons/check';
2
+ import '../icons/exclamation';
3
+ import type { TSinchVerticalStepperItemElement, TSinchVerticalStepperItemReact } from './types';
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-vertical-stepper-item': TSinchVerticalStepperItemReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-vertical-stepper-item': TSinchVerticalStepperItemElement;
12
+ }
13
+ }