@nectary/components 0.38.0 → 0.39.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 (54) hide show
  1. package/accordion/types.d.ts +1 -0
  2. package/card/index.d.ts +2 -0
  3. package/card/index.js +6 -31
  4. package/date-picker/index.js +42 -2
  5. package/date-picker/types.d.ts +25 -1
  6. package/dialog/index.d.ts +1 -0
  7. package/dialog/index.js +3 -2
  8. package/dropdown/types.d.ts +2 -0
  9. package/inline-alert/index.js +1 -1
  10. package/package.json +1 -1
  11. package/pagination/types.d.ts +1 -0
  12. package/radio/types.d.ts +1 -0
  13. package/segment/index.js +1 -1
  14. package/segment-collapse/types.d.ts +1 -0
  15. package/segmented-control/types.d.ts +1 -0
  16. package/segmented-icon-control/types.d.ts +1 -0
  17. package/select/types.d.ts +1 -1
  18. package/tabs/types.d.ts +1 -0
  19. package/tag/index.d.ts +1 -0
  20. package/tag/index.js +10 -3
  21. package/tag/utils.d.ts +3 -0
  22. package/tag/utils.js +6 -1
  23. package/tag-close/index.js +5 -1
  24. package/tag-close/types.d.ts +3 -1
  25. package/time-picker/index.js +9 -1
  26. package/time-picker/types.d.ts +5 -1
  27. package/toast/index.d.ts +17 -0
  28. package/toast/index.js +153 -0
  29. package/toast/types.d.ts +28 -0
  30. package/toast/utils.d.ts +5 -0
  31. package/toast/utils.js +6 -0
  32. package/toast-manager/index.d.ts +17 -0
  33. package/toast-manager/index.js +271 -0
  34. package/toast-manager/types.d.ts +7 -0
  35. package/toggle/index.js +3 -4
  36. package/toggle/types.d.ts +1 -0
  37. package/utils.d.ts +1 -0
  38. package/utils.js +22 -0
  39. package/card-button/index.d.ts +0 -11
  40. package/card-button/index.js +0 -77
  41. package/card-button/types.d.ts +0 -12
  42. package/card-link/index.d.ts +0 -12
  43. package/card-link/index.js +0 -115
  44. package/card-link/types.d.ts +0 -14
  45. package/search/index.d.ts +0 -14
  46. package/search/index.js +0 -523
  47. package/search/types.d.ts +0 -25
  48. package/search/types.js +0 -1
  49. package/search-option/index.d.ts +0 -11
  50. package/search-option/index.js +0 -55
  51. package/search-option/types.d.ts +0 -9
  52. package/search-option/types.js +0 -1
  53. /package/{card-link → toast}/types.js +0 -0
  54. /package/{card-button → toast-manager}/types.js +0 -0
package/toast/index.js ADDED
@@ -0,0 +1,153 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$text, _tid, _updateTimeout, _onTimeout, _clearTimeout, _onTimeoutReactHandler;
5
+
6
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
+
8
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
+
10
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
+
12
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
+
14
+ import '../icons/report-problem';
15
+ import '../icons/report';
16
+ import '../icons/check-circle';
17
+ import '../icons/info';
18
+ import '../title';
19
+ import '../text';
20
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler, getBooleanAttribute, updateBooleanAttribute } from '../utils';
21
+ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:center;gap:8px;width:328px;padding:8px 16px;box-sizing:border-box;border-radius:var(--sinch-shape-radius-l);box-shadow:var(--sinch-elevation-level-3)}#text{color:var(--sinch-color-stormy-500);padding:4px 0 4px 4px;flex:1;min-width:0}#icon-error,#icon-info,#icon-success,#icon-warn{display:none;align-self:flex-start;margin:4px 0}:host([type=success]) #wrapper{background-color:var(--sinch-color-success-200)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-warning-200)}:host([type=error]) #wrapper{background-color:var(--sinch-color-error-200)}:host([type=info]) #wrapper{background-color:var(--sinch-color-informative-200)}:host([type=success]) #icon-success{display:block;--sinch-color-icon:var(--sinch-color-success-500)}:host([type=warn]) #icon-warn{display:block;--sinch-color-icon:var(--sinch-color-warning-500)}:host([type=error]) #icon-error{display:block;--sinch-color-icon:var(--sinch-color-error-500)}:host([type=info]) #icon-info{display:block;--sinch-color-icon:var(--sinch-color-informative-500)}</style><div id="wrapper"><sinch-icon-info id="icon-info"></sinch-icon-info><sinch-icon-check-circle id="icon-success"></sinch-icon-check-circle><sinch-icon-report-problem id="icon-warn"></sinch-icon-report-problem><sinch-icon-report id="icon-error"></sinch-icon-report><sinch-text id="text" type="m"></sinch-text><slot name="action"></slot><slot name="close"></slot></div>';
22
+ import { assertType, typeValues } from './utils';
23
+ const TIMEOUT = 5000;
24
+ const template = document.createElement('template');
25
+ template.innerHTML = templateHTML;
26
+ defineCustomElement('sinch-toast', (_$text = new WeakMap(), _tid = new WeakMap(), _updateTimeout = new WeakSet(), _onTimeout = new WeakMap(), _clearTimeout = new WeakSet(), _onTimeoutReactHandler = new WeakMap(), class extends NectaryElement {
27
+ constructor() {
28
+ super();
29
+
30
+ _classPrivateMethodInitSpec(this, _clearTimeout);
31
+
32
+ _classPrivateMethodInitSpec(this, _updateTimeout);
33
+
34
+ _classPrivateFieldInitSpec(this, _$text, {
35
+ writable: true,
36
+ value: void 0
37
+ });
38
+
39
+ _classPrivateFieldInitSpec(this, _tid, {
40
+ writable: true,
41
+ value: null
42
+ });
43
+
44
+ _classPrivateFieldInitSpec(this, _onTimeout, {
45
+ writable: true,
46
+ value: () => {
47
+ this.dispatchEvent(new CustomEvent('-timeout'));
48
+ }
49
+ });
50
+
51
+ _classPrivateFieldInitSpec(this, _onTimeoutReactHandler, {
52
+ writable: true,
53
+ value: e => {
54
+ getReactEventHandler(this, 'on-timeout')?.(e);
55
+ }
56
+ });
57
+
58
+ const shadowRoot = this.attachShadow();
59
+ shadowRoot.appendChild(template.content.cloneNode(true));
60
+
61
+ _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
62
+ }
63
+
64
+ connectedCallback() {
65
+ this.setAttribute('aria-atomic', 'true');
66
+ this.setAttribute('aria-live', 'polite');
67
+ this.addEventListener('-timeout', _classPrivateFieldGet(this, _onTimeoutReactHandler));
68
+
69
+ _classPrivateMethodGet(this, _updateTimeout, _updateTimeout2).call(this);
70
+ }
71
+
72
+ disconnectedCallback() {
73
+ this.removeEventListener('-timeout', _classPrivateFieldGet(this, _onTimeoutReactHandler));
74
+
75
+ _classPrivateMethodGet(this, _clearTimeout, _clearTimeout2).call(this);
76
+ }
77
+
78
+ get type() {
79
+ return getLiteralAttribute(this, typeValues, 'type');
80
+ }
81
+
82
+ set type(value) {
83
+ updateLiteralAttribute(this, typeValues, 'type', value);
84
+ }
85
+
86
+ get text() {
87
+ return getAttribute(this, 'text', '');
88
+ }
89
+
90
+ set text(value) {
91
+ updateAttribute(this, 'text', value);
92
+ }
93
+
94
+ get persistent() {
95
+ return getBooleanAttribute(this, 'persistent');
96
+ }
97
+
98
+ set persistent(isPersistent) {
99
+ updateBooleanAttribute(this, 'persistent', isPersistent);
100
+ }
101
+
102
+ static get observedAttributes() {
103
+ return ['text', 'type', 'persistent'];
104
+ }
105
+
106
+ attributeChangedCallback(name, oldVal, newVal) {
107
+ if (oldVal === newVal) {
108
+ return;
109
+ }
110
+
111
+ switch (name) {
112
+ case 'type':
113
+ {
114
+ assertType(newVal);
115
+ break;
116
+ }
117
+
118
+ case 'text':
119
+ {
120
+ _classPrivateFieldGet(this, _$text).textContent = newVal;
121
+ break;
122
+ }
123
+
124
+ case 'persistent':
125
+ {
126
+ _classPrivateMethodGet(this, _updateTimeout, _updateTimeout2).call(this);
127
+
128
+ break;
129
+ }
130
+ }
131
+ }
132
+
133
+ }));
134
+
135
+ function _updateTimeout2() {
136
+ if (this.persistent) {
137
+ _classPrivateMethodGet(this, _clearTimeout, _clearTimeout2).call(this);
138
+
139
+ return;
140
+ }
141
+
142
+ if (_classPrivateFieldGet(this, _tid) === null) {
143
+ _classPrivateFieldSet(this, _tid, window.setTimeout(_classPrivateFieldGet(this, _onTimeout), TIMEOUT));
144
+ }
145
+ }
146
+
147
+ function _clearTimeout2() {
148
+ if (_classPrivateFieldGet(this, _tid) !== null) {
149
+ window.clearTimeout(_classPrivateFieldGet(this, _tid));
150
+
151
+ _classPrivateFieldSet(this, _tid, null);
152
+ }
153
+ }
@@ -0,0 +1,28 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchToastType = 'info' | 'warn' | 'error' | 'success';
3
+ export declare type TSinchToastElement = HTMLElement & {
4
+ /** Type */
5
+ type: TSinchToastType;
6
+ /** Text */
7
+ text: string;
8
+ /** Persistent, i.e. doesn't automatically dissapear after 5s */
9
+ persistent: boolean;
10
+ /** Timeout event */
11
+ addEventListener(type: '-timeout', listener: (e: CustomEvent<void>) => void): void;
12
+ /** Type */
13
+ setAttribute(name: 'type', value: TSinchToastType): void;
14
+ /** Text */
15
+ setAttribute(name: 'text', value: string): void;
16
+ /** Persistent, i.e. doesn't automatically dissapear after 5s */
17
+ setAttribute(name: 'persistent', value: ''): void;
18
+ };
19
+ export declare type TSinchToastReact = TSinchElementReact<TSinchToastElement> & {
20
+ /** Type */
21
+ type: TSinchToastType;
22
+ /** Text */
23
+ text: string;
24
+ /** Persistent, i.e. doesn't automatically dissapear after 5s */
25
+ persistent?: boolean;
26
+ /** Timeout handler */
27
+ 'on-timeout'?: (e: CustomEvent<void>) => void;
28
+ };
@@ -0,0 +1,5 @@
1
+ import type { TSinchToastType } from './types';
2
+ export declare const typeValues: readonly TSinchToastType[];
3
+ declare type TAssertType = (value: string | null) => asserts value is TSinchToastType;
4
+ export declare const assertType: TAssertType;
5
+ export {};
package/toast/utils.js ADDED
@@ -0,0 +1,6 @@
1
+ export const typeValues = ['info', 'success', 'warn', 'error'];
2
+ export const assertType = value => {
3
+ if (value === null || !typeValues.includes(value)) {
4
+ throw new Error(`sinch-toast: invalid type attribute: ${value}`);
5
+ }
6
+ };
@@ -0,0 +1,17 @@
1
+ import '../icons/report-problem';
2
+ import '../icons/report';
3
+ import '../icons/check-circle';
4
+ import '../icons/info';
5
+ import '../title';
6
+ import '../text';
7
+ import type { TSinchToastManagerElement, TSinchToastManagerReact } from './types';
8
+ declare global {
9
+ namespace JSX {
10
+ interface IntrinsicElements {
11
+ 'sinch-toast-manager': TSinchToastManagerReact;
12
+ }
13
+ }
14
+ interface HTMLElementTagNameMap {
15
+ 'sinch-toast-manager': TSinchToastManagerElement;
16
+ }
17
+ }
@@ -0,0 +1,271 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$slot, _$list, _map, _shouldReduceMotion, _animations, _onAnimateAdd, _onAnimateRemove, _onSlotChange, _storeAnimation, _clear, _subscribeChildren, _unsubscribeChildren, _onCloneCloseClick, _onCloneActionClick;
5
+
6
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
+
8
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
+
10
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
+
12
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
+
14
+ import '../icons/report-problem';
15
+ import '../icons/report';
16
+ import '../icons/check-circle';
17
+ import '../icons/info';
18
+ import '../title';
19
+ import '../text';
20
+ import { cloneNode, defineCustomElement, getRect, NectaryElement } from '../utils';
21
+ const templateHTML = '<style>:host{display:block}#items{display:block;width:0;height:0;visibility:hidden;overflow:hidden}#list{display:flex;flex-direction:column;position:fixed;bottom:0;right:16px}.item-wrapper{height:0;opacity:0;position:relative}.item-wrapper[data-deleting]::after{content:"";position:absolute;top:0;left:0;bottom:0;right:0}</style><slot id="items"></slot><div id="list"></div>';
22
+ const DURATION_ADD = 250;
23
+ const DURATION_REMOVE = 250;
24
+ const ITEMS_GAP = 16;
25
+ const template = document.createElement('template');
26
+ template.innerHTML = templateHTML;
27
+ defineCustomElement('sinch-toast-manager', (_$slot = new WeakMap(), _$list = new WeakMap(), _map = new WeakMap(), _shouldReduceMotion = new WeakMap(), _animations = new WeakMap(), _onAnimateAdd = new WeakSet(), _onAnimateRemove = new WeakSet(), _onSlotChange = new WeakMap(), _storeAnimation = new WeakSet(), _clear = new WeakSet(), _subscribeChildren = new WeakSet(), _unsubscribeChildren = new WeakSet(), _onCloneCloseClick = new WeakMap(), _onCloneActionClick = new WeakMap(), class extends NectaryElement {
28
+ constructor() {
29
+ super();
30
+
31
+ _classPrivateMethodInitSpec(this, _unsubscribeChildren);
32
+
33
+ _classPrivateMethodInitSpec(this, _subscribeChildren);
34
+
35
+ _classPrivateMethodInitSpec(this, _clear);
36
+
37
+ _classPrivateMethodInitSpec(this, _storeAnimation);
38
+
39
+ _classPrivateMethodInitSpec(this, _onAnimateRemove);
40
+
41
+ _classPrivateMethodInitSpec(this, _onAnimateAdd);
42
+
43
+ _classPrivateFieldInitSpec(this, _$slot, {
44
+ writable: true,
45
+ value: void 0
46
+ });
47
+
48
+ _classPrivateFieldInitSpec(this, _$list, {
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+
53
+ _classPrivateFieldInitSpec(this, _map, {
54
+ writable: true,
55
+ value: new WeakMap()
56
+ });
57
+
58
+ _classPrivateFieldInitSpec(this, _shouldReduceMotion, {
59
+ writable: true,
60
+ value: false
61
+ });
62
+
63
+ _classPrivateFieldInitSpec(this, _animations, {
64
+ writable: true,
65
+ value: new Set()
66
+ });
67
+
68
+ _classPrivateFieldInitSpec(this, _onSlotChange, {
69
+ writable: true,
70
+ value: () => {
71
+ const slotItems = _classPrivateFieldGet(this, _$slot).assignedElements();
72
+
73
+ const listItems = Array.from(_classPrivateFieldGet(this, _$list).children);
74
+ let removeIndex = 0;
75
+
76
+ for (const item of listItems) {
77
+ if (item.hasAttribute('data-deleting')) {
78
+ ++removeIndex;
79
+ continue;
80
+ }
81
+
82
+ const orig = _classPrivateFieldGet(this, _map).get(item);
83
+
84
+ if (orig != null && slotItems.includes(orig)) {
85
+ continue;
86
+ }
87
+
88
+ _classPrivateFieldGet(this, _map).delete(item);
89
+
90
+ if (orig != null) {
91
+ _classPrivateFieldGet(this, _map).delete(orig);
92
+ }
93
+
94
+ _classPrivateMethodGet(this, _unsubscribeChildren, _unsubscribeChildren2).call(this, item);
95
+
96
+ _classPrivateMethodGet(this, _onAnimateRemove, _onAnimateRemove2).call(this, item, removeIndex);
97
+
98
+ ++removeIndex;
99
+ }
100
+
101
+ let addIndex = 0;
102
+
103
+ for (const item of slotItems) {
104
+ if (_classPrivateFieldGet(this, _map).has(item)) {
105
+ continue;
106
+ }
107
+
108
+ const cloned = cloneNode(item, true);
109
+ const rect = item.getBoundingClientRect();
110
+ const wrapper = document.createElement('div');
111
+ wrapper.className = 'item-wrapper';
112
+ wrapper.appendChild(cloned);
113
+
114
+ _classPrivateFieldGet(this, _$list).appendChild(wrapper);
115
+
116
+ _classPrivateFieldGet(this, _map).set(item, wrapper);
117
+
118
+ _classPrivateFieldGet(this, _map).set(wrapper, item);
119
+
120
+ _classPrivateMethodGet(this, _subscribeChildren, _subscribeChildren2).call(this, cloned);
121
+
122
+ _classPrivateMethodGet(this, _onAnimateAdd, _onAnimateAdd2).call(this, wrapper, addIndex, rect.height);
123
+
124
+ addIndex++;
125
+ }
126
+ }
127
+ });
128
+
129
+ _classPrivateFieldInitSpec(this, _onCloneCloseClick, {
130
+ writable: true,
131
+ value: e => {
132
+ const item = e.target.parentElement?.parentElement;
133
+
134
+ if (item != null) {
135
+ item.setAttribute('data-delete-now', '');
136
+ _classPrivateFieldGet(this, _map).get(item)?.querySelector('[slot=close]')?.dispatchEvent(new CustomEvent('-click'));
137
+ }
138
+ }
139
+ });
140
+
141
+ _classPrivateFieldInitSpec(this, _onCloneActionClick, {
142
+ writable: true,
143
+ value: e => {
144
+ const item = e.target.parentElement?.parentElement;
145
+
146
+ if (item != null) {
147
+ _classPrivateFieldGet(this, _map).get(item)?.querySelector('[slot=action]')?.dispatchEvent(new CustomEvent('-click'));
148
+ }
149
+ }
150
+ });
151
+
152
+ const shadowRoot = this.attachShadow();
153
+ shadowRoot.appendChild(template.content.cloneNode(true));
154
+
155
+ _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
156
+
157
+ _classPrivateFieldSet(this, _$list, shadowRoot.querySelector('#list'));
158
+ }
159
+
160
+ connectedCallback() {
161
+ _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
162
+
163
+ _classPrivateFieldSet(this, _shouldReduceMotion, window.matchMedia('(prefers-reduced-motion: reduce)').matches);
164
+ }
165
+
166
+ disconnectedCallback() {
167
+ _classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
168
+
169
+ _classPrivateMethodGet(this, _clear, _clear2).call(this);
170
+ }
171
+
172
+ get containerRect() {
173
+ return getRect(_classPrivateFieldGet(this, _$list));
174
+ }
175
+
176
+ nthActionRect(nth) {
177
+ const item = _classPrivateFieldGet(this, _$list).children[nth]?.querySelector('[slot=action]');
178
+ return item != null ? getRect(item) : null;
179
+ }
180
+
181
+ nthCloseRect(nth) {
182
+ const item = _classPrivateFieldGet(this, _$list).children[nth]?.querySelector('[slot=close]');
183
+ return item != null ? getRect(item) : null;
184
+ }
185
+
186
+ }));
187
+
188
+ function _onAnimateAdd2(item, index, height) {
189
+ const duration = _classPrivateFieldGet(this, _shouldReduceMotion) ? 0 : DURATION_ADD;
190
+ const addAnim = item.animate({
191
+ height: ['0', `${height + ITEMS_GAP}px`],
192
+ opacity: [0, 1]
193
+ }, {
194
+ delay: index * duration,
195
+ duration,
196
+ iterations: 1,
197
+ fill: 'forwards'
198
+ });
199
+
200
+ _classPrivateMethodGet(this, _storeAnimation, _storeAnimation2).call(this, addAnim);
201
+ }
202
+
203
+ function _onAnimateRemove2(item, index) {
204
+ const rect = item.getBoundingClientRect();
205
+ const duration = _classPrivateFieldGet(this, _shouldReduceMotion) ? 0 : DURATION_REMOVE;
206
+ const indexInQueue = item.hasAttribute('data-delete-now') ? 0 : index;
207
+ const heightAnim = item.animate({
208
+ height: [`${rect.height}px`, '0']
209
+ }, {
210
+ delay: duration + indexInQueue * duration,
211
+ duration,
212
+ iterations: 1,
213
+ fill: 'forwards'
214
+ });
215
+ const opacityAnim = item.animate({
216
+ opacity: [1, 0]
217
+ }, {
218
+ delay: indexInQueue * duration,
219
+ duration,
220
+ iterations: 1,
221
+ fill: 'forwards'
222
+ });
223
+ item.setAttribute('data-deleting', '');
224
+
225
+ _classPrivateMethodGet(this, _storeAnimation, _storeAnimation2).call(this, heightAnim, () => item.remove());
226
+
227
+ _classPrivateMethodGet(this, _storeAnimation, _storeAnimation2).call(this, opacityAnim);
228
+ }
229
+
230
+ function _storeAnimation2(anim, cb) {
231
+ const onAnimEnd = () => {
232
+ _classPrivateFieldGet(this, _animations).delete(anim);
233
+
234
+ cb?.();
235
+ anim.removeEventListener('finish', onAnimEnd);
236
+ anim.removeEventListener('remove', onAnimEnd);
237
+ anim.removeEventListener('cancel', onAnimEnd);
238
+ };
239
+
240
+ anim.addEventListener('finish', onAnimEnd);
241
+ anim.addEventListener('remove', onAnimEnd);
242
+ anim.addEventListener('cancel', onAnimEnd);
243
+
244
+ _classPrivateFieldGet(this, _animations).add(anim);
245
+ }
246
+
247
+ function _clear2() {
248
+ const listItems = Array.from(_classPrivateFieldGet(this, _$list).children);
249
+
250
+ for (const item of listItems) {
251
+ _classPrivateFieldGet(this, _map).delete(item);
252
+
253
+ _classPrivateMethodGet(this, _unsubscribeChildren, _unsubscribeChildren2).call(this, item);
254
+
255
+ item.remove();
256
+ }
257
+
258
+ for (const anim of _classPrivateFieldGet(this, _animations)) {
259
+ anim.cancel();
260
+ }
261
+ }
262
+
263
+ function _subscribeChildren2(item) {
264
+ item.querySelector('[slot=close]')?.addEventListener('-click', _classPrivateFieldGet(this, _onCloneCloseClick));
265
+ item.querySelector('[slot=action]')?.addEventListener('-click', _classPrivateFieldGet(this, _onCloneActionClick));
266
+ }
267
+
268
+ function _unsubscribeChildren2(item) {
269
+ item.querySelector('[slot=close]')?.removeEventListener('-click', _classPrivateFieldGet(this, _onCloneCloseClick));
270
+ item.querySelector('[slot=action]')?.removeEventListener('-click', _classPrivateFieldGet(this, _onCloneActionClick));
271
+ }
@@ -0,0 +1,7 @@
1
+ import type { TRect, TSinchElementReact } from '../types';
2
+ export declare type TSinchToastManagerElement = HTMLElement & {
3
+ readonly containerRect: TRect;
4
+ nthActionRect: (nth: number) => TRect | null;
5
+ nthCloseRect: (nth: number) => TRect | null;
6
+ };
7
+ export declare type TSinchToastManagerReact = TSinchElementReact<TSinchToastManagerElement> & {};
package/toggle/index.js CHANGED
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
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
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}#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>';
11
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;width:100%;height:32px}:host([small]:not([small=false])) #wrapper{font:var(--sinch-font-small-text)}#input{all:initial;display:block;position:absolute;left:0;top:6px;width:40px;height:20px;cursor:pointer;pointer-events:initial}#input:disabled{cursor:initial}:host([small]:not([small=false])) #input{width:32px;height:16px;top:8px}#input:focus-visible::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-color-aqua-400);border-radius:18px;pointer-events:none}:host([small]:not([small=false])) #input:focus-visible::after{border-radius:14px}@supports not selector(:focus-visible){#input:focus::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-color-aqua-400);border-radius:18px;pointer-events:none}:host([small]:not([small=false])) #input:focus::after{border-radius:14px}}#knob-container{position:relative;box-sizing:border-box;width:40px;height:20px;border-radius:10px;pointer-events:none;padding:2px;background-color:var(--sinch-color-stormy-100);overflow:hidden}:host([small]:not([small=false])) #knob-container{width:32px;height:16px;border-radius:8px}#input:checked~#knob-container{background-color:var(--sinch-color-tropical-500)}#knob{position:relative;box-sizing:border-box;width:16px;height:16px;border-radius:50%;background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-level-1);transform:translateX(0);transition:transform .1s ease-in-out}:host([small]:not([small=false])) #knob{width:12px;height:12px}#input:checked~#knob-container>#knob{transform:translateX(20px)}:host([small]:not([small=false])) #input:checked~#knob-container>#knob{transform:translateX(16px)}#knob::after,#knob::before{font:var(--sinch-font-body);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{flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#label:empty{display:none}#input:disabled~#label{color:var(--sinch-color-stormy-200)}#input:disabled~#knob-container{background-color:var(--sinch-color-snow-700)}#input:checked:disabled~#knob-container{background-color:var(--sinch-color-tropical-100)}</style><div id="wrapper"><input id="input" type="checkbox"><div id="knob-container"><div id="knob"></div></div><label id="label" for="input"></label></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
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 {
@@ -81,14 +81,13 @@ defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new Weak
81
81
  const shadowRoot = this.attachShadow();
82
82
  shadowRoot.appendChild(template.content.cloneNode(true));
83
83
 
84
- _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
84
+ _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
85
85
 
86
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
86
+ _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
87
87
  }
88
88
 
89
89
  connectedCallback() {
90
90
  this.setAttribute('role', 'checkbox');
91
- this.setAttribute('aria-label', 'toggle');
92
91
 
93
92
  _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
94
93
 
package/toggle/types.d.ts CHANGED
@@ -21,6 +21,7 @@ export declare type TSinchToggleReact = TSinchElementReact<TSinchToggleElement>
21
21
  disabled?: boolean;
22
22
  text?: string;
23
23
  'aria-label': string;
24
+ /** @deprecated */
24
25
  onChange?: (e: SyntheticEvent<TSinchToggleElement, CustomEvent<boolean>>) => void;
25
26
  'on-change'?: (e: CustomEvent<boolean>) => void;
26
27
  };
package/utils.d.ts CHANGED
@@ -48,4 +48,5 @@ export declare const throttleAnimationFrame: (cb: (...args: any[]) => void) => {
48
48
  cancel: () => void;
49
49
  };
50
50
  export declare const getFirstSlotElement: (root: HTMLSlotElement) => HTMLElement | null;
51
+ export declare const cloneNode: (el: Element, deep: boolean) => Element;
51
52
  export {};
package/utils.js CHANGED
@@ -261,4 +261,26 @@ export const getFirstSlotElement = root => {
261
261
 
262
262
  slot = el;
263
263
  }
264
+ };
265
+ export const cloneNode = (el, deep) => {
266
+ const root = el.getRootNode();
267
+
268
+ if (root !== document && Reflect.has(root, 'createElement')) {
269
+ const cloned = root.createElement(el.tagName.toLowerCase());
270
+
271
+ for (const attr of el.getAttributeNames()) {
272
+ cloned.setAttribute(attr, el.getAttribute(attr));
273
+ }
274
+
275
+ if (deep) {
276
+ for (let i = 0; i < el.children.length; i++) {
277
+ const clonedChild = cloneNode(el.children[i], deep);
278
+ cloned.appendChild(clonedChild);
279
+ }
280
+ }
281
+
282
+ return cloned;
283
+ }
284
+
285
+ return el.cloneNode(deep);
264
286
  };
@@ -1,11 +0,0 @@
1
- import type { TSinchCardButtonElement, TSinchCardButtonReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-card-button': TSinchCardButtonReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-card-button': TSinchCardButtonElement;
10
- }
11
- }
@@ -1,77 +0,0 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$button;
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, getBooleanAttribute, getAttribute, updateAttribute, NectaryElement } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;outline:0}sinch-button{display:block}</style><sinch-button type="primary" small></sinch-button>';
12
- const template = document.createElement('template');
13
- template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-card-button', (_$button = new WeakMap(), class extends NectaryElement {
15
- constructor() {
16
- super();
17
-
18
- _classPrivateFieldInitSpec(this, _$button, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
- const shadowRoot = this.attachShadow();
24
- shadowRoot.appendChild(template.content.cloneNode(true));
25
-
26
- _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('sinch-button'));
27
- }
28
-
29
- connectedCallback() {
30
- this.setAttribute('role', 'button');
31
- }
32
-
33
- static get observedAttributes() {
34
- return ['text', 'disabled'];
35
- }
36
-
37
- attributeChangedCallback(name, _, newVal) {
38
- switch (name) {
39
- case 'text':
40
- {
41
- updateAttribute(_classPrivateFieldGet(this, _$button), 'text', newVal);
42
- break;
43
- }
44
-
45
- case 'disabled':
46
- {
47
- updateAttribute(_classPrivateFieldGet(this, _$button), 'disabled', newVal);
48
- break;
49
- }
50
- }
51
- }
52
-
53
- set text(value) {
54
- updateAttribute(this, 'text', value);
55
- }
56
-
57
- get text() {
58
- return getAttribute(this, 'text', '');
59
- }
60
-
61
- set disabled(isDisabled) {
62
- updateAttribute(this, 'disabled', isDisabled);
63
- }
64
-
65
- get disabled() {
66
- return getBooleanAttribute(this, 'disabled');
67
- }
68
-
69
- focus() {
70
- _classPrivateFieldGet(this, _$button).focus();
71
- }
72
-
73
- blur() {
74
- _classPrivateFieldGet(this, _$button).blur();
75
- }
76
-
77
- }));