@gjsify/adwaita-web 0.64.1 → 0.64.2-next.254

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 (335) hide show
  1. package/README.md +22 -88
  2. package/dist/adwaita-web.css +91 -12
  3. package/dist/adwaita-web.css.map +1 -1
  4. package/lib/types/accessible.d.ts +8 -0
  5. package/lib/types/application.d.ts +1 -1
  6. package/lib/types/child-slot.spec.d.ts +1 -0
  7. package/lib/types/compute-expand.d.ts +5 -0
  8. package/lib/types/compute-expand.spec.d.ts +1 -0
  9. package/lib/types/container-fill.spec.d.ts +1 -0
  10. package/lib/types/elements/adw-about-dialog.d.ts +28 -1
  11. package/lib/types/elements/adw-action-row.d.ts +2 -1
  12. package/lib/types/elements/adw-alert-dialog.d.ts +80 -19
  13. package/lib/types/elements/adw-avatar.d.ts +2 -1
  14. package/lib/types/elements/adw-banner.d.ts +2 -1
  15. package/lib/types/elements/adw-bin.d.ts +2 -1
  16. package/lib/types/elements/adw-bottom-sheet.d.ts +5 -4
  17. package/lib/types/elements/adw-breakpoint-bin.d.ts +2 -1
  18. package/lib/types/elements/adw-button-content.d.ts +2 -1
  19. package/lib/types/elements/adw-button-row.d.ts +2 -1
  20. package/lib/types/elements/adw-card.d.ts +2 -1
  21. package/lib/types/elements/adw-carousel.d.ts +20 -3
  22. package/lib/types/elements/adw-clamp-scrollable.d.ts +2 -1
  23. package/lib/types/elements/adw-clamp.d.ts +2 -1
  24. package/lib/types/elements/adw-combo-row.d.ts +6 -1
  25. package/lib/types/elements/adw-data-grid.d.ts +2 -1
  26. package/lib/types/elements/adw-dialog.d.ts +2 -1
  27. package/lib/types/elements/adw-entry-row.d.ts +2 -1
  28. package/lib/types/elements/adw-expander-row.d.ts +2 -1
  29. package/lib/types/elements/adw-header-bar.d.ts +2 -1
  30. package/lib/types/elements/adw-inline-view-switcher.d.ts +3 -2
  31. package/lib/types/elements/adw-layout-slot.d.ts +2 -1
  32. package/lib/types/elements/adw-multi-layout-view.d.ts +2 -1
  33. package/lib/types/elements/adw-navigation-split-view.d.ts +2 -1
  34. package/lib/types/elements/adw-navigation-view.d.ts +3 -2
  35. package/lib/types/elements/adw-overlay-split-view.d.ts +2 -1
  36. package/lib/types/elements/adw-preferences-dialog.d.ts +5 -4
  37. package/lib/types/elements/adw-preferences-group.d.ts +2 -1
  38. package/lib/types/elements/adw-preferences-row.d.ts +2 -1
  39. package/lib/types/elements/adw-shortcut-label.d.ts +2 -1
  40. package/lib/types/elements/adw-shortcuts-item.d.ts +2 -1
  41. package/lib/types/elements/adw-shortcuts-section.d.ts +2 -1
  42. package/lib/types/elements/adw-sidebar.d.ts +4 -3
  43. package/lib/types/elements/adw-spin-row.d.ts +2 -1
  44. package/lib/types/elements/adw-spinner.d.ts +2 -1
  45. package/lib/types/elements/adw-split-button.d.ts +2 -1
  46. package/lib/types/elements/adw-status-page.d.ts +2 -1
  47. package/lib/types/elements/adw-switch-row.d.ts +4 -1
  48. package/lib/types/elements/adw-tab-bar.d.ts +2 -1
  49. package/lib/types/elements/adw-tab-button.d.ts +2 -1
  50. package/lib/types/elements/adw-tab-overview.d.ts +2 -1
  51. package/lib/types/elements/adw-tab-view.d.ts +3 -2
  52. package/lib/types/elements/adw-toast-overlay.d.ts +10 -30
  53. package/lib/types/elements/adw-toggle-group.d.ts +3 -2
  54. package/lib/types/elements/adw-toolbar-view.d.ts +2 -1
  55. package/lib/types/elements/adw-view-stack.d.ts +3 -1
  56. package/lib/types/elements/adw-view-switcher-bar.d.ts +2 -1
  57. package/lib/types/elements/adw-view-switcher-sidebar.d.ts +2 -1
  58. package/lib/types/elements/adw-view-switcher.d.ts +3 -2
  59. package/lib/types/elements/adw-window-features.d.ts +8 -0
  60. package/lib/types/elements/adw-window-title.d.ts +2 -1
  61. package/lib/types/elements/adw-wrap-box.d.ts +2 -1
  62. package/lib/types/elements/checks.d.ts +16 -1
  63. package/lib/types/elements/gtk-action-bar.d.ts +2 -1
  64. package/lib/types/elements/gtk-application-window.d.ts +1 -4
  65. package/lib/types/elements/gtk-aspect-frame.d.ts +2 -1
  66. package/lib/types/elements/gtk-box.d.ts +5 -1
  67. package/lib/types/elements/gtk-button.d.ts +5 -7
  68. package/lib/types/elements/gtk-calendar.d.ts +2 -1
  69. package/lib/types/elements/gtk-center-box.d.ts +2 -1
  70. package/lib/types/elements/gtk-color-dialog-button.d.ts +2 -1
  71. package/lib/types/elements/gtk-drag-icon.d.ts +2 -1
  72. package/lib/types/elements/gtk-drawing-area.d.ts +2 -1
  73. package/lib/types/elements/gtk-drop-down.d.ts +2 -1
  74. package/lib/types/elements/gtk-editable-label.d.ts +2 -1
  75. package/lib/types/elements/gtk-emoji-chooser.d.ts +2 -0
  76. package/lib/types/elements/gtk-entry.d.ts +2 -1
  77. package/lib/types/elements/gtk-expander.d.ts +2 -1
  78. package/lib/types/elements/gtk-fixed.d.ts +2 -1
  79. package/lib/types/elements/gtk-flow-box-child.d.ts +2 -1
  80. package/lib/types/elements/gtk-flow-box.d.ts +2 -1
  81. package/lib/types/elements/gtk-font-dialog-button.d.ts +2 -1
  82. package/lib/types/elements/gtk-frame.d.ts +2 -1
  83. package/lib/types/elements/gtk-gl-area.d.ts +2 -1
  84. package/lib/types/elements/gtk-graphics-offload.d.ts +2 -1
  85. package/lib/types/elements/gtk-grid.d.ts +2 -1
  86. package/lib/types/elements/gtk-header-bar.d.ts +2 -1
  87. package/lib/types/elements/gtk-image.d.ts +5 -6
  88. package/lib/types/elements/gtk-inscription.d.ts +2 -1
  89. package/lib/types/elements/gtk-label.d.ts +10 -3
  90. package/lib/types/elements/gtk-level-bar.d.ts +2 -1
  91. package/lib/types/elements/gtk-list-box-row.d.ts +2 -1
  92. package/lib/types/elements/gtk-list-box.d.ts +2 -1
  93. package/lib/types/elements/gtk-list-view.d.ts +2 -1
  94. package/lib/types/elements/gtk-media-controls.d.ts +2 -1
  95. package/lib/types/elements/gtk-menu-button.d.ts +2 -1
  96. package/lib/types/elements/gtk-notebook.d.ts +2 -1
  97. package/lib/types/elements/gtk-overlay.d.ts +2 -1
  98. package/lib/types/elements/gtk-paned.d.ts +2 -1
  99. package/lib/types/elements/gtk-picture.d.ts +2 -1
  100. package/lib/types/elements/gtk-popover-bin.d.ts +2 -1
  101. package/lib/types/elements/gtk-popover-menu-bar.d.ts +2 -1
  102. package/lib/types/elements/gtk-popover-menu.d.ts +2 -0
  103. package/lib/types/elements/gtk-popover.d.ts +7 -1
  104. package/lib/types/elements/gtk-progress-bar.d.ts +2 -1
  105. package/lib/types/elements/gtk-revealer.d.ts +2 -1
  106. package/lib/types/elements/gtk-scale-button.d.ts +2 -1
  107. package/lib/types/elements/gtk-scale.d.ts +2 -1
  108. package/lib/types/elements/gtk-scrollbar.d.ts +2 -1
  109. package/lib/types/elements/gtk-scrolled-window.d.ts +2 -1
  110. package/lib/types/elements/gtk-search-bar.d.ts +2 -1
  111. package/lib/types/elements/gtk-separator.d.ts +2 -1
  112. package/lib/types/elements/gtk-spin-button.d.ts +2 -1
  113. package/lib/types/elements/gtk-spinner.d.ts +2 -1
  114. package/lib/types/elements/gtk-stack-page.d.ts +29 -0
  115. package/lib/types/elements/gtk-stack-sidebar.d.ts +2 -1
  116. package/lib/types/elements/gtk-stack-switcher.d.ts +2 -1
  117. package/lib/types/elements/gtk-stack.d.ts +13 -1
  118. package/lib/types/elements/gtk-switch.d.ts +2 -1
  119. package/lib/types/elements/gtk-text-view.d.ts +2 -1
  120. package/lib/types/elements/gtk-text.d.ts +2 -1
  121. package/lib/types/elements/gtk-tree-expander.d.ts +2 -1
  122. package/lib/types/elements/gtk-video.d.ts +2 -1
  123. package/lib/types/elements/gtk-viewport.d.ts +2 -1
  124. package/lib/types/elements/gtk-window-controls.d.ts +2 -1
  125. package/lib/types/elements/gtk-window-handle.d.ts +2 -1
  126. package/lib/types/elements/gtk-window.d.ts +18 -2
  127. package/lib/types/gobject-elements.d.ts +15 -0
  128. package/lib/types/gtksource/gtk-source-view.d.ts +2 -1
  129. package/lib/types/{icon-registry.spec.d.ts → icon-masks.spec.d.ts} +1 -1
  130. package/lib/types/icon-theme.d.ts +15 -35
  131. package/lib/types/index.d.ts +3 -4
  132. package/lib/types/learn6502-window.spec.d.ts +1 -0
  133. package/lib/types/namespace/adw.d.ts +1 -1
  134. package/lib/types/namespace/gdk.d.ts +1 -0
  135. package/lib/types/namespace/gio.d.ts +1 -0
  136. package/lib/types/namespace/glib.d.ts +2 -1
  137. package/lib/types/namespace/gtk.d.ts +2 -0
  138. package/lib/types/shared-tree-builder.d.ts +31 -0
  139. package/lib/types/signals.d.ts +5 -1
  140. package/lib/types/source-view/adw-source-view.d.ts +2 -1
  141. package/lib/types/styles.generated.d.ts +1 -1
  142. package/lib/types/widget-element.d.ts +25 -0
  143. package/lib/types/widget-map.spec.d.ts +1 -0
  144. package/lib/types/widget-mapping.d.ts +7 -0
  145. package/lib/types/widget-visible.spec.d.ts +1 -0
  146. package/lib/types/window-maximize.spec.d.ts +1 -0
  147. package/package.json +13 -12
  148. package/scss/_about_dialog.scss +46 -1
  149. package/scss/_bin.scss +6 -3
  150. package/scss/_checks.scss +5 -2
  151. package/scss/_icon.scss +3 -4
  152. package/scss/_labels.scss +2 -2
  153. package/scss/_overlay.scss +11 -1
  154. package/scss/_overlay_split_view.scss +10 -0
  155. package/scss/_reset.scss +1 -1
  156. package/scss/_scrolled_window.scss +15 -0
  157. package/scss/_stack.scss +8 -2
  158. package/scss/_toast.scss +13 -3
  159. package/scss/_widget.scss +5 -1
  160. package/scss/_window.scss +16 -0
  161. package/src/accessible.ts +29 -0
  162. package/src/adw-about-dialog.spec.ts +81 -12
  163. package/src/adw-action-rows.spec.ts +2 -2
  164. package/src/adw-alert-dialog.spec.ts +71 -5
  165. package/src/adw-bin.spec.ts +4 -3
  166. package/src/adw-button-content.spec.ts +1 -1
  167. package/src/adw-carousel.spec.ts +49 -1
  168. package/src/adw-header-bar.spec.ts +18 -0
  169. package/src/adw-toast-overlay.spec.ts +68 -24
  170. package/src/application.spec.ts +44 -0
  171. package/src/application.ts +13 -18
  172. package/src/capabilities.mjs +2 -3
  173. package/src/checks.spec.ts +51 -1
  174. package/src/child-slot.spec.ts +71 -0
  175. package/src/compute-expand.spec.ts +186 -0
  176. package/src/compute-expand.ts +134 -0
  177. package/src/construct-vectors.spec.ts +97 -7
  178. package/src/container-fill.spec.ts +70 -0
  179. package/src/elements/adw-about-dialog.ts +152 -9
  180. package/src/elements/adw-action-row.ts +2 -1
  181. package/src/elements/adw-alert-dialog.ts +177 -46
  182. package/src/elements/adw-application-window.ts +0 -3
  183. package/src/elements/adw-avatar.ts +2 -1
  184. package/src/elements/adw-banner.ts +2 -1
  185. package/src/elements/adw-bin.ts +2 -1
  186. package/src/elements/adw-bottom-sheet.ts +5 -4
  187. package/src/elements/adw-breakpoint-bin.ts +5 -1
  188. package/src/elements/adw-button-content.ts +2 -1
  189. package/src/elements/adw-button-row.ts +2 -1
  190. package/src/elements/adw-card.ts +2 -1
  191. package/src/elements/adw-carousel.ts +62 -3
  192. package/src/elements/adw-clamp-scrollable.ts +2 -1
  193. package/src/elements/adw-clamp.ts +2 -1
  194. package/src/elements/adw-combo-row.ts +15 -1
  195. package/src/elements/adw-data-grid.ts +2 -1
  196. package/src/elements/adw-dialog.ts +5 -2
  197. package/src/elements/adw-entry-row.ts +2 -1
  198. package/src/elements/adw-expander-row.ts +2 -1
  199. package/src/elements/adw-header-bar.ts +6 -1
  200. package/src/elements/adw-inline-view-switcher.ts +3 -2
  201. package/src/elements/adw-layout-slot.ts +2 -1
  202. package/src/elements/adw-multi-layout-view.ts +2 -1
  203. package/src/elements/adw-navigation-split-view.ts +2 -1
  204. package/src/elements/adw-navigation-view.ts +3 -2
  205. package/src/elements/adw-overlay-split-view.ts +2 -1
  206. package/src/elements/adw-preferences-dialog.ts +6 -4
  207. package/src/elements/adw-preferences-group.ts +2 -1
  208. package/src/elements/adw-preferences-row.ts +2 -1
  209. package/src/elements/adw-shortcut-label.ts +2 -1
  210. package/src/elements/adw-shortcuts-item.ts +2 -1
  211. package/src/elements/adw-shortcuts-section.ts +2 -1
  212. package/src/elements/adw-sidebar.ts +4 -3
  213. package/src/elements/adw-spin-row.ts +2 -1
  214. package/src/elements/adw-spinner.ts +2 -1
  215. package/src/elements/adw-split-button.ts +2 -1
  216. package/src/elements/adw-status-page.ts +2 -1
  217. package/src/elements/adw-switch-row.ts +10 -1
  218. package/src/elements/adw-tab-bar.ts +2 -1
  219. package/src/elements/adw-tab-button.ts +2 -1
  220. package/src/elements/adw-tab-overview.ts +2 -1
  221. package/src/elements/adw-tab-view.ts +3 -2
  222. package/src/elements/adw-toast-overlay.ts +37 -70
  223. package/src/elements/adw-toggle-group.ts +3 -2
  224. package/src/elements/adw-toolbar-view.ts +2 -1
  225. package/src/elements/adw-view-stack.ts +39 -1
  226. package/src/elements/adw-view-switcher-bar.ts +2 -1
  227. package/src/elements/adw-view-switcher-sidebar.ts +2 -1
  228. package/src/elements/adw-view-switcher.ts +3 -2
  229. package/src/elements/adw-window-features.ts +14 -2
  230. package/src/elements/adw-window-title.ts +2 -1
  231. package/src/elements/adw-wrap-box.ts +2 -1
  232. package/src/elements/checks.ts +85 -6
  233. package/src/elements/gtk-action-bar.ts +2 -1
  234. package/src/elements/gtk-application-window.ts +3 -8
  235. package/src/elements/gtk-aspect-frame.ts +2 -1
  236. package/src/elements/gtk-box.ts +56 -1
  237. package/src/elements/gtk-button.ts +10 -22
  238. package/src/elements/gtk-calendar.ts +2 -1
  239. package/src/elements/gtk-center-box.ts +2 -1
  240. package/src/elements/gtk-color-dialog-button.ts +2 -1
  241. package/src/elements/gtk-drag-icon.ts +6 -1
  242. package/src/elements/gtk-drawing-area.ts +2 -1
  243. package/src/elements/gtk-drop-down.ts +2 -1
  244. package/src/elements/gtk-editable-label.ts +2 -1
  245. package/src/elements/gtk-emoji-chooser.ts +5 -0
  246. package/src/elements/gtk-entry.ts +2 -1
  247. package/src/elements/gtk-expander.ts +2 -1
  248. package/src/elements/gtk-fixed.ts +2 -1
  249. package/src/elements/gtk-flow-box-child.ts +5 -2
  250. package/src/elements/gtk-flow-box.ts +2 -1
  251. package/src/elements/gtk-font-dialog-button.ts +2 -1
  252. package/src/elements/gtk-frame.ts +2 -1
  253. package/src/elements/gtk-gl-area.ts +2 -1
  254. package/src/elements/gtk-graphics-offload.ts +5 -2
  255. package/src/elements/gtk-grid.ts +2 -1
  256. package/src/elements/gtk-header-bar.ts +2 -1
  257. package/src/elements/gtk-image.ts +14 -15
  258. package/src/elements/gtk-inscription.ts +2 -1
  259. package/src/elements/gtk-label.ts +12 -5
  260. package/src/elements/gtk-level-bar.ts +2 -1
  261. package/src/elements/gtk-list-box-row.ts +5 -2
  262. package/src/elements/gtk-list-box.ts +2 -1
  263. package/src/elements/gtk-list-view.ts +2 -1
  264. package/src/elements/gtk-media-controls.ts +2 -1
  265. package/src/elements/gtk-menu-button.ts +2 -1
  266. package/src/elements/gtk-notebook.ts +2 -1
  267. package/src/elements/gtk-overlay.ts +7 -5
  268. package/src/elements/gtk-paned.ts +9 -2
  269. package/src/elements/gtk-picture.ts +2 -1
  270. package/src/elements/gtk-popover-bin.ts +5 -1
  271. package/src/elements/gtk-popover-menu-bar.ts +2 -1
  272. package/src/elements/gtk-popover-menu.ts +5 -0
  273. package/src/elements/gtk-popover.ts +14 -1
  274. package/src/elements/gtk-progress-bar.ts +2 -1
  275. package/src/elements/gtk-revealer.ts +2 -1
  276. package/src/elements/gtk-scale-button.ts +2 -1
  277. package/src/elements/gtk-scale.ts +2 -1
  278. package/src/elements/gtk-scrollbar.ts +2 -1
  279. package/src/elements/gtk-scrolled-window.ts +8 -5
  280. package/src/elements/gtk-search-bar.ts +7 -6
  281. package/src/elements/gtk-separator.ts +2 -1
  282. package/src/elements/gtk-spin-button.ts +2 -1
  283. package/src/elements/gtk-spinner.ts +2 -1
  284. package/src/elements/gtk-stack-page.ts +112 -0
  285. package/src/elements/gtk-stack-sidebar.ts +2 -1
  286. package/src/elements/gtk-stack-switcher.ts +2 -1
  287. package/src/elements/gtk-stack.ts +52 -6
  288. package/src/elements/gtk-switch.ts +2 -1
  289. package/src/elements/gtk-text-view.ts +2 -1
  290. package/src/elements/gtk-text.ts +2 -1
  291. package/src/elements/gtk-tree-expander.ts +5 -1
  292. package/src/elements/gtk-video.ts +2 -1
  293. package/src/elements/gtk-viewport.ts +6 -1
  294. package/src/elements/gtk-window-controls.ts +2 -1
  295. package/src/elements/gtk-window-handle.ts +6 -1
  296. package/src/elements/gtk-window.ts +57 -7
  297. package/src/gio.spec.ts +13 -3
  298. package/src/glib.spec.ts +9 -0
  299. package/src/gobject-elements.ts +44 -2
  300. package/src/gtk-label.spec.ts +39 -0
  301. package/src/gtk-scrolled-window.spec.ts +6 -6
  302. package/src/gtk-stack.spec.ts +170 -0
  303. package/src/gtk-value-doors.spec.ts +19 -0
  304. package/src/gtk-window.spec.ts +2 -2
  305. package/src/gtksource/gtk-source-view.ts +2 -1
  306. package/src/{icon-registry.spec.ts → icon-masks.spec.ts} +4 -100
  307. package/src/icon-theme.spec.ts +69 -124
  308. package/src/icon-theme.ts +29 -119
  309. package/src/index.ts +5 -9
  310. package/src/keyboard-operable.spec.ts +3 -3
  311. package/src/learn6502-window.spec.ts +113 -0
  312. package/src/namespace/adw.ts +1 -1
  313. package/src/namespace/gdk.ts +1 -0
  314. package/src/namespace/gio.ts +8 -0
  315. package/src/namespace/glib.ts +4 -0
  316. package/src/namespace/gtk.ts +2 -0
  317. package/src/shared-tree-builder.ts +131 -13
  318. package/src/shared-trees.spec.ts +15 -1
  319. package/src/signals.ts +11 -2
  320. package/src/slotted-children.spec.ts +24 -0
  321. package/src/slotted-children.ts +18 -2
  322. package/src/source-view/adw-source-view.ts +2 -1
  323. package/src/split-button.spec.ts +1 -1
  324. package/src/style-manager.spec.ts +13 -0
  325. package/src/style-manager.ts +6 -0
  326. package/src/styles.generated.ts +1 -1
  327. package/src/test.browser.mts +16 -2
  328. package/src/value-lists.spec.ts +3 -3
  329. package/src/widget-element.ts +75 -0
  330. package/src/widget-map.spec.ts +116 -0
  331. package/src/widget-mapping.ts +100 -0
  332. package/src/widget-visible.spec.ts +148 -0
  333. package/src/window-maximize.spec.ts +93 -0
  334. package/lib/types/icon-registry.d.ts +0 -37
  335. package/src/icon-registry.ts +0 -163
@@ -5,11 +5,20 @@
5
5
  // with a unique string ID and a label; one may carry the suggested or
6
6
  // destructive appearance.
7
7
  //
8
- // Responses are declared imperatively via add_response() / addResponse() (the
9
- // Adw.AlertDialog API), or via <adw-alert-response> children consumed at connect
10
- // time. The dialog is hidden until `present()` (or setting the `open` attribute)
11
- // reveals it; Escape / scrim-click dismiss it — respecting the `close-response`
12
- // — unless can-close is suppressed by the close response.
8
+ // Responses are declared imperatively via add_response() (the Adw.AlertDialog API),
9
+ // or via <adw-alert-response> children consumed at connect time. The dialog is
10
+ // hidden until `present()` (or setting the `open` attribute) reveals it; Escape /
11
+ // scrim-click dismiss it — respecting the `close-response` — unless can-close is
12
+ // suppressed by the close response.
13
+ //
14
+ // THE GJS FORM RUNS AS WRITTEN: `new Adw.AlertDialog({ heading, close_response })`,
15
+ // `add_response(id, label)`, `connect('response', (dialog, id) => …)`, `present(parent)`.
16
+ // The response verbs carry libadwaita's snake_case names only — the camelCase
17
+ // `addResponse` / `setDefaultResponse` … this element used to publish had no GIR
18
+ // counterpart. `present()` attaches a detached dialog to the document: libadwaita adds it
19
+ // to the dialog host of `parent`'s ROOT window, and the page is that root here. A dialog
20
+ // `present()` attached leaves the document again when it closes, as `adw_dialog_close`
21
+ // unparents it from the host; one placed in markup stays where its author put it.
13
22
  //
14
23
  // Attributes:
15
24
  // heading (the bold heading text)
@@ -35,12 +44,12 @@
35
44
  // sizes) and laid out horizontally when prefer-wide-layout is set and there are no more
36
45
  // than two of them — the libadwaita measure/allocate heuristic in spirit, not to the px.
37
46
  //
38
- // Events:
39
- // `response` (CustomEvent, bubbles, `detail = { response }`) when a response
40
- // button is activated OR the dialog is dismissed (then `response` is the
41
- // close-response ID) — mirrors the Adw.AlertDialog::response signal.
42
- // `notify::heading` / `notify::body` / `notify::open` (CustomEvent, bubbles)
43
- // mirroring the matching GObject properties.
47
+ // Signals (declared in `static signals`, reached with `connect`):
48
+ // `response (dialog, id)` when a response button is activated OR the dialog is
49
+ // dismissed (then `id` is the close-response) — Adw.AlertDialog::response. It
50
+ // arrives as a non-bubbling `response` DOM event whose `detail` is `[id]`.
51
+ // `notify::heading` / `notify::body` (CustomEvent, bubbles) mirroring the matching
52
+ // GObject properties; `notify::open` is the web-only `open` attribute's.
44
53
  //
45
54
  // The RESPONSE MODEL — the registry (id/label/appearance/enabled), the
46
55
  // default/close-response semantics and the resolve-to-chosen-id contract — is HEADLESS
@@ -57,12 +66,16 @@
57
66
 
58
67
  import { AdwAlertResponses } from '@gjsify/adwaita-core';
59
68
  import type { AdwResponseAppearance } from '@gjsify/adwaita-core';
69
+ import { propertyOf } from '@gjsify/adwaita-core/tags';
60
70
 
71
+ import { dispatchElement, installElementApi } from '../gobject-elements.js';
61
72
  import { renderPangoMarkup } from '../pango-markup.js';
73
+ import type { DispatchedSignals } from '../signals.js';
62
74
  import { bindEmptySections } from '../empty-sections.js';
63
75
  import { bindSlottedChildren } from '../slotted-children.js';
64
76
  import { AdwModalSurface } from './modal-surface.js';
65
77
  import { booleanAttribute } from '../attributes.js';
78
+ import { WidgetElement } from '../widget-element.js';
66
79
 
67
80
  /** Response button appearance — mirrors Adw.ResponseAppearance. */
68
81
  export type { AdwResponseAppearance } from '@gjsify/adwaita-core';
@@ -73,14 +86,61 @@ export type { AdwResponseAppearance } from '@gjsify/adwaita-core';
73
86
  * `appearance="suggested|destructive"` and `enabled="false"` mirror the
74
87
  * GtkBuildable `<response>` element attributes. Consumed at connect time.
75
88
  */
76
- export class AdwAlertResponse extends HTMLElement {
89
+ export class AdwAlertResponse extends WidgetElement {
77
90
  static get observedAttributes() {
78
91
  return ['id', 'appearance', 'enabled'];
79
92
  }
80
93
  }
81
94
 
82
- export class AdwAlertDialog extends HTMLElement {
95
+ /** The `Adw.AlertDialog` construct properties, in GJS's snake_case or the camelCase GJS also takes. */
96
+ export interface AdwAlertDialogProps {
97
+ heading?: string;
98
+ body?: string;
99
+ heading_use_markup?: boolean;
100
+ headingUseMarkup?: boolean;
101
+ body_use_markup?: boolean;
102
+ bodyUseMarkup?: boolean;
103
+ close_response?: string;
104
+ closeResponse?: string;
105
+ default_response?: string | null;
106
+ defaultResponse?: string | null;
107
+ prefer_wide_layout?: boolean;
108
+ preferWideLayout?: boolean;
109
+ }
110
+
111
+ export class AdwAlertDialog extends WidgetElement {
112
+ /** The GTK signals this element dispatches, each with the DOM event it arrives as (ADR 0093). */
113
+ static readonly signals: DispatchedSignals = {
114
+ response: 'response',
115
+ ...Object.fromEntries(
116
+ [
117
+ 'heading',
118
+ 'body',
119
+ 'heading-use-markup',
120
+ 'body-use-markup',
121
+ 'close-response',
122
+ 'default-response',
123
+ 'prefer-wide-layout',
124
+ ].map((name) => [`notify::${name}`, `notify::${name}`]),
125
+ ),
126
+ };
127
+
128
+ /** `GObject.Object.connect`: installed per instance by `installElementApi`; refuses an undeclared signal. */
129
+ declare connect: (signal: string, handler: (emitter: this, ...args: any[]) => unknown) => number;
130
+ /** `GObject.Object.disconnect`: throws for an id that is not connected. */
131
+ declare disconnect: (id: number) => void;
132
+ /** `GObject.Object.emit`. */
133
+ declare emit: (signal: string, ...args: unknown[]) => void;
134
+ /** `GObject.Object.notify`. */
135
+ declare notify: (name: string) => void;
136
+ /** `GObject.Object.get_property`, by GTK's dashed name. */
137
+ declare get_property: (name: string) => unknown;
138
+ /** `GObject.Object.set_property`. */
139
+ declare set_property: (name: string, value: unknown) => void;
140
+
83
141
  private _initialized = false;
142
+ /** Set when `present()` attached the dialog, so closing detaches it again. */
143
+ private _attachedByPresent = false;
84
144
  private _scrimEl!: HTMLDivElement;
85
145
  private _dialogEl!: HTMLDivElement;
86
146
  private _headingEl!: HTMLHeadingElement;
@@ -97,6 +157,22 @@ export class AdwAlertDialog extends HTMLElement {
97
157
  // also fire the close-response (AdwAlertDialog's `block_close_response`).
98
158
  private _blockCloseResponse = false;
99
159
 
160
+ /**
161
+ * `new Adw.AlertDialog({ heading, body, close_response, default_response })`, the GJS
162
+ * construct bag. Only the `new` form passes one: `document.createElement` and the
163
+ * parser call this with nothing, which is why writing attributes here is allowed.
164
+ */
165
+ constructor(props?: AdwAlertDialogProps) {
166
+ super();
167
+ installElementApi(this);
168
+ for (const [key, value] of Object.entries(props ?? {})) {
169
+ if (value === undefined) continue;
170
+ const member = propertyOf(key);
171
+ if (!(member in this)) throw new Error(`No property ${key} on <adw-alert-dialog>`);
172
+ (this as unknown as Record<string, unknown>)[member] = value;
173
+ }
174
+ }
175
+
100
176
  static get observedAttributes() {
101
177
  return [
102
178
  'heading',
@@ -171,7 +247,7 @@ export class AdwAlertDialog extends HTMLElement {
171
247
  }
172
248
 
173
249
  set defaultResponse(value: string | null) {
174
- this.setDefaultResponse(value);
250
+ this.set_default_response(value);
175
251
  }
176
252
 
177
253
  /** The ID passed to `response` when the dialog is dismissed. */
@@ -180,7 +256,7 @@ export class AdwAlertDialog extends HTMLElement {
180
256
  }
181
257
 
182
258
  set closeResponse(value: string) {
183
- this.setCloseResponse(value);
259
+ this.set_close_response(value);
184
260
  }
185
261
 
186
262
  connectedCallback() {
@@ -239,6 +315,7 @@ export class AdwAlertDialog extends HTMLElement {
239
315
  claims: (node) => node instanceof Element && node.localName === 'adw-alert-response',
240
316
  consume: (node) => this._adoptResponse(node as AdwAlertResponse),
241
317
  },
318
+ { name: 'extra-child', into: this._childEl },
242
319
  { into: this._childEl },
243
320
  ]).install(this._scrimEl, this._dialogEl);
244
321
 
@@ -261,7 +338,9 @@ export class AdwAlertDialog extends HTMLElement {
261
338
  // two live in the model and would simply be dropped.
262
339
  const closeResponse = this.getAttribute('close-response');
263
340
  if (closeResponse !== null) this._model.closeResponse = closeResponse;
264
- this._model.defaultResponse = this.getAttribute('default-response');
341
+ // An absent attribute leaves a `default_response` the construct bag already set.
342
+ const defaultResponse = this.getAttribute('default-response');
343
+ if (defaultResponse !== null) this._model.defaultResponse = defaultResponse;
265
344
 
266
345
  this._render();
267
346
  }
@@ -275,11 +354,11 @@ export class AdwAlertDialog extends HTMLElement {
275
354
  const id = el.getAttribute('id');
276
355
  if (!id) return;
277
356
  const appearance = (el.getAttribute('appearance') ?? 'default') as AdwResponseAppearance;
278
- this.addResponse(id, (el.textContent ?? '').trim());
279
- if (appearance !== 'default') this.setResponseAppearance(id, appearance);
357
+ this.add_response(id, (el.textContent ?? '').trim());
358
+ if (appearance !== 'default') this.set_response_appearance(id, appearance);
280
359
  // `enabled` is a value-based boolean attribute (GTK property defaulting to TRUE).
281
360
  // Use the shared reader instead of a hand-rolled `=== 'false'` comparison.
282
- if (!booleanAttribute(el.getAttribute('enabled'), true)) this.setResponseEnabled(id, false);
361
+ if (!booleanAttribute(el.getAttribute('enabled'), true)) this.set_response_enabled(id, false);
283
362
  }
284
363
 
285
364
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {
@@ -301,22 +380,38 @@ export class AdwAlertDialog extends HTMLElement {
301
380
  // header) — the attribute is a markup entry point that feeds it, so the
302
381
  // setter is not mirrored back and there is no reflection loop. An absent
303
382
  // attribute means "leave the model's default", not "reset to `close`".
304
- if (newValue !== null) this.setCloseResponse(newValue);
383
+ if (newValue !== null) this.set_close_response(newValue);
305
384
  } else if (name === 'default-response') {
306
- this.setDefaultResponse(newValue);
385
+ this.set_default_response(newValue);
307
386
  } else if (name === 'open') {
308
387
  this.dispatchEvent(new CustomEvent('notify::open', { bubbles: true, detail: { open: this.open } }));
309
- if (this.open) this._modal.present();
310
- else this._modal.dismiss();
388
+ if (this.open) {
389
+ this._modal.present();
390
+ } else {
391
+ this._modal.dismiss();
392
+ if (this._attachedByPresent) {
393
+ this._attachedByPresent = false;
394
+ this.remove();
395
+ }
396
+ }
311
397
  }
312
398
  }
313
399
 
314
- /** Present the dialog. `parent` is accepted for API parity; unused. */
400
+ /**
401
+ * Present the dialog (`adw_dialog_present`). A detached dialog is attached to the document
402
+ * first and detached again when it closes; `parent` names the window it belongs to, and the
403
+ * page is that window's root here, so it does not change where the dialog goes.
404
+ */
315
405
  present(_parent?: unknown): void {
406
+ if (!this.isConnected) {
407
+ document.body.appendChild(this);
408
+ this._attachedByPresent = true;
409
+ }
316
410
  this.open = true;
317
411
  }
318
412
 
319
- addResponse(id: string, label: string): void {
413
+ /** `adw_alert_dialog_add_response`: a duplicate id is refused, as libadwaita's g_critical does. */
414
+ add_response(id: string, label: string): void {
320
415
  // The core registry UPDATES a duplicate id in place; AdwAlertDialog refuses it,
321
416
  // so the guard stays here.
322
417
  if (this._model.hasResponse(id)) {
@@ -339,15 +434,14 @@ export class AdwAlertDialog extends HTMLElement {
339
434
  this._render();
340
435
  }
341
436
 
342
- /** Adds multiple responses at once — id/label pairs (Adw.add_responses parity). */
343
- addResponses(...idLabelPairs: string[]): void {
344
- for (let i = 0; i + 1 < idLabelPairs.length; i += 2) {
345
- this.addResponse(idLabelPairs[i], idLabelPairs[i + 1]);
437
+ /** `adw_alert_dialog_remove_response`. */
438
+ remove_response(id: string): void {
439
+ if (!this._model.hasResponse(id)) {
440
+ console.warn(
441
+ `[adw-alert-dialog] Trying to remove a response with id '${id}', but such a response does not exist`,
442
+ );
443
+ return;
346
444
  }
347
- }
348
-
349
- removeResponse(id: string): void {
350
- if (!this._model.hasResponse(id)) return;
351
445
  this._buttons.get(id)?.remove();
352
446
  this._buttons.delete(id);
353
447
  // `AdwAlertResponses` exposes no removal (a gap against
@@ -367,15 +461,18 @@ export class AdwAlertDialog extends HTMLElement {
367
461
  this._render();
368
462
  }
369
463
 
370
- hasResponse(id: string): boolean {
464
+ /** `adw_alert_dialog_has_response`. */
465
+ has_response(id: string): boolean {
371
466
  return this._model.hasResponse(id);
372
467
  }
373
468
 
374
- getResponseLabel(id: string): string | null {
469
+ /** `adw_alert_dialog_get_response_label`; `null` for an unknown id, as the C returns NULL. */
470
+ get_response_label(id: string): string | null {
375
471
  return this._model.responses.find((response) => response.id === id)?.label ?? null;
376
472
  }
377
473
 
378
- setResponseLabel(id: string, label: string): void {
474
+ /** `adw_alert_dialog_set_response_label`. */
475
+ set_response_label(id: string, label: string): void {
379
476
  const button = this._buttons.get(id);
380
477
  if (!button) return;
381
478
  // Re-adding a known id updates it in place (the core registry contract).
@@ -383,11 +480,13 @@ export class AdwAlertDialog extends HTMLElement {
383
480
  button.textContent = label;
384
481
  }
385
482
 
386
- getResponseAppearance(id: string): AdwResponseAppearance | null {
483
+ /** `adw_alert_dialog_get_response_appearance`; `null` for an unknown id. */
484
+ get_response_appearance(id: string): AdwResponseAppearance | null {
387
485
  return this._model.hasResponse(id) ? this._model.getResponseAppearance(id) : null;
388
486
  }
389
487
 
390
- setResponseAppearance(id: string, appearance: AdwResponseAppearance): void {
488
+ /** `adw_alert_dialog_set_response_appearance`. */
489
+ set_response_appearance(id: string, appearance: AdwResponseAppearance): void {
391
490
  const button = this._buttons.get(id);
392
491
  if (!button) return;
393
492
  this._model.setResponseAppearance(id, appearance);
@@ -395,31 +494,63 @@ export class AdwAlertDialog extends HTMLElement {
395
494
  button.classList.toggle('destructive-action', appearance === 'destructive');
396
495
  }
397
496
 
398
- getResponseEnabled(id: string): boolean {
497
+ /** `adw_alert_dialog_get_response_enabled`; `false` for an unknown id, as the C returns FALSE. */
498
+ get_response_enabled(id: string): boolean {
399
499
  return this._model.hasResponse(id) ? this._model.getResponseEnabled(id) : false;
400
500
  }
401
501
 
402
- /** Sets whether a response is enabled (disabled buttons can't be activated). */
403
- setResponseEnabled(id: string, enabled: boolean): void {
502
+ /** `adw_alert_dialog_set_response_enabled`: a disabled button cannot be activated. */
503
+ set_response_enabled(id: string, enabled: boolean): void {
404
504
  const button = this._buttons.get(id);
405
505
  if (!button) return;
406
506
  this._model.setResponseEnabled(id, enabled);
407
507
  button.disabled = !enabled;
408
508
  }
409
509
 
410
- /** Sets the default response — its button is highlighted as the suggested one. */
411
- setDefaultResponse(id: string | null): void {
510
+ /** `adw_alert_dialog_get_default_response`. */
511
+ get_default_response(): string | null {
512
+ return this._model.defaultResponse;
513
+ }
514
+
515
+ /** `adw_alert_dialog_set_default_response`: its button is highlighted and takes the focus. */
516
+ set_default_response(id: string | null): void {
412
517
  this._model.defaultResponse = id;
413
518
  this._render();
414
519
  }
415
520
 
416
- /** Sets the close response — emitted on dismissal (Escape / scrim click). */
417
- setCloseResponse(id: string): void {
521
+ /** `adw_alert_dialog_get_close_response`. */
522
+ get_close_response(): string {
523
+ return this._model.closeResponse;
524
+ }
525
+
526
+ /** `adw_alert_dialog_set_close_response`: emitted on dismissal (Escape / scrim click). */
527
+ set_close_response(id: string): void {
418
528
  this._model.closeResponse = id;
419
529
  }
420
530
 
531
+ /** `adw_alert_dialog_get_heading`. */
532
+ get_heading(): string {
533
+ return this.heading;
534
+ }
535
+
536
+ /** `adw_alert_dialog_set_heading`. */
537
+ set_heading(heading: string): void {
538
+ this.heading = heading;
539
+ }
540
+
541
+ /** `adw_alert_dialog_get_body`. */
542
+ get_body(): string {
543
+ return this.body;
544
+ }
545
+
546
+ /** `adw_alert_dialog_set_body`. */
547
+ set_body(body: string): void {
548
+ this.body = body;
549
+ }
550
+
421
551
  private _activateResponse(id: string): void {
422
552
  if (!this._model.getResponseEnabled(id)) return;
553
+ // `emit_response`: block the close-response, close, then emit the chosen one.
423
554
  this._blockCloseResponse = true;
424
555
  this.open = false;
425
556
  this._blockCloseResponse = false;
@@ -438,7 +569,7 @@ export class AdwAlertDialog extends HTMLElement {
438
569
  }
439
570
 
440
571
  private _emitResponse(response: string): void {
441
- this.dispatchEvent(new CustomEvent('response', { bubbles: true, detail: { response } }));
572
+ dispatchElement(this, 'response', [response]);
442
573
  }
443
574
 
444
575
  /**
@@ -45,7 +45,6 @@ import type { AdwBreakpoint } from '@gjsify/adwaita-core';
45
45
  import type { AdwSlot } from '../slotted-children.js';
46
46
  import { AdwWindowFeatures } from './adw-window-features.js';
47
47
  import { GtkApplicationWindow } from './gtk-application-window.js';
48
- import { defineWindowApplication } from '../application.js';
49
48
 
50
49
  export class AdwApplicationWindow extends GtkApplicationWindow {
51
50
  private readonly _features = new AdwWindowFeatures(this);
@@ -232,5 +231,3 @@ export class AdwApplicationWindow extends GtkApplicationWindow {
232
231
  }
233
232
 
234
233
  customElements.define('adw-application-window', AdwApplicationWindow);
235
-
236
- defineWindowApplication(AdwApplicationWindow.prototype);
@@ -29,8 +29,9 @@ import {
29
29
  } from '@gjsify/adwaita-core';
30
30
 
31
31
  import { type GtkImage, createGtkImage } from './gtk-image.js';
32
+ import { WidgetElement } from '../widget-element.js';
32
33
 
33
- export class AdwAvatar extends HTMLElement {
34
+ export class AdwAvatar extends WidgetElement {
34
35
  private _textEl!: HTMLSpanElement;
35
36
  private _iconEl!: GtkImage;
36
37
  private _imageEl!: HTMLImageElement;
@@ -21,8 +21,9 @@ import {
21
21
  } from '@gjsify/adwaita-core';
22
22
 
23
23
  import { renderPangoMarkup } from '../pango-markup.js';
24
+ import { WidgetElement } from '../widget-element.js';
24
25
 
25
- export class AdwBanner extends HTMLElement {
26
+ export class AdwBanner extends WidgetElement {
26
27
  private _titleEl!: HTMLSpanElement;
27
28
  private _button!: HTMLButtonElement;
28
29
  private _initialized = false;
@@ -31,8 +31,9 @@
31
31
  // Modifications: Implemented as a Web Component for @gjsify/adwaita-web.
32
32
 
33
33
  import { bindSlottedChildren } from '../slotted-children.js';
34
+ import { WidgetElement } from '../widget-element.js';
34
35
 
35
- export class AdwBin extends HTMLElement {
36
+ export class AdwBin extends WidgetElement {
36
37
  private _observer: MutationObserver | null = null;
37
38
 
38
39
  /** `Adw.Bin:child` — the one child, or `null`. The last one appended is the one that stays. */
@@ -66,17 +66,18 @@ import type {
66
66
  import { bindSlottedChildren, type AdwSlot } from '../slotted-children.js';
67
67
  import { installElementApi } from '../gobject-elements.js';
68
68
  import type { DispatchedSignals } from '../signals.js';
69
+ import { WidgetElement } from '../widget-element.js';
69
70
 
70
71
  /** The persistent content. Child of <adw-bottom-sheet>; consumed at connect time. */
71
- export class AdwBottomSheetContent extends HTMLElement {}
72
+ export class AdwBottomSheetContent extends WidgetElement {}
72
73
 
73
74
  /** The slide-up sheet. Child of <adw-bottom-sheet>; consumed at connect time. */
74
- export class AdwBottomSheetSheet extends HTMLElement {}
75
+ export class AdwBottomSheetSheet extends WidgetElement {}
75
76
 
76
77
  /** The collapsed bar the sheet morphs out of. Child of <adw-bottom-sheet>. */
77
- export class AdwBottomSheetBottomBar extends HTMLElement {}
78
+ export class AdwBottomSheetBottomBar extends WidgetElement {}
78
79
 
79
- export class AdwBottomSheet extends HTMLElement {
80
+ export class AdwBottomSheet extends WidgetElement {
80
81
  /** The GTK signals this element dispatches, each with the DOM event it arrives as (ADR 0093). */
81
82
  static readonly signals: DispatchedSignals = { 'notify::open': 'notify::open' };
82
83
 
@@ -67,6 +67,8 @@ import { BreakpointBinState } from '@gjsify/adwaita-core';
67
67
  import type { BreakpointSetter } from '@gjsify/adwaita-core';
68
68
 
69
69
  import { observeAdaptiveSize } from '../breakpoints.js';
70
+ import { bindSlottedChildren } from '../slotted-children.js';
71
+ import { WidgetElement } from '../widget-element.js';
70
72
 
71
73
  /** One authored setter, as it reads in the `breakpoints` attribute. */
72
74
  interface AuthoredSetter {
@@ -103,7 +105,7 @@ function parseBreakpoints(raw: string | null): AuthoredBreakpoint[] {
103
105
  });
104
106
  }
105
107
 
106
- export class AdwBreakpointBin extends HTMLElement {
108
+ export class AdwBreakpointBin extends WidgetElement {
107
109
  /** The C's own structure: a list of breakpoints, and at most one picked. */
108
110
  private _state = new BreakpointBinState<Element>();
109
111
  private _dispose: (() => void) | undefined;
@@ -157,6 +159,8 @@ export class AdwBreakpointBin extends HTMLElement {
157
159
  }
158
160
 
159
161
  connectedCallback() {
162
+ // The NAME only, for the reason `adw-bin.ts` gives: the child already IS the content.
163
+ bindSlottedChildren(this, [{ name: 'child', into: this }]);
160
164
  this.setAttribute('role', 'group');
161
165
  // A GTK widget is a box and an unknown custom element is `inline`, which measures
162
166
  // zero — and a bin measuring zero matches every condition forever. libadwaita
@@ -25,6 +25,7 @@
25
25
  import { BUTTON_CONTENT_STYLE_CLASS, buttonContentIconName, buttonContentLabelText } from '@gjsify/adwaita-core';
26
26
 
27
27
  import { type GtkImage, createGtkImage } from './gtk-image.js';
28
+ import { WidgetElement } from '../widget-element.js';
28
29
 
29
30
  /**
30
31
  * What `gtk_widget_get_ancestor (…, GTK_TYPE_BUTTON)` looks like in the DOM: a native
@@ -36,7 +37,7 @@ const BUTTON_SELECTOR = 'button, .adw-button';
36
37
  /** The split-button node the class is RETARGETED to. */
37
38
  const SPLIT_BUTTON_SELECTOR = 'adw-split-button, .adw-split-button';
38
39
 
39
- export class AdwButtonContent extends HTMLElement {
40
+ export class AdwButtonContent extends WidgetElement {
40
41
  private _boxEl!: HTMLDivElement;
41
42
  private _iconEl!: GtkImage;
42
43
  private _labelEl!: HTMLSpanElement;
@@ -27,8 +27,9 @@ import { BUTTON_ROW_ACTIVATABLE, ButtonRowState } from '@gjsify/adwaita-core';
27
27
  import { applyRowTooltip } from '../row-tooltip.js';
28
28
  import { type GtkImage, createGtkImage } from './gtk-image.js';
29
29
  import { attachRowActivation } from './row-activation.js';
30
+ import { TooltipElement } from '../widget-element.js';
30
31
 
31
- export class AdwButtonRow extends HTMLElement {
32
+ export class AdwButtonRow extends TooltipElement {
32
33
  private _contentsEl!: HTMLDivElement;
33
34
  private _startIconEl!: GtkImage;
34
35
  private _endIconEl!: GtkImage;
@@ -5,8 +5,9 @@
5
5
  // Reference: refs/adwaita-web/adwaita-web/scss/_card.scss
6
6
  // Copyright (c) GNOME contributors (libadwaita). LGPLv2.1+.
7
7
  // Modifications: Implemented as Web Component for @gjsify/adwaita-web.
8
+ import { WidgetElement } from '../widget-element.js';
8
9
 
9
- export class AdwCard extends HTMLElement {
10
+ export class AdwCard extends WidgetElement {
10
11
  connectedCallback() {
11
12
  this.classList.add('adw-card');
12
13
  }
@@ -36,9 +36,10 @@ import { CarouselState, carouselClosestSnapPoint, carouselPageAllocation } from
36
36
  import type { CarouselScrollRequest, CarouselScrollSource, CarouselStateChange } from '@gjsify/adwaita-core';
37
37
 
38
38
  import { attachSwipeDrag, type AdwSwipeDrag } from './swipe-drag.js';
39
+ import { WidgetElement } from '../widget-element.js';
39
40
 
40
41
  /** Common surface an indicator binds to. The concrete element is AdwCarousel. */
41
- interface CarouselHost extends HTMLElement {
42
+ interface CarouselHost extends WidgetElement {
42
43
  readonly nPages: number;
43
44
  readonly position: number;
44
45
  /** The page the current position settles on, `-1` when empty. */
@@ -70,7 +71,7 @@ function wheelSource(event: WheelEvent): CarouselScrollSource {
70
71
  return 'mouse';
71
72
  }
72
73
 
73
- export class AdwCarousel extends HTMLElement implements CarouselHost {
74
+ export class AdwCarousel extends WidgetElement implements CarouselHost {
74
75
  private readonly _state = new CarouselState({
75
76
  // The DOM owns the scroll animation: `scrollTo` only asks, and the
76
77
  // scroll handler feeds the ramp back through `setPosition`.
@@ -103,6 +104,8 @@ export class AdwCarousel extends HTMLElement implements CarouselHost {
103
104
  private _scrollTargetId: string | null = null;
104
105
  /** The pointer-drag gesture, asked whether it owns the strip. See `_onWheel`. */
105
106
  private _drag: AdwSwipeDrag | undefined;
107
+ /** A `scroll_to` issued before the pages were adopted, run once they are. */
108
+ private _pendingScrollPage: HTMLElement | null = null;
106
109
 
107
110
  static get observedAttributes() {
108
111
  return ['allow-scroll-wheel', 'allow-mouse-drag', 'allow-long-swipes', 'interactive', 'spacing', 'position'];
@@ -272,6 +275,14 @@ export class AdwCarousel extends HTMLElement implements CarouselHost {
272
275
  // delivers attributes BEFORE `connectedCallback`, so reading it here is the
273
276
  // only way `<adw-carousel position="2">` works at all.
274
277
  this._applyAttribute('position', this.getAttribute('position'));
278
+
279
+ // Upstream defers a `scroll_to` that arrives before the first allocation to an
280
+ // idle (adw-carousel.c:1580-1595); the pages existing is the earliest this port
281
+ // can resolve one, and it lands where a declared `position` would.
282
+ const pending = this._pendingScrollPage;
283
+ this._pendingScrollPage = null;
284
+ const id = pending ? this._idOf(pending) : null;
285
+ if (id !== null) this._positionWhenMeasurable(this._state.indexOf(id));
275
286
  }
276
287
 
277
288
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
@@ -450,6 +461,45 @@ export class AdwCarousel extends HTMLElement implements CarouselHost {
450
461
  return this._state.navigate(direction);
451
462
  }
452
463
 
464
+ /**
465
+ * `adw_carousel_scroll_to` — scroll to `widget`, one of the pages. A widget that is
466
+ * not one is refused, which is C's precondition; `animate = false` lands at once.
467
+ */
468
+ scroll_to(widget: HTMLElement, animate: boolean): void {
469
+ if (!this._initialized) {
470
+ if (widget.parentElement === this) this._pendingScrollPage = widget;
471
+ return;
472
+ }
473
+ const id = this._idOf(widget);
474
+ if (id === null) return;
475
+ this._state.scrollTo(this._state.indexOf(id), { animate });
476
+ }
477
+
478
+ /**
479
+ * `adw_carousel_get_nth_page` — the page at `n`. Past the last page C's precondition
480
+ * fails and returns NULL, so this returns `null`.
481
+ */
482
+ get_nth_page(n: number): HTMLElement | null {
483
+ if (!this._initialized) {
484
+ const declared = this.children[n];
485
+ return Number.isInteger(n) && declared instanceof HTMLElement ? declared : null;
486
+ }
487
+ if (!Number.isInteger(n) || n < 0 || n >= this._state.nPages) return null;
488
+ const id = this._state.ids[n];
489
+ const page = id === undefined ? null : this._slots.get(id)?.firstElementChild;
490
+ return page instanceof HTMLElement ? page : null;
491
+ }
492
+
493
+ /** `adw_carousel_get_n_pages`. */
494
+ get_n_pages(): number {
495
+ return this._initialized ? this._state.nPages : this.children.length;
496
+ }
497
+
498
+ /** `adw_carousel_get_position` — the {@link position} property. */
499
+ get_position(): number {
500
+ return this._state.position;
501
+ }
502
+
453
503
  private _insert(page: HTMLElement, position: number): boolean {
454
504
  const id = `page-${this._nextPageId++}`;
455
505
  if (!this._state.insertPage(id, position)) return false;
@@ -601,6 +651,15 @@ export class AdwCarousel extends HTMLElement implements CarouselHost {
601
651
  if (!this._trackEl) return;
602
652
  const distance = this._distance();
603
653
  if (!(distance > 0)) return;
654
+ // The model is already there (`adw_animation_skip`), so the offset follows at once
655
+ // and nothing waits for an arrival; a smooth scroll would feed the frames in
656
+ // between back into `position`.
657
+ if (!request.animate) {
658
+ this._pendingInteractive = null;
659
+ this._scrollTargetId = null;
660
+ this._trackEl.scrollTo({ left: request.index * distance, behavior: 'instant' });
661
+ return;
662
+ }
604
663
  this._pendingInteractive = request.interactive;
605
664
  this._scrollTargetId = this._state.ids[request.index] ?? null;
606
665
  // `offset = distance * position`, NOT `slot.offsetLeft` — that is measured from
@@ -673,7 +732,7 @@ export class AdwCarousel extends HTMLElement implements CarouselHost {
673
732
  }
674
733
  }
675
734
 
676
- abstract class AdwCarouselIndicator extends HTMLElement {
735
+ abstract class AdwCarouselIndicator extends WidgetElement {
677
736
  protected _carousel: CarouselHost | null = null;
678
737
  protected _initialized = false;
679
738
 
@@ -53,6 +53,7 @@ import {
53
53
  } from '@gjsify/adwaita-core';
54
54
 
55
55
  import { bindSlottedChildren } from '../slotted-children.js';
56
+ import { WidgetElement } from '../widget-element.js';
56
57
 
57
58
  /** `Gtk.ScrollablePolicy`'s three nicks, in enum order. */
58
59
  export type ScrollPolicy = 'automatic' | 'always' | 'never';
@@ -64,7 +65,7 @@ const POLICY_OVERFLOW: Record<ScrollPolicy, string> = {
64
65
  never: 'hidden',
65
66
  };
66
67
 
67
- export class AdwClampScrollable extends HTMLElement {
68
+ export class AdwClampScrollable extends WidgetElement {
68
69
  private _resize: ResizeObserver | null = null;
69
70
  private _mutations: MutationObserver | null = null;
70
71