@swiftwc/ui 0.0.0-dev.3 → 0.0.0-dev.31
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 +31 -2
- package/generated/client/index.js +415 -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 +13 -0
- package/generated/components/bordered-button.js +42 -0
- package/generated/components/bordered-prominent-button.d.ts +13 -0
- package/generated/components/bordered-prominent-button.js +42 -0
- package/generated/components/borderless-button.d.ts +13 -0
- package/generated/components/borderless-button.js +42 -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 +442 -0
- package/generated/components/disclosure-group.d.ts +9 -0
- package/generated/components/disclosure-group.js +54 -0
- package/generated/components/fine-tooltip.d.ts +7 -0
- package/generated/components/fine-tooltip.js +104 -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 +12 -0
- package/generated/components/glass-button.js +39 -0
- package/generated/components/glass-prominent-button.d.ts +12 -0
- package/generated/components/glass-prominent-button.js +39 -0
- package/generated/components/index.d.ts +41 -1
- package/generated/components/index.js +41 -6
- package/generated/components/label-view.d.ts +9 -0
- package/generated/components/label-view.js +56 -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 +49 -0
- package/generated/components/picker-view.d.ts +27 -0
- package/generated/components/picker-view.js +452 -0
- package/generated/components/plain-button.d.ts +7 -0
- package/generated/components/plain-button.js +20 -0
- package/generated/components/progress-view.d.ts +13 -0
- package/generated/components/progress-view.js +122 -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 +197 -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 +8 -0
- package/generated/components/sheet-view.js +85 -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 +187 -0
- package/generated/components/text-field.d.ts +29 -0
- package/generated/components/text-field.js +478 -0
- package/generated/components/tool-bar-item-group.d.ts +5 -0
- package/generated/components/tool-bar-item-group.js +28 -0
- package/generated/components/tool-bar-item.d.ts +7 -0
- package/generated/components/tool-bar-item.js +53 -0
- package/generated/components/tool-bar.d.ts +19 -0
- package/generated/components/tool-bar.js +90 -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 +8067 -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 +28 -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 +15 -0
- package/generated/i18n/locales/el.js +15 -0
- package/generated/i18n/locales/en.d.ts +15 -0
- package/generated/i18n/locales/en.js +15 -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 +59 -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 +19 -1
- package/generated/internal/utils/index.js +20 -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/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 +82 -0
- package/scss/_final.scss +1 -0
- package/scss/_functions.scss +31 -0
- package/scss/_mixins.scss +7 -0
- package/scss/_placeholders.scss +3 -0
- package/scss/_transitions.scss +32 -0
- package/scss/_utils.scss +9 -0
- package/scss/_vars.scss +179 -3
- package/scss/base/_layout.scss +56 -0
- package/scss/base/_reboot.scss +191 -0
- package/scss/base/_root.scss +397 -0
- package/scss/colors/_index.scss +704 -0
- package/scss/components/_alert-dialog.scss +111 -0
- package/scss/components/_body-view.scss +17 -0
- package/scss/components/_bordered-button.scss +57 -0
- package/scss/components/_bordered-prominent-button.scss +63 -0
- package/scss/components/_borderless-button.scss +44 -0
- package/scss/components/_confirmation-dialog.scss +117 -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 +175 -0
- package/scss/components/_fine-tooltip.scss +82 -0
- package/scss/components/_form-view.scss +195 -0
- package/scss/components/_full-screen.scss +15 -0
- package/scss/components/_glass-button.scss +59 -0
- package/scss/components/_glass-prominent-button.scss +68 -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 +249 -0
- package/scss/components/_label-view copy.scss.txt +420 -0
- package/scss/components/_label-view.scss +355 -0
- package/scss/components/_label-view.scss.txt +536 -0
- package/scss/components/_labeled-content.scss +9 -0
- package/scss/components/_list-view.scss +229 -0
- package/scss/components/_menu-view.scss +205 -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/_progress-view.scss +98 -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 +260 -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 +97 -0
- package/scss/components/_tool-bar.scss +153 -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/_button.scss +44 -0
- package/scss/mixins/_color.scss +16 -0
- package/scss/mixins/_dialog.scss +89 -0
- package/scss/mixins/_index.scss +422 -0
- package/scss/placeholders/_buttons.scss +117 -0
- package/scss/placeholders/_lists.scss +561 -0
- package/scss/transitions/_alert-dialog.scss +18 -0
- package/scss/transitions/_bwd.navbar.scss +19 -0
- package/scss/transitions/_bwd.scss +39 -0
- package/scss/transitions/_confirmation-dialog.scss +13 -0
- package/scss/transitions/_disclosure-group.scss +35 -0
- package/scss/transitions/_fine-tooltip.scss +21 -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/_progress-view.scss +23 -0
- package/scss/transitions/_sheet-view.scss +30 -0
- package/scss/transitions/_sidebar-view.scss +36 -0
- package/scss/transitions/_tab-bar.scss +20 -0
- package/scss/utils/_frame.scss +91 -0
- package/scss/utils/_index.scss +77 -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 +458 -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
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { lifecycleObserver } from '../buses';
|
|
3
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
4
|
+
import { ResizeObserverSingleton } from '../internal/class/resize-observer-singleton';
|
|
5
|
+
import { $, frame, onoff, slowHideShow } from '../internal/utils';
|
|
6
|
+
const observers = new ResizeObserverSingleton();
|
|
7
|
+
export class ScrollView extends HTMLElement {
|
|
8
|
+
static get observedAttributes() {
|
|
9
|
+
return ['navigation-title', 'navigation-inline-title', 'navigation-inline-subtitle', 'navigation-bar-title-display-mode'];
|
|
10
|
+
}
|
|
11
|
+
static #template;
|
|
12
|
+
static get template() {
|
|
13
|
+
return (this.#template ??= $(String.raw `
|
|
14
|
+
<slot></slot>
|
|
15
|
+
<div part="root scroll-view-navbar">
|
|
16
|
+
<div part="root scroll-view-navbar-stack">
|
|
17
|
+
<slot name="top-bar-principal"></slot>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
<div part="root scroll-view-toolbar">
|
|
21
|
+
<div part="root scroll-view-toolbar-stack">
|
|
22
|
+
<slot name="bottom-bar-principal"></slot>
|
|
23
|
+
</div>
|
|
24
|
+
</div>`));
|
|
25
|
+
}
|
|
26
|
+
#shadowRoot;
|
|
27
|
+
#slots = new Map();
|
|
28
|
+
// #navbarPrincipalSlot?: HTMLSlotElement
|
|
29
|
+
#isMidScroll;
|
|
30
|
+
#lastScrollTop = 0;
|
|
31
|
+
// #stopRecordingScrollTop?: boolean = false
|
|
32
|
+
#beforeTabSwapLastScrolltop;
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
36
|
+
this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
|
|
37
|
+
for (const slot of this.#shadowRoot.querySelectorAll('slot'))
|
|
38
|
+
this.#slots?.set(slot.name, slot);
|
|
39
|
+
CleanupRegistry.register(this, () => {
|
|
40
|
+
this.#slots = new Map();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
console.debug(`${_a.name} ⚡️ disconnect`);
|
|
45
|
+
CleanupRegistry.unregister(this);
|
|
46
|
+
observers.unobserve(this);
|
|
47
|
+
frame().then(() => lifecycleObserver.dispatchEvent(new CustomEvent('pagehide', { detail: { page: this }, bubbles: true, composed: true })));
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
console.debug(`${_a.name} ⚡️ connect`);
|
|
51
|
+
CleanupRegistry.register(this, onoff([
|
|
52
|
+
// { types: 'tabreveal', listener: this.#handleTabReveal as EventListener },
|
|
53
|
+
{ types: 'beforetabswap', listener: this.#handleTabBeforeswap },
|
|
54
|
+
], this.closest('tab-view') ?? undefined).on());
|
|
55
|
+
CleanupRegistry.register(this, onoff([
|
|
56
|
+
{ types: 'scroll', listener: this.#handleScroll, addOptions: { passive: true } },
|
|
57
|
+
{ types: 'scrollend', listener: this.#handleScrollend, addOptions: { passive: true } },
|
|
58
|
+
], this).on());
|
|
59
|
+
frame().then(() => lifecycleObserver.dispatchEvent(new CustomEvent('pageshow', { detail: { page: this }, bubbles: true, composed: true })));
|
|
60
|
+
observers.observe(this, this.#handleMeasure.bind(this));
|
|
61
|
+
// frame(this).then((r) => {
|
|
62
|
+
// if (!r) return
|
|
63
|
+
// let first = true
|
|
64
|
+
// observeResizeEnd(this, () => {
|
|
65
|
+
// if (first) {
|
|
66
|
+
// first = false
|
|
67
|
+
// return
|
|
68
|
+
// }
|
|
69
|
+
// this.dispatchEvent(new CustomEvent('resizeend', { bubbles: true, composed: true }))
|
|
70
|
+
// })
|
|
71
|
+
// })
|
|
72
|
+
}
|
|
73
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
74
|
+
console.debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
75
|
+
switch (name) {
|
|
76
|
+
case 'navigation-inline-title':
|
|
77
|
+
this.#renderNavTitle(newValue, this.getAttribute('navigation-inline-subtitle'));
|
|
78
|
+
break;
|
|
79
|
+
case 'navigation-inline-subtitle':
|
|
80
|
+
this.#renderNavTitle(this.getAttribute('navigation-inline-title'), newValue);
|
|
81
|
+
break;
|
|
82
|
+
case 'navigation-title':
|
|
83
|
+
//
|
|
84
|
+
break;
|
|
85
|
+
case 'navigation-bar-title-display-mode':
|
|
86
|
+
if (oldValue === newValue)
|
|
87
|
+
break;
|
|
88
|
+
if (this.closest('[hidden]'))
|
|
89
|
+
break; // iREPAINT ALERT! if (0 === this.offsetHeight + this.offsetWidth) break
|
|
90
|
+
if (!this.#isMidScroll)
|
|
91
|
+
break;
|
|
92
|
+
const title = this.#slots?.get('top-bar-principal')?.assignedElements({ flatten: true })?.at(0);
|
|
93
|
+
slowHideShow('largeinline' === `${oldValue}${newValue}` ? 'show' : 'hide', title);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
#handleScroll = (evt) => {
|
|
98
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
99
|
+
if (!this.#isMidScroll)
|
|
100
|
+
this.#isMidScroll = true;
|
|
101
|
+
// if (this.#stopRecordingScrollTop) return
|
|
102
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
103
|
+
if (!target)
|
|
104
|
+
return;
|
|
105
|
+
this.#lastScrollTop = target.scrollTop;
|
|
106
|
+
};
|
|
107
|
+
#handleScrollend = (evt) => {
|
|
108
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
109
|
+
if (this.#isMidScroll)
|
|
110
|
+
this.#isMidScroll = false;
|
|
111
|
+
};
|
|
112
|
+
#handleMeasure = (entry) => {
|
|
113
|
+
console.debug(`${_a.name} ⚡️ measure`);
|
|
114
|
+
if (0 === entry.contentRect.width + entry.contentRect.height)
|
|
115
|
+
return;
|
|
116
|
+
if (undefined === this.#beforeTabSwapLastScrolltop)
|
|
117
|
+
return;
|
|
118
|
+
if (this.#beforeTabSwapLastScrolltop === this.#lastScrollTop)
|
|
119
|
+
return;
|
|
120
|
+
// this.#stopRecordingScrollTop = true
|
|
121
|
+
entry.target.scrollTop = this.#beforeTabSwapLastScrolltop;
|
|
122
|
+
// entry.target.scrollTo({
|
|
123
|
+
// top: this.#beforeTabSwapLastScrolltop,
|
|
124
|
+
// behavior: 'smooth',
|
|
125
|
+
// }) //
|
|
126
|
+
// this.#stopRecordingScrollTop = false
|
|
127
|
+
this.#beforeTabSwapLastScrolltop = undefined;
|
|
128
|
+
};
|
|
129
|
+
#handleTabReveal = (evt) => {
|
|
130
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
131
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
132
|
+
if (!target)
|
|
133
|
+
return;
|
|
134
|
+
if (!target.contains(this))
|
|
135
|
+
return;
|
|
136
|
+
if (this.closest('[hidden]'))
|
|
137
|
+
return;
|
|
138
|
+
// console.log(888, this.#beforeTabSwapLastScrolltop, this.#lastScrollTop)
|
|
139
|
+
// this.style.setProperty('clip-path', 'inset(50%)')
|
|
140
|
+
// this.style.setProperty('opacity', '0.001')
|
|
141
|
+
// this.style.opacity = '0.001'
|
|
142
|
+
// console.log(99, this.style.opacity)
|
|
143
|
+
// self.requestAnimationFrame(() => {
|
|
144
|
+
// if (undefined === this.#beforeTabSwapLastScrolltop) return
|
|
145
|
+
// if (this.#beforeTabSwapLastScrolltop === this.#lastScrollTop) return
|
|
146
|
+
// this.#stopRecordingScrollTop = true
|
|
147
|
+
// // console.log(999, this.#beforeTabSwapLastScrolltop)
|
|
148
|
+
// // console.log(999, this, this.#beforeTabSwapLastScrolltop, this.#lastScrollTop)
|
|
149
|
+
// this.scrollTop = this.#beforeTabSwapLastScrolltop
|
|
150
|
+
// // this.scrollTo({
|
|
151
|
+
// // top: this.#beforeTabSwapLastScrolltop,
|
|
152
|
+
// // behavior: 'instant',
|
|
153
|
+
// // }) //
|
|
154
|
+
// this.#stopRecordingScrollTop = false
|
|
155
|
+
// this.#beforeTabSwapLastScrolltop = undefined
|
|
156
|
+
// // self.requestAnimationFrame(() => {
|
|
157
|
+
// // // this.style.removeProperty('opacity')
|
|
158
|
+
// // })
|
|
159
|
+
// })
|
|
160
|
+
};
|
|
161
|
+
#handleTabBeforeswap = (evt) => {
|
|
162
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
163
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
164
|
+
if (!target)
|
|
165
|
+
return;
|
|
166
|
+
if (!target.contains(this))
|
|
167
|
+
return;
|
|
168
|
+
if (this.closest('[hidden]'))
|
|
169
|
+
return;
|
|
170
|
+
this.#beforeTabSwapLastScrolltop = this.scrollTop; //#lastScrollTop
|
|
171
|
+
};
|
|
172
|
+
centerScrollToElement(child) {
|
|
173
|
+
// scrollTop needed to center child
|
|
174
|
+
const parentRect = this.getBoundingClientRect(), childRect = child.getBoundingClientRect();
|
|
175
|
+
// current scroll + offset of child relative to parent
|
|
176
|
+
const top = this.scrollTop + childRect.top - parentRect.top - parentRect.height / 2 + childRect.height / 2;
|
|
177
|
+
this.scrollTo({
|
|
178
|
+
top,
|
|
179
|
+
behavior: self.matchMedia('(prefers-reduced-motion: no-preference)').matches ? 'smooth' : 'instant', // optional: smooth scroll
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
#renderNavTitle = (title, subtitle) => {
|
|
183
|
+
const titleTemplate = `<label-view line-limit="1" truncation-mode="tail" font="headline"></label-view>`, subtitleTemplate = `<label-view line-limit="1" truncation-mode="tail" foreground="secondary" font="callout"></label-view>`;
|
|
184
|
+
const vStack = this.querySelector(':scope>[slot=top-bar-principal]') ?? this.appendChild($(`<v-stack spacing="0" alignment="fill" slot="top-bar-principal">${titleTemplate}${subtitleTemplate}</v-stack>`, '>1'));
|
|
185
|
+
const titleLabel = vStack.querySelector(':scope>label-view:nth-child(1)') ?? vStack.appendChild($(titleTemplate, '>1'));
|
|
186
|
+
if (title)
|
|
187
|
+
titleLabel.setAttribute('title', title);
|
|
188
|
+
else
|
|
189
|
+
titleLabel?.removeAttribute('title');
|
|
190
|
+
let subtitleLabel = vStack.querySelector(':scope>label-view:nth-child(2)') ?? vStack.appendChild($(subtitleTemplate, '>1'));
|
|
191
|
+
if (subtitle)
|
|
192
|
+
subtitleLabel.setAttribute('title', subtitle);
|
|
193
|
+
else
|
|
194
|
+
subtitleLabel?.removeAttribute('title');
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
_a = ScrollView;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class SectionView extends HTMLElement {
|
|
2
|
+
#private;
|
|
3
|
+
static get observedAttributes(): string[];
|
|
4
|
+
static get template(): DocumentFragment;
|
|
5
|
+
constructor();
|
|
6
|
+
disconnectedCallback(): void;
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { $ } from '../internal/utils';
|
|
2
|
+
export class SectionView extends HTMLElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return ['header', 'footer'];
|
|
5
|
+
}
|
|
6
|
+
static #template;
|
|
7
|
+
static get template() {
|
|
8
|
+
return (this.#template ??= $(String.raw `
|
|
9
|
+
<div part="root section-main-stack">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</div>
|
|
12
|
+
<div part="root section-header-stack">
|
|
13
|
+
<slot name="header"></slot>
|
|
14
|
+
</div>
|
|
15
|
+
<div part="root section-footer-stack">
|
|
16
|
+
<slot name="footer"></slot>
|
|
17
|
+
</div>`));
|
|
18
|
+
// <div class="sticky-sentinel" style="grid-area:sentinel;inline-size:100%;block-size:0.1px;pointer-events:none;"></div>
|
|
19
|
+
}
|
|
20
|
+
#shadowRoot;
|
|
21
|
+
// #observer?: IntersectionObserver
|
|
22
|
+
// #sibling?: HTMLElement
|
|
23
|
+
// #sentinel?: HTMLElement
|
|
24
|
+
// #sentinelIsIntersecting: boolean = false
|
|
25
|
+
// #isIntersecting: boolean = false
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.#shadowRoot = this.attachShadow({ mode: 'closed' });
|
|
29
|
+
// Snapshot.waitReady.then(() => {
|
|
30
|
+
this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
|
|
31
|
+
// this.#sentinel = this.#shadowRoot.querySelector('.sticky-sentinel') ?? undefined
|
|
32
|
+
// })
|
|
33
|
+
}
|
|
34
|
+
disconnectedCallback() {
|
|
35
|
+
console.debug(`${SectionView.name} ⚡️ disconnect`);
|
|
36
|
+
// if (this.#sentinel) this.#observer?.unobserve(this.#sentinel)
|
|
37
|
+
// this.#observer?.unobserve(this)
|
|
38
|
+
}
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
console.debug(`${SectionView.name} ⚡️ connect`);
|
|
41
|
+
// this.#sibling = this.closest('scroll-view') ?? undefined
|
|
42
|
+
// Snapshot.waitReady.then(() => {
|
|
43
|
+
// if (!(await frame(this))) return // NOTE: Required or BREAKS transitions // self.requestAnimationFrame(() => {
|
|
44
|
+
// if (!this.isConnected) return
|
|
45
|
+
// const blockSizeProp = getComputedStyle(this).getPropertyValue('--navigation-bar-block-size') || '0', //`${document.documentElement.computedStyleMap().get(`--navigation-bar-block-size`) ?? '0'}`, //
|
|
46
|
+
// blockSize = parseFloat(blockSizeProp) * (blockSizeProp.endsWith('rem') ? parseFloat(getComputedStyle(document.documentElement).fontSize) : 1)
|
|
47
|
+
// this.#observer = new IntersectionObserver(this.#handleIntersect, {
|
|
48
|
+
// root: this.#sibling,
|
|
49
|
+
// rootMargin: `-${blockSize}px 0px 0px 0px`,
|
|
50
|
+
// threshold: [0, 1],
|
|
51
|
+
// })
|
|
52
|
+
// if (this.#sentinel) this.#observer.observe(this.#sentinel)
|
|
53
|
+
// this.#observer.observe(this)
|
|
54
|
+
// })
|
|
55
|
+
}
|
|
56
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
57
|
+
console.debug(`${SectionView.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
|
|
58
|
+
// Snapshot.waitReady.then(() => {
|
|
59
|
+
switch (name) {
|
|
60
|
+
case 'header':
|
|
61
|
+
let header = this.querySelector(':scope>[slot=header]');
|
|
62
|
+
if (newValue) {
|
|
63
|
+
header ??= this.appendChild($(`<header slot="header"><label-view line-limit="1" truncation-mode="tail" font="callout"></label-view></header>`, '>1'));
|
|
64
|
+
header.querySelector('label-view')?.setAttribute('title', newValue);
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
header?.remove();
|
|
68
|
+
break;
|
|
69
|
+
case 'footer':
|
|
70
|
+
let footer = this.querySelector(':scope>[slot=footer]');
|
|
71
|
+
if (newValue) {
|
|
72
|
+
footer ??= this.appendChild($(`<footer slot="footer"><label-view line-limit="1" truncation-mode="tail" font="callout"></label-view></footer>`, '>1'));
|
|
73
|
+
footer.querySelector('label-view')?.setAttribute('title', newValue);
|
|
74
|
+
}
|
|
75
|
+
else
|
|
76
|
+
footer?.remove();
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
// })
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
2
|
+
export declare class SheetView extends DialogBase {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
static polyfillDisconnectedCallback(el: SheetView): void;
|
|
6
|
+
static polyfillConnectedCallback(el: SheetView): void;
|
|
7
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
+
import { onoff } from '../internal/utils';
|
|
3
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
4
|
+
import { Snapshot } from '../snapshot';
|
|
5
|
+
export class SheetView extends DialogBase {
|
|
6
|
+
// static get observedAttributes() {
|
|
7
|
+
// return ['fine-presentation-large-adaptation']
|
|
8
|
+
// }
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
static polyfillDisconnectedCallback(el) {
|
|
13
|
+
console.debug(`${SheetView.name} ⚡️ disconnect`);
|
|
14
|
+
CleanupRegistry.unregister(el);
|
|
15
|
+
}
|
|
16
|
+
static polyfillConnectedCallback(el) {
|
|
17
|
+
console.debug(`${SheetView.name} ⚡️ connect`);
|
|
18
|
+
CleanupRegistry.register(el, onoff([
|
|
19
|
+
{ types: 'cancel', listener: this.#handleCancel },
|
|
20
|
+
{ types: 'keydown', listener: SheetView.#handleKeydown },
|
|
21
|
+
], el).on());
|
|
22
|
+
el.autofocus = true;
|
|
23
|
+
if (!self.matchMedia('(pointer: fine)').matches)
|
|
24
|
+
return;
|
|
25
|
+
const handler1 = this.#handleMediaChange.bind(null, el);
|
|
26
|
+
CleanupRegistry.register(el, onoff('fine_dialog_sheet:change', handler1, Snapshot.on).on());
|
|
27
|
+
Snapshot.waitReady.then(() => {
|
|
28
|
+
this.#handleMediaChange(el, new MediaQueryListEvent(`media-change`, {
|
|
29
|
+
matches: Snapshot.breakpoints?.get('fine_dialog_sheet'),
|
|
30
|
+
})); // Initial check
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
|
|
34
|
+
console.debug(`${SheetView.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
|
|
35
|
+
// // NOTE: wait for config
|
|
36
|
+
// Snapshot.waitReady.then(() => {
|
|
37
|
+
// switch (attributeName) {
|
|
38
|
+
// case 'fine-presentation-large-adaptation':
|
|
39
|
+
// const node = target instanceof HTMLDialogElement && target
|
|
40
|
+
// if (!node) break
|
|
41
|
+
// CleanupRegistry.unregister(node, 'mediaquery')
|
|
42
|
+
// if ('bottom-bar' !== target.getAttribute(attributeName ?? '')) break
|
|
43
|
+
// const mediaQueryList = self.matchMedia(`(pointer: fine) and (min-width: ${Snapshot.config!['ipad-sheet-view-inline-size']}) and (min-height: ${Snapshot.config!['ipad-sheet-view-height']})`)
|
|
44
|
+
// SheetView.#handleMediaChange(
|
|
45
|
+
// node,
|
|
46
|
+
// new MediaQueryListEvent(`media-change`, {
|
|
47
|
+
// matches: mediaQueryList.matches,
|
|
48
|
+
// })
|
|
49
|
+
// ) // Initial check
|
|
50
|
+
// const handler1 = SheetView.#handleMediaChange.bind(null, node)
|
|
51
|
+
// CleanupRegistry.register(node, onoff('change', handler1 as unknown as EventListener, mediaQueryList).on(), 'mediaquery')
|
|
52
|
+
// break
|
|
53
|
+
// }
|
|
54
|
+
// })
|
|
55
|
+
}
|
|
56
|
+
static #handleKeydown = (evt) => {
|
|
57
|
+
console.debug(`${SheetView.name} ⚡️ ${evt?.type} (${evt.key})`);
|
|
58
|
+
if ('Escape' !== evt.key)
|
|
59
|
+
return;
|
|
60
|
+
evt.preventDefault();
|
|
61
|
+
evt.stopImmediatePropagation();
|
|
62
|
+
evt.stopPropagation();
|
|
63
|
+
};
|
|
64
|
+
static #handleCancel = (evt) => {
|
|
65
|
+
console.debug(`${SheetView.name} ⚡️ ${evt?.type} (${evt.cancelable})`);
|
|
66
|
+
if (!evt.cancelable)
|
|
67
|
+
return;
|
|
68
|
+
evt.preventDefault();
|
|
69
|
+
};
|
|
70
|
+
static #handleMediaChange = (el, evt) => {
|
|
71
|
+
console.debug(`${SheetView.name} ⚡️ ${evt?.type}`);
|
|
72
|
+
if (evt.matches)
|
|
73
|
+
for (const item of el.querySelectorAll(':scope>tool-bar>[slot^="top-bar-"],:scope>tool-bar>[slot="cancellation-action"],:scope>tool-bar>[slot="primary-action"],:scope>tool-bar>[slot="confirmation-action"],:scope>tool-bar>[slot="destructive-action"]')) {
|
|
74
|
+
const newSlot = item.slot.endsWith('leading') ? 'bottom-bar-leading' : 'bottom-bar-trailing';
|
|
75
|
+
if (item.slot !== newSlot)
|
|
76
|
+
item.dataset.previousSlot = item.slot;
|
|
77
|
+
item.slot = newSlot;
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
for (const item of el.querySelectorAll(':scope>tool-bar>[data-previous-slot]')) {
|
|
81
|
+
item.slot = item.dataset.previousSlot ?? '';
|
|
82
|
+
delete item.dataset.previousSlot;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
3
|
+
import { ResizeObserverSingleton } from '../internal/class/resize-observer-singleton';
|
|
4
|
+
import { debounce, onoff } from '../internal/utils';
|
|
5
|
+
const observers = new ResizeObserverSingleton();
|
|
6
|
+
export class SidebarToggle extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
connectedCallback() {
|
|
11
|
+
console.debug(`${_a.name} ⚡️ connect`);
|
|
12
|
+
CleanupRegistry.register(this, onoff('click', this.#handleClick, this).on());
|
|
13
|
+
const entry = {
|
|
14
|
+
target: this,
|
|
15
|
+
};
|
|
16
|
+
observers.observe(this, debounce(_a.#handleMeasure, 100, true)); //this.#ro?.observe(this)
|
|
17
|
+
// @ts-expect-error
|
|
18
|
+
_a.#handleMeasure([entry]);
|
|
19
|
+
}
|
|
20
|
+
disconnectedCallback() {
|
|
21
|
+
console.debug(`${_a.name} ⚡️ disconnect`);
|
|
22
|
+
observers.unobserve(this);
|
|
23
|
+
CleanupRegistry.unregister(this);
|
|
24
|
+
}
|
|
25
|
+
static query(target) {
|
|
26
|
+
const container = target?.closest('navigation-split-view,tab-view'), sideBar = container?.querySelector(':scope>[is=sidebar-view]');
|
|
27
|
+
return { container, sideBar };
|
|
28
|
+
}
|
|
29
|
+
// This triggers on show/hide of any of sidebar-toggle elements
|
|
30
|
+
static #handleMeasure(entry) {
|
|
31
|
+
console.debug(`${_a.name} ⚡️ measure`);
|
|
32
|
+
const target = entry?.target instanceof HTMLElement && entry.target;
|
|
33
|
+
if (!target)
|
|
34
|
+
return;
|
|
35
|
+
// set/remove css var/prop to parent based on shown/hidden
|
|
36
|
+
const tv = target.parentElement;
|
|
37
|
+
// inlineSize = entry.borderBoxSize?.at(0)?.inlineSize ?? entry.contentRect?.width ?? 0,
|
|
38
|
+
// blockSize = entry.borderBoxSize?.at(0)?.blockSize ?? entry.contentRect?.height ?? 0
|
|
39
|
+
self.requestAnimationFrame(() => {
|
|
40
|
+
const inlineSize = target.offsetWidth ?? 0;
|
|
41
|
+
if (0 < inlineSize)
|
|
42
|
+
tv?.style?.setProperty?.('--sidebar-toggle-padding-inline-start', `${inlineSize}px`); //$.prop('--sidebar-toggle-padding-inline-start', `${inlineSize}px`, tv) //
|
|
43
|
+
else
|
|
44
|
+
tv?.style?.removeProperty?.('--sidebar-toggle-padding-inline-start'); //$.prop('--sidebar-toggle-padding-inline-start', null, tv) //
|
|
45
|
+
});
|
|
46
|
+
// auto close IF open
|
|
47
|
+
const { container, sideBar } = _a.query(target); //target?.closest('navigation-split-view,tab-view')
|
|
48
|
+
if (!sideBar?.open)
|
|
49
|
+
return;
|
|
50
|
+
self.requestAnimationFrame(() => {
|
|
51
|
+
switch (container?.tagName) {
|
|
52
|
+
case 'NAVIGATION-SPLIT-VIEW':
|
|
53
|
+
if (0 < target.offsetWidth && 0 < target.offsetHeight)
|
|
54
|
+
return;
|
|
55
|
+
break;
|
|
56
|
+
case 'TAB-VIEW':
|
|
57
|
+
// scan all toggles for anyone that is visible, sign that sidebar should stay open
|
|
58
|
+
if ([
|
|
59
|
+
...container.querySelectorAll(':scope > sidebar-toggle,:scope > [is=tab-bar] > sidebar-toggle' //,:scope > [is='sidebar-view'] > tool-bar > sidebar-toggle" ?? FIXME: removed this bc/ inside sidebar!
|
|
60
|
+
),
|
|
61
|
+
].some(({ offsetWidth, offsetHeight }) => 0 < offsetWidth && 0 < offsetHeight))
|
|
62
|
+
return;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
sideBar?.close?.();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
#handleClick(evt) {
|
|
69
|
+
console.debug(`${_a.name} ⚡️ ${evt?.type}`);
|
|
70
|
+
const target = evt?.target instanceof HTMLElement && evt.target;
|
|
71
|
+
if (!target)
|
|
72
|
+
return;
|
|
73
|
+
if (!target?.closest('button'))
|
|
74
|
+
return;
|
|
75
|
+
const { sideBar } = _a.query(target);
|
|
76
|
+
if (!sideBar?.open)
|
|
77
|
+
sideBar?.showModal();
|
|
78
|
+
else
|
|
79
|
+
sideBar.close();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
_a = SidebarToggle;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
2
|
+
export declare class SidebarView extends DialogBase {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
static polyfillDisconnectedCallback(el: HTMLDialogElement): void;
|
|
6
|
+
static polyfillConnectedCallback(el: HTMLDialogElement): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
+
import { onoff, touchGlass } from '../internal/utils';
|
|
3
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
4
|
+
export class SidebarView extends DialogBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
static polyfillDisconnectedCallback(el) {
|
|
9
|
+
el.removeEventListener('click', SidebarView.#handleClick);
|
|
10
|
+
CleanupRegistry.unregister(el);
|
|
11
|
+
}
|
|
12
|
+
static polyfillConnectedCallback(el) {
|
|
13
|
+
CleanupRegistry.register(el, onoff('click', SidebarView.#handleClick, el).on());
|
|
14
|
+
CleanupRegistry.register(el, onoff(touchGlass(el, (t) => t, (evt) => {
|
|
15
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
16
|
+
if (!target)
|
|
17
|
+
return true;
|
|
18
|
+
if (target.matches('[is=sidebar-view]'))
|
|
19
|
+
return false;
|
|
20
|
+
if (target.closest('tool-bar-item'))
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}), el).on());
|
|
24
|
+
el.autofocus = true;
|
|
25
|
+
}
|
|
26
|
+
/** Autoclose on click outside. */
|
|
27
|
+
static #handleClick = async (evt) => {
|
|
28
|
+
console.debug(`${SidebarView.name} ⚡️ ${evt?.type}`);
|
|
29
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
30
|
+
if (!target)
|
|
31
|
+
return;
|
|
32
|
+
if (target instanceof HTMLDialogElement && 'sidebar-view' === target.getAttribute('is'))
|
|
33
|
+
target.close?.();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
+
import { onoff } from '../internal/utils';
|
|
3
|
+
export class StickyContainer extends HTMLElement {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
console.debug(`${StickyContainer.name} ⚡️ connect`);
|
|
9
|
+
// CleanupRegistry.register(this, onoff('transitionend transitionstart transitioncancel', this.#handleTransitionrun as unknown as EventListener, this).on())
|
|
10
|
+
CleanupRegistry.register(this, onoff('transitionrun', this.#handleTransitionrun, this).on());
|
|
11
|
+
}
|
|
12
|
+
disconnectedCallback() {
|
|
13
|
+
console.debug(`${StickyContainer.name} ⚡️ disconnect`);
|
|
14
|
+
CleanupRegistry.unregister(this);
|
|
15
|
+
}
|
|
16
|
+
#handleTransitionrun = ({ target, propertyName, pseudoElement }) => {
|
|
17
|
+
if (!(target instanceof HTMLElement && target))
|
|
18
|
+
return;
|
|
19
|
+
if ('--stuck' !== propertyName || '::before' !== pseudoElement || !target.matches('sticky-container'))
|
|
20
|
+
return;
|
|
21
|
+
const stuck = self.getComputedStyle(this, 'before').getPropertyValue('--stuck');
|
|
22
|
+
this.toggleAttribute('stuck', '1' === stuck);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
2
|
+
/**
|
|
3
|
+
* @summary A screen that lets users switch between different views using buttons, tabs, or other controls.
|
|
4
|
+
*/
|
|
5
|
+
export declare class TabBar extends DialogBase {
|
|
6
|
+
#private;
|
|
7
|
+
constructor();
|
|
8
|
+
static polyfillDisconnectedCallback(el: HTMLDialogElement): void;
|
|
9
|
+
static polyfillConnectedCallback(el: HTMLDialogElement): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CleanupRegistry } from '../internal/class/cleanup-registry';
|
|
2
|
+
import { onoff, touchGlass } from '../internal/utils';
|
|
3
|
+
import { DialogBase } from '../namespace-browser/base';
|
|
4
|
+
/**
|
|
5
|
+
* @summary A screen that lets users switch between different views using buttons, tabs, or other controls.
|
|
6
|
+
*/
|
|
7
|
+
export class TabBar extends DialogBase {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
static polyfillDisconnectedCallback(el) {
|
|
12
|
+
console.debug(`${TabBar.name} ⚡️ disconnect`);
|
|
13
|
+
el.removeEventListener('click', TabBar.#handleClick);
|
|
14
|
+
CleanupRegistry.unregister(el);
|
|
15
|
+
}
|
|
16
|
+
static polyfillConnectedCallback(el) {
|
|
17
|
+
console.debug(`${TabBar.name} ⚡️ connect`);
|
|
18
|
+
el.autofocus = true;
|
|
19
|
+
// Snapshot.waitReadyFor(el).then((r) => {
|
|
20
|
+
// if (!r) return
|
|
21
|
+
CleanupRegistry.register(el, onoff('click', TabBar.#handleClick, el).on());
|
|
22
|
+
CleanupRegistry.register(el, onoff(touchGlass(el, (t) => t, (evt) => {
|
|
23
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
24
|
+
if (!target)
|
|
25
|
+
return true;
|
|
26
|
+
if (target.matches('[is=tab-bar]'))
|
|
27
|
+
return false;
|
|
28
|
+
if (target.closest('tool-bar-item'))
|
|
29
|
+
return false;
|
|
30
|
+
return true;
|
|
31
|
+
}), el).on());
|
|
32
|
+
// })
|
|
33
|
+
}
|
|
34
|
+
static #handleClick = async (evt) => {
|
|
35
|
+
console.debug(`${TabBar.name} ⚡️ ${evt?.type}`);
|
|
36
|
+
const target = evt.target instanceof HTMLElement && evt.target;
|
|
37
|
+
if (!target)
|
|
38
|
+
return;
|
|
39
|
+
if (target instanceof HTMLDialogElement && 'tab-bar' === target.getAttribute('is'))
|
|
40
|
+
target.close?.();
|
|
41
|
+
};
|
|
42
|
+
}
|