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

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 (332) hide show
  1. package/README.md +15 -0
  2. package/generated/buses/alert-dialog.d.ts +2 -0
  3. package/generated/buses/alert-dialog.js +1 -0
  4. package/generated/buses/confirmation-dialog.d.ts +2 -0
  5. package/generated/buses/confirmation-dialog.js +1 -0
  6. package/generated/buses/index.d.ts +6 -0
  7. package/generated/buses/index.js +6 -0
  8. package/generated/buses/lifecycle-observer.d.ts +2 -0
  9. package/generated/buses/lifecycle-observer.js +1 -0
  10. package/generated/client/index.d.ts +22 -4
  11. package/generated/client/index.js +219 -181
  12. package/generated/components/alert-dialog.d.ts +8 -0
  13. package/generated/components/alert-dialog.js +99 -0
  14. package/generated/components/body-view.js +5 -2
  15. package/generated/components/bordered-button.d.ts +17 -0
  16. package/generated/components/bordered-button.js +56 -0
  17. package/generated/components/bordered-prominent-button.d.ts +17 -0
  18. package/generated/components/bordered-prominent-button.js +56 -0
  19. package/generated/components/borderless-button.d.ts +12 -4
  20. package/generated/components/borderless-button.js +47 -16
  21. package/generated/components/color-scheme.d.ts +7 -0
  22. package/generated/components/color-scheme.js +54 -0
  23. package/generated/components/confirmation-dialog.d.ts +9 -0
  24. package/generated/components/confirmation-dialog.js +113 -0
  25. package/generated/components/content-unavailable-view.d.ts +24 -0
  26. package/generated/components/content-unavailable-view.js +81 -0
  27. package/generated/components/date-picker.d.ts +36 -0
  28. package/generated/components/date-picker.js +461 -0
  29. package/generated/components/disclosure-group.d.ts +9 -7
  30. package/generated/components/disclosure-group.js +51 -65
  31. package/generated/components/fine-tooltip.d.ts +7 -0
  32. package/generated/components/fine-tooltip.js +107 -0
  33. package/generated/components/form-view.d.ts +9 -0
  34. package/generated/components/form-view.js +63 -0
  35. package/generated/components/glass-button.d.ts +16 -0
  36. package/generated/components/glass-button.js +53 -0
  37. package/generated/components/glass-prominent-button.d.ts +16 -0
  38. package/generated/components/glass-prominent-button.js +53 -0
  39. package/generated/components/h-stack.d.ts +10 -0
  40. package/generated/components/h-stack.js +19 -0
  41. package/generated/components/image-view.d.ts +9 -0
  42. package/generated/components/image-view.js +46 -0
  43. package/generated/components/index.d.ts +41 -10
  44. package/generated/components/index.js +41 -15
  45. package/generated/components/label-view.d.ts +9 -0
  46. package/generated/components/label-view.js +51 -0
  47. package/generated/components/labeled-content.d.ts +9 -0
  48. package/generated/components/labeled-content.js +115 -0
  49. package/generated/components/list-view.d.ts +8 -0
  50. package/generated/components/list-view.js +32 -0
  51. package/generated/components/menu-view.d.ts +12 -0
  52. package/generated/components/menu-view.js +142 -0
  53. package/generated/components/navigation-large-title.d.ts +6 -0
  54. package/generated/components/navigation-large-title.js +181 -0
  55. package/generated/components/navigation-split-view.d.ts +7 -2
  56. package/generated/components/navigation-split-view.js +19 -3
  57. package/generated/components/navigation-stack.d.ts +6 -2
  58. package/generated/components/navigation-stack.js +23 -59
  59. package/generated/components/navigation-title.d.ts +8 -0
  60. package/generated/components/navigation-title.js +50 -0
  61. package/generated/components/picker-view.d.ts +44 -0
  62. package/generated/components/picker-view.js +1009 -0
  63. package/generated/components/plain-button.d.ts +7 -0
  64. package/generated/components/plain-button.js +22 -0
  65. package/generated/components/progress-view.d.ts +13 -0
  66. package/generated/components/progress-view.js +120 -0
  67. package/generated/components/screen-view.d.ts +1 -1
  68. package/generated/components/screen-view.js +4 -2
  69. package/generated/components/scroll-view-proxy.d.ts +8 -0
  70. package/generated/components/scroll-view-proxy.js +17 -0
  71. package/generated/components/scroll-view.d.ts +4 -2
  72. package/generated/components/scroll-view.js +179 -64
  73. package/generated/components/search-view.d.ts +7 -0
  74. package/generated/components/search-view.js +30 -0
  75. package/generated/components/section-view.d.ts +9 -0
  76. package/generated/components/section-view.js +85 -0
  77. package/generated/components/sheet-view.d.ts +3 -4
  78. package/generated/components/sheet-view.js +53 -17
  79. package/generated/components/sidebar-toggle.d.ts +1 -1
  80. package/generated/components/sidebar-toggle.js +76 -72
  81. package/generated/components/sidebar-view.d.ts +2 -4
  82. package/generated/components/sidebar-view.js +25 -17
  83. package/generated/components/sticky-container.d.ts +6 -0
  84. package/generated/components/sticky-container.js +26 -0
  85. package/generated/components/tab-bar.d.ts +5 -4
  86. package/generated/components/tab-bar.js +34 -17
  87. package/generated/components/tab-item.d.ts +4 -3
  88. package/generated/components/tab-item.js +125 -29
  89. package/generated/components/tab-view.d.ts +17 -2
  90. package/generated/components/tab-view.js +252 -17
  91. package/generated/components/table-view.d.ts +12 -0
  92. package/generated/components/table-view.js +153 -0
  93. package/generated/components/text-field.d.ts +29 -0
  94. package/generated/components/text-field.js +496 -0
  95. package/generated/components/tool-bar-item-group.d.ts +5 -0
  96. package/generated/components/tool-bar-item-group.js +28 -0
  97. package/generated/components/tool-bar-item.d.ts +8 -0
  98. package/generated/components/tool-bar-item.js +66 -0
  99. package/generated/components/tool-bar.d.ts +19 -0
  100. package/generated/components/tool-bar.js +93 -0
  101. package/generated/components/v-keyboard.d.ts +4 -0
  102. package/generated/components/v-keyboard.js +72 -70
  103. package/generated/components/v-stack.d.ts +13 -0
  104. package/generated/components/v-stack.js +22 -0
  105. package/generated/css/index.css +8847 -0
  106. package/generated/events/alert-dialog.d.ts +8 -0
  107. package/generated/events/confirmation-dialog.d.ts +9 -0
  108. package/generated/events/confirmation-dialog.js +1 -0
  109. package/generated/events/date-picker.d.ts +8 -0
  110. package/generated/events/date-picker.js +1 -0
  111. package/generated/events/index.d.ts +8 -0
  112. package/generated/events/index.js +8 -0
  113. package/generated/events/lifecycle-observer.d.ts +10 -0
  114. package/generated/events/lifecycle-observer.js +1 -0
  115. package/generated/events/picker-view.d.ts +15 -0
  116. package/generated/events/picker-view.js +1 -0
  117. package/generated/events/scroll-view.d.ts +10 -0
  118. package/generated/events/scroll-view.js +1 -0
  119. package/generated/events/tab-view.d.ts +28 -0
  120. package/generated/events/tab-view.js +1 -0
  121. package/generated/events/text-field.d.ts +8 -0
  122. package/generated/events/text-field.js +1 -0
  123. package/generated/i18n/index.d.ts +34 -0
  124. package/generated/i18n/index.js +167 -0
  125. package/generated/i18n/locales/el.d.ts +16 -0
  126. package/generated/i18n/locales/el.js +16 -0
  127. package/generated/i18n/locales/en.d.ts +16 -0
  128. package/generated/i18n/locales/en.js +16 -0
  129. package/generated/i18n/locales/index.d.ts +4 -0
  130. package/generated/i18n/locales/index.js +4 -0
  131. package/generated/internal/class/cleanup-registry.d.ts +5 -0
  132. package/generated/internal/class/cleanup-registry.js +38 -0
  133. package/generated/internal/class/css-style-observer.d.ts +8 -0
  134. package/generated/internal/class/css-style-observer.js +26 -0
  135. package/generated/internal/class/form-associated-base.d.ts +16 -0
  136. package/generated/internal/class/form-associated-base.js +78 -0
  137. package/generated/internal/class/mutation-observer-set.d.ts +9 -0
  138. package/generated/internal/class/mutation-observer-set.js +42 -0
  139. package/generated/internal/class/mutation-observer-singleton.d.ts +10 -0
  140. package/generated/internal/class/mutation-observer-singleton.js +64 -0
  141. package/generated/internal/class/navigation-path.d.ts +15 -0
  142. package/generated/internal/class/navigation-path.js +84 -0
  143. package/generated/internal/class/navigation-view.d.ts +8 -0
  144. package/generated/internal/class/navigation-view.js +72 -0
  145. package/generated/internal/class/resize-observer-singleton.d.ts +7 -0
  146. package/generated/internal/class/resize-observer-singleton.js +22 -0
  147. package/generated/internal/decorators/adaptive-slot.d.ts +1 -0
  148. package/generated/internal/decorators/adaptive-slot.js +50 -0
  149. package/generated/internal/decorators/custom-element.d.ts +5 -0
  150. package/generated/internal/decorators/custom-element.js +5 -0
  151. package/generated/internal/decorators/index.d.ts +6 -0
  152. package/generated/internal/decorators/index.js +6 -0
  153. package/generated/internal/decorators/microtask-on-connected.d.ts +39 -0
  154. package/generated/internal/decorators/microtask-on-connected.js +67 -0
  155. package/generated/internal/privateNamespace.d.ts +14 -0
  156. package/generated/internal/privateNamespace.js +168 -0
  157. package/generated/internal/utils/add.d.ts +1 -0
  158. package/generated/internal/utils/add.js +7 -0
  159. package/generated/internal/utils/cash/ancestors.d.ts +1 -0
  160. package/generated/internal/utils/cash/ancestors.js +27 -0
  161. package/generated/internal/utils/cash/index.d.ts +23 -0
  162. package/generated/internal/utils/cash/index.js +25 -0
  163. package/generated/internal/utils/cash/next-all.d.ts +1 -0
  164. package/generated/internal/utils/cash/next-all.js +10 -0
  165. package/generated/internal/utils/cash/next.d.ts +1 -0
  166. package/generated/internal/utils/cash/next.js +9 -0
  167. package/generated/internal/utils/cash/prev-all.d.ts +1 -0
  168. package/generated/internal/utils/cash/prev-all.js +10 -0
  169. package/generated/internal/utils/cash/prev.d.ts +1 -0
  170. package/generated/internal/utils/cash/prev.js +9 -0
  171. package/generated/internal/utils/cash/prop.d.ts +18 -0
  172. package/generated/internal/utils/cash/prop.js +30 -0
  173. package/generated/internal/utils/cash/siblings.d.ts +1 -0
  174. package/generated/internal/utils/cash/siblings.js +10 -0
  175. package/generated/internal/utils/clamp.d.ts +1 -0
  176. package/generated/internal/utils/clamp.js +4 -0
  177. package/generated/internal/utils/compare-big-decimals.d.ts +1 -0
  178. package/generated/internal/utils/compare-big-decimals.js +90 -0
  179. package/generated/internal/utils/debounce.d.ts +1 -0
  180. package/generated/internal/utils/debounce.js +13 -0
  181. package/generated/internal/utils/dev-flags.d.ts +3 -0
  182. package/generated/internal/utils/dev-flags.js +5 -0
  183. package/generated/internal/utils/ensure-placeholder.d.ts +1 -0
  184. package/generated/internal/utils/ensure-placeholder.js +55 -0
  185. package/generated/internal/utils/frame.d.ts +1 -0
  186. package/generated/internal/utils/frame.js +6 -0
  187. package/generated/internal/utils/index.d.ts +21 -1
  188. package/generated/internal/utils/index.js +24 -1
  189. package/generated/internal/utils/is-inside.d.ts +1 -0
  190. package/generated/internal/utils/is-inside.js +4 -0
  191. package/generated/internal/utils/kebab-case.d.ts +1 -1
  192. package/generated/internal/utils/list-active.d.ts +7 -0
  193. package/generated/internal/utils/list-active.js +83 -0
  194. package/generated/internal/utils/microtask.d.ts +1 -0
  195. package/generated/internal/utils/microtask.js +3 -0
  196. package/generated/internal/utils/onoff.d.ts +45 -0
  197. package/generated/internal/utils/onoff.js +31 -0
  198. package/generated/internal/utils/render-label-icon.d.ts +2 -0
  199. package/generated/internal/utils/render-label-icon.js +19 -0
  200. package/generated/internal/utils/render-label-title.d.ts +2 -0
  201. package/generated/internal/utils/render-label-title.js +16 -0
  202. package/generated/internal/utils/render-label.d.ts +1 -0
  203. package/generated/internal/utils/render-label.js +19 -0
  204. package/generated/internal/utils/set.d.ts +1 -0
  205. package/generated/internal/utils/set.js +7 -0
  206. package/generated/internal/utils/sleep.d.ts +1 -0
  207. package/generated/internal/utils/sleep.js +3 -0
  208. package/generated/internal/utils/slow-hide-show.d.ts +1 -0
  209. package/generated/internal/utils/slow-hide-show.js +16 -0
  210. package/generated/internal/utils/timeout.d.ts +5 -0
  211. package/generated/internal/utils/timeout.js +16 -0
  212. package/generated/internal/utils/touch-glass.d.ts +7 -0
  213. package/generated/internal/utils/touch-glass.js +19 -0
  214. package/generated/namespace-browser/base.d.ts +45 -0
  215. package/generated/namespace-browser/base.js +115 -0
  216. package/generated/namespace-browser/index.d.ts +7 -0
  217. package/generated/namespace-browser/index.js +1 -0
  218. package/generated/snapshot/index.d.ts +4 -11
  219. package/generated/snapshot/index.js +55 -145
  220. package/package.json +33 -9
  221. package/scss/_components.scss +60 -13
  222. package/scss/_final.scss +1 -0
  223. package/scss/_functions.scss +10 -0
  224. package/scss/_mixins.scss +4 -169
  225. package/scss/_placeholders.scss +3 -0
  226. package/scss/_transitions.scss +22 -1
  227. package/scss/_utils.scss +9 -0
  228. package/scss/_vars.scss +144 -23
  229. package/scss/base/_layout.scss +40 -16
  230. package/scss/base/_reboot.scss +151 -15
  231. package/scss/base/_root.scss +358 -25
  232. package/scss/colors/_index.scss +788 -70
  233. package/scss/components/_alert-dialog.scss +111 -0
  234. package/scss/components/_body-view.scss +12 -3
  235. package/scss/components/_bordered-button.scss +57 -0
  236. package/scss/components/_bordered-prominent-button.scss +64 -0
  237. package/scss/components/_borderless-button.scss +36 -6
  238. package/scss/components/_confirmation-dialog.scss +102 -0
  239. package/scss/components/_content-unavailable-view.scss +54 -0
  240. package/scss/components/_date-picker.scss +30 -0
  241. package/scss/components/_detail-placeholder.scss +153 -0
  242. package/scss/components/_disclosure-group.scss +147 -48
  243. package/scss/components/_fine-tooltip.scss +84 -0
  244. package/scss/components/_form-view.scss +233 -0
  245. package/scss/components/_full-screen.scss +7 -5
  246. package/scss/components/_glass-button.scss +59 -0
  247. package/scss/components/_glass-prominent-button.scss +70 -0
  248. package/scss/components/_h-divider.scss +13 -0
  249. package/scss/components/_h-flex-stack.scss +23 -0
  250. package/scss/components/_h-stack.scss +29 -0
  251. package/scss/components/_image-view.scss +9 -0
  252. package/scss/components/_index.scss +239 -7
  253. package/scss/components/_label-view copy.scss.txt +420 -0
  254. package/scss/components/_label-view.scss +372 -0
  255. package/scss/components/_label-view.scss.txt +536 -0
  256. package/scss/components/_labeled-content.scss +67 -0
  257. package/scss/components/_list-view.scss +269 -0
  258. package/scss/components/_menu-view.scss +219 -0
  259. package/scss/components/_navigation-large-title.scss +27 -0
  260. package/scss/components/_navigation-split-view.scss +329 -269
  261. package/scss/components/_navigation-stack.scss +6 -6
  262. package/scss/components/_navigation-title.scss +10 -0
  263. package/scss/components/_picker-view.scss +307 -0
  264. package/scss/components/_plain-button.scss +18 -0
  265. package/scss/components/_progress-view.scss +98 -0
  266. package/scss/components/_scroll-view-proxy.scss +79 -0
  267. package/scss/components/_scroll-view-toolbars.scss +126 -0
  268. package/scss/components/_scroll-view.scss +114 -66
  269. package/scss/components/_search-view.scss +22 -0
  270. package/scss/components/_section-view.scss +119 -0
  271. package/scss/components/_sheet-view.scss +78 -35
  272. package/scss/components/_sidebar-toggle.scss +87 -27
  273. package/scss/components/_sidebar-view.scss +30 -40
  274. package/scss/components/_sticky-container.scss +42 -0
  275. package/scss/components/_tab-bar.scss +211 -84
  276. package/scss/components/_tab-item.scss +25 -0
  277. package/scss/components/_tab-view.scss +270 -126
  278. package/scss/components/_table-column.scss +54 -0
  279. package/scss/components/_table-row.scss +240 -0
  280. package/scss/components/_table-view.scss +231 -0
  281. package/scss/components/_text-field.scss +53 -0
  282. package/scss/components/_tool-bar-item-group.scss +30 -19
  283. package/scss/components/_tool-bar-item.scss +81 -71
  284. package/scss/components/_tool-bar.scss +126 -63
  285. package/scss/components/_v-divider.scss +13 -0
  286. package/scss/components/_v-flex-stack.scss +29 -0
  287. package/scss/components/_v-keyboard.scss +6 -4
  288. package/scss/components/_v-stack.scss +15 -9
  289. package/scss/final/_touch-glass.scss +91 -0
  290. package/scss/index.scss +6 -2
  291. package/scss/mixins/_button.scss +44 -0
  292. package/scss/mixins/_color.scss +16 -0
  293. package/scss/mixins/_dialog.scss +89 -0
  294. package/scss/mixins/_index.scss +453 -0
  295. package/scss/placeholders/_buttons.scss +117 -0
  296. package/scss/placeholders/_lists.scss +594 -0
  297. package/scss/transitions/_alert-dialog.scss +18 -0
  298. package/scss/transitions/_bwd.navbar.scss +3 -13
  299. package/scss/transitions/_bwd.scss +4 -20
  300. package/scss/transitions/_confirmation-dialog.scss +27 -0
  301. package/scss/transitions/_disclosure-group.scss +35 -0
  302. package/scss/transitions/_fine-tooltip.scss +21 -0
  303. package/scss/transitions/_fwd.navbar.scss +4 -9
  304. package/scss/transitions/_fwd.scss +4 -34
  305. package/scss/transitions/_glass-button.scss +12 -0
  306. package/scss/transitions/_glass-prominent-button.scss +12 -0
  307. package/scss/transitions/_index.scss +35 -143
  308. package/scss/transitions/_menu-view.scss +26 -0
  309. package/scss/transitions/_navigation-split-view.scss +23 -0
  310. package/scss/transitions/_progress-view.scss +23 -0
  311. package/scss/transitions/_sheet-view.scss +30 -0
  312. package/scss/transitions/_sidebar-view.scss +36 -0
  313. package/scss/transitions/_tab-bar.scss +20 -0
  314. package/scss/utils/_frame.scss +91 -0
  315. package/scss/utils/_index.scss +78 -0
  316. package/scss/utils/_scroll-view.scss +14 -0
  317. package/scss/utils/_spacing.scss +25 -0
  318. package/scss/utils/_stacks.scss +222 -0
  319. package/web-components.html-data/en.json +721 -0
  320. package/generated/components/bottom-bar.d.ts +0 -10
  321. package/generated/components/bottom-bar.js +0 -73
  322. package/generated/components/navigation-bar.d.ts +0 -10
  323. package/generated/components/navigation-bar.js +0 -80
  324. package/generated/internal/class.d.ts +0 -18
  325. package/generated/internal/class.js +0 -18
  326. package/generated/namespace/index.d.ts +0 -6
  327. package/generated/styles.css +0 -1305
  328. package/scss/_dev.scss +0 -68
  329. package/scss/components/_tab-bar-stack.scss +0 -101
  330. package/scss/components/_toolbars.scss +0 -100
  331. package/scss/transitions/_dialog.scss +0 -32
  332. /package/generated/{namespace/index.js → events/alert-dialog.js} +0 -0
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).
@@ -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();
@@ -1,6 +1,24 @@
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';
1
6
  import { Snapshot } from '../snapshot';
2
- import { type WebComponentCtor } from '../namespace';
3
7
  export declare const polyfills: Map<string, WebComponentCtor>;
4
- type TransitionType = 'forwards' | 'backwards' | 'reload';
5
- export declare const startViewTransition: (event: Event, type?: TransitionType, updateCallback?: () => Promise<void>) => Promise<void>;
6
- export { Snapshot };
8
+ export declare const alert: (title?: string, message?: string, actions?: {
9
+ label?: string;
10
+ image?: string;
11
+ role?: string;
12
+ }[], options?: {
13
+ titleVisibility?: boolean;
14
+ }) => Promise<string>;
15
+ export declare const confirmationDialog: (trigger: HTMLElement, title: string, message?: string, actions?: {
16
+ label?: string;
17
+ image?: string;
18
+ role?: string;
19
+ }[], options?: {
20
+ controller?: AbortController;
21
+ titleVisibility?: boolean;
22
+ }) => Promise<string>;
23
+ export { I18n, lifecycleObserver, NavigationPath, queryInsertPosition, Snapshot, startViewTransition };
24
+ export { type NavigationHost };
@@ -1,70 +1,100 @@
1
+ import { alertDialog, confirmationDialog as confirmationDialogBus, lifecycleObserver } from '../buses';
1
2
  import * as Components from '../components';
2
- import { kebabCase } from '../internal/utils';
3
+ import { I18n } from '../i18n';
4
+ import { NavigationPath } from '../internal/class/navigation-path';
5
+ import { queryInsertPosition, startViewTransition } from '../internal/privateNamespace';
6
+ import { $, devFlags, kebabCase, onoff } from '../internal/utils';
3
7
  import { Snapshot } from '../snapshot';
8
+ //#region polyfills
4
9
  export const polyfills = new Map();
5
- for (const [k, v] of Object.entries(Components)) {
10
+ for (const [k, Ctor] of Object.entries(Components)) {
6
11
  const is = kebabCase(k);
7
- if ('polyfillExtends' in v &&
8
- 'string' === typeof v.polyfillExtends) {
9
- customElements.define(is, v, { extends: v.polyfillExtends });
10
- if (!(document.createElement(v.polyfillExtends, { is }) instanceof v))
11
- polyfills.set(is, v);
12
+ if ('polyfillExtends' in Ctor && 'string' === typeof Ctor.polyfillExtends) {
13
+ if (customElements.get(is))
14
+ continue;
15
+ customElements.define(is, Ctor, { extends: Ctor.polyfillExtends });
16
+ if (!(document.createElement(Ctor.polyfillExtends, { is }) instanceof Ctor))
17
+ polyfills.set(is, Ctor);
18
+ // const testEl = document.createElement('template')
19
+ // testEl.innerHTML = `<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`
20
+ // const testNode = testEl.content.firstElementChild,
21
+ if (!($(`<${Ctor.polyfillExtends} is="${is}"></${Ctor.polyfillExtends}>`, '>1') instanceof Ctor))
22
+ polyfills.set(is, Ctor);
12
23
  continue;
13
24
  }
14
- customElements.define(is, v);
25
+ if (!customElements.get(is))
26
+ customElements.define(is, Ctor);
15
27
  }
16
- console.debug(polyfills);
28
+ if (devFlags.debug)
29
+ console.debug(polyfills);
17
30
  if (0 < polyfills.size) {
18
- const polyfillTagNamesCache = new Set([...polyfills.values()]
19
- .map((v) => String(v.polyfillExtends ?? '').toUpperCase())
20
- .filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
31
+ const polyfillTagNamesCache = new Set([...polyfills.values()].map((v) => String(v.polyfillExtends ?? '').toUpperCase()).filter(Boolean)); // ['TAG-NAME1', 'TAG-NAME2', ...]
21
32
  const handlers = new WeakMap();
22
- // @ts-expect-error
23
33
  const observe = (el, polyfill) => {
24
34
  if (!Array.isArray(polyfill.observedAttributes))
25
35
  return;
26
36
  if (0 === polyfill?.observedAttributes.length)
27
37
  return;
28
- handlers.set(el, new MutationObserver(polyfill.polyfillAttributeChangedCallback).observe(el, {
38
+ if (!polyfill.polyfillAttributeChangedCallback)
39
+ return;
40
+ const observer = new MutationObserver(polyfill.polyfillAttributeChangedCallback);
41
+ observer.observe(el, {
29
42
  attributes: true,
30
43
  attributeFilter: polyfill.observedAttributes,
31
44
  attributeOldValue: true,
32
- }));
33
- },
34
- // @ts-expect-error
35
- unobserve = (el) => {
45
+ });
46
+ handlers.set(el, observer);
47
+ for (const attributeName of polyfill.observedAttributes)
48
+ if (el.hasAttribute(attributeName)) {
49
+ const entry = {
50
+ attributeName,
51
+ oldValue: null,
52
+ target: el,
53
+ };
54
+ polyfill.polyfillAttributeChangedCallback([entry]);
55
+ }
56
+ }, unobserve = (el) => {
36
57
  handlers.delete(el);
37
- };
38
- console.debug(polyfillTagNamesCache);
58
+ }, polyfillTagNamesCacheSelector = [...polyfillTagNamesCache.values()].map((v) => `${v}`.toLowerCase()).join(','), flatten = (node) => [node, ...(node.querySelectorAll?.(polyfillTagNamesCacheSelector) ?? [])];
59
+ if (devFlags.debug)
60
+ console.debug(polyfillTagNamesCache, polyfillTagNamesCacheSelector);
39
61
  for (const [is, polyfill] of polyfills)
40
- for (const el of document.querySelectorAll(`${polyfill.polyfillExtends}[is="${is}"]`)) {
62
+ for (const el of document.querySelectorAll(`${polyfill.polyfillExtends}[is="${CSS.escape(is)}"]`)) {
41
63
  polyfill.polyfillConnectedCallback(el);
42
64
  observe(el, polyfill);
43
65
  }
44
66
  // observer callback
45
67
  const observer = new MutationObserver((mutations) => {
46
68
  for (const { addedNodes, removedNodes } of mutations) {
47
- for (const node of addedNodes) {
48
- if (!(node instanceof HTMLElement))
49
- continue;
50
- if (!polyfillTagNamesCache.has(node.tagName))
69
+ for (const root of addedNodes) {
70
+ if (!(root instanceof HTMLElement))
51
71
  continue;
52
- const is = node?.getAttribute('is') ?? '';
53
- if (!polyfills.has(is))
54
- continue;
55
- polyfills.get(is)?.polyfillConnectedCallback(node);
56
- observe(node, polyfills.get(is));
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
+ }
57
83
  }
58
- for (const node of removedNodes) {
59
- if (!(node instanceof HTMLElement))
60
- continue;
61
- if (!polyfillTagNamesCache.has(node.tagName))
84
+ for (const root of removedNodes) {
85
+ if (!(root instanceof HTMLElement))
62
86
  continue;
63
- const is = node?.getAttribute('is') ?? '';
64
- if (!polyfills.has(is))
65
- continue;
66
- polyfills.get(is)?.polyfillDisconnectedCallback(node);
67
- unobserve(node);
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
+ }
68
98
  }
69
99
  }
70
100
  });
@@ -73,151 +103,159 @@ if (0 < polyfills.size) {
73
103
  subtree: true,
74
104
  });
75
105
  }
76
- const cleanup = (lm, dir) => {
77
- let arr = [
78
- Snapshot.config['vt-fwd-class-name'],
79
- 'fwdd',
80
- 'fwn',
81
- 'fwnn',
82
- 'bwd',
83
- 'bwdd',
84
- 'bwn',
85
- 'bwnn',
86
- ];
87
- if (['backwards', 'forwards'].includes(dir ?? ''))
88
- for (let i = arr.length - 1; i >= 0; i--)
89
- if (arr[i].startsWith('backwards' === dir ? 'fw' : 'bw'))
90
- arr.splice(i, 1);
91
- for (const el of [
92
- ...(lm?.querySelectorAll(arr.map((v) => `.${v}`).join(',')) ?? []),
93
- ])
94
- el.classList.remove(...arr);
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' === trigger.tagName)
117
+ return;
118
+ if (relatedTarget instanceof HTMLElement && trigger.contains(relatedTarget))
119
+ return;
120
+ const newAnchorName = `--help-${self.crypto.randomUUID()}`;
121
+ const tooltip = $(`<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' === 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?.()
95
155
  };
96
- export const startViewTransition = async (event, type = 'forwards', updateCallback = async () => { }) => {
97
- // const sv =
98
- // (event.target as HTMLElement).closest<Components.ScrollView>(
99
- // 'scroll-view'
100
- // ) ?? undefined,
101
- const from = event.target.closest('scroll-view') ?? undefined;
102
- if ('forwards' === type) {
103
- // const sis = Router.toolbarItems //sv.parentElement.querySelectorAll(`:scope > navigation-bar > toolbar-item,:scope > bottom-bar > toolbar-item`)
104
- // pr = Router.frame //sv.parentElement
105
- // const pt = event.target.closest('navigation-stack,body-view')
106
- // const inte = event.target.closest(".fwd");
107
- // const st = sv.scrollTop
108
- // console.log(333, lm, sv, sis)
109
- // let to
110
- // inject or unhide
111
- // if (pr.tagName === 'NAVIGATION-STACK' && 'more' === pr.getAttribute('is')) {
112
- // to = document.querySelector(`#${event.target.getAttribute('tag')}`)
113
- // to.hidden = false
114
- // } else {
115
- await updateCallback(); // updatetheDOMSomehow
116
- // to = sv.nextElementSibling //pr.lastElementChild //sv.nextElementSibling
117
- // }
118
- Snapshot.getSnapshot(from);
119
- const fromToolbars = Snapshot.toolbarItems;
120
- // from = Snapshot.landmark
121
- const to = Snapshot.leaf, toFrame = Snapshot.leafContainer, toToolbars = Snapshot.leafToolbarItems;
122
- if ('DIALOG' === toFrame?.tagName) {
123
- ;
124
- toFrame.showModal();
125
- console.debug(`⚡️ view-transition-start (${type})`);
126
- await Promise.allSettled(toFrame.getAnimations().map(({ finished }) => finished));
127
- console.debug(`⚡️ view-transition-end (${type})`);
128
- return;
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
+ export const alert = async (title, message, actions, options) => {
178
+ return await navigator.locks.request('alert:', async () => {
179
+ const dialog = $(`<dialog is="alert-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(`<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
180
+ if (title) {
181
+ const label = $(`<label-view font="headline"></label-view>`, '>1');
182
+ label.setAttribute('title', title);
183
+ vStack.insertAdjacentElement('beforeend', label);
129
184
  }
130
- // purge
131
- cleanup(Snapshot.root, 'backwards');
132
- for (const ti of toToolbars ?? [])
133
- ti.classList.add('fwnn');
134
- to?.classList.add('fwdd');
135
- // prepare principal/leader
136
- from?.classList.add(Snapshot.config['vt-fwd-class-name']);
137
- for (const ti of fromToolbars ?? [])
138
- ti.classList.add('fwn'); // prepare navbs
139
- // sv.inert = true
140
- // if (!document.startViewTransition) {
141
- // startViewTransition(event, false)
142
- // return
143
- // }
144
- // With a transition:
145
- // const transition = document.startViewTransition({
146
- // async update() {},
147
- // types: ['forwards'],
148
- // })
149
- // console.debug(transition)
150
- // await transition.finished
151
- // alert(3)
152
- // return
153
- console.debug(`⚡️ view-transition-start (${type})`);
154
- await Promise.allSettled([
155
- ...(from?.getAnimations().map(({ finished }) => finished) ?? []),
156
- ...(to?.getAnimations().map(({ finished }) => finished) ?? []),
157
- ]);
158
- // await Promise.allSettled(
159
- // from.getAnimations().map(({ finished }) => finished)
160
- // )
161
- console.debug(`⚡️ view-transition-end (${type})`);
162
- // console.log(9, to.querySelectorAll('.fwd'))
163
- // sv2.classList.remove("fwdd");
164
- if (0 <
165
- (toFrame?.querySelectorAll(`.${Snapshot.config?.['vt-fwd-class-name']},.bwd`) ?? []).length)
166
- return;
167
- cleanup(Snapshot.root);
185
+ if (message) {
186
+ const label = $(`<label-view foreground="secondary" font="callout"></label-view>`, '>1');
187
+ label.setAttribute('title', message);
188
+ vStack.insertAdjacentElement('beforeend', label);
189
+ }
190
+ for (const [index, action] of (actions ?? [
191
+ {
192
+ role: 'close',
193
+ },
194
+ ]).entries()) {
195
+ const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
196
+ btn.setAttribute('value', `${index}`);
197
+ if (action?.role)
198
+ btn.setAttribute('role', action.role);
199
+ if (action.label || action.image) {
200
+ const label = $(`<label-view></label-view>`, '>1');
201
+ if (action.label)
202
+ label.setAttribute('title', action.label);
203
+ if (action.image)
204
+ label.setAttribute('system-image', action.image);
205
+ btn.appendChild(label);
206
+ }
207
+ dialog.insertAdjacentElement('beforeend', btn);
208
+ }
209
+ document.body.insertAdjacentElement('beforeend', dialog);
210
+ dialog.showModal();
211
+ const { promise, resolve } = Promise.withResolvers(), off = onoff('alert:return', (evt) => {
212
+ const { detail } = evt;
213
+ off();
214
+ resolve(detail.returnValue);
215
+ }, alertDialog, { once: true }).on();
216
+ return promise;
217
+ });
218
+ };
219
+ export const confirmationDialog = async (trigger, title, message, actions, options) => {
220
+ const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
221
+ const dialog = $(`<dialog is="confirmation-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(`<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
222
+ trigger.style.setProperty('anchor-name', newAnchorName, 'important'); //$.prop('anchor-name', newAnchorName, trigger, 'important')
223
+ dialog.style.setProperty('position-anchor', newAnchorName); //$.prop('position-anchor', newAnchorName, dialog)
224
+ if (title && false !== options?.titleVisibility) {
225
+ const label = $(`<label-view font="headline"></label-view>`, '>1');
226
+ label.setAttribute('title', title);
227
+ vStack.insertAdjacentElement('beforeend', label);
168
228
  }
169
- else {
170
- Snapshot.getSnapshot(from);
171
- const fromToolbars = Snapshot.toolbarItems,
172
- // from = Snapshot.landmark,
173
- fromFrame = Snapshot.container; //sv.parentElement.querySelectorAll(`:scope > navigation-bar > toolbar-item,:scope > bottom-bar > toolbar-item`)
174
- // fromFrame = Router.frame //sv.parentElement
175
- // const pt = event.target.closest('navigation-stack,body-view')
176
- // const pt = pt0.parentElement.closest('navigation-stack,body-view')
177
- const to = Snapshot.parent, //pr.parentElement.querySelector(`:scope > scroll-view`) //pr.previousElementSibling
178
- // toFrame = Snapshot.parentContainer,
179
- toToolbars = Snapshot.parentToolbarItems; //sv2.parentElement?.querySelectorAll?.( `:scope > navigation-bar > toolbar-item,:scope > bottom-bar > toolbar-item` )
180
- // const st2 = sv2.scrollTop
181
- if ('DIALOG' === fromFrame?.tagName) {
182
- ;
183
- fromFrame.close();
184
- console.debug(`⚡️ view-transition-start (${type})`);
185
- await Promise.allSettled(fromFrame.getAnimations().map(({ finished }) => finished));
186
- console.debug(`⚡️ view-transition-end (${type})`);
187
- if (fromFrame.matches('[open]'))
188
- return;
189
- await updateCallback();
190
- return;
229
+ if (message && false !== options?.titleVisibility) {
230
+ const label = $(`<label-view foreground="secondary" font="callout"></label-view>`, '>1');
231
+ label.setAttribute('title', message);
232
+ vStack.insertAdjacentElement('beforeend', label);
233
+ }
234
+ for (const [index, action] of (actions ?? []).entries()) {
235
+ const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
236
+ btn.setAttribute('value', `${index}`);
237
+ if (action?.role)
238
+ btn.setAttribute('role', action.role);
239
+ if (action.label || action.image) {
240
+ const label = $(`<label-view></label-view>`, '>1');
241
+ if (action.label)
242
+ label.setAttribute('title', action.label);
243
+ if (action.image)
244
+ label.setAttribute('system-image', action.image);
245
+ btn.appendChild(label);
191
246
  }
192
- // purge
193
- cleanup(Snapshot.root, 'forwards');
194
- // prepare others
195
- for (const ti of toToolbars ?? [])
196
- ti.classList.add('bwnn');
197
- to?.classList.add('bwdd');
198
- // sv2.style.visibility = "visible";
199
- // prepare leader/principal (tracked)
200
- for (const ti of fromToolbars ?? [])
201
- ti.classList.add('bwn');
202
- from?.classList.add('bwd');
203
- // pr.inert = true
204
- console.debug(`⚡️ view-transition-start (${type})`);
205
- await Promise.allSettled([
206
- ...(from?.getAnimations().map(({ finished }) => finished) ?? []),
207
- ...(to?.getAnimations().map(({ finished }) => finished) ?? []),
208
- ]);
209
- // await Promise.allSettled(
210
- // from.getAnimations().map(({ finished }) => finished)
211
- // )
212
- // await Promise.allSettled(to.getAnimations().map(({ finished }) => finished))
213
- console.debug(`⚡️ view-transition-end (${type})`);
214
- // console.log(999, sv2.closest('.fwd'))
215
- if (to?.closest(`.bwd,.${Snapshot.config?.['vt-fwd-class-name']}`))
216
- return;
217
- cleanup(Snapshot.root);
218
- // remove or hide
219
- await updateCallback();
247
+ dialog.insertAdjacentElement('beforeend', btn);
220
248
  }
249
+ trigger.closest('body-view,dialog')?.insertAdjacentElement('beforeend', dialog); // dialog.showModal()
250
+ const { promise, resolve } = Promise.withResolvers(), off = onoff('confirmation:return', (evt) => {
251
+ const { detail } = evt;
252
+ off();
253
+ resolve(detail.returnValue);
254
+ }, confirmationDialogBus, { once: true }).on();
255
+ return promise;
221
256
  };
222
- void Snapshot.setOwnConfig();
223
- export { Snapshot };
257
+ //#endregion
258
+ void Snapshot.waitReady;
259
+ //#region exports
260
+ export { I18n, lifecycleObserver, NavigationPath, queryInsertPosition, Snapshot, startViewTransition };
261
+ //#endregion
@@ -0,0 +1,8 @@
1
+ import { DialogBase } from '../namespace-browser/base';
2
+ export declare class AlertDialog extends DialogBase {
3
+ #private;
4
+ constructor();
5
+ static polyfillDisconnectedCallback(el: AlertDialog): void;
6
+ static polyfillConnectedCallback(el: AlertDialog): void;
7
+ static polyfillAttributeChangedCallback([{ attributeName, target, oldValue }]: Pick<MutationRecord, 'attributeName' | 'oldValue' | 'target'>[]): void;
8
+ }
@@ -0,0 +1,99 @@
1
+ import { alertDialog } from '../buses';
2
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
3
+ import { devFlags, onoff, touchGlass } from '../internal/utils';
4
+ import { DialogBase } from '../namespace-browser/base';
5
+ export class AlertDialog extends DialogBase {
6
+ constructor() {
7
+ super();
8
+ }
9
+ static polyfillDisconnectedCallback(el) {
10
+ if (devFlags.debug)
11
+ console.debug(`${AlertDialog.name} ⚡️ disconnect`);
12
+ CleanupRegistry.unregister(el);
13
+ alertDialog.dispatchEvent(new CustomEvent('alert:return', {
14
+ detail: { returnValue: el.returnValue },
15
+ bubbles: true,
16
+ composed: true,
17
+ }));
18
+ }
19
+ static polyfillConnectedCallback(el) {
20
+ if (devFlags.debug)
21
+ console.debug(`${AlertDialog.name} ⚡️ connect`);
22
+ CleanupRegistry.register(el, onoff([
23
+ { types: 'click', listener: this.#handleDialogClick },
24
+ { types: 'close', listener: this.#handleDialogClose },
25
+ { types: 'cancel', listener: this.#handleDialogCancel },
26
+ ], el).on());
27
+ CleanupRegistry.register(el, onoff(touchGlass(el, (t) => t, ({ target }) => {
28
+ if (!(target instanceof HTMLElement))
29
+ return true;
30
+ if (target.matches('[is=alert-dialog]'))
31
+ return false;
32
+ return true;
33
+ }), el).on());
34
+ if (devFlags.debug)
35
+ console.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
+ if (devFlags.debug)
44
+ console.debug(`${AlertDialog.name} ⚡️ attr-change [${attributeName}] ("${oldValue}" → "${target.getAttribute(attributeName ?? '')}")`);
45
+ switch (attributeName) {
46
+ case 'label':
47
+ //
48
+ break;
49
+ }
50
+ }
51
+ static #handleDialogClick = (evt) => {
52
+ if (devFlags.debug)
53
+ console.debug(`${AlertDialog.name} ⚡️ ${evt?.type}`);
54
+ const { target, currentTarget: dialog } = evt;
55
+ if (!(dialog instanceof HTMLDialogElement))
56
+ return;
57
+ if (!(target instanceof HTMLElement))
58
+ return;
59
+ const button = target.closest('button');
60
+ if (!button)
61
+ return;
62
+ button.scrollIntoView({
63
+ behavior: self.matchMedia('(prefers-reduced-motion: no-preference)').matches ? 'smooth' : 'instant',
64
+ block: 'nearest',
65
+ inline: 'nearest',
66
+ });
67
+ dialog.returnValue = button.value;
68
+ dialog.requestClose(button.value);
69
+ evt.stopPropagation();
70
+ evt.stopImmediatePropagation();
71
+ };
72
+ static #handleDialogCancel = (evt) => {
73
+ if (devFlags.debug)
74
+ console.debug(`${AlertDialog.name} ⚡️ ${evt?.type}`);
75
+ if (!evt.cancelable)
76
+ return;
77
+ const { target } = evt;
78
+ if (!(target instanceof HTMLDialogElement))
79
+ return;
80
+ evt.preventDefault();
81
+ target.inert = true;
82
+ if (devFlags.debug)
83
+ console.debug(`${AlertDialog.name} ⚡️ will-close`);
84
+ target.setAttribute('closing', '');
85
+ Promise.allSettled(target.getAnimations().map(({ finished }) => finished)).then(() => {
86
+ if (!target.hasAttribute('closing'))
87
+ return;
88
+ target?.close(target?.returnValue);
89
+ target.removeAttribute('closing');
90
+ });
91
+ };
92
+ static #handleDialogClose = ({ type, target }) => {
93
+ if (devFlags.debug)
94
+ console.debug(`${AlertDialog.name} ⚡️ ${type}`);
95
+ if (!(target instanceof HTMLDialogElement))
96
+ return;
97
+ target.remove();
98
+ };
99
+ }