@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,6 @@
1
+ export type WebComponentCtor = CustomElementConstructor & {
2
+ polyfillExtends?: string;
3
+ polyfillConnectedCallback(el: HTMLElement): void;
4
+ polyfillDisconnectedCallback(el: HTMLElement): void;
5
+ polyfillAttributeChangedCallback?(entries: MutationRecord[]): void;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import type * as Components from '../components';
2
+ export declare class Snapshot {
3
+ #private;
4
+ static get config(): Record<string, string> | undefined;
5
+ static setOwnConfig(): Promise<void>;
6
+ static get parent(): Components.ScrollView | undefined;
7
+ static get root(): HTMLElement | undefined;
8
+ static get leaf(): Components.ScrollView | undefined;
9
+ static get parentContainer(): HTMLElement | undefined;
10
+ static get leafContainer(): HTMLElement | undefined;
11
+ static get container(): HTMLElement | undefined;
12
+ static get toolbarItems(): NodeListOf<Element> | undefined;
13
+ static get parentToolbarItems(): NodeListOf<Element> | undefined;
14
+ static get leafToolbarItems(): NodeListOf<Element> | undefined;
15
+ static getSnapshot(scrollView?: Components.ScrollView): void;
16
+ }
@@ -0,0 +1,150 @@
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, _Snapshot_config, _Snapshot_getOwnConfig, _Snapshot_parent, _Snapshot_leaf, _Snapshot_root, _Snapshot_parentContainer, _Snapshot_container, _Snapshot_leafContainer, _Snapshot_parentToolbarItems, _Snapshot_toolbarItems, _Snapshot_leafToolbarItems, _Snapshot_queryScrollViewRels;
13
+ export class Snapshot {
14
+ static get config() {
15
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_config);
16
+ }
17
+ static async setOwnConfig() {
18
+ if ('complete' === document.readyState)
19
+ return __classPrivateFieldGet(_a, _a, "m", _Snapshot_getOwnConfig).call(_a); // Page already loaded
20
+ await new Promise((resolve) => self.addEventListener('load', resolve)); // Wait for window load
21
+ return __classPrivateFieldGet(_a, _a, "m", _Snapshot_getOwnConfig).call(_a);
22
+ }
23
+ static get parent() {
24
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_parent);
25
+ }
26
+ static get root() {
27
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_root);
28
+ }
29
+ static get leaf() {
30
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_leaf);
31
+ }
32
+ static get parentContainer() {
33
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_parentContainer);
34
+ }
35
+ static get leafContainer() {
36
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_leafContainer);
37
+ }
38
+ static get container() {
39
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_container);
40
+ }
41
+ static get toolbarItems() {
42
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_toolbarItems);
43
+ }
44
+ static get parentToolbarItems() {
45
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_parentToolbarItems);
46
+ }
47
+ static get leafToolbarItems() {
48
+ return __classPrivateFieldGet(this, _a, "f", _Snapshot_leafToolbarItems);
49
+ }
50
+ static getSnapshot(scrollView) {
51
+ console.debug(`${_a.name} ⚡️ getSnapshot`);
52
+ // root
53
+ for (let e = scrollView; e; e = e.parentElement)
54
+ e.matches('navigation-stack,navigation-split-view') && (__classPrivateFieldSet(this, _a, e, "f", _Snapshot_root));
55
+ // current
56
+ const { frame, toolbarElements: toolbarItems } = __classPrivateFieldGet(this, _a, "f", _Snapshot_queryScrollViewRels).call(this, scrollView);
57
+ __classPrivateFieldSet(this, _a, frame, "f", _Snapshot_container);
58
+ __classPrivateFieldSet(this, _a, toolbarItems, "f", _Snapshot_toolbarItems);
59
+ // parent
60
+ const possibleParent = __classPrivateFieldGet(this, _a, "f", _Snapshot_container)?.parentElement;
61
+ __classPrivateFieldSet(this, _a, possibleParent?.querySelector(`:scope > scroll-view,:scope > [is=sidebar-view] > scroll-view`) ?? undefined, "f", _Snapshot_parent); //const sv2 = pr.parentElement.querySelector(`:scope > scroll-view`) //pr.previousElementSibling
62
+ const { frame: parentFrame, toolbarElements: parentToolbarItems } = __classPrivateFieldGet(this, _a, "f", _Snapshot_queryScrollViewRels).call(this, __classPrivateFieldGet(this, _a, "f", _Snapshot_parent));
63
+ __classPrivateFieldSet(this, _a, parentFrame, "f", _Snapshot_parentContainer);
64
+ __classPrivateFieldSet(this, _a, parentToolbarItems, "f", _Snapshot_parentToolbarItems);
65
+ // const possibleParent =
66
+ // this.#container?.parentElement?.querySelector<HTMLElement>(
67
+ // `:scope > scroll-view,:scope > [is=sidebar-view] > scroll-view`
68
+ // ) ?? undefined, //const sv2 = pr.parentElement.querySelector(`:scope > scroll-view`) //pr.previousElementSibling
69
+ // {
70
+ // landmark: parentLm,
71
+ // frame: parentFrame,
72
+ // toolbarElements: parentToolbarItems,
73
+ // } = this.#queryScrollViewRels(possibleParent)
74
+ // this.#parent = parentLm
75
+ // this.#parentContainer = parentFrame
76
+ // this.#parentToolbarItems = parentToolbarItems
77
+ // detect children
78
+ let possibleNest = scrollView?.nextElementSibling;
79
+ if ('NAVIGATION-SPLIT-VIEW' === __classPrivateFieldGet(this, _a, "f", _Snapshot_root)?.tagName)
80
+ if (scrollView?.matches(`navigation-split-view > scroll-view${null !== __classPrivateFieldGet(this, _a, "f", _Snapshot_root).querySelector(':scope > [is=sidebar-view]') ? ',navigation-split-view > [is=sidebar-view] > scroll-view,navigation-split-view > body-view > scroll-view' : ''}`))
81
+ possibleNest = (scrollView?.parentElement?.matches('dialog[is=sidebar-view]')
82
+ ? scrollView?.parentElement
83
+ : scrollView)?.previousElementSibling; // look for prev sibling instead
84
+ // const possibleNest = scrollView?.nextElementSibling as HTMLElement | null
85
+ __classPrivateFieldSet(this, _a, [
86
+ ...(possibleNest?.querySelectorAll('scroll-view:not(navigation-stack[hidden] scroll-view,navigation-split-view[hidden] scroll-view)') ?? []),
87
+ ]?.pop?.(), "f", _Snapshot_leaf); //'navigation-stack:not([hidden]) scroll-view'
88
+ const { frame: leafFrame, toolbarElements: leafToolbarItems } = __classPrivateFieldGet(this, _a, "f", _Snapshot_queryScrollViewRels).call(this, __classPrivateFieldGet(this, _a, "f", _Snapshot_leaf));
89
+ __classPrivateFieldSet(this, _a, leafFrame, "f", _Snapshot_leafContainer);
90
+ __classPrivateFieldSet(this, _a, leafToolbarItems, "f", _Snapshot_leafToolbarItems);
91
+ // const {
92
+ // landmark: leafLm,
93
+ // frame: leafFrame,
94
+ // toolbarElements: leafToolbarItems,
95
+ // } = this.#queryScrollViewRels(
96
+ // [
97
+ // ...(possibleNest?.querySelectorAll<Components.ScrollView>(
98
+ // 'scroll-view:not(navigation-stack[hidden] scroll-view,navigation-split-view[hidden] scroll-view)'
99
+ // ) ?? []),
100
+ // ]?.pop?.()
101
+ // ) //'navigation-stack:not([hidden]) scroll-view'
102
+ // this.#leaf = leafLm
103
+ // this.#leafContainer = leafFrame
104
+ // this.#leafToolbarItems = leafToolbarItems
105
+ console.debug(`${__classPrivateFieldGet(this, _a, "f", _Snapshot_root)?.tagName}
106
+ / \\
107
+ B ${__classPrivateFieldGet(this, _a, "f", _Snapshot_parentContainer)?.tagName}
108
+ / \\
109
+ D ${__classPrivateFieldGet(this, _a, "f", _Snapshot_container)?.tagName}
110
+ / \\
111
+ H ${__classPrivateFieldGet(this, _a, "f", _Snapshot_leafContainer)?.tagName}
112
+ `);
113
+ // this.#childFrame = ['BODY-VIEW', 'NAVIGATION-STACK'].includes(
114
+ // possibleNest?.tagName ?? ''
115
+ // )
116
+ // ? (possibleNest ?? undefined)
117
+ // : undefined
118
+ // this.#childToolbarItems = this.#childFrame?.querySelectorAll(
119
+ // `:scope > navigation-bar > tool-bar-item,:scope > bottom-bar > tool-bar-item`
120
+ // )
121
+ }
122
+ }
123
+ _a = Snapshot, _Snapshot_getOwnConfig = function _Snapshot_getOwnConfig() {
124
+ const style = getComputedStyle(document.documentElement, '::before'), content = style.getPropertyValue('content'), unquoted = content.replace(/^"(.*)"$/, '$1'); // Remove quotes around the content
125
+ try {
126
+ __classPrivateFieldSet(this, _a, Object.fromEntries(new URLSearchParams(unquoted).entries()), "f", _Snapshot_config); // {"none": ""}
127
+ }
128
+ catch {
129
+ console.error('could-not-parse-config');
130
+ }
131
+ console.debug(__classPrivateFieldGet(this, _a, "f", _Snapshot_config));
132
+ };
133
+ _Snapshot_config = { value: void 0 };
134
+ //////
135
+ _Snapshot_parent = { value: void 0 };
136
+ _Snapshot_leaf = { value: void 0 };
137
+ _Snapshot_root = { value: void 0 };
138
+ _Snapshot_parentContainer = { value: void 0 };
139
+ _Snapshot_container = { value: void 0 };
140
+ _Snapshot_leafContainer = { value: void 0 };
141
+ _Snapshot_parentToolbarItems = { value: void 0 };
142
+ _Snapshot_toolbarItems = { value: void 0 };
143
+ _Snapshot_leafToolbarItems = { value: void 0 };
144
+ _Snapshot_queryScrollViewRels = { value: (sv) => {
145
+ const isSidebarWrapped = sv?.parentElement?.matches('dialog[is=sidebar-view]');
146
+ return {
147
+ frame: (isSidebarWrapped ? sv?.parentElement : sv)?.parentElement ?? undefined,
148
+ toolbarElements: sv?.parentElement?.querySelectorAll(`:scope > navigation-bar > tool-bar-item,:scope > bottom-bar > tool-bar-item,:scope > navigation-bar > tool-bar-item-group,:scope > bottom-bar > tool-bar-item-group`),
149
+ };
150
+ } };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swiftwc/ui",
3
- "version": "0.0.0-dev.4",
4
- "description": "Elegant SwiftUI-inspired web components for ambitious web apps and web extensions.",
3
+ "version": "0.0.0-dev.6",
4
+ "description": "Elegant SwiftUI-inspired web components for standalone web apps and web extensions.",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -53,8 +53,8 @@
53
53
  "prebuild": "rm -rf generated",
54
54
  "build": "npm run build:ts && npm run build:scss",
55
55
  "build:ts:watch": "npm run prebuild && tsc --watch",
56
- "build:ts": "npm run prebuild && tsc",
57
- "build:scss": "npm run prebuild && sass --no-source-map scss/index.scss generated/styles.css",
56
+ "build:ts": "tsc",
57
+ "build:scss": "sass --no-source-map scss/index.scss generated/styles.css",
58
58
  "format:check": "prettier . --check",
59
59
  "format:write": "prettier . --write"
60
60
  },