@nectary/components 0.37.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 (83) hide show
  1. package/accordion/types.d.ts +1 -0
  2. package/alert/index.js +1 -1
  3. package/card/index.d.ts +2 -0
  4. package/card/index.js +6 -31
  5. package/date-picker/index.js +42 -2
  6. package/date-picker/types.d.ts +25 -1
  7. package/dialog/index.d.ts +1 -0
  8. package/dialog/index.js +3 -2
  9. package/dropdown/types.d.ts +2 -0
  10. package/file-drop/index.d.ts +13 -0
  11. package/file-drop/index.js +320 -0
  12. package/file-drop/types.d.ts +50 -0
  13. package/file-drop/utils.d.ts +2 -0
  14. package/file-drop/utils.js +37 -0
  15. package/file-picker/index.d.ts +12 -0
  16. package/file-picker/index.js +170 -0
  17. package/file-picker/types.d.ts +32 -0
  18. package/file-picker/utils.d.ts +1 -0
  19. package/file-picker/utils.js +9 -0
  20. package/file-status/index.d.ts +17 -0
  21. package/file-status/index.js +100 -0
  22. package/file-status/types.d.ts +18 -0
  23. package/file-status/utils.d.ts +5 -0
  24. package/file-status/utils.js +6 -0
  25. package/icons-branded/easytouse/index.d.ts +11 -0
  26. package/icons-branded/easytouse/index.js +4 -0
  27. package/inline-alert/index.js +1 -1
  28. package/inline-alert/types.d.ts +2 -2
  29. package/package.json +1 -1
  30. package/pagination/types.d.ts +1 -0
  31. package/progress/index.d.ts +17 -0
  32. package/progress/index.js +87 -0
  33. package/progress/types.d.ts +12 -0
  34. package/radio/types.d.ts +1 -0
  35. package/segment/index.js +1 -1
  36. package/segment-collapse/types.d.ts +1 -0
  37. package/segmented-control/types.d.ts +1 -0
  38. package/segmented-icon-control/types.d.ts +1 -0
  39. package/select/types.d.ts +1 -1
  40. package/spinner/index.js +1 -1
  41. package/tabs/types.d.ts +1 -0
  42. package/tag/index.d.ts +1 -0
  43. package/tag/index.js +10 -3
  44. package/tag/utils.d.ts +3 -0
  45. package/tag/utils.js +6 -1
  46. package/tag-close/index.js +5 -1
  47. package/tag-close/types.d.ts +3 -1
  48. package/text/index.js +9 -1
  49. package/text/types.d.ts +3 -0
  50. package/time-picker/index.js +9 -1
  51. package/time-picker/types.d.ts +5 -1
  52. package/title/index.js +10 -2
  53. package/title/types.d.ts +3 -0
  54. package/toast/index.d.ts +17 -0
  55. package/toast/index.js +153 -0
  56. package/toast/types.d.ts +28 -0
  57. package/toast/types.js +1 -0
  58. package/toast/utils.d.ts +5 -0
  59. package/toast/utils.js +6 -0
  60. package/toast-manager/index.d.ts +17 -0
  61. package/toast-manager/index.js +271 -0
  62. package/toast-manager/types.d.ts +7 -0
  63. package/toast-manager/types.js +1 -0
  64. package/toggle/index.js +3 -4
  65. package/toggle/types.d.ts +1 -0
  66. package/utils.d.ts +2 -0
  67. package/utils.js +40 -1
  68. package/card-button/index.d.ts +0 -11
  69. package/card-button/index.js +0 -77
  70. package/card-button/types.d.ts +0 -12
  71. package/card-link/index.d.ts +0 -12
  72. package/card-link/index.js +0 -115
  73. package/card-link/types.d.ts +0 -14
  74. package/search/index.d.ts +0 -14
  75. package/search/index.js +0 -523
  76. package/search/types.d.ts +0 -25
  77. package/search-option/index.d.ts +0 -11
  78. package/search-option/index.js +0 -55
  79. package/search-option/types.d.ts +0 -9
  80. /package/{card-button → file-drop}/types.js +0 -0
  81. /package/{card-link → file-picker}/types.js +0 -0
  82. /package/{search-option → file-status}/types.js +0 -0
  83. /package/{search → progress}/types.js +0 -0
@@ -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> & {};
@@ -0,0 +1 @@
1
+ export {};
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
@@ -47,4 +47,6 @@ export declare const throttleAnimationFrame: (cb: (...args: any[]) => void) => {
47
47
  fn: (...args: any[]) => void;
48
48
  cancel: () => void;
49
49
  };
50
+ export declare const getFirstSlotElement: (root: HTMLSlotElement) => HTMLElement | null;
51
+ export declare const cloneNode: (el: Element, deep: boolean) => Element;
50
52
  export {};
package/utils.js CHANGED
@@ -244,4 +244,43 @@ const throttle = (delayFn, cancelFn) => cb => {
244
244
  };
245
245
  };
246
246
 
247
- export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
247
+ export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
248
+ export const getFirstSlotElement = root => {
249
+ let slot = root;
250
+
251
+ while (true) {
252
+ const el = slot.assignedElements()[0];
253
+
254
+ if (el == null) {
255
+ return null;
256
+ }
257
+
258
+ if (el.tagName !== 'SLOT') {
259
+ return el;
260
+ }
261
+
262
+ slot = el;
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);
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
- }));
@@ -1,12 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export declare type TSinchCardButtonElement = HTMLElement & {
3
- text: string;
4
- disabled: boolean;
5
- setAttribute(name: 'text', value: string): void;
6
- setAttribute(name: 'disabled', value: ''): void;
7
- };
8
- export declare type TSinchCardButtonReact = TSinchElementReact<TSinchCardButtonElement> & {
9
- text: string;
10
- 'aria-label': string;
11
- disabled?: boolean;
12
- };
@@ -1,12 +0,0 @@
1
- import '../icons/arrow-forward';
2
- import type { TSinchCardLinkElement, TSinchCardLinkReact } from './types';
3
- declare global {
4
- namespace JSX {
5
- interface IntrinsicElements {
6
- 'sinch-card-link': TSinchCardLinkReact;
7
- }
8
- }
9
- interface HTMLElementTagNameMap {
10
- 'sinch-card-link': TSinchCardLinkElement;
11
- }
12
- }
@@ -1,115 +0,0 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$anchor, _$text, _onClick;
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/arrow-forward';
11
- import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement } from '../utils';
12
- const templateHTML = '<style>:host{display:inline;outline:0}a{display:flex;flex-direction:row;gap:8px;font:var(--sinch-font-emphasized-body);color:var(--sinch-color-tropical-500);text-decoration:none;outline:0;--sinch-color-icon:var(--sinch-color-tropical-500);--sinch-size-icon:24px}a:hover{color:var(--sinch-color-tropical-600);fill:var(--sinch-color-tropical-600)}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-300);pointer-events:none;cursor:initial;--sinch-color-icon:var(--sinch-color-tropical-300)}span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex-shrink:1}</style><a><span></span><sinch-icon-arrow-forward></sinch-icon-arrow-forward></a>';
13
- const template = document.createElement('template');
14
- template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-card-link', (_$anchor = new WeakMap(), _$text = new WeakMap(), _onClick = new WeakMap(), class extends NectaryElement {
16
- constructor() {
17
- super();
18
-
19
- _classPrivateFieldInitSpec(this, _$anchor, {
20
- writable: true,
21
- value: void 0
22
- });
23
-
24
- _classPrivateFieldInitSpec(this, _$text, {
25
- writable: true,
26
- value: void 0
27
- });
28
-
29
- _classPrivateFieldInitSpec(this, _onClick, {
30
- writable: true,
31
- value: e => {
32
- if (this.disabled) {
33
- e.preventDefault();
34
- e.stopPropagation();
35
- }
36
- }
37
- });
38
-
39
- const shadowRoot = this.attachShadow();
40
- shadowRoot.appendChild(template.content.cloneNode(true));
41
-
42
- _classPrivateFieldSet(this, _$anchor, shadowRoot.querySelector('a'));
43
-
44
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('span'));
45
- }
46
-
47
- connectedCallback() {
48
- _classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onClick));
49
- }
50
-
51
- disconnectedCallback() {
52
- _classPrivateFieldGet(this, _$anchor).removeEventListener('click', _classPrivateFieldGet(this, _onClick));
53
- }
54
-
55
- get text() {
56
- return getAttribute(this, 'text', '');
57
- }
58
-
59
- set text(value) {
60
- updateAttribute(this, 'text', value);
61
- }
62
-
63
- get href() {
64
- return getAttribute(this, 'href', '');
65
- }
66
-
67
- set href(value) {
68
- updateAttribute(this, 'href', value);
69
- }
70
-
71
- set disabled(isDisabled) {
72
- updateBooleanAttribute(this, 'disabled', isDisabled);
73
- }
74
-
75
- get disabled() {
76
- return getBooleanAttribute(this, 'disabled');
77
- }
78
-
79
- set external(isExternal) {
80
- updateBooleanAttribute(this, 'external', isExternal);
81
- }
82
-
83
- get external() {
84
- return getBooleanAttribute(this, 'external');
85
- }
86
-
87
- static get observedAttributes() {
88
- return ['text', 'href'];
89
- }
90
-
91
- attributeChangedCallback(name, _, newVal) {
92
- switch (name) {
93
- case 'text':
94
- {
95
- _classPrivateFieldGet(this, _$text).textContent = newVal;
96
- break;
97
- }
98
-
99
- case 'href':
100
- {
101
- updateAttribute(_classPrivateFieldGet(this, _$anchor), 'href', newVal);
102
- break;
103
- }
104
- }
105
- }
106
-
107
- focus() {
108
- _classPrivateFieldGet(this, _$anchor).focus();
109
- }
110
-
111
- blur() {
112
- _classPrivateFieldGet(this, _$anchor).blur();
113
- }
114
-
115
- }));
@@ -1,14 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export declare type TSinchCardLinkElement = HTMLElement & {
3
- text: string;
4
- href: string;
5
- disabled: boolean;
6
- setAttribute(name: 'text', value: string): void;
7
- setAttribute(name: 'href', value: string): void;
8
- setAttribute(name: 'disabled', value: ''): void;
9
- };
10
- export declare type TSinchCardLinkReact = TSinchElementReact<TSinchCardLinkElement> & {
11
- text: string;
12
- href: string;
13
- disabled?: boolean;
14
- };
package/search/index.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import '../icons/search';
2
- import '../icons/close';
3
- import '../icon-button';
4
- import type { TSinchSearchElement, TSinchSearchReact } from './types';
5
- declare global {
6
- namespace JSX {
7
- interface IntrinsicElements {
8
- 'sinch-search': TSinchSearchReact;
9
- }
10
- }
11
- interface HTMLElementTagNameMap {
12
- 'sinch-search': TSinchSearchElement;
13
- }
14
- }