@swiftwc/ui 0.0.0-dev.1 → 0.0.0-dev.13

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 (263) hide show
  1. package/README.md +15 -0
  2. package/generated/client/index.d.ts +16 -2
  3. package/generated/client/index.js +298 -8
  4. package/generated/components/body-view.d.ts +5 -0
  5. package/generated/components/body-view.js +11 -0
  6. package/generated/components/bordered-button.d.ts +7 -0
  7. package/generated/components/bordered-button.js +20 -0
  8. package/generated/components/bordered-prominent-button.d.ts +7 -0
  9. package/generated/components/bordered-prominent-button.js +20 -0
  10. package/generated/components/borderless-button.d.ts +9 -0
  11. package/generated/components/borderless-button.js +35 -0
  12. package/generated/components/confirmation-dialog.d.ts +9 -0
  13. package/generated/components/confirmation-dialog.js +102 -0
  14. package/generated/components/date-picker.d.ts +46 -0
  15. package/generated/components/date-picker.js +430 -0
  16. package/generated/components/disclosure-group.d.ts +9 -0
  17. package/generated/components/disclosure-group.js +51 -0
  18. package/generated/components/form-view.d.ts +6 -0
  19. package/generated/components/form-view.js +58 -0
  20. package/generated/components/glass-button.d.ts +6 -0
  21. package/generated/components/glass-button.js +17 -0
  22. package/generated/components/glass-prominent-button.d.ts +6 -0
  23. package/generated/components/glass-prominent-button.js +17 -0
  24. package/generated/components/index.d.ts +39 -1
  25. package/generated/components/index.js +38 -5
  26. package/generated/components/label-view.d.ts +9 -0
  27. package/generated/components/label-view.js +83 -0
  28. package/generated/components/list-view.d.ts +5 -0
  29. package/generated/components/list-view.js +29 -0
  30. package/generated/components/menu-view.d.ts +9 -0
  31. package/generated/components/menu-view.js +133 -0
  32. package/generated/components/navigation-large-title.d.ts +6 -0
  33. package/generated/components/navigation-large-title.js +177 -0
  34. package/generated/components/navigation-split-view.d.ts +7 -0
  35. package/generated/components/navigation-split-view.js +18 -0
  36. package/generated/components/navigation-stack.d.ts +7 -0
  37. package/generated/components/navigation-stack.js +24 -0
  38. package/generated/components/navigation-title.d.ts +8 -0
  39. package/generated/components/navigation-title.js +66 -0
  40. package/generated/components/picker-view.d.ts +27 -0
  41. package/generated/components/picker-view.js +442 -0
  42. package/generated/components/plain-button.d.ts +7 -0
  43. package/generated/components/plain-button.js +20 -0
  44. package/generated/components/screen-view.d.ts +5 -0
  45. package/generated/components/screen-view.js +9 -0
  46. package/generated/components/scroll-view.d.ts +10 -0
  47. package/generated/components/scroll-view.js +187 -0
  48. package/generated/components/section-view.d.ts +9 -0
  49. package/generated/components/section-view.js +81 -0
  50. package/generated/components/sheet-view.d.ts +9 -0
  51. package/generated/components/sheet-view.js +69 -0
  52. package/generated/components/sidebar-toggle.d.ts +7 -0
  53. package/generated/components/sidebar-toggle.js +107 -0
  54. package/generated/components/sidebar-view.d.ts +7 -0
  55. package/generated/components/sidebar-view.js +29 -0
  56. package/generated/components/sticky-container.d.ts +6 -0
  57. package/generated/components/sticky-container.js +22 -0
  58. package/generated/components/tab-bar.d.ts +7 -0
  59. package/generated/components/tab-bar.js +33 -0
  60. package/generated/components/tab-item.d.ts +7 -0
  61. package/generated/components/tab-item.js +120 -0
  62. package/generated/components/tab-view.d.ts +22 -0
  63. package/generated/components/tab-view.js +256 -0
  64. package/generated/components/table-view.d.ts +7 -0
  65. package/generated/components/table-view.js +175 -0
  66. package/generated/components/text-field.d.ts +29 -0
  67. package/generated/components/text-field.js +489 -0
  68. package/generated/components/tool-bar-item-group.d.ts +5 -0
  69. package/generated/components/tool-bar-item-group.js +11 -0
  70. package/generated/components/tool-bar-item.d.ts +5 -0
  71. package/generated/components/tool-bar-item.js +19 -0
  72. package/generated/components/tool-bar.d.ts +7 -0
  73. package/generated/components/tool-bar.js +77 -0
  74. package/generated/components/v-keyboard.d.ts +11 -0
  75. package/generated/components/v-keyboard.js +81 -0
  76. package/generated/components/v-stack.d.ts +5 -0
  77. package/generated/components/v-stack.js +11 -0
  78. package/generated/confirmation-dialog/index.d.ts +1 -0
  79. package/generated/confirmation-dialog/index.js +1 -0
  80. package/generated/css/index.css +7466 -0
  81. package/generated/events/confirmation-dialog.d.ts +9 -0
  82. package/generated/events/confirmation-dialog.js +1 -0
  83. package/generated/events/date-picker.d.ts +8 -0
  84. package/generated/events/date-picker.js +1 -0
  85. package/generated/events/index.d.ts +7 -0
  86. package/generated/events/index.js +7 -0
  87. package/generated/events/lifecycle-observer.d.ts +10 -0
  88. package/generated/events/lifecycle-observer.js +1 -0
  89. package/generated/events/picker-view.d.ts +8 -0
  90. package/generated/events/picker-view.js +1 -0
  91. package/generated/events/scroll-view.d.ts +10 -0
  92. package/generated/events/scroll-view.js +1 -0
  93. package/generated/events/tab-view.d.ts +24 -0
  94. package/generated/events/tab-view.js +1 -0
  95. package/generated/events/text-field.d.ts +8 -0
  96. package/generated/events/text-field.js +1 -0
  97. package/generated/i18n/index.d.ts +24 -0
  98. package/generated/i18n/index.js +139 -0
  99. package/generated/index.js +1 -1
  100. package/generated/internal/class/cleanup-registry.d.ts +5 -0
  101. package/generated/internal/class/cleanup-registry.js +38 -0
  102. package/generated/internal/class/css-style-observer.d.ts +8 -0
  103. package/generated/internal/class/css-style-observer.js +25 -0
  104. package/generated/internal/class/form-associated-base.d.ts +20 -0
  105. package/generated/internal/class/form-associated-base.js +93 -0
  106. package/generated/internal/class/mutation-observer-singleton.d.ts +10 -0
  107. package/generated/internal/class/mutation-observer-singleton.js +46 -0
  108. package/generated/internal/class/navigation-path.d.ts +15 -0
  109. package/generated/internal/class/navigation-path.js +84 -0
  110. package/generated/internal/class/navigation-view.d.ts +8 -0
  111. package/generated/internal/class/navigation-view.js +77 -0
  112. package/generated/internal/class/resize-observer-singleton.d.ts +7 -0
  113. package/generated/internal/class/resize-observer-singleton.js +22 -0
  114. package/generated/internal/decorators/custom-element.d.ts +5 -0
  115. package/generated/internal/decorators/custom-element.js +4 -0
  116. package/generated/internal/privateNamespace.d.ts +4 -0
  117. package/generated/internal/privateNamespace.js +1 -0
  118. package/generated/internal/utils/add.d.ts +1 -0
  119. package/generated/internal/utils/add.js +7 -0
  120. package/generated/internal/utils/cash/ancestors.d.ts +1 -0
  121. package/generated/internal/utils/cash/ancestors.js +27 -0
  122. package/generated/internal/utils/cash/index.d.ts +22 -0
  123. package/generated/internal/utils/cash/index.js +23 -0
  124. package/generated/internal/utils/cash/next-all.d.ts +1 -0
  125. package/generated/internal/utils/cash/next-all.js +10 -0
  126. package/generated/internal/utils/cash/next.d.ts +1 -0
  127. package/generated/internal/utils/cash/next.js +9 -0
  128. package/generated/internal/utils/cash/prev-all.d.ts +1 -0
  129. package/generated/internal/utils/cash/prev-all.js +10 -0
  130. package/generated/internal/utils/cash/prev.d.ts +1 -0
  131. package/generated/internal/utils/cash/prev.js +9 -0
  132. package/generated/internal/utils/cash/prop.d.ts +18 -0
  133. package/generated/internal/utils/cash/prop.js +30 -0
  134. package/generated/internal/utils/cash/siblings.d.ts +1 -0
  135. package/generated/internal/utils/cash/siblings.js +10 -0
  136. package/generated/internal/utils/clamp.d.ts +1 -0
  137. package/generated/internal/utils/clamp.js +4 -0
  138. package/generated/internal/utils/compare-big-decimals.d.ts +1 -0
  139. package/generated/internal/utils/compare-big-decimals.js +90 -0
  140. package/generated/internal/utils/css-time.d.ts +1 -0
  141. package/generated/internal/utils/css-time.js +3 -0
  142. package/generated/internal/utils/debounce.d.ts +1 -0
  143. package/generated/internal/utils/debounce.js +13 -0
  144. package/generated/internal/utils/frame.d.ts +1 -0
  145. package/generated/internal/utils/frame.js +6 -0
  146. package/generated/internal/utils/index.d.ts +17 -1
  147. package/generated/internal/utils/index.js +18 -1
  148. package/generated/internal/utils/kebab-case.d.ts +1 -1
  149. package/generated/internal/utils/kebab-case.js +3 -3
  150. package/generated/internal/utils/list-active.d.ts +7 -0
  151. package/generated/internal/utils/list-active.js +28 -0
  152. package/generated/internal/utils/microtask.d.ts +1 -0
  153. package/generated/internal/utils/microtask.js +3 -0
  154. package/generated/internal/utils/onoff.d.ts +45 -0
  155. package/generated/internal/utils/onoff.js +31 -0
  156. package/generated/internal/utils/set.d.ts +1 -0
  157. package/generated/internal/utils/set.js +7 -0
  158. package/generated/internal/utils/sleep.d.ts +1 -0
  159. package/generated/internal/utils/sleep.js +3 -0
  160. package/generated/internal/utils/slow-hide-show.d.ts +1 -0
  161. package/generated/internal/utils/slow-hide-show.js +16 -0
  162. package/generated/internal/utils/timeout.d.ts +5 -0
  163. package/generated/internal/utils/timeout.js +16 -0
  164. package/generated/internal/utils/touch-glass.d.ts +7 -0
  165. package/generated/internal/utils/touch-glass.js +19 -0
  166. package/generated/lifecycle-observer/index.d.ts +1 -0
  167. package/generated/lifecycle-observer/index.js +1 -0
  168. package/generated/namespace-browser/base.d.ts +36 -0
  169. package/generated/namespace-browser/base.js +92 -0
  170. package/generated/namespace-browser/index.d.ts +7 -0
  171. package/generated/namespace-browser/index.js +1 -0
  172. package/generated/snapshot/index.d.ts +7 -0
  173. package/generated/snapshot/index.js +37 -0
  174. package/package.json +28 -8
  175. package/scss/_base.scss +5 -0
  176. package/scss/_components.scss +75 -0
  177. package/scss/_final.scss +1 -0
  178. package/scss/_functions.scss +21 -0
  179. package/scss/_mixins.scss +3 -0
  180. package/scss/_placeholders.scss +3 -0
  181. package/scss/_transitions.scss +27 -0
  182. package/scss/_utils.scss +9 -0
  183. package/scss/_vars.scss +174 -0
  184. package/scss/base/_layout.scss +56 -0
  185. package/scss/base/_reboot.scss +158 -0
  186. package/scss/base/_root.scss +399 -0
  187. package/scss/colors/_index.scss +653 -0
  188. package/scss/components/_body-view.scss +17 -0
  189. package/scss/components/_bordered-button.scss +22 -0
  190. package/scss/components/_bordered-prominent-button.scss +19 -0
  191. package/scss/components/_borderless-button.scss +19 -0
  192. package/scss/components/_confirmation-dialog.scss +110 -0
  193. package/scss/components/_date-picker.scss +30 -0
  194. package/scss/components/_detail-placeholder.scss +155 -0
  195. package/scss/components/_disclosure-group.scss +128 -0
  196. package/scss/components/_form-view.scss +195 -0
  197. package/scss/components/_full-screen.scss +15 -0
  198. package/scss/components/_glass-button.scss +24 -0
  199. package/scss/components/_glass-prominent-button.scss +24 -0
  200. package/scss/components/_h-divider.scss +13 -0
  201. package/scss/components/_h-stack.scss +39 -0
  202. package/scss/components/_index.scss +241 -0
  203. package/scss/components/_label-view.scss +386 -0
  204. package/scss/components/_labeled-content.scss +9 -0
  205. package/scss/components/_list-view.scss +229 -0
  206. package/scss/components/_menu-view.scss +188 -0
  207. package/scss/components/_navigation-large-title.scss +27 -0
  208. package/scss/components/_navigation-split-view.scss +424 -0
  209. package/scss/components/_navigation-stack.scss +11 -0
  210. package/scss/components/_navigation-title.scss +10 -0
  211. package/scss/components/_picker-view.scss +122 -0
  212. package/scss/components/_plain-button.scss +11 -0
  213. package/scss/components/_scroll-view-proxy.scss +79 -0
  214. package/scss/components/_scroll-view-toolbars.scss +126 -0
  215. package/scss/components/_scroll-view.scss +130 -0
  216. package/scss/components/_section-view.scss +119 -0
  217. package/scss/components/_sheet-view.scss +93 -0
  218. package/scss/components/_sidebar-toggle.scss +124 -0
  219. package/scss/components/_sidebar-view.scss +53 -0
  220. package/scss/components/_sticky-container.scss +42 -0
  221. package/scss/components/_tab-bar.scss +257 -0
  222. package/scss/components/_tab-item.scss +25 -0
  223. package/scss/components/_tab-view.scss +310 -0
  224. package/scss/components/_table-column.scss +52 -0
  225. package/scss/components/_table-row.scss +172 -0
  226. package/scss/components/_table-view.scss +223 -0
  227. package/scss/components/_text-field.scss +37 -0
  228. package/scss/components/_tool-bar-item-group.scss +48 -0
  229. package/scss/components/_tool-bar-item.scss +145 -0
  230. package/scss/components/_tool-bar.scss +133 -0
  231. package/scss/components/_v-divider.scss +13 -0
  232. package/scss/components/_v-flex-stack.scss +29 -0
  233. package/scss/components/_v-keyboard.scss +14 -0
  234. package/scss/components/_v-stack.scss +18 -0
  235. package/scss/final/_touch-glass.scss +67 -0
  236. package/scss/index.scss +18 -1
  237. package/scss/mixins/_dialog.scss +88 -0
  238. package/scss/mixins/_index.scss +405 -0
  239. package/scss/placeholders/_buttons.scss +83 -0
  240. package/scss/placeholders/_lists.scss +589 -0
  241. package/scss/transitions/_bwd.navbar.scss +19 -0
  242. package/scss/transitions/_bwd.scss +39 -0
  243. package/scss/transitions/_confirmation-dialog.scss +19 -0
  244. package/scss/transitions/_dialog.scss +28 -0
  245. package/scss/transitions/_disclosure-group.scss +35 -0
  246. package/scss/transitions/_fwd.navbar.scss +41 -0
  247. package/scss/transitions/_fwd.scss +24 -0
  248. package/scss/transitions/_glass-button.scss +12 -0
  249. package/scss/transitions/_glass-prominent-button.scss +12 -0
  250. package/scss/transitions/_index.scss +74 -0
  251. package/scss/transitions/_menu-view.scss +26 -0
  252. package/scss/transitions/_navigation-split-view.scss +23 -0
  253. package/scss/transitions/_sidebar-view.scss +36 -0
  254. package/scss/transitions/_tab-bar.scss +19 -0
  255. package/scss/utils/_frame.scss +84 -0
  256. package/scss/utils/_index.scss +68 -0
  257. package/scss/utils/_scroll-view.scss +14 -0
  258. package/scss/utils/_spacing.scss +25 -0
  259. package/scss/utils/_stacks.scss +242 -0
  260. package/web-components.html-data/en.json +330 -0
  261. package/generated/internal/snapshot.d.ts +0 -5
  262. package/generated/internal/snapshot.js +0 -23
  263. package/generated/styles.css +0 -1
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).
@@ -1,2 +1,16 @@
1
- import { Snapshot } from "../internal/snapshot";
2
- export { Snapshot };
1
+ import { ConfirmationDialog } from '../confirmation-dialog';
2
+ import { I18n } from '../i18n';
3
+ import { NavigationPath } from '../internal/class/navigation-path';
4
+ import { LifecycleObserver } from '../lifecycle-observer';
5
+ import { type WebComponentCtor } from '../namespace-browser';
6
+ import { Snapshot } from '../snapshot';
7
+ export declare const polyfills: Map<string, WebComponentCtor>;
8
+ type TransitionType = 'forwards' | 'backwards' | 'reload';
9
+ type UpdateCallback = () => void | Promise<void>;
10
+ type NavigateOptions = {
11
+ updateCallback?: UpdateCallback;
12
+ tos?: () => NavigationPath[];
13
+ };
14
+ export declare const startViewTransition: (target: HTMLElement, type?: TransitionType, updateCallbackOrOptions?: UpdateCallback | NavigateOptions) => Promise<void>;
15
+ export declare const confirmationDialog: (trigger: HTMLElement, title: string, entries: Array<[string, any]>, controller?: AbortController) => Promise<unknown>;
16
+ export { ConfirmationDialog, I18n, LifecycleObserver, NavigationPath, Snapshot };
@@ -1,8 +1,298 @@
1
- import { kebabCase } from "../internal/utils";
2
- console.log(kebabCase(`Hello client!`));
3
- import { Snapshot } from "../internal/snapshot";
4
- console.log(77, Snapshot);
5
- console.log(88, Snapshot.count);
6
- Snapshot.getSnapshot();
7
- console.log(99, Snapshot);
8
- export { Snapshot };
1
+ import * as Components from '../components';
2
+ import { ConfirmationDialog } from '../confirmation-dialog';
3
+ import { I18n } from '../i18n';
4
+ import { NavigationPath } from '../internal/class/navigation-path';
5
+ import { $, kebabCase, onoff } from '../internal/utils';
6
+ import { LifecycleObserver } from '../lifecycle-observer';
7
+ import { Snapshot } from '../snapshot';
8
+ export const polyfills = new Map();
9
+ for (const [k, Ctor] of Object.entries(Components)) {
10
+ const is = kebabCase(k);
11
+ if ('polyfillExtends' in Ctor && 'string' === typeof Ctor.polyfillExtends) {
12
+ if (customElements.get(is))
13
+ continue;
14
+ customElements.define(is, Ctor, { extends: Ctor.polyfillExtends });
15
+ if (!(document.createElement(Ctor.polyfillExtends, { is }) instanceof Ctor))
16
+ polyfills.set(is, Ctor);
17
+ // const testEl = document.createElement('template')
18
+ // testEl.innerHTML = `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`
19
+ // const testNode = testEl.content.firstElementChild,
20
+ if (!($(`<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`) instanceof Ctor))
21
+ polyfills.set(is, Ctor);
22
+ continue;
23
+ }
24
+ if (!customElements.get(is))
25
+ customElements.define(is, Ctor);
26
+ }
27
+ console.debug(polyfills);
28
+ if (0 < polyfills.size) {
29
+ const polyfillTagNamesCache = new Set([...polyfills.values()].map((v) => String(v.polyfillExtends ?? '').toUpperCase()).filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
30
+ const handlers = new WeakMap();
31
+ const observe = (el, polyfill) => {
32
+ if (!Array.isArray(polyfill.observedAttributes))
33
+ return;
34
+ if (0 === polyfill?.observedAttributes.length)
35
+ return;
36
+ if (!polyfill.polyfillAttributeChangedCallback)
37
+ return;
38
+ const observer = new MutationObserver(polyfill.polyfillAttributeChangedCallback);
39
+ observer.observe(el, {
40
+ attributes: true,
41
+ attributeFilter: polyfill.observedAttributes,
42
+ attributeOldValue: true,
43
+ });
44
+ handlers.set(el, observer);
45
+ for (const attributeName of polyfill.observedAttributes)
46
+ if (el.hasAttribute(attributeName)) {
47
+ const entry = {
48
+ attributeName,
49
+ oldValue: null,
50
+ target: el,
51
+ };
52
+ void polyfill.polyfillAttributeChangedCallback([entry]);
53
+ }
54
+ }, unobserve = (el) => {
55
+ handlers.delete(el);
56
+ }, polyfillTagNamesCacheSelector = [...polyfillTagNamesCache.values()].map((v) => `${v}`.toLowerCase()).join(','), flatten = (node) => [node, ...(node.querySelectorAll?.(polyfillTagNamesCacheSelector) ?? [])];
57
+ console.debug(polyfillTagNamesCache, polyfillTagNamesCacheSelector);
58
+ for (const [is, polyfill] of polyfills)
59
+ for (const el of document.querySelectorAll(`${polyfill.polyfillExtends}[is="${CSS.escape(is)}"]`)) {
60
+ polyfill.polyfillConnectedCallback(el);
61
+ observe(el, polyfill);
62
+ }
63
+ // observer callback
64
+ const observer = new MutationObserver((mutations) => {
65
+ for (const { addedNodes, removedNodes } of mutations) {
66
+ for (const root of addedNodes) {
67
+ if (!(root instanceof HTMLElement))
68
+ continue;
69
+ for (const node of flatten(root)) {
70
+ if (!(node instanceof HTMLElement))
71
+ continue;
72
+ if (!polyfillTagNamesCache.has(node.tagName))
73
+ continue;
74
+ const is = node?.getAttribute('is') ?? '';
75
+ if (!polyfills.has(is))
76
+ continue;
77
+ polyfills.get(is)?.polyfillConnectedCallback(node);
78
+ observe(node, polyfills.get(is));
79
+ }
80
+ }
81
+ for (const root of removedNodes) {
82
+ if (!(root instanceof HTMLElement))
83
+ continue;
84
+ for (const node of flatten(root)) {
85
+ if (!(node instanceof HTMLElement))
86
+ continue;
87
+ if (!polyfillTagNamesCache.has(node.tagName))
88
+ continue;
89
+ const is = node?.getAttribute('is') ?? '';
90
+ if (!polyfills.has(is))
91
+ continue;
92
+ polyfills.get(is)?.polyfillDisconnectedCallback(node);
93
+ unobserve(node);
94
+ }
95
+ }
96
+ }
97
+ });
98
+ observer.observe(document.body, {
99
+ childList: true,
100
+ subtree: true,
101
+ });
102
+ }
103
+ // SECTION: Safari polyfill
104
+ document.addEventListener('touchstart', () => { }, { passive: true });
105
+ // SECTION: Transitions
106
+ const cleanup = (lm, type) => {
107
+ let arr = [Snapshot.config['vt-fwd-class-name'], 'fwdd', 'fwn', 'fwnn', 'bwd', 'bwdd', 'bwn', 'bwnn'];
108
+ if (['backwards', 'forwards'].includes(type ?? ''))
109
+ for (let i = arr.length - 1; i >= 0; i--)
110
+ if (arr[i].startsWith('backwards' === type ? 'fw' : 'bw'))
111
+ arr.splice(i, 1);
112
+ for (const el of [...(lm?.querySelectorAll(arr.map((v) => `.${v}`).join(',')) ?? [])])
113
+ el.classList.remove(...arr);
114
+ };
115
+ export const startViewTransition = async (target, type = 'forwards', updateCallbackOrOptions = async () => { }) => {
116
+ console.debug(`startViewTransition (${type})`, target);
117
+ if (!(target instanceof HTMLElement))
118
+ throw new TypeError("Argument 1 ('target') to client.startViewTransition must be an instance of HTMLElement");
119
+ if (!['forwards', 'backwards', 'reload'].includes(type))
120
+ throw new TypeError("Argument 2 ('type') to client.startViewTransition must be of TransitionType");
121
+ const options = typeof updateCallbackOrOptions === 'function'
122
+ ? {
123
+ updateCallback: updateCallbackOrOptions,
124
+ }
125
+ : (updateCallbackOrOptions ?? {}), updateCallback = options.updateCallback ?? (async () => { });
126
+ await Snapshot.waitReady;
127
+ const from = new NavigationPath(target); //const from = closestBody(target) //event.target as HTMLElement)
128
+ if ('forwards' === type) {
129
+ await updateCallback(); // updatetheDOMSomehow
130
+ // Snapshot.getSnapshot(from)
131
+ // const root = getRootViewController(from)
132
+ // const oldPath = new NavigationPath(from)
133
+ const root = [from, ...from.parents()]
134
+ .map((item) => item.component)
135
+ .filter(Boolean)
136
+ .at(-1);
137
+ // const { toolBarConfig: oldToolbars } = getComputedView(from) // const { toolBarConfig: oldToolbars, slot: oldSLot, page: oldPage } = getComputedView(from) //
138
+ // console.log(88, oldPage, oldPath.page, oldSLot, oldPath.slot, oldToolbars, oldPath.toolBarConfig)
139
+ // const oldToolbars = Snapshot.toolbarItems
140
+ // const { toolBarConfig: oldToolbars, host: oldHost } = getComputedView(from)
141
+ const tos = options.tos?.() ?? [...from.children()].map((item) => item?.hydrate()), //queryBodyAll(oldSLot), //[...oldPath.children()].map((item) => item.body).filter(Boolean),//
142
+ to = tos.at(-1),
143
+ // to = newPath?.body, //tos.slice(-1)?.pop?.(), //Snapshot.leaf, //
144
+ // newHost = newPath?.component, //{ host: newHost } = getComputedView(to),
145
+ newToolbars = tos.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item),
146
+ // .map((item) => item.toolBarConfig)
147
+ // .flat()
148
+ // .filter(Boolean), //queryToolbarConfigAll(oldSLot),
149
+ modalViews = tos.map((item) => item.component).filter((item) => !!item && item.matches('dialog')); //[...queryHostAll(oldPage)].filter?.((item) => item?.matches('dialog'))
150
+ // toFrame = Snapshot.leafContainer, //queryHostAll(from).slice(-1)?.pop?.(),
151
+ // toToolbars = Snapshot.leafToolbarItems
152
+ // dialogFrames = [toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item): item is HTMLDialogElement => item instanceof HTMLDialogElement) //[toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item) => item?.matches('dialog'))
153
+ // if ('DIALOG' === newHost?.tagName) {
154
+ // ;(newHost as HTMLDialogElement).showModal()
155
+ // console.debug(`⚡️ view-transition-start (${type})`)
156
+ // await Promise.allSettled(newHost.getAnimations().map(({ finished }) => finished))
157
+ // console.debug(`⚡️ view-transition-end (${type})`)
158
+ // return
159
+ // }
160
+ // purge
161
+ cleanup(root, 'backwards');
162
+ // prepare old
163
+ from.body?.classList.add(Snapshot.config['vt-fwd-class-name']);
164
+ from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
165
+ for (const oldToolbar of from.toolBarConfig ?? [])
166
+ oldToolbar.classList.add('fwn'); // prepare navbs
167
+ // prepare new
168
+ const toolbarExclusion = 0 < modalViews.length
169
+ ? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar,body-view ~ tool-bar)')
170
+ : (value, index, array) => value.parentElement?.matches('tool-bar:not(body-view ~ tool-bar)'), bodyExclusion = 0 < modalViews.length
171
+ ? (item) => item.body?.matches('scroll-view:not(dialog scroll-view)')
172
+ : (value, index, array) => value;
173
+ for (const bti of newToolbars?.filter?.(toolbarExclusion) ?? [])
174
+ bti.classList.add('fwnn'); // for (const ti of newToolbars ?? []) ti.classList.add('fwnn') //
175
+ for (const bt of tos?.filter?.(bodyExclusion) ?? []) {
176
+ bt.body?.classList.add('fwdd'); //to?.classList.add('fwdd')
177
+ bt.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: bt.body }, bubbles: true, composed: true }));
178
+ }
179
+ if (0 < modalViews.length) {
180
+ for await (const el of modalViews)
181
+ el.showModal();
182
+ console.debug(`⚡️ view-dialog-transition-start (${type})`);
183
+ await Promise.allSettled(modalViews?.[0].getAnimations().map(({ finished }) => finished));
184
+ console.debug(`⚡️ view-dialog-transition-end (${type})`);
185
+ }
186
+ else {
187
+ console.debug(`⚡️ view-transition-start (${type})`);
188
+ await Promise.allSettled([
189
+ ...(from.body?.getAnimations().map(({ finished }) => finished) ?? []),
190
+ ...(to?.body?.getAnimations().map(({ finished }) => finished) ?? []),
191
+ ]);
192
+ console.debug(`⚡️ view-transition-end (${type})`);
193
+ }
194
+ if (0 < (to?.component?.querySelectorAll(`.${Snapshot.config?.['vt-fwd-class-name']},.bwd`) ?? []).length)
195
+ return;
196
+ cleanup(root);
197
+ }
198
+ else {
199
+ // Snapshot.getSnapshot(from)
200
+ // const oldPath = new NavigationPath(from)
201
+ const root = [from, ...from.parents()]
202
+ .map((item) => item.component)
203
+ .filter(Boolean)
204
+ .at(-1); // const root = getRootViewController(from)
205
+ //const { toolBarConfig: oldToolbars, host: oldHost, page: oldPage, slot: oldSlot } = getComputedView(from)
206
+ const froms = [...from.children()].map((item) => item?.hydrate());
207
+ const oldToolbars = froms.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item), oldBodies = froms.map((item) => item.body).filter((item) => !!item);
208
+ // console.log(99, queryToolbarConfigAll(oldSlot), oldToolbars)
209
+ // if most-top effect is closing a modal, skip everything
210
+ if ('DIALOG' === from.component?.tagName) {
211
+ from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
212
+ from.component.close();
213
+ console.debug(`⚡️ view-dialog-transition-start (${type})`);
214
+ await Promise.allSettled(from.component.getAnimations().map(({ finished }) => finished));
215
+ console.debug(`⚡️ view-dialog-transition-end (${type})`);
216
+ if (from.component.matches('[open]'))
217
+ return;
218
+ await updateCallback();
219
+ return; // just close modal
220
+ }
221
+ const to = [...from.parents()].at(0)?.hydrate(); //closestBody(oldPath.component?.parentElement ?? undefined)
222
+ // console.log(99, to)
223
+ if (!to)
224
+ return console.debug('Can not go backwards.'); // nothing to go back to
225
+ const tv = to.body?.closest('tab-view');
226
+ if (tv && to.body?.matches('tab-view>navigation-stack:has(> navigation-stack,> navigation-split-view)>:scope'))
227
+ if ('bottom-bar' !== tv.tabBarPlacement)
228
+ return;
229
+ // const { toolBarConfig: newToolbars } = getComputedView(to.body)
230
+ // purge
231
+ cleanup(root, 'forwards');
232
+ // prepare new
233
+ for (const ti of to.toolBarConfig ?? [])
234
+ ti.classList.add('bwnn');
235
+ to.body?.classList.add('bwdd');
236
+ to.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: to.body }, bubbles: true, composed: true }));
237
+ // prepare old
238
+ 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
239
+ toolbarExclusion = 0 < inbetweenModals.length
240
+ ? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar)')
241
+ : (value, index, array) => value, bodyExclusion = 0 < inbetweenModals.length ? (item) => item?.matches('scroll-view:not(dialog scroll-view)') : (item) => item;
242
+ for (const ti of [...(from.toolBarConfig ?? []), ...(oldToolbars?.filter?.(toolbarExclusion) ?? [])])
243
+ ti.classList.add('bwn');
244
+ for (const nn of [from.body, ...oldBodies?.filter?.(bodyExclusion)]) {
245
+ nn?.classList.add('bwd'); //from?.classList.add('bwd')
246
+ nn?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: nn }, bubbles: true, composed: true }));
247
+ }
248
+ for (const el of inbetweenModals)
249
+ el.close(); // close old inbetween modals
250
+ // capture trans
251
+ console.debug(`⚡️ view-transition-start (${type})`);
252
+ await Promise.allSettled([
253
+ ...(from.body?.getAnimations().map(({ finished }) => finished) ?? []),
254
+ ...(to.body?.getAnimations().map(({ finished }) => finished) ?? []),
255
+ ]);
256
+ console.debug(`⚡️ view-transition-end (${type})`);
257
+ if (to.body?.closest(`.bwd,.${Snapshot.config?.['vt-fwd-class-name']}`))
258
+ return;
259
+ cleanup(root);
260
+ // remove or hide
261
+ await updateCallback();
262
+ }
263
+ };
264
+ export const confirmationDialog = async (trigger, title, entries, controller = new AbortController()) => {
265
+ const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
266
+ const dialog = $(`<dialog is="confirmation-dialog">
267
+ ${entries.map((item, index) => `<button type="button" tabindex="0" value="${index}">
268
+ <label-view title="${item[0]}"></label-view>
269
+ </button>`)}
270
+ </dialog>`);
271
+ $.prop('anchor-name', newAnchorName, trigger, 'important');
272
+ $.prop('position-anchor', newAnchorName, dialog);
273
+ if (title) {
274
+ const label = $(`<label-view></label-view>`);
275
+ label.setAttribute('title', title);
276
+ dialog.insertAdjacentElement('afterbegin', label);
277
+ }
278
+ trigger.closest('body-view')?.insertAdjacentElement('beforeend', dialog); // dialog.showModal()
279
+ return await new Promise((resolve, reject) => {
280
+ const onClose = (evt) => {
281
+ off();
282
+ resolve(evt.detail.returnValue);
283
+ }, off = onoff('return', onClose, ConfirmationDialog, { once: true }).on();
284
+ // const onAbort = () => {
285
+ // cleanup()
286
+ // reject(new DOMException('aborted', 'AbortError'))
287
+ // }
288
+ // const cleanup = () => {
289
+ // ConfirmationDialog.removeEventListener('close', onClose)
290
+ // // controller.signal.removeEventListener('abort', onAbort)
291
+ // }
292
+ // ConfirmationDialog.addEventListener('close', onClose, { once: true })
293
+ // controller.signal.addEventListener('abort', onAbort, { once: true })
294
+ });
295
+ };
296
+ void Snapshot.waitReady; // void Snapshot.setOwnConfig()
297
+ // SECTION
298
+ export { ConfirmationDialog, I18n, LifecycleObserver, NavigationPath, Snapshot };
@@ -0,0 +1,5 @@
1
+ export declare class BodyView extends HTMLElement {
2
+ constructor();
3
+ disconnectedCallback(): void;
4
+ connectedCallback(): void;
5
+ }
@@ -0,0 +1,11 @@
1
+ export class BodyView extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ }
5
+ disconnectedCallback() {
6
+ console.debug(`${BodyView.name} ⚡️ disconnect`);
7
+ }
8
+ connectedCallback() {
9
+ console.debug(`${BodyView.name} ⚡️ connect`);
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ import { ButtonBase } from '../namespace-browser/base';
2
+ export declare class BorderedButton extends ButtonBase {
3
+ #private;
4
+ constructor();
5
+ static polyfillDisconnectedCallback(el: BorderedButton): void;
6
+ static polyfillConnectedCallback(el: BorderedButton): void;
7
+ }
@@ -0,0 +1,20 @@
1
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
2
+ import { onoff } from '../internal/utils';
3
+ import { ButtonBase } from '../namespace-browser/base';
4
+ export class BorderedButton extends ButtonBase {
5
+ constructor() {
6
+ super();
7
+ }
8
+ static polyfillDisconnectedCallback(el) {
9
+ console.debug(`${BorderedButton.name} ⚡️ disconnect`);
10
+ CleanupRegistry.unregister(el);
11
+ }
12
+ static polyfillConnectedCallback(el) {
13
+ console.debug(`${BorderedButton.name} ⚡️ connect`);
14
+ el.tabIndex = 0;
15
+ CleanupRegistry.register(el, onoff('click', BorderedButton.#handleClick, el).on());
16
+ }
17
+ static #handleClick = async (evt) => {
18
+ //
19
+ };
20
+ }
@@ -0,0 +1,7 @@
1
+ import { ButtonBase } from '../namespace-browser/base';
2
+ export declare class BorderedProminentButton extends ButtonBase {
3
+ #private;
4
+ constructor();
5
+ static polyfillDisconnectedCallback(el: BorderedProminentButton): void;
6
+ static polyfillConnectedCallback(el: BorderedProminentButton): void;
7
+ }
@@ -0,0 +1,20 @@
1
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
2
+ import { onoff } from '../internal/utils';
3
+ import { ButtonBase } from '../namespace-browser/base';
4
+ export class BorderedProminentButton extends ButtonBase {
5
+ constructor() {
6
+ super();
7
+ }
8
+ static polyfillDisconnectedCallback(el) {
9
+ console.debug(`${BorderedProminentButton.name} ⚡️ disconnect`);
10
+ CleanupRegistry.unregister(el);
11
+ }
12
+ static polyfillConnectedCallback(el) {
13
+ console.debug(`${BorderedProminentButton.name} ⚡️ connect`);
14
+ el.tabIndex = 0;
15
+ CleanupRegistry.register(el, onoff('click', BorderedProminentButton.#handleClick, el).on());
16
+ }
17
+ static #handleClick = async (evt) => {
18
+ //
19
+ };
20
+ }
@@ -0,0 +1,9 @@
1
+ import { ButtonBase } from '../namespace-browser/base';
2
+ export declare class BorderlessButton extends ButtonBase {
3
+ #private;
4
+ static get observedAttributes(): string[];
5
+ constructor();
6
+ static polyfillDisconnectedCallback(el: BorderlessButton): void;
7
+ static polyfillConnectedCallback(el: BorderlessButton): void;
8
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): Promise<void>;
9
+ }
@@ -0,0 +1,35 @@
1
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
2
+ import { onoff } from '../internal/utils';
3
+ import { ButtonBase } from '../namespace-browser/base';
4
+ export class BorderlessButton extends ButtonBase {
5
+ static get observedAttributes() {
6
+ return ['role'];
7
+ }
8
+ constructor() {
9
+ super();
10
+ }
11
+ static polyfillDisconnectedCallback(el) {
12
+ console.debug(`${BorderlessButton.name} ⚡️ disconnect`);
13
+ CleanupRegistry.unregister(el);
14
+ }
15
+ static polyfillConnectedCallback(el) {
16
+ console.debug(`${BorderlessButton.name} ⚡️ connect`);
17
+ el.tabIndex = 0;
18
+ CleanupRegistry.register(el, onoff('click', BorderlessButton.#handleClick, el).on());
19
+ }
20
+ static async polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
21
+ console.debug(`${BorderlessButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
22
+ switch (attributeName) {
23
+ case 'role':
24
+ // let label = this.querySelector(':scope>[slot=label]')
25
+ // if (newValue) {
26
+ // label ??= this.appendChild($(`<label-view slot="label"></label-view>`))
27
+ // label.setAttribute('title', newValue)
28
+ // } else label?.remove()
29
+ break;
30
+ }
31
+ }
32
+ static #handleClick = async (evt) => {
33
+ // alert(99)
34
+ };
35
+ }
@@ -0,0 +1,9 @@
1
+ import { DialogBase } from '../namespace-browser/base';
2
+ export declare class ConfirmationDialog extends DialogBase {
3
+ #private;
4
+ static get observedAttributes(): string[];
5
+ constructor();
6
+ static polyfillDisconnectedCallback(el: ConfirmationDialog): void;
7
+ static polyfillConnectedCallback(el: ConfirmationDialog): void;
8
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): Promise<void>;
9
+ }
@@ -0,0 +1,102 @@
1
+ import { ConfirmationDialog as EvtBus } from '../confirmation-dialog';
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 ConfirmationDialog extends DialogBase {
6
+ static get observedAttributes() {
7
+ return ['anchor'];
8
+ }
9
+ constructor() {
10
+ super();
11
+ }
12
+ static polyfillDisconnectedCallback(el) {
13
+ console.debug(`${ConfirmationDialog.name} ⚡️ disconnect`);
14
+ const positionAnchor = el.style.getPropertyValue('position-anchor');
15
+ $.prop('anchor-name', null, document.querySelector(`[style*="${positionAnchor}"]`));
16
+ $.prop('position-anchor', null, el);
17
+ CleanupRegistry.unregister(el);
18
+ EvtBus.dispatchEvent(new CustomEvent('return', {
19
+ detail: { returnValue: el.returnValue, positionAnchor },
20
+ bubbles: true,
21
+ composed: true,
22
+ }));
23
+ }
24
+ static polyfillConnectedCallback(el) {
25
+ console.debug(`${ConfirmationDialog.name} ⚡️ connect`);
26
+ CleanupRegistry.register(el, onoff([
27
+ { types: 'click', listener: this.#handleDialogClick },
28
+ { types: 'close', listener: this.#handleDialogClose },
29
+ { types: 'cancel', listener: this.#handleDialogCancel },
30
+ ], el).on());
31
+ CleanupRegistry.register(el, onoff(touchGlass(el, (t) => t, (evt) => {
32
+ if (evt.target.matches('[is=confirmation-dialog]'))
33
+ return false;
34
+ // if (!(event.target as HTMLElement).closest('menu-view[open]')) return false
35
+ return true;
36
+ }), el).on());
37
+ console.debug(`${ConfirmationDialog.name} ⚡️ will-open`);
38
+ el.removeAttribute('closing');
39
+ el.scrollTop = 0;
40
+ el.returnValue = '';
41
+ el.showModal();
42
+ }
43
+ static async polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
44
+ console.debug(`${ConfirmationDialog.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
45
+ // const newValue = (target as HTMLElement).getAttribute(attributeName ?? '')
46
+ switch (attributeName) {
47
+ case 'label':
48
+ // let label = this.querySelector(':scope>[slot=label]')
49
+ // if (newValue) {
50
+ // label ??= this.appendChild($(`<label-view slot="label"></label-view>`))
51
+ // label.setAttribute('title', newValue)
52
+ // } else label?.remove()
53
+ break;
54
+ }
55
+ }
56
+ static #handleDialogClick = (evt) => {
57
+ console.debug(`${ConfirmationDialog.name} ⚡️ ${evt?.type}`);
58
+ const dialog = evt.currentTarget;
59
+ if (!dialog)
60
+ return;
61
+ const target = evt.target;
62
+ const rect = dialog.getBoundingClientRect();
63
+ const isInside = evt.clientX >= rect.left && evt.clientX <= rect.right && evt.clientY >= rect.top && evt.clientY <= rect.bottom;
64
+ if (target?.matches('dialog') && !isInside)
65
+ return dialog?.requestClose(); // click outside
66
+ const button = target?.closest('button');
67
+ if (!button)
68
+ return;
69
+ button.scrollIntoView({
70
+ behavior: self.matchMedia('(prefers-reduced-motion: no-preference)').matches ? 'smooth' : 'instant',
71
+ block: 'nearest',
72
+ inline: 'nearest',
73
+ });
74
+ dialog.returnValue = button.value;
75
+ dialog?.requestClose(button.value);
76
+ evt?.stopPropagation();
77
+ evt?.stopImmediatePropagation();
78
+ };
79
+ static #handleDialogCancel = (evt) => {
80
+ console.debug(`${ConfirmationDialog.name} ⚡️ ${evt?.type}`);
81
+ if (!evt.cancelable)
82
+ return;
83
+ const target = evt.target;
84
+ if (!target)
85
+ return;
86
+ evt.preventDefault();
87
+ target.inert = true;
88
+ console.debug(`${ConfirmationDialog.name} ⚡️ will-close`);
89
+ target.setAttribute('closing', '');
90
+ Promise.allSettled(target.getAnimations().map(({ finished }) => finished)).then(() => {
91
+ if (!target.hasAttribute('closing'))
92
+ return;
93
+ target?.close(target?.returnValue);
94
+ target.removeAttribute('closing');
95
+ });
96
+ };
97
+ static #handleDialogClose = (evt) => {
98
+ console.debug(`${ConfirmationDialog.name} ⚡️ ${evt?.type}`);
99
+ const target = evt.target;
100
+ target?.remove();
101
+ };
102
+ }
@@ -0,0 +1,46 @@
1
+ import { FormAssociatedBase } from '../internal/class/form-associated-base';
2
+ declare const datePickerStyles: readonly ["graphical", "field", "automatic"];
3
+ export type DatePickerStyle = (typeof datePickerStyles)[number];
4
+ export declare class DatePicker extends FormAssociatedBase {
5
+ #private;
6
+ static get observedAttributes(): string[];
7
+ get template(): DocumentFragment;
8
+ constructor();
9
+ connectedCallback(): void;
10
+ disconnectedCallback(): void;
11
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
12
+ get datePickerStyle(): DatePickerStyle;
13
+ get selection(): {
14
+ year: string;
15
+ month: string;
16
+ day: string;
17
+ };
18
+ set selection(v: {
19
+ year: string;
20
+ month: string;
21
+ day: string;
22
+ });
23
+ get name(): string;
24
+ get value(): {
25
+ year: string;
26
+ month: string;
27
+ day: string;
28
+ };
29
+ get valueAsDate(): Date | null;
30
+ get minimum(): {
31
+ year: string;
32
+ month: string;
33
+ day: string;
34
+ } | null;
35
+ get maximum(): {
36
+ year: string;
37
+ month: string;
38
+ day: string;
39
+ } | null;
40
+ setValidity: (flags?: ValidityStateFlags, message?: string, anchor?: HTMLElement) => void;
41
+ setCustomValidity: (message: string) => void;
42
+ formAssociatedCallback: (form: HTMLFormElement) => void;
43
+ formDisabledCallback: (disabled: boolean) => void;
44
+ formResetCallback: () => void;
45
+ }
46
+ export {};