@gjsify/adwaita-web 0.54.0 → 0.55.0

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 (439) hide show
  1. package/dist/adwaita-web.css +8066 -3033
  2. package/dist/adwaita-web.css.map +1 -1
  3. package/lib/types/adw-application-window.spec.d.ts +1 -0
  4. package/lib/types/adw-bin.spec.d.ts +1 -0
  5. package/lib/types/adw-breakpoint-bin.spec.d.ts +1 -0
  6. package/lib/types/adw-clamp-scrollable.spec.d.ts +1 -0
  7. package/lib/types/adw-multi-layout-view.spec.d.ts +1 -0
  8. package/lib/types/adw-preferences-row.spec.d.ts +1 -0
  9. package/lib/types/adw-shortcuts.spec.d.ts +1 -0
  10. package/lib/types/adw-tab-bar.spec.d.ts +1 -0
  11. package/lib/types/adw-tab-button.spec.d.ts +1 -0
  12. package/lib/types/adw-tab-overview.spec.d.ts +1 -0
  13. package/lib/types/adw-view-switcher-sidebar.spec.d.ts +1 -0
  14. package/lib/types/adw-window.spec.d.ts +1 -0
  15. package/lib/types/breakpoints.d.ts +14 -3
  16. package/lib/types/construct-vectors.spec.d.ts +1 -0
  17. package/lib/types/elements/adw-application-window.d.ts +27 -0
  18. package/lib/types/elements/adw-bin.d.ts +17 -0
  19. package/lib/types/elements/adw-breakpoint-bin.d.ts +67 -0
  20. package/lib/types/elements/adw-clamp-scrollable.d.ts +38 -0
  21. package/lib/types/elements/adw-dialog.d.ts +10 -0
  22. package/lib/types/elements/adw-layout-slot.d.ts +19 -0
  23. package/lib/types/elements/adw-multi-layout-view.d.ts +101 -0
  24. package/lib/types/elements/adw-preferences-row.d.ts +31 -0
  25. package/lib/types/elements/adw-shortcuts-dialog.d.ts +13 -0
  26. package/lib/types/elements/adw-shortcuts-item.d.ts +36 -0
  27. package/lib/types/elements/adw-shortcuts-section.d.ts +14 -0
  28. package/lib/types/elements/adw-sidebar.d.ts +5 -0
  29. package/lib/types/elements/adw-switch-row.d.ts +3 -0
  30. package/lib/types/elements/adw-tab-bar.d.ts +108 -0
  31. package/lib/types/elements/adw-tab-button.d.ts +32 -0
  32. package/lib/types/elements/adw-tab-overview.d.ts +199 -0
  33. package/lib/types/elements/adw-tab-view.d.ts +19 -23
  34. package/lib/types/elements/adw-view-switcher-sidebar.d.ts +84 -0
  35. package/lib/types/elements/adw-window.d.ts +40 -0
  36. package/lib/types/elements/gtk-about-dialog.d.ts +146 -0
  37. package/lib/types/elements/gtk-application-window.d.ts +34 -0
  38. package/lib/types/elements/gtk-aspect-frame.d.ts +27 -0
  39. package/lib/types/elements/gtk-button.d.ts +9 -0
  40. package/lib/types/elements/gtk-calendar.d.ts +159 -0
  41. package/lib/types/elements/gtk-center-box.d.ts +39 -0
  42. package/lib/types/elements/gtk-color-dialog-button.d.ts +69 -0
  43. package/lib/types/elements/gtk-column-view.d.ts +50 -0
  44. package/lib/types/elements/gtk-drag-icon.d.ts +78 -0
  45. package/lib/types/elements/gtk-drawing-area.d.ts +95 -0
  46. package/lib/types/elements/gtk-editable-label.d.ts +33 -0
  47. package/lib/types/elements/gtk-emoji-chooser.d.ts +84 -0
  48. package/lib/types/elements/gtk-entry.d.ts +20 -1
  49. package/lib/types/elements/gtk-expander.d.ts +49 -0
  50. package/lib/types/elements/gtk-fixed.d.ts +13 -0
  51. package/lib/types/elements/gtk-flow-box-child.d.ts +14 -0
  52. package/lib/types/elements/gtk-flow-box.d.ts +87 -0
  53. package/lib/types/elements/gtk-font-dialog-button.d.ts +83 -0
  54. package/lib/types/elements/gtk-frame.d.ts +24 -0
  55. package/lib/types/elements/gtk-gl-area.d.ts +136 -0
  56. package/lib/types/elements/gtk-graphics-offload.d.ts +24 -0
  57. package/lib/types/elements/gtk-grid-view.d.ts +39 -0
  58. package/lib/types/elements/gtk-grid.d.ts +27 -0
  59. package/lib/types/elements/gtk-header-bar.d.ts +60 -0
  60. package/lib/types/elements/gtk-inscription.d.ts +64 -0
  61. package/lib/types/elements/gtk-label.d.ts +3 -0
  62. package/lib/types/elements/gtk-level-bar.d.ts +59 -0
  63. package/lib/types/elements/gtk-link-button.d.ts +29 -0
  64. package/lib/types/elements/gtk-list-box-row.d.ts +54 -0
  65. package/lib/types/elements/gtk-list-box.d.ts +100 -0
  66. package/lib/types/elements/gtk-list-view.d.ts +73 -0
  67. package/lib/types/elements/gtk-media-controls.d.ts +142 -0
  68. package/lib/types/elements/gtk-notebook.d.ts +148 -0
  69. package/lib/types/elements/gtk-overlay.d.ts +22 -0
  70. package/lib/types/elements/gtk-page-setup-unix-dialog.d.ts +87 -0
  71. package/lib/types/elements/gtk-paned.d.ts +121 -0
  72. package/lib/types/elements/gtk-password-entry.d.ts +27 -0
  73. package/lib/types/elements/gtk-picture.d.ts +66 -0
  74. package/lib/types/elements/gtk-popover-bin.d.ts +82 -0
  75. package/lib/types/elements/gtk-popover-menu-bar.d.ts +66 -0
  76. package/lib/types/elements/gtk-popover-menu.d.ts +83 -0
  77. package/lib/types/elements/gtk-popover.d.ts +28 -3
  78. package/lib/types/elements/gtk-print-unix-dialog.d.ts +167 -0
  79. package/lib/types/elements/gtk-revealer.d.ts +55 -0
  80. package/lib/types/elements/gtk-scale-button.d.ts +59 -0
  81. package/lib/types/elements/gtk-scale.d.ts +98 -0
  82. package/lib/types/elements/gtk-scrollbar.d.ts +124 -0
  83. package/lib/types/elements/gtk-scrolled-window.d.ts +121 -0
  84. package/lib/types/elements/gtk-search-bar.d.ts +39 -0
  85. package/lib/types/elements/gtk-search-entry.d.ts +27 -0
  86. package/lib/types/elements/gtk-separator.d.ts +10 -0
  87. package/lib/types/elements/gtk-spin-button.d.ts +94 -0
  88. package/lib/types/elements/gtk-spinner.d.ts +14 -0
  89. package/lib/types/elements/gtk-stack-sidebar.d.ts +43 -0
  90. package/lib/types/elements/gtk-stack-switcher.d.ts +58 -0
  91. package/lib/types/elements/gtk-stack.d.ts +154 -0
  92. package/lib/types/elements/gtk-switch.d.ts +4 -1
  93. package/lib/types/elements/gtk-text-view.d.ts +62 -0
  94. package/lib/types/elements/gtk-text.d.ts +45 -0
  95. package/lib/types/elements/gtk-toggle-button.d.ts +45 -0
  96. package/lib/types/elements/gtk-tree-expander.d.ts +38 -0
  97. package/lib/types/elements/gtk-video.d.ts +97 -0
  98. package/lib/types/elements/gtk-viewport.d.ts +84 -0
  99. package/lib/types/elements/gtk-window-controls.d.ts +80 -0
  100. package/lib/types/elements/gtk-window-handle.d.ts +39 -0
  101. package/lib/types/elements/gtk-window.d.ts +97 -0
  102. package/lib/types/elements/justification.d.ts +2 -0
  103. package/lib/types/elements/popover-menu.d.ts +18 -0
  104. package/lib/types/elements/roving-focus.d.ts +29 -1
  105. package/lib/types/emoji-data.d.ts +38 -0
  106. package/lib/types/font-description.d.ts +96 -0
  107. package/lib/types/gtk-about-dialog.spec.d.ts +1 -0
  108. package/lib/types/gtk-action-bar.spec.d.ts +1 -0
  109. package/lib/types/gtk-application-window.spec.d.ts +1 -0
  110. package/lib/types/gtk-aspect-frame.spec.d.ts +1 -0
  111. package/lib/types/gtk-calendar.spec.d.ts +1 -0
  112. package/lib/types/gtk-center-box.spec.d.ts +1 -0
  113. package/lib/types/gtk-color-dialog-button.spec.d.ts +1 -0
  114. package/lib/types/gtk-column-view.spec.d.ts +1 -0
  115. package/lib/types/gtk-drag-icon.spec.d.ts +1 -0
  116. package/lib/types/gtk-drawing-area.spec.d.ts +1 -0
  117. package/lib/types/gtk-editable-label.spec.d.ts +1 -0
  118. package/lib/types/gtk-emoji-chooser.spec.d.ts +1 -0
  119. package/lib/types/gtk-expander.spec.d.ts +1 -0
  120. package/lib/types/gtk-fixed.spec.d.ts +1 -0
  121. package/lib/types/gtk-flow-box.spec.d.ts +1 -0
  122. package/lib/types/gtk-font-dialog-button.spec.d.ts +1 -0
  123. package/lib/types/gtk-frame.spec.d.ts +1 -0
  124. package/lib/types/gtk-gl-area.spec.d.ts +1 -0
  125. package/lib/types/gtk-graphics-offload.spec.d.ts +1 -0
  126. package/lib/types/gtk-grid-view.spec.d.ts +1 -0
  127. package/lib/types/gtk-grid.spec.d.ts +1 -0
  128. package/lib/types/gtk-header-bar.spec.d.ts +1 -0
  129. package/lib/types/gtk-inscription.spec.d.ts +1 -0
  130. package/lib/types/gtk-level-bar.spec.d.ts +1 -0
  131. package/lib/types/gtk-link-button.spec.d.ts +1 -0
  132. package/lib/types/gtk-list-box.spec.d.ts +1 -0
  133. package/lib/types/gtk-list-view.spec.d.ts +1 -0
  134. package/lib/types/gtk-media-controls.spec.d.ts +1 -0
  135. package/lib/types/gtk-notebook.spec.d.ts +1 -0
  136. package/lib/types/gtk-overlay.spec.d.ts +1 -0
  137. package/lib/types/gtk-paned.spec.d.ts +1 -0
  138. package/lib/types/gtk-password-entry.spec.d.ts +1 -0
  139. package/lib/types/gtk-picture.spec.d.ts +1 -0
  140. package/lib/types/gtk-popover-bin.spec.d.ts +1 -0
  141. package/lib/types/gtk-popover-menu-bar.spec.d.ts +1 -0
  142. package/lib/types/gtk-popover-menu.spec.d.ts +1 -0
  143. package/lib/types/gtk-popover-role.spec.d.ts +1 -0
  144. package/lib/types/gtk-popover.spec.d.ts +1 -0
  145. package/lib/types/gtk-print-dialogs.spec.d.ts +1 -0
  146. package/lib/types/gtk-revealer.spec.d.ts +1 -0
  147. package/lib/types/gtk-scale-button.spec.d.ts +1 -0
  148. package/lib/types/gtk-scale.spec.d.ts +1 -0
  149. package/lib/types/gtk-scrollbar.spec.d.ts +1 -0
  150. package/lib/types/gtk-scrolled-window.spec.d.ts +1 -0
  151. package/lib/types/gtk-search-bar.spec.d.ts +1 -0
  152. package/lib/types/gtk-search-entry.spec.d.ts +1 -0
  153. package/lib/types/gtk-separator.spec.d.ts +1 -0
  154. package/lib/types/gtk-spin-button.spec.d.ts +1 -0
  155. package/lib/types/gtk-spinner.spec.d.ts +1 -0
  156. package/lib/types/gtk-stack-sidebar.spec.d.ts +1 -0
  157. package/lib/types/gtk-stack-switcher.spec.d.ts +1 -0
  158. package/lib/types/gtk-stack.spec.d.ts +1 -0
  159. package/lib/types/gtk-text-view.spec.d.ts +1 -0
  160. package/lib/types/gtk-text.spec.d.ts +1 -0
  161. package/lib/types/gtk-toggle-button.spec.d.ts +1 -0
  162. package/lib/types/gtk-tree-expander.spec.d.ts +1 -0
  163. package/lib/types/gtk-video.spec.d.ts +1 -0
  164. package/lib/types/gtk-viewport.spec.d.ts +1 -0
  165. package/lib/types/gtk-window-controls.spec.d.ts +1 -0
  166. package/lib/types/gtk-window-handle.spec.d.ts +1 -0
  167. package/lib/types/gtk-window.spec.d.ts +1 -0
  168. package/lib/types/index.d.ts +4 -1
  169. package/lib/types/list-view-dom.d.ts +44 -0
  170. package/lib/types/namespace/adw.d.ts +12 -0
  171. package/lib/types/namespace/gtk.d.ts +61 -0
  172. package/lib/types/page-setup.d.ts +100 -0
  173. package/lib/types/scroll-shading.d.ts +15 -1
  174. package/lib/types/shared-tree-builder.d.ts +30 -2
  175. package/lib/types/signals.d.ts +4 -0
  176. package/lib/types/styles.generated.d.ts +1 -1
  177. package/lib/types/tab-chip.d.ts +73 -0
  178. package/lib/types/template-classes.d.ts +11 -0
  179. package/package.json +12 -8
  180. package/scss/_action_row.scss +2 -2
  181. package/scss/_application_window.scss +26 -0
  182. package/scss/_aspect_frame.scss +25 -0
  183. package/scss/_bin.scss +26 -0
  184. package/scss/_button.scss +45 -0
  185. package/scss/_calendar.scss +176 -0
  186. package/scss/_center_box.scss +25 -0
  187. package/scss/_checks.scss +6 -1
  188. package/scss/_clamp_scrollable.scss +28 -0
  189. package/scss/_color_button.scss +67 -0
  190. package/scss/_column_view.scss +126 -0
  191. package/scss/_drag_icon.scss +55 -0
  192. package/scss/_drawing.scss +85 -0
  193. package/scss/_emoji_chooser.scss +213 -0
  194. package/scss/_entry.scss +13 -5
  195. package/scss/_entry_row.scss +1 -1
  196. package/scss/_expander.scss +113 -0
  197. package/scss/_fixed.scss +29 -0
  198. package/scss/_flow_box.scss +94 -0
  199. package/scss/_font_button.scss +63 -0
  200. package/scss/_frame.scss +41 -0
  201. package/scss/_grid.scss +19 -0
  202. package/scss/_grid_view.scss +46 -0
  203. package/scss/_gtk_about_dialog.scss +186 -0
  204. package/scss/_headerbar.scss +132 -0
  205. package/scss/_icons.generated.scss +186 -0
  206. package/scss/_inscription.scss +125 -0
  207. package/scss/_level_bar.scss +190 -0
  208. package/scss/_link.scss +82 -0
  209. package/scss/_list_box.scss +88 -0
  210. package/scss/_list_view.scss +96 -0
  211. package/scss/_media_controls.scss +139 -0
  212. package/scss/_overlay.scss +68 -0
  213. package/scss/_paned.scss +130 -0
  214. package/scss/_password_entry.scss +83 -0
  215. package/scss/_picture.scss +80 -0
  216. package/scss/_popover_bin.scss +53 -0
  217. package/scss/_popover_menu_bar.scss +104 -0
  218. package/scss/_preferences_row.scss +51 -0
  219. package/scss/_print_dialogs.scss +328 -0
  220. package/scss/_reset.scss +21 -19
  221. package/scss/_revealer.scss +37 -0
  222. package/scss/_row.scss +20 -5
  223. package/scss/_scale.scss +298 -0
  224. package/scss/_scale_button.scss +167 -0
  225. package/scss/_scrollbar.scss +230 -0
  226. package/scss/_scrolled_window.scss +131 -0
  227. package/scss/_search_bar.scss +118 -0
  228. package/scss/_search_entry.scss +86 -0
  229. package/scss/_separator.scss +44 -0
  230. package/scss/_shortcuts_dialog.scss +100 -0
  231. package/scss/_spin_button.scss +172 -0
  232. package/scss/_spin_row.scss +56 -8
  233. package/scss/_spinner.scss +85 -4
  234. package/scss/_stack.scss +729 -0
  235. package/scss/_switch.scss +13 -5
  236. package/scss/_switch_row.scss +10 -0
  237. package/scss/_tab_bar.scss +317 -0
  238. package/scss/_tab_button.scss +98 -0
  239. package/scss/_tab_overview.scss +483 -0
  240. package/scss/_text.scss +182 -0
  241. package/scss/_theme.scss +1 -1
  242. package/scss/_tree_expander.scss +62 -0
  243. package/scss/_variables.scss +1 -1
  244. package/scss/_video.scss +146 -0
  245. package/scss/_view_switcher_sidebar.scss +112 -0
  246. package/scss/_viewport.scss +50 -0
  247. package/scss/_window.scss +118 -1
  248. package/scss/_window_handle.scss +20 -0
  249. package/scss/adwaita-skin.scss +109 -0
  250. package/src/adw-action-rows.spec.ts +76 -0
  251. package/src/adw-application-window.spec.ts +118 -0
  252. package/src/adw-bin.spec.ts +75 -0
  253. package/src/adw-breakpoint-bin.spec.ts +324 -0
  254. package/src/adw-clamp-scrollable.spec.ts +189 -0
  255. package/src/adw-multi-layout-view.spec.ts +243 -0
  256. package/src/adw-preferences-row.spec.ts +164 -0
  257. package/src/adw-row-state.spec.ts +142 -0
  258. package/src/adw-shortcuts.spec.ts +155 -0
  259. package/src/adw-tab-bar.spec.ts +287 -0
  260. package/src/adw-tab-button.spec.ts +101 -0
  261. package/src/adw-tab-overview.spec.ts +443 -0
  262. package/src/adw-view-switcher-sidebar.spec.ts +281 -0
  263. package/src/adw-window.spec.ts +129 -0
  264. package/src/breakpoints.ts +25 -8
  265. package/src/capabilities.d.mts +3 -0
  266. package/src/capabilities.mjs +18 -0
  267. package/src/connect-lifecycle.spec.ts +12 -0
  268. package/src/construct-vectors.spec.ts +175 -0
  269. package/src/elements/adw-application-window.ts +154 -0
  270. package/src/elements/adw-bin.ts +101 -0
  271. package/src/elements/adw-breakpoint-bin.ts +287 -0
  272. package/src/elements/adw-clamp-scrollable.ts +207 -0
  273. package/src/elements/adw-dialog.ts +19 -0
  274. package/src/elements/adw-layout-slot.ts +95 -0
  275. package/src/elements/adw-multi-layout-view.ts +326 -0
  276. package/src/elements/adw-preferences-row.ts +150 -0
  277. package/src/elements/adw-shortcuts-dialog.ts +52 -0
  278. package/src/elements/adw-shortcuts-item.ts +171 -0
  279. package/src/elements/adw-shortcuts-section.ts +86 -0
  280. package/src/elements/adw-sidebar.ts +42 -3
  281. package/src/elements/adw-switch-row.ts +28 -1
  282. package/src/elements/adw-tab-bar.ts +529 -0
  283. package/src/elements/adw-tab-button.ts +194 -0
  284. package/src/elements/adw-tab-overview.ts +1011 -0
  285. package/src/elements/adw-tab-view.ts +66 -145
  286. package/src/elements/adw-toggle-group.ts +20 -5
  287. package/src/elements/adw-view-stack.ts +18 -0
  288. package/src/elements/adw-view-switcher-sidebar.ts +332 -0
  289. package/src/elements/adw-window.ts +185 -11
  290. package/src/elements/checks.ts +35 -8
  291. package/src/elements/gtk-about-dialog.ts +811 -0
  292. package/src/elements/gtk-application-window.ts +108 -0
  293. package/src/elements/gtk-aspect-frame.ts +160 -0
  294. package/src/elements/gtk-button.ts +12 -0
  295. package/src/elements/gtk-calendar.ts +757 -0
  296. package/src/elements/gtk-center-box.ts +184 -0
  297. package/src/elements/gtk-color-dialog-button.ts +278 -0
  298. package/src/elements/gtk-column-view.ts +320 -0
  299. package/src/elements/gtk-drag-icon.ts +257 -0
  300. package/src/elements/gtk-drawing-area.ts +303 -0
  301. package/src/elements/gtk-editable-label.ts +204 -0
  302. package/src/elements/gtk-emoji-chooser.ts +542 -0
  303. package/src/elements/gtk-entry.ts +39 -5
  304. package/src/elements/gtk-expander.ts +301 -0
  305. package/src/elements/gtk-fixed.ts +99 -0
  306. package/src/elements/gtk-flow-box-child.ts +68 -0
  307. package/src/elements/gtk-flow-box.ts +480 -0
  308. package/src/elements/gtk-font-dialog-button.ts +432 -0
  309. package/src/elements/gtk-frame.ts +174 -0
  310. package/src/elements/gtk-gl-area.ts +476 -0
  311. package/src/elements/gtk-graphics-offload.ts +130 -0
  312. package/src/elements/gtk-grid-view.ts +168 -0
  313. package/src/elements/gtk-grid.ts +127 -0
  314. package/src/elements/gtk-header-bar.ts +273 -0
  315. package/src/elements/gtk-inscription.ts +387 -0
  316. package/src/elements/gtk-label.ts +19 -11
  317. package/src/elements/gtk-level-bar.ts +323 -0
  318. package/src/elements/gtk-link-button.ts +138 -0
  319. package/src/elements/gtk-list-box-row.ts +195 -0
  320. package/src/elements/gtk-list-box.ts +413 -0
  321. package/src/elements/gtk-list-view.ts +370 -0
  322. package/src/elements/gtk-media-controls.ts +509 -0
  323. package/src/elements/gtk-notebook.ts +664 -0
  324. package/src/elements/gtk-overlay.ts +149 -0
  325. package/src/elements/gtk-page-setup-unix-dialog.ts +420 -0
  326. package/src/elements/gtk-paned.ts +597 -0
  327. package/src/elements/gtk-password-entry.ts +170 -0
  328. package/src/elements/gtk-picture.ts +254 -0
  329. package/src/elements/gtk-popover-bin.ts +332 -0
  330. package/src/elements/gtk-popover-menu-bar.ts +355 -0
  331. package/src/elements/gtk-popover-menu.ts +339 -0
  332. package/src/elements/gtk-popover.ts +92 -10
  333. package/src/elements/gtk-print-unix-dialog.ts +989 -0
  334. package/src/elements/gtk-progress-bar.ts +24 -11
  335. package/src/elements/gtk-revealer.ts +406 -0
  336. package/src/elements/gtk-scale-button.ts +358 -0
  337. package/src/elements/gtk-scale.ts +492 -0
  338. package/src/elements/gtk-scrollbar.ts +528 -0
  339. package/src/elements/gtk-scrolled-window.ts +642 -0
  340. package/src/elements/gtk-search-bar.ts +200 -0
  341. package/src/elements/gtk-search-entry.ts +172 -0
  342. package/src/elements/gtk-separator.ts +52 -0
  343. package/src/elements/gtk-spin-button.ts +475 -0
  344. package/src/elements/gtk-spinner.ts +126 -0
  345. package/src/elements/gtk-stack-sidebar.ts +212 -0
  346. package/src/elements/gtk-stack-switcher.ts +279 -0
  347. package/src/elements/gtk-stack.ts +748 -0
  348. package/src/elements/gtk-switch.ts +52 -19
  349. package/src/elements/gtk-text-view.ts +290 -0
  350. package/src/elements/gtk-text.ts +219 -0
  351. package/src/elements/gtk-toggle-button.ts +239 -0
  352. package/src/elements/gtk-tree-expander.ts +243 -0
  353. package/src/elements/gtk-video.ts +423 -0
  354. package/src/elements/gtk-viewport.ts +277 -0
  355. package/src/elements/gtk-window-controls.ts +341 -0
  356. package/src/elements/gtk-window-handle.ts +221 -0
  357. package/src/elements/gtk-window.ts +366 -0
  358. package/src/elements/justification.ts +24 -0
  359. package/src/elements/popover-menu.ts +24 -0
  360. package/src/elements/roving-focus.ts +53 -21
  361. package/src/emoji-data.ts +577 -0
  362. package/src/entry-rows.spec.ts +31 -0
  363. package/src/font-description.ts +238 -0
  364. package/src/gtk-about-dialog.spec.ts +250 -0
  365. package/src/gtk-action-bar.spec.ts +89 -0
  366. package/src/gtk-application-window.spec.ts +107 -0
  367. package/src/gtk-aspect-frame.spec.ts +114 -0
  368. package/src/gtk-calendar.spec.ts +589 -0
  369. package/src/gtk-center-box.spec.ts +125 -0
  370. package/src/gtk-color-dialog-button.spec.ts +141 -0
  371. package/src/gtk-column-view.spec.ts +154 -0
  372. package/src/gtk-drag-icon.spec.ts +190 -0
  373. package/src/gtk-drawing-area.spec.ts +211 -0
  374. package/src/gtk-editable-label.spec.ts +190 -0
  375. package/src/gtk-emoji-chooser.spec.ts +173 -0
  376. package/src/gtk-entry.spec.ts +23 -0
  377. package/src/gtk-expander.spec.ts +170 -0
  378. package/src/gtk-fixed.spec.ts +97 -0
  379. package/src/gtk-flow-box.spec.ts +289 -0
  380. package/src/gtk-font-dialog-button.spec.ts +166 -0
  381. package/src/gtk-frame.spec.ts +119 -0
  382. package/src/gtk-gl-area.spec.ts +361 -0
  383. package/src/gtk-graphics-offload.spec.ts +119 -0
  384. package/src/gtk-grid-view.spec.ts +106 -0
  385. package/src/gtk-grid.spec.ts +122 -0
  386. package/src/gtk-header-bar.spec.ts +202 -0
  387. package/src/gtk-inscription.spec.ts +235 -0
  388. package/src/gtk-level-bar.spec.ts +199 -0
  389. package/src/gtk-link-button.spec.ts +117 -0
  390. package/src/gtk-list-box.spec.ts +422 -0
  391. package/src/gtk-list-view.spec.ts +203 -0
  392. package/src/gtk-media-controls.spec.ts +295 -0
  393. package/src/gtk-notebook.spec.ts +546 -0
  394. package/src/gtk-overlay.spec.ts +141 -0
  395. package/src/gtk-paned.spec.ts +267 -0
  396. package/src/gtk-password-entry.spec.ts +150 -0
  397. package/src/gtk-picture.spec.ts +172 -0
  398. package/src/gtk-popover-bin.spec.ts +229 -0
  399. package/src/gtk-popover-menu-bar.spec.ts +296 -0
  400. package/src/gtk-popover-menu.spec.ts +261 -0
  401. package/src/gtk-popover-role.spec.ts +138 -0
  402. package/src/gtk-popover.spec.ts +264 -0
  403. package/src/gtk-print-dialogs.spec.ts +251 -0
  404. package/src/gtk-revealer.spec.ts +164 -0
  405. package/src/gtk-scale-button.spec.ts +218 -0
  406. package/src/gtk-scale.spec.ts +213 -0
  407. package/src/gtk-scrollbar.spec.ts +244 -0
  408. package/src/gtk-scrolled-window.spec.ts +262 -0
  409. package/src/gtk-search-bar.spec.ts +179 -0
  410. package/src/gtk-search-entry.spec.ts +142 -0
  411. package/src/gtk-separator.spec.ts +74 -0
  412. package/src/gtk-spin-button.spec.ts +186 -0
  413. package/src/gtk-spinner.spec.ts +130 -0
  414. package/src/gtk-stack-sidebar.spec.ts +217 -0
  415. package/src/gtk-stack-switcher.spec.ts +249 -0
  416. package/src/gtk-stack.spec.ts +432 -0
  417. package/src/gtk-text-view.spec.ts +189 -0
  418. package/src/gtk-text.spec.ts +163 -0
  419. package/src/gtk-toggle-button.spec.ts +186 -0
  420. package/src/gtk-tree-expander.spec.ts +201 -0
  421. package/src/gtk-video.spec.ts +240 -0
  422. package/src/gtk-viewport.spec.ts +140 -0
  423. package/src/gtk-window-controls.spec.ts +232 -0
  424. package/src/gtk-window-handle.spec.ts +158 -0
  425. package/src/gtk-window.spec.ts +190 -0
  426. package/src/index.ts +9 -1
  427. package/src/keyboard-operable.spec.ts +33 -1
  428. package/src/list-view-dom.ts +121 -0
  429. package/src/namespace/adw.ts +12 -0
  430. package/src/namespace/gtk.ts +61 -0
  431. package/src/page-setup.ts +222 -0
  432. package/src/scroll-shading.ts +18 -1
  433. package/src/shared-tree-builder.ts +263 -21
  434. package/src/signals.ts +15 -0
  435. package/src/style-classes.spec.ts +9 -8
  436. package/src/styles.generated.ts +1 -1
  437. package/src/tab-chip.ts +200 -0
  438. package/src/template-classes.ts +45 -0
  439. package/src/test.browser.mts +152 -0
@@ -0,0 +1,184 @@
1
+ // <gtk-center-box> — Gtk.CenterBox: three children, pinned to the start, the centre and
2
+ // the end, with whatever space is left over between them.
3
+ //
4
+ // THREE SLOTS AND TWO PROPERTIES. `start-widget`, `center-widget` and `end-widget` are
5
+ // WIDGET-valued, so on this renderer they are SLOTS (gtkcenterbox.c:285-321) and the
6
+ // element reads each child's `slot=` to learn which of the three it is — which also makes
7
+ // the markup order irrelevant, where GTK's is not: `gtk_center_box_set_start_widget()`
8
+ // unparents whatever held that slot first (gtkcenterbox.c:380-403).
9
+ //
10
+ // `shrink-center-last` is the interesting one, and its DEFAULT is TRUE (gtkcenterbox.c:
11
+ // 322-336). TRUE shrinks the start and end children first, each down to its own minimum,
12
+ // and only then the centre; FALSE reverses that. GTK expresses the order as a clamp chain
13
+ // (gtkcenterlayout.c:144-170: the centre is measured against `shrink_center_last`, then
14
+ // the start and end against what is left). CSS flexbox has no priority — only WEIGHTS —
15
+ // and its resolution loop freezes an item at its minimum size and redistributes the
16
+ // remaining violation among the rest (CSS Flexbox § 9.7), so a large weight on the widgets
17
+ // that shrink first reproduces the order exactly: they reach their minimum long before the
18
+ // other moves at all, and the last one then absorbs the whole remainder. 100 and 1 are that
19
+ // ratio, not a tuned constant.
20
+ //
21
+ // `baseline-position` says where a baseline-aligned child sits when the box has extra
22
+ // space. GTK's own default is the CENTRE position and every child's default `valign` is
23
+ // FILL, which is what the stylesheet's `align-items: stretch` already draws — so the
24
+ // attribute is read only when it is AUTHORED, and its three nicks map to the same three
25
+ // `align-items` zones `xalign` / `yalign` use in `<gtk-aspect-frame>`. A single-line flex
26
+ // container has nowhere to put a baseline line, so this is a DECLARED divergence, not an
27
+ // exact one.
28
+ //
29
+ // `gtk_center_box_set_layout_manager_type(GTK_TYPE_CENTER_LAYOUT)` plus the CSS name
30
+ // `box` (gtkcenterbox.c:344-345) mean the theme's `box` rule styles it — libadwaita ships
31
+ // no `box` rule at all, so the browser port draws no gap of its own and the spacing is
32
+ // whatever `gap` the author writes, exactly as a bare `Gtk.Box` with `spacing: 0` does.
33
+ //
34
+ // A11Y: `role="generic"`, GtkCenterBox's own accessible role (gtkcenterbox.c:346).
35
+ //
36
+ // Reference: refs/gtk/gtk/gtkcenterbox.c:267-346, :371-430
37
+ // Reference: refs/gtk/gtk/gtkcenterlayout.c:144-186
38
+ // Copyright (c) The GTK Team. LGPLv2.1+.
39
+ // Modifications: Implemented as a Web Component for @gjsify/adwaita-web.
40
+
41
+ import { labelYalignAlignItems } from '@gjsify/adwaita-core';
42
+
43
+ import { bindSlottedChildren } from '../slotted-children.js';
44
+
45
+ /** `Gtk.BaselinePosition`'s three nicks, in the order GTK measures them (gtkcenterbox.c:267-271). */
46
+ const BASELINE_POSITIONS = { top: 0, center: 0.5, bottom: 1 } as const;
47
+
48
+ export type BaselinePosition = keyof typeof BASELINE_POSITIONS;
49
+
50
+ /** The weight split `shrink-center-last` is a ratio of; the ORDER is what carries it. */
51
+ const SHRINK_FIRST = 100;
52
+ const SHRINK_LAST = 1;
53
+
54
+ export class GtkCenterBox extends HTMLElement {
55
+ static get observedAttributes() {
56
+ return ['baseline-position', 'shrink-center-last'];
57
+ }
58
+
59
+ /**
60
+ * `Gtk.CenterBox:baseline-position` — `top`, `center` (the pspec default) or `bottom`.
61
+ * An unknown nick is the default, the same answer an enum nick GTK does not know gets.
62
+ */
63
+ get baselinePosition(): BaselinePosition {
64
+ const raw = this.getAttribute('baseline-position');
65
+ return raw !== null && raw in BASELINE_POSITIONS ? (raw as BaselinePosition) : 'center';
66
+ }
67
+
68
+ set baselinePosition(value: BaselinePosition) {
69
+ this.setAttribute('baseline-position', value);
70
+ }
71
+
72
+ /**
73
+ * `Gtk.CenterBox:shrink-center-last` — TRUE (the pspec default, gtkcenterbox.c:330-333)
74
+ * shrinks the start and end children before the centre; FALSE shrinks the centre first.
75
+ * The default is the AFFIRMATIVE one, so it is the ABSENCE of the attribute — a bare
76
+ * `<gtk-center-box>` is a TRUE box, and `shrink-center-last="false"` is what turns it off.
77
+ */
78
+ get shrinkCenterLast(): boolean {
79
+ const raw = this.getAttribute('shrink-center-last');
80
+ return raw === null || (raw !== 'false' && raw !== '0');
81
+ }
82
+
83
+ set shrinkCenterLast(value: boolean) {
84
+ if (value) this.removeAttribute('shrink-center-last');
85
+ else this.setAttribute('shrink-center-last', 'false');
86
+ }
87
+
88
+ /** `Gtk.CenterBox:start-widget` — the child pinned to the start. */
89
+ get startWidget(): HTMLElement | null {
90
+ return this.querySelector<HTMLElement>('[slot="start-widget"]');
91
+ }
92
+
93
+ set startWidget(value: HTMLElement | null) {
94
+ this._assign('start-widget', value);
95
+ }
96
+
97
+ /** `Gtk.CenterBox:center-widget` — the child that takes the space between the other two. */
98
+ get centerWidget(): HTMLElement | null {
99
+ return this.querySelector<HTMLElement>('[slot="center-widget"]');
100
+ }
101
+
102
+ set centerWidget(value: HTMLElement | null) {
103
+ this._assign('center-widget', value);
104
+ }
105
+
106
+ /** `Gtk.CenterBox:end-widget` — the child pinned to the end. */
107
+ get endWidget(): HTMLElement | null {
108
+ return this.querySelector<HTMLElement>('[slot="end-widget"]');
109
+ }
110
+
111
+ set endWidget(value: HTMLElement | null) {
112
+ this._assign('end-widget', value);
113
+ }
114
+
115
+ connectedCallback() {
116
+ // The three NAMES, so an authored tree may address them. Nothing is MOVED: the box
117
+ // places its children by their `slot=`, so the author's order is not the layout's,
118
+ // and moving them would only fight a renderer that appends them back.
119
+ bindSlottedChildren(this, [
120
+ { name: 'start-widget', into: this },
121
+ { name: 'center-widget', into: this },
122
+ { name: 'end-widget', into: this },
123
+ ]);
124
+ this.setAttribute('role', 'generic');
125
+ this._sync();
126
+ }
127
+
128
+ attributeChangedCallback(name: string, old: string | null, value: string | null) {
129
+ this._sync();
130
+ if (!this.isConnected) return;
131
+ const next = this._normalized(name, value);
132
+ if (next === this._normalized(name, old)) return;
133
+ this.dispatchEvent(new CustomEvent(`notify::${name}`, { bubbles: true, detail: { [name]: next } }));
134
+ }
135
+
136
+ private _normalized(name: string, raw: string | null): boolean | string {
137
+ if (name === 'shrink-center-last') return raw === null || (raw !== 'false' && raw !== '0');
138
+ return raw !== null && raw in BASELINE_POSITIONS ? raw : 'center';
139
+ }
140
+
141
+ private _assign(slot: string, value: HTMLElement | null): void {
142
+ const current = this.querySelector(`[slot="${slot}"]`);
143
+ if (current !== null) {
144
+ current.removeAttribute('slot');
145
+ // `set_start_widget(NULL)` UNPARENTS the child (gtkcenterbox.c:391-393), and an
146
+ // element left behind as an unnamed one would be a fourth slot this widget does
147
+ // not have — GtkCenterBox's buildable refuses an untyped child (gtkcenterbox.c:110-135).
148
+ current.remove();
149
+ }
150
+ if (value !== null) {
151
+ value.setAttribute('slot', slot);
152
+ this.append(value);
153
+ }
154
+ // The new child needs its shrink weight, which `_sync` reads off the slot names.
155
+ this._sync();
156
+ }
157
+
158
+ private _sync(): void {
159
+ const centerShrinksLast = this.shrinkCenterLast;
160
+ for (const child of this.children) {
161
+ const role = child.getAttribute('slot');
162
+ // An unnamed child is not one of the three slots — GtkCenterBox's buildable
163
+ // refuses an untyped child (gtkcenterbox.c:110-135) — so it takes the weight of a
164
+ // widget that shrinks LAST and keeps whatever position the author gave it.
165
+ const shrinksFirst =
166
+ role === 'center-widget'
167
+ ? !centerShrinksLast
168
+ : role === 'start-widget' || role === 'end-widget'
169
+ ? centerShrinksLast
170
+ : false;
171
+ (child as HTMLElement).style.flexShrink = String(shrinksFirst ? SHRINK_FIRST : SHRINK_LAST);
172
+ }
173
+ // Only when AUTHORED: GTK's default position is `center` and a box of FILL children
174
+ // already draws stretched, which is the stylesheet's `align-items`. Writing it
175
+ // unconditionally would make the default position change the default look.
176
+ if (this.hasAttribute('baseline-position')) {
177
+ this.style.alignItems = labelYalignAlignItems(BASELINE_POSITIONS[this.baselinePosition]);
178
+ } else {
179
+ this.style.removeProperty('align-items');
180
+ }
181
+ }
182
+ }
183
+
184
+ customElements.define('gtk-center-box', GtkCenterBox);
@@ -0,0 +1,278 @@
1
+ // <gtk-color-dialog-button> — a button that shows a colour and opens a chooser for it.
2
+ // GTK's is a `GtkWidget` holding a plain `GtkButton` whose CHILD is a `GtkColorSwatch`
3
+ // (gtkcolordialogbutton.c:126-171), with the CSS node `colorbutton > button.color`.
4
+ // This element builds the same three nodes: the host, the button, the swatch.
5
+ //
6
+ // `rgba` is the colour, and `dialog` the chooser it opens. The C's sensitivity rule is
7
+ // `self->dialog != NULL && self->cancellable == NULL` (:384-390), and BOTH halves matter:
8
+ // a button with no dialog is insensitive, and so is one while a chooser is already up.
9
+ //
10
+ // WHAT THE DIALOG IS HERE. `GtkColorDialog` is a GObject carrying three parameters —
11
+ // `modal` (TRUE), `title` (NULL) and `with-alpha` (TRUE) — and presenting it is GTK's
12
+ // job. A browser has one colour chooser and no parameters for it, so:
13
+ // · `dialog` accepts those three as a plain bag, and the two a browser can honour are
14
+ // honoured: `title` becomes the picker's title and `withAlpha: false` says the button
15
+ // will not carry a translucent colour, which is what `with-alpha` decides.
16
+ // · the chooser is `<input type="color">`, and it has NO alpha channel — so a colour
17
+ // chosen in it keeps the alpha the button already had. `withAlpha` is therefore not
18
+ // observable here and says so in the header rather than pretending otherwise.
19
+ // · the SECOND half of the sensitivity rule is not reproduced: the platform picker is
20
+ // modal and reports no "still open" state, so `_pending` only stops a second click
21
+ // from opening a second picker. That is a strictly weaker guarantee than
22
+ // `cancellable` and the reason is the platform's, not a choice.
23
+ //
24
+ // `update_button_sensitivity`'s dialog half IS reproduced exactly, which is why the
25
+ // button is dead out of the box: `dialog` has to be set, from markup with the attribute
26
+ // or from code with the property.
27
+ //
28
+ // The swatch's accessible name is GTK's sentence, `accessible_color_name` (:334-347):
29
+ // `Red 75%, Green 25%, Blue 25%`, with `, Alpha 50%` appended while the colour is
30
+ // translucent — and `scale_round` is transcribed with it, `floor (value * 100 + 0.5)`
31
+ // clamped into 0…100 (:329-333), because a colour announced as "Red 75%" and drawn as
32
+ // 75.4% is a mismatch a reader can hear.
33
+ //
34
+ // Reference: refs/gtk/gtk/gtkcolordialogbutton.c (rgba, dialog, the sensitivity rule, the
35
+ // accessible name, the swatch)
36
+ // Reference: refs/gtk/gtk/gtkcolordialog.c (the three parameters a GtkColorDialog holds)
37
+ // Reference: refs/libadwaita/src/stylesheet/widgets/_linked.scss:6 (`colorbutton > button`)
38
+ // Copyright (c) GNOME contributors (libadwaita). LGPLv2.1+.
39
+ // Modifications: Implemented as a Web Component for @gjsify/adwaita-web.
40
+
41
+ /** A `GdkRGBA` — the four channels of `GtkColorDialogButton:rgba`, each 0…1. */
42
+ export interface GdkRgbaValue {
43
+ red: number;
44
+ green: number;
45
+ blue: number;
46
+ alpha: number;
47
+ }
48
+
49
+ /**
50
+ * `GtkColorDialog`'s three parameters, under the property names. `filter` and `font-map`
51
+ * are font dialog's; the colour one holds exactly these.
52
+ */
53
+ export interface ColorDialogParameters {
54
+ /** Whether the chooser is modal. Default `TRUE`, as in the GIR. */
55
+ modal?: boolean;
56
+ /** The chooser's title. Default `null`. */
57
+ title?: string | null;
58
+ /** Whether colours may carry alpha. Default `TRUE`, as in the GIR. */
59
+ withAlpha?: boolean;
60
+ }
61
+
62
+ /** `gtk_color_dialog_button_init`'s own colour: `{ 0.75, 0.25, 0.25, 1.0 }` (:170). */
63
+ const INITIAL_RGBA: GdkRgbaValue = { red: 0.75, green: 0.25, blue: 0.25, alpha: 1 };
64
+
65
+ export class GtkColorDialogButton extends HTMLElement {
66
+ private _buttonEl!: HTMLButtonElement;
67
+ private _swatchEl!: HTMLSpanElement;
68
+ private _inputEl!: HTMLInputElement;
69
+ private _dialog: ColorDialogParameters | null = null;
70
+ private _rgba: GdkRgbaValue = { ...INITIAL_RGBA };
71
+ /** `self->cancellable != NULL` — a chooser run is in progress (:396-419). */
72
+ private _pending = false;
73
+ private _initialized = false;
74
+
75
+ static get observedAttributes() {
76
+ return ['rgba', 'dialog', 'disabled'];
77
+ }
78
+
79
+ /** `GtkColorDialogButton:rgba` — the selected colour. */
80
+ get rgba(): GdkRgbaValue {
81
+ return { ...this._rgba };
82
+ }
83
+
84
+ set rgba(value: string | GdkRgbaValue) {
85
+ const next = typeof value === 'string' ? parseCssColor(value) : value;
86
+ // `gtk_color_dialog_button_set_rgba` returns early when `gdk_rgba_equal` holds
87
+ // (:520-522): a write of the colour already shown is not a change.
88
+ if (next === null || rgbaEqual(next, this._rgba)) return;
89
+ this._rgba = next;
90
+ this._renderSwatch();
91
+ this.dispatchEvent(new CustomEvent('notify::rgba', { bubbles: true, detail: { rgba: this.rgba } }));
92
+ }
93
+
94
+ /** `GtkColorDialogButton:dialog` — the chooser this button opens, or `null` for none. */
95
+ get dialog(): ColorDialogParameters | null {
96
+ return this._dialog;
97
+ }
98
+
99
+ set dialog(value: ColorDialogParameters | null) {
100
+ // `g_set_object` + an early return (:508-512): the same dialog twice is not a
101
+ // change, and the notify follows the change rather than the assignment.
102
+ if (this._dialog === value) return;
103
+ this._dialog = value;
104
+ if (value?.title != null) this._inputEl.title = value.title;
105
+ this._renderSensitivity();
106
+ this.dispatchEvent(new CustomEvent('notify::dialog', { bubbles: true, detail: { dialog: value } }));
107
+ }
108
+
109
+ connectedCallback() {
110
+ if (this._initialized) return;
111
+ this._initialized = true;
112
+ this.setAttribute('role', 'group');
113
+
114
+ this._swatchEl = document.createElement('span');
115
+ this._swatchEl.className = 'color-button-swatch';
116
+
117
+ this._buttonEl = document.createElement('button');
118
+ this._buttonEl.type = 'button';
119
+ // `gtk_widget_add_css_class (self->button, "color")` (:163).
120
+ this._buttonEl.className = 'adw-button color icon-only';
121
+ // GTK marks the button HAS_POPUP (:174-176).
122
+ this._buttonEl.setAttribute('aria-haspopup', 'dialog');
123
+ this._buttonEl.appendChild(this._swatchEl);
124
+
125
+ // A SIBLING of the button, not its child: an interactive control inside a `<button>`
126
+ // is not content the HTML parser or the a11y tree can make sense of.
127
+ this._inputEl = document.createElement('input');
128
+ this._inputEl.type = 'color';
129
+ this._inputEl.className = 'color-button-input';
130
+ this._inputEl.tabIndex = -1;
131
+ this._inputEl.setAttribute('aria-hidden', 'true');
132
+
133
+ this.replaceChildren(this._buttonEl, this._inputEl);
134
+
135
+ this._buttonEl.addEventListener('click', () => this.activate());
136
+ this._inputEl.addEventListener('change', () => {
137
+ this._pending = false;
138
+ // The input carries no alpha channel, so the chosen colour keeps the alpha the
139
+ // button already had — which is what `GtkColorDialog:with_alpha` decides, and
140
+ // the only half of it a browser colour picker can honour.
141
+ const chosen = parseCssColor(this._inputEl.value);
142
+ if (chosen !== null) this.rgba = { ...chosen, alpha: this._rgba.alpha };
143
+ this._renderSensitivity();
144
+ });
145
+
146
+ // The attribute door: a bare `dialog` means a chooser with the GIR's own defaults.
147
+ if (this.hasAttribute('dialog')) this.dialog = {};
148
+ const authored = this.getAttribute('rgba');
149
+ if (authored !== null) this.rgba = authored;
150
+ this._renderSwatch();
151
+ this._renderSensitivity();
152
+ }
153
+
154
+ attributeChangedCallback(name?: string) {
155
+ if (!this._initialized) return;
156
+ if (name === 'rgba') {
157
+ const authored = this.getAttribute('rgba');
158
+ if (authored !== null) this.rgba = authored;
159
+ return;
160
+ }
161
+ if (name === 'dialog') {
162
+ this.dialog = this.hasAttribute('dialog') ? (this._dialog ?? {}) : null;
163
+ return;
164
+ }
165
+ this._renderSensitivity();
166
+ }
167
+
168
+ /**
169
+ * The `::activate` action signal (:283-296), which `activated()` binds straight to
170
+ * `gtk_widget_activate (self->button)` (:378-382): pressing the button and activating
171
+ * the widget are the same thing, and both pop the chooser.
172
+ */
173
+ activate(): void {
174
+ this.dispatchEvent(new CustomEvent('activate', { bubbles: true }));
175
+ this._choose();
176
+ }
177
+
178
+ /** `button_clicked` (:394-419) — the whole run, and it is one guard deep. */
179
+ private _choose(): void {
180
+ if (this._dialog === null || this._pending) return;
181
+ this._pending = true;
182
+ this._renderSensitivity();
183
+ // The input holds no alpha, so it is seeded with the opaque part and the alpha the
184
+ // button had comes back untouched when `change` reads only `value`.
185
+ this._inputEl.value = formatHex(this._rgba);
186
+ this._inputEl.click();
187
+ }
188
+
189
+ /** `update_button_sensitivity` (:380-391), with the run guard explained in the header. */
190
+ private _renderSensitivity(): void {
191
+ const sensitive = this._dialog !== null && !this.hasAttribute('disabled');
192
+ this._buttonEl.disabled = !sensitive;
193
+ this._buttonEl.classList.toggle('disabled', !sensitive);
194
+ }
195
+
196
+ private _renderSwatch(): void {
197
+ this._swatchEl.style.backgroundColor = formatCssColor(this._rgba);
198
+ // The checkerboard behind a translucent colour is GtkColorSwatch's own drawing;
199
+ // `data-translucent` is what `_color_button.scss` keys it on.
200
+ this._swatchEl.dataset.translucent = String(this._rgba.alpha < 1);
201
+ // `accessible_color_name` (:334-347), on the swatch as on the C, and on the button
202
+ // beside it — a swatch with a name inside a button with none announces nothing.
203
+ const name = describeColor(this._rgba);
204
+ this._swatchEl.setAttribute('aria-label', name);
205
+ this._buttonEl.setAttribute('aria-label', name);
206
+ }
207
+ }
208
+
209
+ customElements.define('gtk-color-dialog-button', GtkColorDialogButton);
210
+
211
+ /** `gdk_rgba_equal` — four exact comparisons, so a write of the same colour is not one. */
212
+ export function rgbaEqual(a: GdkRgbaValue, b: GdkRgbaValue): boolean {
213
+ return a.red === b.red && a.green === b.green && a.blue === b.blue && a.alpha === b.alpha;
214
+ }
215
+
216
+ /**
217
+ * `scale_round` (:329-333) — `floor (value * scale + 0.5)`, clamped into 0…scale.
218
+ */
219
+ export function scaleRound(value: number, scale: number): number {
220
+ return Math.min(scale, Math.max(0, Math.floor(value * scale + 0.5)));
221
+ }
222
+
223
+ /** `accessible_color_name` (:334-347), with the Alpha clause only while it is translucent. */
224
+ export function describeColor(color: GdkRgbaValue): string {
225
+ const parts = [
226
+ `Red ${scaleRound(color.red, 100)}%`,
227
+ `Green ${scaleRound(color.green, 100)}%`,
228
+ `Blue ${scaleRound(color.blue, 100)}%`,
229
+ ];
230
+ if (color.alpha < 1) parts.push(`Alpha ${scaleRound(color.alpha, 100)}%`);
231
+ return parts.join(', ');
232
+ }
233
+
234
+ /** `#rrggbb` for an opaque colour and `rgba(...)` for a translucent one — the two an author writes. */
235
+ export function formatHex(color: GdkRgbaValue): string {
236
+ const channel = (value: number) =>
237
+ Math.round(Math.min(1, Math.max(0, value)) * 255)
238
+ .toString(16)
239
+ .padStart(2, '0');
240
+ return `#${channel(color.red)}${channel(color.green)}${channel(color.blue)}`;
241
+ }
242
+
243
+ function formatCssColor(color: GdkRgbaValue): string {
244
+ const hex = formatHex(color);
245
+ return color.alpha < 1
246
+ ? `${hex}${Math.round(color.alpha * 255)
247
+ .toString(16)
248
+ .padStart(2, '0')}`
249
+ : hex;
250
+ }
251
+
252
+ const CSS_COLOR = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i;
253
+
254
+ /**
255
+ * Any CSS colour the browser understands → a `GdkRGBA`.
256
+ *
257
+ * The PARSE IS THE BROWSER'S, through CSSOM: an unrecognised value leaves
258
+ * `style.color` empty, and a recognised one comes back normalised to `rgb()`/`rgba()`.
259
+ * That is why `#abc`, `hsl()`, `color-mix()` and a named colour all work here without a
260
+ * second parser — and why the one thing that cannot be parsed is refused rather than
261
+ * guessed at, which is what the C's `G_IS_VALUE`/`gdk_rgba_parse` pair does.
262
+ */
263
+ export function parseCssColor(value: string): GdkRgbaValue | null {
264
+ const probe = document.createElement('span');
265
+ probe.style.color = '';
266
+ probe.style.color = value.trim();
267
+ const normalized = probe.style.color;
268
+ if (normalized === '') return null;
269
+ const match = CSS_COLOR.exec(normalized);
270
+ if (match === null) return null;
271
+ const alpha = match[4];
272
+ return {
273
+ red: Number(match[1]) / 255,
274
+ green: Number(match[2]) / 255,
275
+ blue: Number(match[3]) / 255,
276
+ alpha: alpha === undefined ? 1 : alpha.endsWith('%') ? Number.parseFloat(alpha) / 100 : Number(alpha),
277
+ };
278
+ }