@swiftwc/ui 0.0.0-dev.4 → 0.0.0-dev.6

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 (51) hide show
  1. package/generated/client/index.d.ts +6 -0
  2. package/generated/client/index.js +223 -0
  3. package/generated/components/body-view.d.ts +5 -0
  4. package/generated/components/body-view.js +11 -0
  5. package/generated/components/borderless-button.d.ts +9 -0
  6. package/generated/components/borderless-button.js +25 -0
  7. package/generated/components/bottom-bar.d.ts +10 -0
  8. package/generated/components/bottom-bar.js +73 -0
  9. package/generated/components/disclosure-group.d.ts +12 -0
  10. package/generated/components/disclosure-group.js +76 -0
  11. package/generated/components/index.d.ts +15 -0
  12. package/generated/components/index.js +20 -0
  13. package/generated/components/navigation-bar.d.ts +10 -0
  14. package/generated/components/navigation-bar.js +80 -0
  15. package/generated/components/navigation-split-view.d.ts +5 -0
  16. package/generated/components/navigation-split-view.js +9 -0
  17. package/generated/components/navigation-stack.d.ts +6 -0
  18. package/generated/components/navigation-stack.js +67 -0
  19. package/generated/components/screen-view.d.ts +5 -0
  20. package/generated/components/screen-view.js +9 -0
  21. package/generated/components/scroll-view.d.ts +8 -0
  22. package/generated/components/scroll-view.js +80 -0
  23. package/generated/components/sheet-view.d.ts +9 -0
  24. package/generated/components/sheet-view.js +26 -0
  25. package/generated/components/sidebar-toggle.d.ts +7 -0
  26. package/generated/components/sidebar-toggle.js +81 -0
  27. package/generated/components/sidebar-view.d.ts +9 -0
  28. package/generated/components/sidebar-view.js +26 -0
  29. package/generated/components/tab-bar.d.ts +9 -0
  30. package/generated/components/tab-bar.js +26 -0
  31. package/generated/components/tab-item.d.ts +6 -0
  32. package/generated/components/tab-item.js +35 -0
  33. package/generated/components/tab-view.d.ts +7 -0
  34. package/generated/components/tab-view.js +29 -0
  35. package/generated/components/v-keyboard.d.ts +11 -0
  36. package/generated/components/v-keyboard.js +87 -0
  37. package/generated/index.d.ts +2 -0
  38. package/generated/index.js +3 -0
  39. package/generated/internal/class.d.ts +18 -0
  40. package/generated/internal/class.js +18 -0
  41. package/generated/internal/utils/css-time.d.ts +1 -0
  42. package/generated/internal/utils/css-time.js +3 -0
  43. package/generated/internal/utils/index.d.ts +2 -0
  44. package/generated/internal/utils/index.js +2 -0
  45. package/generated/internal/utils/kebab-case.d.ts +1 -0
  46. package/generated/internal/utils/kebab-case.js +11 -0
  47. package/generated/namespace/index.d.ts +6 -0
  48. package/generated/namespace/index.js +1 -0
  49. package/generated/snapshot/index.d.ts +16 -0
  50. package/generated/snapshot/index.js +150 -0
  51. package/package.json +4 -4
@@ -0,0 +1,67 @@
1
+ export class NavigationStack extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ /* const shadowRoot = this.attachShadow({ mode: 'open' })
5
+ shadowRoot.appendChild(
6
+ document.importNode(this.constructor.template.content, true)
7
+ )
8
+ const slot = shadowRoot.querySelector('slot')!
9
+
10
+ slot.addEventListener('slotchange', () => {
11
+ const sv = this.querySelector<HTMLElement>(':scope > scroll-view')
12
+ if (!sv) return
13
+
14
+ const st = parseInt(sv?.dataset?.scrolltop ?? '0')
15
+
16
+ requestAnimationFrame(() => (sv.scrollTop = st))
17
+ }) */
18
+ // const template = document.createElement('template')
19
+ // template.innerHTML = this.constructor.#template
20
+ // const template = document.getElementById('element-details-template')
21
+ // // Named slot for toolbar
22
+ // const toolbarSlot = document.createElement('slot');
23
+ // toolbarSlot.name = 'toolbar';
24
+ // // Default slot for everything else
25
+ // const defaultSlot = document.createElement('slot');
26
+ // shadow.appendChild(toolbarSlot);
27
+ // shadow.appendChild(defaultSlot);
28
+ // this.attachShadow({ mode: 'open' }).append(template.content.cloneNode(true))
29
+ ////this.constructor.template.content.cloneNode(true)
30
+ // shadowRoot.appendChild(document.importNode(template.content, true))
31
+ // alert(9)
32
+ // const t = this
33
+ }
34
+ disconnectedCallback() {
35
+ console.debug(`${NavigationStack.name} ⚡️ disconnect`);
36
+ }
37
+ connectedCallback() {
38
+ // this.attachShadow({ mode: "open" });
39
+ // this.shadowRoot.innerHTML = NavigationStack.template;
40
+ // Access slotted elements
41
+ // const toolbarSlot = this.shadowRoot.querySelector('slot[name="toolbar"]');
42
+ // const defaultSlot = this.shadowRoot.querySelector('slot:not([name])');
43
+ // // Get assigned nodes
44
+ // const toolbarNodes = toolbarSlot.assignedNodes({ flatten: true });
45
+ // const defaultNodes = defaultSlot.assignedNodes({ flatten: true });
46
+ // console.log('Toolbar nodes:', toolbarNodes);
47
+ // console.log('Default nodes:', defaultNodes);
48
+ // const starRating = document.getElementById('star-rating-template').content;
49
+ // const shadowRoot = this.attachShadow({
50
+ // mode: 'open'
51
+ // });
52
+ // shadowRoot.appendChild(starRating.cloneNode(true));
53
+ // this.innerHTML = `<div>gh</div><slot name="toolbar"><legend>Rate your experience:</legend></slot>`
54
+ // this.appendChild(slottedToolbar)
55
+ // console.log(99)
56
+ // this.innerHTML = `
57
+ // <header>
58
+ // <label>New</label>
59
+ // </header>
60
+ // <p>
61
+ // <h2>Welcome to the new page!</h2>
62
+ // </p>
63
+ // ${this.innerHTML}
64
+ // `;
65
+ }
66
+ }
67
+ NavigationStack.observedAttributes = ['hidden'];
@@ -0,0 +1,5 @@
1
+ import { DialogBase } from '../internal/class';
2
+ export declare class ScreenView extends DialogBase {
3
+ constructor();
4
+ disconnectedCallback(): void;
5
+ }
@@ -0,0 +1,9 @@
1
+ import { DialogBase } from '../internal/class';
2
+ export class ScreenView extends DialogBase {
3
+ constructor() {
4
+ super();
5
+ }
6
+ disconnectedCallback() {
7
+ console.debug(`${ScreenView.name} ⚡️ disconnect`);
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ export declare class ScrollView extends HTMLElement {
2
+ #private;
3
+ static get template(): HTMLTemplateElement;
4
+ constructor();
5
+ disconnectedCallback(): void;
6
+ connectedCallback(): void;
7
+ scrollToElement(el: Element): void;
8
+ }
@@ -0,0 +1,80 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _a, _ScrollView_template, _ScrollView_shadowRoot;
13
+ export class ScrollView extends HTMLElement {
14
+ static get template() {
15
+ if (!__classPrivateFieldGet(this, _a, "f", _ScrollView_template))
16
+ __classPrivateFieldSet(this, _a, Object.assign(document.createElement('template'), {
17
+ innerHTML: `<slot></slot>
18
+ <slot name="navigation-bar"></slot>
19
+ <slot name="bottom-bar"></slot>`,
20
+ }), "f", _ScrollView_template);
21
+ return __classPrivateFieldGet(this, _a, "f", _ScrollView_template);
22
+ }
23
+ constructor() {
24
+ super();
25
+ _ScrollView_shadowRoot.set(this, void 0);
26
+ __classPrivateFieldSet(this, _ScrollView_shadowRoot, this.attachShadow({ mode: 'open' }), "f");
27
+ __classPrivateFieldGet(this, _ScrollView_shadowRoot, "f").appendChild(document.importNode(this.constructor.template.content, true));
28
+ // this.addEventListener(
29
+ // 'scrollend',
30
+ // () => {
31
+ // this.dataset.scrolltop = this.scrollTop
32
+ // },
33
+ // { passive: true }
34
+ // )
35
+ }
36
+ disconnectedCallback() {
37
+ console.debug(`${_a.name} ⚡️ disconnect`);
38
+ }
39
+ connectedCallback() {
40
+ console.debug(`${_a.name} ⚡️ connect`);
41
+ // const nSlot = this.shadowRoot.querySelector('slot[name=navigation-bar]')!
42
+ if (0 ===
43
+ __classPrivateFieldGet(this, _ScrollView_shadowRoot, "f")
44
+ .querySelector('slot[name=navigation-bar]')
45
+ .assignedNodes({ flatten: true }).length)
46
+ this.insertAdjacentHTML('beforeend', `<tool-bar slot="navigation-bar">
47
+ <span>ghjh</span>
48
+ </tool-bar>`);
49
+ if (0 ===
50
+ __classPrivateFieldGet(this, _ScrollView_shadowRoot, "f")
51
+ .querySelector('slot[name=bottom-bar]')
52
+ .assignedNodes({ flatten: true }).length)
53
+ this.insertAdjacentHTML('beforeend', `<tool-bar slot="bottom-bar">
54
+ <span>ghj</span>
55
+ </tool-bar>`);
56
+ }
57
+ scrollToElement(el) {
58
+ // document.querySelector("#kb").innerHTML = self.visualViewport.height;
59
+ // document.querySelector("#console4").innerHTML = `${self.scrollY} / ${
60
+ // document.querySelector("scroll-view").scrollTop
61
+ // }`;
62
+ // const parent = el.closest('scroll-view')
63
+ const child = el;
64
+ // scrollTop needed to center child
65
+ const parentRect = this.getBoundingClientRect();
66
+ const childRect = child.getBoundingClientRect();
67
+ // current scroll + offset of child relative to parent
68
+ const scrollTop = this.scrollTop +
69
+ childRect.top -
70
+ parentRect.top -
71
+ parentRect.height / 2 +
72
+ childRect.height / 2;
73
+ this.scrollTo({
74
+ top: scrollTop,
75
+ behavior: 'smooth', // optional: smooth scroll
76
+ });
77
+ }
78
+ }
79
+ _a = ScrollView, _ScrollView_shadowRoot = new WeakMap();
80
+ _ScrollView_template = { value: void 0 };
@@ -0,0 +1,9 @@
1
+ import { DialogBase } from '../internal/class';
2
+ export declare class SheetView extends DialogBase {
3
+ constructor();
4
+ disconnectedCallback(): void;
5
+ connectedCallback(): void;
6
+ static polyfillDisconnectedCallback(el: SheetView): void;
7
+ static polyfillConnectedCallback(el: SheetView): void;
8
+ static handleCancel: (event: Event) => void;
9
+ }
@@ -0,0 +1,26 @@
1
+ import { DialogBase } from '../internal/class';
2
+ export class SheetView extends DialogBase {
3
+ constructor() {
4
+ super();
5
+ }
6
+ disconnectedCallback() {
7
+ console.debug(`${SheetView.name} ⚡️ disconnect`);
8
+ SheetView.polyfillDisconnectedCallback(this);
9
+ }
10
+ connectedCallback() {
11
+ console.debug(`${SheetView.name} ⚡️ connect`);
12
+ SheetView.polyfillConnectedCallback(this);
13
+ }
14
+ static polyfillDisconnectedCallback(el) {
15
+ el.removeEventListener('cancel', SheetView.handleCancel);
16
+ }
17
+ static polyfillConnectedCallback(el) {
18
+ el.addEventListener('cancel', SheetView.handleCancel);
19
+ }
20
+ }
21
+ SheetView.handleCancel = (event) => {
22
+ console.debug(`${SheetView.name} ⚡️ cancel (${event.cancelable})`);
23
+ if (!event.cancelable)
24
+ return;
25
+ event.preventDefault();
26
+ };
@@ -0,0 +1,7 @@
1
+ export declare class SidebarToggle extends HTMLElement {
2
+ #private;
3
+ static get cssVarPaddingName(): string;
4
+ constructor();
5
+ connectedCallback(): void;
6
+ disconnectedCallback(): void;
7
+ }
@@ -0,0 +1,81 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _SidebarToggle_instances, _a, _SidebarToggle_ro, _SidebarToggle_autoCloseTabBar, _SidebarToggle_handleClick;
13
+ export class SidebarToggle extends HTMLElement {
14
+ // #io
15
+ static get cssVarPaddingName() {
16
+ return '--tabview-padding-inline-start';
17
+ }
18
+ constructor() {
19
+ super();
20
+ _SidebarToggle_instances.add(this);
21
+ _SidebarToggle_ro.set(this, void 0);
22
+ __classPrivateFieldSet(this, _SidebarToggle_ro, new ResizeObserver(__classPrivateFieldGet(this, _SidebarToggle_instances, "m", _SidebarToggle_autoCloseTabBar)), "f");
23
+ // this.#io = new IntersectionObserver((entries) => {
24
+ // this._checkVisibility2(entries)
25
+ // })
26
+ }
27
+ connectedCallback() {
28
+ console.debug(`${_a.name} ⚡️ connect`);
29
+ this.addEventListener('click', __classPrivateFieldGet(this, _SidebarToggle_instances, "m", _SidebarToggle_handleClick));
30
+ __classPrivateFieldGet(this, _SidebarToggle_ro, "f")?.observe(this);
31
+ // this.#io.observe(this)
32
+ __classPrivateFieldGet(this, _SidebarToggle_instances, "m", _SidebarToggle_autoCloseTabBar).call(this);
33
+ }
34
+ disconnectedCallback() {
35
+ console.debug(`${_a.name} ⚡️ disconnect`);
36
+ __classPrivateFieldGet(this, _SidebarToggle_ro, "f")?.disconnect();
37
+ // this.#io.disconnect()
38
+ this.removeEventListener('click', __classPrivateFieldGet(this, _SidebarToggle_instances, "m", _SidebarToggle_handleClick));
39
+ }
40
+ }
41
+ _a = SidebarToggle, _SidebarToggle_ro = new WeakMap(), _SidebarToggle_instances = new WeakSet(), _SidebarToggle_autoCloseTabBar = function _SidebarToggle_autoCloseTabBar() {
42
+ console.debug('#autoCloseTabBar');
43
+ const toggles = [
44
+ ...document.querySelectorAll('sidebar-toggle'),
45
+ ];
46
+ // set css vars
47
+ for (const tg of toggles) {
48
+ const tv = tg.parentElement;
49
+ const width = tg?.offsetWidth ?? 0;
50
+ if (0 < width) {
51
+ // const gapProp =
52
+ // getComputedStyle(tg).getPropertyValue('--toolbar-col-gap') || '0',
53
+ // gap = parseFloat(gapProp) * 1 //(gapProp.endsWith('rem')? parseFloat(getComputedStyle(document.documentElement).fontSize): 1)
54
+ tv?.style?.setProperty?.(_a.cssVarPaddingName, `${width}px`);
55
+ }
56
+ else {
57
+ tv?.style?.removeProperty?.(_a.cssVarPaddingName);
58
+ }
59
+ }
60
+ // auto close
61
+ const tabBar = document.querySelector('dialog[is=tab-bar]');
62
+ if (!tabBar?.open)
63
+ return;
64
+ // scan all toggles for anyone that is visible, sign that sidebar should stay open
65
+ const isAnyVisible = toggles.some(({ offsetWidth, offsetHeight }) => 0 < offsetWidth && 0 < offsetHeight);
66
+ if (isAnyVisible)
67
+ return;
68
+ tabBar?.close?.();
69
+ }, _SidebarToggle_handleClick = function _SidebarToggle_handleClick(event) {
70
+ const target = event.target;
71
+ if (!target?.closest('button'))
72
+ return;
73
+ const lm = target?.closest('tab-view,navigation-split-view');
74
+ const dialog = 'TAB-VIEW' === lm?.tagName
75
+ ? lm.querySelector('dialog[is="tab-bar"]')
76
+ : lm?.querySelector('dialog[is="sidebar-view"]');
77
+ if (!dialog?.open)
78
+ dialog?.showModal();
79
+ else
80
+ dialog.close();
81
+ };
@@ -0,0 +1,9 @@
1
+ import { DialogBase } from '../internal/class';
2
+ export declare class SidebarView extends DialogBase {
3
+ constructor();
4
+ disconnectedCallback(): void;
5
+ connectedCallback(): void;
6
+ static polyfillDisconnectedCallback(el: HTMLDialogElement): void;
7
+ static polyfillConnectedCallback(el: HTMLDialogElement): void;
8
+ static handleClick: (event: Event) => Promise<void>;
9
+ }
@@ -0,0 +1,26 @@
1
+ var _a;
2
+ import { DialogBase } from '../internal/class';
3
+ export class SidebarView extends DialogBase {
4
+ constructor() {
5
+ super();
6
+ }
7
+ disconnectedCallback() {
8
+ console.debug(`${_a.name} ⚡️ disconnect`);
9
+ _a.polyfillDisconnectedCallback(this);
10
+ }
11
+ connectedCallback() {
12
+ _a.polyfillConnectedCallback(this);
13
+ }
14
+ static polyfillDisconnectedCallback(el) {
15
+ el.removeEventListener('click', _a.handleClick);
16
+ }
17
+ static polyfillConnectedCallback(el) {
18
+ el.addEventListener('click', _a.handleClick);
19
+ }
20
+ }
21
+ _a = SidebarView;
22
+ SidebarView.handleClick = async (event) => {
23
+ if ('DIALOG' === event.target.tagName &&
24
+ 'sidebar-view' === event.target.getAttribute('is'))
25
+ event?.target?.close?.();
26
+ };
@@ -0,0 +1,9 @@
1
+ import { DialogBase } from '../internal/class';
2
+ export declare class TabBar extends DialogBase {
3
+ constructor();
4
+ disconnectedCallback(): void;
5
+ connectedCallback(): void;
6
+ static polyfillDisconnectedCallback(el: HTMLDialogElement): void;
7
+ static polyfillConnectedCallback(el: HTMLDialogElement): void;
8
+ static handleClick: (event: Event) => Promise<void>;
9
+ }
@@ -0,0 +1,26 @@
1
+ var _a;
2
+ import { DialogBase } from '../internal/class';
3
+ export class TabBar extends DialogBase {
4
+ constructor() {
5
+ super();
6
+ }
7
+ disconnectedCallback() {
8
+ console.debug(`${_a.name} ⚡️ disconnect`);
9
+ _a.polyfillDisconnectedCallback(this);
10
+ }
11
+ connectedCallback() {
12
+ _a.polyfillConnectedCallback(this);
13
+ }
14
+ static polyfillDisconnectedCallback(el) {
15
+ el.removeEventListener('click', _a.handleClick);
16
+ }
17
+ static polyfillConnectedCallback(el) {
18
+ el.addEventListener('click', _a.handleClick);
19
+ }
20
+ }
21
+ _a = TabBar;
22
+ TabBar.handleClick = async (event) => {
23
+ if ('DIALOG' === event.target.tagName &&
24
+ 'tab-bar' === event.target.getAttribute('is'))
25
+ event?.target?.close?.();
26
+ };
@@ -0,0 +1,6 @@
1
+ export declare class TabItem extends HTMLElement {
2
+ #private;
3
+ constructor();
4
+ disconnectedCallback(): void;
5
+ connectedCallback(): void;
6
+ }
@@ -0,0 +1,35 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _a, _TabItem_handleClick;
7
+ export class TabItem extends HTMLElement {
8
+ constructor() {
9
+ super();
10
+ _TabItem_handleClick.set(this, () => {
11
+ console.debug(`${_a.name} ⚡️ click`);
12
+ const tag = this.getAttribute('tag');
13
+ if (!tag)
14
+ throw new DOMException(`Attribute "tag" is set but invalid`, 'InvalidStateError');
15
+ const tv = this.closest('tab-view');
16
+ if (!tv)
17
+ throw new Error('Element not found');
18
+ const newTab = tv?.querySelector(`#${tag}`);
19
+ // 'more' === tag
20
+ // ? tv?.querySelector<HTMLElement>(`tab-view>[is=more]`):
21
+ if (!newTab)
22
+ throw new Error('Element not found');
23
+ tv.selection = newTab;
24
+ });
25
+ }
26
+ disconnectedCallback() {
27
+ console.debug(`${_a.name} ⚡️ disconnect`);
28
+ this.removeEventListener('click', __classPrivateFieldGet(this, _TabItem_handleClick, "f"));
29
+ }
30
+ connectedCallback() {
31
+ console.debug(`${_a.name} ⚡️ connect`);
32
+ this.addEventListener('click', __classPrivateFieldGet(this, _TabItem_handleClick, "f"));
33
+ }
34
+ }
35
+ _a = TabItem, _TabItem_handleClick = new WeakMap();
@@ -0,0 +1,7 @@
1
+ export declare class TabView extends HTMLElement {
2
+ constructor();
3
+ disconnectedCallback(): void;
4
+ connectedCallback(): void;
5
+ get selection(): HTMLElement | null;
6
+ set selection(nv: HTMLElement | null);
7
+ }
@@ -0,0 +1,29 @@
1
+ export class TabView extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ }
5
+ disconnectedCallback() {
6
+ console.debug(`${TabView.name} ⚡️ disconnect`);
7
+ }
8
+ connectedCallback() {
9
+ console.debug(`${TabView.name} ⚡️ connect`);
10
+ }
11
+ get selection() {
12
+ const selectedTab = this.querySelector(':scope > navigation-stack:not([hidden]),:scope > navigation-split-view:not([hidden])');
13
+ return selectedTab;
14
+ }
15
+ set selection(nv) {
16
+ if (!['NAVIGATION-STACK', 'NAVIGATION-SPLIT-VIEW'].includes(nv?.tagName ?? ''))
17
+ throw new Error('Element not found');
18
+ if (nv === this.selection)
19
+ return;
20
+ for (const ns of this.querySelectorAll(':scope > navigation-stack,:scope > navigation-split-view')) {
21
+ if (nv === ns)
22
+ continue;
23
+ ns.hidden = true;
24
+ this.dispatchEvent(new CustomEvent('tabswap', { detail: { x: 42 } }));
25
+ }
26
+ nv.hidden = false;
27
+ this.dispatchEvent(new CustomEvent('tabreveal', { detail: { x: 42 } }));
28
+ }
29
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * BUG: Safari on IOS reports inaccurate innerHeight (which is what we really want) on orientationchange.
3
+ * So we live with a pescy body-scrollbar that shows up on resize on desktops.
4
+ */
5
+ export declare class VKeyboard extends HTMLElement {
6
+ #private;
7
+ constructor();
8
+ disconnectedCallback(): void;
9
+ connectedCallback(): void;
10
+ set shouldKeyboardBeOpen(fn: () => boolean);
11
+ }
@@ -0,0 +1,87 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _a, _VKeyboard_shouldKeyboardBeOpenCallback, _VKeyboard_handleWindowScroll, _VKeyboard_handleVisualViewportResize, _VKeyboard_handleWindowOrientationChange, _VKeyboard_handleBodyFocusIn, _VKeyboard_ifKeyboardScrollIntoActiveElement;
13
+ /**
14
+ * BUG: Safari on IOS reports inaccurate innerHeight (which is what we really want) on orientationchange.
15
+ * So we live with a pescy body-scrollbar that shows up on resize on desktops.
16
+ */
17
+ export class VKeyboard extends HTMLElement {
18
+ constructor() {
19
+ super();
20
+ /**
21
+ * Change like this:
22
+ * document.querySelector('v-keyboard').shouldKeyboardBeOpen = () => document.activeElement.tagName === 'INPUT'
23
+ */
24
+ _VKeyboard_shouldKeyboardBeOpenCallback.set(this, () => {
25
+ return ('INPUT' === document.activeElement?.tagName &&
26
+ 'text' === document.activeElement?.getAttribute('type'));
27
+ });
28
+ _VKeyboard_handleWindowScroll.set(this, () => {
29
+ self.scrollTo(0, 0);
30
+ });
31
+ _VKeyboard_handleVisualViewportResize.set(this, () => {
32
+ const dvh = self.visualViewport?.height ?? 0, fullLvh = this.offsetHeight;
33
+ const diff = Math.abs(self.outerHeight - (__classPrivateFieldGet(this, _VKeyboard_shouldKeyboardBeOpenCallback, "f").call(this) ? dvh : fullLvh));
34
+ document.documentElement.style.setProperty('--100lvh', 30 < diff ? `${dvh}px` : `${fullLvh}px`);
35
+ document.documentElement.style.setProperty('--keyboard-inset-top', 30 < diff ? `${dvh}px` : `${fullLvh}px`);
36
+ document.documentElement.style.setProperty('--keyboard-inset-height', 30 < diff ? `${diff}px` : `0px`);
37
+ // @ts-expect-error
38
+ if (import.meta.env.DEV) {
39
+ // @ts-expect-error
40
+ document.querySelector('#console0').innerHTML =
41
+ `${__classPrivateFieldGet(this, _VKeyboard_shouldKeyboardBeOpenCallback, "f").call(this)} (${diff}) (${self.innerHeight}) (${fullLvh}) (${dvh})`;
42
+ // @ts-expect-error
43
+ document.querySelector('#console').hidePopover();
44
+ // @ts-expect-error
45
+ document.querySelector('#console').showPopover();
46
+ }
47
+ self.scrollTo(0, 0);
48
+ });
49
+ _VKeyboard_handleWindowOrientationChange.set(this, () => {
50
+ console.debug(`${_a.name} ⚡️ orientationchange`);
51
+ self.requestAnimationFrame(__classPrivateFieldGet(this, _VKeyboard_ifKeyboardScrollIntoActiveElement, "f"));
52
+ });
53
+ _VKeyboard_handleBodyFocusIn.set(this, () => {
54
+ console.debug(`${_a.name} ⚡️ focusin`);
55
+ setTimeout(__classPrivateFieldGet(this, _VKeyboard_ifKeyboardScrollIntoActiveElement, "f"), 100);
56
+ });
57
+ _VKeyboard_ifKeyboardScrollIntoActiveElement.set(this, () => {
58
+ if (!__classPrivateFieldGet(this, _VKeyboard_shouldKeyboardBeOpenCallback, "f").call(this) || !document.activeElement)
59
+ return;
60
+ const parent = document.activeElement?.closest('scroll-view');
61
+ parent?.scrollToElement?.(document.activeElement);
62
+ });
63
+ }
64
+ disconnectedCallback() {
65
+ console.debug(`${_a.name} ⚡️ disconnect`);
66
+ self.removeEventListener('resize', __classPrivateFieldGet(this, _VKeyboard_handleWindowScroll, "f"));
67
+ self.visualViewport?.removeEventListener('resize', __classPrivateFieldGet(this, _VKeyboard_handleVisualViewportResize, "f"));
68
+ self.removeEventListener('orientationchange', __classPrivateFieldGet(this, _VKeyboard_handleWindowOrientationChange, "f"));
69
+ document.body.removeEventListener('focusin', __classPrivateFieldGet(this, _VKeyboard_handleBodyFocusIn, "f"));
70
+ }
71
+ connectedCallback() {
72
+ console.debug(`${_a.name} ⚡️ connect`);
73
+ this.inert = true;
74
+ self.addEventListener('scroll', __classPrivateFieldGet(this, _VKeyboard_handleWindowScroll, "f"));
75
+ self.visualViewport?.addEventListener('resize', __classPrivateFieldGet(this, _VKeyboard_handleVisualViewportResize, "f"));
76
+ __classPrivateFieldGet(this, _VKeyboard_handleVisualViewportResize, "f").call(this);
77
+ //
78
+ self.addEventListener('orientationchange', __classPrivateFieldGet(this, _VKeyboard_handleWindowOrientationChange, "f"));
79
+ document.body.addEventListener('focusin', __classPrivateFieldGet(this, _VKeyboard_handleBodyFocusIn, "f"));
80
+ }
81
+ set shouldKeyboardBeOpen(fn) {
82
+ if (typeof fn !== 'function')
83
+ throw new TypeError(`fn must be a function`);
84
+ __classPrivateFieldSet(this, _VKeyboard_shouldKeyboardBeOpenCallback, fn, "f");
85
+ }
86
+ }
87
+ _a = VKeyboard, _VKeyboard_shouldKeyboardBeOpenCallback = new WeakMap(), _VKeyboard_handleWindowScroll = new WeakMap(), _VKeyboard_handleVisualViewportResize = new WeakMap(), _VKeyboard_handleWindowOrientationChange = new WeakMap(), _VKeyboard_handleBodyFocusIn = new WeakMap(), _VKeyboard_ifKeyboardScrollIntoActiveElement = new WeakMap();
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import packageJson from '../package.json';
3
+ console.log(`Hello world! ${packageJson.version}`);
@@ -0,0 +1,18 @@
1
+ export declare abstract class DialogBase extends HTMLDialogElement {
2
+ static polyfillExtends: "dialog";
3
+ static polyfillConnectedCallback(el: HTMLDialogElement): void;
4
+ static polyfillDisonnectedCallback(el: HTMLDialogElement): void;
5
+ static polyfillAttributeChangedCallback(entries: MutationRecord[]): void;
6
+ }
7
+ export declare abstract class ButtonBase extends HTMLButtonElement {
8
+ static polyfillExtends: "button";
9
+ static polyfillConnectedCallback(el: HTMLButtonElement): void;
10
+ static polyfillDisonnectedCallback(el: HTMLButtonElement): void;
11
+ static polyfillAttributeChangedCallback(entries: MutationRecord[]): void;
12
+ }
13
+ export declare abstract class DetailsBase extends HTMLDetailsElement {
14
+ static polyfillExtends: "details";
15
+ static polyfillConnectedCallback(el: HTMLDetailsElement): void;
16
+ static polyfillDisonnectedCallback(el: HTMLDetailsElement): void;
17
+ static polyfillAttributeChangedCallback(entries: MutationRecord[]): void;
18
+ }
@@ -0,0 +1,18 @@
1
+ export class DialogBase extends HTMLDialogElement {
2
+ static polyfillConnectedCallback(el) { }
3
+ static polyfillDisonnectedCallback(el) { }
4
+ static polyfillAttributeChangedCallback(entries) { }
5
+ }
6
+ DialogBase.polyfillExtends = 'dialog';
7
+ export class ButtonBase extends HTMLButtonElement {
8
+ static polyfillConnectedCallback(el) { }
9
+ static polyfillDisonnectedCallback(el) { }
10
+ static polyfillAttributeChangedCallback(entries) { }
11
+ }
12
+ ButtonBase.polyfillExtends = 'button';
13
+ export class DetailsBase extends HTMLDetailsElement {
14
+ static polyfillConnectedCallback(el) { }
15
+ static polyfillDisonnectedCallback(el) { }
16
+ static polyfillAttributeChangedCallback(entries) { }
17
+ }
18
+ DetailsBase.polyfillExtends = 'details';
@@ -0,0 +1 @@
1
+ export default function (cssTime: string): number;
@@ -0,0 +1,3 @@
1
+ export default function (cssTime) {
2
+ return parseFloat(cssTime) * (/\ds$/.test(cssTime) ? 1000 : 1);
3
+ }
@@ -0,0 +1,2 @@
1
+ export { default as kebabCase } from './kebab-case';
2
+ export { default as cssTime } from './css-time';
@@ -0,0 +1,2 @@
1
+ export { default as kebabCase } from './kebab-case';
2
+ export { default as cssTime } from './css-time';
@@ -0,0 +1 @@
1
+ export default function (str: String): string;
@@ -0,0 +1,11 @@
1
+ export default function (str) {
2
+ return (str
3
+ // Replace uppercase letters with - + lowercase
4
+ .replace(/([A-Z])/g, '-$1')
5
+ // Replace spaces and underscores with -
6
+ .replace(/[\s_]+/g, '-')
7
+ // Convert to lowercase
8
+ .toLowerCase()
9
+ // Remove leading/trailing dashes
10
+ .replace(/^-+|-+$/g, ''));
11
+ }