@nectary/components 0.39.0 → 0.41.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 (142) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +30 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +177 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +52 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +46 -92
  16. package/button/types.d.ts +1 -1
  17. package/card/index.js +21 -59
  18. package/chat-avatar/index.js +8 -22
  19. package/chat-block/index.js +29 -69
  20. package/chat-bubble/index.js +6 -20
  21. package/checkbox/index.js +59 -107
  22. package/chip/index.d.ts +13 -0
  23. package/chip/index.js +140 -0
  24. package/chip/types.d.ts +37 -0
  25. package/color-menu/index.d.ts +14 -0
  26. package/color-menu/index.js +450 -0
  27. package/color-menu/types.d.ts +36 -0
  28. package/color-menu/utils.d.ts +1 -0
  29. package/color-menu/utils.js +15 -0
  30. package/color-swatch/index.d.ts +13 -0
  31. package/color-swatch/index.js +60 -0
  32. package/color-swatch/types.d.ts +11 -0
  33. package/colors.json +61 -49
  34. package/date-picker/index.js +162 -293
  35. package/dialog/index.js +70 -142
  36. package/field/index.js +44 -65
  37. package/file-drop/index.js +123 -200
  38. package/file-picker/index.d.ts +0 -1
  39. package/file-picker/index.js +55 -108
  40. package/file-status/index.js +15 -39
  41. package/help-tooltip/index.js +11 -28
  42. package/horizontal-stepper/index.js +33 -59
  43. package/horizontal-stepper-item/index.js +13 -37
  44. package/icon-button/index.d.ts +1 -0
  45. package/icon-button/index.js +51 -85
  46. package/icon-button/types.d.ts +16 -2
  47. package/icons-channel/notify/index.d.ts +11 -0
  48. package/icons-channel/notify/index.js +4 -0
  49. package/illustrations/create-illustration-class.js +1 -1
  50. package/inline-alert/index.js +29 -81
  51. package/input/index.js +117 -222
  52. package/link/index.js +51 -97
  53. package/list-item/index.js +1 -1
  54. package/package.json +12 -14
  55. package/pagination/index.js +113 -163
  56. package/pop/index.d.ts +11 -0
  57. package/pop/index.js +391 -0
  58. package/pop/types.d.ts +35 -0
  59. package/pop/utils.d.ts +7 -0
  60. package/pop/utils.js +18 -0
  61. package/popover/index.d.ts +1 -0
  62. package/popover/index.js +105 -314
  63. package/popover/types.d.ts +8 -1
  64. package/popover/utils.d.ts +5 -0
  65. package/popover/utils.js +17 -1
  66. package/progress/index.js +9 -28
  67. package/radio/index.js +103 -169
  68. package/radio-option/index.js +28 -48
  69. package/segment/index.js +49 -130
  70. package/segment-collapse/index.js +28 -49
  71. package/segmented-control/index.js +36 -73
  72. package/segmented-control-option/index.js +45 -87
  73. package/segmented-icon-control/index.js +47 -84
  74. package/segmented-icon-control-option/index.js +42 -79
  75. package/select-button/index.d.ts +13 -0
  76. package/select-button/index.js +158 -0
  77. package/select-button/types.d.ts +43 -0
  78. package/select-menu/index.d.ts +11 -0
  79. package/select-menu/index.js +345 -0
  80. package/select-menu/types.d.ts +29 -0
  81. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  82. package/select-menu-option/index.js +76 -0
  83. package/{select-option → select-menu-option}/types.d.ts +8 -9
  84. package/stop-events/index.js +7 -20
  85. package/table-head-cell/index.js +7 -21
  86. package/tabs/index.js +103 -165
  87. package/tabs-option/index.js +24 -44
  88. package/tag/index.d.ts +0 -1
  89. package/tag/index.js +35 -38
  90. package/tag/types.d.ts +12 -7
  91. package/textarea/index.js +96 -167
  92. package/theme.css +146 -49
  93. package/tile-control/index.js +55 -96
  94. package/tile-control-option/index.js +45 -87
  95. package/time-picker/index.js +216 -368
  96. package/title/index.js +6 -20
  97. package/toast/index.js +32 -70
  98. package/toast-manager/index.js +141 -217
  99. package/toggle/index.js +59 -107
  100. package/tooltip/index.d.ts +2 -0
  101. package/tooltip/index.js +160 -17
  102. package/tooltip/types.d.ts +13 -0
  103. package/tooltip/utils.d.ts +5 -0
  104. package/tooltip/utils.js +25 -1
  105. package/utils/animation.d.ts +17 -0
  106. package/utils/animation.js +142 -0
  107. package/utils/colors.d.ts +5 -0
  108. package/utils/colors.js +5 -0
  109. package/utils/context.d.ts +15 -0
  110. package/utils/context.js +57 -0
  111. package/{utils.d.ts → utils/index.d.ts} +15 -11
  112. package/{utils.js → utils/index.js} +104 -48
  113. package/vertical-stepper/index.js +29 -50
  114. package/vertical-stepper-item/index.js +13 -37
  115. package/dropdown/index.d.ts +0 -12
  116. package/dropdown/index.js +0 -415
  117. package/dropdown/types.d.ts +0 -32
  118. package/dropdown-checkbox-option/index.d.ts +0 -11
  119. package/dropdown-checkbox-option/index.js +0 -88
  120. package/dropdown-checkbox-option/types.d.ts +0 -15
  121. package/dropdown-radio-option/index.d.ts +0 -11
  122. package/dropdown-radio-option/index.js +0 -88
  123. package/dropdown-radio-option/types.d.ts +0 -15
  124. package/dropdown-text-option/index.js +0 -104
  125. package/dropdown-text-option/types.d.ts +0 -16
  126. package/select/index.d.ts +0 -13
  127. package/select/index.js +0 -316
  128. package/select/types.d.ts +0 -53
  129. package/select-option/index.d.ts +0 -11
  130. package/select-option/index.js +0 -8
  131. package/tag/utils.d.ts +0 -5
  132. package/tag/utils.js +0 -6
  133. package/tag-close/index.d.ts +0 -12
  134. package/tag-close/index.js +0 -42
  135. package/tag-close/types.d.ts +0 -5
  136. /package/{dropdown-checkbox-option → chip}/types.js +0 -0
  137. /package/{dropdown-radio-option → color-menu}/types.js +0 -0
  138. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  139. /package/{dropdown → pop}/types.js +0 -0
  140. /package/{select-option → select-button}/types.js +0 -0
  141. /package/{tag-close → select-menu}/types.js +0 -0
  142. /package/{select → select-menu-option}/types.js +0 -0
package/title/index.js CHANGED
@@ -1,31 +1,17 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../icons/cancel';
11
2
  import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute } from '../utils';
12
3
  const templateHTML = '<style>:host{display:block}:host([type=xl]) #text{font:var(--sinch-font-title-xl)}:host([type="l"]) #text{font:var(--sinch-font-title-l)}:host([type="m"]) #text{font:var(--sinch-font-title-m)}:host([type="s"]) #text{font:var(--sinch-font-title-s)}:host([type=xs]) #text{font:var(--sinch-font-title-xs)}:host([ellipsis]:not([ellipsis=false])) #text{display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
13
4
  import { assertLevel, assertType, typeValues } from './utils';
14
5
  const template = document.createElement('template');
15
6
  template.innerHTML = templateHTML;
16
- defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends NectaryElement {
7
+ defineCustomElement('sinch-title', class extends NectaryElement {
8
+ #$text;
9
+
17
10
  constructor() {
18
11
  super();
19
-
20
- _classPrivateFieldInitSpec(this, _$text, {
21
- writable: true,
22
- value: void 0
23
- });
24
-
25
12
  const shadowRoot = this.attachShadow();
26
13
  shadowRoot.appendChild(template.content.cloneNode(true));
27
-
28
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
14
+ this.#$text = shadowRoot.querySelector('#text');
29
15
  }
30
16
 
31
17
  connectedCallback() {
@@ -64,7 +50,7 @@ defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends Nectar
64
50
  switch (name) {
65
51
  case 'text':
66
52
  {
67
- _classPrivateFieldGet(this, _$text).textContent = newVal;
53
+ this.#$text.textContent = newVal;
68
54
  break;
69
55
  }
70
56
 
@@ -83,4 +69,4 @@ defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends Nectar
83
69
  }
84
70
  }
85
71
 
86
- }));
72
+ });
package/toast/index.js CHANGED
@@ -1,16 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$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
1
  import '../icons/report-problem';
15
2
  import '../icons/report';
16
3
  import '../icons/check-circle';
@@ -23,56 +10,27 @@ import { assertType, typeValues } from './utils';
23
10
  const TIMEOUT = 5000;
24
11
  const template = document.createElement('template');
25
12
  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 {
13
+ defineCustomElement('sinch-toast', class extends NectaryElement {
14
+ #$text;
15
+ #tid = null;
16
+
27
17
  constructor() {
28
18
  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
19
  const shadowRoot = this.attachShadow();
59
20
  shadowRoot.appendChild(template.content.cloneNode(true));
60
-
61
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
21
+ this.#$text = shadowRoot.querySelector('#text');
62
22
  }
63
23
 
64
24
  connectedCallback() {
65
25
  this.setAttribute('aria-atomic', 'true');
66
26
  this.setAttribute('aria-live', 'polite');
67
- this.addEventListener('-timeout', _classPrivateFieldGet(this, _onTimeoutReactHandler));
68
-
69
- _classPrivateMethodGet(this, _updateTimeout, _updateTimeout2).call(this);
27
+ this.addEventListener('-timeout', this.#onTimeoutReactHandler);
28
+ this.#updateTimeout();
70
29
  }
71
30
 
72
31
  disconnectedCallback() {
73
- this.removeEventListener('-timeout', _classPrivateFieldGet(this, _onTimeoutReactHandler));
74
-
75
- _classPrivateMethodGet(this, _clearTimeout, _clearTimeout2).call(this);
32
+ this.removeEventListener('-timeout', this.#onTimeoutReactHandler);
33
+ this.#clearTimeout();
76
34
  }
77
35
 
78
36
  get type() {
@@ -117,37 +75,41 @@ defineCustomElement('sinch-toast', (_$text = new WeakMap(), _tid = new WeakMap()
117
75
 
118
76
  case 'text':
119
77
  {
120
- _classPrivateFieldGet(this, _$text).textContent = newVal;
78
+ this.#$text.textContent = newVal;
121
79
  break;
122
80
  }
123
81
 
124
82
  case 'persistent':
125
83
  {
126
- _classPrivateMethodGet(this, _updateTimeout, _updateTimeout2).call(this);
127
-
84
+ this.#updateTimeout();
128
85
  break;
129
86
  }
130
87
  }
131
88
  }
132
89
 
133
- }));
134
-
135
- function _updateTimeout2() {
136
- if (this.persistent) {
137
- _classPrivateMethodGet(this, _clearTimeout, _clearTimeout2).call(this);
138
-
139
- return;
140
- }
90
+ #updateTimeout() {
91
+ if (this.persistent) {
92
+ this.#clearTimeout();
93
+ return;
94
+ }
141
95
 
142
- if (_classPrivateFieldGet(this, _tid) === null) {
143
- _classPrivateFieldSet(this, _tid, window.setTimeout(_classPrivateFieldGet(this, _onTimeout), TIMEOUT));
96
+ if (this.#tid === null) {
97
+ this.#tid = window.setTimeout(this.#onTimeout, TIMEOUT);
98
+ }
144
99
  }
145
- }
146
100
 
147
- function _clearTimeout2() {
148
- if (_classPrivateFieldGet(this, _tid) !== null) {
149
- window.clearTimeout(_classPrivateFieldGet(this, _tid));
101
+ #onTimeout = () => {
102
+ this.dispatchEvent(new CustomEvent('-timeout'));
103
+ };
150
104
 
151
- _classPrivateFieldSet(this, _tid, null);
105
+ #clearTimeout() {
106
+ if (this.#tid !== null) {
107
+ window.clearTimeout(this.#tid);
108
+ this.#tid = null;
109
+ }
152
110
  }
153
- }
111
+
112
+ #onTimeoutReactHandler = e => {
113
+ getReactEventHandler(this, 'on-timeout')?.(e);
114
+ };
115
+ });
@@ -1,16 +1,3 @@
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
1
  import '../icons/report-problem';
15
2
  import '../icons/report';
16
3
  import '../icons/check-circle';
@@ -24,248 +11,185 @@ const DURATION_REMOVE = 250;
24
11
  const ITEMS_GAP = 16;
25
12
  const template = document.createElement('template');
26
13
  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 {
14
+ defineCustomElement('sinch-toast-manager', class extends NectaryElement {
15
+ #$slot;
16
+ #$list;
17
+ #map = new WeakMap();
18
+ #shouldReduceMotion = false;
19
+ #animations = new Set();
20
+
28
21
  constructor() {
29
22
  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
23
  const shadowRoot = this.attachShadow();
153
24
  shadowRoot.appendChild(template.content.cloneNode(true));
154
-
155
- _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
156
-
157
- _classPrivateFieldSet(this, _$list, shadowRoot.querySelector('#list'));
25
+ this.#$slot = shadowRoot.querySelector('slot');
26
+ this.#$list = shadowRoot.querySelector('#list');
158
27
  }
159
28
 
160
29
  connectedCallback() {
161
- _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
162
-
163
- _classPrivateFieldSet(this, _shouldReduceMotion, window.matchMedia('(prefers-reduced-motion: reduce)').matches);
30
+ this.#$slot.addEventListener('slotchange', this.#onSlotChange);
31
+ this.#shouldReduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
164
32
  }
165
33
 
166
34
  disconnectedCallback() {
167
- _classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
168
-
169
- _classPrivateMethodGet(this, _clear, _clear2).call(this);
35
+ this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
36
+ this.#clear();
170
37
  }
171
38
 
172
39
  get containerRect() {
173
- return getRect(_classPrivateFieldGet(this, _$list));
40
+ return getRect(this.#$list);
174
41
  }
175
42
 
176
43
  nthActionRect(nth) {
177
- const item = _classPrivateFieldGet(this, _$list).children[nth]?.querySelector('[slot=action]');
44
+ const item = this.#$list.children[nth]?.querySelector('[slot=action]');
178
45
  return item != null ? getRect(item) : null;
179
46
  }
180
47
 
181
48
  nthCloseRect(nth) {
182
- const item = _classPrivateFieldGet(this, _$list).children[nth]?.querySelector('[slot=close]');
49
+ const item = this.#$list.children[nth]?.querySelector('[slot=close]');
183
50
  return item != null ? getRect(item) : null;
184
51
  }
185
52
 
186
- }));
53
+ #onAnimateAdd(item, index, height) {
54
+ const duration = this.#shouldReduceMotion ? 0 : DURATION_ADD;
55
+ const addAnim = item.animate({
56
+ height: ['0', `${height + ITEMS_GAP}px`],
57
+ opacity: [0, 1]
58
+ }, {
59
+ delay: index * duration,
60
+ duration,
61
+ iterations: 1,
62
+ fill: 'forwards'
63
+ });
64
+ this.#storeAnimation(addAnim);
65
+ }
187
66
 
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
- });
67
+ #onAnimateRemove(item, index) {
68
+ const rect = item.getBoundingClientRect();
69
+ const duration = this.#shouldReduceMotion ? 0 : DURATION_REMOVE;
70
+ const indexInQueue = item.hasAttribute('data-delete-now') ? 0 : index;
71
+ const heightAnim = item.animate({
72
+ height: [`${rect.height}px`, '0']
73
+ }, {
74
+ delay: duration + indexInQueue * duration,
75
+ duration,
76
+ iterations: 1,
77
+ fill: 'forwards'
78
+ });
79
+ const opacityAnim = item.animate({
80
+ opacity: [1, 0]
81
+ }, {
82
+ delay: indexInQueue * duration,
83
+ duration,
84
+ iterations: 1,
85
+ fill: 'forwards'
86
+ });
87
+ item.setAttribute('data-deleting', '');
88
+ this.#storeAnimation(heightAnim, () => item.remove());
89
+ this.#storeAnimation(opacityAnim);
90
+ }
199
91
 
200
- _classPrivateMethodGet(this, _storeAnimation, _storeAnimation2).call(this, addAnim);
201
- }
92
+ #onSlotChange = () => {
93
+ const slotItems = this.#$slot.assignedElements();
94
+ const listItems = Array.from(this.#$list.children);
95
+ let removeIndex = 0;
202
96
 
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', '');
97
+ for (const item of listItems) {
98
+ if (item.hasAttribute('data-deleting')) {
99
+ ++removeIndex;
100
+ continue;
101
+ }
224
102
 
225
- _classPrivateMethodGet(this, _storeAnimation, _storeAnimation2).call(this, heightAnim, () => item.remove());
103
+ const orig = this.#map.get(item);
226
104
 
227
- _classPrivateMethodGet(this, _storeAnimation, _storeAnimation2).call(this, opacityAnim);
228
- }
105
+ if (orig != null && slotItems.includes(orig)) {
106
+ continue;
107
+ }
229
108
 
230
- function _storeAnimation2(anim, cb) {
231
- const onAnimEnd = () => {
232
- _classPrivateFieldGet(this, _animations).delete(anim);
109
+ this.#map.delete(item);
233
110
 
234
- cb?.();
235
- anim.removeEventListener('finish', onAnimEnd);
236
- anim.removeEventListener('remove', onAnimEnd);
237
- anim.removeEventListener('cancel', onAnimEnd);
238
- };
111
+ if (orig != null) {
112
+ this.#map.delete(orig);
113
+ }
239
114
 
240
- anim.addEventListener('finish', onAnimEnd);
241
- anim.addEventListener('remove', onAnimEnd);
242
- anim.addEventListener('cancel', onAnimEnd);
115
+ this.#unsubscribeChildren(item);
116
+ this.#onAnimateRemove(item, removeIndex);
117
+ ++removeIndex;
118
+ }
243
119
 
244
- _classPrivateFieldGet(this, _animations).add(anim);
245
- }
120
+ let addIndex = 0;
246
121
 
247
- function _clear2() {
248
- const listItems = Array.from(_classPrivateFieldGet(this, _$list).children);
122
+ for (const item of slotItems) {
123
+ if (this.#map.has(item)) {
124
+ continue;
125
+ }
249
126
 
250
- for (const item of listItems) {
251
- _classPrivateFieldGet(this, _map).delete(item);
127
+ const cloned = cloneNode(item, true);
128
+ const rect = item.getBoundingClientRect();
129
+ const wrapper = document.createElement('div');
130
+ wrapper.className = 'item-wrapper';
131
+ wrapper.appendChild(cloned);
132
+ this.#$list.appendChild(wrapper);
133
+ this.#map.set(item, wrapper);
134
+ this.#map.set(wrapper, item);
135
+ this.#subscribeChildren(cloned);
136
+ this.#onAnimateAdd(wrapper, addIndex, rect.height);
137
+ addIndex++;
138
+ }
139
+ };
140
+
141
+ #storeAnimation(anim, cb) {
142
+ const onAnimEnd = () => {
143
+ this.#animations.delete(anim);
144
+ cb?.();
145
+ anim.removeEventListener('finish', onAnimEnd);
146
+ anim.removeEventListener('remove', onAnimEnd);
147
+ anim.removeEventListener('cancel', onAnimEnd);
148
+ };
149
+
150
+ anim.addEventListener('finish', onAnimEnd);
151
+ anim.addEventListener('remove', onAnimEnd);
152
+ anim.addEventListener('cancel', onAnimEnd);
153
+ this.#animations.add(anim);
154
+ }
252
155
 
253
- _classPrivateMethodGet(this, _unsubscribeChildren, _unsubscribeChildren2).call(this, item);
156
+ #clear() {
157
+ const listItems = Array.from(this.#$list.children);
254
158
 
255
- item.remove();
159
+ for (const item of listItems) {
160
+ this.#map.delete(item);
161
+ this.#unsubscribeChildren(item);
162
+ item.remove();
163
+ }
164
+
165
+ for (const anim of this.#animations) {
166
+ anim.cancel();
167
+ }
256
168
  }
257
169
 
258
- for (const anim of _classPrivateFieldGet(this, _animations)) {
259
- anim.cancel();
170
+ #subscribeChildren(item) {
171
+ item.querySelector('[slot=close]')?.addEventListener('-click', this.#onCloneCloseClick);
172
+ item.querySelector('[slot=action]')?.addEventListener('-click', this.#onCloneActionClick);
260
173
  }
261
- }
262
174
 
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
- }
175
+ #unsubscribeChildren(item) {
176
+ item.querySelector('[slot=close]')?.removeEventListener('-click', this.#onCloneCloseClick);
177
+ item.querySelector('[slot=action]')?.removeEventListener('-click', this.#onCloneActionClick);
178
+ }
267
179
 
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
- }
180
+ #onCloneCloseClick = e => {
181
+ const item = e.target.parentElement?.parentElement;
182
+
183
+ if (item != null) {
184
+ item.setAttribute('data-delete-now', '');
185
+ this.#map.get(item)?.querySelector('[slot=close]')?.dispatchEvent(new CustomEvent('-click'));
186
+ }
187
+ };
188
+ #onCloneActionClick = e => {
189
+ const item = e.target.parentElement?.parentElement;
190
+
191
+ if (item != null) {
192
+ this.#map.get(item)?.querySelector('[slot=action]')?.dispatchEvent(new CustomEvent('-click'));
193
+ }
194
+ };
195
+ });