@cloudfrogger/goodui 0.0.60 → 0.0.63

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 (400) hide show
  1. package/README.md +10 -0
  2. package/ai/README.md +47 -0
  3. package/ai/case-studies/index.md +10 -0
  4. package/ai/case-studies/vpshoster.md +18 -0
  5. package/ai/case-studies/webmailer.md +21 -0
  6. package/ai/catalog/README.md +7 -0
  7. package/ai/catalog/component.schema.json +289 -0
  8. package/ai/catalog/components/div-goodDetailRow.json +33 -0
  9. package/ai/catalog/components/form-goodForm.json +84 -0
  10. package/ai/catalog/components/good-action-bar.json +83 -0
  11. package/ai/catalog/components/good-action-group.json +143 -0
  12. package/ai/catalog/components/good-action-menu.json +121 -0
  13. package/ai/catalog/components/good-alert.json +184 -0
  14. package/ai/catalog/components/good-app-layout.json +247 -0
  15. package/ai/catalog/components/good-assistant-body.json +43 -0
  16. package/ai/catalog/components/good-assistant-footer.json +43 -0
  17. package/ai/catalog/components/good-assistant-header.json +43 -0
  18. package/ai/catalog/components/good-assistant-main.json +61 -0
  19. package/ai/catalog/components/good-assistant-mobile.json +43 -0
  20. package/ai/catalog/components/good-assistant-panel.json +131 -0
  21. package/ai/catalog/components/good-avatar-menu-item.json +82 -0
  22. package/ai/catalog/components/good-avatar-menu.json +83 -0
  23. package/ai/catalog/components/good-badge.json +180 -0
  24. package/ai/catalog/components/good-bar-chart.json +118 -0
  25. package/ai/catalog/components/good-brand-icon.json +71 -0
  26. package/ai/catalog/components/good-breadcrumbs.json +102 -0
  27. package/ai/catalog/components/good-button.json +192 -0
  28. package/ai/catalog/components/good-calendar.json +430 -0
  29. package/ai/catalog/components/good-card-footer.json +63 -0
  30. package/ai/catalog/components/good-card-header.json +100 -0
  31. package/ai/catalog/components/good-card.json +57 -0
  32. package/ai/catalog/components/good-chart-axis.json +168 -0
  33. package/ai/catalog/components/good-chart-bar.json +89 -0
  34. package/ai/catalog/components/good-chart-histogram.json +78 -0
  35. package/ai/catalog/components/good-chart-line.json +89 -0
  36. package/ai/catalog/components/good-chart-scatter.json +87 -0
  37. package/ai/catalog/components/good-checkbox.json +171 -0
  38. package/ai/catalog/components/good-citation.json +62 -0
  39. package/ai/catalog/components/good-code-block.json +116 -0
  40. package/ai/catalog/components/good-color-controls.json +58 -0
  41. package/ai/catalog/components/good-color-picker.json +141 -0
  42. package/ai/catalog/components/good-column.json +53 -0
  43. package/ai/catalog/components/good-columns.json +77 -0
  44. package/ai/catalog/components/good-date-input.json +386 -0
  45. package/ai/catalog/components/good-detail-list.json +43 -0
  46. package/ai/catalog/components/good-dropdown.json +259 -0
  47. package/ai/catalog/components/good-error-page.json +133 -0
  48. package/ai/catalog/components/good-error-text.json +43 -0
  49. package/ai/catalog/components/good-expandable.json +159 -0
  50. package/ai/catalog/components/good-eyebrow.json +61 -0
  51. package/ai/catalog/components/good-field-label.json +62 -0
  52. package/ai/catalog/components/good-form-field.json +67 -0
  53. package/ai/catalog/components/good-form-row.json +70 -0
  54. package/ai/catalog/components/good-group.json +150 -0
  55. package/ai/catalog/components/good-heading-group.json +45 -0
  56. package/ai/catalog/components/good-heading.json +69 -0
  57. package/ai/catalog/components/good-hint.json +43 -0
  58. package/ai/catalog/components/good-histogram.json +103 -0
  59. package/ai/catalog/components/good-icon.json +97 -0
  60. package/ai/catalog/components/good-image-input.json +190 -0
  61. package/ai/catalog/components/good-image-preview.json +97 -0
  62. package/ai/catalog/components/good-inline-image.json +131 -0
  63. package/ai/catalog/components/good-input-phone.json +226 -0
  64. package/ai/catalog/components/good-input.json +350 -0
  65. package/ai/catalog/components/good-line-chart.json +94 -0
  66. package/ai/catalog/components/good-link.json +147 -0
  67. package/ai/catalog/components/good-listbox.json +248 -0
  68. package/ai/catalog/components/good-main-menu.json +140 -0
  69. package/ai/catalog/components/good-main-view.json +179 -0
  70. package/ai/catalog/components/good-map-color-scale.json +163 -0
  71. package/ai/catalog/components/good-map-overlay.json +136 -0
  72. package/ai/catalog/components/good-modal-footer.json +63 -0
  73. package/ai/catalog/components/good-modal-header.json +73 -0
  74. package/ai/catalog/components/good-modal.json +131 -0
  75. package/ai/catalog/components/good-month-calendar.json +170 -0
  76. package/ai/catalog/components/good-notification-host.json +46 -0
  77. package/ai/catalog/components/good-notifications.json +72 -0
  78. package/ai/catalog/components/good-number-input.json +180 -0
  79. package/ai/catalog/components/good-paragraph.json +47 -0
  80. package/ai/catalog/components/good-pdf-preview.json +153 -0
  81. package/ai/catalog/components/good-pin-input.json +211 -0
  82. package/ai/catalog/components/good-progress.json +158 -0
  83. package/ai/catalog/components/good-prose.json +43 -0
  84. package/ai/catalog/components/good-radio-group.json +181 -0
  85. package/ai/catalog/components/good-range-slider.json +285 -0
  86. package/ai/catalog/components/good-rating.json +160 -0
  87. package/ai/catalog/components/good-resizable-pane.json +61 -0
  88. package/ai/catalog/components/good-resizable.json +185 -0
  89. package/ai/catalog/components/good-rich-text-editor.json +164 -0
  90. package/ai/catalog/components/good-scatter-chart.json +94 -0
  91. package/ai/catalog/components/good-search.json +60 -0
  92. package/ai/catalog/components/good-section.json +43 -0
  93. package/ai/catalog/components/good-select-country.json +205 -0
  94. package/ai/catalog/components/good-select-font.json +111 -0
  95. package/ai/catalog/components/good-select.json +217 -0
  96. package/ai/catalog/components/good-separator.json +59 -0
  97. package/ai/catalog/components/good-settings.json +60 -0
  98. package/ai/catalog/components/good-sidebar-container.json +112 -0
  99. package/ai/catalog/components/good-sidebar-item.json +210 -0
  100. package/ai/catalog/components/good-sidebar-menu-container.json +80 -0
  101. package/ai/catalog/components/good-sidebar-submenu-group.json +98 -0
  102. package/ai/catalog/components/good-sidebar-submenu-item.json +113 -0
  103. package/ai/catalog/components/good-signature-pad.json +115 -0
  104. package/ai/catalog/components/good-sparkline.json +188 -0
  105. package/ai/catalog/components/good-status-icon.json +425 -0
  106. package/ai/catalog/components/good-subheading.json +67 -0
  107. package/ai/catalog/components/good-subnav.json +132 -0
  108. package/ai/catalog/components/good-summary.json +43 -0
  109. package/ai/catalog/components/good-switch.json +167 -0
  110. package/ai/catalog/components/good-tab.json +129 -0
  111. package/ai/catalog/components/good-table.json +294 -0
  112. package/ai/catalog/components/good-tabs.json +90 -0
  113. package/ai/catalog/components/good-textarea.json +194 -0
  114. package/ai/catalog/components/good-theme-toggle.json +57 -0
  115. package/ai/catalog/components/good-timeline-section.json +105 -0
  116. package/ai/catalog/components/good-timeline-step.json +248 -0
  117. package/ai/catalog/components/good-timeline.json +302 -0
  118. package/ai/catalog/components/good-topbar-dropdown-item.json +115 -0
  119. package/ai/catalog/components/good-topbar-dropdown-menu.json +85 -0
  120. package/ai/catalog/components/good-topbar-menu-container.json +96 -0
  121. package/ai/catalog/components/good-topbar-menu-item.json +99 -0
  122. package/ai/catalog/components/good-topbar-submenu.json +77 -0
  123. package/ai/catalog/components/good-topbar.json +259 -0
  124. package/ai/catalog/components/good-world-map.json +145 -0
  125. package/ai/catalog/components/goodCardActions.json +33 -0
  126. package/ai/catalog/components/goodDropdownFooter.json +33 -0
  127. package/ai/catalog/components/goodDropdownHeader.json +33 -0
  128. package/ai/catalog/components/goodExpandableHeader.json +33 -0
  129. package/ai/catalog/components/ng-template-goodListboxItem.json +33 -0
  130. package/ai/catalog/components/ng-template-goodTableCell.json +43 -0
  131. package/ai/catalog/index.json +1484 -0
  132. package/ai/catalog/index.schema.json +13 -0
  133. package/ai/examples/angular.json +26 -0
  134. package/ai/examples/edit-form.html +13 -0
  135. package/ai/examples/edit-form.ts +18 -0
  136. package/ai/examples/index.html +1 -0
  137. package/ai/examples/login.html +11 -0
  138. package/ai/examples/login.ts +14 -0
  139. package/ai/examples/main.ts +25 -0
  140. package/ai/examples/settings.html +10 -0
  141. package/ai/examples/settings.ts +13 -0
  142. package/ai/examples/table-view.html +3 -0
  143. package/ai/examples/table-view.ts +21 -0
  144. package/ai/examples/tsconfig.json +27 -0
  145. package/ai/guides/common-mistakes.md +9 -0
  146. package/ai/guides/component-discovery.md +19 -0
  147. package/ai/guides/design-tokens.md +10 -0
  148. package/ai/guides/layout.md +19 -0
  149. package/ai/guides/page-patterns.md +39 -0
  150. package/ai/install.mjs +25 -0
  151. package/ai/manifest.json +6 -0
  152. package/ai/skill/goodui/SKILL.md +27 -0
  153. package/angular/projects/goodui/package.json +28 -0
  154. package/angular/projects/goodui/src/action-bar.css +20 -0
  155. package/angular/projects/goodui/src/assistant-panel.css +38 -0
  156. package/angular/projects/goodui/src/calendar.css +161 -0
  157. package/angular/projects/goodui/src/chart.css +35 -0
  158. package/angular/projects/goodui/src/color-picker.css +40 -0
  159. package/angular/projects/goodui/src/error-page.css +24 -0
  160. package/angular/projects/goodui/src/lib/action-bar.ts +161 -0
  161. package/angular/projects/goodui/src/lib/action-group.ts +31 -0
  162. package/angular/projects/goodui/src/lib/action-menu.ts +81 -0
  163. package/angular/projects/goodui/src/lib/actions.ts +320 -0
  164. package/angular/projects/goodui/src/lib/alert.ts +60 -0
  165. package/angular/projects/goodui/src/lib/app-layout.ts +84 -0
  166. package/angular/projects/goodui/src/lib/assistant-panel.ts +133 -0
  167. package/angular/projects/goodui/src/lib/badge.ts +47 -0
  168. package/angular/projects/goodui/src/lib/bar-chart.html +80 -0
  169. package/angular/projects/goodui/src/lib/bar-chart.ts +233 -0
  170. package/angular/projects/goodui/src/lib/breadcrumbs.ts +81 -0
  171. package/angular/projects/goodui/src/lib/button.ts +38 -0
  172. package/angular/projects/goodui/src/lib/calendar-layout.ts +68 -0
  173. package/angular/projects/goodui/src/lib/calendar-service.ts +144 -0
  174. package/angular/projects/goodui/src/lib/calendar-working-hours.ts +65 -0
  175. package/angular/projects/goodui/src/lib/calendar.html +200 -0
  176. package/angular/projects/goodui/src/lib/calendar.ts +471 -0
  177. package/angular/projects/goodui/src/lib/card.ts +64 -0
  178. package/angular/projects/goodui/src/lib/chart-colors.ts +22 -0
  179. package/angular/projects/goodui/src/lib/chart-data.ts +269 -0
  180. package/angular/projects/goodui/src/lib/checkbox.ts +87 -0
  181. package/angular/projects/goodui/src/lib/code-block.ts +147 -0
  182. package/angular/projects/goodui/src/lib/color-controls.ts +107 -0
  183. package/angular/projects/goodui/src/lib/color-picker.ts +142 -0
  184. package/angular/projects/goodui/src/lib/color-utils.ts +69 -0
  185. package/angular/projects/goodui/src/lib/country-data.ts +16 -0
  186. package/angular/projects/goodui/src/lib/date-input.ts +542 -0
  187. package/angular/projects/goodui/src/lib/dropdown.ts +309 -0
  188. package/angular/projects/goodui/src/lib/error-page.ts +46 -0
  189. package/angular/projects/goodui/src/lib/expandable.ts +64 -0
  190. package/angular/projects/goodui/src/lib/form.ts +12 -0
  191. package/angular/projects/goodui/src/lib/goodui-config.ts +16 -0
  192. package/angular/projects/goodui/src/lib/group.ts +45 -0
  193. package/angular/projects/goodui/src/lib/histogram.html +52 -0
  194. package/angular/projects/goodui/src/lib/histogram.ts +146 -0
  195. package/angular/projects/goodui/src/lib/icon.ts +44 -0
  196. package/angular/projects/goodui/src/lib/image-input.ts +154 -0
  197. package/angular/projects/goodui/src/lib/image-preview.ts +26 -0
  198. package/angular/projects/goodui/src/lib/input-phone.ts +305 -0
  199. package/angular/projects/goodui/src/lib/input.ts +143 -0
  200. package/angular/projects/goodui/src/lib/line-chart.html +53 -0
  201. package/angular/projects/goodui/src/lib/line-chart.ts +193 -0
  202. package/angular/projects/goodui/src/lib/link.ts +46 -0
  203. package/angular/projects/goodui/src/lib/listbox.ts +254 -0
  204. package/angular/projects/goodui/src/lib/main-view.ts +39 -0
  205. package/angular/projects/goodui/src/lib/marker-colors.ts +7 -0
  206. package/angular/projects/goodui/src/lib/modal.ts +199 -0
  207. package/angular/projects/goodui/src/lib/models.ts +115 -0
  208. package/angular/projects/goodui/src/lib/month-calendar.ts +289 -0
  209. package/angular/projects/goodui/src/lib/notification-center.ts +170 -0
  210. package/angular/projects/goodui/src/lib/notification-host.ts +86 -0
  211. package/angular/projects/goodui/src/lib/number-input.ts +180 -0
  212. package/angular/projects/goodui/src/lib/pdf-preview.ts +242 -0
  213. package/angular/projects/goodui/src/lib/pdf-worker.generated.ts +2 -0
  214. package/angular/projects/goodui/src/lib/pin-input.ts +193 -0
  215. package/angular/projects/goodui/src/lib/progress.ts +93 -0
  216. package/angular/projects/goodui/src/lib/provide-goodui.ts +15 -0
  217. package/angular/projects/goodui/src/lib/radio-group.ts +94 -0
  218. package/angular/projects/goodui/src/lib/range-slider.ts +313 -0
  219. package/angular/projects/goodui/src/lib/rating.ts +90 -0
  220. package/angular/projects/goodui/src/lib/required-control.ts +4 -0
  221. package/angular/projects/goodui/src/lib/resizable.ts +168 -0
  222. package/angular/projects/goodui/src/lib/rich-text-command.ts +111 -0
  223. package/angular/projects/goodui/src/lib/rich-text-editor.html +193 -0
  224. package/angular/projects/goodui/src/lib/rich-text-editor.ts +864 -0
  225. package/angular/projects/goodui/src/lib/rich-text-sanitize.ts +99 -0
  226. package/angular/projects/goodui/src/lib/scatter-chart.html +48 -0
  227. package/angular/projects/goodui/src/lib/scatter-chart.ts +150 -0
  228. package/angular/projects/goodui/src/lib/select-country.ts +104 -0
  229. package/angular/projects/goodui/src/lib/select-font.ts +189 -0
  230. package/angular/projects/goodui/src/lib/select.ts +336 -0
  231. package/angular/projects/goodui/src/lib/sidebar.ts +232 -0
  232. package/angular/projects/goodui/src/lib/signature-pad.ts +238 -0
  233. package/angular/projects/goodui/src/lib/sparkline.html +15 -0
  234. package/angular/projects/goodui/src/lib/sparkline.ts +106 -0
  235. package/angular/projects/goodui/src/lib/status-icon.ts +79 -0
  236. package/angular/projects/goodui/src/lib/subnav.ts +156 -0
  237. package/angular/projects/goodui/src/lib/switch.ts +54 -0
  238. package/angular/projects/goodui/src/lib/table.ts +538 -0
  239. package/angular/projects/goodui/src/lib/tabs.ts +251 -0
  240. package/angular/projects/goodui/src/lib/textarea.ts +83 -0
  241. package/angular/projects/goodui/src/lib/theme.ts +49 -0
  242. package/angular/projects/goodui/src/lib/timeline.ts +252 -0
  243. package/angular/projects/goodui/src/lib/topbar.ts +403 -0
  244. package/angular/projects/goodui/src/lib/typography.ts +250 -0
  245. package/angular/projects/goodui/src/lib/world-map-data.ts +3 -0
  246. package/angular/projects/goodui/src/lib/world-map.html +73 -0
  247. package/angular/projects/goodui/src/lib/world-map.ts +391 -0
  248. package/angular/projects/goodui/src/month-calendar.css +47 -0
  249. package/angular/projects/goodui/src/pdf-preview.css +25 -0
  250. package/angular/projects/goodui/src/progress.css +38 -0
  251. package/angular/projects/goodui/src/public-api.ts +74 -0
  252. package/angular/projects/goodui/src/range-slider.css +54 -0
  253. package/angular/projects/goodui/src/resizable.css +32 -0
  254. package/angular/projects/goodui/src/rich-text-editor.css +33 -0
  255. package/angular/projects/goodui/src/select-font.css +16 -0
  256. package/angular/projects/goodui/src/signature-pad.css +14 -0
  257. package/angular/projects/goodui/src/styles.css +1105 -0
  258. package/angular/projects/goodui/src/timeline.css +138 -0
  259. package/angular/projects/goodui/src/tokens.generated.css +754 -0
  260. package/design/component-map.json +2233 -0
  261. package/design-tokens/penpot.tokens.json +3339 -0
  262. package/design.md +452 -0
  263. package/fesm2022/cloudfrogger-goodui.mjs +32 -18
  264. package/fesm2022/cloudfrogger-goodui.mjs.map +1 -1
  265. package/guides/README.md +17 -0
  266. package/guides/components/action-bar.md +43 -0
  267. package/guides/components/action-group.md +43 -0
  268. package/guides/components/action-menu.md +22 -0
  269. package/guides/components/alert.md +28 -0
  270. package/guides/components/assistant-panel.md +50 -0
  271. package/guides/components/avatar-menu.md +34 -0
  272. package/guides/components/badge.md +39 -0
  273. package/guides/components/bar-chart.md +40 -0
  274. package/guides/components/breadcrumbs.md +37 -0
  275. package/guides/components/button.md +40 -0
  276. package/guides/components/calendar.md +166 -0
  277. package/guides/components/card.md +62 -0
  278. package/guides/components/chart-axis.md +5 -0
  279. package/guides/components/chart-bar.md +5 -0
  280. package/guides/components/chart-data.md +58 -0
  281. package/guides/components/chart-histogram.md +16 -0
  282. package/guides/components/chart-line.md +5 -0
  283. package/guides/components/chart-scatter.md +14 -0
  284. package/guides/components/checkbox.md +36 -0
  285. package/guides/components/code-block.md +35 -0
  286. package/guides/components/color-controls.md +22 -0
  287. package/guides/components/column.md +5 -0
  288. package/guides/components/columns.md +13 -0
  289. package/guides/components/date-input.md +62 -0
  290. package/guides/components/detail-list.md +25 -0
  291. package/guides/components/dropdown.md +48 -0
  292. package/guides/components/error-page.md +31 -0
  293. package/guides/components/expandable.md +36 -0
  294. package/guides/components/form.md +49 -0
  295. package/guides/components/group.md +41 -0
  296. package/guides/components/histogram.md +45 -0
  297. package/guides/components/icon.md +13 -0
  298. package/guides/components/image-input.md +34 -0
  299. package/guides/components/input-phone.md +45 -0
  300. package/guides/components/input.md +59 -0
  301. package/guides/components/line-chart.md +37 -0
  302. package/guides/components/link.md +31 -0
  303. package/guides/components/listbox.md +109 -0
  304. package/guides/components/main-menu.md +23 -0
  305. package/guides/components/main-view.md +21 -0
  306. package/guides/components/modal.md +58 -0
  307. package/guides/components/month-calendar.md +88 -0
  308. package/guides/components/notifications.md +76 -0
  309. package/guides/components/number-input.md +21 -0
  310. package/guides/components/pdf-preview.md +38 -0
  311. package/guides/components/pin-input.md +37 -0
  312. package/guides/components/progress.md +41 -0
  313. package/guides/components/radio-group.md +41 -0
  314. package/guides/components/range-slider.md +42 -0
  315. package/guides/components/rating.md +39 -0
  316. package/guides/components/resizable-pane.md +3 -0
  317. package/guides/components/resizable.md +75 -0
  318. package/guides/components/rich-text-editor.md +113 -0
  319. package/guides/components/scatter-chart.md +43 -0
  320. package/guides/components/search.md +51 -0
  321. package/guides/components/select-font.md +16 -0
  322. package/guides/components/select.md +65 -0
  323. package/guides/components/settings.md +11 -0
  324. package/guides/components/sidebar.md +47 -0
  325. package/guides/components/signature-pad.md +45 -0
  326. package/guides/components/sparkline.md +31 -0
  327. package/guides/components/status-icon.md +32 -0
  328. package/guides/components/submenus.md +30 -0
  329. package/guides/components/subnav.md +54 -0
  330. package/guides/components/switch.md +48 -0
  331. package/guides/components/table.md +256 -0
  332. package/guides/components/tabs.md +46 -0
  333. package/guides/components/textarea.md +44 -0
  334. package/guides/components/theme-toggle.md +33 -0
  335. package/guides/components/timeline-section.md +7 -0
  336. package/guides/components/timeline-step.md +12 -0
  337. package/guides/components/timeline.md +179 -0
  338. package/guides/components/topbar.md +89 -0
  339. package/guides/components/typography.md +155 -0
  340. package/guides/components/world-map.md +72 -0
  341. package/guides/contributing/design-to-code.md +265 -0
  342. package/guides/deployment/drone.md +77 -0
  343. package/guides/examples/user-registration.md +11 -0
  344. package/guides/foundations/naming.md +7 -0
  345. package/guides/foundations/tokens.md +203 -0
  346. package/guides/intro.md +80 -0
  347. package/guides/layout/app-layout.md +81 -0
  348. package/guides/layout/layout-rules.md +16 -0
  349. package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.html +22 -0
  350. package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.ts +111 -0
  351. package/homepage/src/app/examples/calendar-workspace/source-code.generated.ts +3 -0
  352. package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.html +166 -0
  353. package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.ts +134 -0
  354. package/homepage/src/app/examples/case-studies/cloudhoster/cloudhoster-store.ts +92 -0
  355. package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.html +93 -0
  356. package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.ts +115 -0
  357. package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.html +202 -0
  358. package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.ts +143 -0
  359. package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.html +70 -0
  360. package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.ts +44 -0
  361. package/homepage/src/app/examples/case-studies/cloudhoster/home-page.html +70 -0
  362. package/homepage/src/app/examples/case-studies/cloudhoster/home-page.ts +32 -0
  363. package/homepage/src/app/examples/case-studies/cloudhoster/source-code.generated.ts +12 -0
  364. package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.html +208 -0
  365. package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.ts +214 -0
  366. package/homepage/src/app/examples/case-studies/vpshoster/overview-page.html +35 -0
  367. package/homepage/src/app/examples/case-studies/vpshoster/overview-page.ts +17 -0
  368. package/homepage/src/app/examples/case-studies/vpshoster/servers-page.html +111 -0
  369. package/homepage/src/app/examples/case-studies/vpshoster/servers-page.ts +206 -0
  370. package/homepage/src/app/examples/case-studies/vpshoster/source-code.generated.ts +6 -0
  371. package/homepage/src/app/examples/case-studies/vpshoster/vps-store.ts +92 -0
  372. package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.html +35 -0
  373. package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.ts +17 -0
  374. package/homepage/src/app/examples/error-pages/error-pages-example-page.html +27 -0
  375. package/homepage/src/app/examples/error-pages/error-pages-example-page.ts +34 -0
  376. package/homepage/src/app/examples/error-pages/not-found-page.html +8 -0
  377. package/homepage/src/app/examples/error-pages/not-found-page.ts +19 -0
  378. package/homepage/src/app/examples/error-pages/server-error-page.html +8 -0
  379. package/homepage/src/app/examples/error-pages/server-error-page.ts +20 -0
  380. package/homepage/src/app/examples/error-pages/source-code.generated.ts +7 -0
  381. package/homepage/src/app/examples/mail-compose/mail-compose-page.html +25 -0
  382. package/homepage/src/app/examples/mail-compose/mail-compose-page.ts +28 -0
  383. package/homepage/src/app/examples/mail-workspace/mail-workspace-page.html +59 -0
  384. package/homepage/src/app/examples/mail-workspace/mail-workspace-page.ts +128 -0
  385. package/homepage/src/app/examples/mail-workspace/source-code.generated.ts +3 -0
  386. package/homepage/src/app/examples/notifications/notifications-page.html +51 -0
  387. package/homepage/src/app/examples/notifications/notifications-page.ts +133 -0
  388. package/homepage/src/app/examples/notifications/source-code.generated.ts +3 -0
  389. package/homepage/src/app/examples/pdf-reader/pdf-reader-page.html +27 -0
  390. package/homepage/src/app/examples/pdf-reader/pdf-reader-page.ts +39 -0
  391. package/homepage/src/app/examples/pdf-reader/source-code.generated.ts +3 -0
  392. package/homepage/src/app/examples/user-registration/source-code.generated.ts +5 -0
  393. package/homepage/src/app/examples/user-registration/user-registration-example-page.html +11 -0
  394. package/homepage/src/app/examples/user-registration/user-registration-example-page.ts +21 -0
  395. package/homepage/src/app/examples/user-registration/user-registration-form.html +116 -0
  396. package/homepage/src/app/examples/user-registration/user-registration-form.ts +93 -0
  397. package/homepage/src/app/examples/user-registration/user-registration-page.html +11 -0
  398. package/homepage/src/app/examples/user-registration/user-registration-page.ts +23 -0
  399. package/package.json +2 -2
  400. package/types/cloudfrogger-goodui.d.ts +2 -2
@@ -0,0 +1,269 @@
1
+ /** A source can carry one, two, or three (and later more) typed dimensions. */
2
+ export type GoodChartKeyType = 'category' | 'integer' | 'number' | 'date' | 'datetime';
3
+ export type GoodChartValue = string | number | Date | null;
4
+
5
+ export interface GoodChartKey {
6
+ key: string;
7
+ type: GoodChartKeyType;
8
+ label?: string;
9
+ unit?: string;
10
+ }
11
+
12
+ export interface GoodChartDataSource {
13
+ id: string;
14
+ keys: readonly GoodChartKey[];
15
+ rows: readonly Readonly<Record<string, GoodChartValue>>[];
16
+ }
17
+
18
+ export type GoodChartAxisType = 'category' | 'number' | 'time';
19
+ export type GoodChartTimeGroup = 'day' | 'month' | 'year';
20
+ export type GoodChartAggregation = 'none' | 'mean' | 'sum' | 'min' | 'max' | 'count' | 'first' | 'last';
21
+
22
+ export interface GoodChartAxisDefinition {
23
+ type: GoodChartAxisType;
24
+ label?: string;
25
+ min?: number | string | Date | null;
26
+ max?: number | string | Date | null;
27
+ ticks?: number;
28
+ /** Rounds displayed numeric tick labels only; it never changes source values. */
29
+ precision?: number;
30
+ /** Buckets dates before plotting. Requires an explicit aggregation for duplicate buckets. */
31
+ groupBy?: GoodChartTimeGroup | null;
32
+ aggregate?: GoodChartAggregation;
33
+ }
34
+
35
+ export interface GoodChartSeriesDefinition {
36
+ source: string;
37
+ yKey: string;
38
+ xKey?: string;
39
+ label?: string;
40
+ color?: string;
41
+ }
42
+
43
+ export interface GoodChartPoint {
44
+ x: string | number;
45
+ y: number;
46
+ }
47
+
48
+ export interface GoodResolvedChartSeries {
49
+ id: string;
50
+ label: string;
51
+ source: string;
52
+ color?: string;
53
+ points: readonly GoodChartPoint[];
54
+ }
55
+
56
+ export interface GoodChartResolution {
57
+ lines: readonly GoodResolvedChartSeries[];
58
+ errors: readonly string[];
59
+ }
60
+
61
+ export type GoodChartLineDefinition = GoodChartSeriesDefinition;
62
+ export type GoodResolvedChartLine = GoodResolvedChartSeries;
63
+
64
+ function parseNumber(value: GoodChartValue | undefined, type: GoodChartKeyType): number | null {
65
+ if (typeof value !== 'number' || !Number.isFinite(value)) return null;
66
+ return type === 'integer' && !Number.isInteger(value) ? null : value;
67
+ }
68
+
69
+ function parseTime(value: GoodChartValue | undefined, type: GoodChartKeyType): number | null {
70
+ if (value instanceof Date) return Number.isFinite(value.getTime()) ? value.getTime() : null;
71
+ if (typeof value !== 'string') return null;
72
+ const day = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);
73
+ if (!day) return null;
74
+ const [, year, month, date] = day;
75
+ const validDay = new Date(0);
76
+ validDay.setUTCFullYear(Number(year), Number(month) - 1, Number(date));
77
+ if (validDay.getUTCFullYear() !== Number(year) || validDay.getUTCMonth() !== Number(month) - 1 ||
78
+ validDay.getUTCDate() !== Number(date)) return null;
79
+ if (type === 'date' && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
80
+ if (type === 'datetime' && !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/.test(value)) return null;
81
+ const time = Date.parse(value);
82
+ return Number.isFinite(time) ? time : null;
83
+ }
84
+
85
+ function bucketTime(time: number, groupBy: GoodChartTimeGroup | null | undefined): number {
86
+ if (!groupBy) return time;
87
+ const date = new Date(time);
88
+ const year = date.getUTCFullYear();
89
+ const month = groupBy === 'year' ? 0 : date.getUTCMonth();
90
+ const day = groupBy === 'day' ? date.getUTCDate() : 1;
91
+ const bucket = new Date(0);
92
+ bucket.setUTCFullYear(year, month, day);
93
+ bucket.setUTCHours(0, 0, 0, 0);
94
+ return bucket.getTime();
95
+ }
96
+
97
+ function aggregate(values: readonly number[], method: GoodChartAggregation): number {
98
+ if (method === 'count') return values.length;
99
+ if (method === 'sum') return values.reduce((sum, value) => sum + value, 0);
100
+ if (method === 'mean') return values.reduce((sum, value) => sum + value, 0) / values.length;
101
+ if (method === 'min') return Math.min(...values);
102
+ if (method === 'max') return Math.max(...values);
103
+ if (method === 'first') return values[0];
104
+ return values[values.length - 1];
105
+ }
106
+
107
+ /** Validates metadata and values once for every chart; it never silently coerces strings into numbers. */
108
+ export function resolveChartSeries(
109
+ sources: readonly GoodChartDataSource[], definitions: readonly GoodChartSeriesDefinition[],
110
+ xAxis: GoodChartAxisDefinition, seriesName = 'Line',
111
+ ): GoodChartResolution {
112
+ const errors: string[] = [];
113
+ const lines: GoodResolvedChartSeries[] = [];
114
+ const sourceById = new Map(sources.map(source => [source.id, source]));
115
+ for (const [index, line] of definitions.entries()) {
116
+ const source = sourceById.get(line.source);
117
+ if (!source) { errors.push(`${seriesName} ${index + 1}: data source "${line.source}" was not found.`); continue; }
118
+ const yKey = source.keys.find(key => key.key === line.yKey);
119
+ const xKey = line.xKey ? source.keys.find(key => key.key === line.xKey) : null;
120
+ if (!yKey || !['number', 'integer'].includes(yKey.type)) {
121
+ errors.push(`${seriesName} ${index + 1}: "${line.yKey}" must be a declared numeric key.`); continue;
122
+ }
123
+ if (line.xKey && !xKey) { errors.push(`${seriesName} ${index + 1}: x key "${line.xKey}" was not found.`); continue; }
124
+ if (!xKey && xAxis.type !== 'number') {
125
+ errors.push(`${seriesName} ${index + 1}: an x key is required for ${xAxis.type} axes.`); continue;
126
+ }
127
+ if (xKey && ((xAxis.type === 'number' && !['number', 'integer'].includes(xKey.type)) ||
128
+ (xAxis.type === 'time' && !['date', 'datetime'].includes(xKey.type)) ||
129
+ (xAxis.type === 'category' && xKey.type !== 'category'))) {
130
+ errors.push(`${seriesName} ${index + 1}: x key "${xKey.key}" does not match the ${xAxis.type} axis.`); continue;
131
+ }
132
+ const groups = new Map<string | number, number[]>();
133
+ for (const [rowIndex, row] of source.rows.entries()) {
134
+ const y = parseNumber(row[yKey.key], yKey.type);
135
+ if (y === null) continue;
136
+ let x: string | number | null = rowIndex + 1;
137
+ if (xKey?.type === 'category') x = typeof row[xKey.key] === 'string' ? row[xKey.key] as string : null;
138
+ else if (xKey?.type === 'number' || xKey?.type === 'integer') x = parseNumber(row[xKey.key], xKey.type);
139
+ else if (xKey) {
140
+ const time = parseTime(row[xKey.key], xKey.type);
141
+ x = time === null ? null : bucketTime(time, xAxis.groupBy);
142
+ }
143
+ if (x === null || x === '') continue;
144
+ groups.set(x, [...(groups.get(x) ?? []), y]);
145
+ }
146
+ const method = xAxis.aggregate ?? 'none';
147
+ if ([...groups.values()].some(values => values.length > 1) && method === 'none') {
148
+ errors.push(`${seriesName} ${index + 1}: duplicate x values need an explicit aggregate (mean, sum, min, max, count, first, or last).`);
149
+ continue;
150
+ }
151
+ const points = [...groups].map(([x, values]) => ({ x, y: aggregate(values, method) }));
152
+ if (xAxis.type !== 'category') points.sort((a, b) => Number(a.x) - Number(b.x));
153
+ lines.push({ id: `${source.id}:${line.yKey}:${index}`, label: line.label || yKey.label || line.yKey,
154
+ source: source.id, color: line.color, points });
155
+ }
156
+ return { lines, errors };
157
+ }
158
+
159
+ /** Compatibility name for line-chart consumers of the shared resolver. */
160
+ export function resolveChartLines(
161
+ sources: readonly GoodChartDataSource[], definitions: readonly GoodChartLineDefinition[],
162
+ xAxis: GoodChartAxisDefinition,
163
+ ): GoodChartResolution {
164
+ return resolveChartSeries(sources, definitions, xAxis, 'Line');
165
+ }
166
+
167
+ /** Resolves independent 2D observations. Equal X values remain separate points. */
168
+ export function resolveScatterSeries(
169
+ sources: readonly GoodChartDataSource[], definitions: readonly GoodChartSeriesDefinition[],
170
+ xAxis: GoodChartAxisDefinition,
171
+ ): GoodChartResolution {
172
+ const errors: string[] = [];
173
+ const lines: GoodResolvedChartSeries[] = [];
174
+ const sourceById = new Map(sources.map(source => [source.id, source]));
175
+ if (xAxis.type === 'category') return { lines, errors: ['Scatter: the X axis must be number or time.'] };
176
+ for (const [index, definition] of definitions.entries()) {
177
+ const prefix = `Scatter ${index + 1}`;
178
+ const source = sourceById.get(definition.source);
179
+ if (!source) { errors.push(`${prefix}: data source "${definition.source}" was not found.`); continue; }
180
+ const xKey = source.keys.find(key => key.key === definition.xKey);
181
+ const yKey = source.keys.find(key => key.key === definition.yKey);
182
+ if (!xKey) { errors.push(`${prefix}: a declared xKey is required.`); continue; }
183
+ if (!yKey || !['number', 'integer'].includes(yKey.type)) {
184
+ errors.push(`${prefix}: "${definition.yKey}" must be a declared numeric key.`); continue;
185
+ }
186
+ if ((xAxis.type === 'number' && !['number', 'integer'].includes(xKey.type)) ||
187
+ (xAxis.type === 'time' && !['date', 'datetime'].includes(xKey.type))) {
188
+ errors.push(`${prefix}: x key "${xKey.key}" does not match the ${xAxis.type} axis.`); continue;
189
+ }
190
+ const points: GoodChartPoint[] = [];
191
+ for (const row of source.rows) {
192
+ const y = parseNumber(row[yKey.key], yKey.type);
193
+ const x = xAxis.type === 'time' ? parseTime(row[xKey.key], xKey.type) : parseNumber(row[xKey.key], xKey.type);
194
+ if (x !== null && y !== null) points.push({ x: xAxis.type === 'time' ? bucketTime(x, xAxis.groupBy) : x, y });
195
+ }
196
+ // Aggregation is opt-in: duplicate X values normally represent distinct observations.
197
+ const method = xAxis.aggregate ?? 'none';
198
+ let result = points;
199
+ if (method !== 'none') {
200
+ const groups = new Map<number, number[]>();
201
+ for (const point of points) groups.set(Number(point.x), [...(groups.get(Number(point.x)) ?? []), point.y]);
202
+ result = [...groups].map(([x, values]) => ({ x, y: aggregate(values, method) }));
203
+ }
204
+ lines.push({ id: `${source.id}:${definition.xKey}:${definition.yKey}:${index}`,
205
+ label: definition.label || yKey.label || definition.yKey, source: source.id, color: definition.color, points: result });
206
+ }
207
+ return { lines, errors };
208
+ }
209
+
210
+ export interface GoodHistogramSeriesDefinition {
211
+ source: string;
212
+ valueKey: string;
213
+ label?: string;
214
+ color?: string;
215
+ }
216
+
217
+ export interface GoodHistogramBin {
218
+ start: number;
219
+ end: number;
220
+ /** One count per declared series, in series order. */
221
+ counts: readonly number[];
222
+ }
223
+
224
+ export interface GoodHistogramResolution {
225
+ series: readonly { id: string; label: string; color?: string }[];
226
+ bins: readonly GoodHistogramBin[];
227
+ errors: readonly string[];
228
+ }
229
+
230
+ /** Uses one shared numeric range for every source; bins are left-closed, right-open except the last. */
231
+ export function resolveHistogram(
232
+ sources: readonly GoodChartDataSource[], definitions: readonly GoodHistogramSeriesDefinition[],
233
+ binCount = 8, minOverride: number | null = null, maxOverride: number | null = null,
234
+ ): GoodHistogramResolution {
235
+ const errors: string[] = [];
236
+ if (!Number.isInteger(binCount) || binCount < 2 || binCount > 40) errors.push('Histogram: binCount must be an integer from 2 to 40.');
237
+ if (minOverride !== null && !Number.isFinite(minOverride)) errors.push('Histogram: min must be finite.');
238
+ if (maxOverride !== null && !Number.isFinite(maxOverride)) errors.push('Histogram: max must be finite.');
239
+ const byId = new Map(sources.map(source => [source.id, source]));
240
+ const series: { id: string; label: string; color?: string }[] = [];
241
+ const values: number[][] = [];
242
+ for (const [index, definition] of definitions.entries()) {
243
+ const source = byId.get(definition.source);
244
+ if (!source) { errors.push(`Histogram ${index + 1}: data source "${definition.source}" was not found.`); continue; }
245
+ const key = source.keys.find(item => item.key === definition.valueKey);
246
+ if (!key || !['number', 'integer'].includes(key.type)) {
247
+ errors.push(`Histogram ${index + 1}: "${definition.valueKey}" must be a declared numeric key.`); continue;
248
+ }
249
+ series.push({ id: `${source.id}:${key.key}:${index}`, label: definition.label || key.label || key.key, color: definition.color });
250
+ values.push(source.rows.map(row => parseNumber(row[key.key], key.type)).filter((value): value is number => value !== null));
251
+ }
252
+ if (errors.length) return { series, bins: [], errors };
253
+ const all = values.flat();
254
+ if (!all.length) return { series, bins: [], errors };
255
+ const rawMin = Math.min(...all);
256
+ const rawMax = Math.max(...all);
257
+ const start = minOverride ?? (rawMin === rawMax ? rawMin - .5 : rawMin);
258
+ const end = maxOverride ?? (rawMin === rawMax ? rawMax + .5 : rawMax);
259
+ if (start >= end) return { series, bins: [], errors: ['Histogram: min must be smaller than max.'] };
260
+ const step = (end - start) / binCount;
261
+ const counts = Array.from({ length: binCount }, () => Array.from({ length: series.length }, () => 0));
262
+ values.forEach((sourceValues, seriesIndex) => sourceValues.forEach(value => {
263
+ if (value < start || value > end) return;
264
+ const index = Math.min(binCount - 1, Math.floor((value - start) / step));
265
+ counts[index][seriesIndex]++;
266
+ }));
267
+ return { series, bins: counts.map((row, index) => ({ start: start + index * step,
268
+ end: index === binCount - 1 ? end : start + (index + 1) * step, counts: row })), errors };
269
+ }
@@ -0,0 +1,87 @@
1
+ import { ChangeDetectionStrategy, Component, computed, effect, forwardRef, input, model, signal } from '@angular/core';
2
+ import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator, Validators } from '@angular/forms';
3
+
4
+ export type GoodCheckboxSize = 'small' | 'default' | 'large';
5
+ export type GoodCheckboxAppearance = 'brand' | 'mono';
6
+
7
+ @Component({
8
+ selector: 'good-checkbox',
9
+ standalone: true,
10
+ changeDetection: ChangeDetectionStrategy.OnPush,
11
+ providers: [
12
+ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodCheckboxComponent), multi: true },
13
+ { provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodCheckboxComponent), multi: true },
14
+ ],
15
+ host: { class: 'good-checkbox' },
16
+ template: `
17
+ <label class="good-checkbox-control" [attr.data-size]="size()" [attr.data-appearance]="appearance()"
18
+ [attr.data-state]="indeterminate() ? 'indeterminate' : checked() ? 'checked' : 'unchecked'"
19
+ [attr.data-disabled]="isDisabled() ? 'true' : null">
20
+ <input class="good-checkbox-input" type="checkbox" [checked]="checked()" [indeterminate]="indeterminate()"
21
+ [disabled]="isDisabled()" [required]="effectiveRequired()" [name]="name()" [id]="inputId() || null"
22
+ [attr.aria-label]="showLabel() ? null : label()" [attr.aria-checked]="indeterminate() ? 'mixed' : checked()"
23
+ [attr.aria-describedby]="describedBy() || null" (change)="onInputChange($event)" (blur)="onBlur()" />
24
+ <span class="good-checkbox-box" aria-hidden="true">
25
+ @if (indeterminate()) {
26
+ <svg class="good-checkbox-mark" viewBox="0 0 24 24" fill="none"><path d="M5 12h14" stroke="currentColor" stroke-width="3" stroke-linecap="round" /></svg>
27
+ } @else if (checked()) {
28
+ <svg class="good-checkbox-mark" viewBox="0 0 24 24" fill="none"><path d="m4 12 5 5L20 6" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" /></svg>
29
+ }
30
+ </span>
31
+ @if (showLabel()) { <span class="good-checkbox-label">{{ label() }}@if (effectiveRequired()) { <span class="good-required-mark" aria-hidden="true">*</span><span class="good-sr-only"> required</span> }</span> }
32
+ </label>
33
+ `,
34
+ })
35
+ export class GoodCheckboxComponent implements ControlValueAccessor, Validator {
36
+ readonly label = input.required<string>();
37
+ readonly showLabel = input(false);
38
+ readonly checked = model(false);
39
+ readonly indeterminate = model(false);
40
+ readonly size = input<GoodCheckboxSize>('default');
41
+ readonly appearance = input<GoodCheckboxAppearance>('brand');
42
+ readonly disabled = input(false);
43
+ readonly required = input(false);
44
+ readonly fieldRequired = signal(false);
45
+ readonly effectiveRequired = computed(() => this.required() || this.fieldRequired());
46
+ readonly name = input('');
47
+ readonly inputId = input('');
48
+ readonly describedBy = input('');
49
+ private readonly formDisabled = signal(false);
50
+ readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
51
+ private onChange: (value: boolean | null) => void = () => {};
52
+ private onTouched: () => void = () => {};
53
+ private onValidatorChange: () => void = () => {};
54
+
55
+ constructor() {
56
+ effect(() => {
57
+ this.effectiveRequired();
58
+ this.isDisabled();
59
+ this.onValidatorChange();
60
+ });
61
+ }
62
+
63
+ setFieldRequired(required: boolean): void { this.fieldRequired.set(required); }
64
+ validate(control: AbstractControl): ValidationErrors | null {
65
+ return this.effectiveRequired() && !this.isDisabled() ? Validators.requiredTrue(control) : null;
66
+ }
67
+ registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
68
+
69
+ onInputChange(event: Event): void {
70
+ const input = event.target as HTMLInputElement;
71
+ const next = this.indeterminate() ? false : input.checked;
72
+ this.indeterminate.set(false);
73
+ this.checked.set(next);
74
+ input.indeterminate = false;
75
+ input.checked = next;
76
+ this.onChange(next);
77
+ }
78
+
79
+ onBlur(): void { this.onTouched(); }
80
+ writeValue(value: unknown): void {
81
+ this.indeterminate.set(value === null);
82
+ this.checked.set(value === true);
83
+ }
84
+ registerOnChange(fn: (value: boolean | null) => void): void { this.onChange = fn; }
85
+ registerOnTouched(fn: () => void): void { this.onTouched = fn; }
86
+ setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
87
+ }
@@ -0,0 +1,147 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, computed, effect, inject, input, OnDestroy, signal } from '@angular/core';
3
+ import { GoodButtonComponent } from './button';
4
+
5
+ type Highlighter = typeof import('highlight.js/lib/core').default;
6
+
7
+ export type GoodCodeLanguage =
8
+ | 'plaintext' | 'bash' | 'css' | 'go' | 'html' | 'java' | 'javascript'
9
+ | 'json' | 'markdown' | 'python' | 'rust' | 'sql' | 'typescript' | 'yaml';
10
+
11
+ const languages: Record<Exclude<GoodCodeLanguage, 'plaintext'>, () => Promise<{ default: Parameters<Highlighter['registerLanguage']>[1] }>> = {
12
+ bash: () => import('highlight.js/lib/languages/bash'),
13
+ css: () => import('highlight.js/lib/languages/css'),
14
+ go: () => import('highlight.js/lib/languages/go'),
15
+ html: () => import('highlight.js/lib/languages/xml'),
16
+ java: () => import('highlight.js/lib/languages/java'),
17
+ javascript: () => import('highlight.js/lib/languages/javascript'),
18
+ json: () => import('highlight.js/lib/languages/json'),
19
+ markdown: () => import('highlight.js/lib/languages/markdown'),
20
+ python: () => import('highlight.js/lib/languages/python'),
21
+ rust: () => import('highlight.js/lib/languages/rust'),
22
+ sql: () => import('highlight.js/lib/languages/sql'),
23
+ typescript: () => import('highlight.js/lib/languages/typescript'),
24
+ yaml: () => import('highlight.js/lib/languages/yaml'),
25
+ };
26
+
27
+ let core: Promise<Highlighter> | undefined;
28
+ const loading = new Map<string, Promise<Highlighter>>();
29
+ let nextCodeId = 0;
30
+
31
+ function loadLanguage(language: string): Promise<Highlighter | null> {
32
+ const loader = languages[language as Exclude<GoodCodeLanguage, 'plaintext'>];
33
+ if (!loader) return Promise.resolve(null);
34
+ if (!loading.has(language)) {
35
+ core ??= import('highlight.js/lib/core').then(module => module.default);
36
+ loading.set(language, core.then(async highlighter => {
37
+ if (!highlighter.getLanguage(language)) {
38
+ const module = await loader();
39
+ highlighter.registerLanguage(language, module.default);
40
+ }
41
+ return highlighter;
42
+ }).finally(() => loading.delete(language)));
43
+ }
44
+ return loading.get(language)!;
45
+ }
46
+
47
+ function escapeHtml(value: string): string {
48
+ return value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
49
+ .replaceAll('"', '&quot;').replaceAll("'", '&#39;');
50
+ }
51
+
52
+ @Component({
53
+ selector: 'good-code-block',
54
+ standalone: true,
55
+ imports: [GoodButtonComponent],
56
+ changeDetection: ChangeDetectionStrategy.OnPush,
57
+ host: { class: 'good-code-block', '[class.good-code-display-inline]': 'inline()' },
58
+ template: `
59
+ @if (inline()) {
60
+ <code class="good-code-inline" [innerHTML]="highlighted()"></code>
61
+ } @else {
62
+ <div class="good-code-frame">
63
+ @if (title() || language() !== 'plaintext' || copyable()) {
64
+ <div class="good-code-toolbar">
65
+ <span class="good-code-caption">{{ title() || languageLabel() }}</span>
66
+ @if (copyable()) {
67
+ <good-button class="good-code-copy" variant="ghost" size="small" [ariaLabel]="copyState() === 'copied' ? 'Code copied' : 'Copy code'" (click)="copy()">
68
+ {{ copyState() === 'copied' ? 'Copied' : copyState() === 'error' ? 'Copy failed' : 'Copy' }}
69
+ </good-button>
70
+ }
71
+ </div>
72
+ }
73
+ <div class="good-code-viewport" [id]="codeId" [class.good-code-is-collapsed]="isCollapsed()" [style.--good-code-preview-lines]="previewLines()">
74
+ @if (lineNumbers()) {
75
+ <div class="good-code-line-numbers" aria-hidden="true">
76
+ @for (number of numbers(); track number) { <span>{{ number }}</span> }
77
+ </div>
78
+ }
79
+ <pre class="good-code-pre"><code [innerHTML]="highlighted()"></code></pre>
80
+ @if (isCollapsed()) { <div class="good-code-fade" aria-hidden="true"></div> }
81
+ </div>
82
+ @if (canToggle()) {
83
+ <div class="good-code-expand-row">
84
+ <good-button class="good-code-expand" variant="secondary" size="small" (click)="expanded.set(!expanded())"
85
+ [ariaControls]="codeId" [ariaExpanded]="expanded()">{{ expanded() ? 'Show less' : 'Show more' }}</good-button>
86
+ </div>
87
+ }
88
+ <span class="good-code-sr-only" role="status" aria-live="polite">{{ copyState() === 'copied' ? 'Code copied to clipboard' : copyState() === 'error' ? 'Could not copy code' : '' }}</span>
89
+ </div>
90
+ }
91
+ `,
92
+ })
93
+ export class GoodCodeBlockComponent implements OnDestroy {
94
+ private readonly document = inject(DOCUMENT);
95
+ private requestId = 0;
96
+ private resetTimer: ReturnType<typeof setTimeout> | undefined;
97
+ readonly codeId = `good-code-${++nextCodeId}`;
98
+
99
+ readonly code = input('');
100
+ readonly language = input<string>('plaintext');
101
+ readonly title = input('');
102
+ readonly inline = input(false);
103
+ readonly lineNumbers = input(false);
104
+ readonly copyable = input(true);
105
+ readonly collapsible = input(false);
106
+ readonly collapsedLines = input(6);
107
+ readonly expanded = signal(false);
108
+ readonly copyState = signal<'idle' | 'copied' | 'error'>('idle');
109
+ readonly highlighted = signal('');
110
+ readonly numbers = computed(() => Array.from({ length: this.code().split('\n').length }, (_, index) => index + 1));
111
+ readonly previewLines = computed(() => Math.max(1, Math.floor(this.collapsedLines())));
112
+ readonly canToggle = computed(() => !this.inline() && this.collapsible() && this.numbers().length > this.previewLines());
113
+ readonly isCollapsed = computed(() => this.canToggle() && !this.expanded());
114
+ readonly languageLabel = computed(() => this.language() === 'plaintext' ? 'Plain text' : this.language().toUpperCase());
115
+
116
+ constructor() {
117
+ effect(() => {
118
+ const code = this.code();
119
+ const language = this.language();
120
+ const requestId = ++this.requestId;
121
+ this.highlighted.set(escapeHtml(code));
122
+ if (language === 'plaintext') return;
123
+ void loadLanguage(language).then(highlighter => {
124
+ if (requestId !== this.requestId || !highlighter?.getLanguage(language)) return;
125
+ this.highlighted.set(highlighter.highlight(code, { language, ignoreIllegals: true }).value);
126
+ }).catch(() => { /* Plain text remains available if a grammar cannot load. */ });
127
+ });
128
+ }
129
+
130
+ async copy(): Promise<void> {
131
+ try {
132
+ const clipboard = this.document.defaultView?.navigator.clipboard;
133
+ if (!clipboard) throw new Error('Clipboard unavailable');
134
+ await clipboard.writeText(this.code());
135
+ this.copyState.set('copied');
136
+ } catch {
137
+ this.copyState.set('error');
138
+ }
139
+ if (this.resetTimer) clearTimeout(this.resetTimer);
140
+ this.resetTimer = setTimeout(() => this.copyState.set('idle'), 2200);
141
+ }
142
+
143
+ ngOnDestroy(): void {
144
+ ++this.requestId;
145
+ if (this.resetTimer) clearTimeout(this.resetTimer);
146
+ }
147
+ }
@@ -0,0 +1,107 @@
1
+ import { ChangeDetectionStrategy, Component, ElementRef, computed, effect, model, signal, viewChild } from '@angular/core';
2
+ import { clampColor, hexToRgb, hslToRgb, hsvToRgb, normalizeHex, rgbToHex, rgbToHsl, rgbToHsv, type GoodHsl, type GoodHsv, type GoodRgb } from './color-utils';
3
+
4
+ export type GoodColorMode = 'rgb' | 'hsl';
5
+
6
+ @Component({
7
+ selector: 'good-color-controls', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush,
8
+ host: { class: 'good-color-controls' },
9
+ template: `
10
+ <div class="good-color-controls-area" #area role="slider" tabindex="0" aria-label="Saturation and brightness"
11
+ [attr.aria-valuetext]="value()" [style.background-color]="hueColor()"
12
+ (pointerdown)="onAreaDown($event)" (pointermove)="onAreaMove($event)" (pointerup)="onAreaUp($event)"
13
+ (pointercancel)="onAreaUp($event)" (keydown)="onAreaKey($event)">
14
+ <span class="good-color-controls-cursor" [style.left.%]="hsv().s * 100" [style.top.%]="(1 - hsv().v) * 100"></span>
15
+ </div>
16
+ <div class="good-color-controls-hue-row">
17
+ <span class="good-color-controls-preview" [style.background-color]="value()" aria-hidden="true"></span>
18
+ <input type="range" min="0" max="359" step="1" [value]="hsv().h" aria-label="Hue"
19
+ class="good-color-controls-hue" (input)="onHue($event)" />
20
+ </div>
21
+ <div class="good-color-controls-mode" role="group" aria-label="Color model">
22
+ <button type="button" [attr.aria-pressed]="mode() === 'rgb'" (click)="mode.set('rgb')">RGB</button>
23
+ <button type="button" [attr.aria-pressed]="mode() === 'hsl'" (click)="mode.set('hsl')">HSL</button>
24
+ </div>
25
+ <div class="good-color-controls-channels">
26
+ @if (mode() === 'rgb') {
27
+ <label>R <input type="number" min="0" max="255" [value]="rgb().r" (change)="setRgb('r', $event)" /></label>
28
+ <label>G <input type="number" min="0" max="255" [value]="rgb().g" (change)="setRgb('g', $event)" /></label>
29
+ <label>B <input type="number" min="0" max="255" [value]="rgb().b" (change)="setRgb('b', $event)" /></label>
30
+ } @else {
31
+ <label>H <input type="number" min="0" max="359" [value]="hsl().h" (change)="setHsl('h', $event)" /></label>
32
+ <label>S % <input type="number" min="0" max="100" [value]="hsl().s" (change)="setHsl('s', $event)" /></label>
33
+ <label>L % <input type="number" min="0" max="100" [value]="hsl().l" (change)="setHsl('l', $event)" /></label>
34
+ }
35
+ </div>
36
+ <label class="good-color-controls-hex">Hex
37
+ <input type="text" inputmode="text" maxlength="7" [value]="hexDraft()" aria-label="Hex color"
38
+ (input)="hexDraft.set($any($event.target).value)" (change)="commitHex()" (blur)="commitHex()"
39
+ (keydown.enter)="commitHex(); $event.preventDefault()" />
40
+ </label>
41
+ `,
42
+ })
43
+ export class GoodColorControlsComponent {
44
+ readonly value = model('#2563EB');
45
+ readonly mode = signal<GoodColorMode>('rgb');
46
+ readonly hsv = signal<GoodHsv>({ h: 217, s: .82, v: .92 });
47
+ readonly rgb = computed<GoodRgb>(() => hexToRgb(this.value()) ?? { r: 37, g: 99, b: 235 });
48
+ readonly hsl = computed<GoodHsl>(() => rgbToHsl(this.rgb()));
49
+ readonly hueColor = computed(() => `hsl(${this.hsv().h} 100% 50%)`);
50
+ readonly hexDraft = signal('#2563EB');
51
+ private readonly area = viewChild<ElementRef<HTMLElement>>('area');
52
+ private activePointer: number | null = null;
53
+
54
+ constructor() {
55
+ effect(() => {
56
+ const hex = normalizeHex(this.value()) ?? '#2563EB';
57
+ this.hexDraft.set(hex);
58
+ this.hsv.set(rgbToHsv(hexToRgb(hex)!));
59
+ });
60
+ }
61
+
62
+ private setHsv(hsv: GoodHsv): void { this.value.set(rgbToHex(hsvToRgb(hsv))); }
63
+ onHue(event: Event): void { this.setHsv({ ...this.hsv(), h: Number((event.target as HTMLInputElement).value) }); }
64
+ onAreaDown(event: PointerEvent): void {
65
+ if (event.button !== 0) return;
66
+ this.activePointer = event.pointerId;
67
+ this.area()?.nativeElement.setPointerCapture(event.pointerId);
68
+ this.pickArea(event);
69
+ }
70
+ onAreaMove(event: PointerEvent): void { if (this.activePointer === event.pointerId) this.pickArea(event); }
71
+ onAreaUp(event: PointerEvent): void {
72
+ if (this.activePointer !== event.pointerId) return;
73
+ const area = this.area()?.nativeElement;
74
+ if (area?.hasPointerCapture(event.pointerId)) area.releasePointerCapture(event.pointerId);
75
+ this.activePointer = null;
76
+ }
77
+ private pickArea(event: PointerEvent): void {
78
+ const rect = this.area()?.nativeElement.getBoundingClientRect();
79
+ if (!rect) return;
80
+ this.setHsv({ h: this.hsv().h, s: clampColor((event.clientX - rect.left) / rect.width, 0, 1), v: 1 - clampColor((event.clientY - rect.top) / rect.height, 0, 1) });
81
+ }
82
+ onAreaKey(event: KeyboardEvent): void {
83
+ const current = this.hsv();
84
+ const amount = event.shiftKey ? .1 : .02;
85
+ const next = { ...current };
86
+ if (event.key === 'ArrowLeft') next.s -= amount;
87
+ else if (event.key === 'ArrowRight') next.s += amount;
88
+ else if (event.key === 'ArrowUp') next.v += amount;
89
+ else if (event.key === 'ArrowDown') next.v -= amount;
90
+ else return;
91
+ event.preventDefault();
92
+ this.setHsv({ h: next.h, s: clampColor(next.s, 0, 1), v: clampColor(next.v, 0, 1) });
93
+ }
94
+ setRgb(channel: keyof GoodRgb, event: Event): void {
95
+ const next = { ...this.rgb(), [channel]: clampColor(Number((event.target as HTMLInputElement).value), 0, 255) };
96
+ this.value.set(rgbToHex(next));
97
+ }
98
+ setHsl(channel: keyof GoodHsl, event: Event): void {
99
+ const next = { ...this.hsl(), [channel]: clampColor(Number((event.target as HTMLInputElement).value), 0, channel === 'h' ? 359 : 100) };
100
+ this.value.set(rgbToHex(hslToRgb(next)));
101
+ }
102
+ commitHex(): void {
103
+ const hex = normalizeHex(this.hexDraft());
104
+ if (hex) this.value.set(hex);
105
+ else this.hexDraft.set(normalizeHex(this.value()) ?? '#2563EB');
106
+ }
107
+ }