@swiftwc/ui 0.0.0-dev.20 → 0.0.0-dev.21
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/generated/buses/alert-dialog.d.ts +2 -0
- package/generated/buses/alert-dialog.js +1 -0
- package/generated/buses/confirmation-dialog.d.ts +2 -0
- package/generated/buses/confirmation-dialog.js +1 -0
- package/generated/buses/index.d.ts +6 -0
- package/generated/buses/index.js +6 -0
- package/generated/buses/lifecycle-observer.d.ts +2 -0
- package/generated/buses/lifecycle-observer.js +1 -0
- package/generated/client/index.d.ts +17 -4
- package/generated/client/index.js +83 -32
- package/generated/components/alert-dialog.d.ts +8 -0
- package/generated/components/alert-dialog.js +94 -0
- package/generated/components/bordered-button.d.ts +2 -0
- package/generated/components/bordered-button.js +15 -1
- package/generated/components/bordered-prominent-button.d.ts +2 -0
- package/generated/components/bordered-prominent-button.js +15 -1
- package/generated/components/borderless-button.d.ts +1 -1
- package/generated/components/borderless-button.js +6 -7
- package/generated/components/confirmation-dialog.d.ts +1 -1
- package/generated/components/confirmation-dialog.js +26 -20
- package/generated/components/content-unavailable-view.js +2 -2
- package/generated/components/date-picker.js +14 -6
- package/generated/components/disclosure-group.js +4 -1
- package/generated/components/glass-button.d.ts +2 -0
- package/generated/components/glass-button.js +15 -1
- package/generated/components/glass-prominent-button.d.ts +2 -0
- package/generated/components/glass-prominent-button.js +15 -1
- package/generated/components/index.d.ts +1 -0
- package/generated/components/index.js +1 -0
- package/generated/components/label-view.js +3 -3
- package/generated/components/menu-view.js +12 -7
- package/generated/components/navigation-title.js +4 -4
- package/generated/components/picker-view.js +16 -10
- package/generated/components/scroll-view.js +19 -10
- package/generated/components/section-view.js +3 -3
- package/generated/components/sheet-view.d.ts +1 -1
- package/generated/components/sheet-view.js +21 -17
- package/generated/components/sidebar-toggle.js +5 -3
- package/generated/components/sidebar-view.js +10 -4
- package/generated/components/sticky-container.js +3 -1
- package/generated/components/tab-bar.js +10 -4
- package/generated/components/tab-item.js +3 -1
- package/generated/components/tab-view.js +4 -1
- package/generated/components/table-view.js +11 -5
- package/generated/components/text-field.js +28 -28
- package/generated/components/tool-bar-item-group.d.ts +2 -0
- package/generated/components/tool-bar-item-group.js +28 -0
- package/generated/components/tool-bar-item.d.ts +2 -0
- package/generated/components/tool-bar-item.js +32 -2
- package/generated/components/tool-bar.js +1 -1
- package/generated/components/v-stack.d.ts +5 -0
- package/generated/components/v-stack.js +5 -0
- package/generated/css/index.css +128 -37
- package/generated/events/alert-dialog.d.ts +8 -0
- package/generated/events/alert-dialog.js +1 -0
- package/generated/events/confirmation-dialog.d.ts +2 -2
- package/generated/events/index.d.ts +1 -0
- package/generated/events/index.js +1 -0
- package/generated/i18n/locales/el.d.ts +9 -0
- package/generated/i18n/locales/el.js +9 -0
- package/generated/i18n/locales/en.d.ts +9 -0
- package/generated/i18n/locales/en.js +9 -0
- package/generated/internal/class/form-associated-base.js +4 -1
- package/generated/internal/class/navigation-view.js +4 -4
- package/generated/internal/utils/button-role.d.ts +1 -0
- package/generated/internal/utils/button-role.js +19 -0
- package/generated/internal/utils/cash/index.d.ts +4 -3
- package/generated/internal/utils/cash/index.js +6 -4
- package/generated/internal/utils/index.d.ts +3 -0
- package/generated/internal/utils/index.js +3 -0
- package/generated/internal/utils/is-inside.d.ts +1 -0
- package/generated/internal/utils/is-inside.js +4 -0
- package/generated/internal/utils/list-active.js +15 -5
- package/generated/internal/utils/toolbar-repositioner.d.ts +1 -0
- package/generated/internal/utils/toolbar-repositioner.js +12 -0
- package/generated/snapshot/index.d.ts +2 -0
- package/generated/snapshot/index.js +21 -0
- package/package.json +7 -4
- package/scss/_components.scss +2 -0
- package/scss/_functions.scss +10 -0
- package/scss/_transitions.scss +1 -0
- package/scss/colors/_index.scss +2 -2
- package/scss/components/_alert-dialog.scss +106 -0
- package/scss/components/_confirmation-dialog.scss +39 -39
- package/scss/components/_h-stack.scss +3 -13
- package/scss/components/_index.scss +1 -0
- package/scss/components/_sheet-view.scss +11 -1
- package/scss/components/_v-stack.scss +3 -13
- package/scss/final/_touch-glass.scss +7 -0
- package/scss/mixins/_index.scss +17 -0
- package/scss/placeholders/_buttons.scss +42 -0
- package/scss/transitions/_alert-dialog.scss +19 -0
- package/scss/utils/_frame.scss +7 -0
- package/web-components.html-data/en.json +84 -7
- package/generated/confirmation-dialog/index.d.ts +0 -1
- package/generated/confirmation-dialog/index.js +0 -1
- package/generated/lifecycle-observer/index.d.ts +0 -1
- package/generated/lifecycle-observer/index.js +0 -1
- package/scss/components/_components.scss +0 -76
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default new EventTarget();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default new EventTarget();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as alertDialog } from './alert-dialog';
|
|
2
|
+
export * from './alert-dialog';
|
|
3
|
+
export { default as confirmationDialog } from './confirmation-dialog';
|
|
4
|
+
export * from './confirmation-dialog';
|
|
5
|
+
export { default as lifecycleObserver } from './lifecycle-observer';
|
|
6
|
+
export * from './lifecycle-observer';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as alertDialog } from './alert-dialog';
|
|
2
|
+
export * from './alert-dialog';
|
|
3
|
+
export { default as confirmationDialog } from './confirmation-dialog';
|
|
4
|
+
export * from './confirmation-dialog';
|
|
5
|
+
export { default as lifecycleObserver } from './lifecycle-observer';
|
|
6
|
+
export * from './lifecycle-observer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default new EventTarget();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lifecycleObserver } from '../buses';
|
|
2
2
|
import { I18n } from '../i18n';
|
|
3
3
|
import { NavigationPath } from '../internal/class/navigation-path';
|
|
4
|
-
import { LifecycleObserver } from '../lifecycle-observer';
|
|
5
4
|
import { type WebComponentCtor } from '../namespace-browser';
|
|
6
5
|
import { Snapshot } from '../snapshot';
|
|
7
6
|
export declare const polyfills: Map<string, WebComponentCtor>;
|
|
@@ -12,5 +11,19 @@ type NavigateOptions = {
|
|
|
12
11
|
tos?: () => NavigationPath[];
|
|
13
12
|
};
|
|
14
13
|
export declare const startViewTransition: (target: HTMLElement, type?: TransitionType, updateCallbackOrOptions?: UpdateCallback | NavigateOptions) => Promise<void>;
|
|
15
|
-
export declare const
|
|
16
|
-
|
|
14
|
+
export declare const alert: (title?: string, message?: string, actions?: {
|
|
15
|
+
label?: string;
|
|
16
|
+
image?: string;
|
|
17
|
+
role?: string;
|
|
18
|
+
}[], options?: {
|
|
19
|
+
titleVisibility?: boolean;
|
|
20
|
+
}) => Promise<any>;
|
|
21
|
+
export declare const confirmationDialog: (trigger: HTMLElement, title: string, actions?: {
|
|
22
|
+
label?: string;
|
|
23
|
+
image?: string;
|
|
24
|
+
role?: string;
|
|
25
|
+
}[], options?: {
|
|
26
|
+
controller?: AbortController;
|
|
27
|
+
titleVisibility?: boolean;
|
|
28
|
+
}) => Promise<any>;
|
|
29
|
+
export { I18n, lifecycleObserver, NavigationPath, Snapshot };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { alertDialog, confirmationDialog as confirmationDialogBus, lifecycleObserver } from '../buses';
|
|
1
2
|
import * as Components from '../components';
|
|
2
|
-
import { ConfirmationDialog } from '../confirmation-dialog';
|
|
3
3
|
import { I18n } from '../i18n';
|
|
4
4
|
import { NavigationPath } from '../internal/class/navigation-path';
|
|
5
5
|
import { $, kebabCase, onoff } from '../internal/utils';
|
|
6
|
-
import { LifecycleObserver } from '../lifecycle-observer';
|
|
7
6
|
import { Snapshot } from '../snapshot';
|
|
8
7
|
export const polyfills = new Map();
|
|
9
8
|
for (const [k, Ctor] of Object.entries(Components)) {
|
|
@@ -17,7 +16,7 @@ for (const [k, Ctor] of Object.entries(Components)) {
|
|
|
17
16
|
// const testEl = document.createElement('template')
|
|
18
17
|
// testEl.innerHTML = `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`
|
|
19
18
|
// const testNode = testEl.content.firstElementChild,
|
|
20
|
-
if (!($(`<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}
|
|
19
|
+
if (!($(`<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`, '>1') instanceof Ctor))
|
|
21
20
|
polyfills.set(is, Ctor);
|
|
22
21
|
continue;
|
|
23
22
|
}
|
|
@@ -49,7 +48,7 @@ if (0 < polyfills.size) {
|
|
|
49
48
|
oldValue: null,
|
|
50
49
|
target: el,
|
|
51
50
|
};
|
|
52
|
-
|
|
51
|
+
polyfill.polyfillAttributeChangedCallback([entry]);
|
|
53
52
|
}
|
|
54
53
|
}, unobserve = (el) => {
|
|
55
54
|
handlers.delete(el);
|
|
@@ -253,38 +252,90 @@ export const startViewTransition = async (target, type = 'forwards', updateCallb
|
|
|
253
252
|
await updateCallback();
|
|
254
253
|
}
|
|
255
254
|
};
|
|
256
|
-
export const
|
|
257
|
-
const
|
|
258
|
-
const dialog = $(`<dialog is="confirmation-dialog">
|
|
259
|
-
${entries.map((item, index) => `<button type="button" tabindex="0" value="${index}">
|
|
260
|
-
<label-view title="${item[0]}"></label-view>
|
|
261
|
-
</button>`)}
|
|
262
|
-
</dialog>`);
|
|
263
|
-
$.prop('anchor-name', newAnchorName, trigger, 'important');
|
|
264
|
-
$.prop('position-anchor', newAnchorName, dialog);
|
|
255
|
+
export const alert = async (title, message, actions, options) => {
|
|
256
|
+
const dialog = $(`<dialog is="alert-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(`<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
|
|
265
257
|
if (title) {
|
|
266
|
-
const label = $(`<label-view></label-view
|
|
258
|
+
const label = $(`<label-view font="headline"></label-view>`, '>1');
|
|
267
259
|
label.setAttribute('title', title);
|
|
268
|
-
|
|
260
|
+
vStack.insertAdjacentElement('beforeend', label);
|
|
261
|
+
}
|
|
262
|
+
if (message) {
|
|
263
|
+
const label = $(`<label-view foreground="secondary" font="callout"></label-view>`, '>1');
|
|
264
|
+
label.setAttribute('title', message);
|
|
265
|
+
vStack.insertAdjacentElement('beforeend', label);
|
|
266
|
+
}
|
|
267
|
+
for (const [index, action] of (actions ?? []).entries()) {
|
|
268
|
+
const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
|
|
269
|
+
btn.setAttribute('value', `${index}`);
|
|
270
|
+
if (action?.role)
|
|
271
|
+
btn.setAttribute('role', action.role);
|
|
272
|
+
if (action.label || action.image) {
|
|
273
|
+
const label = $(`<label-view title="${action.label}"></label-view>`, '>1');
|
|
274
|
+
if (action.label)
|
|
275
|
+
label.setAttribute('title', action.label);
|
|
276
|
+
if (action.image)
|
|
277
|
+
label.setAttribute('system-image', action.image);
|
|
278
|
+
btn.appendChild(label);
|
|
279
|
+
}
|
|
280
|
+
dialog.insertAdjacentElement('beforeend', btn);
|
|
281
|
+
}
|
|
282
|
+
document.body.insertAdjacentElement('beforeend', dialog);
|
|
283
|
+
dialog.showModal();
|
|
284
|
+
const { promise, resolve } = Promise.withResolvers(), off = onoff('alert:return', (evt) => {
|
|
285
|
+
off();
|
|
286
|
+
resolve(evt.detail.returnValue);
|
|
287
|
+
}, alertDialog, { once: true }).on();
|
|
288
|
+
return promise;
|
|
289
|
+
};
|
|
290
|
+
export const confirmationDialog = async (trigger, title, actions, options) => {
|
|
291
|
+
const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
|
|
292
|
+
const dialog = $(`<dialog is="confirmation-dialog"></dialog>`, '>1');
|
|
293
|
+
trigger.style.setProperty('anchor-name', newAnchorName, 'important'); //$.prop('anchor-name', newAnchorName, trigger, 'important')
|
|
294
|
+
dialog.style.setProperty('position-anchor', newAnchorName); //$.prop('position-anchor', newAnchorName, dialog)
|
|
295
|
+
if (title && false !== options?.titleVisibility) {
|
|
296
|
+
const label = $(`<label-view></label-view>`, '>1');
|
|
297
|
+
label.setAttribute('title', title);
|
|
298
|
+
dialog.insertAdjacentElement('beforeend', label);
|
|
299
|
+
}
|
|
300
|
+
for (const [index, action] of (actions ?? []).entries()) {
|
|
301
|
+
const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
|
|
302
|
+
btn.setAttribute('value', `${index}`);
|
|
303
|
+
if (action?.role)
|
|
304
|
+
btn.setAttribute('role', action.role);
|
|
305
|
+
if (action.label || action.image) {
|
|
306
|
+
const label = $(`<label-view title="${action.label}"></label-view>`, '>1');
|
|
307
|
+
if (action.label)
|
|
308
|
+
label.setAttribute('title', action.label);
|
|
309
|
+
if (action.image)
|
|
310
|
+
label.setAttribute('system-image', action.image);
|
|
311
|
+
btn.appendChild(label);
|
|
312
|
+
}
|
|
313
|
+
dialog.insertAdjacentElement('beforeend', btn);
|
|
269
314
|
}
|
|
270
315
|
trigger.closest('body-view')?.insertAdjacentElement('beforeend', dialog); // dialog.showModal()
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
316
|
+
const { promise, resolve } = Promise.withResolvers(), off = onoff('confirmation:return', (evt) => {
|
|
317
|
+
off();
|
|
318
|
+
resolve(evt.detail.returnValue);
|
|
319
|
+
}, confirmationDialogBus, { once: true }).on();
|
|
320
|
+
return promise;
|
|
321
|
+
// return await new Promise((resolve, reject) => {
|
|
322
|
+
// const onClose = (evt: any) => {
|
|
323
|
+
// off()
|
|
324
|
+
// resolve(evt.detail.returnValue)
|
|
325
|
+
// },
|
|
326
|
+
// off = onoff('return', onClose, ConfirmationDialog, { once: true }).on()
|
|
327
|
+
// // const onAbort = () => {
|
|
328
|
+
// // cleanup()
|
|
329
|
+
// // reject(new DOMException('aborted', 'AbortError'))
|
|
330
|
+
// // }
|
|
331
|
+
// // const cleanup = () => {
|
|
332
|
+
// // ConfirmationDialog.removeEventListener('close', onClose)
|
|
333
|
+
// // // controller.signal.removeEventListener('abort', onAbort)
|
|
334
|
+
// // }
|
|
335
|
+
// // ConfirmationDialog.addEventListener('close', onClose, { once: true })
|
|
336
|
+
// // controller.signal.addEventListener('abort', onAbort, { once: true })
|
|
337
|
+
// })
|
|
287
338
|
};
|
|
288
339
|
void Snapshot.waitReady; // void Snapshot.setOwnConfig()
|
|
289
340
|
// SECTION
|
|
290
|
-
export {
|
|
341
|
+
export { I18n, lifecycleObserver, NavigationPath, Snapshot };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
2
|
+
export declare class AlertDialog extends DialogBase {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
static polyfillDisconnectedCallback(el: AlertDialog): void;
|
|
6
|
+
static polyfillConnectedCallback(el: AlertDialog): void;
|
|
7
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { alertDialog } from '../buses';
|
|
2
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
|
+
import { onoff, touchGlass } from '../internal/utils';
|
|
4
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
5
|
+
export class AlertDialog extends DialogBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
static polyfillDisconnectedCallback(el) {
|
|
10
|
+
console.debug(`${AlertDialog.name} ⚡️ disconnect`);
|
|
11
|
+
CleanupRegistry.unregister(el);
|
|
12
|
+
alertDialog.dispatchEvent(new CustomEvent('alert:return', {
|
|
13
|
+
detail: { returnValue: el.returnValue },
|
|
14
|
+
bubbles: true,
|
|
15
|
+
composed: true,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
static polyfillConnectedCallback(el) {
|
|
19
|
+
console.debug(`${AlertDialog.name} ⚡️ connect`);
|
|
20
|
+
CleanupRegistry.register(el, onoff([
|
|
21
|
+
{ types: 'click', listener: this.#handleDialogClick },
|
|
22
|
+
{ types: 'close', listener: this.#handleDialogClose },
|
|
23
|
+
{ types: 'cancel', listener: this.#handleDialogCancel },
|
|
24
|
+
], el).on());
|
|
25
|
+
CleanupRegistry.register(el, onoff(touchGlass(el, (t) => t, (evt) => {
|
|
26
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
27
|
+
if (!target)
|
|
28
|
+
return true;
|
|
29
|
+
if (target.matches('[is=alert-dialog]'))
|
|
30
|
+
return false;
|
|
31
|
+
return true;
|
|
32
|
+
}), el).on());
|
|
33
|
+
console.debug(`${AlertDialog.name} ⚡️ will-open`);
|
|
34
|
+
el.removeAttribute('closing');
|
|
35
|
+
el.scrollTop = 0;
|
|
36
|
+
el.returnValue = '';
|
|
37
|
+
el.autofocus = true;
|
|
38
|
+
el.showModal();
|
|
39
|
+
}
|
|
40
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
|
|
41
|
+
console.debug(`${AlertDialog.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
|
|
42
|
+
switch (attributeName) {
|
|
43
|
+
case 'label':
|
|
44
|
+
//
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
static #handleDialogClick = (evt) => {
|
|
49
|
+
console.debug(`${AlertDialog.name} ⚡️ ${evt?.type}`);
|
|
50
|
+
const dialog = evt.currentTarget instanceof HTMLDialogElement && evt.currentTarget;
|
|
51
|
+
if (!dialog)
|
|
52
|
+
return;
|
|
53
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
54
|
+
if (!target)
|
|
55
|
+
return;
|
|
56
|
+
const button = target.closest('button');
|
|
57
|
+
if (!button)
|
|
58
|
+
return;
|
|
59
|
+
button.scrollIntoView({
|
|
60
|
+
behavior: self.matchMedia('(prefers-reduced-motion: no-preference)').matches ? 'smooth' : 'instant',
|
|
61
|
+
block: 'nearest',
|
|
62
|
+
inline: 'nearest',
|
|
63
|
+
});
|
|
64
|
+
dialog.returnValue = button.value;
|
|
65
|
+
dialog.requestClose(button.value);
|
|
66
|
+
evt.stopPropagation();
|
|
67
|
+
evt.stopImmediatePropagation();
|
|
68
|
+
};
|
|
69
|
+
static #handleDialogCancel = (evt) => {
|
|
70
|
+
console.debug(`${AlertDialog.name} ⚡️ ${evt?.type}`);
|
|
71
|
+
if (!evt.cancelable)
|
|
72
|
+
return;
|
|
73
|
+
const target = evt.target instanceof HTMLDialogElement && evt.target;
|
|
74
|
+
if (!target)
|
|
75
|
+
return;
|
|
76
|
+
evt.preventDefault();
|
|
77
|
+
target.inert = true;
|
|
78
|
+
console.debug(`${AlertDialog.name} ⚡️ will-close`);
|
|
79
|
+
target.setAttribute('closing', '');
|
|
80
|
+
Promise.allSettled(target.getAnimations().map(({ finished }) => finished)).then(() => {
|
|
81
|
+
if (!target.hasAttribute('closing'))
|
|
82
|
+
return;
|
|
83
|
+
target?.close(target?.returnValue);
|
|
84
|
+
target.removeAttribute('closing');
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
static #handleDialogClose = (evt) => {
|
|
88
|
+
console.debug(`${AlertDialog.name} ⚡️ ${evt?.type}`);
|
|
89
|
+
const target = evt.target instanceof HTMLDialogElement && evt.target;
|
|
90
|
+
if (!target)
|
|
91
|
+
return;
|
|
92
|
+
target.remove();
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ButtonBase } from '../namespace-browser/base';
|
|
2
2
|
export declare class BorderedButton extends ButtonBase {
|
|
3
3
|
#private;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
4
5
|
constructor();
|
|
5
6
|
static polyfillDisconnectedCallback(el: BorderedButton): void;
|
|
6
7
|
static polyfillConnectedCallback(el: BorderedButton): void;
|
|
8
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
7
9
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import { onoff } from '../internal/utils';
|
|
2
|
+
import { buttonRole, onoff } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
export class BorderedButton extends ButtonBase {
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ['role'];
|
|
7
|
+
}
|
|
5
8
|
constructor() {
|
|
6
9
|
super();
|
|
7
10
|
}
|
|
@@ -14,6 +17,17 @@ export class BorderedButton extends ButtonBase {
|
|
|
14
17
|
el.tabIndex = 0;
|
|
15
18
|
CleanupRegistry.register(el, onoff('click', BorderedButton.#handleClick, el).on());
|
|
16
19
|
}
|
|
20
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
|
|
21
|
+
console.debug(`${BorderedButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
|
|
22
|
+
const node = target instanceof HTMLButtonElement && target;
|
|
23
|
+
if (!node)
|
|
24
|
+
return;
|
|
25
|
+
switch (attributeName) {
|
|
26
|
+
case 'role':
|
|
27
|
+
buttonRole(target, attributeName);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
17
31
|
static #handleClick = async (evt) => {
|
|
18
32
|
//
|
|
19
33
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ButtonBase } from '../namespace-browser/base';
|
|
2
2
|
export declare class BorderedProminentButton extends ButtonBase {
|
|
3
3
|
#private;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
4
5
|
constructor();
|
|
5
6
|
static polyfillDisconnectedCallback(el: BorderedProminentButton): void;
|
|
6
7
|
static polyfillConnectedCallback(el: BorderedProminentButton): void;
|
|
8
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
7
9
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import { onoff } from '../internal/utils';
|
|
2
|
+
import { buttonRole, onoff } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
export class BorderedProminentButton extends ButtonBase {
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ['role'];
|
|
7
|
+
}
|
|
5
8
|
constructor() {
|
|
6
9
|
super();
|
|
7
10
|
}
|
|
@@ -14,6 +17,17 @@ export class BorderedProminentButton extends ButtonBase {
|
|
|
14
17
|
el.tabIndex = 0;
|
|
15
18
|
CleanupRegistry.register(el, onoff('click', BorderedProminentButton.#handleClick, el).on());
|
|
16
19
|
}
|
|
20
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
|
|
21
|
+
console.debug(`${BorderedProminentButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
|
|
22
|
+
const node = target instanceof HTMLButtonElement && target;
|
|
23
|
+
if (!node)
|
|
24
|
+
return;
|
|
25
|
+
switch (attributeName) {
|
|
26
|
+
case 'role':
|
|
27
|
+
buttonRole(target, attributeName);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
17
31
|
static #handleClick = async (evt) => {
|
|
18
32
|
//
|
|
19
33
|
};
|
|
@@ -5,5 +5,5 @@ export declare class BorderlessButton extends ButtonBase {
|
|
|
5
5
|
constructor();
|
|
6
6
|
static polyfillDisconnectedCallback(el: BorderlessButton): void;
|
|
7
7
|
static polyfillConnectedCallback(el: BorderlessButton): void;
|
|
8
|
-
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]):
|
|
8
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
-
import { onoff } from '../internal/utils';
|
|
2
|
+
import { buttonRole, onoff } from '../internal/utils';
|
|
3
3
|
import { ButtonBase } from '../namespace-browser/base';
|
|
4
4
|
export class BorderlessButton extends ButtonBase {
|
|
5
5
|
static get observedAttributes() {
|
|
@@ -17,15 +17,14 @@ export class BorderlessButton extends ButtonBase {
|
|
|
17
17
|
el.tabIndex = 0;
|
|
18
18
|
CleanupRegistry.register(el, onoff('click', BorderlessButton.#handleClick, el).on());
|
|
19
19
|
}
|
|
20
|
-
static
|
|
20
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
|
|
21
21
|
console.debug(`${BorderlessButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
|
|
22
|
+
const node = target instanceof HTMLButtonElement && target;
|
|
23
|
+
if (!node)
|
|
24
|
+
return;
|
|
22
25
|
switch (attributeName) {
|
|
23
26
|
case 'role':
|
|
24
|
-
|
|
25
|
-
// if (newValue) {
|
|
26
|
-
// label ??= this.appendChild($(`<label-view slot="label"></label-view>`))
|
|
27
|
-
// label.setAttribute('title', newValue)
|
|
28
|
-
// } else label?.remove()
|
|
27
|
+
buttonRole(target, attributeName);
|
|
29
28
|
break;
|
|
30
29
|
}
|
|
31
30
|
}
|
|
@@ -5,5 +5,5 @@ export declare class ConfirmationDialog extends DialogBase {
|
|
|
5
5
|
constructor();
|
|
6
6
|
static polyfillDisconnectedCallback(el: ConfirmationDialog): void;
|
|
7
7
|
static polyfillConnectedCallback(el: ConfirmationDialog): void;
|
|
8
|
-
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]):
|
|
8
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { confirmationDialog } from '../buses';
|
|
2
2
|
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
|
-
import {
|
|
3
|
+
import { isInside, onoff, touchGlass } from '../internal/utils';
|
|
4
4
|
import { DialogBase } from '../namespace-browser/base';
|
|
5
5
|
export class ConfirmationDialog extends DialogBase {
|
|
6
6
|
static get observedAttributes() {
|
|
@@ -12,10 +12,10 @@ export class ConfirmationDialog extends DialogBase {
|
|
|
12
12
|
static polyfillDisconnectedCallback(el) {
|
|
13
13
|
console.debug(`${ConfirmationDialog.name} ⚡️ disconnect`);
|
|
14
14
|
const positionAnchor = el.style.getPropertyValue('position-anchor');
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
document.querySelector(`[style*="${positionAnchor}"]`)?.style.removeProperty('anchor-name'); //$.prop('anchor-name', null, document.querySelector<HTMLElement>(`[style*="${positionAnchor}"]`))
|
|
16
|
+
el.style.removeProperty('position-anchor'); //$.prop('position-anchor', null, el)
|
|
17
17
|
CleanupRegistry.unregister(el);
|
|
18
|
-
|
|
18
|
+
confirmationDialog.dispatchEvent(new CustomEvent('confirmation:return', {
|
|
19
19
|
detail: { returnValue: el.returnValue, positionAnchor },
|
|
20
20
|
bubbles: true,
|
|
21
21
|
composed: true,
|
|
@@ -29,7 +29,10 @@ export class ConfirmationDialog extends DialogBase {
|
|
|
29
29
|
{ types: 'cancel', listener: this.#handleDialogCancel },
|
|
30
30
|
], el).on());
|
|
31
31
|
CleanupRegistry.register(el, onoff(touchGlass(el, (t) => t, (evt) => {
|
|
32
|
-
|
|
32
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
33
|
+
if (!target)
|
|
34
|
+
return true;
|
|
35
|
+
if (target.matches('[is=confirmation-dialog]'))
|
|
33
36
|
return false;
|
|
34
37
|
// if (!(event.target as HTMLElement).closest('menu-view[open]')) return false
|
|
35
38
|
return true;
|
|
@@ -38,9 +41,10 @@ export class ConfirmationDialog extends DialogBase {
|
|
|
38
41
|
el.removeAttribute('closing');
|
|
39
42
|
el.scrollTop = 0;
|
|
40
43
|
el.returnValue = '';
|
|
44
|
+
el.autofocus = true;
|
|
41
45
|
el.showModal();
|
|
42
46
|
}
|
|
43
|
-
static
|
|
47
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
|
|
44
48
|
console.debug(`${ConfirmationDialog.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
|
|
45
49
|
// const newValue = (target as HTMLElement).getAttribute(attributeName ?? '')
|
|
46
50
|
switch (attributeName) {
|
|
@@ -55,15 +59,15 @@ export class ConfirmationDialog extends DialogBase {
|
|
|
55
59
|
}
|
|
56
60
|
static #handleDialogClick = (evt) => {
|
|
57
61
|
console.debug(`${ConfirmationDialog.name} ⚡️ ${evt?.type}`);
|
|
58
|
-
const dialog = evt.currentTarget;
|
|
62
|
+
const dialog = evt.currentTarget instanceof HTMLDialogElement && evt.currentTarget;
|
|
59
63
|
if (!dialog)
|
|
60
64
|
return;
|
|
61
|
-
const target = evt.target;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (target
|
|
65
|
-
return dialog
|
|
66
|
-
const button = target
|
|
65
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
66
|
+
if (!target)
|
|
67
|
+
return;
|
|
68
|
+
if (target.matches('dialog') && !isInside(evt.clientX, evt.clientY, dialog.getBoundingClientRect()))
|
|
69
|
+
return dialog.requestClose(); // click outside
|
|
70
|
+
const button = target.closest('button');
|
|
67
71
|
if (!button)
|
|
68
72
|
return;
|
|
69
73
|
button.scrollIntoView({
|
|
@@ -72,15 +76,15 @@ export class ConfirmationDialog extends DialogBase {
|
|
|
72
76
|
inline: 'nearest',
|
|
73
77
|
});
|
|
74
78
|
dialog.returnValue = button.value;
|
|
75
|
-
dialog
|
|
76
|
-
evt
|
|
77
|
-
evt
|
|
79
|
+
dialog.requestClose(button.value);
|
|
80
|
+
evt.stopPropagation();
|
|
81
|
+
evt.stopImmediatePropagation();
|
|
78
82
|
};
|
|
79
83
|
static #handleDialogCancel = (evt) => {
|
|
80
84
|
console.debug(`${ConfirmationDialog.name} ⚡️ ${evt?.type}`);
|
|
81
85
|
if (!evt.cancelable)
|
|
82
86
|
return;
|
|
83
|
-
const target = evt.target;
|
|
87
|
+
const target = evt.target instanceof HTMLDialogElement && evt.target;
|
|
84
88
|
if (!target)
|
|
85
89
|
return;
|
|
86
90
|
evt.preventDefault();
|
|
@@ -96,7 +100,9 @@ export class ConfirmationDialog extends DialogBase {
|
|
|
96
100
|
};
|
|
97
101
|
static #handleDialogClose = (evt) => {
|
|
98
102
|
console.debug(`${ConfirmationDialog.name} ⚡️ ${evt?.type}`);
|
|
99
|
-
const target = evt.target;
|
|
100
|
-
target
|
|
103
|
+
const target = evt.target instanceof HTMLDialogElement && evt.target;
|
|
104
|
+
if (!target)
|
|
105
|
+
return;
|
|
106
|
+
target.remove();
|
|
101
107
|
};
|
|
102
108
|
}
|
|
@@ -31,7 +31,7 @@ export class ContentUnavailableView extends HTMLElement {
|
|
|
31
31
|
</div>
|
|
32
32
|
<div part="root content-unavailable-actions-stack">
|
|
33
33
|
<slot name="actions"></slot>
|
|
34
|
-
</div
|
|
34
|
+
</div>`));
|
|
35
35
|
}
|
|
36
36
|
#shadowRoot;
|
|
37
37
|
#slots;
|
|
@@ -66,7 +66,7 @@ export class ContentUnavailableView extends HTMLElement {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
#renderSearch = (search) => {
|
|
69
|
-
const titleLabel = this.querySelector(':scope>:not([slot])') ?? this.appendChild($(`<label-view><i class="ph ph-magnifying-glass" slot="image" foreground="secondary"></i></label-view
|
|
69
|
+
const titleLabel = this.querySelector(':scope>:not([slot])') ?? this.appendChild($(`<label-view><i class="ph ph-magnifying-glass" slot="image" foreground="secondary"></i></label-view>`, '>1')), descText = this.querySelector(':scope>[slot=description]') ?? this.appendChild($(`<label-view foreground="secondary" slot="description"></label-view>`, '>1'));
|
|
70
70
|
if (search) {
|
|
71
71
|
const interpolate = (text, vars) => text.replaceAll(/\{(\w+)\}/g, (_, key) => vars[key] ?? '');
|
|
72
72
|
titleLabel.setAttribute('title', interpolate(I18n.t('SearchUnavailableContent').Label, { search }));
|
|
@@ -48,7 +48,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
48
48
|
<input type="text" name="year" inputmode="numeric" pattern="\d*" minlength="4" maxlength="4" min="0" max="9999" part="root input date-picker-form-input">
|
|
49
49
|
</div>
|
|
50
50
|
<slot name="validity-options" hidden></slot>
|
|
51
|
-
</label
|
|
51
|
+
</label>`));
|
|
52
52
|
break;
|
|
53
53
|
}
|
|
54
54
|
return _a.#templates.get(this.datePickerStyle);
|
|
@@ -99,7 +99,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
99
99
|
case 'label':
|
|
100
100
|
let label = this.querySelector(':scope>[slot=label]');
|
|
101
101
|
if (newValue) {
|
|
102
|
-
label ??= this.appendChild($(`<span slot="label"></span
|
|
102
|
+
label ??= this.appendChild($(`<span slot="label"></span>`, '>1'));
|
|
103
103
|
label.textContent = newValue;
|
|
104
104
|
}
|
|
105
105
|
else
|
|
@@ -177,7 +177,10 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
177
177
|
}
|
|
178
178
|
#handleClick = (evt) => {
|
|
179
179
|
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
180
|
-
const
|
|
180
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
181
|
+
if (!target)
|
|
182
|
+
return;
|
|
183
|
+
const input = target.closest('input');
|
|
181
184
|
if (input)
|
|
182
185
|
return;
|
|
183
186
|
this.#shadowRoot.querySelector('input.focus')?.focus?.();
|
|
@@ -217,7 +220,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
217
220
|
};
|
|
218
221
|
#handleInputPaste = (evt) => {
|
|
219
222
|
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
220
|
-
const input = evt.target;
|
|
223
|
+
const input = evt.target instanceof HTMLInputElement && evt.target;
|
|
221
224
|
if (!input)
|
|
222
225
|
return;
|
|
223
226
|
evt.preventDefault();
|
|
@@ -239,7 +242,7 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
239
242
|
};
|
|
240
243
|
#handleInputBeforeinput = (evt) => {
|
|
241
244
|
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
242
|
-
const input = evt.target;
|
|
245
|
+
const input = evt.target instanceof HTMLInputElement && evt.target;
|
|
243
246
|
if (!input)
|
|
244
247
|
return;
|
|
245
248
|
if ('insertText' !== evt.inputType)
|
|
@@ -262,6 +265,8 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
262
265
|
};
|
|
263
266
|
#handleInputKeydown = ({ type, target, key }) => {
|
|
264
267
|
console.debug(`${_a.name} ⚡️ ${type}`);
|
|
268
|
+
if (!(target instanceof HTMLInputElement && target))
|
|
269
|
+
return;
|
|
265
270
|
const input = target;
|
|
266
271
|
if (!input)
|
|
267
272
|
return;
|
|
@@ -284,7 +289,10 @@ export class DatePicker extends FormAssociatedBase {
|
|
|
284
289
|
};
|
|
285
290
|
#handleInputBlur = (evt) => {
|
|
286
291
|
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
287
|
-
const
|
|
292
|
+
const target = evt.target instanceof HTMLInputElement && evt.target;
|
|
293
|
+
if (!target)
|
|
294
|
+
return;
|
|
295
|
+
const input = target;
|
|
288
296
|
if (0 === input.value.length)
|
|
289
297
|
return;
|
|
290
298
|
const finalText = `${clamp(this.value[input.name] ?? '0', _a.#min(input), _a.#max(input))}`.padStart(parseInt(input.getAttribute('maxlength') ?? '0'), '0');
|