@swiftwc/ui 1.0.0-canary.0 → 1.0.0-canary.2

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/generated/buses/alert-dialog.d.ts +2 -0
  2. package/generated/buses/alert-dialog.js +1 -0
  3. package/generated/buses/confirmation-dialog.d.ts +2 -0
  4. package/generated/buses/confirmation-dialog.js +1 -0
  5. package/generated/buses/index.d.ts +6 -0
  6. package/generated/buses/index.js +6 -0
  7. package/generated/buses/lifecycle-observer.d.ts +2 -0
  8. package/generated/buses/lifecycle-observer.js +1 -0
  9. package/generated/client/index.d.ts +30 -0
  10. package/generated/client/index.js +278 -0
  11. package/generated/components/alert-dialog.d.ts +11 -0
  12. package/generated/components/alert-dialog.js +94 -0
  13. package/generated/components/bordered-button.d.ts +17 -0
  14. package/generated/components/bordered-button.js +53 -0
  15. package/generated/components/bordered-prominent-button.d.ts +17 -0
  16. package/generated/components/bordered-prominent-button.js +53 -0
  17. package/generated/components/borderless-button.d.ts +17 -0
  18. package/generated/components/borderless-button.js +53 -0
  19. package/generated/components/color-scheme.d.ts +12 -0
  20. package/generated/components/color-scheme.js +51 -0
  21. package/generated/components/confirmation-dialog.d.ts +12 -0
  22. package/generated/components/confirmation-dialog.js +108 -0
  23. package/generated/components/content-unavailable.d.ts +30 -0
  24. package/generated/components/content-unavailable.js +79 -0
  25. package/generated/components/content-view.d.ts +13 -0
  26. package/generated/components/content-view.js +15 -0
  27. package/generated/components/date-picker.d.ts +52 -0
  28. package/generated/components/date-picker.js +468 -0
  29. package/generated/components/detail-placeholder.d.ts +11 -0
  30. package/generated/components/detail-placeholder.js +15 -0
  31. package/generated/components/disclosure-group.d.ts +17 -0
  32. package/generated/components/disclosure-group.js +62 -0
  33. package/generated/components/fine-tooltip.d.ts +15 -0
  34. package/generated/components/fine-tooltip.js +108 -0
  35. package/generated/components/form-view.d.ts +16 -0
  36. package/generated/components/form-view.js +63 -0
  37. package/generated/components/glass-button.d.ts +16 -0
  38. package/generated/components/glass-button.js +50 -0
  39. package/generated/components/glass-prominent-button.d.ts +16 -0
  40. package/generated/components/glass-prominent-button.js +50 -0
  41. package/generated/components/h-divider.d.ts +11 -0
  42. package/generated/components/h-divider.js +15 -0
  43. package/generated/components/h-flex-stack.d.ts +16 -0
  44. package/generated/components/h-flex-stack.js +18 -0
  45. package/generated/components/h-stack.d.ts +22 -0
  46. package/generated/components/h-stack.js +24 -0
  47. package/generated/components/image-view.d.ts +18 -0
  48. package/generated/components/image-view.js +65 -0
  49. package/generated/components/index.d.ts +53 -0
  50. package/generated/components/index.js +53 -0
  51. package/generated/components/label-view.d.ts +27 -0
  52. package/generated/components/label-view.js +84 -0
  53. package/generated/components/labeled-content.d.ts +33 -0
  54. package/generated/components/labeled-content.js +160 -0
  55. package/generated/components/list-view.d.ts +19 -0
  56. package/generated/components/list-view.js +24 -0
  57. package/generated/components/menu-view.d.ts +20 -0
  58. package/generated/components/menu-view.js +131 -0
  59. package/generated/components/navigation-large-title.d.ts +17 -0
  60. package/generated/components/navigation-large-title.js +183 -0
  61. package/generated/components/navigation-split-view.d.ts +15 -0
  62. package/generated/components/navigation-split-view.js +22 -0
  63. package/generated/components/navigation-stack.d.ts +15 -0
  64. package/generated/components/navigation-stack.js +26 -0
  65. package/generated/components/navigation-title.d.ts +18 -0
  66. package/generated/components/navigation-title.js +69 -0
  67. package/generated/components/picker-view.d.ts +51 -0
  68. package/generated/components/picker-view.js +1201 -0
  69. package/generated/components/plain-button.d.ts +7 -0
  70. package/generated/components/plain-button.js +20 -0
  71. package/generated/components/progress-view.d.ts +20 -0
  72. package/generated/components/progress-view.js +120 -0
  73. package/generated/components/screen-view.d.ts +5 -0
  74. package/generated/components/screen-view.js +10 -0
  75. package/generated/components/scroll-view-proxy.d.ts +13 -0
  76. package/generated/components/scroll-view-proxy.js +15 -0
  77. package/generated/components/scroll-view.d.ts +22 -0
  78. package/generated/components/scroll-view.js +230 -0
  79. package/generated/components/search-view.d.ts +12 -0
  80. package/generated/components/search-view.js +24 -0
  81. package/generated/components/section-view.d.ts +21 -0
  82. package/generated/components/section-view.js +61 -0
  83. package/generated/components/sheet-view.d.ts +11 -0
  84. package/generated/components/sheet-view.js +40 -0
  85. package/generated/components/sidebar-toggle.d.ts +15 -0
  86. package/generated/components/sidebar-toggle.js +84 -0
  87. package/generated/components/sidebar-view.d.ts +10 -0
  88. package/generated/components/sidebar-view.js +36 -0
  89. package/generated/components/sticky-container.d.ts +11 -0
  90. package/generated/components/sticky-container.js +24 -0
  91. package/generated/components/tab-bar.d.ts +10 -0
  92. package/generated/components/tab-bar.js +37 -0
  93. package/generated/components/tab-item.d.ts +10 -0
  94. package/generated/components/tab-item.js +127 -0
  95. package/generated/components/tab-view.d.ts +31 -0
  96. package/generated/components/tab-view.js +194 -0
  97. package/generated/components/table-view.d.ts +26 -0
  98. package/generated/components/table-view.js +156 -0
  99. package/generated/components/text-field.d.ts +42 -0
  100. package/generated/components/text-field.js +517 -0
  101. package/generated/components/text-view.d.ts +11 -0
  102. package/generated/components/text-view.js +16 -0
  103. package/generated/components/toggle-view.d.ts +43 -0
  104. package/generated/components/toggle-view.js +366 -0
  105. package/generated/components/tool-bar-item-group.d.ts +13 -0
  106. package/generated/components/tool-bar-item-group.js +29 -0
  107. package/generated/components/tool-bar-item.d.ts +16 -0
  108. package/generated/components/tool-bar-item.js +66 -0
  109. package/generated/components/tool-bar.d.ts +26 -0
  110. package/generated/components/tool-bar.js +92 -0
  111. package/generated/components/v-divider.d.ts +11 -0
  112. package/generated/components/v-divider.js +15 -0
  113. package/generated/components/v-flex-stack.d.ts +16 -0
  114. package/generated/components/v-flex-stack.js +18 -0
  115. package/generated/components/v-keyboard.d.ts +20 -0
  116. package/generated/components/v-keyboard.js +85 -0
  117. package/generated/components/v-stack.d.ts +25 -0
  118. package/generated/components/v-stack.js +27 -0
  119. package/generated/css/index.css +10964 -0
  120. package/generated/events/alert-dialog.d.ts +13 -0
  121. package/generated/events/alert-dialog.js +1 -0
  122. package/generated/events/confirmation-dialog.d.ts +14 -0
  123. package/generated/events/confirmation-dialog.js +1 -0
  124. package/generated/events/date-picker.d.ts +13 -0
  125. package/generated/events/date-picker.js +1 -0
  126. package/generated/events/index.d.ts +9 -0
  127. package/generated/events/index.js +9 -0
  128. package/generated/events/lifecycle-observer.d.ts +18 -0
  129. package/generated/events/lifecycle-observer.js +1 -0
  130. package/generated/events/picker-view.d.ts +29 -0
  131. package/generated/events/picker-view.js +1 -0
  132. package/generated/events/scroll-view.d.ts +18 -0
  133. package/generated/events/scroll-view.js +1 -0
  134. package/generated/events/tab-view.d.ts +54 -0
  135. package/generated/events/tab-view.js +1 -0
  136. package/generated/events/text-field.d.ts +13 -0
  137. package/generated/events/text-field.js +1 -0
  138. package/generated/events/toggle-view.d.ts +14 -0
  139. package/generated/events/toggle-view.js +1 -0
  140. package/generated/i18n/index.d.ts +33 -0
  141. package/generated/i18n/index.js +164 -0
  142. package/generated/i18n/locales/el.d.ts +16 -0
  143. package/generated/i18n/locales/el.js +16 -0
  144. package/generated/i18n/locales/en.d.ts +16 -0
  145. package/generated/i18n/locales/en.js +16 -0
  146. package/generated/i18n/locales/index.d.ts +4 -0
  147. package/generated/i18n/locales/index.js +4 -0
  148. package/generated/index.d.ts +2 -0
  149. package/generated/index.js +3 -0
  150. package/generated/internal/class/cleanup-registry.d.ts +5 -0
  151. package/generated/internal/class/cleanup-registry.js +38 -0
  152. package/generated/internal/class/css-style-observer.d.ts +8 -0
  153. package/generated/internal/class/css-style-observer.js +25 -0
  154. package/generated/internal/class/form-associated-base.d.ts +16 -0
  155. package/generated/internal/class/form-associated-base.js +76 -0
  156. package/generated/internal/class/mutation-observer-set.d.ts +9 -0
  157. package/generated/internal/class/mutation-observer-set.js +42 -0
  158. package/generated/internal/class/mutation-observer-singleton.d.ts +10 -0
  159. package/generated/internal/class/mutation-observer-singleton.js +64 -0
  160. package/generated/internal/class/navigation-path.d.ts +15 -0
  161. package/generated/internal/class/navigation-path.js +84 -0
  162. package/generated/internal/class/navigation-view.d.ts +8 -0
  163. package/generated/internal/class/navigation-view.js +70 -0
  164. package/generated/internal/class/resize-observer-singleton.d.ts +7 -0
  165. package/generated/internal/class/resize-observer-singleton.js +22 -0
  166. package/generated/internal/decorators/adaptive-slot.d.ts +1 -0
  167. package/generated/internal/decorators/adaptive-slot.js +47 -0
  168. package/generated/internal/decorators/custom-element.d.ts +5 -0
  169. package/generated/internal/decorators/custom-element.js +5 -0
  170. package/generated/internal/decorators/index.d.ts +6 -0
  171. package/generated/internal/decorators/index.js +6 -0
  172. package/generated/internal/decorators/microtask-on-connected.d.ts +39 -0
  173. package/generated/internal/decorators/microtask-on-connected.js +67 -0
  174. package/generated/internal/dev-flags.d.ts +4 -0
  175. package/generated/internal/dev-flags.js +1 -0
  176. package/generated/internal/privateNamespace.d.ts +14 -0
  177. package/generated/internal/privateNamespace.js +159 -0
  178. package/generated/internal/utils/$.d.ts +9 -0
  179. package/generated/internal/utils/$.js +11 -0
  180. package/generated/internal/utils/add.d.ts +1 -0
  181. package/generated/internal/utils/add.js +7 -0
  182. package/generated/internal/utils/ancestors.d.ts +1 -0
  183. package/generated/internal/utils/ancestors.js +27 -0
  184. package/generated/internal/utils/clamp.d.ts +1 -0
  185. package/generated/internal/utils/clamp.js +4 -0
  186. package/generated/internal/utils/compare-big-decimals.d.ts +1 -0
  187. package/generated/internal/utils/compare-big-decimals.js +80 -0
  188. package/generated/internal/utils/css-time.d.ts +1 -0
  189. package/generated/internal/utils/css-time.js +3 -0
  190. package/generated/internal/utils/debounce.d.ts +1 -0
  191. package/generated/internal/utils/debounce.js +13 -0
  192. package/generated/internal/utils/debug.d.ts +1 -0
  193. package/generated/internal/utils/debug.js +4 -0
  194. package/generated/internal/utils/define-translations.d.ts +1 -0
  195. package/generated/internal/utils/define-translations.js +3 -0
  196. package/generated/internal/utils/ensure-placeholder.d.ts +1 -0
  197. package/generated/internal/utils/ensure-placeholder.js +41 -0
  198. package/generated/internal/utils/frame.d.ts +1 -0
  199. package/generated/internal/utils/frame.js +6 -0
  200. package/generated/internal/utils/index.d.ts +54 -0
  201. package/generated/internal/utils/index.js +54 -0
  202. package/generated/internal/utils/is-inside.d.ts +1 -0
  203. package/generated/internal/utils/is-inside.js +4 -0
  204. package/generated/internal/utils/kebab-case.d.ts +1 -0
  205. package/generated/internal/utils/kebab-case.js +8 -0
  206. package/generated/internal/utils/list-active.d.ts +7 -0
  207. package/generated/internal/utils/list-active.js +83 -0
  208. package/generated/internal/utils/microtask.d.ts +1 -0
  209. package/generated/internal/utils/microtask.js +3 -0
  210. package/generated/internal/utils/next-all.d.ts +1 -0
  211. package/generated/internal/utils/next-all.js +10 -0
  212. package/generated/internal/utils/next.d.ts +1 -0
  213. package/generated/internal/utils/next.js +9 -0
  214. package/generated/internal/utils/onoff.d.ts +45 -0
  215. package/generated/internal/utils/onoff.js +31 -0
  216. package/generated/internal/utils/prev-all.d.ts +1 -0
  217. package/generated/internal/utils/prev-all.js +10 -0
  218. package/generated/internal/utils/prev.d.ts +1 -0
  219. package/generated/internal/utils/prev.js +9 -0
  220. package/generated/internal/utils/prop.d.ts +18 -0
  221. package/generated/internal/utils/prop.js +30 -0
  222. package/generated/internal/utils/set.d.ts +1 -0
  223. package/generated/internal/utils/set.js +7 -0
  224. package/generated/internal/utils/siblings.d.ts +1 -0
  225. package/generated/internal/utils/siblings.js +10 -0
  226. package/generated/internal/utils/sleep.d.ts +1 -0
  227. package/generated/internal/utils/sleep.js +3 -0
  228. package/generated/internal/utils/slow-hide-show.d.ts +1 -0
  229. package/generated/internal/utils/slow-hide-show.js +16 -0
  230. package/generated/internal/utils/timeout.d.ts +5 -0
  231. package/generated/internal/utils/timeout.js +16 -0
  232. package/generated/internal/utils/touch-glass.d.ts +7 -0
  233. package/generated/internal/utils/touch-glass.js +19 -0
  234. package/generated/internal/vendor/morphdom.d.ts +6 -0
  235. package/generated/internal/vendor/morphdom.js +720 -0
  236. package/generated/morphdom/index.d.ts +8 -0
  237. package/generated/morphdom/index.js +8 -0
  238. package/generated/morphdom/morph.d.ts +4 -0
  239. package/generated/morphdom/morph.js +10 -0
  240. package/generated/morphdom/query-morph.d.ts +5 -0
  241. package/generated/morphdom/query-morph.js +12 -0
  242. package/generated/morphdom/render-to-string.d.ts +12 -0
  243. package/generated/morphdom/render-to-string.js +48 -0
  244. package/generated/morphdom/unsafe-html.d.ts +2 -0
  245. package/generated/morphdom/unsafe-html.js +4 -0
  246. package/generated/namespace-browser/base.d.ts +45 -0
  247. package/generated/namespace-browser/base.js +115 -0
  248. package/generated/namespace-browser/event.d.ts +10 -0
  249. package/generated/namespace-browser/event.js +1 -0
  250. package/generated/namespace-browser/index.d.ts +7 -0
  251. package/generated/namespace-browser/index.js +1 -0
  252. package/generated/snapshot/index.d.ts +9 -0
  253. package/generated/snapshot/index.js +58 -0
  254. package/generated/tpl/html.d.ts +5 -0
  255. package/generated/tpl/html.js +7 -0
  256. package/generated/tpl/index.d.ts +6 -0
  257. package/generated/tpl/index.js +6 -0
  258. package/generated/tpl/is-template-result.d.ts +3 -0
  259. package/generated/tpl/is-template-result.js +1 -0
  260. package/generated/tpl/render.d.ts +2 -0
  261. package/generated/tpl/render.js +132 -0
  262. package/package.json +19 -18
@@ -0,0 +1,2 @@
1
+ declare const _default: EventTarget;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default new EventTarget();
@@ -0,0 +1,2 @@
1
+ declare const _default: EventTarget;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default new EventTarget();
@@ -0,0 +1,6 @@
1
+ export { default as alertDialog } from './alert-dialog';
2
+ export * from './alert-dialog';
3
+ export { default as confirmationDialog } from './confirmation-dialog';
4
+ export * from './confirmation-dialog';
5
+ export { default as lifecycleObserver } from './lifecycle-observer';
6
+ export * from './lifecycle-observer';
@@ -0,0 +1,6 @@
1
+ export { default as alertDialog } from './alert-dialog';
2
+ export * from './alert-dialog';
3
+ export { default as confirmationDialog } from './confirmation-dialog';
4
+ export * from './confirmation-dialog';
5
+ export { default as lifecycleObserver } from './lifecycle-observer';
6
+ export * from './lifecycle-observer';
@@ -0,0 +1,2 @@
1
+ declare const _default: EventTarget;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default new EventTarget();
@@ -0,0 +1,30 @@
1
+ import { lifecycleObserver } from '../buses';
2
+ import { I18n } from '../i18n';
3
+ import { NavigationPath } from '../internal/class/navigation-path';
4
+ import { type NavigationHost, queryInsertPosition, startViewTransition } from '../internal/privateNamespace';
5
+ import { type WebComponentCtor } from '../namespace-browser';
6
+ import { Snapshot } from '../snapshot';
7
+ export declare const polyfills: Map<string, WebComponentCtor>;
8
+ /**
9
+ * Presents an alert with a message using the given data to produce the alert’s content and a string variable as a title.
10
+ */
11
+ export declare const alert: (title?: string, message?: string, actions?: {
12
+ label?: string;
13
+ image?: string;
14
+ role?: string;
15
+ }[], options?: {
16
+ titleVisibility?: boolean;
17
+ signal?: AbortSignal;
18
+ }) => Promise<string | undefined> & {
19
+ dismiss: (reason?: unknown) => void;
20
+ };
21
+ export declare const confirmationDialog: (trigger: HTMLElement, title: string, message?: string, actions?: {
22
+ label?: string;
23
+ image?: string;
24
+ role?: string;
25
+ }[], options?: {
26
+ controller?: AbortController;
27
+ titleVisibility?: boolean;
28
+ }) => Promise<string>;
29
+ export { I18n, lifecycleObserver, NavigationPath, queryInsertPosition, Snapshot, startViewTransition };
30
+ export { type NavigationHost };
@@ -0,0 +1,278 @@
1
+ import { alertDialog, confirmationDialog as confirmationDialogBus, lifecycleObserver } from '../buses';
2
+ import * as Components from '../components';
3
+ import { I18n } from '../i18n';
4
+ import { NavigationPath } from '../internal/class/navigation-path';
5
+ import devFlags from '../internal/dev-flags';
6
+ import { queryInsertPosition, startViewTransition } from '../internal/privateNamespace';
7
+ import { $, debug, kebabCase, onoff } from '../internal/utils';
8
+ import { Snapshot } from '../snapshot';
9
+ import { html, render } from '../tpl';
10
+ debug(devFlags);
11
+ //#region polyfills
12
+ export const polyfills = new Map();
13
+ for (const [k, Ctor] of Object.entries(Components)) {
14
+ const is = kebabCase(k);
15
+ if ('polyfillExtends' in Ctor && 'string' === typeof Ctor.polyfillExtends) {
16
+ if (customElements.get(is))
17
+ continue;
18
+ customElements.define(is, Ctor, { extends: Ctor.polyfillExtends });
19
+ // NOTE: Test via the imperative creation path
20
+ if (!(document.createElement(Ctor.polyfillExtends, { is }) instanceof Ctor))
21
+ polyfills.set(is, Ctor);
22
+ // NOTE: Defensive, test again via the HTML-parsing path
23
+ if (!($(html `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`, '>1') instanceof Ctor))
24
+ polyfills.set(is, Ctor);
25
+ continue;
26
+ }
27
+ if (!customElements.get(is))
28
+ customElements.define(is, Ctor);
29
+ }
30
+ debug(polyfills);
31
+ if (0 < polyfills.size) {
32
+ const polyfillTagNamesCache = new Set([...polyfills.values()].map((v) => String(v.polyfillExtends ?? '').toUpperCase()).filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
33
+ const handlers = new WeakMap();
34
+ const observe = (el, polyfill) => {
35
+ if (!Array.isArray(polyfill.observedAttributes))
36
+ return;
37
+ if (0 === polyfill?.observedAttributes.length)
38
+ return;
39
+ if (!polyfill.polyfillAttributeChangedCallback)
40
+ return;
41
+ const observer = new MutationObserver(polyfill.polyfillAttributeChangedCallback);
42
+ observer.observe(el, {
43
+ attributes: true,
44
+ attributeFilter: polyfill.observedAttributes,
45
+ attributeOldValue: true,
46
+ });
47
+ handlers.set(el, observer);
48
+ for (const attributeName of polyfill.observedAttributes)
49
+ if (el.hasAttribute(attributeName)) {
50
+ const entry = {
51
+ attributeName,
52
+ oldValue: null,
53
+ target: el,
54
+ };
55
+ polyfill.polyfillAttributeChangedCallback([entry]);
56
+ }
57
+ }, unobserve = (el) => {
58
+ handlers.delete(el);
59
+ }, polyfillTagNamesCacheSelector = [...polyfillTagNamesCache.values()].map((v) => `${v}`.toLowerCase()).join(','), flatten = (node) => [node, ...(node.querySelectorAll?.(polyfillTagNamesCacheSelector) ?? [])];
60
+ debug(polyfillTagNamesCache, polyfillTagNamesCacheSelector);
61
+ for (const [is, polyfill] of polyfills)
62
+ for (const el of document.querySelectorAll(`${polyfill.polyfillExtends}[is="${CSS.escape(is)}"]`)) {
63
+ polyfill.polyfillConnectedCallback(el);
64
+ observe(el, polyfill);
65
+ }
66
+ // observer callback
67
+ const observer = new MutationObserver((mutations) => {
68
+ for (const { addedNodes, removedNodes } of mutations) {
69
+ for (const root of addedNodes) {
70
+ if (!(root instanceof HTMLElement))
71
+ continue;
72
+ for (const node of flatten(root)) {
73
+ if (!(node instanceof HTMLElement))
74
+ continue;
75
+ if (!polyfillTagNamesCache.has(node.tagName))
76
+ continue;
77
+ const is = node?.getAttribute('is') ?? '';
78
+ if (!polyfills.has(is))
79
+ continue;
80
+ polyfills.get(is)?.polyfillConnectedCallback(node);
81
+ observe(node, polyfills.get(is));
82
+ }
83
+ }
84
+ for (const root of removedNodes) {
85
+ if (!(root instanceof HTMLElement))
86
+ continue;
87
+ for (const node of flatten(root)) {
88
+ if (!(node instanceof HTMLElement))
89
+ continue;
90
+ if (!polyfillTagNamesCache.has(node.tagName))
91
+ continue;
92
+ const is = node?.getAttribute('is') ?? '';
93
+ if (!polyfills.has(is))
94
+ continue;
95
+ polyfills.get(is)?.polyfillDisconnectedCallback(node);
96
+ unobserve(node);
97
+ }
98
+ }
99
+ }
100
+ });
101
+ observer.observe(document.body, {
102
+ childList: true,
103
+ subtree: true,
104
+ });
105
+ }
106
+ // SECTION: Safari polyfill
107
+ document.addEventListener('touchstart', () => { }, { passive: true });
108
+ //#endregion
109
+ // SECTION
110
+ const handleHelp = ({ target, relatedTarget }) => {
111
+ if (!(target instanceof HTMLElement))
112
+ return;
113
+ const trigger = target.closest('[help]');
114
+ if (!trigger)
115
+ return;
116
+ if (['PICKER-VIEW'].includes(trigger.tagName))
117
+ return;
118
+ if (relatedTarget instanceof HTMLElement && trigger.contains(relatedTarget))
119
+ return;
120
+ const newAnchorName = `--help-${self.crypto.randomUUID()}`;
121
+ const tooltip = $(html `<fine-tooltip></fine-tooltip>`, '>1');
122
+ trigger.style.setProperty('anchor-name', newAnchorName);
123
+ tooltip.style.setProperty('position-anchor', newAnchorName);
124
+ document.body.appendChild(tooltip);
125
+ // setInterval(() => {
126
+ // trigger.setAttribute('help', trigger.getAttribute('help') + 'h')
127
+ // }, 2000)
128
+ // console.log(999, trigger)
129
+ }, handleDone = ({ target, relatedTarget }) => {
130
+ if (!(target instanceof HTMLElement))
131
+ return;
132
+ const trigger = target.closest('[help]');
133
+ if (!trigger)
134
+ return;
135
+ if (['PICKER-VIEW'].includes(trigger.tagName))
136
+ return;
137
+ if (relatedTarget instanceof HTMLElement && trigger.contains(relatedTarget))
138
+ return;
139
+ const anchorName = trigger.style.anchorName;
140
+ if (!anchorName.startsWith('--help-'))
141
+ return;
142
+ // for (const el of document.querySelectorAll<HTMLElement>(`[style*="--help-${CSS.escape(anchorName)}"][help]`)) el.style.removeProperty('anchor-name') //trigger.style.removeProperty('anchor-name')
143
+ // for (const el of document.querySelectorAll(`[style*="${CSS.escape(anchorName)}"]:not([help])`)) el.remove()
144
+ // return
145
+ // }
146
+ const tooltip = document.querySelector(`[style*="${CSS.escape(anchorName)}"]:not([help])`);
147
+ if (!tooltip)
148
+ return;
149
+ // for (const el of document.querySelectorAll<HTMLElement>(`[style*="--help-${CSS.escape(anchorName)}"][help]`)) el.style.removeProperty('anchor-name') //trigger.style.removeProperty('anchor-name')
150
+ // for (const el of document.querySelectorAll(`[style*="${CSS.escape(anchorName)}"]:not([help])`)) el.remove()
151
+ // return
152
+ // }
153
+ // trigger.style.removeProperty('anchor-name')
154
+ tooltip.hidePopover(); // tooltip.remove?.()
155
+ };
156
+ const mediaQueryList = self.matchMedia(`(pointer: fine)`);
157
+ mediaQueryList.addEventListener('change', ({ matches }) => {
158
+ for (const [k, v] of [
159
+ ['pointerover', handleHelp],
160
+ ['pointerout', handleDone],
161
+ ])
162
+ document.removeEventListener(k, v);
163
+ if (matches)
164
+ for (const [k, v] of [
165
+ ['pointerover', handleHelp],
166
+ ['pointerout', handleDone],
167
+ ])
168
+ document.addEventListener(k, v, { passive: true });
169
+ });
170
+ if (mediaQueryList.matches)
171
+ for (const [k, v] of [
172
+ ['pointerover', handleHelp],
173
+ ['pointerout', handleDone],
174
+ ])
175
+ document.addEventListener(k, v, { passive: true });
176
+ //#region fns
177
+ // const a = alert('Saving…', 'Please wait')
178
+ // // later, e.g. save completed early
179
+ // a.dismiss() // silently resolves undefined, closes+removes dialog
180
+ // // or
181
+ // a.dismiss(new Error('cancelled')) // rejects instead
182
+ // const result = await a // still works normally if not dismissed
183
+ // const ac = new AbortController()
184
+ // const a = alert('Uploading…', 'Please wait', undefined, { signal: ac.signal })
185
+ // // elsewhere, e.g. upload finished before the user dismissed
186
+ // ac.abort() // dialog closes silently, a rejects with AbortError
187
+ // // or still works standalone
188
+ // a.dismiss() // same effect, no signal needed
189
+ /**
190
+ * Presents an alert with a message using the given data to produce the alert’s content and a string variable as a title.
191
+ */
192
+ export const alert = (title, message, actions, options) => {
193
+ const { promise, resolve, reject } = Promise.withResolvers();
194
+ let dialog;
195
+ let off;
196
+ const dismiss = (reason) => {
197
+ off?.();
198
+ dialog?.close();
199
+ // dialog?.remove()
200
+ reason === undefined ? resolve(undefined) : reject(reason instanceof Error ? reason : new DOMException('Alert dismissed', 'AbortError'));
201
+ };
202
+ if (options?.signal)
203
+ if (options.signal.aborted)
204
+ dismiss(options.signal.reason); // already aborted before we even started — settle immediately, skip showing anything
205
+ else
206
+ options.signal.addEventListener('abort', () => dismiss(options.signal.reason), { once: true });
207
+ navigator.locks
208
+ .request('alert:', async () => {
209
+ if (options?.signal?.aborted)
210
+ return; // in case it was aborted while queued behind another lock holder
211
+ const mount = document.createElement('div');
212
+ render(html `<dialog is="alert-dialog">
213
+ <v-stack spacing="1" alignment="fill">
214
+ ${title ? html `<label-view font="headline" title="${title}"></label-view>` : null}
215
+ ${message ? html `<label-view foreground="secondary" font="callout" title="${message}"></label-view>` : null}
216
+ </v-stack>
217
+ ${(actions ?? [{ role: 'close' }]).map((action, index) => html `
218
+ <button type="button" tabindex="0" is="bordered-button" value="${index}" role="${action.role ?? null}">
219
+ ${action.label || action.image ? html `<label-view title="${action.label ?? null}" system-image="${action.image ?? null}"></label-view>` : null}
220
+ </button>
221
+ `)}
222
+ </dialog>`, mount);
223
+ dialog = mount.firstElementChild;
224
+ document.body.insertAdjacentElement('beforeend', dialog);
225
+ dialog.showModal();
226
+ off = onoff('alert:return', (evt) => {
227
+ const { detail } = evt;
228
+ off?.();
229
+ resolve(detail.returnValue);
230
+ }, alertDialog, { once: true }).on();
231
+ return promise;
232
+ })
233
+ .catch(() => { });
234
+ return Object.assign(promise, { dismiss });
235
+ };
236
+ export const confirmationDialog = async (trigger, title, message, actions, options) => {
237
+ const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
238
+ const dialog = $(html `<dialog is="confirmation-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(html `<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
239
+ trigger.style.setProperty('anchor-name', newAnchorName, 'important'); //$.prop('anchor-name', newAnchorName, trigger, 'important')
240
+ dialog.style.setProperty('position-anchor', newAnchorName); //$.prop('position-anchor', newAnchorName, dialog)
241
+ if (title && false !== options?.titleVisibility) {
242
+ const label = $(html `<label-view font="headline"></label-view>`, '>1');
243
+ label.setAttribute('title', title);
244
+ vStack.insertAdjacentElement('beforeend', label);
245
+ }
246
+ if (message && false !== options?.titleVisibility) {
247
+ const label = $(html `<label-view foreground="secondary" font="callout"></label-view>`, '>1');
248
+ label.setAttribute('title', message);
249
+ vStack.insertAdjacentElement('beforeend', label);
250
+ }
251
+ for (const [index, action] of (actions ?? []).entries()) {
252
+ const btn = $(html `<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
253
+ btn.setAttribute('value', `${index}`);
254
+ if (action?.role)
255
+ btn.setAttribute('role', action.role);
256
+ if (action.label || action.image) {
257
+ const label = $(html `<label-view></label-view>`, '>1');
258
+ if (action.label)
259
+ label.setAttribute('title', action.label);
260
+ if (action.image)
261
+ label.setAttribute('system-image', action.image);
262
+ btn.appendChild(label);
263
+ }
264
+ dialog.insertAdjacentElement('beforeend', btn);
265
+ }
266
+ trigger.closest('content-view,dialog')?.insertAdjacentElement('beforeend', dialog); // dialog.showModal()
267
+ const { promise, resolve } = Promise.withResolvers(), off = onoff('confirmation:return', (evt) => {
268
+ const { detail } = evt;
269
+ off();
270
+ resolve(detail.returnValue);
271
+ }, confirmationDialogBus, { once: true }).on();
272
+ return promise;
273
+ };
274
+ //#endregion
275
+ void Snapshot.waitReady;
276
+ //#region exports
277
+ export { I18n, lifecycleObserver, NavigationPath, queryInsertPosition, Snapshot, startViewTransition };
278
+ //#endregion
@@ -0,0 +1,11 @@
1
+ import { DialogBase } from '../namespace-browser/base';
2
+ /**
3
+ * @summary A dialog that shows a message. Use it from the client module like `void alert('Save failed.')`.
4
+ */
5
+ export declare class AlertDialog extends DialogBase {
6
+ #private;
7
+ constructor();
8
+ static polyfillDisconnectedCallback(el: AlertDialog): void;
9
+ static polyfillConnectedCallback(el: AlertDialog): void;
10
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
11
+ }
@@ -0,0 +1,94 @@
1
+ import { alertDialog } from '../buses';
2
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
3
+ import { debug, onoff, touchGlass } from '../internal/utils';
4
+ import { DialogBase } from '../namespace-browser/base';
5
+ /**
6
+ * @summary A dialog that shows a message. Use it from the client module like `void alert('Save failed.')`.
7
+ */
8
+ export class AlertDialog extends DialogBase {
9
+ constructor() {
10
+ super();
11
+ }
12
+ static polyfillDisconnectedCallback(el) {
13
+ debug(`${AlertDialog.name} ⚡️ disconnect`);
14
+ CleanupRegistry.unregister(el);
15
+ alertDialog.dispatchEvent(new CustomEvent('alert:return', {
16
+ detail: { returnValue: el.returnValue },
17
+ bubbles: true,
18
+ composed: true,
19
+ }));
20
+ }
21
+ static polyfillConnectedCallback(el) {
22
+ debug(`${AlertDialog.name} ⚡️ connect`);
23
+ CleanupRegistry.register(el, onoff([
24
+ { types: 'click', listener: this.#handleDialogClick },
25
+ { types: 'close', listener: this.#handleDialogClose },
26
+ { types: 'cancel', listener: this.#handleDialogCancel },
27
+ ], el).on());
28
+ CleanupRegistry.register(el, onoff(touchGlass(el, (t) => t, ({ target }) => {
29
+ if (!(target instanceof HTMLElement))
30
+ return true;
31
+ if (target.matches('[is=alert-dialog]'))
32
+ return false;
33
+ return true;
34
+ }), el).on());
35
+ debug(`${AlertDialog.name} ⚡️ will-open`);
36
+ el.removeAttribute('closing');
37
+ el.scrollTop = 0;
38
+ el.returnValue = '';
39
+ el.autofocus = true;
40
+ el.showModal();
41
+ }
42
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
43
+ debug(`${AlertDialog.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
44
+ switch (attributeName) {
45
+ case 'label':
46
+ //
47
+ break;
48
+ }
49
+ }
50
+ static #handleDialogClick = (evt) => {
51
+ debug(`${AlertDialog.name} ⚡️ ${evt?.type}`);
52
+ const { target, currentTarget: dialog } = evt;
53
+ if (!(dialog instanceof HTMLDialogElement))
54
+ return;
55
+ if (!(target instanceof HTMLElement))
56
+ return;
57
+ const button = target.closest('button');
58
+ if (!button)
59
+ return;
60
+ button.scrollIntoView({
61
+ behavior: self.matchMedia('(prefers-reduced-motion: no-preference)').matches ? 'smooth' : 'instant',
62
+ block: 'nearest',
63
+ inline: 'nearest',
64
+ });
65
+ dialog.returnValue = button.value;
66
+ dialog.requestClose(button.value);
67
+ evt.stopPropagation();
68
+ evt.stopImmediatePropagation();
69
+ };
70
+ static #handleDialogCancel = (evt) => {
71
+ debug(`${AlertDialog.name} ⚡️ ${evt?.type}`);
72
+ if (!evt.cancelable)
73
+ return;
74
+ const { target } = evt;
75
+ if (!(target instanceof HTMLDialogElement))
76
+ return;
77
+ evt.preventDefault();
78
+ target.inert = true;
79
+ debug(`${AlertDialog.name} ⚡️ will-close`);
80
+ target.setAttribute('closing', '');
81
+ Promise.allSettled(target.getAnimations().map(({ finished }) => finished)).then(() => {
82
+ if (!target.hasAttribute('closing'))
83
+ return;
84
+ target?.close(target?.returnValue);
85
+ target.removeAttribute('closing');
86
+ });
87
+ };
88
+ static #handleDialogClose = ({ type, target }) => {
89
+ debug(`${AlertDialog.name} ⚡️ ${type}`);
90
+ if (!(target instanceof HTMLDialogElement))
91
+ return;
92
+ target.remove();
93
+ };
94
+ }
@@ -0,0 +1,17 @@
1
+ import { ButtonBase } from '../namespace-browser/base';
2
+ /**
3
+ * @summary A control that starts an action. Styled with a standard border, adapting to the button’s surroundings.
4
+ *
5
+ * @example <button is="bordered-button"><label-view system-image="hand-tap" title="Tap Me"></label-view></button> — Creating a bordered button
6
+ *
7
+ * @slot overlay
8
+ *
9
+ */
10
+ export declare class BorderedButton extends ButtonBase {
11
+ #private;
12
+ static get observedAttributes(): string[];
13
+ constructor();
14
+ static polyfillDisconnectedCallback(el: BorderedButton): void;
15
+ static polyfillConnectedCallback(el: BorderedButton): void;
16
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
17
+ }
@@ -0,0 +1,53 @@
1
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
2
+ import { debug, ensurePlaceholder, onoff } from '../internal/utils';
3
+ import { ButtonBase } from '../namespace-browser/base';
4
+ import { Snapshot } from '../snapshot';
5
+ /**
6
+ * @summary A control that starts an action. Styled with a standard border, adapting to the button’s surroundings.
7
+ *
8
+ * @example <button is="bordered-button"><label-view system-image="hand-tap" title="Tap Me"></label-view></button> — Creating a bordered button
9
+ *
10
+ * @slot overlay
11
+ *
12
+ */
13
+ export class BorderedButton extends ButtonBase {
14
+ static get observedAttributes() {
15
+ return [
16
+ /**
17
+ * A value that describes the purpose of a button
18
+ * @type {destructive|confirm}
19
+ */
20
+ 'role',
21
+ 'title-key',
22
+ ];
23
+ }
24
+ constructor() {
25
+ super();
26
+ }
27
+ static polyfillDisconnectedCallback(el) {
28
+ debug(`${BorderedButton.name} ⚡️ disconnect`);
29
+ CleanupRegistry.unregister(el);
30
+ }
31
+ static polyfillConnectedCallback(el) {
32
+ debug(`${BorderedButton.name} ⚡️ connect`);
33
+ el.tabIndex = 0;
34
+ CleanupRegistry.register(el, onoff('click', BorderedButton.#handleClick, el).on());
35
+ }
36
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
37
+ debug(`${BorderedButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
38
+ const node = target instanceof HTMLButtonElement;
39
+ if (!node)
40
+ return;
41
+ switch (attributeName) {
42
+ case 'title-key':
43
+ case 'role':
44
+ Snapshot.waitReady.then(() => {
45
+ ensurePlaceholder(target, target.getAttribute('role'), target.getAttribute('title-key'), Snapshot.config);
46
+ });
47
+ break;
48
+ }
49
+ }
50
+ static #handleClick = async (evt) => {
51
+ //
52
+ };
53
+ }
@@ -0,0 +1,17 @@
1
+ import { ButtonBase } from '../namespace-browser/base';
2
+ /**
3
+ * @summary A control that starts an action. Styled with a prominent border, adapting to the button’s surroundings.
4
+ *
5
+ * @example <button is="bordered-prominent-button"><label-view system-image="hand-tap" title="Tap Me"></label-view></button> — Creating a prominent bordered button
6
+ *
7
+ * @slot overlay
8
+ *
9
+ */
10
+ export declare class BorderedProminentButton extends ButtonBase {
11
+ #private;
12
+ static get observedAttributes(): string[];
13
+ constructor();
14
+ static polyfillDisconnectedCallback(el: BorderedProminentButton): void;
15
+ static polyfillConnectedCallback(el: BorderedProminentButton): void;
16
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
17
+ }
@@ -0,0 +1,53 @@
1
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
2
+ import { debug, ensurePlaceholder, onoff } from '../internal/utils';
3
+ import { ButtonBase } from '../namespace-browser/base';
4
+ import { Snapshot } from '../snapshot';
5
+ /**
6
+ * @summary A control that starts an action. Styled with a prominent border, adapting to the button’s surroundings.
7
+ *
8
+ * @example <button is="bordered-prominent-button"><label-view system-image="hand-tap" title="Tap Me"></label-view></button> — Creating a prominent bordered button
9
+ *
10
+ * @slot overlay
11
+ *
12
+ */
13
+ export class BorderedProminentButton extends ButtonBase {
14
+ static get observedAttributes() {
15
+ return [
16
+ /**
17
+ * A value that describes the purpose of a button
18
+ * @type {destructive|confirm}
19
+ */
20
+ 'role',
21
+ 'title-key',
22
+ ];
23
+ }
24
+ constructor() {
25
+ super();
26
+ }
27
+ static polyfillDisconnectedCallback(el) {
28
+ debug(`${BorderedProminentButton.name} ⚡️ disconnect`);
29
+ CleanupRegistry.unregister(el);
30
+ }
31
+ static polyfillConnectedCallback(el) {
32
+ debug(`${BorderedProminentButton.name} ⚡️ connect`);
33
+ el.tabIndex = 0;
34
+ CleanupRegistry.register(el, onoff('click', BorderedProminentButton.#handleClick, el).on());
35
+ }
36
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]) {
37
+ debug(`${BorderedProminentButton.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
38
+ const node = target instanceof HTMLButtonElement;
39
+ if (!node)
40
+ return;
41
+ switch (attributeName) {
42
+ case 'title-key':
43
+ case 'role':
44
+ Snapshot.waitReady.then(() => {
45
+ ensurePlaceholder(target, target.getAttribute('role'), target.getAttribute('title-key'), Snapshot.config);
46
+ });
47
+ break;
48
+ }
49
+ }
50
+ static #handleClick = async (evt) => {
51
+ //
52
+ };
53
+ }
@@ -0,0 +1,17 @@
1
+ import { ButtonBase } from '../namespace-browser/base';
2
+ /**
3
+ * @summary A control that starts an action. Styled without any borders.
4
+ *
5
+ * @example <button is="borderless-button"><label-view system-image="hand-tap" title="Tap Me"></label-view></button> — Use the `is` attribute to style a `button` as a `borderless-button`
6
+ *
7
+ * @slot overlay
8
+ *
9
+ */
10
+ export declare class BorderlessButton extends ButtonBase {
11
+ #private;
12
+ static get observedAttributes(): string[];
13
+ constructor();
14
+ static polyfillDisconnectedCallback(el: BorderlessButton): void;
15
+ static polyfillConnectedCallback(el: BorderlessButton): void;
16
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
17
+ }