@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.
Files changed (99) hide show
  1. package/generated/buses/alert-dialog.d.ts +2 -0
  2. package/generated/buses/alert-dialog.js +1 -0
  3. package/generated/buses/confirmation-dialog.d.ts +2 -0
  4. package/generated/buses/confirmation-dialog.js +1 -0
  5. package/generated/buses/index.d.ts +6 -0
  6. package/generated/buses/index.js +6 -0
  7. package/generated/buses/lifecycle-observer.d.ts +2 -0
  8. package/generated/buses/lifecycle-observer.js +1 -0
  9. package/generated/client/index.d.ts +17 -4
  10. package/generated/client/index.js +83 -32
  11. package/generated/components/alert-dialog.d.ts +8 -0
  12. package/generated/components/alert-dialog.js +94 -0
  13. package/generated/components/bordered-button.d.ts +2 -0
  14. package/generated/components/bordered-button.js +15 -1
  15. package/generated/components/bordered-prominent-button.d.ts +2 -0
  16. package/generated/components/bordered-prominent-button.js +15 -1
  17. package/generated/components/borderless-button.d.ts +1 -1
  18. package/generated/components/borderless-button.js +6 -7
  19. package/generated/components/confirmation-dialog.d.ts +1 -1
  20. package/generated/components/confirmation-dialog.js +26 -20
  21. package/generated/components/content-unavailable-view.js +2 -2
  22. package/generated/components/date-picker.js +14 -6
  23. package/generated/components/disclosure-group.js +4 -1
  24. package/generated/components/glass-button.d.ts +2 -0
  25. package/generated/components/glass-button.js +15 -1
  26. package/generated/components/glass-prominent-button.d.ts +2 -0
  27. package/generated/components/glass-prominent-button.js +15 -1
  28. package/generated/components/index.d.ts +1 -0
  29. package/generated/components/index.js +1 -0
  30. package/generated/components/label-view.js +3 -3
  31. package/generated/components/menu-view.js +12 -7
  32. package/generated/components/navigation-title.js +4 -4
  33. package/generated/components/picker-view.js +16 -10
  34. package/generated/components/scroll-view.js +19 -10
  35. package/generated/components/section-view.js +3 -3
  36. package/generated/components/sheet-view.d.ts +1 -1
  37. package/generated/components/sheet-view.js +21 -17
  38. package/generated/components/sidebar-toggle.js +5 -3
  39. package/generated/components/sidebar-view.js +10 -4
  40. package/generated/components/sticky-container.js +3 -1
  41. package/generated/components/tab-bar.js +10 -4
  42. package/generated/components/tab-item.js +3 -1
  43. package/generated/components/tab-view.js +4 -1
  44. package/generated/components/table-view.js +11 -5
  45. package/generated/components/text-field.js +28 -28
  46. package/generated/components/tool-bar-item-group.d.ts +2 -0
  47. package/generated/components/tool-bar-item-group.js +28 -0
  48. package/generated/components/tool-bar-item.d.ts +2 -0
  49. package/generated/components/tool-bar-item.js +32 -2
  50. package/generated/components/tool-bar.js +1 -1
  51. package/generated/components/v-stack.d.ts +5 -0
  52. package/generated/components/v-stack.js +5 -0
  53. package/generated/css/index.css +128 -37
  54. package/generated/events/alert-dialog.d.ts +8 -0
  55. package/generated/events/alert-dialog.js +1 -0
  56. package/generated/events/confirmation-dialog.d.ts +2 -2
  57. package/generated/events/index.d.ts +1 -0
  58. package/generated/events/index.js +1 -0
  59. package/generated/i18n/locales/el.d.ts +9 -0
  60. package/generated/i18n/locales/el.js +9 -0
  61. package/generated/i18n/locales/en.d.ts +9 -0
  62. package/generated/i18n/locales/en.js +9 -0
  63. package/generated/internal/class/form-associated-base.js +4 -1
  64. package/generated/internal/class/navigation-view.js +4 -4
  65. package/generated/internal/utils/button-role.d.ts +1 -0
  66. package/generated/internal/utils/button-role.js +19 -0
  67. package/generated/internal/utils/cash/index.d.ts +4 -3
  68. package/generated/internal/utils/cash/index.js +6 -4
  69. package/generated/internal/utils/index.d.ts +3 -0
  70. package/generated/internal/utils/index.js +3 -0
  71. package/generated/internal/utils/is-inside.d.ts +1 -0
  72. package/generated/internal/utils/is-inside.js +4 -0
  73. package/generated/internal/utils/list-active.js +15 -5
  74. package/generated/internal/utils/toolbar-repositioner.d.ts +1 -0
  75. package/generated/internal/utils/toolbar-repositioner.js +12 -0
  76. package/generated/snapshot/index.d.ts +2 -0
  77. package/generated/snapshot/index.js +21 -0
  78. package/package.json +7 -4
  79. package/scss/_components.scss +2 -0
  80. package/scss/_functions.scss +10 -0
  81. package/scss/_transitions.scss +1 -0
  82. package/scss/colors/_index.scss +2 -2
  83. package/scss/components/_alert-dialog.scss +106 -0
  84. package/scss/components/_confirmation-dialog.scss +39 -39
  85. package/scss/components/_h-stack.scss +3 -13
  86. package/scss/components/_index.scss +1 -0
  87. package/scss/components/_sheet-view.scss +11 -1
  88. package/scss/components/_v-stack.scss +3 -13
  89. package/scss/final/_touch-glass.scss +7 -0
  90. package/scss/mixins/_index.scss +17 -0
  91. package/scss/placeholders/_buttons.scss +42 -0
  92. package/scss/transitions/_alert-dialog.scss +19 -0
  93. package/scss/utils/_frame.scss +7 -0
  94. package/web-components.html-data/en.json +84 -7
  95. package/generated/confirmation-dialog/index.d.ts +0 -1
  96. package/generated/confirmation-dialog/index.js +0 -1
  97. package/generated/lifecycle-observer/index.d.ts +0 -1
  98. package/generated/lifecycle-observer/index.js +0 -1
  99. package/scss/components/_components.scss +0 -76
@@ -0,0 +1,2 @@
1
+ declare const _default: EventTarget;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default new EventTarget();
@@ -0,0 +1,2 @@
1
+ declare const _default: EventTarget;
2
+ export default _default;
@@ -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,2 @@
1
+ declare const _default: EventTarget;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default new EventTarget();
@@ -1,7 +1,6 @@
1
- import { ConfirmationDialog } from '../confirmation-dialog';
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 confirmationDialog: (trigger: HTMLElement, title: string, entries: Array<[string, any]>, controller?: AbortController) => Promise<unknown>;
16
- export { ConfirmationDialog, I18n, LifecycleObserver, NavigationPath, Snapshot };
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}>`) instanceof Ctor))
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
- void polyfill.polyfillAttributeChangedCallback([entry]);
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 confirmationDialog = async (trigger, title, entries, controller = new AbortController()) => {
257
- const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
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
- dialog.insertAdjacentElement('afterbegin', label);
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
- return await new Promise((resolve, reject) => {
272
- const onClose = (evt) => {
273
- off();
274
- resolve(evt.detail.returnValue);
275
- }, off = onoff('return', onClose, ConfirmationDialog, { once: true }).on();
276
- // const onAbort = () => {
277
- // cleanup()
278
- // reject(new DOMException('aborted', 'AbortError'))
279
- // }
280
- // const cleanup = () => {
281
- // ConfirmationDialog.removeEventListener('close', onClose)
282
- // // controller.signal.removeEventListener('abort', onAbort)
283
- // }
284
- // ConfirmationDialog.addEventListener('close', onClose, { once: true })
285
- // controller.signal.addEventListener('abort', onAbort, { once: true })
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 { ConfirmationDialog, I18n, LifecycleObserver, NavigationPath, Snapshot };
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'>[]): Promise<void>;
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 async polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
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
- // let label = this.querySelector(':scope>[slot=label]')
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'>[]): Promise<void>;
8
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
9
9
  }
@@ -1,6 +1,6 @@
1
- import { ConfirmationDialog as EvtBus } from '../confirmation-dialog';
1
+ import { confirmationDialog } from '../buses';
2
2
  import { CleanupRegistry } from '../internal/class/cleanup-registry';
3
- import { $, onoff, touchGlass } from '../internal/utils';
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
- $.prop('anchor-name', null, document.querySelector(`[style*="${positionAnchor}"]`));
16
- $.prop('position-anchor', null, el);
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
- EvtBus.dispatchEvent(new CustomEvent('return', {
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
- if (evt.target.matches('[is=confirmation-dialog]'))
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 async polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
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
- const rect = dialog.getBoundingClientRect();
63
- const isInside = evt.clientX >= rect.left && evt.clientX <= rect.right && evt.clientY >= rect.top && evt.clientY <= rect.bottom;
64
- if (target?.matches('dialog') && !isInside)
65
- return dialog?.requestClose(); // click outside
66
- const button = target?.closest('button');
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?.requestClose(button.value);
76
- evt?.stopPropagation();
77
- evt?.stopImmediatePropagation();
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?.remove();
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>`)), descText = this.querySelector(':scope>[slot=description]') ?? this.appendChild($(`<label-view foreground="secondary" slot="description"></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 input = evt.target?.closest('input');
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 input = evt.target;
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');