@swiftwc/ui 0.0.0-dev.0 → 0.0.0-dev.11

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 (262) hide show
  1. package/README.md +15 -0
  2. package/generated/client/index.d.ts +16 -2
  3. package/generated/client/index.js +293 -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 +7463 -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 +32 -7
  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 +254 -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
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,293 @@
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
+ continue;
18
+ }
19
+ if (!customElements.get(is))
20
+ customElements.define(is, Ctor);
21
+ }
22
+ console.debug(polyfills);
23
+ if (0 < polyfills.size) {
24
+ const polyfillTagNamesCache = new Set([...polyfills.values()].map((v) => String(v.polyfillExtends ?? '').toUpperCase()).filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
25
+ const handlers = new WeakMap();
26
+ const observe = (el, polyfill) => {
27
+ if (!Array.isArray(polyfill.observedAttributes))
28
+ return;
29
+ if (0 === polyfill?.observedAttributes.length)
30
+ return;
31
+ if (!polyfill.polyfillAttributeChangedCallback)
32
+ return;
33
+ const observer = new MutationObserver(polyfill.polyfillAttributeChangedCallback);
34
+ observer.observe(el, {
35
+ attributes: true,
36
+ attributeFilter: polyfill.observedAttributes,
37
+ attributeOldValue: true,
38
+ });
39
+ handlers.set(el, observer);
40
+ for (const attributeName of polyfill.observedAttributes)
41
+ if (el.hasAttribute(attributeName)) {
42
+ const entry = {
43
+ attributeName,
44
+ oldValue: null,
45
+ target: el,
46
+ };
47
+ void polyfill.polyfillAttributeChangedCallback([entry]);
48
+ }
49
+ }, unobserve = (el) => {
50
+ handlers.delete(el);
51
+ }, polyfillTagNamesCacheSelector = [...polyfillTagNamesCache.values()].map((v) => `${v}`.toLowerCase()).join(','), flatten = (node) => [node, ...(node.querySelectorAll?.(polyfillTagNamesCacheSelector) ?? [])];
52
+ console.debug(polyfillTagNamesCache, polyfillTagNamesCacheSelector);
53
+ for (const [is, polyfill] of polyfills)
54
+ for (const el of document.querySelectorAll(`${polyfill.polyfillExtends}[is="${CSS.escape(is)}"]`)) {
55
+ polyfill.polyfillConnectedCallback(el);
56
+ observe(el, polyfill);
57
+ }
58
+ // observer callback
59
+ const observer = new MutationObserver((mutations) => {
60
+ for (const { addedNodes, removedNodes } of mutations) {
61
+ for (const root of addedNodes) {
62
+ if (!(root instanceof HTMLElement))
63
+ continue;
64
+ for (const node of flatten(root)) {
65
+ if (!(node instanceof HTMLElement))
66
+ continue;
67
+ if (!polyfillTagNamesCache.has(node.tagName))
68
+ continue;
69
+ const is = node?.getAttribute('is') ?? '';
70
+ if (!polyfills.has(is))
71
+ continue;
72
+ polyfills.get(is)?.polyfillConnectedCallback(node);
73
+ observe(node, polyfills.get(is));
74
+ }
75
+ }
76
+ for (const root of removedNodes) {
77
+ if (!(root instanceof HTMLElement))
78
+ continue;
79
+ for (const node of flatten(root)) {
80
+ if (!(node instanceof HTMLElement))
81
+ continue;
82
+ if (!polyfillTagNamesCache.has(node.tagName))
83
+ continue;
84
+ const is = node?.getAttribute('is') ?? '';
85
+ if (!polyfills.has(is))
86
+ continue;
87
+ polyfills.get(is)?.polyfillDisconnectedCallback(node);
88
+ unobserve(node);
89
+ }
90
+ }
91
+ }
92
+ });
93
+ observer.observe(document.body, {
94
+ childList: true,
95
+ subtree: true,
96
+ });
97
+ }
98
+ // SECTION: Safari polyfill
99
+ document.addEventListener('touchstart', () => { }, { passive: true });
100
+ // SECTION: Transitions
101
+ const cleanup = (lm, type) => {
102
+ let arr = [Snapshot.config['vt-fwd-class-name'], 'fwdd', 'fwn', 'fwnn', 'bwd', 'bwdd', 'bwn', 'bwnn'];
103
+ if (['backwards', 'forwards'].includes(type ?? ''))
104
+ for (let i = arr.length - 1; i >= 0; i--)
105
+ if (arr[i].startsWith('backwards' === type ? 'fw' : 'bw'))
106
+ arr.splice(i, 1);
107
+ for (const el of [...(lm?.querySelectorAll(arr.map((v) => `.${v}`).join(',')) ?? [])])
108
+ el.classList.remove(...arr);
109
+ };
110
+ export const startViewTransition = async (target, type = 'forwards', updateCallbackOrOptions = async () => { }) => {
111
+ console.debug(`startViewTransition (${type})`, target);
112
+ if (!(target instanceof HTMLElement))
113
+ throw new TypeError("Argument 1 ('target') to client.startViewTransition must be an instance of HTMLElement");
114
+ if (!['forwards', 'backwards', 'reload'].includes(type))
115
+ throw new TypeError("Argument 2 ('type') to client.startViewTransition must be of TransitionType");
116
+ const options = typeof updateCallbackOrOptions === 'function'
117
+ ? {
118
+ updateCallback: updateCallbackOrOptions,
119
+ }
120
+ : (updateCallbackOrOptions ?? {}), updateCallback = options.updateCallback ?? (async () => { });
121
+ await Snapshot.waitReady;
122
+ const from = new NavigationPath(target); //const from = closestBody(target) //event.target as HTMLElement)
123
+ if ('forwards' === type) {
124
+ await updateCallback(); // updatetheDOMSomehow
125
+ // Snapshot.getSnapshot(from)
126
+ // const root = getRootViewController(from)
127
+ // const oldPath = new NavigationPath(from)
128
+ const root = [from, ...from.parents()]
129
+ .map((item) => item.component)
130
+ .filter(Boolean)
131
+ .at(-1);
132
+ // const { toolBarConfig: oldToolbars } = getComputedView(from) // const { toolBarConfig: oldToolbars, slot: oldSLot, page: oldPage } = getComputedView(from) //
133
+ // console.log(88, oldPage, oldPath.page, oldSLot, oldPath.slot, oldToolbars, oldPath.toolBarConfig)
134
+ // const oldToolbars = Snapshot.toolbarItems
135
+ // const { toolBarConfig: oldToolbars, host: oldHost } = getComputedView(from)
136
+ const tos = options.tos?.() ?? [...from.children()].map((item) => item?.hydrate()), //queryBodyAll(oldSLot), //[...oldPath.children()].map((item) => item.body).filter(Boolean),//
137
+ to = tos.at(-1),
138
+ // to = newPath?.body, //tos.slice(-1)?.pop?.(), //Snapshot.leaf, //
139
+ // newHost = newPath?.component, //{ host: newHost } = getComputedView(to),
140
+ newToolbars = tos.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item),
141
+ // .map((item) => item.toolBarConfig)
142
+ // .flat()
143
+ // .filter(Boolean), //queryToolbarConfigAll(oldSLot),
144
+ modalViews = tos.map((item) => item.component).filter((item) => !!item && item.matches('dialog')); //[...queryHostAll(oldPage)].filter?.((item) => item?.matches('dialog'))
145
+ // toFrame = Snapshot.leafContainer, //queryHostAll(from).slice(-1)?.pop?.(),
146
+ // toToolbars = Snapshot.leafToolbarItems
147
+ // dialogFrames = [toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item): item is HTMLDialogElement => item instanceof HTMLDialogElement) //[toFrame, ...(Snapshot.leaveFrames ?? [])].filter((item) => item?.matches('dialog'))
148
+ // if ('DIALOG' === newHost?.tagName) {
149
+ // ;(newHost as HTMLDialogElement).showModal()
150
+ // console.debug(`⚡️ view-transition-start (${type})`)
151
+ // await Promise.allSettled(newHost.getAnimations().map(({ finished }) => finished))
152
+ // console.debug(`⚡️ view-transition-end (${type})`)
153
+ // return
154
+ // }
155
+ // purge
156
+ cleanup(root, 'backwards');
157
+ // prepare old
158
+ from.body?.classList.add(Snapshot.config['vt-fwd-class-name']);
159
+ from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
160
+ for (const oldToolbar of from.toolBarConfig ?? [])
161
+ oldToolbar.classList.add('fwn'); // prepare navbs
162
+ // prepare new
163
+ const toolbarExclusion = 0 < modalViews.length
164
+ ? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar,body-view ~ tool-bar)')
165
+ : (value, index, array) => value.parentElement?.matches('tool-bar:not(body-view ~ tool-bar)'), bodyExclusion = 0 < modalViews.length
166
+ ? (item) => item.body?.matches('scroll-view:not(dialog scroll-view)')
167
+ : (value, index, array) => value;
168
+ for (const bti of newToolbars?.filter?.(toolbarExclusion) ?? [])
169
+ bti.classList.add('fwnn'); // for (const ti of newToolbars ?? []) ti.classList.add('fwnn') //
170
+ for (const bt of tos?.filter?.(bodyExclusion) ?? []) {
171
+ bt.body?.classList.add('fwdd'); //to?.classList.add('fwdd')
172
+ bt.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: bt.body }, bubbles: true, composed: true }));
173
+ }
174
+ if (0 < modalViews.length) {
175
+ for await (const el of modalViews)
176
+ el.showModal();
177
+ console.debug(`⚡️ view-dialog-transition-start (${type})`);
178
+ await Promise.allSettled(modalViews?.[0].getAnimations().map(({ finished }) => finished));
179
+ console.debug(`⚡️ view-dialog-transition-end (${type})`);
180
+ }
181
+ else {
182
+ console.debug(`⚡️ view-transition-start (${type})`);
183
+ await Promise.allSettled([
184
+ ...(from.body?.getAnimations().map(({ finished }) => finished) ?? []),
185
+ ...(to?.body?.getAnimations().map(({ finished }) => finished) ?? []),
186
+ ]);
187
+ console.debug(`⚡️ view-transition-end (${type})`);
188
+ }
189
+ if (0 < (to?.component?.querySelectorAll(`.${Snapshot.config?.['vt-fwd-class-name']},.bwd`) ?? []).length)
190
+ return;
191
+ cleanup(root);
192
+ }
193
+ else {
194
+ // Snapshot.getSnapshot(from)
195
+ // const oldPath = new NavigationPath(from)
196
+ const root = [from, ...from.parents()]
197
+ .map((item) => item.component)
198
+ .filter(Boolean)
199
+ .at(-1); // const root = getRootViewController(from)
200
+ //const { toolBarConfig: oldToolbars, host: oldHost, page: oldPage, slot: oldSlot } = getComputedView(from)
201
+ const froms = [...from.children()].map((item) => item?.hydrate());
202
+ const oldToolbars = froms.flatMap((item) => item.toolBarConfig ?? []).filter((item) => !!item), oldBodies = froms.map((item) => item.body).filter((item) => !!item);
203
+ // console.log(99, queryToolbarConfigAll(oldSlot), oldToolbars)
204
+ // if most-top effect is closing a modal, skip everything
205
+ if ('DIALOG' === from.component?.tagName) {
206
+ from.body?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: from.body }, bubbles: true, composed: true }));
207
+ from.component.close();
208
+ console.debug(`⚡️ view-dialog-transition-start (${type})`);
209
+ await Promise.allSettled(from.component.getAnimations().map(({ finished }) => finished));
210
+ console.debug(`⚡️ view-dialog-transition-end (${type})`);
211
+ if (from.component.matches('[open]'))
212
+ return;
213
+ await updateCallback();
214
+ return; // just close modal
215
+ }
216
+ const to = [...from.parents()].at(0)?.hydrate(); //closestBody(oldPath.component?.parentElement ?? undefined)
217
+ // console.log(99, to)
218
+ if (!to)
219
+ return console.debug('Can not go backwards.'); // nothing to go back to
220
+ const tv = to.body?.closest('tab-view');
221
+ if (tv && to.body?.matches('tab-view>navigation-stack:has(> navigation-stack,> navigation-split-view)>:scope'))
222
+ if ('bottom-bar' !== tv.tabBarPlacement)
223
+ return;
224
+ // const { toolBarConfig: newToolbars } = getComputedView(to.body)
225
+ // purge
226
+ cleanup(root, 'forwards');
227
+ // prepare new
228
+ for (const ti of to.toolBarConfig ?? [])
229
+ ti.classList.add('bwnn');
230
+ to.body?.classList.add('bwdd');
231
+ to.body?.dispatchEvent(new CustomEvent('pagereveal', { detail: { page: to.body }, bubbles: true, composed: true }));
232
+ // prepare old
233
+ 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
234
+ toolbarExclusion = 0 < inbetweenModals.length
235
+ ? (value, index, array) => value.parentElement?.matches('tool-bar:not(dialog tool-bar)')
236
+ : (value, index, array) => value, bodyExclusion = 0 < inbetweenModals.length ? (item) => item?.matches('scroll-view:not(dialog scroll-view)') : (item) => item;
237
+ for (const ti of [...(from.toolBarConfig ?? []), ...(oldToolbars?.filter?.(toolbarExclusion) ?? [])])
238
+ ti.classList.add('bwn');
239
+ for (const nn of [from.body, ...oldBodies?.filter?.(bodyExclusion)]) {
240
+ nn?.classList.add('bwd'); //from?.classList.add('bwd')
241
+ nn?.dispatchEvent(new CustomEvent('pageswap', { detail: { page: nn }, bubbles: true, composed: true }));
242
+ }
243
+ for (const el of inbetweenModals)
244
+ el.close(); // close old inbetween modals
245
+ // capture trans
246
+ console.debug(`⚡️ view-transition-start (${type})`);
247
+ await Promise.allSettled([
248
+ ...(from.body?.getAnimations().map(({ finished }) => finished) ?? []),
249
+ ...(to.body?.getAnimations().map(({ finished }) => finished) ?? []),
250
+ ]);
251
+ console.debug(`⚡️ view-transition-end (${type})`);
252
+ if (to.body?.closest(`.bwd,.${Snapshot.config?.['vt-fwd-class-name']}`))
253
+ return;
254
+ cleanup(root);
255
+ // remove or hide
256
+ await updateCallback();
257
+ }
258
+ };
259
+ export const confirmationDialog = async (trigger, title, entries, controller = new AbortController()) => {
260
+ const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
261
+ const dialog = $(`<dialog is="confirmation-dialog">
262
+ ${entries.map((item, index) => `<button type="button" tabindex="0" value="${index}">
263
+ <label-view title="${item[0]}"></label-view>
264
+ </button>`)}
265
+ </dialog>`);
266
+ $.prop('anchor-name', newAnchorName, trigger, 'important');
267
+ $.prop('position-anchor', newAnchorName, dialog);
268
+ if (title) {
269
+ const label = $(`<label-view></label-view>`);
270
+ label.setAttribute('title', title);
271
+ dialog.insertAdjacentElement('afterbegin', label);
272
+ }
273
+ trigger.closest('body-view')?.insertAdjacentElement('beforeend', dialog); // dialog.showModal()
274
+ return await new Promise((resolve, reject) => {
275
+ const onClose = (evt) => {
276
+ off();
277
+ resolve(evt.detail.returnValue);
278
+ }, off = onoff('return', onClose, ConfirmationDialog, { once: true }).on();
279
+ // const onAbort = () => {
280
+ // cleanup()
281
+ // reject(new DOMException('aborted', 'AbortError'))
282
+ // }
283
+ // const cleanup = () => {
284
+ // ConfirmationDialog.removeEventListener('close', onClose)
285
+ // // controller.signal.removeEventListener('abort', onAbort)
286
+ // }
287
+ // ConfirmationDialog.addEventListener('close', onClose, { once: true })
288
+ // controller.signal.addEventListener('abort', onAbort, { once: true })
289
+ });
290
+ };
291
+ void Snapshot.waitReady; // void Snapshot.setOwnConfig()
292
+ // SECTION
293
+ 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 {};