@nectary/components 0.34.0 → 0.36.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 (105) hide show
  1. package/accordion/index.js +35 -10
  2. package/accordion/types.d.ts +3 -2
  3. package/accordion-item/index.js +8 -4
  4. package/action-menu/index.js +7 -8
  5. package/action-menu/types.d.ts +3 -3
  6. package/action-menu-option/index.js +23 -3
  7. package/action-menu-option/types.d.ts +2 -0
  8. package/alert/index.d.ts +4 -0
  9. package/alert/index.js +17 -32
  10. package/alert/types.d.ts +1 -7
  11. package/alert/utils.d.ts +3 -0
  12. package/alert/utils.js +6 -1
  13. package/avatar/index.js +1 -1
  14. package/button/index.js +69 -5
  15. package/button/types.d.ts +6 -0
  16. package/checkbox/index.js +64 -6
  17. package/checkbox/types.d.ts +8 -2
  18. package/date-picker/index.js +37 -12
  19. package/date-picker/types.d.ts +4 -2
  20. package/dialog/index.js +5 -6
  21. package/dialog/types.d.ts +3 -3
  22. package/dropdown/index.js +44 -28
  23. package/dropdown/types.d.ts +6 -4
  24. package/dropdown-checkbox-option/index.js +1 -1
  25. package/dropdown-checkbox-option/types.d.ts +0 -2
  26. package/dropdown-radio-option/index.js +1 -1
  27. package/dropdown-radio-option/types.d.ts +0 -2
  28. package/dropdown-text-option/index.js +1 -1
  29. package/dropdown-text-option/types.d.ts +0 -2
  30. package/horizontal-stepper/types.d.ts +4 -0
  31. package/horizontal-stepper-item/index.js +1 -1
  32. package/horizontal-stepper-item/types.d.ts +9 -0
  33. package/icon-button/index.js +75 -5
  34. package/icon-button/types.d.ts +6 -0
  35. package/icons/create-icon-class.js +1 -1
  36. package/icons-branded/create-icon-class.js +3 -7
  37. package/icons-branded/types.d.ts +3 -0
  38. package/icons-channel/create-icon-class.js +3 -7
  39. package/icons-channel/types.d.ts +3 -0
  40. package/inline-alert/index.d.ts +17 -0
  41. package/inline-alert/index.js +154 -0
  42. package/inline-alert/types.d.ts +15 -0
  43. package/inline-alert/utils.d.ts +5 -0
  44. package/inline-alert/utils.js +6 -0
  45. package/input/index.d.ts +0 -1
  46. package/input/index.js +58 -5
  47. package/input/types.d.ts +8 -2
  48. package/link/index.js +81 -3
  49. package/link/types.d.ts +9 -0
  50. package/package.json +1 -1
  51. package/pagination/index.js +24 -8
  52. package/pagination/types.d.ts +3 -1
  53. package/popover/index.js +5 -6
  54. package/popover/types.d.ts +4 -3
  55. package/radio/index.js +36 -8
  56. package/radio/types.d.ts +3 -1
  57. package/radio-option/index.js +1 -1
  58. package/search/types.d.ts +0 -1
  59. package/segment-collapse/index.js +28 -12
  60. package/segment-collapse/types.d.ts +3 -1
  61. package/segmented-control/index.js +28 -23
  62. package/segmented-control/types.d.ts +3 -2
  63. package/segmented-control-option/index.js +59 -13
  64. package/segmented-control-option/types.d.ts +4 -0
  65. package/segmented-icon-control/index.js +27 -16
  66. package/segmented-icon-control/types.d.ts +5 -2
  67. package/segmented-icon-control-option/index.js +54 -12
  68. package/segmented-icon-control-option/types.d.ts +4 -0
  69. package/select/index.js +68 -9
  70. package/select/types.d.ts +8 -2
  71. package/tabs/index.js +32 -8
  72. package/tabs/types.d.ts +3 -2
  73. package/tabs-option/index.js +2 -2
  74. package/text/index.js +1 -1
  75. package/textarea/index.js +58 -4
  76. package/textarea/types.d.ts +7 -2
  77. package/tile-control/index.d.ts +11 -0
  78. package/tile-control/index.js +181 -0
  79. package/tile-control/types.d.ts +38 -0
  80. package/tile-control/types.js +1 -0
  81. package/tile-control-option/index.d.ts +11 -0
  82. package/tile-control-option/index.js +161 -0
  83. package/tile-control-option/types.d.ts +37 -0
  84. package/time-picker/index.js +18 -4
  85. package/time-picker/types.d.ts +4 -2
  86. package/toggle/index.js +63 -5
  87. package/toggle/types.d.ts +3 -1
  88. package/vertical-stepper/index.d.ts +13 -0
  89. package/vertical-stepper/index.js +95 -0
  90. package/vertical-stepper/types.d.ts +13 -0
  91. package/vertical-stepper/types.js +1 -0
  92. package/vertical-stepper-item/index.d.ts +13 -0
  93. package/vertical-stepper-item/index.js +100 -0
  94. package/vertical-stepper-item/types.d.ts +24 -0
  95. package/vertical-stepper-item/types.js +1 -0
  96. package/vertical-stepper-item/utils.d.ts +2 -0
  97. package/vertical-stepper-item/utils.js +1 -0
  98. package/alert-button/index.d.ts +0 -11
  99. package/alert-button/index.js +0 -59
  100. package/alert-button/types.d.ts +0 -8
  101. package/alert-close/index.d.ts +0 -12
  102. package/alert-close/index.js +0 -38
  103. package/alert-close/types.d.ts +0 -3
  104. /package/{alert-button → inline-alert}/types.js +0 -0
  105. /package/{alert-close → tile-control-option}/types.js +0 -0
@@ -0,0 +1,38 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { SyntheticEvent } from 'react';
3
+ export declare type TSinchTileControlElement = HTMLElement & {
4
+ /** Value */
5
+ value: string;
6
+ /** Small */
7
+ small: boolean;
8
+ /** Multiple */
9
+ multiple: boolean;
10
+ /** Number of columns from 1 to 8 */
11
+ cols: number;
12
+ /** Change value event */
13
+ addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
14
+ /** Value */
15
+ setAttribute(name: 'value', value: string): void;
16
+ /** Small */
17
+ setAttribute(name: 'small', value: ''): void;
18
+ /** Multiple */
19
+ setAttribute(name: 'multiple', value: ''): void;
20
+ /** Number of columns from 1 to 8 */
21
+ setAttribute(name: 'cols', value: string): void;
22
+ };
23
+ export declare type TSinchTileControlReact = TSinchElementReact<TSinchTileControlElement> & {
24
+ /** Value */
25
+ value: string;
26
+ /** Multiple */
27
+ multiple?: boolean;
28
+ /** Small */
29
+ small?: boolean;
30
+ /** Number of columns from 1 to 8 */
31
+ cols: number;
32
+ /** Label that is used for a11y */
33
+ 'aria-label': string;
34
+ /** @deprecated Change value handler */
35
+ onChange?: (event: SyntheticEvent<TSinchTileControlElement, CustomEvent<string>>) => void;
36
+ /** Change value handler */
37
+ 'on-change'?: (e: CustomEvent<string>) => void;
38
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { TSinchTileControlOptionElement, TSinchTileControlOptionReact } from './types';
2
+ declare global {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ 'sinch-tile-control-option': TSinchTileControlOptionReact;
6
+ }
7
+ }
8
+ interface HTMLElementTagNameMap {
9
+ 'sinch-tile-control-option': TSinchTileControlOptionElement;
10
+ }
11
+ }
@@ -0,0 +1,161 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$button, _$text, _onButtonClick, _onButtonFocus, _onButtonBlur, _onFocusReactHandler, _onBlurReactHandler;
5
+
6
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
+
8
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
+
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
11
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;position:relative;display:flex;flex-direction:column;justify-content:space-between;box-sizing:border-box;width:88px;height:88px;padding:16px 8px 8px;border-radius:var(--sinch-shape-radius-l);background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-leve-1);cursor:pointer}:host([data-small])>button{width:64px;height:64px;border-radius:var(--sinch-shape-radius-m);padding:12px 4px 4px}button::before{content:"";position:absolute;left:0;top:0;bottom:0;right:0;border:1px solid var(--sinch-color-snow-700);border-radius:var(--sinch-shape-radius-l);pointer-events:none}:host([data-small])>button::before{border-radius:var(--sinch-shape-radius-m)}button:focus-visible::after{position:absolute;content:"";left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:100%;padding:2px;border:2px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-shape-radius-l) + 4px);pointer-events:none}:host([data-small])>button:focus-visible::after{border-radius:calc(var(--sinch-shape-radius-m) + 4px)}@supports not selector(:focus-visible){button:focus::after{position:absolute;content:"";left:50%;top:50%;transform:translate(-50%,-50%);width:100%;height:100%;padding:2px;border:2px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-shape-radius-l) + 4px)}:host([data-small])>button:focus::after{border-radius:calc(var(--sinch-shape-radius-m) + 4px)}}button:enabled:hover{background-color:var(--sinch-color-tropical-100)}button:enabled:hover::before{border-color:var(--sinch-color-tropical-100)}:host([data-checked])>button:enabled,button:enabled:active{box-shadow:var(--sinch-elevation-level-0)}:host([data-checked])>button:enabled::before,button:enabled:active::before{border-width:2px;border-color:var(--sinch-color-stormy-500)}button:disabled{cursor:initial}button:disabled>#icon,button:disabled>#text{opacity:.5}#text{display:inline-block;min-height:20px;text-align:center;font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-500);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon{width:32px;height:32px;align-self:center;--sinch-size-icon:32px;--sinch-color-icon:var(--sinch-color-stormy-500)}:host([data-small]) #icon{width:24px;height:24px;--sinch-size-icon:24px}button>*{pointer-events:none}</style><button><div id="icon"><slot name="icon"></slot></div><span id="text"></span></button>';
12
+ const template = document.createElement('template');
13
+ template.innerHTML = templateHTML;
14
+ defineCustomElement('sinch-tile-control-option', (_$button = new WeakMap(), _$text = new WeakMap(), _onButtonClick = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
15
+ constructor() {
16
+ super();
17
+
18
+ _classPrivateFieldInitSpec(this, _$button, {
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+
23
+ _classPrivateFieldInitSpec(this, _$text, {
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+
28
+ _classPrivateFieldInitSpec(this, _onButtonClick, {
29
+ writable: true,
30
+ value: e => {
31
+ e.stopPropagation();
32
+ this.dispatchEvent(new CustomEvent('option-change', {
33
+ detail: this.value,
34
+ bubbles: true
35
+ }));
36
+ }
37
+ });
38
+
39
+ _classPrivateFieldInitSpec(this, _onButtonFocus, {
40
+ writable: true,
41
+ value: () => {
42
+ this.dispatchEvent(new CustomEvent('-focus'));
43
+ }
44
+ });
45
+
46
+ _classPrivateFieldInitSpec(this, _onButtonBlur, {
47
+ writable: true,
48
+ value: () => {
49
+ this.dispatchEvent(new CustomEvent('-blur'));
50
+ }
51
+ });
52
+
53
+ _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
54
+ writable: true,
55
+ value: () => {
56
+ getReactEventHandler(this, 'on-focus')?.();
57
+ }
58
+ });
59
+
60
+ _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
61
+ writable: true,
62
+ value: () => {
63
+ getReactEventHandler(this, 'on-blur')?.();
64
+ }
65
+ });
66
+
67
+ const shadowRoot = this.attachShadow();
68
+ shadowRoot.appendChild(template.content.cloneNode(true));
69
+
70
+ _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
71
+
72
+ _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
73
+ }
74
+
75
+ connectedCallback() {
76
+ this.setAttribute('role', 'tab');
77
+
78
+ _classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
79
+
80
+ _classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
81
+
82
+ _classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
83
+
84
+ this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
85
+ this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
86
+ }
87
+
88
+ disconnectedCallback() {
89
+ _classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
90
+
91
+ _classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
92
+
93
+ _classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
94
+
95
+ this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
96
+ this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
97
+ }
98
+
99
+ static get observedAttributes() {
100
+ return ['data-checked', 'text', 'disabled'];
101
+ }
102
+
103
+ attributeChangedCallback(name, oldVal, newVal) {
104
+ if (oldVal === newVal) {
105
+ return;
106
+ }
107
+
108
+ switch (name) {
109
+ case 'text':
110
+ {
111
+ _classPrivateFieldGet(this, _$text).textContent = newVal;
112
+ break;
113
+ }
114
+
115
+ case 'data-checked':
116
+ {
117
+ updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
118
+ break;
119
+ }
120
+
121
+ case 'disabled':
122
+ {
123
+ _classPrivateFieldGet(this, _$button).disabled = isAttrTrue(newVal);
124
+ break;
125
+ }
126
+ }
127
+ }
128
+
129
+ set value(value) {
130
+ updateAttribute(this, 'value', value);
131
+ }
132
+
133
+ get value() {
134
+ return getAttribute(this, 'value', '');
135
+ }
136
+
137
+ set disabled(isDisabled) {
138
+ updateBooleanAttribute(this, 'disabled', isDisabled);
139
+ }
140
+
141
+ get disabled() {
142
+ return getBooleanAttribute(this, 'disabled');
143
+ }
144
+
145
+ set text(value) {
146
+ updateAttribute(this, 'text', value);
147
+ }
148
+
149
+ get text() {
150
+ return getAttribute(this, 'text', '');
151
+ }
152
+
153
+ focus() {
154
+ _classPrivateFieldGet(this, _$button).focus();
155
+ }
156
+
157
+ blur() {
158
+ _classPrivateFieldGet(this, _$button).blur();
159
+ }
160
+
161
+ }));
@@ -0,0 +1,37 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchTileControlOptionElement = HTMLElement & {
3
+ /** Value */
4
+ value: string;
5
+ /** Text content */
6
+ text: string;
7
+ /** Disabled */
8
+ disabled: boolean;
9
+ /** Small */
10
+ small: boolean;
11
+ /** Focus event */
12
+ addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
13
+ /** Blur event */
14
+ addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
15
+ /** Value */
16
+ setAttribute(name: 'value', value: string): void;
17
+ /** Text content */
18
+ setAttribute(attr: 'text', value: string): void;
19
+ /** Disabled */
20
+ setAttribute(name: 'disabled', value: ''): void;
21
+ /** Small */
22
+ setAttribute(name: 'small', value: ''): void;
23
+ };
24
+ export declare type TSinchTileControlOptionReact = TSinchElementReact<TSinchTileControlOptionElement> & {
25
+ /** Value */
26
+ value: string;
27
+ /** Text content */
28
+ text: string;
29
+ /** Label that is used for a11y */
30
+ 'aria-label': string;
31
+ /** Disabled */
32
+ disabled?: boolean;
33
+ /** Focus handler */
34
+ 'on-focus'?: (e: CustomEvent<void>) => void;
35
+ /** Blur handler */
36
+ 'on-blur'?: (e: CustomEvent<void>) => void;
37
+ };
@@ -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 _$pickerHours, _$pickerMinutes, _$pickerTouch, _$needleHour, _$needleMinute, _$headerHours, _$headerHoursText, _$headerMinutes, _$headerMinutesText, _$ampm, _$submitButton, _hour, _minute, _getClickDegree, _onPickerClick, _render, _selectHour, _selectMinute, _onAmPmChange, _onSubmitButtonClick, _onHoursKeydown, _onMinutesKeydown;
4
+ var _$pickerHours, _$pickerMinutes, _$pickerTouch, _$needleHour, _$needleMinute, _$headerHours, _$headerHoursText, _$headerMinutes, _$headerMinutesText, _$ampm, _$submitButton, _hour, _minute, _getClickDegree, _onPickerClick, _render, _selectHour, _selectMinute, _onAmPmChange, _onSubmitButtonClick, _onHoursKeydown, _onMinutesKeydown, _onChangeReactHandler;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -17,8 +17,8 @@ import '../icons/arrow-drop-up';
17
17
  import '../icons/arrow-drop-down';
18
18
  import '../segmented-control';
19
19
  import '../segmented-control-option';
20
- import { defineCustomElement, getAttribute, getBooleanAttribute, 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>';
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)}#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;
@@ -32,7 +32,7 @@ const HOUR_24_RADIUS = HOUR_12_RADIUS - HOUR_24_DIGIT_SIZE;
32
32
  const NEEDLE_HOUR_12_LENGTH = HOUR_12_RADIUS;
33
33
  const NEEDLE_HOUR_24_LENGTH = HOUR_24_RADIUS;
34
34
  const NEEDLE_MINUTE_LENGTH = MINUTE_RADIUS;
35
- defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$pickerMinutes = new WeakMap(), _$pickerTouch = new WeakMap(), _$needleHour = new WeakMap(), _$needleMinute = new WeakMap(), _$headerHours = new WeakMap(), _$headerHoursText = new WeakMap(), _$headerMinutes = new WeakMap(), _$headerMinutesText = new WeakMap(), _$ampm = new WeakMap(), _$submitButton = new WeakMap(), _hour = new WeakMap(), _minute = new WeakMap(), _getClickDegree = new WeakSet(), _onPickerClick = new WeakMap(), _render = new WeakSet(), _selectHour = new WeakSet(), _selectMinute = new WeakSet(), _onAmPmChange = new WeakMap(), _onSubmitButtonClick = new WeakMap(), _onHoursKeydown = new WeakMap(), _onMinutesKeydown = new WeakMap(), class extends NectaryElement {
35
+ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$pickerMinutes = new WeakMap(), _$pickerTouch = new WeakMap(), _$needleHour = new WeakMap(), _$needleMinute = new WeakMap(), _$headerHours = new WeakMap(), _$headerHoursText = new WeakMap(), _$headerMinutes = new WeakMap(), _$headerMinutesText = new WeakMap(), _$ampm = new WeakMap(), _$submitButton = new WeakMap(), _hour = new WeakMap(), _minute = new WeakMap(), _getClickDegree = new WeakSet(), _onPickerClick = new WeakMap(), _render = new WeakSet(), _selectHour = new WeakSet(), _selectMinute = new WeakSet(), _onAmPmChange = new WeakMap(), _onSubmitButtonClick = new WeakMap(), _onHoursKeydown = new WeakMap(), _onMinutesKeydown = new WeakMap(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
36
36
  constructor() {
37
37
  super();
38
38
 
@@ -182,6 +182,9 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
182
182
  bubbles: true,
183
183
  detail: value
184
184
  }));
185
+ this.dispatchEvent(new CustomEvent('-change', {
186
+ detail: value
187
+ }));
185
188
  }
186
189
  });
187
190
 
@@ -235,6 +238,13 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
235
238
  }
236
239
  });
237
240
 
241
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
242
+ writable: true,
243
+ value: e => {
244
+ getReactEventHandler(this, 'on-change')?.(e);
245
+ }
246
+ });
247
+
238
248
  const shadowRoot = this.attachShadow();
239
249
  shadowRoot.appendChild(template.content.cloneNode(true));
240
250
 
@@ -323,6 +333,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
323
333
  _classPrivateFieldGet(this, _$headerHours).addEventListener('keydown', _classPrivateFieldGet(this, _onHoursKeydown));
324
334
 
325
335
  _classPrivateFieldGet(this, _$headerMinutes).addEventListener('keydown', _classPrivateFieldGet(this, _onMinutesKeydown));
336
+
337
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
326
338
  }
327
339
 
328
340
  disconnectedCallback() {
@@ -335,6 +347,8 @@ defineCustomElement('sinch-time-picker', (_$pickerHours = new WeakMap(), _$picke
335
347
  _classPrivateFieldGet(this, _$headerHours).removeEventListener('keydown', _classPrivateFieldGet(this, _onHoursKeydown));
336
348
 
337
349
  _classPrivateFieldGet(this, _$headerMinutes).removeEventListener('keydown', _classPrivateFieldGet(this, _onMinutesKeydown));
350
+
351
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
338
352
  }
339
353
 
340
354
  static get observedAttributes() {
@@ -11,7 +11,7 @@ export declare type TSinchTimePickerElement = HTMLElement & {
11
11
  hourDigitRect(hour: number): TRect | null;
12
12
  minuteDigitRect(minute: number): TRect | null;
13
13
  /** Change value handler, return time in ISO 8601 format */
14
- addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
14
+ addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
15
15
  /** Time value in ISO 8601 format */
16
16
  setAttribute(name: 'value', value: string): void;
17
17
  /** AM/PM 12-hour clock system, `false` by default */
@@ -27,5 +27,7 @@ export declare type TSinchTimePickerReact = TSinchElementReact<TSinchTimePickerE
27
27
  /** Submit button label that is used for a11y */
28
28
  'submit-aria-label': string;
29
29
  /** Change value handler, return time in ISO 8601 format */
30
- onChange: (e: SyntheticEvent<TSinchTimePickerElement, CustomEvent<string>>) => void;
30
+ onChange?: (e: SyntheticEvent<TSinchTimePickerElement, CustomEvent<string>>) => void;
31
+ /** Change value handler, return time in ISO 8601 format */
32
+ 'on-change'?: (e: CustomEvent<string>) => void;
31
33
  };
package/toggle/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$input, _$label, _onInput;
4
+ var _$input, _$label, _onInput, _onCheckboxFocus, _onCheckboxBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
11
11
  const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);text-align:initial}:host([small]:not([small=false])) #wrapper{font:var(--sinch-font-small-text)}#checkbox{all:initial;display:block;position:absolute;left:0;top:0;width:40px;height:20px;cursor:pointer;pointer-events:initial}#checkbox:disabled{cursor:initial}#knob-container{position:relative;box-sizing:border-box;align-self:center;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-color-stormy-100);box-shadow:var(--sinch-elevation-level-1);overflow:hidden}:host([checked]:not([checked=false])) #knob-container{background-color:var(--sinch-color-tropical-500)}:host([small]:not([small=false])) #knob-container{width:32px;height:16px;border-radius:8px}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-color-snow-100);transform:translateX(0);transition:transform .1s ease-in-out}:host([checked]:not([checked=false])) #knob{transform:translateX(20px)}:host([small]:not([small=false])) #knob{width:12px;height:12px}:host([small]:not([small=false])[checked]:not([checked=false])) #knob{transform:translateX(16px)}#knob::after,#knob::before{color:var(--sinch-color-snow-100);text-transform:uppercase;font-size:8px;line-height:16px;display:none;position:absolute;top:0;padding:0 3px}#knob::before{content:"on";right:100%}#knob::after{content:"off";left:100%}:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::after,:host([labeled]:not([labeled=false]):is(:not([small]),[small=false])) #knob::before{display:block}@media (prefers-reduced-motion){#knob{transition:none}}#label{display:none;flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-stormy-200)}:host([disabled]:not([disabled=false])) #knob-container{background-color:var(--sinch-color-snow-700)}:host([checked]:not([checked=false])[disabled]:not([disabled=false])) #knob-container{background-color:var(--sinch-color-tropical-100)}</style><div id="wrapper"><div id="knob-container"><div id="knob"></div><input id="checkbox" type="checkbox"></div><label for="checkbox" id="label"></label></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new WeakMap(), _onInput = new WeakMap(), class extends NectaryElement {
14
+ defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new WeakMap(), _onInput = new WeakMap(), _onCheckboxFocus = new WeakMap(), _onCheckboxBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -37,6 +37,44 @@ defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new Weak
37
37
  detail: isChecked,
38
38
  bubbles: true
39
39
  }));
40
+ this.dispatchEvent(new CustomEvent('-change', {
41
+ detail: isChecked
42
+ }));
43
+ }
44
+ });
45
+
46
+ _classPrivateFieldInitSpec(this, _onCheckboxFocus, {
47
+ writable: true,
48
+ value: () => {
49
+ this.dispatchEvent(new CustomEvent('-focus'));
50
+ }
51
+ });
52
+
53
+ _classPrivateFieldInitSpec(this, _onCheckboxBlur, {
54
+ writable: true,
55
+ value: () => {
56
+ this.dispatchEvent(new CustomEvent('-blur'));
57
+ }
58
+ });
59
+
60
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
61
+ writable: true,
62
+ value: e => {
63
+ getReactEventHandler(this, 'on-change')?.(e);
64
+ }
65
+ });
66
+
67
+ _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
68
+ writable: true,
69
+ value: e => {
70
+ getReactEventHandler(this, 'on-focus')?.(e);
71
+ }
72
+ });
73
+
74
+ _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
75
+ writable: true,
76
+ value: e => {
77
+ getReactEventHandler(this, 'on-blur')?.(e);
40
78
  }
41
79
  });
42
80
 
@@ -46,13 +84,33 @@ defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new Weak
46
84
  _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
47
85
 
48
86
  _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
49
-
50
- _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
51
87
  }
52
88
 
53
89
  connectedCallback() {
54
90
  this.setAttribute('role', 'checkbox');
55
91
  this.setAttribute('aria-label', 'toggle');
92
+
93
+ _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
94
+
95
+ _classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onCheckboxFocus));
96
+
97
+ _classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onCheckboxBlur));
98
+
99
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
100
+ this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
101
+ this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
102
+ }
103
+
104
+ disconnectedCallback() {
105
+ _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
106
+
107
+ _classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onCheckboxFocus));
108
+
109
+ _classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onCheckboxBlur));
110
+
111
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
112
+ this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
113
+ this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
56
114
  }
57
115
 
58
116
  static get observedAttributes() {
package/toggle/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare type TSinchToggleElement = HTMLElement & {
7
7
  disabled: boolean;
8
8
  text: string | null;
9
9
  addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
10
+ addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
10
11
  setAttribute(name: 'checked', value: ''): void;
11
12
  setAttribute(name: 'small', value: ''): void;
12
13
  setAttribute(name: 'labeled', value: ''): void;
@@ -20,5 +21,6 @@ export declare type TSinchToggleReact = TSinchElementReact<TSinchToggleElement>
20
21
  disabled?: boolean;
21
22
  text?: string;
22
23
  'aria-label': string;
23
- onChange: (e: SyntheticEvent<TSinchToggleElement, CustomEvent<boolean>>) => void;
24
+ onChange?: (e: SyntheticEvent<TSinchToggleElement, CustomEvent<boolean>>) => void;
25
+ 'on-change'?: (e: CustomEvent<boolean>) => void;
24
26
  };
@@ -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
+ }