@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.
- package/accordion/index.js +47 -84
- package/accordion-item/index.js +30 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +177 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +52 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +46 -92
- package/button/types.d.ts +1 -1
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +59 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +140 -0
- package/chip/types.d.ts +37 -0
- package/color-menu/index.d.ts +14 -0
- package/color-menu/index.js +450 -0
- package/color-menu/types.d.ts +36 -0
- package/color-menu/utils.d.ts +1 -0
- package/color-menu/utils.js +15 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +60 -0
- package/color-swatch/types.d.ts +11 -0
- package/colors.json +61 -49
- package/date-picker/index.js +162 -293
- package/dialog/index.js +70 -142
- package/field/index.js +44 -65
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +11 -28
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.d.ts +1 -0
- package/icon-button/index.js +51 -85
- package/icon-button/types.d.ts +16 -2
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +117 -222
- package/link/index.js +51 -97
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +113 -163
- package/pop/index.d.ts +11 -0
- package/pop/index.js +391 -0
- package/pop/types.d.ts +35 -0
- package/pop/utils.d.ts +7 -0
- package/pop/utils.js +18 -0
- package/popover/index.d.ts +1 -0
- package/popover/index.js +105 -314
- package/popover/types.d.ts +8 -1
- package/popover/utils.d.ts +5 -0
- package/popover/utils.js +17 -1
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +28 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +28 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +45 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +42 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +158 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +345 -0
- package/select-menu/types.d.ts +29 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +24 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +35 -38
- package/tag/types.d.ts +12 -7
- package/textarea/index.js +96 -167
- package/theme.css +146 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +45 -87
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +59 -107
- package/tooltip/index.d.ts +2 -0
- package/tooltip/index.js +160 -17
- package/tooltip/types.d.ts +13 -0
- package/tooltip/utils.d.ts +5 -0
- package/tooltip/utils.js +25 -1
- package/utils/animation.d.ts +17 -0
- package/utils/animation.js +142 -0
- package/utils/colors.d.ts +5 -0
- package/utils/colors.js +5 -0
- package/utils/context.d.ts +15 -0
- package/utils/context.js +57 -0
- package/{utils.d.ts → utils/index.d.ts} +15 -11
- package/{utils.js → utils/index.js} +104 -48
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-checkbox-option/index.d.ts +0 -11
- package/dropdown-checkbox-option/index.js +0 -88
- package/dropdown-checkbox-option/types.d.ts +0 -15
- package/dropdown-radio-option/index.d.ts +0 -11
- package/dropdown-radio-option/index.js +0 -88
- package/dropdown-radio-option/types.d.ts +0 -15
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-checkbox-option → chip}/types.js +0 -0
- /package/{dropdown-radio-option → color-menu}/types.js +0 -0
- /package/{dropdown-text-option → color-swatch}/types.js +0 -0
- /package/{dropdown → pop}/types.js +0 -0
- /package/{select-option → select-button}/types.js +0 -0
- /package/{tag-close → select-menu}/types.js +0 -0
- /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',
|
|
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
|
-
|
|
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',
|
|
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',
|
|
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',
|
|
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
|
-
|
|
78
|
+
this.#$text.textContent = newVal;
|
|
121
79
|
break;
|
|
122
80
|
}
|
|
123
81
|
|
|
124
82
|
case 'persistent':
|
|
125
83
|
{
|
|
126
|
-
|
|
127
|
-
|
|
84
|
+
this.#updateTimeout();
|
|
128
85
|
break;
|
|
129
86
|
}
|
|
130
87
|
}
|
|
131
88
|
}
|
|
132
89
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
90
|
+
#updateTimeout() {
|
|
91
|
+
if (this.persistent) {
|
|
92
|
+
this.#clearTimeout();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
141
95
|
|
|
142
|
-
|
|
143
|
-
|
|
96
|
+
if (this.#tid === null) {
|
|
97
|
+
this.#tid = window.setTimeout(this.#onTimeout, TIMEOUT);
|
|
98
|
+
}
|
|
144
99
|
}
|
|
145
|
-
}
|
|
146
100
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
101
|
+
#onTimeout = () => {
|
|
102
|
+
this.dispatchEvent(new CustomEvent('-timeout'));
|
|
103
|
+
};
|
|
150
104
|
|
|
151
|
-
|
|
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
|
+
});
|
package/toast-manager/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 _$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',
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
40
|
+
return getRect(this.#$list);
|
|
174
41
|
}
|
|
175
42
|
|
|
176
43
|
nthActionRect(nth) {
|
|
177
|
-
const item =
|
|
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 =
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
201
|
-
|
|
92
|
+
#onSlotChange = () => {
|
|
93
|
+
const slotItems = this.#$slot.assignedElements();
|
|
94
|
+
const listItems = Array.from(this.#$list.children);
|
|
95
|
+
let removeIndex = 0;
|
|
202
96
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
103
|
+
const orig = this.#map.get(item);
|
|
226
104
|
|
|
227
|
-
|
|
228
|
-
|
|
105
|
+
if (orig != null && slotItems.includes(orig)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
229
108
|
|
|
230
|
-
|
|
231
|
-
const onAnimEnd = () => {
|
|
232
|
-
_classPrivateFieldGet(this, _animations).delete(anim);
|
|
109
|
+
this.#map.delete(item);
|
|
233
110
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
anim.removeEventListener('cancel', onAnimEnd);
|
|
238
|
-
};
|
|
111
|
+
if (orig != null) {
|
|
112
|
+
this.#map.delete(orig);
|
|
113
|
+
}
|
|
239
114
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
115
|
+
this.#unsubscribeChildren(item);
|
|
116
|
+
this.#onAnimateRemove(item, removeIndex);
|
|
117
|
+
++removeIndex;
|
|
118
|
+
}
|
|
243
119
|
|
|
244
|
-
|
|
245
|
-
}
|
|
120
|
+
let addIndex = 0;
|
|
246
121
|
|
|
247
|
-
|
|
248
|
-
|
|
122
|
+
for (const item of slotItems) {
|
|
123
|
+
if (this.#map.has(item)) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
249
126
|
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
156
|
+
#clear() {
|
|
157
|
+
const listItems = Array.from(this.#$list.children);
|
|
254
158
|
|
|
255
|
-
item
|
|
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
|
-
|
|
259
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
+
});
|