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

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 (355) 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 +30 -2
  11. package/generated/client/index.js +279 -8
  12. package/generated/components/alert-dialog.d.ts +11 -0
  13. package/generated/components/alert-dialog.js +102 -0
  14. package/generated/components/body-view.d.ts +13 -0
  15. package/generated/components/body-view.js +17 -0
  16. package/generated/components/bordered-button.d.ts +17 -0
  17. package/generated/components/bordered-button.js +56 -0
  18. package/generated/components/bordered-prominent-button.d.ts +17 -0
  19. package/generated/components/bordered-prominent-button.js +56 -0
  20. package/generated/components/borderless-button.d.ts +17 -0
  21. package/generated/components/borderless-button.js +56 -0
  22. package/generated/components/color-scheme.d.ts +12 -0
  23. package/generated/components/color-scheme.js +54 -0
  24. package/generated/components/confirmation-dialog.d.ts +12 -0
  25. package/generated/components/confirmation-dialog.js +116 -0
  26. package/generated/components/content-unavailable.d.ts +30 -0
  27. package/generated/components/content-unavailable.js +82 -0
  28. package/generated/components/date-picker.d.ts +52 -0
  29. package/generated/components/date-picker.js +480 -0
  30. package/generated/components/disclosure-group.d.ts +17 -0
  31. package/generated/components/disclosure-group.js +66 -0
  32. package/generated/components/fine-tooltip.d.ts +15 -0
  33. package/generated/components/fine-tooltip.js +111 -0
  34. package/generated/components/form-view.d.ts +16 -0
  35. package/generated/components/form-view.js +65 -0
  36. package/generated/components/glass-button.d.ts +16 -0
  37. package/generated/components/glass-button.js +53 -0
  38. package/generated/components/glass-prominent-button.d.ts +16 -0
  39. package/generated/components/glass-prominent-button.js +53 -0
  40. package/generated/components/h-stack.d.ts +22 -0
  41. package/generated/components/h-stack.js +26 -0
  42. package/generated/components/image-view.d.ts +18 -0
  43. package/generated/components/image-view.js +68 -0
  44. package/generated/components/index.d.ts +47 -1
  45. package/generated/components/index.js +47 -6
  46. package/generated/components/label-view.d.ts +27 -0
  47. package/generated/components/label-view.js +87 -0
  48. package/generated/components/labeled-content.d.ts +33 -0
  49. package/generated/components/labeled-content.js +161 -0
  50. package/generated/components/list-view.d.ts +15 -0
  51. package/generated/components/list-view.js +22 -0
  52. package/generated/components/menu-view.d.ts +20 -0
  53. package/generated/components/menu-view.js +140 -0
  54. package/generated/components/navigation-large-title.d.ts +18 -0
  55. package/generated/components/navigation-large-title.js +188 -0
  56. package/generated/components/navigation-split-view.d.ts +15 -0
  57. package/generated/components/navigation-split-view.js +25 -0
  58. package/generated/components/navigation-stack.d.ts +15 -0
  59. package/generated/components/navigation-stack.js +29 -0
  60. package/generated/components/navigation-title.d.ts +18 -0
  61. package/generated/components/navigation-title.js +72 -0
  62. package/generated/components/picker-view.d.ts +68 -0
  63. package/generated/components/picker-view.js +1153 -0
  64. package/generated/components/plain-button.d.ts +7 -0
  65. package/generated/components/plain-button.js +22 -0
  66. package/generated/components/progress-view.d.ts +20 -0
  67. package/generated/components/progress-view.js +125 -0
  68. package/generated/components/screen-view.d.ts +5 -0
  69. package/generated/components/screen-view.js +11 -0
  70. package/generated/components/scroll-view-proxy.d.ts +13 -0
  71. package/generated/components/scroll-view-proxy.js +17 -0
  72. package/generated/components/scroll-view.d.ts +22 -0
  73. package/generated/components/scroll-view.js +237 -0
  74. package/generated/components/search-view.d.ts +12 -0
  75. package/generated/components/search-view.js +27 -0
  76. package/generated/components/section-view.d.ts +21 -0
  77. package/generated/components/section-view.js +64 -0
  78. package/generated/components/sheet-view.d.ts +11 -0
  79. package/generated/components/sheet-view.js +45 -0
  80. package/generated/components/sidebar-toggle.d.ts +15 -0
  81. package/generated/components/sidebar-toggle.js +88 -0
  82. package/generated/components/sidebar-view.d.ts +10 -0
  83. package/generated/components/sidebar-view.js +37 -0
  84. package/generated/components/sticky-container.d.ts +11 -0
  85. package/generated/components/sticky-container.js +26 -0
  86. package/generated/components/tab-bar.d.ts +10 -0
  87. package/generated/components/tab-bar.js +40 -0
  88. package/generated/components/tab-item.d.ts +10 -0
  89. package/generated/components/tab-item.js +134 -0
  90. package/generated/components/tab-view.d.ts +31 -0
  91. package/generated/components/tab-view.js +198 -0
  92. package/generated/components/table-view.d.ts +26 -0
  93. package/generated/components/table-view.js +161 -0
  94. package/generated/components/text-field.d.ts +42 -0
  95. package/generated/components/text-field.js +526 -0
  96. package/generated/components/toggle-view.d.ts +43 -0
  97. package/generated/components/toggle-view.js +371 -0
  98. package/generated/components/tool-bar-item-group.d.ts +13 -0
  99. package/generated/components/tool-bar-item-group.js +31 -0
  100. package/generated/components/tool-bar-item.d.ts +16 -0
  101. package/generated/components/tool-bar-item.js +69 -0
  102. package/generated/components/tool-bar.d.ts +26 -0
  103. package/generated/components/tool-bar.js +95 -0
  104. package/generated/components/v-keyboard.d.ts +18 -0
  105. package/generated/components/v-keyboard.js +87 -0
  106. package/generated/components/v-stack.d.ts +25 -0
  107. package/generated/components/v-stack.js +29 -0
  108. package/generated/css/index.css +10644 -0
  109. package/generated/events/alert-dialog.d.ts +13 -0
  110. package/generated/events/alert-dialog.js +1 -0
  111. package/generated/events/confirmation-dialog.d.ts +14 -0
  112. package/generated/events/confirmation-dialog.js +1 -0
  113. package/generated/events/date-picker.d.ts +13 -0
  114. package/generated/events/date-picker.js +1 -0
  115. package/generated/events/index.d.ts +9 -0
  116. package/generated/events/index.js +9 -0
  117. package/generated/events/lifecycle-observer.d.ts +18 -0
  118. package/generated/events/lifecycle-observer.js +1 -0
  119. package/generated/events/picker-view.d.ts +29 -0
  120. package/generated/events/picker-view.js +1 -0
  121. package/generated/events/scroll-view.d.ts +18 -0
  122. package/generated/events/scroll-view.js +1 -0
  123. package/generated/events/tab-view.d.ts +54 -0
  124. package/generated/events/tab-view.js +1 -0
  125. package/generated/events/text-field.d.ts +13 -0
  126. package/generated/events/text-field.js +1 -0
  127. package/generated/events/toggle-view.d.ts +14 -0
  128. package/generated/events/toggle-view.js +1 -0
  129. package/generated/i18n/index.d.ts +33 -0
  130. package/generated/i18n/index.js +164 -0
  131. package/generated/i18n/locales/el.d.ts +16 -0
  132. package/generated/i18n/locales/el.js +16 -0
  133. package/generated/i18n/locales/en.d.ts +16 -0
  134. package/generated/i18n/locales/en.js +16 -0
  135. package/generated/i18n/locales/index.d.ts +4 -0
  136. package/generated/i18n/locales/index.js +4 -0
  137. package/generated/index.js +1 -1
  138. package/generated/internal/class/cleanup-registry.d.ts +5 -0
  139. package/generated/internal/class/cleanup-registry.js +38 -0
  140. package/generated/internal/class/css-style-observer.d.ts +8 -0
  141. package/generated/internal/class/css-style-observer.js +26 -0
  142. package/generated/internal/class/form-associated-base.d.ts +16 -0
  143. package/generated/internal/class/form-associated-base.js +78 -0
  144. package/generated/internal/class/mutation-observer-set.d.ts +9 -0
  145. package/generated/internal/class/mutation-observer-set.js +42 -0
  146. package/generated/internal/class/mutation-observer-singleton.d.ts +10 -0
  147. package/generated/internal/class/mutation-observer-singleton.js +64 -0
  148. package/generated/internal/class/navigation-path.d.ts +15 -0
  149. package/generated/internal/class/navigation-path.js +84 -0
  150. package/generated/internal/class/navigation-view.d.ts +8 -0
  151. package/generated/internal/class/navigation-view.js +72 -0
  152. package/generated/internal/class/resize-observer-singleton.d.ts +7 -0
  153. package/generated/internal/class/resize-observer-singleton.js +22 -0
  154. package/generated/internal/decorators/adaptive-slot.d.ts +1 -0
  155. package/generated/internal/decorators/adaptive-slot.js +50 -0
  156. package/generated/internal/decorators/custom-element.d.ts +5 -0
  157. package/generated/internal/decorators/custom-element.js +5 -0
  158. package/generated/internal/decorators/index.d.ts +6 -0
  159. package/generated/internal/decorators/index.js +6 -0
  160. package/generated/internal/decorators/microtask-on-connected.d.ts +39 -0
  161. package/generated/internal/decorators/microtask-on-connected.js +67 -0
  162. package/generated/internal/privateNamespace.d.ts +14 -0
  163. package/generated/internal/privateNamespace.js +168 -0
  164. package/generated/internal/utils/add.d.ts +1 -0
  165. package/generated/internal/utils/add.js +7 -0
  166. package/generated/internal/utils/cash/ancestors.d.ts +1 -0
  167. package/generated/internal/utils/cash/ancestors.js +27 -0
  168. package/generated/internal/utils/cash/index.d.ts +24 -0
  169. package/generated/internal/utils/cash/index.js +27 -0
  170. package/generated/internal/utils/cash/next-all.d.ts +1 -0
  171. package/generated/internal/utils/cash/next-all.js +10 -0
  172. package/generated/internal/utils/cash/next.d.ts +1 -0
  173. package/generated/internal/utils/cash/next.js +9 -0
  174. package/generated/internal/utils/cash/prev-all.d.ts +1 -0
  175. package/generated/internal/utils/cash/prev-all.js +10 -0
  176. package/generated/internal/utils/cash/prev.d.ts +1 -0
  177. package/generated/internal/utils/cash/prev.js +9 -0
  178. package/generated/internal/utils/cash/prop.d.ts +18 -0
  179. package/generated/internal/utils/cash/prop.js +30 -0
  180. package/generated/internal/utils/cash/siblings.d.ts +1 -0
  181. package/generated/internal/utils/cash/siblings.js +10 -0
  182. package/generated/internal/utils/clamp.d.ts +1 -0
  183. package/generated/internal/utils/clamp.js +4 -0
  184. package/generated/internal/utils/compare-big-decimals.d.ts +1 -0
  185. package/generated/internal/utils/compare-big-decimals.js +80 -0
  186. package/generated/internal/utils/css-time.d.ts +1 -0
  187. package/generated/internal/utils/css-time.js +3 -0
  188. package/generated/internal/utils/debounce.d.ts +1 -0
  189. package/generated/internal/utils/debounce.js +13 -0
  190. package/generated/internal/utils/define-translations.d.ts +1 -0
  191. package/generated/internal/utils/define-translations.js +3 -0
  192. package/generated/internal/utils/dev-flags.d.ts +3 -0
  193. package/generated/internal/utils/dev-flags.js +5 -0
  194. package/generated/internal/utils/ensure-placeholder.d.ts +1 -0
  195. package/generated/internal/utils/ensure-placeholder.js +41 -0
  196. package/generated/internal/utils/frame.d.ts +1 -0
  197. package/generated/internal/utils/frame.js +6 -0
  198. package/generated/internal/utils/index.d.ts +20 -1
  199. package/generated/internal/utils/index.js +23 -1
  200. package/generated/internal/utils/is-inside.d.ts +1 -0
  201. package/generated/internal/utils/is-inside.js +4 -0
  202. package/generated/internal/utils/kebab-case.d.ts +1 -1
  203. package/generated/internal/utils/kebab-case.js +6 -9
  204. package/generated/internal/utils/list-active.d.ts +7 -0
  205. package/generated/internal/utils/list-active.js +83 -0
  206. package/generated/internal/utils/microtask.d.ts +1 -0
  207. package/generated/internal/utils/microtask.js +3 -0
  208. package/generated/internal/utils/onoff.d.ts +45 -0
  209. package/generated/internal/utils/onoff.js +31 -0
  210. package/generated/internal/utils/set.d.ts +1 -0
  211. package/generated/internal/utils/set.js +7 -0
  212. package/generated/internal/utils/sleep.d.ts +1 -0
  213. package/generated/internal/utils/sleep.js +3 -0
  214. package/generated/internal/utils/slow-hide-show.d.ts +1 -0
  215. package/generated/internal/utils/slow-hide-show.js +16 -0
  216. package/generated/internal/utils/timeout.d.ts +5 -0
  217. package/generated/internal/utils/timeout.js +16 -0
  218. package/generated/internal/utils/touch-glass.d.ts +7 -0
  219. package/generated/internal/utils/touch-glass.js +19 -0
  220. package/generated/internal/vendor/morphdom.d.ts +6 -0
  221. package/generated/internal/vendor/morphdom.js +720 -0
  222. package/generated/morphdom/index.d.ts +8 -0
  223. package/generated/morphdom/index.js +8 -0
  224. package/generated/morphdom/morph.d.ts +4 -0
  225. package/generated/morphdom/morph.js +10 -0
  226. package/generated/morphdom/query-morph.d.ts +5 -0
  227. package/generated/morphdom/query-morph.js +12 -0
  228. package/generated/morphdom/render-to-string.d.ts +12 -0
  229. package/generated/morphdom/render-to-string.js +48 -0
  230. package/generated/morphdom/unsafe-html.d.ts +2 -0
  231. package/generated/morphdom/unsafe-html.js +4 -0
  232. package/generated/namespace-browser/base.d.ts +45 -0
  233. package/generated/namespace-browser/base.js +115 -0
  234. package/generated/namespace-browser/event.d.ts +10 -0
  235. package/generated/namespace-browser/event.js +1 -0
  236. package/generated/namespace-browser/index.d.ts +7 -0
  237. package/generated/namespace-browser/index.js +1 -0
  238. package/generated/snapshot/index.d.ts +9 -0
  239. package/generated/snapshot/index.js +60 -0
  240. package/generated/tpl/html.d.ts +5 -0
  241. package/generated/tpl/html.js +7 -0
  242. package/generated/tpl/index.d.ts +6 -0
  243. package/generated/tpl/index.js +6 -0
  244. package/generated/tpl/is-template-result.d.ts +3 -0
  245. package/generated/tpl/is-template-result.js +1 -0
  246. package/generated/tpl/render.d.ts +2 -0
  247. package/generated/tpl/render.js +132 -0
  248. package/package.json +53 -7
  249. package/scss/_base.scss +5 -0
  250. package/scss/_components.scss +90 -0
  251. package/scss/_final.scss +1 -0
  252. package/scss/_functions.scss +31 -0
  253. package/scss/_maps.scss +293 -0
  254. package/scss/_mixins.scss +7 -0
  255. package/scss/_placeholders.scss +3 -0
  256. package/scss/_transitions.scss +32 -0
  257. package/scss/_utils.scss +9 -0
  258. package/scss/_vars.scss +68 -0
  259. package/scss/base/_layout.scss +66 -0
  260. package/scss/base/_reboot.scss +191 -0
  261. package/scss/base/_root.scss +415 -0
  262. package/scss/colors/_index.scss +881 -0
  263. package/scss/components/_alert-dialog.scss +111 -0
  264. package/scss/components/_body-view.scss +17 -0
  265. package/scss/components/_bordered-button.scss +59 -0
  266. package/scss/components/_bordered-prominent-button.scss +65 -0
  267. package/scss/components/_borderless-button.scss +45 -0
  268. package/scss/components/_confirmation-dialog.scss +102 -0
  269. package/scss/components/_content-unavailable.scss +57 -0
  270. package/scss/components/_date-picker.scss +30 -0
  271. package/scss/components/_detail-placeholder.scss +153 -0
  272. package/scss/components/_disclosure-group.scss +179 -0
  273. package/scss/components/_fine-tooltip.scss +84 -0
  274. package/scss/components/_form-view.scss +234 -0
  275. package/scss/components/_full-screen.scss +15 -0
  276. package/scss/components/_glass-button.scss +61 -0
  277. package/scss/components/_glass-prominent-button.scss +71 -0
  278. package/scss/components/_group-box.scss +27 -0
  279. package/scss/components/_h-divider.scss +13 -0
  280. package/scss/components/_h-flex-stack.scss +23 -0
  281. package/scss/components/_h-stack.scss +28 -0
  282. package/scss/components/_image-view.scss +20 -0
  283. package/scss/components/_index.scss +264 -0
  284. package/scss/components/_label-view copy.scss.txt +420 -0
  285. package/scss/components/_label-view.scss +371 -0
  286. package/scss/components/_label-view.scss.txt +536 -0
  287. package/scss/components/_labeled-content.scss +75 -0
  288. package/scss/components/_list-view.scss +270 -0
  289. package/scss/components/_menu-view.scss +223 -0
  290. package/scss/components/_navigation-large-title.scss +44 -0
  291. package/scss/components/_navigation-split-view.scss +424 -0
  292. package/scss/components/_navigation-stack.scss +11 -0
  293. package/scss/components/_navigation-title.scss +10 -0
  294. package/scss/components/_picker-view.scss +329 -0
  295. package/scss/components/_plain-button.scss +19 -0
  296. package/scss/components/_progress-view.scss +98 -0
  297. package/scss/components/_scroll-view-proxy.scss +81 -0
  298. package/scss/components/_scroll-view-toolbars.scss +132 -0
  299. package/scss/components/_scroll-view.scss +134 -0
  300. package/scss/components/_search-view.scss +23 -0
  301. package/scss/components/_section-view.scss +120 -0
  302. package/scss/components/_sheet-view.scss +103 -0
  303. package/scss/components/_sidebar-toggle.scss +121 -0
  304. package/scss/components/_sidebar-view.scss +53 -0
  305. package/scss/components/_sticky-container.scss +42 -0
  306. package/scss/components/_tab-bar.scss +268 -0
  307. package/scss/components/_tab-item.scss +25 -0
  308. package/scss/components/_tab-view.scss +312 -0
  309. package/scss/components/_table-column.scss +54 -0
  310. package/scss/components/_table-row.scss +240 -0
  311. package/scss/components/_table-view.scss +232 -0
  312. package/scss/components/_text-field.scss +57 -0
  313. package/scss/components/_text-view.scss +57 -0
  314. package/scss/components/_toggle-view.scss +161 -0
  315. package/scss/components/_tool-bar-item-group.scss +48 -0
  316. package/scss/components/_tool-bar-item.scss +97 -0
  317. package/scss/components/_tool-bar.scss +153 -0
  318. package/scss/components/_v-divider.scss +13 -0
  319. package/scss/components/_v-flex-stack.scss +29 -0
  320. package/scss/components/_v-keyboard.scss +14 -0
  321. package/scss/components/_v-stack.scss +24 -0
  322. package/scss/final/_touch-glass.scss +98 -0
  323. package/scss/index.scss +18 -1
  324. package/scss/mixins/_button.scss +44 -0
  325. package/scss/mixins/_color.scss +16 -0
  326. package/scss/mixins/_dialog.scss +89 -0
  327. package/scss/mixins/_index.scss +473 -0
  328. package/scss/placeholders/_buttons.scss +118 -0
  329. package/scss/placeholders/_lists.scss +622 -0
  330. package/scss/transitions/_alert-dialog.scss +18 -0
  331. package/scss/transitions/_bwd.navbar.scss +19 -0
  332. package/scss/transitions/_bwd.scss +39 -0
  333. package/scss/transitions/_confirmation-dialog.scss +27 -0
  334. package/scss/transitions/_disclosure-group.scss +35 -0
  335. package/scss/transitions/_fine-tooltip.scss +21 -0
  336. package/scss/transitions/_fwd.navbar.scss +41 -0
  337. package/scss/transitions/_fwd.scss +24 -0
  338. package/scss/transitions/_glass-button.scss +12 -0
  339. package/scss/transitions/_glass-prominent-button.scss +12 -0
  340. package/scss/transitions/_index.scss +74 -0
  341. package/scss/transitions/_menu-view.scss +28 -0
  342. package/scss/transitions/_navigation-split-view.scss +23 -0
  343. package/scss/transitions/_progress-view.scss +23 -0
  344. package/scss/transitions/_sheet-view.scss +30 -0
  345. package/scss/transitions/_sidebar-view.scss +36 -0
  346. package/scss/transitions/_tab-bar.scss +20 -0
  347. package/scss/utils/_frame.scss +103 -0
  348. package/scss/utils/_index.scss +54 -0
  349. package/scss/utils/_scroll-view.scss +14 -0
  350. package/scss/utils/_spacing.scss +25 -0
  351. package/scss/utils/_stacks.scss +112 -0
  352. package/web-components.css-data/en.json +28 -0
  353. package/web-components.html-data/en.json +2604 -0
  354. package/generated/internal/snapshot.d.ts +0 -5
  355. package/generated/internal/snapshot.js +0 -23
@@ -0,0 +1,371 @@
1
+ var _a;
2
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
3
+ import { FormAssociatedBase, getInternals } from '../internal/class/form-associated-base';
4
+ import { MutationObserverSet } from '../internal/class/mutation-observer-set';
5
+ import { $, devFlags, kebabCase, onoff, touchGlass } from '../internal/utils';
6
+ import { queryMorph } from '../morphdom';
7
+ import { html } from '../tpl';
8
+ const toggleStyles = ['switch', 'button'];
9
+ /**
10
+ * @summary A control that switches between on and off states.
11
+ *
12
+ * @example <toggle-view label="Custom Label"></toggle-view> — Creates a toggle that displays a custom label
13
+ *
14
+ * @fires toggle:change — User toggled the control
15
+ *
16
+ * @slot label
17
+ * @slot {HTMLOptionElement[]} validity-options
18
+ */
19
+ export class ToggleView extends FormAssociatedBase {
20
+ static get observedAttributes() {
21
+ return [
22
+ 'label',
23
+ 'name',
24
+ 'value',
25
+ /**
26
+ * @type {boolean}
27
+ */
28
+ 'is-on',
29
+ /**
30
+ * @type {boolean}
31
+ */
32
+ 'required',
33
+ /**
34
+ * @type {boolean}
35
+ */
36
+ 'disabled',
37
+ ];
38
+ }
39
+ static #template;
40
+ static get template() {
41
+ return (this.#template ??= $(html `<label part="root toggle-stack">
42
+ <div part="root toggle-label-stack">
43
+ <slot name="label"></slot>
44
+ </div>
45
+ <div part="root toggle-input-stack">
46
+ <div part="root toggle-track" tabindex="0"></div>
47
+ </div>
48
+ <slot name="validity-options" hidden></slot>
49
+ </label>`));
50
+ }
51
+ #renderValidityMsgs = (entries) => {
52
+ if (devFlags.debug)
53
+ console.debug(`${_a.name} ⚡️ mutation`);
54
+ this.setValidity(this.validity, this.validationMessage);
55
+ };
56
+ #shadowRoot;
57
+ #customValidity = '';
58
+ #slots = new Map();
59
+ #validityObservers = new MutationObserverSet(this.#renderValidityMsgs);
60
+ #track;
61
+ #value = 'on';
62
+ #isOn = false;
63
+ #didDrag = false;
64
+ #trackWidth = 0;
65
+ #dotSize = 0;
66
+ get #trackMinX() {
67
+ return 0;
68
+ }
69
+ get #trackMaxX() {
70
+ return this.#trackWidth - this.#dotSize;
71
+ }
72
+ #handleMeasure = ([{ target, borderBoxSize }]) => {
73
+ if (devFlags.debug)
74
+ console.debug(`${_a.name} ⚡️ measure`);
75
+ if (!(target instanceof HTMLElement))
76
+ return;
77
+ this.#trackWidth = borderBoxSize.at(0)?.inlineSize ?? 0;
78
+ this.#dotSize = borderBoxSize.at(0)?.blockSize ?? 0;
79
+ };
80
+ #resizeObserver = new ResizeObserver(this.#handleMeasure);
81
+ #dragOffsetX = 0;
82
+ get #isDragging() {
83
+ return '0ms' === this.#track?.style.getPropertyValue('--toggle--dot-transition-duration');
84
+ }
85
+ get #internals() {
86
+ return getInternals(this);
87
+ }
88
+ constructor() {
89
+ super();
90
+ this.#shadowRoot = this.attachShadow({ mode: 'closed' });
91
+ this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
92
+ for (const slot of this.#shadowRoot.querySelectorAll('slot'))
93
+ this.#slots?.set(slot.name, slot);
94
+ CleanupRegistry.register(this, () => {
95
+ this.#slots = new Map();
96
+ });
97
+ CleanupRegistry.unregister(this, 'validities');
98
+ CleanupRegistry.register(this, onoff('slotchange', this.#handleValiditiesSlotchange, this.#slots?.get('validity-options')).on(), 'validities');
99
+ this.#track = this.#shadowRoot.querySelector('[part*=toggle-track]') ?? undefined;
100
+ CleanupRegistry.register(this, onoff([{ types: 'focusin', listener: this.#handleFocusin }], this).on());
101
+ CleanupRegistry.register(this, onoff([
102
+ { types: 'keydown', listener: this.#handleTrackKeydown },
103
+ { types: 'click', listener: this.#handleTrackClick },
104
+ { types: 'pointerdown', listener: this.#handleTrackPointerdown },
105
+ { types: 'pointerup', listener: this.#handleTrackPointerup },
106
+ { types: 'pointercancel', listener: this.#handleTrackPointercancel },
107
+ { types: 'pointermove', listener: this.#handleTrackPointermove },
108
+ { types: 'lostpointercapture', listener: this.#handleTrackPointercancel },
109
+ ], this.#track).on());
110
+ CleanupRegistry.register(this, onoff([{ types: 'blur', listener: this.#handleWindowBlur }], self).on());
111
+ }
112
+ attributeChangedCallback(name, oldValue, newValue) {
113
+ if (devFlags.debug)
114
+ console.debug(`${_a.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
115
+ switch (name) {
116
+ case 'value':
117
+ this.value = String(newValue); // this.#input?.setAttribute('checked', newValue ?? '')
118
+ this.#sendValueToForm(false);
119
+ break;
120
+ case 'is-on':
121
+ this.isOn = newValue !== null; // this.#input?.setAttribute('checked', newValue ?? '')
122
+ this.#sendValueToForm(false);
123
+ break;
124
+ case 'required':
125
+ // this.#input?.setAttribute(name, newValue ?? '')
126
+ this.#sendValueToForm(false);
127
+ break;
128
+ case 'name':
129
+ this.#sendValueToForm(false);
130
+ break;
131
+ case 'label':
132
+ queryMorph('[slot=label]', html `<label-view slot="label">${newValue ? html `<span>${newValue}</span>` : null}</label-view>`, this);
133
+ break;
134
+ case 'disabled':
135
+ for (const el of this.#shadowRoot.querySelectorAll('input'))
136
+ el.toggleAttribute('disabled', !newValue);
137
+ break;
138
+ }
139
+ }
140
+ disconnectedCallback() {
141
+ super.disconnectedCallback();
142
+ if (this.#track)
143
+ this.#resizeObserver.unobserve(this.#track);
144
+ this.#validityObservers.unobserveAll();
145
+ }
146
+ connectedCallback() {
147
+ super.connectedCallback();
148
+ if (this.hasAttribute('is-on'))
149
+ this.isOn = this.hasAttribute('is-on');
150
+ this.#sendValueToForm(false);
151
+ if (this.#track)
152
+ this.#resizeObserver.observe(this.#track);
153
+ CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t, ({ clientX, clientY }) => this.#measurePointerIsOverDot(clientX, clientY) ?? false), this).on());
154
+ }
155
+ get toggleStyle() {
156
+ return toggleStyles.includes(this.getAttribute('toggle-style') ?? '') ? this.getAttribute('toggle-style') : 'switch';
157
+ }
158
+ get isOn() {
159
+ return this.#isOn;
160
+ }
161
+ set isOn(v) {
162
+ this.#isOn = Boolean(v);
163
+ this.#value = this.#isOn ? (this.getAttribute('value') ?? 'on') : null;
164
+ this.ariaChecked = `${this.#isOn}`;
165
+ }
166
+ #handleValiditiesSlotchange = ({ type, target: slot }) => {
167
+ if (devFlags.debug)
168
+ console.debug(`${_a.name} ⚡️ ${type}`);
169
+ if (!(slot instanceof HTMLSlotElement))
170
+ return;
171
+ const assigned = slot.assignedElements();
172
+ this.#validityObservers.syncObservations(assigned, ['value', 'label']);
173
+ this.#renderValidityMsgs([]);
174
+ };
175
+ #handleFocusin = ({ type, target }) => {
176
+ if (devFlags.debug)
177
+ console.debug(`${_a.name} ⚡️ ${type}`);
178
+ if (target === this)
179
+ this.#track?.focus();
180
+ };
181
+ #handleTrackClick = ({ type }) => {
182
+ if (devFlags.debug)
183
+ console.debug(`${_a.name} ⚡️ ${type}`);
184
+ if (this.#didDrag)
185
+ return (this.#didDrag = false);
186
+ this.#applyIsOnWithFlip(!this.isOn);
187
+ this.#sendValueToForm(true);
188
+ };
189
+ #measurePointerIsOverDot = (clientX, clientY) => {
190
+ if (!this.#track)
191
+ return;
192
+ const { left, top, height } = this.#track.getBoundingClientRect();
193
+ const dotLeft = left + parseFloat(self.getComputedStyle(this.#track, '::before').left);
194
+ const dotCenterX = dotLeft + this.#dotSize / 2;
195
+ const dotCenterY = top + height / 2;
196
+ return Math.hypot(clientX - dotCenterX, clientY - dotCenterY) <= this.#dotSize / 2;
197
+ };
198
+ get #baseX() {
199
+ return this.isOn ? this.#trackMaxX : this.#trackMinX;
200
+ }
201
+ #handleTrackPointerdown = ({ type, pointerId, clientX, clientY }) => {
202
+ if (devFlags.debug)
203
+ console.debug(`${_a.name} ⚡️ ${type}`);
204
+ if (!this.#track)
205
+ return;
206
+ if (!this.#measurePointerIsOverDot(clientX, clientY))
207
+ return; // ignore taps elsewhere on the track
208
+ this.#didDrag = true; // dot was engaged — settle() will own the outcome, click must be swallowed
209
+ const currentDelta = parseFloat(self.getComputedStyle(this.#track).getPropertyValue('--toggle--dot-translate-x')) || 0, currentAbsoluteX = this.#baseX + currentDelta;
210
+ this.#dragOffsetX = clientX - this.#track.getBoundingClientRect().left - currentAbsoluteX;
211
+ this.#track.style.setProperty('--toggle--dot-transition-duration', '0ms');
212
+ this.#track.setPointerCapture(pointerId);
213
+ };
214
+ #handleTrackPointermove = ({ type, clientX }) => {
215
+ if (devFlags.debug)
216
+ console.debug(`${_a.name} ⚡️ ${type}`);
217
+ if (!this.#isDragging)
218
+ return;
219
+ this.#updateFromEvent(clientX);
220
+ };
221
+ #handleTrackPointerup = ({ type, pointerId }) => {
222
+ if (devFlags.debug)
223
+ console.debug(`${_a.name} ⚡️ ${type}`);
224
+ if (!this.#isDragging)
225
+ return; // pointerdown never engaged (missed the dot) — plain click, nothing to settle
226
+ this.#track?.style.removeProperty('--toggle--dot-transition-duration');
227
+ this.#track?.releasePointerCapture(pointerId);
228
+ this.#settle();
229
+ };
230
+ #handleTrackPointercancel = ({ type }) => {
231
+ if (devFlags.debug)
232
+ console.debug(`${_a.name} ⚡️ ${type}`);
233
+ if (!this.#isDragging)
234
+ return; // already settled via pointerup, or nothing to settle
235
+ this.#track?.style.removeProperty('--toggle--dot-transition-duration');
236
+ this.#settle();
237
+ };
238
+ #handleWindowBlur = () => {
239
+ if (!this.#isDragging)
240
+ return;
241
+ this.#track?.style.removeProperty('--toggle--dot-transition-duration');
242
+ this.#settle();
243
+ };
244
+ #updateFromEvent = (clientX) => {
245
+ if (!this.#track)
246
+ return;
247
+ const { left } = this.#track.getBoundingClientRect();
248
+ const scaleShiftStart = this.#isOn ? 5 : 0, scaleShiftEnd = this.#isOn ? 0 : 4;
249
+ const absoluteX = Math.min(Math.max(clientX - left - this.#dragOffsetX, this.#trackMinX + scaleShiftStart), this.#trackMaxX - scaleShiftEnd);
250
+ this.#track.style.setProperty('--toggle--dot-translate-x', `${Math.round(absoluteX - this.#baseX)}px`);
251
+ };
252
+ #settle = () => {
253
+ if (!this.#track)
254
+ return;
255
+ const deltaX = parseFloat(self.getComputedStyle(this.#track).getPropertyValue('--toggle--dot-translate-x')) || 0;
256
+ const absoluteX = this.#baseX + deltaX;
257
+ const nextIsOn = absoluteX > this.#trackMaxX / 2;
258
+ if (nextIsOn === this.isOn)
259
+ return this.#track.style.removeProperty('--toggle--dot-translate-x'); // pure transform animation back to rest, inset untouched
260
+ this.#applyIsOnWithFlip(nextIsOn);
261
+ this.#sendValueToForm(true);
262
+ };
263
+ #handleTrackKeydown = (evt) => {
264
+ if (devFlags.debug)
265
+ console.debug(`${_a.name} ⚡️ ${evt?.type}`);
266
+ if (' ' !== evt.key)
267
+ return;
268
+ evt.preventDefault();
269
+ this.#applyIsOnWithFlip(!this.isOn);
270
+ this.#sendValueToForm(true);
271
+ };
272
+ #applyIsOnWithFlip = (nextIsOn) => {
273
+ if (!this.#track || nextIsOn === this.isOn)
274
+ return;
275
+ // capture current visual position under the OLD base, before flipping state
276
+ const deltaX = parseFloat(self.getComputedStyle(this.#track).getPropertyValue('--toggle--dot-translate-x')) || 0, oldAbsoluteX = this.#baseX + deltaX;
277
+ this.isOn = nextIsOn; // changes --toggle--dot-inset-inline-start/-end via aria-checked
278
+ const compensationX = oldAbsoluteX - this.#baseX; // baseX now reflects the NEW state
279
+ // make inset + transform jump together, instantly, so nothing is visibly out of sync
280
+ this.#track.style.setProperty('--toggle--dot-transition-duration', '0ms');
281
+ this.#track.style.setProperty('--toggle--dot-translate-x', `${Math.round(compensationX)}px`);
282
+ void this.#track.offsetWidth; // force reflow so the instant jump is committed before re-enabling transitions
283
+ this.#track.style.removeProperty('--toggle--dot-transition-duration');
284
+ self.requestAnimationFrame(() => {
285
+ this.#track?.style.removeProperty('--toggle--dot-translate-x'); // only transform animates from here — single source of motion
286
+ });
287
+ };
288
+ #sendValueToForm = (dispatchEvent = true) => {
289
+ // input.value has already been updated/synced !!
290
+ if (this.matches(':disabled'))
291
+ return this.setValidity({});
292
+ if (this.hasAttribute('required') && !this.isOn) {
293
+ this.setValidity({ valueMissing: true });
294
+ }
295
+ else
296
+ this.setValidity({});
297
+ const entries = new FormData();
298
+ if (this.value)
299
+ entries.append(this.name, this.value);
300
+ this.#internals.setFormValue(entries);
301
+ if (dispatchEvent)
302
+ this.dispatchEvent(new CustomEvent('toggle:change', { detail: { value: this.value, isOn: this.isOn }, bubbles: true, composed: true }));
303
+ };
304
+ /**
305
+ * Form participation property
306
+ */
307
+ get name() {
308
+ return this.getAttribute('name') ?? this.getAttribute('label') ?? this.querySelector(':scope>[slot=label]')?.textContent ?? '';
309
+ }
310
+ get value() {
311
+ return this.#value;
312
+ }
313
+ set value(v) {
314
+ this.#value = this.isOn ? String(v) : null;
315
+ }
316
+ setValidity = (flags, message, anchor) => {
317
+ // let msg
318
+ // if (message)
319
+ for (const k in flags) {
320
+ const key = k; // ✅ type-safe cast
321
+ if (true !== flags[key])
322
+ continue;
323
+ for (const el of this.#slots?.get('validity-options')?.assignedElements({ flatten: true }) ?? []) {
324
+ if (!el.matches('option'))
325
+ continue;
326
+ const { label, value } = el;
327
+ if (`${kebabCase(key)}` === value) {
328
+ message = label;
329
+ break;
330
+ }
331
+ else if (`${kebabCase(key)}:${message}` === value) {
332
+ message = label;
333
+ break;
334
+ }
335
+ }
336
+ }
337
+ if (!message)
338
+ for (const k in flags) {
339
+ const key = k; // ✅ type-safe cast
340
+ if (true !== flags[key])
341
+ continue;
342
+ message = kebabCase(key);
343
+ break;
344
+ }
345
+ if (devFlags.debug)
346
+ console.debug(`${_a.name} ⚡️ validity-change`);
347
+ return this.#internals.setValidity(flags, this.#customValidity || message, anchor ?? this.#track);
348
+ };
349
+ setCustomValidity = (message) => {
350
+ this.#customValidity = message;
351
+ if (this.#customValidity)
352
+ this.#internals.setValidity({ ...this.#internals.validity, customError: true }, message);
353
+ else
354
+ this.#sendValueToForm(false);
355
+ };
356
+ formStateRestoreCallback(state, reason) {
357
+ this.value = state;
358
+ }
359
+ formAssociatedCallback(form) {
360
+ this.#sendValueToForm(false);
361
+ }
362
+ formDisabledCallback(disabled) {
363
+ for (const el of this.#shadowRoot.querySelectorAll('input'))
364
+ el.toggleAttribute('disabled', !disabled);
365
+ }
366
+ formResetCallback() {
367
+ this.value = '';
368
+ this.#sendValueToForm(false);
369
+ }
370
+ }
371
+ _a = ToggleView;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @summary A container view that groups items together in the toolbar or navigation bar.
3
+ */
4
+ export declare class ToolBarItemGroup extends HTMLElement {
5
+ constructor();
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ }
9
+ declare global {
10
+ interface HTMLElementTagNameMap {
11
+ 'tool-bar-item-group': ToolBarItemGroup;
12
+ }
13
+ }
@@ -0,0 +1,31 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var ToolBarItemGroup_1;
8
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
9
+ import { adaptiveSlot } from '../internal/decorators';
10
+ import { devFlags } from '../internal/utils';
11
+ /**
12
+ * @summary A container view that groups items together in the toolbar or navigation bar.
13
+ */
14
+ let ToolBarItemGroup = ToolBarItemGroup_1 = class ToolBarItemGroup extends HTMLElement {
15
+ constructor() {
16
+ super();
17
+ }
18
+ connectedCallback() {
19
+ if (devFlags.debug)
20
+ console.debug(`${ToolBarItemGroup_1.name} ⚡️ connect`);
21
+ }
22
+ disconnectedCallback() {
23
+ if (devFlags.debug)
24
+ console.debug(`${ToolBarItemGroup_1.name} ⚡️ disconnect`);
25
+ CleanupRegistry.unregister(this);
26
+ }
27
+ };
28
+ ToolBarItemGroup = ToolBarItemGroup_1 = __decorate([
29
+ adaptiveSlot()
30
+ ], ToolBarItemGroup);
31
+ export { ToolBarItemGroup };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @summary A view placed in the toolbar or navigation bar.
3
+ */
4
+ export declare class ToolBarItem extends HTMLElement {
5
+ #private;
6
+ static get observedAttributes(): string[];
7
+ constructor();
8
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
9
+ disconnectedCallback(): void;
10
+ connectedCallback(): void;
11
+ }
12
+ declare global {
13
+ interface HTMLElementTagNameMap {
14
+ 'tool-bar-item': ToolBarItem;
15
+ }
16
+ }
@@ -0,0 +1,69 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var ToolBarItem_1;
8
+ import { CleanupRegistry } from '../internal/class/cleanup-registry';
9
+ import { adaptiveSlot } from '../internal/decorators';
10
+ import { devFlags, ensurePlaceholder, onoff, touchGlass } from '../internal/utils';
11
+ import { Snapshot } from '../snapshot';
12
+ /**
13
+ * @summary A view placed in the toolbar or navigation bar.
14
+ */
15
+ let ToolBarItem = ToolBarItem_1 = class ToolBarItem extends HTMLElement {
16
+ static get observedAttributes() {
17
+ return ['slot', 'data-previous-slot', 'title-key'];
18
+ }
19
+ #mutationObserver;
20
+ constructor() {
21
+ super();
22
+ }
23
+ attributeChangedCallback(name, oldValue, newValue) {
24
+ if (devFlags.debug)
25
+ console.debug(`${ToolBarItem_1.name} ⚡️ attr-change [${name}] ("${oldValue}" → "${newValue}")`);
26
+ switch (name) {
27
+ case 'slot':
28
+ case 'data-previous-slot':
29
+ case 'title-key': {
30
+ this.#mutationObserver?.disconnect();
31
+ const role = this.getAttribute('data-previous-slot') ?? this.getAttribute('slot') ?? '', tKey = this.getAttribute('title-key');
32
+ if (['confirmation-action', 'cancellation-action'].includes(role))
33
+ Snapshot.waitReady.then(() => {
34
+ ensurePlaceholder(this.querySelector(':scope>button:not(:has(> :not([slot])))'), role, tKey, Snapshot.config);
35
+ this.#mutationObserver = new MutationObserver((mutations) => {
36
+ for (const { target } of mutations)
37
+ if (target instanceof HTMLElement)
38
+ ensurePlaceholder(this.querySelector(':scope>button:not(:has(> :not([slot])))'), role, tKey, Snapshot.config);
39
+ });
40
+ this.#mutationObserver.observe(this, {
41
+ childList: true,
42
+ });
43
+ });
44
+ break;
45
+ }
46
+ }
47
+ }
48
+ disconnectedCallback() {
49
+ if (devFlags.debug)
50
+ console.debug(`${ToolBarItem_1.name} ⚡️ disconnect`);
51
+ this.#mutationObserver?.disconnect();
52
+ CleanupRegistry.unregister(this);
53
+ }
54
+ connectedCallback() {
55
+ if (devFlags.debug)
56
+ console.debug(`${ToolBarItem_1.name} ⚡️ connect`);
57
+ CleanupRegistry.register(this, onoff(touchGlass(this, (t) => t.closest('tool-bar-item-group') ?? t, ({ target }) => {
58
+ if (!(target instanceof HTMLElement))
59
+ return true;
60
+ if (target.closest('menu-view[open]'))
61
+ return false;
62
+ return true;
63
+ }), this).on());
64
+ }
65
+ };
66
+ ToolBarItem = ToolBarItem_1 = __decorate([
67
+ adaptiveSlot((el) => !el.closest('tool-bar-item-group'))
68
+ ], ToolBarItem);
69
+ export { ToolBarItem };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @summary A list of items placed into the toolbar or navigation bar around your content.
3
+ *
4
+ * @slot cancellation-action — The item represents a cancellation action for a modal interface. Places the item in the leading edge of the top bar and on the trailing edge of the bottom bar when fine modal
5
+ * @slot primary-action — The item represents a primary action. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
6
+ * @slot confirmation-action — The item represents a confirmation action for a modal interface. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
7
+ * @slot destructive-action — The item represents a destructive action for a modal interface. Places the item in the leading edge of the top bar and on the leading edge of the bottom bar when fine modal
8
+ * @slot top-bar-leading — Places the item in the leading edge of the top bar
9
+ * @slot top-bar-principal — Places the item in the middle of the top bar
10
+ * @slot top-bar-trailing — Places the item in the trailing edge of the top bar
11
+ * @slot bottom-bar-leading — Places the item in the leading edge of the bottom bar
12
+ * @slot bottom-bar-principal — Places the item in the middle of the bottom bar
13
+ * @slot bottom-bar-trailing — Places the item in the trailing edge of the bottom bar
14
+ */
15
+ export declare class ToolBar extends HTMLElement {
16
+ #private;
17
+ static get template(): DocumentFragment;
18
+ constructor();
19
+ connectedCallback(): void;
20
+ disconnectedCallback(): void;
21
+ }
22
+ declare global {
23
+ interface HTMLElementTagNameMap {
24
+ 'tool-bar': ToolBar;
25
+ }
26
+ }
@@ -0,0 +1,95 @@
1
+ var _a;
2
+ import { ResizeObserverSingleton } from '../internal/class/resize-observer-singleton';
3
+ import { $, devFlags } from '../internal/utils';
4
+ import { html } from '../tpl';
5
+ const observers = new ResizeObserverSingleton();
6
+ /**
7
+ * @summary A list of items placed into the toolbar or navigation bar around your content.
8
+ *
9
+ * @slot cancellation-action — The item represents a cancellation action for a modal interface. Places the item in the leading edge of the top bar and on the trailing edge of the bottom bar when fine modal
10
+ * @slot primary-action — The item represents a primary action. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
11
+ * @slot confirmation-action — The item represents a confirmation action for a modal interface. Places the item in the trailing edge of the top bar and on the trailing edge of the bottom bar when fine modal
12
+ * @slot destructive-action — The item represents a destructive action for a modal interface. Places the item in the leading edge of the top bar and on the leading edge of the bottom bar when fine modal
13
+ * @slot top-bar-leading — Places the item in the leading edge of the top bar
14
+ * @slot top-bar-principal — Places the item in the middle of the top bar
15
+ * @slot top-bar-trailing — Places the item in the trailing edge of the top bar
16
+ * @slot bottom-bar-leading — Places the item in the leading edge of the bottom bar
17
+ * @slot bottom-bar-principal — Places the item in the middle of the bottom bar
18
+ * @slot bottom-bar-trailing — Places the item in the trailing edge of the bottom bar
19
+ */
20
+ export class ToolBar extends HTMLElement {
21
+ static #template;
22
+ static get template() {
23
+ // <!--exportparts="toolbar-leading-stack,toolbar-principal-stack,toolbar-trailing-stack"-->
24
+ return (this.#template ??= $(html `<div part="root top-bar">
25
+ <div part="root toolbar-leading-stack">
26
+ <slot name="cancellation-action"></slot>
27
+ <slot name="destructive-action"></slot>
28
+ <slot name="top-bar-leading"></slot>
29
+ </div>
30
+ <div part="root toolbar-principal-stack">
31
+ <slot name="top-bar-principal"></slot>
32
+ </div>
33
+ <div part="root toolbar-trailing-stack">
34
+ <slot name="top-bar-trailing"></slot>
35
+ <slot name="primary-action"></slot>
36
+ <slot name="confirmation-action"></slot>
37
+ </div>
38
+ </div>
39
+ <div part="root bottom-bar">
40
+ <div part="root toolbar-leading-stack">
41
+ <slot name="bottom-bar-leading"></slot>
42
+ </div>
43
+ <div part="root toolbar-principal-stack">
44
+ <slot name="bottom-bar-principal"></slot>
45
+ </div>
46
+ <div part="root toolbar-trailing-stack">
47
+ <slot name="bottom-bar-trailing"></slot>
48
+ </div>
49
+ </div>`));
50
+ }
51
+ #shadowRoot;
52
+ get #scrollView() {
53
+ return this.parentElement?.querySelector(':scope>scroll-view') ?? undefined; //this.previousElementSibling ?? undefined
54
+ }
55
+ constructor() {
56
+ super();
57
+ this.#shadowRoot = this.attachShadow({ mode: 'closed' });
58
+ this.#shadowRoot.appendChild(document.importNode(this.constructor.template, true));
59
+ }
60
+ connectedCallback() {
61
+ if (devFlags.debug)
62
+ console.debug(`${_a.name} ⚡️ connect`);
63
+ // NOTE: wait for config
64
+ // Snapshot.waitReady.then(() => {
65
+ for (const el of this.#shadowRoot.querySelectorAll(`[part*="toolbar-leading-stack"],[part*="toolbar-trailing-stack"]`))
66
+ observers.observe(el, this.#measureStacks.bind(this));
67
+ // })
68
+ }
69
+ disconnectedCallback() {
70
+ if (devFlags.debug)
71
+ console.debug(`${_a.name} ⚡️ disconnect`);
72
+ observers.unobserve(this);
73
+ }
74
+ #measureStacks(entry) {
75
+ if (devFlags.debug)
76
+ console.debug(`${_a.name} ⚡️ measure`);
77
+ if (this.closest('[hidden]'))
78
+ return;
79
+ const leading = 'toolbar-leading-stack', trailing = 'toolbar-trailing-stack';
80
+ const parentMap = {
81
+ 'top-bar': 'navbar',
82
+ 'bottom-bar': 'toolbar', //'bottombar',
83
+ };
84
+ const { contentRect: { width }, target, } = entry;
85
+ const parentPart = target.parentElement?.part.contains('top-bar') ? 'top-bar' : target.parentElement?.part.contains('bottom-bar') ? 'bottom-bar' : null;
86
+ if (!parentPart)
87
+ return;
88
+ const side = target.part.contains(leading) ? 'inline-start' : target.part.contains(trailing) ? 'inline-end' : null;
89
+ if (!side)
90
+ return;
91
+ const prop = `--${parentMap[parentPart]}-padding-${side}`;
92
+ this.#scrollView?.style?.setProperty(prop, `${Math.round(width)}px`); // $.prop(prop, `${Math.round(width)}px`, this.#scrollView) //
93
+ }
94
+ }
95
+ _a = ToolBar;
@@ -1,2 +1,20 @@
1
+ /**
2
+ * BUG: Safari on IOS reports inaccurate innerHeight (which is what we really want) on orientationchange.
3
+ * So we live with a pescy body-scrollbar that shows up on resize on desktops.
4
+ *
5
+ * @summary Required component, used to handle the virtual keyboard on touch devices.
6
+ *
7
+ * @attr {Inter} system-font — Prefers the "Inter" font family, if loaded.
8
+ */
1
9
  export declare class VKeyboard extends HTMLElement {
10
+ #private;
11
+ constructor();
12
+ disconnectedCallback(): void;
13
+ connectedCallback(): void;
14
+ set shouldKeyboardBeOpen(fn: () => boolean);
15
+ }
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ 'v-keyboard': VKeyboard;
19
+ }
2
20
  }