@swiftwc/ui 0.0.0-dev.2 → 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/README.md +15 -0
- 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 +29 -2
- package/generated/client/index.js +341 -8
- package/generated/components/alert-dialog.d.ts +8 -0
- package/generated/components/alert-dialog.js +94 -0
- package/generated/components/body-view.d.ts +5 -0
- package/generated/components/body-view.js +11 -0
- package/generated/components/bordered-button.d.ts +9 -0
- package/generated/components/bordered-button.js +34 -0
- package/generated/components/bordered-prominent-button.d.ts +9 -0
- package/generated/components/bordered-prominent-button.js +34 -0
- package/generated/components/borderless-button.d.ts +9 -0
- package/generated/components/borderless-button.js +34 -0
- package/generated/components/confirmation-dialog.d.ts +9 -0
- package/generated/components/confirmation-dialog.js +108 -0
- package/generated/components/content-unavailable-view.d.ts +24 -0
- package/generated/components/content-unavailable-view.js +78 -0
- package/generated/components/date-picker.d.ts +46 -0
- package/generated/components/date-picker.js +436 -0
- package/generated/components/disclosure-group.d.ts +9 -0
- package/generated/components/disclosure-group.js +54 -0
- package/generated/components/form-view.d.ts +6 -0
- package/generated/components/form-view.js +58 -0
- package/generated/components/glass-button.d.ts +8 -0
- package/generated/components/glass-button.js +31 -0
- package/generated/components/glass-prominent-button.d.ts +8 -0
- package/generated/components/glass-prominent-button.js +31 -0
- package/generated/components/index.d.ts +39 -1
- package/generated/components/index.js +39 -6
- package/generated/components/label-view.d.ts +9 -0
- package/generated/components/label-view.js +83 -0
- package/generated/components/list-view.d.ts +5 -0
- package/generated/components/list-view.js +29 -0
- package/generated/components/menu-view.d.ts +9 -0
- package/generated/components/menu-view.js +138 -0
- package/generated/components/navigation-large-title.d.ts +6 -0
- package/generated/components/navigation-large-title.js +177 -0
- package/generated/components/navigation-split-view.d.ts +10 -0
- package/generated/components/navigation-split-view.js +21 -0
- package/generated/components/navigation-stack.d.ts +10 -0
- package/generated/components/navigation-stack.js +27 -0
- package/generated/components/navigation-title.d.ts +8 -0
- package/generated/components/navigation-title.js +66 -0
- package/generated/components/picker-view.d.ts +27 -0
- package/generated/components/picker-view.js +448 -0
- package/generated/components/plain-button.d.ts +7 -0
- package/generated/components/plain-button.js +20 -0
- package/generated/components/screen-view.d.ts +5 -0
- package/generated/components/screen-view.js +9 -0
- package/generated/components/scroll-view-proxy.d.ts +8 -0
- package/generated/components/scroll-view-proxy.js +14 -0
- package/generated/components/scroll-view.d.ts +10 -0
- package/generated/components/scroll-view.js +196 -0
- package/generated/components/section-view.d.ts +9 -0
- package/generated/components/section-view.js +81 -0
- package/generated/components/sheet-view.d.ts +9 -0
- package/generated/components/sheet-view.js +73 -0
- package/generated/components/sidebar-toggle.d.ts +7 -0
- package/generated/components/sidebar-toggle.js +82 -0
- package/generated/components/sidebar-view.d.ts +7 -0
- package/generated/components/sidebar-view.js +35 -0
- package/generated/components/sticky-container.d.ts +6 -0
- package/generated/components/sticky-container.js +24 -0
- package/generated/components/tab-bar.d.ts +10 -0
- package/generated/components/tab-bar.js +42 -0
- package/generated/components/tab-item.d.ts +7 -0
- package/generated/components/tab-item.js +125 -0
- package/generated/components/tab-view.d.ts +22 -0
- package/generated/components/tab-view.js +259 -0
- package/generated/components/table-view.d.ts +7 -0
- package/generated/components/table-view.js +181 -0
- package/generated/components/text-field.d.ts +29 -0
- package/generated/components/text-field.js +473 -0
- package/generated/components/tool-bar-item-group.d.ts +7 -0
- package/generated/components/tool-bar-item-group.js +39 -0
- package/generated/components/tool-bar-item.d.ts +7 -0
- package/generated/components/tool-bar-item.js +49 -0
- package/generated/components/tool-bar.d.ts +7 -0
- package/generated/components/tool-bar.js +77 -0
- package/generated/components/v-keyboard.d.ts +11 -0
- package/generated/components/v-keyboard.js +81 -0
- package/generated/components/v-stack.d.ts +10 -0
- package/generated/components/v-stack.js +16 -0
- package/generated/css/index.css +7594 -0
- package/generated/events/alert-dialog.d.ts +8 -0
- package/generated/events/alert-dialog.js +1 -0
- package/generated/events/confirmation-dialog.d.ts +9 -0
- package/generated/events/confirmation-dialog.js +1 -0
- package/generated/events/date-picker.d.ts +8 -0
- package/generated/events/date-picker.js +1 -0
- package/generated/events/index.d.ts +8 -0
- package/generated/events/index.js +8 -0
- package/generated/events/lifecycle-observer.d.ts +10 -0
- package/generated/events/lifecycle-observer.js +1 -0
- package/generated/events/picker-view.d.ts +8 -0
- package/generated/events/picker-view.js +1 -0
- package/generated/events/scroll-view.d.ts +10 -0
- package/generated/events/scroll-view.js +1 -0
- package/generated/events/tab-view.d.ts +24 -0
- package/generated/events/tab-view.js +1 -0
- package/generated/events/text-field.d.ts +8 -0
- package/generated/events/text-field.js +1 -0
- package/generated/i18n/index.d.ts +34 -0
- package/generated/i18n/index.js +167 -0
- package/generated/i18n/locales/el.d.ts +17 -0
- package/generated/i18n/locales/el.js +17 -0
- package/generated/i18n/locales/en.d.ts +17 -0
- package/generated/i18n/locales/en.js +17 -0
- package/generated/i18n/locales/index.d.ts +4 -0
- package/generated/i18n/locales/index.js +4 -0
- package/generated/index.js +1 -1
- package/generated/internal/class/cleanup-registry.d.ts +5 -0
- package/generated/internal/class/cleanup-registry.js +38 -0
- package/generated/internal/class/css-style-observer.d.ts +8 -0
- package/generated/internal/class/css-style-observer.js +25 -0
- package/generated/internal/class/form-associated-base.d.ts +20 -0
- package/generated/internal/class/form-associated-base.js +96 -0
- package/generated/internal/class/mutation-observer-singleton.d.ts +10 -0
- package/generated/internal/class/mutation-observer-singleton.js +46 -0
- package/generated/internal/class/navigation-path.d.ts +15 -0
- package/generated/internal/class/navigation-path.js +84 -0
- package/generated/internal/class/navigation-view.d.ts +8 -0
- package/generated/internal/class/navigation-view.js +77 -0
- package/generated/internal/class/resize-observer-singleton.d.ts +7 -0
- package/generated/internal/class/resize-observer-singleton.js +22 -0
- package/generated/internal/decorators/custom-element.d.ts +5 -0
- package/generated/internal/decorators/custom-element.js +4 -0
- package/generated/internal/privateNamespace.d.ts +4 -0
- package/generated/internal/privateNamespace.js +1 -0
- package/generated/internal/utils/add.d.ts +1 -0
- package/generated/internal/utils/add.js +7 -0
- package/generated/internal/utils/button-role.d.ts +1 -0
- package/generated/internal/utils/button-role.js +19 -0
- package/generated/internal/utils/cash/ancestors.d.ts +1 -0
- package/generated/internal/utils/cash/ancestors.js +27 -0
- package/generated/internal/utils/cash/index.d.ts +23 -0
- package/generated/internal/utils/cash/index.js +25 -0
- package/generated/internal/utils/cash/next-all.d.ts +1 -0
- package/generated/internal/utils/cash/next-all.js +10 -0
- package/generated/internal/utils/cash/next.d.ts +1 -0
- package/generated/internal/utils/cash/next.js +9 -0
- package/generated/internal/utils/cash/prev-all.d.ts +1 -0
- package/generated/internal/utils/cash/prev-all.js +10 -0
- package/generated/internal/utils/cash/prev.d.ts +1 -0
- package/generated/internal/utils/cash/prev.js +9 -0
- package/generated/internal/utils/cash/prop.d.ts +18 -0
- package/generated/internal/utils/cash/prop.js +30 -0
- package/generated/internal/utils/cash/siblings.d.ts +1 -0
- package/generated/internal/utils/cash/siblings.js +10 -0
- package/generated/internal/utils/clamp.d.ts +1 -0
- package/generated/internal/utils/clamp.js +4 -0
- package/generated/internal/utils/compare-big-decimals.d.ts +1 -0
- package/generated/internal/utils/compare-big-decimals.js +90 -0
- package/generated/internal/utils/css-time.d.ts +1 -0
- package/generated/internal/utils/css-time.js +3 -0
- package/generated/internal/utils/debounce.d.ts +1 -0
- package/generated/internal/utils/debounce.js +13 -0
- package/generated/internal/utils/frame.d.ts +1 -0
- package/generated/internal/utils/frame.js +6 -0
- package/generated/internal/utils/index.d.ts +20 -1
- package/generated/internal/utils/index.js +21 -1
- package/generated/internal/utils/is-inside.d.ts +1 -0
- package/generated/internal/utils/is-inside.js +4 -0
- package/generated/internal/utils/kebab-case.d.ts +1 -1
- package/generated/internal/utils/kebab-case.js +3 -3
- package/generated/internal/utils/list-active.d.ts +7 -0
- package/generated/internal/utils/list-active.js +83 -0
- package/generated/internal/utils/microtask.d.ts +1 -0
- package/generated/internal/utils/microtask.js +3 -0
- package/generated/internal/utils/onoff.d.ts +45 -0
- package/generated/internal/utils/onoff.js +31 -0
- package/generated/internal/utils/set.d.ts +1 -0
- package/generated/internal/utils/set.js +7 -0
- package/generated/internal/utils/sleep.d.ts +1 -0
- package/generated/internal/utils/sleep.js +3 -0
- package/generated/internal/utils/slow-hide-show.d.ts +1 -0
- package/generated/internal/utils/slow-hide-show.js +16 -0
- package/generated/internal/utils/timeout.d.ts +5 -0
- package/generated/internal/utils/timeout.js +16 -0
- package/generated/internal/utils/toolbar-repositioner.d.ts +1 -0
- package/generated/internal/utils/toolbar-repositioner.js +12 -0
- package/generated/internal/utils/touch-glass.d.ts +7 -0
- package/generated/internal/utils/touch-glass.js +19 -0
- package/generated/namespace-browser/base.d.ts +36 -0
- package/generated/namespace-browser/base.js +92 -0
- package/generated/namespace-browser/index.d.ts +7 -0
- package/generated/namespace-browser/index.js +1 -0
- package/generated/snapshot/index.d.ts +9 -0
- package/generated/snapshot/index.js +58 -0
- package/package.json +36 -9
- package/scss/_base.scss +5 -0
- package/scss/_components.scss +79 -0
- package/scss/_final.scss +1 -0
- package/scss/_functions.scss +31 -0
- package/scss/_mixins.scss +3 -0
- package/scss/_placeholders.scss +3 -0
- package/scss/_transitions.scss +28 -0
- package/scss/_utils.scss +9 -0
- package/scss/_vars.scss +174 -3
- package/scss/base/_layout.scss +56 -0
- package/scss/base/_reboot.scss +160 -0
- package/scss/base/_root.scss +396 -0
- package/scss/colors/_index.scss +635 -0
- package/scss/components/_alert-dialog.scss +106 -0
- package/scss/components/_body-view.scss +17 -0
- package/scss/components/_bordered-button.scss +30 -0
- package/scss/components/_bordered-prominent-button.scss +27 -0
- package/scss/components/_borderless-button.scss +27 -0
- package/scss/components/_confirmation-dialog.scss +110 -0
- package/scss/components/_content-unavailable-view.scss +45 -0
- package/scss/components/_date-picker.scss +30 -0
- package/scss/components/_detail-placeholder.scss +153 -0
- package/scss/components/_disclosure-group.scss +128 -0
- package/scss/components/_form-view.scss +195 -0
- package/scss/components/_full-screen.scss +15 -0
- package/scss/components/_glass-button.scss +32 -0
- package/scss/components/_glass-prominent-button.scss +32 -0
- package/scss/components/_h-divider.scss +13 -0
- package/scss/components/_h-flex-stack.scss +23 -0
- package/scss/components/_h-stack.scss +29 -0
- package/scss/components/_index.scss +246 -0
- package/scss/components/_label-view.scss +393 -0
- package/scss/components/_labeled-content.scss +9 -0
- package/scss/components/_list-view.scss +229 -0
- package/scss/components/_menu-view.scss +188 -0
- package/scss/components/_navigation-large-title.scss +27 -0
- package/scss/components/_navigation-split-view.scss +424 -0
- package/scss/components/_navigation-stack.scss +11 -0
- package/scss/components/_navigation-title.scss +10 -0
- package/scss/components/_picker-view.scss +122 -0
- package/scss/components/_plain-button.scss +18 -0
- package/scss/components/_scroll-view-proxy.scss +79 -0
- package/scss/components/_scroll-view-toolbars.scss +126 -0
- package/scss/components/_scroll-view.scss +130 -0
- package/scss/components/_section-view.scss +119 -0
- package/scss/components/_sheet-view.scss +102 -0
- package/scss/components/_sidebar-toggle.scss +121 -0
- package/scss/components/_sidebar-view.scss +53 -0
- package/scss/components/_sticky-container.scss +42 -0
- package/scss/components/_tab-bar.scss +255 -0
- package/scss/components/_tab-item.scss +25 -0
- package/scss/components/_tab-view.scss +312 -0
- package/scss/components/_table-column.scss +52 -0
- package/scss/components/_table-row.scss +172 -0
- package/scss/components/_table-view.scss +223 -0
- package/scss/components/_text-field.scss +37 -0
- package/scss/components/_tool-bar-item-group.scss +48 -0
- package/scss/components/_tool-bar-item.scss +145 -0
- package/scss/components/_tool-bar.scss +128 -0
- package/scss/components/_v-divider.scss +13 -0
- package/scss/components/_v-flex-stack.scss +29 -0
- package/scss/components/_v-keyboard.scss +14 -0
- package/scss/components/_v-stack.scss +25 -0
- package/scss/final/_touch-glass.scss +91 -0
- package/scss/index.scss +15 -6
- package/scss/mixins/_dialog.scss +89 -0
- package/scss/mixins/_index.scss +422 -0
- package/scss/placeholders/_buttons.scss +125 -0
- package/scss/placeholders/_lists.scss +561 -0
- package/scss/transitions/_alert-dialog.scss +19 -0
- package/scss/transitions/_bwd.navbar.scss +19 -0
- package/scss/transitions/_bwd.scss +39 -0
- package/scss/transitions/_confirmation-dialog.scss +19 -0
- package/scss/transitions/_dialog.scss +28 -0
- package/scss/transitions/_disclosure-group.scss +35 -0
- package/scss/transitions/_fwd.navbar.scss +41 -0
- package/scss/transitions/_fwd.scss +24 -0
- package/scss/transitions/_glass-button.scss +12 -0
- package/scss/transitions/_glass-prominent-button.scss +12 -0
- package/scss/transitions/_index.scss +74 -0
- package/scss/transitions/_menu-view.scss +26 -0
- package/scss/transitions/_navigation-split-view.scss +23 -0
- package/scss/transitions/_sidebar-view.scss +36 -0
- package/scss/transitions/_tab-bar.scss +19 -0
- package/scss/utils/_frame.scss +91 -0
- package/scss/utils/_index.scss +68 -0
- package/scss/utils/_scroll-view.scss +14 -0
- package/scss/utils/_spacing.scss +25 -0
- package/scss/utils/_stacks.scss +247 -0
- package/web-components.html-data/en.json +423 -0
- package/generated/internal/snapshot.d.ts +0 -5
- package/generated/internal/snapshot.js +0 -23
- package/generated/styles.css +0 -8
- package/scss/_reboot.scss +0 -11
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @swiftwc/ui
|
|
2
|
+
|
|
3
|
+
[README](https://github.com/swiftwc/ui/blob/main/README.md)
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
Visit [swiftwc.github.io/ui/](https://swiftwc.github.io/ui/) to view the documentation.
|
|
8
|
+
|
|
9
|
+
## Contributing
|
|
10
|
+
|
|
11
|
+
Please read the [contributing guide](https://github.com/swiftwc/ui/blob/main/CONTRIBUTING.md).
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
Licensed under the [MIT license](https://github.com/swiftwc/ui/blob/main/LICENSE.md).
|
|
@@ -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,2 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { lifecycleObserver } from '../buses';
|
|
2
|
+
import { I18n } from '../i18n';
|
|
3
|
+
import { NavigationPath } from '../internal/class/navigation-path';
|
|
4
|
+
import { type WebComponentCtor } from '../namespace-browser';
|
|
5
|
+
import { Snapshot } from '../snapshot';
|
|
6
|
+
export declare const polyfills: Map<string, WebComponentCtor>;
|
|
7
|
+
type TransitionType = 'forwards' | 'backwards' | 'reload';
|
|
8
|
+
type UpdateCallback = () => void | Promise<void>;
|
|
9
|
+
type NavigateOptions = {
|
|
10
|
+
updateCallback?: UpdateCallback;
|
|
11
|
+
tos?: () => NavigationPath[];
|
|
12
|
+
};
|
|
13
|
+
export declare const startViewTransition: (target: HTMLElement, type?: TransitionType, updateCallbackOrOptions?: UpdateCallback | NavigateOptions) => Promise<void>;
|
|
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,8 +1,341 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Snapshot
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { alertDialog, confirmationDialog as confirmationDialogBus, lifecycleObserver } from '../buses';
|
|
2
|
+
import * as Components from '../components';
|
|
3
|
+
import { I18n } from '../i18n';
|
|
4
|
+
import { NavigationPath } from '../internal/class/navigation-path';
|
|
5
|
+
import { $, kebabCase, onoff } from '../internal/utils';
|
|
6
|
+
import { Snapshot } from '../snapshot';
|
|
7
|
+
export const polyfills = new Map();
|
|
8
|
+
for (const [k, Ctor] of Object.entries(Components)) {
|
|
9
|
+
const is = kebabCase(k);
|
|
10
|
+
if ('polyfillExtends' in Ctor && 'string' === typeof Ctor.polyfillExtends) {
|
|
11
|
+
if (customElements.get(is))
|
|
12
|
+
continue;
|
|
13
|
+
customElements.define(is, Ctor, { extends: Ctor.polyfillExtends });
|
|
14
|
+
if (!(document.createElement(Ctor.polyfillExtends, { is }) instanceof Ctor))
|
|
15
|
+
polyfills.set(is, Ctor);
|
|
16
|
+
// const testEl = document.createElement('template')
|
|
17
|
+
// testEl.innerHTML = `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`
|
|
18
|
+
// const testNode = testEl.content.firstElementChild,
|
|
19
|
+
if (!($(`<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`, '>1') instanceof Ctor))
|
|
20
|
+
polyfills.set(is, Ctor);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (!customElements.get(is))
|
|
24
|
+
customElements.define(is, Ctor);
|
|
25
|
+
}
|
|
26
|
+
console.debug(polyfills);
|
|
27
|
+
if (0 < polyfills.size) {
|
|
28
|
+
const polyfillTagNamesCache = new Set([...polyfills.values()].map((v) => String(v.polyfillExtends ?? '').toUpperCase()).filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
|
|
29
|
+
const handlers = new WeakMap();
|
|
30
|
+
const observe = (el, polyfill) => {
|
|
31
|
+
if (!Array.isArray(polyfill.observedAttributes))
|
|
32
|
+
return;
|
|
33
|
+
if (0 === polyfill?.observedAttributes.length)
|
|
34
|
+
return;
|
|
35
|
+
if (!polyfill.polyfillAttributeChangedCallback)
|
|
36
|
+
return;
|
|
37
|
+
const observer = new MutationObserver(polyfill.polyfillAttributeChangedCallback);
|
|
38
|
+
observer.observe(el, {
|
|
39
|
+
attributes: true,
|
|
40
|
+
attributeFilter: polyfill.observedAttributes,
|
|
41
|
+
attributeOldValue: true,
|
|
42
|
+
});
|
|
43
|
+
handlers.set(el, observer);
|
|
44
|
+
for (const attributeName of polyfill.observedAttributes)
|
|
45
|
+
if (el.hasAttribute(attributeName)) {
|
|
46
|
+
const entry = {
|
|
47
|
+
attributeName,
|
|
48
|
+
oldValue: null,
|
|
49
|
+
target: el,
|
|
50
|
+
};
|
|
51
|
+
polyfill.polyfillAttributeChangedCallback([entry]);
|
|
52
|
+
}
|
|
53
|
+
}, unobserve = (el) => {
|
|
54
|
+
handlers.delete(el);
|
|
55
|
+
}, polyfillTagNamesCacheSelector = [...polyfillTagNamesCache.values()].map((v) => `${v}`.toLowerCase()).join(','), flatten = (node) => [node, ...(node.querySelectorAll?.(polyfillTagNamesCacheSelector) ?? [])];
|
|
56
|
+
console.debug(polyfillTagNamesCache, polyfillTagNamesCacheSelector);
|
|
57
|
+
for (const [is, polyfill] of polyfills)
|
|
58
|
+
for (const el of document.querySelectorAll(`${polyfill.polyfillExtends}[is="${CSS.escape(is)}"]`)) {
|
|
59
|
+
polyfill.polyfillConnectedCallback(el);
|
|
60
|
+
observe(el, polyfill);
|
|
61
|
+
}
|
|
62
|
+
// observer callback
|
|
63
|
+
const observer = new MutationObserver((mutations) => {
|
|
64
|
+
for (const { addedNodes, removedNodes } of mutations) {
|
|
65
|
+
for (const root of addedNodes) {
|
|
66
|
+
if (!(root instanceof HTMLElement))
|
|
67
|
+
continue;
|
|
68
|
+
for (const node of flatten(root)) {
|
|
69
|
+
if (!(node instanceof HTMLElement))
|
|
70
|
+
continue;
|
|
71
|
+
if (!polyfillTagNamesCache.has(node.tagName))
|
|
72
|
+
continue;
|
|
73
|
+
const is = node?.getAttribute('is') ?? '';
|
|
74
|
+
if (!polyfills.has(is))
|
|
75
|
+
continue;
|
|
76
|
+
polyfills.get(is)?.polyfillConnectedCallback(node);
|
|
77
|
+
observe(node, polyfills.get(is));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const root of removedNodes) {
|
|
81
|
+
if (!(root instanceof HTMLElement))
|
|
82
|
+
continue;
|
|
83
|
+
for (const node of flatten(root)) {
|
|
84
|
+
if (!(node instanceof HTMLElement))
|
|
85
|
+
continue;
|
|
86
|
+
if (!polyfillTagNamesCache.has(node.tagName))
|
|
87
|
+
continue;
|
|
88
|
+
const is = node?.getAttribute('is') ?? '';
|
|
89
|
+
if (!polyfills.has(is))
|
|
90
|
+
continue;
|
|
91
|
+
polyfills.get(is)?.polyfillDisconnectedCallback(node);
|
|
92
|
+
unobserve(node);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
observer.observe(document.body, {
|
|
98
|
+
childList: true,
|
|
99
|
+
subtree: true,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// SECTION: Safari polyfill
|
|
103
|
+
document.addEventListener('touchstart', () => { }, { passive: true });
|
|
104
|
+
// SECTION: Transitions
|
|
105
|
+
const cleanup = (lm, type) => {
|
|
106
|
+
let arr = [Snapshot.config['vt-fwd-class-name'], 'fwdd', 'fwn', 'fwnn', 'bwd', 'bwdd', 'bwn', 'bwnn'];
|
|
107
|
+
if (['backwards', 'forwards'].includes(type ?? ''))
|
|
108
|
+
for (let i = arr.length - 1; i >= 0; i--)
|
|
109
|
+
if (arr[i].startsWith('backwards' === type ? 'fw' : 'bw'))
|
|
110
|
+
arr.splice(i, 1);
|
|
111
|
+
for (const el of [...(lm?.querySelectorAll(arr.map((v) => `.${v}`).join(',')) ?? [])])
|
|
112
|
+
el.classList.remove(...arr);
|
|
113
|
+
};
|
|
114
|
+
export const startViewTransition = async (target, type = 'forwards', updateCallbackOrOptions = async () => { }) => {
|
|
115
|
+
console.debug(`startViewTransition (${type})`, target);
|
|
116
|
+
if (!(target instanceof HTMLElement))
|
|
117
|
+
throw new TypeError("Argument 1 ('target') to client.startViewTransition must be an instance of HTMLElement");
|
|
118
|
+
if (!['forwards', 'backwards', 'reload'].includes(type))
|
|
119
|
+
throw new TypeError("Argument 2 ('type') to client.startViewTransition must be of TransitionType");
|
|
120
|
+
const options = typeof updateCallbackOrOptions === 'function'
|
|
121
|
+
? {
|
|
122
|
+
updateCallback: updateCallbackOrOptions,
|
|
123
|
+
}
|
|
124
|
+
: (updateCallbackOrOptions ?? {}), updateCallback = options.updateCallback ?? (async () => { });
|
|
125
|
+
await Snapshot.waitReady;
|
|
126
|
+
const from = new NavigationPath(target); //const from = closestBody(target) //event.target as HTMLElement)
|
|
127
|
+
if ('forwards' === type) {
|
|
128
|
+
await updateCallback(); // updatetheDOMSomehow
|
|
129
|
+
// Snapshot.getSnapshot(from)
|
|
130
|
+
// const root = getRootViewController(from)
|
|
131
|
+
// const oldPath = new NavigationPath(from)
|
|
132
|
+
const root = [from, ...from.parents()]
|
|
133
|
+
.map((item) => item.component)
|
|
134
|
+
.filter(Boolean)
|
|
135
|
+
.at(-1);
|
|
136
|
+
// const { toolBarConfig: oldToolbars } = getComputedView(from) // const { toolBarConfig: oldToolbars, slot: oldSLot, page: oldPage } = getComputedView(from) //
|
|
137
|
+
// console.log(88, oldPage, oldPath.page, oldSLot, oldPath.slot, oldToolbars, oldPath.toolBarConfig)
|
|
138
|
+
// const oldToolbars = Snapshot.toolbarItems
|
|
139
|
+
// const { toolBarConfig: oldToolbars, host: oldHost } = getComputedView(from)
|
|
140
|
+
const tos = options.tos?.() ?? [...from.children()].map((item) => item?.hydrate()), //queryBodyAll(oldSLot), //[...oldPath.children()].map((item) => item.body).filter(Boolean),//
|
|
141
|
+
to = tos.at(-1),
|
|
142
|
+
// to = newPath?.body, //tos.slice(-1)?.pop?.(), //Snapshot.leaf, //
|
|
143
|
+
// newHost = newPath?.component, //{ host: newHost } = getComputedView(to),
|
|
144
|
+
newToolbars = tos.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item),
|
|
145
|
+
// .map((item) => item.toolBarConfig)
|
|
146
|
+
// .flat()
|
|
147
|
+
// .filter(Boolean), //queryToolbarConfigAll(oldSLot),
|
|
148
|
+
modalViews = tos.map((item) => item.component).filter((item) => !!item && item.matches('dialog')); //[...queryHostAll(oldPage)].filter?.((item) => item?.matches('dialog'))
|
|
149
|
+
// toFrame = Snapshot.leafContainer, //queryHostAll(from).slice(-1)?.pop?.(),
|
|
150
|
+
// toToolbars = Snapshot.leafToolbarItems
|
|
151
|
+
// dialogFrames = [toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item): item is HTMLDialogElement => item instanceof HTMLDialogElement) //[toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item) => item?.matches('dialog'))
|
|
152
|
+
// if ('DIALOG' === newHost?.tagName) {
|
|
153
|
+
// ;(newHost as HTMLDialogElement).showModal()
|
|
154
|
+
// console.debug(`⚡️ view-transition-start (${type})`)
|
|
155
|
+
// await Promise.allSettled(newHost.getAnimations().map(({ finished }) => finished))
|
|
156
|
+
// console.debug(`⚡️ view-transition-end (${type})`)
|
|
157
|
+
// return
|
|
158
|
+
// }
|
|
159
|
+
// purge
|
|
160
|
+
cleanup(root, 'backwards');
|
|
161
|
+
// prepare old
|
|
162
|
+
from.body?.classList.add(Snapshot.config['vt-fwd-class-name']);
|
|
163
|
+
from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
|
|
164
|
+
for (const oldToolbar of from.toolBarConfig ?? [])
|
|
165
|
+
oldToolbar.classList.add('fwn'); // prepare navbs
|
|
166
|
+
// prepare new
|
|
167
|
+
const toolbarExclusion = 0 < modalViews.length
|
|
168
|
+
? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar,body-view ~ tool-bar)')
|
|
169
|
+
: (value, index, array) => value.parentElement?.matches('tool-bar:not(body-view ~ tool-bar)'), bodyExclusion = 0 < modalViews.length ? (item) => item.body?.matches('scroll-view:not(dialog scroll-view)') : (value, index, array) => value;
|
|
170
|
+
for (const bti of newToolbars?.filter?.(toolbarExclusion) ?? [])
|
|
171
|
+
bti.classList.add('fwnn'); // for (const ti of newToolbars ?? []) ti.classList.add('fwnn') //
|
|
172
|
+
for (const bt of tos?.filter?.(bodyExclusion) ?? []) {
|
|
173
|
+
bt.body?.classList.add('fwdd'); //to?.classList.add('fwdd')
|
|
174
|
+
bt.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: bt.body }, bubbles: true, composed: true }));
|
|
175
|
+
}
|
|
176
|
+
if (0 < modalViews.length) {
|
|
177
|
+
for await (const el of modalViews)
|
|
178
|
+
el.showModal();
|
|
179
|
+
console.debug(`⚡️ view-dialog-transition-start (${type})`);
|
|
180
|
+
await Promise.allSettled(modalViews?.[0].getAnimations().map(({ finished }) => finished));
|
|
181
|
+
console.debug(`⚡️ view-dialog-transition-end (${type})`);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
console.debug(`⚡️ view-transition-start (${type})`);
|
|
185
|
+
await Promise.allSettled([...(from.body?.getAnimations().map(({ finished }) => finished) ?? []), ...(to?.body?.getAnimations().map(({ finished }) => finished) ?? [])]);
|
|
186
|
+
console.debug(`⚡️ view-transition-end (${type})`);
|
|
187
|
+
}
|
|
188
|
+
if (0 < (to?.component?.querySelectorAll(`.${Snapshot.config?.['vt-fwd-class-name']},.bwd`) ?? []).length)
|
|
189
|
+
return;
|
|
190
|
+
cleanup(root);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
// Snapshot.getSnapshot(from)
|
|
194
|
+
// const oldPath = new NavigationPath(from)
|
|
195
|
+
const root = [from, ...from.parents()]
|
|
196
|
+
.map((item) => item.component)
|
|
197
|
+
.filter(Boolean)
|
|
198
|
+
.at(-1); // const root = getRootViewController(from)
|
|
199
|
+
//const { toolBarConfig: oldToolbars, host: oldHost, page: oldPage, slot: oldSlot } = getComputedView(from)
|
|
200
|
+
const froms = [...from.children()].map((item) => item?.hydrate());
|
|
201
|
+
const oldToolbars = froms.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item), oldBodies = froms.map((item) => item.body).filter((item) => !!item);
|
|
202
|
+
// console.log(99, queryToolbarConfigAll(oldSlot), oldToolbars)
|
|
203
|
+
// if most-top effect is closing a modal, skip everything
|
|
204
|
+
if ('DIALOG' === from.component?.tagName) {
|
|
205
|
+
from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
|
|
206
|
+
from.component.close();
|
|
207
|
+
console.debug(`⚡️ view-dialog-transition-start (${type})`);
|
|
208
|
+
await Promise.allSettled(from.component.getAnimations().map(({ finished }) => finished));
|
|
209
|
+
console.debug(`⚡️ view-dialog-transition-end (${type})`);
|
|
210
|
+
if (from.component.matches('[open]'))
|
|
211
|
+
return;
|
|
212
|
+
await updateCallback();
|
|
213
|
+
return; // just close modal
|
|
214
|
+
}
|
|
215
|
+
const to = [...from.parents()].at(0)?.hydrate(); //closestBody(oldPath.component?.parentElement ?? undefined)
|
|
216
|
+
// console.log(99, to)
|
|
217
|
+
if (!to)
|
|
218
|
+
return console.debug('Can not go backwards.'); // nothing to go back to
|
|
219
|
+
const tv = to.body?.closest('tab-view');
|
|
220
|
+
if (tv && to.body?.matches('tab-view>navigation-stack:has(> navigation-stack,> navigation-split-view)>:scope'))
|
|
221
|
+
if ('bottom-bar' !== tv.tabBarPlacement)
|
|
222
|
+
return;
|
|
223
|
+
// const { toolBarConfig: newToolbars } = getComputedView(to.body)
|
|
224
|
+
// purge
|
|
225
|
+
cleanup(root, 'forwards');
|
|
226
|
+
// prepare new
|
|
227
|
+
for (const ti of to.toolBarConfig ?? [])
|
|
228
|
+
ti.classList.add('bwnn');
|
|
229
|
+
to.body?.classList.add('bwdd');
|
|
230
|
+
to.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: to.body }, bubbles: true, composed: true }));
|
|
231
|
+
// prepare old
|
|
232
|
+
const inbetweenModals = froms.map((item) => item.component).filter((item) => !!item && item.matches('dialog[open]')), //queryHostAll(oldPage).filter?.((item) => item.matches('dialog[open]')) ?? [], // FIXME: TEst this, added oldHost too
|
|
233
|
+
toolbarExclusion = 0 < inbetweenModals.length
|
|
234
|
+
? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar)')
|
|
235
|
+
: (value, index, array) => value, bodyExclusion = 0 < inbetweenModals.length ? (item) => item?.matches('scroll-view:not(dialog scroll-view)') : (item) => item;
|
|
236
|
+
for (const ti of [...(from.toolBarConfig ?? []), ...(oldToolbars?.filter?.(toolbarExclusion) ?? [])])
|
|
237
|
+
ti.classList.add('bwn');
|
|
238
|
+
for (const nn of [from.body, ...oldBodies?.filter?.(bodyExclusion)]) {
|
|
239
|
+
nn?.classList.add('bwd'); //from?.classList.add('bwd')
|
|
240
|
+
nn?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: nn }, bubbles: true, composed: true }));
|
|
241
|
+
}
|
|
242
|
+
for (const el of inbetweenModals)
|
|
243
|
+
el.close(); // close old inbetween modals
|
|
244
|
+
// capture trans
|
|
245
|
+
console.debug(`⚡️ view-transition-start (${type})`);
|
|
246
|
+
await Promise.allSettled([...(from.body?.getAnimations().map(({ finished }) => finished) ?? []), ...(to.body?.getAnimations().map(({ finished }) => finished) ?? [])]);
|
|
247
|
+
console.debug(`⚡️ view-transition-end (${type})`);
|
|
248
|
+
if (to.body?.closest(`.bwd,.${Snapshot.config?.['vt-fwd-class-name']}`))
|
|
249
|
+
return;
|
|
250
|
+
cleanup(root);
|
|
251
|
+
// remove or hide
|
|
252
|
+
await updateCallback();
|
|
253
|
+
}
|
|
254
|
+
};
|
|
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'));
|
|
257
|
+
if (title) {
|
|
258
|
+
const label = $(`<label-view font="headline"></label-view>`, '>1');
|
|
259
|
+
label.setAttribute('title', title);
|
|
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);
|
|
314
|
+
}
|
|
315
|
+
trigger.closest('body-view')?.insertAdjacentElement('beforeend', dialog); // dialog.showModal()
|
|
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
|
+
// })
|
|
338
|
+
};
|
|
339
|
+
void Snapshot.waitReady; // void Snapshot.setOwnConfig()
|
|
340
|
+
// SECTION
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonBase } from '../namespace-browser/base';
|
|
2
|
+
export declare class BorderedButton extends ButtonBase {
|
|
3
|
+
#private;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
constructor();
|
|
6
|
+
static polyfillDisconnectedCallback(el: BorderedButton): void;
|
|
7
|
+
static polyfillConnectedCallback(el: BorderedButton): void;
|
|
8
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
+
import { buttonRole, onoff } from '../internal/utils';
|
|
3
|
+
import { ButtonBase } from '../namespace-browser/base';
|
|
4
|
+
export class BorderedButton extends ButtonBase {
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ['role'];
|
|
7
|
+
}
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
static polyfillDisconnectedCallback(el) {
|
|
12
|
+
console.debug(`${BorderedButton.name} ⚡️ disconnect`);
|
|
13
|
+
CleanupRegistry.unregister(el);
|
|
14
|
+
}
|
|
15
|
+
static polyfillConnectedCallback(el) {
|
|
16
|
+
console.debug(`${BorderedButton.name} ⚡️ connect`);
|
|
17
|
+
el.tabIndex = 0;
|
|
18
|
+
CleanupRegistry.register(el, onoff('click', BorderedButton.#handleClick, el).on());
|
|
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
|
+
}
|
|
31
|
+
static #handleClick = async (evt) => {
|
|
32
|
+
//
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonBase } from '../namespace-browser/base';
|
|
2
|
+
export declare class BorderedProminentButton extends ButtonBase {
|
|
3
|
+
#private;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
constructor();
|
|
6
|
+
static polyfillDisconnectedCallback(el: BorderedProminentButton): void;
|
|
7
|
+
static polyfillConnectedCallback(el: BorderedProminentButton): void;
|
|
8
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
+
import { buttonRole, onoff } from '../internal/utils';
|
|
3
|
+
import { ButtonBase } from '../namespace-browser/base';
|
|
4
|
+
export class BorderedProminentButton extends ButtonBase {
|
|
5
|
+
static get observedAttributes() {
|
|
6
|
+
return ['role'];
|
|
7
|
+
}
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
static polyfillDisconnectedCallback(el) {
|
|
12
|
+
console.debug(`${BorderedProminentButton.name} ⚡️ disconnect`);
|
|
13
|
+
CleanupRegistry.unregister(el);
|
|
14
|
+
}
|
|
15
|
+
static polyfillConnectedCallback(el) {
|
|
16
|
+
console.debug(`${BorderedProminentButton.name} ⚡️ connect`);
|
|
17
|
+
el.tabIndex = 0;
|
|
18
|
+
CleanupRegistry.register(el, onoff('click', BorderedProminentButton.#handleClick, el).on());
|
|
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
|
+
}
|
|
31
|
+
static #handleClick = async (evt) => {
|
|
32
|
+
//
|
|
33
|
+
};
|
|
34
|
+
}
|