tyrell-components 1.0.0-RC16 → 1.0.0-RC17
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/css/tyrell-colors-static.css +14 -0
- package/css/tyrell-theme.css +6 -5
- package/css/tyrell.css +9 -7
- package/dist/tyrell-colors-static.css +1 -1
- package/dist/tyrell-theme.css +1 -1
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +23 -15
- package/lib/base/ty-component.js +63 -26
- package/lib/components/button.d.ts +14 -0
- package/lib/components/button.js +55 -7
- package/lib/components/calendar-month.d.ts +7 -1
- package/lib/components/calendar-month.js +35 -28
- package/lib/components/calendar-navigation.js +19 -6
- package/lib/components/calendar.d.ts +26 -3
- package/lib/components/calendar.js +104 -64
- package/lib/components/checkbox.d.ts +8 -1
- package/lib/components/checkbox.js +27 -6
- package/lib/components/copy.d.ts +2 -0
- package/lib/components/copy.js +15 -31
- package/lib/components/date-picker.d.ts +53 -18
- package/lib/components/date-picker.js +217 -146
- package/lib/components/file-upload.d.ts +4 -1
- package/lib/components/file-upload.js +23 -5
- package/lib/components/input.d.ts +73 -3
- package/lib/components/input.js +157 -22
- package/lib/components/modal.d.ts +2 -0
- package/lib/components/modal.js +97 -17
- package/lib/components/option.js +7 -5
- package/lib/components/popup.js +115 -15
- package/lib/components/radio.d.ts +10 -1
- package/lib/components/radio.js +22 -29
- package/lib/components/resize-observer.js +2 -0
- package/lib/components/scroll-container.js +2 -0
- package/lib/components/select.d.ts +54 -5
- package/lib/components/select.js +136 -26
- package/lib/components/selected-tags.d.ts +7 -1
- package/lib/components/selected-tags.js +10 -1
- package/lib/components/switch.d.ts +9 -1
- package/lib/components/switch.js +27 -6
- package/lib/components/tabs.js +1 -1
- package/lib/components/textarea.d.ts +47 -2
- package/lib/components/textarea.js +81 -17
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/styles/button.js +21 -19
- package/lib/styles/calendar-month.js +1 -1
- package/lib/styles/calendar.js +3 -0
- package/lib/styles/checkbox.js +11 -5
- package/lib/styles/date-picker.js +16 -4
- package/lib/styles/file-upload.d.ts +1 -1
- package/lib/styles/file-upload.js +3 -3
- package/lib/styles/icon.d.ts +1 -1
- package/lib/styles/icon.js +2 -2
- package/lib/styles/input.js +6 -10
- package/lib/styles/option.d.ts +1 -1
- package/lib/styles/option.js +4 -0
- package/lib/styles/popup.d.ts +1 -1
- package/lib/styles/popup.js +2 -0
- package/lib/styles/radio.js +12 -6
- package/lib/styles/select-base.js +24 -3
- package/lib/styles/select.d.ts +1 -1
- package/lib/styles/select.js +4 -0
- package/lib/styles/switch.js +10 -5
- package/lib/styles/tag.js +2 -1
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.js +7 -0
- package/lib/utils/calendar-utils.d.ts +49 -0
- package/lib/utils/calendar-utils.js +63 -6
- package/lib/utils/property-manager.d.ts +6 -0
- package/lib/utils/property-manager.js +15 -5
- package/lib/utils/scroll-lock.d.ts +10 -4
- package/lib/utils/scroll-lock.js +102 -2
- package/lib/utils/upgrade-properties.d.ts +21 -0
- package/lib/utils/upgrade-properties.js +47 -0
- package/lib/utils/validity.d.ts +98 -2
- package/lib/utils/validity.js +244 -8
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -2
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/dropdown.d.ts +0 -403
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -1315
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/multiselect.d.ts +0 -389
- package/lib/components/multiselect.d.ts.map +0 -1
- package/lib/components/multiselect.js +0 -1301
- package/lib/components/multiselect.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/dropdown.d.ts +0 -12
- package/lib/styles/dropdown.d.ts.map +0 -1
- package/lib/styles/dropdown.js +0 -725
- package/lib/styles/dropdown.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -6
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -568
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -23
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
package/lib/components/modal.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { lockScroll, unlockScroll } from '../utils/scroll-lock.js';
|
|
2
|
+
import { coerceBoolean } from '../utils/property-manager.js';
|
|
2
3
|
import { ensureStyles } from '../utils/styles.js';
|
|
4
|
+
import { upgradeProperties } from '../utils/upgrade-properties.js';
|
|
3
5
|
import { modalStyles } from '../styles/modal.js';
|
|
4
6
|
const backdropClickHandlers = new WeakMap();
|
|
5
7
|
const escapeKeyHandlers = new WeakMap();
|
|
@@ -8,6 +10,13 @@ const hoverEnterHandlers = new WeakMap();
|
|
|
8
10
|
const hoverLeaveHandlers = new WeakMap();
|
|
9
11
|
const modalIds = new WeakMap();
|
|
10
12
|
const pendingCloseReasons = new WeakMap();
|
|
13
|
+
const detachedOpen = new WeakSet();
|
|
14
|
+
const openStack = [];
|
|
15
|
+
function dropFromStack(el) {
|
|
16
|
+
const i = openStack.indexOf(el);
|
|
17
|
+
if (i >= 0)
|
|
18
|
+
openStack.splice(i, 1);
|
|
19
|
+
}
|
|
11
20
|
const CLOSE_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;
|
|
12
21
|
function parseBoolAttr(el, name) {
|
|
13
22
|
if (!el.hasAttribute(name)) {
|
|
@@ -97,13 +106,72 @@ event.preventDefault();
|
|
|
97
106
|
closeModal(el, 'backdrop');
|
|
98
107
|
}
|
|
99
108
|
}
|
|
109
|
+
function fromNestedDialog(dialog, event) {
|
|
110
|
+
for (const node of event.composedPath()) {
|
|
111
|
+
if (node === dialog)
|
|
112
|
+
return false;
|
|
113
|
+
if (node instanceof HTMLDialogElement && node.matches(':modal'))
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
function closeNestedDialogs(root) {
|
|
119
|
+
walkNested(root, (node) => {
|
|
120
|
+
if (node instanceof TyModal && node.open)
|
|
121
|
+
node.removeAttribute('open');
|
|
122
|
+
if (node instanceof HTMLDialogElement && node.matches(':modal'))
|
|
123
|
+
node.close();
|
|
124
|
+
return false;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function hasOpenNestedDialog(root) {
|
|
128
|
+
return walkNested(root, (node) => node instanceof HTMLDialogElement && node.matches(':modal'));
|
|
129
|
+
}
|
|
130
|
+
function walkNested(root, visit, seen = new WeakSet()) {
|
|
131
|
+
const walk = (node) => {
|
|
132
|
+
if (seen.has(node))
|
|
133
|
+
return false;
|
|
134
|
+
seen.add(node);
|
|
135
|
+
if (visit(node))
|
|
136
|
+
return true;
|
|
137
|
+
if (node.shadowRoot && walkNested(node.shadowRoot, visit, seen))
|
|
138
|
+
return true;
|
|
139
|
+
if (node instanceof HTMLSlotElement) {
|
|
140
|
+
for (const assigned of node.assignedElements({ flatten: true })) {
|
|
141
|
+
if (walk(assigned) || walkNested(assigned, visit, seen))
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
};
|
|
147
|
+
return Array.from(root.querySelectorAll('*')).some(walk);
|
|
148
|
+
}
|
|
100
149
|
function handleEscapeKey(el, event) {
|
|
150
|
+
const dialog = event.currentTarget;
|
|
151
|
+
if (fromNestedDialog(dialog, event))
|
|
152
|
+
return;
|
|
101
153
|
event.stopPropagation();
|
|
102
154
|
if (event.key === 'Escape') {
|
|
103
155
|
event.preventDefault();
|
|
104
156
|
closeModal(el, 'escape');
|
|
105
157
|
}
|
|
106
158
|
}
|
|
159
|
+
function handleDocumentEscape(event) {
|
|
160
|
+
if (event.key !== 'Escape' || event.defaultPrevented)
|
|
161
|
+
return;
|
|
162
|
+
const top = openStack[openStack.length - 1];
|
|
163
|
+
if (!top)
|
|
164
|
+
return;
|
|
165
|
+
if (event.composedPath().some((n) => n instanceof HTMLDialogElement && n.open))
|
|
166
|
+
return;
|
|
167
|
+
if (hasOpenNestedDialog(top))
|
|
168
|
+
return;
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
if (getModalAttributes(top).closeOnEscape)
|
|
171
|
+
closeModal(top, 'escape');
|
|
172
|
+
}
|
|
173
|
+
if (typeof document !== 'undefined')
|
|
174
|
+
document.addEventListener('keydown', handleDocumentEscape);
|
|
107
175
|
function handleCloseButtonClick(el, event) {
|
|
108
176
|
event.preventDefault();
|
|
109
177
|
event.stopPropagation();
|
|
@@ -154,7 +222,7 @@ dialog.addEventListener('keydown', handler);
|
|
|
154
222
|
}
|
|
155
223
|
else {
|
|
156
224
|
const handler = (e) => {
|
|
157
|
-
if (e.key === 'Escape')
|
|
225
|
+
if (e.key === 'Escape' && !fromNestedDialog(dialog, e))
|
|
158
226
|
e.preventDefault();
|
|
159
227
|
};
|
|
160
228
|
escapeKeyHandlers.set(el, handler);
|
|
@@ -239,19 +307,20 @@ setupCloseButtonHover(el, dialog);
|
|
|
239
307
|
if (attributes.open) {
|
|
240
308
|
if (!dialog.open) {
|
|
241
309
|
lockScroll(modalId);
|
|
242
|
-
if (attributes.backdrop) {
|
|
243
310
|
dialog.showModal();
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
dialog.show();
|
|
247
|
-
}
|
|
311
|
+
dropFromStack(el);
|
|
312
|
+
openStack.push(el);
|
|
248
313
|
syncBackdropZoom();
|
|
314
|
+
if (!detachedOpen.delete(el))
|
|
249
315
|
dispatchModalEvent(el, 'open', {});
|
|
250
316
|
}
|
|
251
317
|
}
|
|
252
318
|
else {
|
|
319
|
+
detachedOpen.delete(el);
|
|
320
|
+
dropFromStack(el);
|
|
253
321
|
if (dialog.open) {
|
|
254
322
|
unlockScroll(modalId);
|
|
323
|
+
closeNestedDialogs(el);
|
|
255
324
|
dialog.close();
|
|
256
325
|
syncBackdropZoom();
|
|
257
326
|
const reason = pendingCloseReasons.get(el) ?? 'programmatic';
|
|
@@ -259,10 +328,13 @@ pendingCloseReasons.delete(el);
|
|
|
259
328
|
dispatchModalEvent(el, 'close', { reason });
|
|
260
329
|
}
|
|
261
330
|
}
|
|
331
|
+
syncBackdropZoom();
|
|
262
332
|
dialog.onclose = (event) => {
|
|
263
|
-
if (event.target !== dialog)
|
|
333
|
+
if (event.target !== dialog || dialog.open || !el.isConnected)
|
|
264
334
|
return;
|
|
265
335
|
unlockScroll(modalId);
|
|
336
|
+
dropFromStack(el);
|
|
337
|
+
closeNestedDialogs(el);
|
|
266
338
|
if (el.hasAttribute('open')) {
|
|
267
339
|
el.removeAttribute('open');
|
|
268
340
|
dispatchModalEvent(el, 'close', {
|
|
@@ -274,16 +346,15 @@ syncBackdropZoom();
|
|
|
274
346
|
};
|
|
275
347
|
}
|
|
276
348
|
function syncBackdropZoom() {
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
});
|
|
281
|
-
document.documentElement.classList.toggle('ty-modal-zoom', anyOpen);
|
|
349
|
+
const zoom = Array.from(document.querySelectorAll('ty-modal[open], ty-dialog[open]'))
|
|
350
|
+
.some((m) => parseBoolAttr(m, 'open') && !parseBoolAttr(m, 'no-backdrop') && !parseBoolAttr(m, 'no-zoom'));
|
|
351
|
+
document.documentElement.classList.toggle('ty-modal-zoom', zoom);
|
|
282
352
|
}
|
|
283
353
|
function cleanup(el) {
|
|
284
354
|
const modalId = modalIds.get(el);
|
|
285
355
|
const shadowRoot = el.shadowRoot;
|
|
286
356
|
const dialog = shadowRoot ? getModalDialog(shadowRoot) : null;
|
|
357
|
+
dropFromStack(el);
|
|
287
358
|
if (modalId) {
|
|
288
359
|
unlockScroll(modalId);
|
|
289
360
|
modalIds.delete(el);
|
|
@@ -291,6 +362,10 @@ modalIds.delete(el);
|
|
|
291
362
|
syncBackdropZoom();
|
|
292
363
|
if (!dialog)
|
|
293
364
|
return;
|
|
365
|
+
if (dialog.open) {
|
|
366
|
+
dialog.close();
|
|
367
|
+
detachedOpen.add(el);
|
|
368
|
+
}
|
|
294
369
|
const backdropHandler = backdropClickHandlers.get(el);
|
|
295
370
|
if (backdropHandler) {
|
|
296
371
|
dialog.removeEventListener('click', backdropHandler);
|
|
@@ -325,27 +400,32 @@ hoverLeaveHandlers.delete(el);
|
|
|
325
400
|
}
|
|
326
401
|
export class TyModal extends HTMLElement {
|
|
327
402
|
static get observedAttributes() {
|
|
328
|
-
return ['open', 'no-backdrop', 'prevent-outside-click', 'prevent-escape', 'label'];
|
|
403
|
+
return ['open', 'no-backdrop', 'no-zoom', 'prevent-outside-click', 'prevent-escape', 'label'];
|
|
329
404
|
}
|
|
330
405
|
get open() { return parseBoolAttr(this, 'open'); }
|
|
331
|
-
set open(v) { v ? this.setAttribute('open', 'true') : this.removeAttribute('open'); }
|
|
406
|
+
set open(v) { coerceBoolean(v) ? this.setAttribute('open', 'true') : this.removeAttribute('open'); }
|
|
332
407
|
get noBackdrop() { return parseBoolAttr(this, 'no-backdrop'); }
|
|
333
408
|
set noBackdrop(v) {
|
|
334
|
-
v ? this.setAttribute('no-backdrop', '') : this.removeAttribute('no-backdrop');
|
|
409
|
+
coerceBoolean(v) ? this.setAttribute('no-backdrop', '') : this.removeAttribute('no-backdrop');
|
|
410
|
+
}
|
|
411
|
+
get noZoom() { return parseBoolAttr(this, 'no-zoom'); }
|
|
412
|
+
set noZoom(v) {
|
|
413
|
+
coerceBoolean(v) ? this.setAttribute('no-zoom', '') : this.removeAttribute('no-zoom');
|
|
335
414
|
}
|
|
336
415
|
get preventOutsideClick() { return parseBoolAttr(this, 'prevent-outside-click'); }
|
|
337
416
|
set preventOutsideClick(v) {
|
|
338
|
-
v ? this.setAttribute('prevent-outside-click', '') : this.removeAttribute('prevent-outside-click');
|
|
417
|
+
coerceBoolean(v) ? this.setAttribute('prevent-outside-click', '') : this.removeAttribute('prevent-outside-click');
|
|
339
418
|
}
|
|
340
419
|
get preventEscape() { return parseBoolAttr(this, 'prevent-escape'); }
|
|
341
420
|
set preventEscape(v) {
|
|
342
|
-
v ? this.setAttribute('prevent-escape', '') : this.removeAttribute('prevent-escape');
|
|
421
|
+
coerceBoolean(v) ? this.setAttribute('prevent-escape', '') : this.removeAttribute('prevent-escape');
|
|
343
422
|
}
|
|
344
423
|
constructor() {
|
|
345
424
|
super();
|
|
346
425
|
this.attachShadow({ mode: 'open' });
|
|
347
426
|
}
|
|
348
427
|
connectedCallback() {
|
|
428
|
+
upgradeProperties(this);
|
|
349
429
|
render(this);
|
|
350
430
|
this.show = () => openModal(this);
|
|
351
431
|
this.hide = (opts) => closeModal(this, 'programmatic', opts);
|
package/lib/components/option.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
2
|
+
import { coerceBoolean } from '../utils/property-manager.js';
|
|
3
|
+
import { upgradeProperties } from '../utils/upgrade-properties.js';
|
|
2
4
|
import { optionStyles } from '../styles/option.js';
|
|
3
5
|
const CHECK_SVG = `
|
|
4
6
|
<svg class="option-check" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
@@ -22,11 +24,7 @@ static get observedAttributes() {
|
|
|
22
24
|
return ['value', 'disabled', 'selected', 'highlighted', 'hidden'];
|
|
23
25
|
}
|
|
24
26
|
connectedCallback() {
|
|
25
|
-
|
|
26
|
-
if (instanceValue) {
|
|
27
|
-
this._value = instanceValue.value;
|
|
28
|
-
delete this.value;
|
|
29
|
-
}
|
|
27
|
+
upgradeProperties(this);
|
|
30
28
|
this.render();
|
|
31
29
|
}
|
|
32
30
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -80,6 +78,7 @@ get selected() {
|
|
|
80
78
|
return this._selected;
|
|
81
79
|
}
|
|
82
80
|
set selected(value) {
|
|
81
|
+
value = coerceBoolean(value);
|
|
83
82
|
if (this._selected !== value) {
|
|
84
83
|
this._selected = value;
|
|
85
84
|
if (value) {
|
|
@@ -95,6 +94,7 @@ get disabled() {
|
|
|
95
94
|
return this._disabled;
|
|
96
95
|
}
|
|
97
96
|
set disabled(value) {
|
|
97
|
+
value = coerceBoolean(value);
|
|
98
98
|
if (this._disabled !== value) {
|
|
99
99
|
this._disabled = value;
|
|
100
100
|
if (value) {
|
|
@@ -110,6 +110,7 @@ get highlighted() {
|
|
|
110
110
|
return this._highlighted;
|
|
111
111
|
}
|
|
112
112
|
set highlighted(value) {
|
|
113
|
+
value = coerceBoolean(value);
|
|
113
114
|
if (this._highlighted !== value) {
|
|
114
115
|
this._highlighted = value;
|
|
115
116
|
if (value) {
|
|
@@ -125,6 +126,7 @@ get hidden() {
|
|
|
125
126
|
return this._hidden;
|
|
126
127
|
}
|
|
127
128
|
set hidden(value) {
|
|
129
|
+
value = coerceBoolean(value);
|
|
128
130
|
if (this._hidden !== value) {
|
|
129
131
|
this._hidden = value;
|
|
130
132
|
if (value) {
|
package/lib/components/popup.js
CHANGED
|
@@ -5,9 +5,13 @@ import { popupStyles } from '../styles/popup.js';
|
|
|
5
5
|
const anchorClickHandlers = new WeakMap();
|
|
6
6
|
const anchorKeyClickHandlers = new WeakMap();
|
|
7
7
|
const outsideClickHandlers = new WeakMap();
|
|
8
|
+
const closeTimers = new WeakMap();
|
|
8
9
|
const escapeHandlers = new WeakMap();
|
|
9
10
|
const closeRequestHandlers = new WeakMap();
|
|
10
11
|
const popupIds = new WeakMap();
|
|
12
|
+
const anchors = new WeakMap();
|
|
13
|
+
const escapeGuards = new WeakMap();
|
|
14
|
+
const pointerPresses = new WeakSet();
|
|
11
15
|
function parseBoolAttr(el, name) {
|
|
12
16
|
return el.hasAttribute(name);
|
|
13
17
|
}
|
|
@@ -76,28 +80,55 @@ if (anchor?.hasAttribute('aria-haspopup'))
|
|
|
76
80
|
anchor.setAttribute('aria-expanded', 'false');
|
|
77
81
|
const exitMs = Math.max(0, ...getComputedStyle(dialog).transitionDuration
|
|
78
82
|
.split(',').map((d) => parseFloat(d) * (d.trim().endsWith('ms') ? 1 : 1000)));
|
|
79
|
-
|
|
83
|
+
clearTimeout(closeTimers.get(el));
|
|
84
|
+
closeTimers.set(el, setTimeout(() => {
|
|
85
|
+
closeTimers.delete(el);
|
|
80
86
|
dialog.classList.remove('position-calculated');
|
|
81
87
|
dialog.close();
|
|
82
|
-
}, exitMs + 20);
|
|
88
|
+
}, exitMs + 20));
|
|
83
89
|
}
|
|
84
90
|
function openPopup(el) {
|
|
85
|
-
const popupId = getPopupId(el);
|
|
86
|
-
lockScroll(popupId);
|
|
87
91
|
const shadowRoot = el.shadowRoot;
|
|
88
92
|
const dialog = shadowRoot ? getPopupDialog(shadowRoot) : null;
|
|
89
|
-
if (!dialog)
|
|
93
|
+
if (!dialog || !el.isConnected)
|
|
90
94
|
return;
|
|
91
|
-
dialog.showModal();
|
|
92
95
|
const anchor = getAnchorElement(el);
|
|
96
|
+
if (dialog.open) {
|
|
97
|
+
const pending = closeTimers.get(el);
|
|
98
|
+
if (pending !== undefined) {
|
|
99
|
+
clearTimeout(pending);
|
|
100
|
+
closeTimers.delete(el);
|
|
101
|
+
dialog.classList.add('open');
|
|
102
|
+
if (anchor?.hasAttribute('aria-haspopup'))
|
|
103
|
+
anchor.setAttribute('aria-expanded', 'true');
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const popupId = getPopupId(el);
|
|
108
|
+
lockScroll(popupId);
|
|
109
|
+
dialog.showModal();
|
|
110
|
+
guardEscape(el);
|
|
93
111
|
if (anchor?.hasAttribute('aria-haspopup'))
|
|
94
112
|
anchor.setAttribute('aria-expanded', 'true');
|
|
95
113
|
requestAnimationFrame(() => {
|
|
96
114
|
updatePosition(el);
|
|
97
115
|
dialog.classList.add('preparing-animation');
|
|
98
|
-
|
|
116
|
+
dialog.getBoundingClientRect();
|
|
99
117
|
requestAnimationFrame(() => {
|
|
100
118
|
dialog.classList.add('open');
|
|
119
|
+
if (!el.matches(':focus-within')) {
|
|
120
|
+
const target = el.querySelector('[autofocus]');
|
|
121
|
+
target?.focus({ preventScroll: true });
|
|
122
|
+
if (!el.matches(':focus-within')) {
|
|
123
|
+
dialog.focus({ preventScroll: true });
|
|
124
|
+
if (target) {
|
|
125
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
126
|
+
if (dialog.open && shadowRoot.activeElement === dialog)
|
|
127
|
+
target.focus({ preventScroll: true });
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
101
132
|
el.dispatchEvent(new CustomEvent('open'));
|
|
102
133
|
});
|
|
103
134
|
});
|
|
@@ -128,7 +159,36 @@ event.preventDefault();
|
|
|
128
159
|
closePopup(el);
|
|
129
160
|
}
|
|
130
161
|
}
|
|
162
|
+
function fromNestedDialog(el, event) {
|
|
163
|
+
const dialog = el.shadowRoot ? getPopupDialog(el.shadowRoot) : null;
|
|
164
|
+
for (const node of event.composedPath()) {
|
|
165
|
+
if (node === dialog)
|
|
166
|
+
return false;
|
|
167
|
+
if (node instanceof HTMLDialogElement && node.matches(':modal'))
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
function guardEscape(el) {
|
|
173
|
+
if (escapeGuards.has(el))
|
|
174
|
+
return;
|
|
175
|
+
const guard = (e) => {
|
|
176
|
+
if (e.key === 'Escape' && getPopupAttributes(el).disableClose && !fromNestedDialog(el, e))
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
};
|
|
179
|
+
escapeGuards.set(el, guard);
|
|
180
|
+
document.addEventListener('keydown', guard, true);
|
|
181
|
+
}
|
|
182
|
+
function unguardEscape(el) {
|
|
183
|
+
const guard = escapeGuards.get(el);
|
|
184
|
+
if (!guard)
|
|
185
|
+
return;
|
|
186
|
+
document.removeEventListener('keydown', guard, true);
|
|
187
|
+
escapeGuards.delete(el);
|
|
188
|
+
}
|
|
131
189
|
function handleEscape(el, event) {
|
|
190
|
+
if (fromNestedDialog(el, event))
|
|
191
|
+
return;
|
|
132
192
|
event.stopPropagation();
|
|
133
193
|
if (event.key === 'Escape') {
|
|
134
194
|
const { disableClose } = getPopupAttributes(el);
|
|
@@ -152,26 +212,39 @@ return;
|
|
|
152
212
|
anchor.setAttribute('aria-haspopup', 'dialog');
|
|
153
213
|
if (!anchor.hasAttribute('aria-expanded'))
|
|
154
214
|
anchor.setAttribute('aria-expanded', 'false');
|
|
215
|
+
const previous = anchors.get(el) ?? anchor;
|
|
155
216
|
const existingHandler = anchorClickHandlers.get(el);
|
|
156
217
|
if (existingHandler) {
|
|
157
|
-
|
|
218
|
+
previous.removeEventListener('pointerdown', existingHandler);
|
|
158
219
|
}
|
|
159
220
|
const existingKeyHandler = anchorKeyClickHandlers.get(el);
|
|
160
221
|
if (existingKeyHandler) {
|
|
161
|
-
|
|
222
|
+
previous.removeEventListener('click', existingKeyHandler);
|
|
162
223
|
}
|
|
163
|
-
|
|
224
|
+
anchors.set(el, anchor);
|
|
225
|
+
const handler = (e) => {
|
|
226
|
+
pointerPresses.add(el);
|
|
227
|
+
handleAnchorClick(el, e);
|
|
228
|
+
};
|
|
164
229
|
anchorClickHandlers.set(el, handler);
|
|
165
230
|
anchor.addEventListener('pointerdown', handler);
|
|
166
231
|
const keyHandler = (e) => {
|
|
167
|
-
if (
|
|
232
|
+
if (pointerPresses.delete(el))
|
|
233
|
+
return;
|
|
234
|
+
const d = e.detail;
|
|
235
|
+
const click = typeof d === 'number' ? e : d?.originalEvent ?? e;
|
|
236
|
+
if (click.detail !== 0)
|
|
237
|
+
return;
|
|
238
|
+
if (click.composedPath().includes(el))
|
|
239
|
+
return;
|
|
168
240
|
handleAnchorClick(el, e);
|
|
169
241
|
};
|
|
170
242
|
anchorKeyClickHandlers.set(el, keyHandler);
|
|
171
243
|
anchor.addEventListener('click', keyHandler);
|
|
172
244
|
}
|
|
173
245
|
function cleanupAnchorEvents(el) {
|
|
174
|
-
const anchor =
|
|
246
|
+
const anchor = anchors.get(el);
|
|
247
|
+
anchors.delete(el);
|
|
175
248
|
const handler = anchorClickHandlers.get(el);
|
|
176
249
|
if (anchor && handler) {
|
|
177
250
|
anchor.removeEventListener('pointerdown', handler);
|
|
@@ -196,6 +269,7 @@ const dialog = document.createElement('dialog');
|
|
|
196
269
|
const container = document.createElement('div');
|
|
197
270
|
const content = document.createElement('slot');
|
|
198
271
|
dialog.className = 'popup-dialog';
|
|
272
|
+
dialog.tabIndex = -1;
|
|
199
273
|
container.className = 'popup-container';
|
|
200
274
|
content.id = 'popup-content';
|
|
201
275
|
shadowRoot.appendChild(dialog);
|
|
@@ -209,17 +283,40 @@ dialog.addEventListener('pointerdown', outsideHandler);
|
|
|
209
283
|
const escapeHandler = (e) => handleEscape(el, e);
|
|
210
284
|
escapeHandlers.set(el, escapeHandler);
|
|
211
285
|
el.addEventListener('keydown', escapeHandler);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
286
|
+
const inertKeys = (e) => {
|
|
287
|
+
if ((e.key === 'Enter' || e.key === ' ') && e.composedPath()[0] === dialog)
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
};
|
|
290
|
+
for (const type of ['keydown', 'keypress', 'keyup'])
|
|
291
|
+
dialog.addEventListener(type, inertKeys);
|
|
292
|
+
dialog.addEventListener('cancel', (e) => {
|
|
293
|
+
if (getPopupAttributes(el).disableClose)
|
|
294
|
+
e.preventDefault();
|
|
295
|
+
});
|
|
296
|
+
new MutationObserver(() => {
|
|
297
|
+
if (dialog.open)
|
|
298
|
+
return;
|
|
299
|
+
clearTimeout(closeTimers.get(el));
|
|
300
|
+
closeTimers.delete(el);
|
|
301
|
+
pointerPresses.delete(el);
|
|
302
|
+
unguardEscape(el);
|
|
303
|
+
unlockScroll(getPopupId(el));
|
|
215
304
|
dialog.classList.remove('open');
|
|
216
305
|
dialog.classList.remove('preparing-animation');
|
|
306
|
+
const anchor = getAnchorElement(el);
|
|
307
|
+
if (anchor?.hasAttribute('aria-haspopup'))
|
|
308
|
+
anchor.setAttribute('aria-expanded', 'false');
|
|
309
|
+
}).observe(dialog, { attributes: true, attributeFilter: ['open'] });
|
|
310
|
+
dialog.addEventListener('close', () => {
|
|
217
311
|
el.dispatchEvent(new CustomEvent('close'));
|
|
218
312
|
});
|
|
219
313
|
}
|
|
220
314
|
el.closePopup = () => closePopup(el, true);
|
|
221
315
|
el.openPopup = () => openPopup(el);
|
|
222
316
|
el.togglePopup = () => togglePopup(el);
|
|
317
|
+
const existingCloseRequest = closeRequestHandlers.get(el);
|
|
318
|
+
if (existingCloseRequest)
|
|
319
|
+
el.removeEventListener('ty:close-popup', existingCloseRequest);
|
|
223
320
|
const closeRequestHandler = (e) => handleCloseRequest(el, e);
|
|
224
321
|
closeRequestHandlers.set(el, closeRequestHandler);
|
|
225
322
|
el.addEventListener('ty:close-popup', closeRequestHandler);
|
|
@@ -240,12 +337,15 @@ if (outsideHandler) {
|
|
|
240
337
|
dialog.removeEventListener('pointerdown', outsideHandler);
|
|
241
338
|
outsideClickHandlers.delete(el);
|
|
242
339
|
}
|
|
340
|
+
if (dialog.open)
|
|
341
|
+
dialog.close();
|
|
243
342
|
}
|
|
244
343
|
const escapeHandler = escapeHandlers.get(el);
|
|
245
344
|
if (escapeHandler) {
|
|
246
345
|
el.removeEventListener('keydown', escapeHandler);
|
|
247
346
|
escapeHandlers.delete(el);
|
|
248
347
|
}
|
|
348
|
+
unguardEscape(el);
|
|
249
349
|
const closeRequestHandler = closeRequestHandlers.get(el);
|
|
250
350
|
if (closeRequestHandler) {
|
|
251
351
|
el.removeEventListener('ty:close-popup', closeRequestHandler);
|
|
@@ -17,6 +17,7 @@ export interface TyRadioElement extends HTMLElement {
|
|
|
17
17
|
flavor: Flavor;
|
|
18
18
|
}
|
|
19
19
|
export declare class TyRadio extends TyComponent<RadioState> implements TyRadioElement {
|
|
20
|
+
protected static labelClicks: boolean;
|
|
20
21
|
protected static properties: {
|
|
21
22
|
value: {
|
|
22
23
|
type: "string";
|
|
@@ -160,12 +161,20 @@ export declare class TyRadioGroup extends TyComponent<RadioGroupState> implement
|
|
|
160
161
|
* the accessors after upgrade. Each radio fires ty-radio-connected once
|
|
161
162
|
* upgraded, which re-syncs the group.
|
|
162
163
|
*/
|
|
164
|
+
/** Focus the group's tab stop: the checked radio, else the first enabled one. */
|
|
165
|
+
focus(options?: FocusOptions): void;
|
|
163
166
|
private getRadios;
|
|
164
167
|
private syncChildren;
|
|
165
168
|
/** Report `required` to the owning form — without this the asterisk
|
|
166
|
-
showed but an empty group submitted anyway.
|
|
169
|
+
showed but an empty group submitted anyway. The message is a native
|
|
170
|
+
radio's; it needs a name, a nameless radio never reports valueMissing. */
|
|
167
171
|
private updateValidity;
|
|
168
172
|
private handleRadioSelect;
|
|
173
|
+
/**
|
|
174
|
+
* Select a value as the user did: input + change, like a native radio,
|
|
175
|
+
* whether by click, arrow keys or Space. Nothing fires when it is already selected.
|
|
176
|
+
*/
|
|
177
|
+
private select;
|
|
169
178
|
/**
|
|
170
179
|
* Arrow-key navigation within group (W3C radio practice: arrow keys move
|
|
171
180
|
* focus and selection together).
|
package/lib/components/radio.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ensureStyles } from "../utils/styles.js";
|
|
|
4
4
|
import { syncCustomFlavorSheet } from "../utils/flavor-sheet.js";
|
|
5
5
|
import { radioStyles, radioCustomFlavorCss } from "../styles/radio.js";
|
|
6
6
|
import { REQUIRED_ICON_SVG } from "../utils/icons.js";
|
|
7
|
+
import { nativeMessage } from "../utils/validity.js";
|
|
7
8
|
export class TyRadio extends TyComponent {
|
|
8
9
|
constructor() {
|
|
9
10
|
super();
|
|
@@ -133,6 +134,7 @@ set size(v) { this.setProperty("size", v); }
|
|
|
133
134
|
get flavor() { return this.getProperty("flavor"); }
|
|
134
135
|
set flavor(v) { this.setProperty("flavor", v); }
|
|
135
136
|
}
|
|
137
|
+
TyRadio.labelClicks = true;
|
|
136
138
|
TyRadio.properties = {
|
|
137
139
|
value: { type: "string", default: "" },
|
|
138
140
|
checked: {
|
|
@@ -184,6 +186,14 @@ this.syncChildren();
|
|
|
184
186
|
getFormValue() {
|
|
185
187
|
return this.value || null;
|
|
186
188
|
}
|
|
189
|
+
focus(options) {
|
|
190
|
+
const enabled = this.getRadios().filter((r) => !r.disabled);
|
|
191
|
+
const stop = enabled.find((r) => r.checked) ?? enabled[0];
|
|
192
|
+
if (stop)
|
|
193
|
+
stop.focus(options);
|
|
194
|
+
else
|
|
195
|
+
super.focus(options);
|
|
196
|
+
}
|
|
187
197
|
getRadios() {
|
|
188
198
|
return Array.from(this.querySelectorAll("ty-radio"))
|
|
189
199
|
.filter((r) => typeof r.setTabStop === "function");
|
|
@@ -215,7 +225,7 @@ updateValidity() {
|
|
|
215
225
|
if (this.required && !this.disabled && !this.value) {
|
|
216
226
|
const anchor = this.getRadios().find((r) => !r.disabled);
|
|
217
227
|
const target = anchor?.shadowRoot?.querySelector(".radio-container");
|
|
218
|
-
this.applyValidity({ valueMissing: true }, "
|
|
228
|
+
this.applyValidity({ valueMissing: true }, nativeMessage("input", { type: "radio", name: "ty", required: true }), target ?? undefined);
|
|
219
229
|
}
|
|
220
230
|
else {
|
|
221
231
|
this.applyValidity({});
|
|
@@ -228,16 +238,17 @@ const detail = e.detail;
|
|
|
228
238
|
const newValue = detail?.value;
|
|
229
239
|
if (typeof newValue !== "string" || newValue === this.value)
|
|
230
240
|
return;
|
|
231
|
-
this.
|
|
241
|
+
this.select(newValue, e);
|
|
242
|
+
}
|
|
243
|
+
select(value, originalEvent) {
|
|
244
|
+
if (value === this.value)
|
|
245
|
+
return;
|
|
246
|
+
this.value = value;
|
|
232
247
|
this.syncChildren();
|
|
248
|
+
const detail = { value, formValue: value, originalEvent };
|
|
233
249
|
setTimeout(() => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
formValue: newValue,
|
|
237
|
-
originalEvent: e,
|
|
238
|
-
};
|
|
239
|
-
this.dispatchEvent(new CustomEvent("input", { detail: eventDetail, bubbles: true, composed: true }));
|
|
240
|
-
this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
|
|
250
|
+
this.dispatchEvent(new CustomEvent("input", { detail, bubbles: true, composed: true }));
|
|
251
|
+
this.dispatchEvent(new CustomEvent("change", { detail, bubbles: true, composed: true }));
|
|
241
252
|
}, 0);
|
|
242
253
|
}
|
|
243
254
|
handleKeydown(e) {
|
|
@@ -262,16 +273,7 @@ nextIndex = current
|
|
|
262
273
|
else if (["Space", " ", "Enter"].includes(e.key)) {
|
|
263
274
|
if (current) {
|
|
264
275
|
e.preventDefault();
|
|
265
|
-
this.
|
|
266
|
-
this.syncChildren();
|
|
267
|
-
const eventDetail = {
|
|
268
|
-
value: current.value,
|
|
269
|
-
formValue: current.value,
|
|
270
|
-
originalEvent: e,
|
|
271
|
-
};
|
|
272
|
-
setTimeout(() => {
|
|
273
|
-
this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
|
|
274
|
-
}, 0);
|
|
276
|
+
this.select(current.value, e);
|
|
275
277
|
}
|
|
276
278
|
return;
|
|
277
279
|
}
|
|
@@ -281,16 +283,7 @@ return;
|
|
|
281
283
|
const next = radios[nextIndex];
|
|
282
284
|
if (next) {
|
|
283
285
|
next.focus();
|
|
284
|
-
this.
|
|
285
|
-
this.syncChildren();
|
|
286
|
-
const eventDetail = {
|
|
287
|
-
value: next.value,
|
|
288
|
-
formValue: next.value,
|
|
289
|
-
originalEvent: e,
|
|
290
|
-
};
|
|
291
|
-
setTimeout(() => {
|
|
292
|
-
this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
|
|
293
|
-
}, 0);
|
|
286
|
+
this.select(next.value, e);
|
|
294
287
|
}
|
|
295
288
|
}
|
|
296
289
|
removeEventListeners() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
2
2
|
import { resizeObserverStyles } from '../styles/resize-observer.js';
|
|
3
3
|
import { updateSize, removeSize } from '../utils/resize-observer.js';
|
|
4
|
+
import { upgradeProperties } from '../utils/upgrade-properties.js';
|
|
4
5
|
export class TyResizeObserver extends HTMLElement {
|
|
5
6
|
static get observedAttributes() {
|
|
6
7
|
return ['id', 'debounce'];
|
|
@@ -20,6 +21,7 @@ ensureStyles(shadow, { css: resizeObserverStyles, id: 'ty-resize-observer' });
|
|
|
20
21
|
shadow.innerHTML = '<slot></slot>';
|
|
21
22
|
}
|
|
22
23
|
connectedCallback() {
|
|
24
|
+
upgradeProperties(this);
|
|
23
25
|
this.setupObserver();
|
|
24
26
|
}
|
|
25
27
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
2
2
|
import { scrollContainerStyles } from '../styles/scroll-container.js';
|
|
3
3
|
import { CustomScrollbar } from '../utils/custom-scrollbar.js';
|
|
4
|
+
import { upgradeProperties } from '../utils/upgrade-properties.js';
|
|
4
5
|
export class TyScrollContainer extends HTMLElement {
|
|
5
6
|
static get observedAttributes() {
|
|
6
7
|
return ['no-shadow', 'max-height', 'hide-scrollbar', 'custom-scrollbar', 'overflow-x', 'scroll-anchoring'];
|
|
@@ -112,6 +113,7 @@ this._shadowLeft = shadow.querySelector('.shadow-left');
|
|
|
112
113
|
this._shadowRight = shadow.querySelector('.shadow-right');
|
|
113
114
|
}
|
|
114
115
|
connectedCallback() {
|
|
116
|
+
upgradeProperties(this);
|
|
115
117
|
this._scrollWrapper?.addEventListener('scroll', this._onScroll, { passive: true });
|
|
116
118
|
this._resizeObserver = new ResizeObserver(() => {
|
|
117
119
|
this._scrollbar?.update();
|