@swiftwc/ui 0.0.0-dev.20 → 0.0.0-dev.22

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 (113) 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 +6 -0
  14. package/generated/components/bordered-button.js +22 -1
  15. package/generated/components/bordered-prominent-button.d.ts +6 -0
  16. package/generated/components/bordered-prominent-button.js +22 -1
  17. package/generated/components/borderless-button.d.ts +5 -1
  18. package/generated/components/borderless-button.js +13 -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 +24 -10
  23. package/generated/components/disclosure-group.js +4 -1
  24. package/generated/components/glass-button.d.ts +6 -0
  25. package/generated/components/glass-button.js +22 -1
  26. package/generated/components/glass-prominent-button.d.ts +6 -0
  27. package/generated/components/glass-prominent-button.js +22 -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 -35
  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 +35 -25
  34. package/generated/components/scroll-view.js +27 -13
  35. package/generated/components/section-view.js +3 -3
  36. package/generated/components/sheet-view.d.ts +1 -2
  37. package/generated/components/sheet-view.js +38 -22
  38. package/generated/components/sidebar-toggle.js +6 -4
  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 +11 -8
  44. package/generated/components/table-view.js +22 -10
  45. package/generated/components/text-field.js +37 -32
  46. package/generated/components/tool-bar-item-group.js +17 -0
  47. package/generated/components/tool-bar-item.js +20 -1
  48. package/generated/components/tool-bar.d.ts +12 -0
  49. package/generated/components/tool-bar.js +20 -7
  50. package/generated/components/v-stack.d.ts +5 -0
  51. package/generated/components/v-stack.js +5 -0
  52. package/generated/css/index.css +377 -86
  53. package/generated/events/alert-dialog.d.ts +8 -0
  54. package/generated/events/alert-dialog.js +1 -0
  55. package/generated/events/confirmation-dialog.d.ts +2 -2
  56. package/generated/events/index.d.ts +1 -0
  57. package/generated/events/index.js +1 -0
  58. package/generated/events/tab-view.d.ts +6 -2
  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/css-style-observer.js +1 -1
  64. package/generated/internal/class/form-associated-base.js +4 -1
  65. package/generated/internal/class/navigation-view.js +4 -4
  66. package/generated/internal/utils/button-role.d.ts +1 -0
  67. package/generated/internal/utils/button-role.js +39 -0
  68. package/generated/internal/utils/cash/index.d.ts +4 -3
  69. package/generated/internal/utils/cash/index.js +6 -4
  70. package/generated/internal/utils/index.d.ts +2 -0
  71. package/generated/internal/utils/index.js +2 -0
  72. package/generated/internal/utils/is-inside.d.ts +1 -0
  73. package/generated/internal/utils/is-inside.js +4 -0
  74. package/generated/internal/utils/list-active.js +15 -5
  75. package/generated/snapshot/index.d.ts +2 -0
  76. package/generated/snapshot/index.js +21 -0
  77. package/package.json +7 -4
  78. package/scss/_components.scss +2 -0
  79. package/scss/_functions.scss +10 -0
  80. package/scss/_transitions.scss +1 -0
  81. package/scss/_vars.scss +5 -0
  82. package/scss/base/_reboot.scss +10 -0
  83. package/scss/colors/_index.scss +39 -21
  84. package/scss/components/_alert-dialog.scss +106 -0
  85. package/scss/components/_bordered-button.scss +14 -0
  86. package/scss/components/_bordered-prominent-button.scss +13 -0
  87. package/scss/components/_borderless-button.scss +4 -0
  88. package/scss/components/_confirmation-dialog.scss +39 -39
  89. package/scss/components/_content-unavailable-view.scss +1 -1
  90. package/scss/components/_disclosure-group.scss +80 -33
  91. package/scss/components/_glass-button.scss +14 -0
  92. package/scss/components/_glass-prominent-button.scss +14 -0
  93. package/scss/components/_h-stack.scss +3 -13
  94. package/scss/components/_index.scss +1 -0
  95. package/scss/components/_label-view.scss +42 -16
  96. package/scss/components/_label-view.scss.txt +536 -0
  97. package/scss/components/_sheet-view.scss +13 -3
  98. package/scss/components/_tab-bar.scss +5 -0
  99. package/scss/components/_tool-bar-item.scss +19 -0
  100. package/scss/components/_tool-bar.scss +25 -0
  101. package/scss/components/_v-stack.scss +3 -13
  102. package/scss/final/_touch-glass.scss +7 -0
  103. package/scss/mixins/_index.scss +17 -0
  104. package/scss/placeholders/_buttons.scss +87 -10
  105. package/scss/transitions/_alert-dialog.scss +19 -0
  106. package/scss/transitions/_tab-bar.scss +6 -5
  107. package/scss/utils/_frame.scss +7 -0
  108. package/web-components.html-data/en.json +81 -13
  109. package/generated/confirmation-dialog/index.d.ts +0 -1
  110. package/generated/confirmation-dialog/index.js +0 -1
  111. package/generated/lifecycle-observer/index.d.ts +0 -1
  112. package/generated/lifecycle-observer/index.js +0 -1
  113. 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,13 @@
1
1
  import { ButtonBase } from '../namespace-browser/base';
2
+ /**
3
+ * @slot overlay
4
+ *
5
+ */
2
6
  export declare class BorderedButton extends ButtonBase {
3
7
  #private;
8
+ static get observedAttributes(): string[];
4
9
  constructor();
5
10
  static polyfillDisconnectedCallback(el: BorderedButton): void;
6
11
  static polyfillConnectedCallback(el: BorderedButton): void;
12
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
7
13
  }
@@ -1,7 +1,15 @@
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
+ import { Snapshot } from '../snapshot';
5
+ /**
6
+ * @slot overlay
7
+ *
8
+ */
4
9
  export class BorderedButton extends ButtonBase {
10
+ static get observedAttributes() {
11
+ return ['role'];
12
+ }
5
13
  constructor() {
6
14
  super();
7
15
  }
@@ -14,6 +22,19 @@ export class BorderedButton extends ButtonBase {
14
22
  el.tabIndex = 0;
15
23
  CleanupRegistry.register(el, onoff('click', BorderedButton.#handleClick, el).on());
16
24
  }
25
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
26
+ console.debug(`${BorderedButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
27
+ const node = target instanceof HTMLButtonElement && target;
28
+ if (!node)
29
+ return;
30
+ switch (attributeName) {
31
+ case 'role':
32
+ Snapshot.waitReady.then(() => {
33
+ buttonRole(target, attributeName);
34
+ });
35
+ break;
36
+ }
37
+ }
17
38
  static #handleClick = async (evt) => {
18
39
  //
19
40
  };
@@ -1,7 +1,13 @@
1
1
  import { ButtonBase } from '../namespace-browser/base';
2
+ /**
3
+ * @slot overlay
4
+ *
5
+ */
2
6
  export declare class BorderedProminentButton extends ButtonBase {
3
7
  #private;
8
+ static get observedAttributes(): string[];
4
9
  constructor();
5
10
  static polyfillDisconnectedCallback(el: BorderedProminentButton): void;
6
11
  static polyfillConnectedCallback(el: BorderedProminentButton): void;
12
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
7
13
  }
@@ -1,7 +1,15 @@
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
+ import { Snapshot } from '../snapshot';
5
+ /**
6
+ * @slot overlay
7
+ *
8
+ */
4
9
  export class BorderedProminentButton extends ButtonBase {
10
+ static get observedAttributes() {
11
+ return ['role'];
12
+ }
5
13
  constructor() {
6
14
  super();
7
15
  }
@@ -14,6 +22,19 @@ export class BorderedProminentButton extends ButtonBase {
14
22
  el.tabIndex = 0;
15
23
  CleanupRegistry.register(el, onoff('click', BorderedProminentButton.#handleClick, el).on());
16
24
  }
25
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
26
+ console.debug(`${BorderedProminentButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
27
+ const node = target instanceof HTMLButtonElement && target;
28
+ if (!node)
29
+ return;
30
+ switch (attributeName) {
31
+ case 'role':
32
+ Snapshot.waitReady.then(() => {
33
+ buttonRole(target, attributeName);
34
+ });
35
+ break;
36
+ }
37
+ }
17
38
  static #handleClick = async (evt) => {
18
39
  //
19
40
  };
@@ -1,9 +1,13 @@
1
1
  import { ButtonBase } from '../namespace-browser/base';
2
+ /**
3
+ * @slot overlay
4
+ *
5
+ */
2
6
  export declare class BorderlessButton extends ButtonBase {
3
7
  #private;
4
8
  static get observedAttributes(): string[];
5
9
  constructor();
6
10
  static polyfillDisconnectedCallback(el: BorderlessButton): void;
7
11
  static polyfillConnectedCallback(el: BorderlessButton): void;
8
- static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): Promise<void>;
12
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
9
13
  }
@@ -1,6 +1,11 @@
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
+ import { Snapshot } from '../snapshot';
5
+ /**
6
+ * @slot overlay
7
+ *
8
+ */
4
9
  export class BorderlessButton extends ButtonBase {
5
10
  static get observedAttributes() {
6
11
  return ['role'];
@@ -17,15 +22,16 @@ export class BorderlessButton extends ButtonBase {
17
22
  el.tabIndex = 0;
18
23
  CleanupRegistry.register(el, onoff('click', BorderlessButton.#handleClick, el).on());
19
24
  }
20
- static async polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
25
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
21
26
  console.debug(`${BorderlessButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
27
+ const node = target instanceof HTMLButtonElement && target;
28
+ if (!node)
29
+ return;
22
30
  switch (attributeName) {
23
31
  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()
32
+ Snapshot.waitReady.then(() => {
33
+ buttonRole(target, attributeName);
34
+ });
29
35
  break;
30
36
  }
31
37
  }
@@ -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 }));