inlaycms 0.0.0-stage → 0.1.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 (364) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +462 -2
  3. package/assets/admin/admin.css +2 -0
  4. package/assets/admin/admin.js +1 -0
  5. package/assets/admin/editor.js +125 -0
  6. package/dist/adapters/admin/activity.d.ts +17 -0
  7. package/dist/adapters/admin/activity.js +59 -0
  8. package/dist/adapters/admin/assets.d.ts +14 -0
  9. package/dist/adapters/admin/assets.js +64 -0
  10. package/dist/adapters/admin/attention.d.ts +15 -0
  11. package/dist/adapters/admin/attention.js +34 -0
  12. package/dist/adapters/admin/context.d.ts +40 -0
  13. package/dist/adapters/admin/context.js +142 -0
  14. package/dist/adapters/admin/form/walk.d.ts +61 -0
  15. package/dist/adapters/admin/form/walk.js +565 -0
  16. package/dist/adapters/admin/pages.d.ts +38 -0
  17. package/dist/adapters/admin/pages.js +66 -0
  18. package/dist/adapters/admin/publish.d.ts +12 -0
  19. package/dist/adapters/admin/publish.js +195 -0
  20. package/dist/adapters/admin/routes.d.ts +47 -0
  21. package/dist/adapters/admin/routes.js +255 -0
  22. package/dist/adapters/admin/screens/backups.d.ts +11 -0
  23. package/dist/adapters/admin/screens/backups.js +223 -0
  24. package/dist/adapters/admin/screens/dashboard.d.ts +4 -0
  25. package/dist/adapters/admin/screens/dashboard.js +160 -0
  26. package/dist/adapters/admin/screens/editor.d.ts +67 -0
  27. package/dist/adapters/admin/screens/editor.js +416 -0
  28. package/dist/adapters/admin/screens/history.d.ts +4 -0
  29. package/dist/adapters/admin/screens/history.js +105 -0
  30. package/dist/adapters/admin/screens/lists.d.ts +4 -0
  31. package/dist/adapters/admin/screens/lists.js +297 -0
  32. package/dist/adapters/admin/screens/media.d.ts +20 -0
  33. package/dist/adapters/admin/screens/media.js +186 -0
  34. package/dist/adapters/admin/screens/pickers.d.ts +29 -0
  35. package/dist/adapters/admin/screens/pickers.js +134 -0
  36. package/dist/adapters/admin/screens/preview-pane.d.ts +10 -0
  37. package/dist/adapters/admin/screens/preview-pane.js +74 -0
  38. package/dist/adapters/admin/screens/redirects.d.ts +4 -0
  39. package/dist/adapters/admin/screens/redirects.js +137 -0
  40. package/dist/adapters/admin/screens/releases.d.ts +7 -0
  41. package/dist/adapters/admin/screens/releases.js +287 -0
  42. package/dist/adapters/admin/screens/search.d.ts +22 -0
  43. package/dist/adapters/admin/screens/search.js +113 -0
  44. package/dist/adapters/admin/screens/security.d.ts +4 -0
  45. package/dist/adapters/admin/screens/security.js +85 -0
  46. package/dist/adapters/admin/screens/users.d.ts +4 -0
  47. package/dist/adapters/admin/screens/users.js +330 -0
  48. package/dist/adapters/admin/theme.d.ts +1 -0
  49. package/dist/adapters/admin/theme.js +1 -0
  50. package/dist/adapters/admin/translations.d.ts +16 -0
  51. package/dist/adapters/admin/translations.js +23 -0
  52. package/dist/adapters/admin/upload.d.ts +8 -0
  53. package/dist/adapters/admin/upload.js +116 -0
  54. package/dist/adapters/admin/views/data-table.d.ts +82 -0
  55. package/dist/adapters/admin/views/data-table.js +117 -0
  56. package/dist/adapters/admin/views/icons.d.ts +48 -0
  57. package/dist/adapters/admin/views/icons.js +47 -0
  58. package/dist/adapters/admin/views/layout.d.ts +51 -0
  59. package/dist/adapters/admin/views/layout.js +145 -0
  60. package/dist/adapters/admin/views/sheet.d.ts +15 -0
  61. package/dist/adapters/admin/views/sheet.js +6 -0
  62. package/dist/adapters/admin/views/status.d.ts +32 -0
  63. package/dist/adapters/admin/views/status.js +74 -0
  64. package/dist/adapters/auth/handler.d.ts +10 -0
  65. package/dist/adapters/auth/handler.js +63 -0
  66. package/dist/adapters/auth/request.d.ts +8 -0
  67. package/dist/adapters/auth/request.js +14 -0
  68. package/dist/adapters/cli/bin.d.ts +2 -0
  69. package/dist/adapters/cli/bin.js +42 -0
  70. package/dist/adapters/cli/main.d.ts +7 -0
  71. package/dist/adapters/cli/main.js +982 -0
  72. package/dist/adapters/cli/remote.d.ts +52 -0
  73. package/dist/adapters/cli/remote.js +161 -0
  74. package/dist/adapters/mcp/agent-refs.d.ts +9 -0
  75. package/dist/adapters/mcp/agent-refs.js +25 -0
  76. package/dist/adapters/mcp/documents.d.ts +15 -0
  77. package/dist/adapters/mcp/documents.js +26 -0
  78. package/dist/adapters/mcp/fetch-url.d.ts +19 -0
  79. package/dist/adapters/mcp/fetch-url.js +244 -0
  80. package/dist/adapters/mcp/request-state.d.ts +15 -0
  81. package/dist/adapters/mcp/request-state.js +38 -0
  82. package/dist/adapters/mcp/results.d.ts +20 -0
  83. package/dist/adapters/mcp/results.js +61 -0
  84. package/dist/adapters/mcp/route.d.ts +34 -0
  85. package/dist/adapters/mcp/route.js +52 -0
  86. package/dist/adapters/mcp/server.d.ts +44 -0
  87. package/dist/adapters/mcp/server.js +49 -0
  88. package/dist/adapters/mcp/tools/history.d.ts +5 -0
  89. package/dist/adapters/mcp/tools/history.js +84 -0
  90. package/dist/adapters/mcp/tools/media.d.ts +5 -0
  91. package/dist/adapters/mcp/tools/media.js +102 -0
  92. package/dist/adapters/mcp/tools/publish.d.ts +5 -0
  93. package/dist/adapters/mcp/tools/publish.js +157 -0
  94. package/dist/adapters/mcp/tools/read.d.ts +5 -0
  95. package/dist/adapters/mcp/tools/read.js +279 -0
  96. package/dist/adapters/mcp/tools/redirects.d.ts +5 -0
  97. package/dist/adapters/mcp/tools/redirects.js +74 -0
  98. package/dist/adapters/mcp/tools/write.d.ts +5 -0
  99. package/dist/adapters/mcp/tools/write.js +304 -0
  100. package/dist/adapters/site/backup-schedule.d.ts +8 -0
  101. package/dist/adapters/site/backup-schedule.js +31 -0
  102. package/dist/adapters/site/cache.d.ts +29 -0
  103. package/dist/adapters/site/cache.js +63 -0
  104. package/dist/adapters/site/context.d.ts +29 -0
  105. package/dist/adapters/site/context.js +278 -0
  106. package/dist/adapters/site/head.d.ts +23 -0
  107. package/dist/adapters/site/head.js +44 -0
  108. package/dist/adapters/site/limiter.d.ts +17 -0
  109. package/dist/adapters/site/limiter.js +39 -0
  110. package/dist/adapters/site/lock.d.ts +30 -0
  111. package/dist/adapters/site/lock.js +143 -0
  112. package/dist/adapters/site/media-routes.d.ts +4 -0
  113. package/dist/adapters/site/media-routes.js +55 -0
  114. package/dist/adapters/site/plugin.d.ts +122 -0
  115. package/dist/adapters/site/plugin.js +436 -0
  116. package/dist/adapters/site/preview.d.ts +36 -0
  117. package/dist/adapters/site/preview.js +82 -0
  118. package/dist/adapters/site/public.d.ts +6 -0
  119. package/dist/adapters/site/public.js +87 -0
  120. package/dist/adapters/site/render.d.ts +45 -0
  121. package/dist/adapters/site/render.js +191 -0
  122. package/dist/adapters/site/routes.d.ts +17 -0
  123. package/dist/adapters/site/routes.js +125 -0
  124. package/dist/adapters/site/sitemap.d.ts +10 -0
  125. package/dist/adapters/site/sitemap.js +10 -0
  126. package/dist/adapters/web.d.ts +22 -0
  127. package/dist/adapters/web.js +75 -0
  128. package/dist/config.d.ts +21 -0
  129. package/dist/config.js +58 -0
  130. package/dist/core/agent/format.d.ts +62 -0
  131. package/dist/core/agent/format.js +211 -0
  132. package/dist/core/agent/schema.d.ts +6 -0
  133. package/dist/core/agent/schema.js +86 -0
  134. package/dist/core/archive.d.ts +12 -0
  135. package/dist/core/archive.js +72 -0
  136. package/dist/core/auth/auth.d.ts +4911 -0
  137. package/dist/core/auth/auth.js +61 -0
  138. package/dist/core/auth/roles.d.ts +10 -0
  139. package/dist/core/auth/roles.js +38 -0
  140. package/dist/core/auth/service.d.ts +118 -0
  141. package/dist/core/auth/service.js +424 -0
  142. package/dist/core/auth/upload-token.d.ts +8 -0
  143. package/dist/core/auth/upload-token.js +27 -0
  144. package/dist/core/backup/backup.d.ts +28 -0
  145. package/dist/core/backup/backup.js +126 -0
  146. package/dist/core/backup/restore.d.ts +41 -0
  147. package/dist/core/backup/restore.js +264 -0
  148. package/dist/core/backup/schedule.d.ts +12 -0
  149. package/dist/core/backup/schedule.js +29 -0
  150. package/dist/core/boot.d.ts +63 -0
  151. package/dist/core/boot.js +141 -0
  152. package/dist/core/check.d.ts +32 -0
  153. package/dist/core/check.js +111 -0
  154. package/dist/core/content/activity.d.ts +8 -0
  155. package/dist/core/content/activity.js +101 -0
  156. package/dist/core/content/delete.d.ts +5 -0
  157. package/dist/core/content/delete.js +100 -0
  158. package/dist/core/content/diff.d.ts +6 -0
  159. package/dist/core/content/diff.js +129 -0
  160. package/dist/core/content/dry-run.d.ts +24 -0
  161. package/dist/core/content/dry-run.js +69 -0
  162. package/dist/core/content/gaps.d.ts +25 -0
  163. package/dist/core/content/gaps.js +50 -0
  164. package/dist/core/content/hidden.d.ts +33 -0
  165. package/dist/core/content/hidden.js +103 -0
  166. package/dist/core/content/history.d.ts +15 -0
  167. package/dist/core/content/history.js +62 -0
  168. package/dist/core/content/patch.d.ts +40 -0
  169. package/dist/core/content/patch.js +287 -0
  170. package/dist/core/content/path.d.ts +6 -0
  171. package/dist/core/content/path.js +38 -0
  172. package/dist/core/content/publish.d.ts +26 -0
  173. package/dist/core/content/publish.js +211 -0
  174. package/dist/core/content/read.d.ts +99 -0
  175. package/dist/core/content/read.js +141 -0
  176. package/dist/core/content/reader.d.ts +37 -0
  177. package/dist/core/content/reader.js +195 -0
  178. package/dist/core/content/refs.d.ts +44 -0
  179. package/dist/core/content/refs.js +161 -0
  180. package/dist/core/content/release-migrations.d.ts +12 -0
  181. package/dist/core/content/release-migrations.js +154 -0
  182. package/dist/core/content/save.d.ts +25 -0
  183. package/dist/core/content/save.js +87 -0
  184. package/dist/core/content/schema.d.ts +22 -0
  185. package/dist/core/content/schema.js +127 -0
  186. package/dist/core/content/search.d.ts +8 -0
  187. package/dist/core/content/search.js +89 -0
  188. package/dist/core/content/shipped-input.d.ts +39 -0
  189. package/dist/core/content/shipped-input.js +221 -0
  190. package/dist/core/content/shipped.d.ts +112 -0
  191. package/dist/core/content/shipped.js +437 -0
  192. package/dist/core/content/slug.d.ts +23 -0
  193. package/dist/core/content/slug.js +182 -0
  194. package/dist/core/content/stats.d.ts +11 -0
  195. package/dist/core/content/stats.js +30 -0
  196. package/dist/core/content/translate.d.ts +3 -0
  197. package/dist/core/content/translate.js +68 -0
  198. package/dist/core/content/usages.d.ts +13 -0
  199. package/dist/core/content/usages.js +70 -0
  200. package/dist/core/content/validate.d.ts +21 -0
  201. package/dist/core/content/validate.js +124 -0
  202. package/dist/core/content/write.d.ts +10 -0
  203. package/dist/core/content/write.js +93 -0
  204. package/dist/core/core.d.ts +227 -0
  205. package/dist/core/core.js +251 -0
  206. package/dist/core/db/connection.d.ts +6 -0
  207. package/dist/core/db/connection.js +12 -0
  208. package/dist/core/db/migrate.d.ts +9 -0
  209. package/dist/core/db/migrate.js +42 -0
  210. package/dist/core/db/migrations/0001_content.d.ts +2 -0
  211. package/dist/core/db/migrations/0001_content.js +69 -0
  212. package/dist/core/db/migrations/0002_media.d.ts +2 -0
  213. package/dist/core/db/migrations/0002_media.js +26 -0
  214. package/dist/core/db/migrations/0003_redirects.d.ts +2 -0
  215. package/dist/core/db/migrations/0003_redirects.js +19 -0
  216. package/dist/core/db/migrations/0004_token_cutoffs.d.ts +3 -0
  217. package/dist/core/db/migrations/0004_token_cutoffs.js +8 -0
  218. package/dist/core/db/migrations/0005_site_lock.d.ts +3 -0
  219. package/dist/core/db/migrations/0005_site_lock.js +10 -0
  220. package/dist/core/db/migrations/0006_releases.d.ts +3 -0
  221. package/dist/core/db/migrations/0006_releases.js +34 -0
  222. package/dist/core/db/schema.d.ts +155 -0
  223. package/dist/core/db/schema.js +1 -0
  224. package/dist/core/errors.d.ts +27 -0
  225. package/dist/core/errors.js +15 -0
  226. package/dist/core/export/export.d.ts +17 -0
  227. package/dist/core/export/export.js +185 -0
  228. package/dist/core/export/format.d.ts +241 -0
  229. package/dist/core/export/format.js +106 -0
  230. package/dist/core/export/import.d.ts +54 -0
  231. package/dist/core/export/import.js +180 -0
  232. package/dist/core/export/read.d.ts +16 -0
  233. package/dist/core/export/read.js +234 -0
  234. package/dist/core/export/replace.d.ts +17 -0
  235. package/dist/core/export/replace.js +36 -0
  236. package/dist/core/export/report.d.ts +55 -0
  237. package/dist/core/export/report.js +50 -0
  238. package/dist/core/export/schema.d.ts +8 -0
  239. package/dist/core/export/schema.js +47 -0
  240. package/dist/core/export/stage.d.ts +25 -0
  241. package/dist/core/export/stage.js +192 -0
  242. package/dist/core/fields/builtins.d.ts +70 -0
  243. package/dist/core/fields/builtins.js +335 -0
  244. package/dist/core/fields/define.d.ts +86 -0
  245. package/dist/core/fields/define.js +34 -0
  246. package/dist/core/fields/walk.d.ts +49 -0
  247. package/dist/core/fields/walk.js +270 -0
  248. package/dist/core/fields/widgets.d.ts +27 -0
  249. package/dist/core/fields/widgets.js +330 -0
  250. package/dist/core/fields/zod-internals.d.ts +29 -0
  251. package/dist/core/fields/zod-internals.js +28 -0
  252. package/dist/core/media/detect.d.ts +5 -0
  253. package/dist/core/media/detect.js +66 -0
  254. package/dist/core/media/labels.d.ts +6 -0
  255. package/dist/core/media/labels.js +17 -0
  256. package/dist/core/media/library.d.ts +45 -0
  257. package/dist/core/media/library.js +239 -0
  258. package/dist/core/media/store.d.ts +11 -0
  259. package/dist/core/media/store.js +49 -0
  260. package/dist/core/media/variants.d.ts +10 -0
  261. package/dist/core/media/variants.js +59 -0
  262. package/dist/core/messages/en.d.ts +1278 -0
  263. package/dist/core/messages/en.js +1287 -0
  264. package/dist/core/messages/index.d.ts +7 -0
  265. package/dist/core/messages/index.js +14 -0
  266. package/dist/core/preview.d.ts +16 -0
  267. package/dist/core/preview.js +42 -0
  268. package/dist/core/redirects/collapse.d.ts +68 -0
  269. package/dist/core/redirects/collapse.js +153 -0
  270. package/dist/core/redirects/csv.d.ts +15 -0
  271. package/dist/core/redirects/csv.js +68 -0
  272. package/dist/core/redirects/redirects.d.ts +58 -0
  273. package/dist/core/redirects/redirects.js +545 -0
  274. package/dist/core/registry/content.d.ts +26 -0
  275. package/dist/core/registry/content.js +9 -0
  276. package/dist/core/registry/define.d.ts +145 -0
  277. package/dist/core/registry/define.js +41 -0
  278. package/dist/core/registry/migration.d.ts +44 -0
  279. package/dist/core/registry/migration.js +4 -0
  280. package/dist/core/registry/registry.d.ts +18 -0
  281. package/dist/core/registry/registry.js +255 -0
  282. package/dist/core/registry/render.d.ts +98 -0
  283. package/dist/core/registry/render.js +1 -0
  284. package/dist/core/registry/route.d.ts +42 -0
  285. package/dist/core/registry/route.js +3 -0
  286. package/dist/core/release/bundle.d.ts +21 -0
  287. package/dist/core/release/bundle.js +252 -0
  288. package/dist/core/release/keys.d.ts +11 -0
  289. package/dist/core/release/keys.js +60 -0
  290. package/dist/core/release/manifest.d.ts +103 -0
  291. package/dist/core/release/manifest.js +138 -0
  292. package/dist/core/release/pack.d.ts +20 -0
  293. package/dist/core/release/pack.js +97 -0
  294. package/dist/core/release/pointer.d.ts +19 -0
  295. package/dist/core/release/pointer.js +53 -0
  296. package/dist/core/release/read.d.ts +59 -0
  297. package/dist/core/release/read.js +256 -0
  298. package/dist/core/report.d.ts +31 -0
  299. package/dist/core/report.js +37 -0
  300. package/dist/core/richtext/html.d.ts +15 -0
  301. package/dist/core/richtext/html.js +81 -0
  302. package/dist/core/richtext/markdown.d.ts +19 -0
  303. package/dist/core/richtext/markdown.js +951 -0
  304. package/dist/core/richtext/schema.d.ts +98 -0
  305. package/dist/core/richtext/schema.js +275 -0
  306. package/dist/core/site/live.d.ts +56 -0
  307. package/dist/core/site/live.js +145 -0
  308. package/dist/core/site/paths.d.ts +15 -0
  309. package/dist/core/site/paths.js +64 -0
  310. package/dist/core/site/resolve.d.ts +9 -0
  311. package/dist/core/site/resolve.js +202 -0
  312. package/dist/core/site/sitemap.d.ts +11 -0
  313. package/dist/core/site/sitemap.js +24 -0
  314. package/dist/core/site-lock/site-lock.d.ts +21 -0
  315. package/dist/core/site-lock/site-lock.js +65 -0
  316. package/dist/core/site-lock/token.d.ts +7 -0
  317. package/dist/core/site-lock/token.js +24 -0
  318. package/dist/core/theme.d.ts +22 -0
  319. package/dist/core/theme.js +133 -0
  320. package/dist/core/types.d.ts +253 -0
  321. package/dist/core/types.js +1 -0
  322. package/dist/core/version.d.ts +1 -0
  323. package/dist/core/version.js +5 -0
  324. package/dist/host/activate.d.ts +53 -0
  325. package/dist/host/activate.js +162 -0
  326. package/dist/host/app.d.ts +46 -0
  327. package/dist/host/app.js +129 -0
  328. package/dist/host/bin.d.ts +5 -0
  329. package/dist/host/bin.js +8 -0
  330. package/dist/host/config.d.ts +36 -0
  331. package/dist/host/config.js +152 -0
  332. package/dist/host/dev.d.ts +10 -0
  333. package/dist/host/dev.js +293 -0
  334. package/dist/host/diff.d.ts +78 -0
  335. package/dist/host/diff.js +346 -0
  336. package/dist/host/hooks.d.ts +41 -0
  337. package/dist/host/hooks.js +49 -0
  338. package/dist/host/ipc.d.ts +123 -0
  339. package/dist/host/ipc.js +61 -0
  340. package/dist/host/preview-proxy.d.ts +24 -0
  341. package/dist/host/preview-proxy.js +154 -0
  342. package/dist/host/preview-worker.d.ts +42 -0
  343. package/dist/host/preview-worker.js +242 -0
  344. package/dist/host/primary.d.ts +38 -0
  345. package/dist/host/primary.js +357 -0
  346. package/dist/host/push.d.ts +125 -0
  347. package/dist/host/push.js +420 -0
  348. package/dist/host/serve.d.ts +16 -0
  349. package/dist/host/serve.js +150 -0
  350. package/dist/host/store.d.ts +48 -0
  351. package/dist/host/store.js +109 -0
  352. package/dist/host/worker.d.ts +67 -0
  353. package/dist/host/worker.js +310 -0
  354. package/dist/index.d.ts +47 -0
  355. package/dist/index.js +32 -0
  356. package/dist/jsx/html.d.ts +16 -0
  357. package/dist/jsx/html.js +65 -0
  358. package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
  359. package/dist/jsx/jsx-dev-runtime.js +5 -0
  360. package/dist/jsx/jsx-runtime.d.ts +17 -0
  361. package/dist/jsx/jsx-runtime.js +41 -0
  362. package/dist/site.d.ts +17 -0
  363. package/dist/site.js +14 -0
  364. package/package.json +111 -3
@@ -0,0 +1,117 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "inlaycms/jsx-runtime";
2
+ import { t } from '../../../core/messages/index.js';
3
+ import { Icon } from './icons.js';
4
+ export const PAGE_SIZES = [25, 50, 100];
5
+ const DEFAULT_SIZE = 25;
6
+ const textOf = (value) => (typeof value === 'string' ? value : '');
7
+ /** Reads a table's search, status tab, sort and page from the query string; anything unknown falls back to the default. */
8
+ export function readTableQuery(query, opts) {
9
+ const status = textOf(query.status);
10
+ const sort = textOf(query.sort);
11
+ const dir = textOf(query.dir);
12
+ const pageText = textOf(query.page);
13
+ const page = /^\d+$/.test(pageText) ? Number(pageText) : 1;
14
+ const sizeText = textOf(query.size);
15
+ return {
16
+ q: textOf(query.q).trim(),
17
+ status: opts.statuses?.includes(status) ? status : (opts.statuses?.[0] ?? ''),
18
+ sort: opts.sorts.includes(sort) ? sort : opts.defaultSort,
19
+ dir: dir === 'asc' || dir === 'desc' ? dir : opts.defaultDir,
20
+ page: Number.isSafeInteger(page) && page >= 1 ? page : 1,
21
+ size: PAGE_SIZES.find((n) => String(n) === sizeText) ?? DEFAULT_SIZE,
22
+ };
23
+ }
24
+ /** The rows on the asked-for page; a page past the end shows the last page. */
25
+ export function pageOf(rows, query) {
26
+ const pages = Math.max(1, Math.ceil(rows.length / query.size));
27
+ const page = Math.min(query.page, pages);
28
+ const start = (page - 1) * query.size;
29
+ return { rows: rows.slice(start, start + query.size), total: rows.length, page };
30
+ }
31
+ /** `base` with `params` as its query string, leaving out empty values. */
32
+ export function tableHref(base, params) {
33
+ const query = new URLSearchParams(Object.entries(params).filter(([, v]) => v !== '')).toString();
34
+ return query === '' ? base : `${base}?${query}`;
35
+ }
36
+ /** htmx attributes that load `href` and swap just this table, keeping the address in the URL. */
37
+ function swapTo(id, href) {
38
+ return { 'hx-get': href, 'hx-target': `#${id}`, 'hx-select': `#${id}`, 'hx-swap': 'outerHTML', 'hx-push-url': 'true' };
39
+ }
40
+ function cellClass(col, base = '') {
41
+ const cls = [base, col.align === 'end' ? 'text-right' : '', col.class ?? ''].filter((c) => c !== '').join(' ');
42
+ return cls === '' ? undefined : cls;
43
+ }
44
+ /** First, last, and the current page with its neighbors; `0` stands for a gap. */
45
+ function pageNumbers(page, pages) {
46
+ const out = [];
47
+ let last = 0;
48
+ for (let p = 1; p <= pages; p++) {
49
+ if (p !== 1 && p !== pages && Math.abs(p - page) > 1)
50
+ continue;
51
+ if (p - last > 1)
52
+ out.push(0);
53
+ out.push(p);
54
+ last = p;
55
+ }
56
+ return out;
57
+ }
58
+ function RowMenu({ title, formId, actions }) {
59
+ return (_jsxs("details", { class: "dropdown dropdown-end", children: [_jsx("summary", { class: "btn btn-ghost btn-xs btn-square", "aria-label": t('admin.table.actionsFor', { title }), children: _jsx(Icon, { name: "more" }) }), _jsx("ul", { class: "dropdown-content menu menu-sm z-20 w-44 rounded-box border border-base-300 bg-base-100 p-1 shadow-lg", children: actions.map((action, i) => (_jsx("li", { children: action.method === 'post' ? (_jsxs("button", { type: "submit", form: `${formId}-${i}`, class: action.danger ? 'text-error' : undefined, children: [_jsx(Icon, { name: action.icon }), action.label] })) : (_jsxs("a", { href: action.href, class: action.danger ? 'text-error' : undefined, children: [_jsx(Icon, { name: action.icon }), action.label] })) }))) })] }));
60
+ }
61
+ /**
62
+ * The admin's shared table. Search, status tabs, sorting and paging live in the URL and work without JS; htmx swaps
63
+ * `div#<id>` for speed. With `bulk`, each row gets a box tied to `form#<id>-bulk`.
64
+ */
65
+ export function DataTable(props) {
66
+ const { id, caption, base, query, rows, columns, rowKey, rowLabel, search, tabs, toolbarEnd, rowActions, bulk, total } = props;
67
+ const filtersId = `${id}-filters`;
68
+ const bulkId = `${id}-bulk`;
69
+ const keep = Object.fromEntries(Object.entries(props.keep ?? {}).filter(([, v]) => v !== ''));
70
+ const paged = query !== undefined && total !== undefined && total > query.size;
71
+ const pages = paged ? Math.ceil(total / query.size) : 1;
72
+ const page = query === undefined ? 1 : Math.min(query.page, pages);
73
+ const state = query === undefined
74
+ ? keep
75
+ : { ...keep, q: query.q, status: query.status, sort: query.sort, dir: query.dir, size: query.size === DEFAULT_SIZE ? '' : String(query.size) };
76
+ const href = (over) => tableHref(base, { ...state, ...over });
77
+ const colSpan = columns.length + (bulk === undefined ? 0 : 1) + (rowActions === undefined ? 0 : 1);
78
+ const hasToolbar = search !== undefined || tabs !== undefined || toolbarEnd !== undefined;
79
+ const controls = props.controls ?? [];
80
+ const hidden = Object.entries(state).filter(([name, value]) => value !== '' && name !== 'q' && (name !== 'size' || !paged) && !controls.includes(name));
81
+ const filters = (query !== undefined || hasToolbar) && (_jsxs("form", { id: filtersId, method: "get", action: base, ...swapTo(id, base), "hx-trigger": "submit, input changed delay:300ms from:find input[name=q], change from:find select", class: hasToolbar ? 'flex min-h-12 flex-wrap items-center gap-2 border-b border-base-300 px-3 py-2' : 'contents', children: [hidden.map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }))), search !== undefined && (_jsxs(_Fragment, { children: [_jsx("label", { for: `${id}-q`, class: "sr-only", children: search.label }), _jsxs("div", { class: "input input-sm w-full sm:w-64", children: [_jsx(Icon, { name: "search", class: "opacity-50" }), _jsx("input", { id: `${id}-q`, name: "q", type: "search", value: query?.q ?? '', placeholder: search.label, autocomplete: "off" })] })] })), tabs !== undefined && query !== undefined && (_jsx("div", { class: "tabs tabs-box tabs-sm", role: "group", "aria-label": t('admin.table.status'), children: tabs.map((tab) => {
82
+ const link = href({ status: tab.key });
83
+ const active = tab.key === query.status;
84
+ return (_jsxs("a", { href: link, ...swapTo(id, link), class: active ? 'tab tab-active gap-1.5' : 'tab gap-1.5', "aria-current": active ? 'true' : undefined, children: [tab.label, _jsx("span", { class: "text-xs text-base-content/60 tabular-nums", children: tab.count })] }));
85
+ }) })), toolbarEnd !== undefined && _jsx("div", { class: "ml-auto flex flex-wrap items-center gap-2", children: toolbarEnd }), _jsx("button", { type: "submit", class: "btn btn-sm sr-only focus:not-sr-only", children: t('admin.table.apply') })] }));
86
+ const bulkBar = bulk !== undefined && (_jsx("div", { "data-bulk-bar": true, "data-selected-template": t('admin.table.selected', { count: '{count}' }), class: "flex min-h-12 items-center border-b border-base-300 bg-primary/5 px-3 py-2", children: _jsxs("form", { id: bulkId, method: "get", class: "flex w-full flex-wrap items-center gap-2", children: [_jsx("span", { "data-selected-count": true, class: "text-sm font-medium tabular-nums" }), bulk.actions, _jsxs("button", { type: "button", "data-clear-selection": true, class: "btn btn-ghost btn-xs ml-auto", children: [_jsx(Icon, { name: "x" }), t('admin.table.clear')] })] }) }));
87
+ const head = (_jsxs("tr", { children: [bulk !== undefined && (_jsx("th", { scope: "col", class: "w-10", children: _jsx("input", { type: "checkbox", class: "checkbox checkbox-xs", "data-select-all": true, form: bulkId, "aria-label": t('admin.table.selectAll') }) })), columns.map((col) => {
88
+ const label = col.hideLabel === true ? _jsx("span", { class: "sr-only", children: col.label }) : col.label;
89
+ if (col.sortable !== true || query === undefined) {
90
+ return (_jsx("th", { scope: "col", class: cellClass(col), children: label }));
91
+ }
92
+ const sorted = query.sort === col.key;
93
+ const link = href({ sort: col.key, dir: sorted && query.dir === 'asc' ? 'desc' : 'asc' });
94
+ return (_jsx("th", { scope: "col", class: cellClass(col), "aria-sort": sorted ? (query.dir === 'asc' ? 'ascending' : 'descending') : undefined, children: _jsxs("a", { href: link, ...swapTo(id, link), class: "inline-flex items-center gap-1 hover:text-base-content", children: [label, sorted ? (_jsx(Icon, { name: query.dir === 'asc' ? 'arrow-up' : 'arrow-down', class: "size-3!" })) : (_jsx(Icon, { name: "updown", class: "size-3! opacity-30" }))] }) }));
95
+ }), rowActions !== undefined && (_jsx("th", { scope: "col", class: "w-10", children: _jsx("span", { class: "sr-only", children: t('admin.table.actions') }) }))] }));
96
+ const body = rows.length === 0 ? (_jsx("tr", { children: _jsx("td", { colspan: colSpan, class: "py-12 text-center text-base-content/60", children: query !== undefined && query.q !== '' ? t('admin.table.noMatches') : props.empty }) })) : (rows.map((row) => {
97
+ const title = rowLabel(row);
98
+ const actions = rowActions?.(row) ?? [];
99
+ const formId = `${id}-act-${rowKey(row)}`;
100
+ return (_jsxs("tr", { class: "hover:bg-base-200/60", children: [bulk !== undefined && (_jsx("td", { class: "w-10", children: _jsx("input", { type: "checkbox", class: "checkbox checkbox-xs", name: "ids", form: bulkId, value: rowKey(row), "aria-label": t('admin.table.select', { title }) }) })), columns.map((col, i) => i === 0 ? (_jsx("th", { scope: "row", class: cellClass(col, 'font-medium'), children: col.cell(row) })) : (_jsx("td", { class: cellClass(col), children: col.cell(row) }))), rowActions !== undefined && (_jsxs("td", { class: "w-10 text-right", children: [actions.map((action, i) => action.method === 'post' ? _jsx("form", { id: `${formId}-${i}`, method: "post", action: action.href, hidden: true }) : null), actions.length > 0 && _jsx(RowMenu, { title: title, formId: formId, actions: actions })] }))] }));
101
+ }));
102
+ const pageLink = (p) => href({ page: p === 1 ? '' : String(p) });
103
+ const prevLink = pageLink(page - 1);
104
+ const nextLink = pageLink(page + 1);
105
+ const footer = paged && (_jsxs("nav", { "aria-label": t('admin.table.pages'), class: "flex flex-wrap items-center gap-3 border-t border-base-300 px-3 py-2 text-sm text-base-content/70", children: [_jsx("span", { class: "tabular-nums", children: t('admin.table.showing', {
106
+ from: (page - 1) * query.size + 1,
107
+ to: Math.min(page * query.size, total),
108
+ total,
109
+ }) }), _jsxs("span", { class: "ml-auto flex items-center gap-2", children: [_jsx("label", { for: `${id}-size`, children: t('admin.table.rowsPerPage') }), _jsx("select", { id: `${id}-size`, name: "size", form: filtersId, class: "select select-xs w-16", ...swapTo(id, base), "hx-include": `#${filtersId}`, children: PAGE_SIZES.map((n) => (_jsx("option", { value: String(n), selected: n === query.size, children: n }))) })] }), _jsxs("div", { class: "join", children: [page > 1 ? (_jsx("a", { href: prevLink, ...swapTo(id, prevLink), class: "join-item btn btn-xs", "aria-label": t('admin.list.prev'), children: _jsx(Icon, { name: "chevron-left" }) })) : (_jsx("span", { class: "join-item btn btn-xs btn-disabled", "aria-hidden": "true", children: _jsx(Icon, { name: "chevron-left" }) })), pageNumbers(page, pages).map((p) => {
110
+ if (p === 0) {
111
+ return (_jsx("span", { class: "join-item btn btn-xs btn-disabled", "aria-hidden": "true", children: "\u2026" }));
112
+ }
113
+ const link = pageLink(p);
114
+ return (_jsx("a", { href: link, ...swapTo(id, link), class: p === page ? 'join-item btn btn-xs btn-active' : 'join-item btn btn-xs', "aria-label": t('admin.list.page', { page: p }), "aria-current": p === page ? 'page' : undefined, children: p }));
115
+ }), page < pages ? (_jsx("a", { href: nextLink, ...swapTo(id, nextLink), class: "join-item btn btn-xs", "aria-label": t('admin.list.next'), children: _jsx(Icon, { name: "chevron-right" }) })) : (_jsx("span", { class: "join-item btn btn-xs btn-disabled", "aria-hidden": "true", children: _jsx(Icon, { name: "chevron-right" }) }))] })] }));
116
+ return (_jsxs("div", { id: id, class: "rounded-box border border-base-300 bg-base-100", children: [filters, bulkBar, _jsx("div", { class: "overflow-x-auto lg:overflow-visible", children: _jsxs("table", { class: "table table-sm", children: [_jsx("caption", { class: "sr-only", children: caption }), _jsx("thead", { class: "text-xs text-base-content/60", children: head }), _jsx("tbody", { children: body })] }) }), footer] }));
117
+ }
@@ -0,0 +1,48 @@
1
+ declare const PATHS: {
2
+ readonly menu: '<line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/>';
3
+ readonly search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>';
4
+ readonly external: '<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3"/>';
5
+ readonly send: '<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>';
6
+ readonly upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>';
7
+ readonly plus: '<path d="M5 12h14"/><path d="M12 5v14"/>';
8
+ readonly 'chevron-down': '<path d="m6 9 6 6 6-6"/>';
9
+ readonly 'chevron-left': '<path d="m15 18-6-6 6-6"/>';
10
+ readonly 'chevron-right': '<path d="m9 18 6-6-6-6"/>';
11
+ readonly updown: '<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>';
12
+ readonly 'arrow-up': '<path d="m5 12 7-7 7 7"/><path d="M12 19V5"/>';
13
+ readonly 'arrow-down': '<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>';
14
+ readonly dashboard: '<rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/>';
15
+ readonly file: '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M16 13H8"/><path d="M16 17H8"/>';
16
+ readonly globe: '<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>';
17
+ readonly collection: '<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>';
18
+ readonly image: '<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>';
19
+ readonly redirect: '<polyline points="15 14 20 9 15 4"/><path d="M4 20v-7a4 4 0 0 1 4-4h12"/>';
20
+ readonly users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>';
21
+ readonly archive: '<rect width="20" height="5" x="2" y="3" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/>';
22
+ readonly rocket: '<path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"/><path d="m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"/><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/>';
23
+ readonly lock: '<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>';
24
+ readonly user: '<circle cx="12" cy="12" r="10"/><circle cx="12" cy="10" r="3"/><path d="M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662"/>';
25
+ readonly logout: '<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/>';
26
+ readonly download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>';
27
+ readonly 'check-circle': '<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>';
28
+ readonly alert: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>';
29
+ readonly more: '<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>';
30
+ readonly pencil: '<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/>';
31
+ readonly history: '<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/>';
32
+ readonly trash: '<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>';
33
+ readonly x: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>';
34
+ readonly info: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>';
35
+ readonly monitor: '<rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>';
36
+ readonly tablet: '<rect width="16" height="20" x="4" y="2" rx="2" ry="2"/><line x1="12" x2="12.01" y1="18" y2="18"/>';
37
+ readonly smartphone: '<rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/>';
38
+ readonly 'panel-right': '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/>';
39
+ readonly refresh: '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>';
40
+ readonly eye: '<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>';
41
+ };
42
+ export type IconName = keyof typeof PATHS;
43
+ /** A decorative Lucide icon; give the control around it an accessible name. */
44
+ export declare function Icon({ name, class: cls }: {
45
+ name: IconName;
46
+ class?: string;
47
+ }): import("../../../jsx/html.js").Html;
48
+ export {};
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "inlaycms/jsx-runtime";
2
+ import { raw } from '../../../jsx/html.js';
3
+ const PATHS = {
4
+ menu: '<line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/>',
5
+ search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',
6
+ external: '<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3"/>',
7
+ send: '<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>',
8
+ upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>',
9
+ plus: '<path d="M5 12h14"/><path d="M12 5v14"/>',
10
+ 'chevron-down': '<path d="m6 9 6 6 6-6"/>',
11
+ 'chevron-left': '<path d="m15 18-6-6 6-6"/>',
12
+ 'chevron-right': '<path d="m9 18 6-6-6-6"/>',
13
+ updown: '<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',
14
+ 'arrow-up': '<path d="m5 12 7-7 7 7"/><path d="M12 19V5"/>',
15
+ 'arrow-down': '<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',
16
+ dashboard: '<rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/>',
17
+ file: '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M16 13H8"/><path d="M16 17H8"/>',
18
+ globe: '<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>',
19
+ collection: '<path d="m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>',
20
+ image: '<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>',
21
+ redirect: '<polyline points="15 14 20 9 15 4"/><path d="M4 20v-7a4 4 0 0 1 4-4h12"/>',
22
+ users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
23
+ archive: '<rect width="20" height="5" x="2" y="3" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/>',
24
+ rocket: '<path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"/><path d="m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"/><path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"/><path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"/>',
25
+ lock: '<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',
26
+ user: '<circle cx="12" cy="12" r="10"/><circle cx="12" cy="10" r="3"/><path d="M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662"/>',
27
+ logout: '<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/>',
28
+ download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',
29
+ 'check-circle': '<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',
30
+ alert: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>',
31
+ more: '<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',
32
+ pencil: '<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/>',
33
+ history: '<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/>',
34
+ trash: '<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>',
35
+ x: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
36
+ info: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>',
37
+ monitor: '<rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>',
38
+ tablet: '<rect width="16" height="20" x="4" y="2" rx="2" ry="2"/><line x1="12" x2="12.01" y1="18" y2="18"/>',
39
+ smartphone: '<rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/>',
40
+ 'panel-right': '<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/>',
41
+ refresh: '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',
42
+ eye: '<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>',
43
+ };
44
+ /** A decorative Lucide icon; give the control around it an accessible name. */
45
+ export function Icon({ name, class: cls }) {
46
+ return (_jsx("svg", { class: cls === undefined ? 'size-4 shrink-0' : `size-4 shrink-0 ${cls}`, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", "aria-hidden": "true", focusable: "false", children: raw(PATHS[name]) }));
47
+ }
@@ -0,0 +1,51 @@
1
+ import type { Actor } from '../../../core/types.js';
2
+ import { type Renderable } from '../../../jsx/html.js';
3
+ import type { AdminContext, Section } from '../context.js';
4
+ /** Up to two initials from `name` (its first and last words), for the small circle next to a person. */
5
+ export declare function initials(name: string): string;
6
+ /**
7
+ * The one dialog every publish and unpublish button opens in: `client/admin/publish.ts` loads the publish page's
8
+ * `#publish-panel` into its body. Without JS, those buttons go to the publish page itself.
9
+ */
10
+ export declare function PublishDialog(): import("../../../jsx/html.js").Html;
11
+ export interface AdminPageOptions {
12
+ title: string;
13
+ actor: Actor;
14
+ section?: Section;
15
+ /** A success message, from `noticeOf`. Not shown when `status` is an error. */
16
+ notice?: string;
17
+ /** The status the page is sent with. */
18
+ status?: number;
19
+ scripts?: Array<'editor.js'>;
20
+ breadcrumbs?: Array<{
21
+ label: string;
22
+ href: string;
23
+ }>;
24
+ /** A line under the heading saying what the page is for. */
25
+ description?: string;
26
+ /** The page's main action(s), on the right of the heading. */
27
+ actions?: Renderable;
28
+ /**
29
+ * `workspace`: a full-height page whose heading is a compact bar and whose `body` fills the rest of the screen, for
30
+ * screens that scroll their own panes (the editor).
31
+ */
32
+ layout?: 'workspace';
33
+ }
34
+ /**
35
+ * A signed-in admin page: the menu on the left (a drawer on small screens), the top bar, and `body` under the page's
36
+ * one heading.
37
+ */
38
+ export declare function adminPage(ctx: AdminContext, opts: AdminPageOptions, body: Renderable): Promise<string>;
39
+ /** A page for someone who isn't signed in (setup, login, consent, uploads): a centered card with the brand, no navigation. */
40
+ export declare function authPage(ctx: AdminContext, title: string, body: Renderable): Promise<string>;
41
+ /** A time in UTC, which `admin.js` rewrites into the reader's own time zone. */
42
+ export declare function Time({ iso, relative }: {
43
+ iso: string;
44
+ relative?: boolean;
45
+ }): import("../../../jsx/html.js").Html;
46
+ /** A message box; an error is announced as an alert. */
47
+ export declare function Alert({ kind, id, children }: {
48
+ kind: 'error' | 'warning' | 'info';
49
+ id?: string;
50
+ children?: Renderable;
51
+ }): import("../../../jsx/html.js").Html;
@@ -0,0 +1,145 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "inlaycms/jsx-runtime";
2
+ import { t } from '../../../core/messages/index.js';
3
+ import { raw, renderToString } from '../../../jsx/html.js';
4
+ import { Icon } from './icons.js';
5
+ import { Badge, badgeClass } from './status.js';
6
+ const HTMX_CONFIG = JSON.stringify({
7
+ allowEval: false,
8
+ allowScriptTags: false,
9
+ includeIndicatorStyles: false,
10
+ selfRequestsOnly: true,
11
+ });
12
+ /** A message under a workspace page's heading: a thin full-width bar. */
13
+ const BAR = 'shrink-0 rounded-none border-x-0 border-t-0 px-4 py-1.5 text-sm';
14
+ const UTC = new Intl.DateTimeFormat('en', { dateStyle: 'medium', timeStyle: 'short', timeZone: 'UTC' });
15
+ function Head({ ctx, title, scripts }) {
16
+ const { theme, name } = ctx.branding;
17
+ return (_jsxs("head", { children: [_jsx("meta", { charset: "utf-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), _jsx("meta", { name: "robots", content: "noindex" }), _jsx("meta", { name: "htmx-config", content: HTMX_CONFIG }), _jsx("title", { children: t('admin.pageTitle', { title, name }) }), _jsx("link", { rel: "stylesheet", href: ctx.assets.url('admin.css') }), theme.css !== '' && _jsx("style", { children: raw(theme.css) }), scripts.map((script) => (_jsx("script", { type: "module", src: ctx.assets.url(script) })))] }));
18
+ }
19
+ function SkipLink() {
20
+ return (_jsx("a", { href: "#main", class: "sr-only focus:not-sr-only focus:absolute focus:left-4 focus:top-4 focus:z-50 btn btn-primary", children: t('admin.skipLink') }));
21
+ }
22
+ /** The logo with the brand name as its text, or the name itself. */
23
+ function Brand({ ctx }) {
24
+ const { name, logo } = ctx.branding;
25
+ return logo !== undefined ? (_jsx("img", { src: logo, alt: name, class: "h-10 w-auto max-w-full" })) : (_jsx("span", { class: "text-lg font-semibold", children: name }));
26
+ }
27
+ /** The sections `actor` may visit, grouped as in the menu; collections carry their entry counts. */
28
+ function navItems(ctx, actor, counts) {
29
+ const { site } = ctx.core.registry;
30
+ const top = [{ section: 'dashboard', href: '/admin', label: t('admin.nav.dashboard'), icon: 'dashboard' }];
31
+ const content = [];
32
+ if (site.singletons.length > 0)
33
+ content.push({ section: 'pages', href: '/admin/pages', label: t('admin.nav.pages'), icon: 'file' });
34
+ if (site.globals.length > 0)
35
+ content.push({ section: 'globals', href: '/admin/globals', label: t('admin.nav.globals'), icon: 'globe' });
36
+ for (const collection of site.collections) {
37
+ content.push({
38
+ section: `collection:${collection.name}`,
39
+ href: `/admin/collections/${encodeURIComponent(collection.name)}`,
40
+ label: collection.label,
41
+ icon: 'collection',
42
+ count: counts[collection.name]?.total ?? 0,
43
+ });
44
+ }
45
+ content.push({ section: 'media', href: '/admin/media', label: t('admin.nav.media'), icon: 'image' });
46
+ const siteItems = [{ section: 'redirects', href: '/admin/redirects', label: t('admin.nav.redirects'), icon: 'redirect' }];
47
+ if (actor.role === 'owner') {
48
+ siteItems.push({ section: 'users', href: '/admin/users', label: t('admin.nav.users'), icon: 'users' });
49
+ siteItems.push({ section: 'backups', href: '/admin/backups', label: t('admin.nav.backups'), icon: 'archive' });
50
+ if (ctx.db !== undefined && ctx.releasesDir !== undefined) {
51
+ siteItems.push({ section: 'releases', href: '/admin/releases', label: t('admin.nav.releases'), icon: 'rocket' });
52
+ }
53
+ siteItems.push({ section: 'security', href: '/admin/security', label: t('admin.nav.security'), icon: 'lock' });
54
+ }
55
+ return { top, content, site: siteItems };
56
+ }
57
+ function NavLink({ item, section }) {
58
+ const current = item.section === section;
59
+ return (_jsx("li", { children: _jsxs("a", { href: item.href, "aria-current": current ? 'page' : undefined, class: current ? 'menu-active' : undefined, children: [_jsx(Icon, { name: item.icon }), _jsx("span", { class: "truncate", children: item.label }), item.count !== undefined && (_jsx(Badge, { tone: "ghost", class: "ml-auto tabular-nums", children: item.count }))] }) }));
60
+ }
61
+ /** Up to two initials from `name` (its first and last words), for the small circle next to a person. */
62
+ export function initials(name) {
63
+ const letters = name
64
+ .trim()
65
+ .split(/\s+/)
66
+ .map((word) => Array.from(word)[0] ?? '')
67
+ .filter((letter) => letter !== '');
68
+ const first = letters[0] ?? '?';
69
+ const last = letters.length > 1 ? (letters[letters.length - 1] ?? '') : '';
70
+ return `${first}${last}`.toUpperCase();
71
+ }
72
+ function PersonMenu({ actor, section }) {
73
+ const current = section === 'account';
74
+ return (_jsxs("details", { class: "dropdown dropdown-top w-full", children: [_jsxs("summary", { class: "flex w-full cursor-pointer list-none items-center gap-3 rounded-field px-2 py-2 hover:bg-base-200", children: [_jsx("span", { "aria-hidden": "true", class: "grid size-8 shrink-0 place-items-center rounded-full bg-neutral text-xs text-neutral-content", children: initials(actor.name) }), _jsxs("span", { class: "min-w-0 flex-1 text-left", children: [_jsx("span", { class: "block truncate text-sm font-medium", children: actor.name }), _jsx("span", { class: "block truncate text-xs text-base-content/60", children: actor.role === 'owner' ? t('admin.users.role.owner') : t('admin.users.role.editor') })] }), _jsx(Icon, { name: "updown", class: "opacity-60" })] }), _jsxs("ul", { class: "dropdown-content menu menu-sm z-50 mb-1 w-full rounded-box border border-base-300 bg-base-100 p-1 shadow-lg", children: [_jsx("li", { children: _jsxs("a", { href: "/admin/account", "aria-current": current ? 'page' : undefined, class: current ? 'menu-active' : undefined, children: [_jsx(Icon, { name: "user" }), t('admin.nav.account')] }) }), _jsx("li", { children: _jsx("form", { method: "post", action: "/admin/logout", class: "p-0", children: _jsxs("button", { type: "submit", class: "flex w-full cursor-pointer items-center gap-2 px-2.5 py-1 text-start", children: [_jsx(Icon, { name: "logout" }), t('auth.logout')] }) }) })] })] }));
75
+ }
76
+ function Nav({ ctx, actor, section, counts, }) {
77
+ const groups = navItems(ctx, actor, counts);
78
+ return (_jsxs("nav", { "aria-label": t('admin.nav.label'), class: "flex flex-1 flex-col", children: [_jsxs("ul", { class: "menu menu-sm w-full flex-1 gap-0.5 px-2 py-3", children: [groups.top.map((item) => (_jsx(NavLink, { item: item, section: section }))), _jsx("li", { class: "menu-title mt-3 text-xs", children: t('admin.nav.content') }), groups.content.map((item) => (_jsx(NavLink, { item: item, section: section }))), _jsx("li", { class: "menu-title mt-3 text-xs", children: t('admin.nav.site') }), groups.site.map((item) => (_jsx(NavLink, { item: item, section: section })))] }), _jsx("div", { class: "border-t border-base-300 p-2", children: _jsx(PersonMenu, { actor: actor, section: section }) })] }));
79
+ }
80
+ /** A small badge saying the site needs a password; a link to the Security page for owners. */
81
+ function PrivateBadge({ owner }) {
82
+ const content = (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "lock", class: "size-3.5" }), _jsx("span", { "aria-hidden": "true", children: t('admin.security.badge') }), _jsx("span", { class: "sr-only", children: t('admin.security.banner') })] }));
83
+ const cls = `${badgeClass('info', 'md')} whitespace-nowrap`;
84
+ return owner ? (_jsx("a", { href: "/admin/security", "data-private-badge": true, class: cls, title: t('admin.security.banner'), children: content })) : (_jsx("span", { role: "status", "data-private-badge": true, class: cls, title: t('admin.security.banner'), children: content }));
85
+ }
86
+ /** The bar along the top: the menu button on small screens, the search box, the private-site badge, View site and Publish. */
87
+ function TopBar({ pending, locked, owner }) {
88
+ return (_jsxs("div", { class: "sticky top-0 z-30 flex h-14 items-center gap-3 border-b border-base-300 bg-base-100 px-4 lg:px-6", children: [_jsxs("label", { for: "admin-nav-toggle", class: "btn btn-ghost btn-sm btn-square lg:hidden", children: [_jsx(Icon, { name: "menu" }), _jsx("span", { class: "sr-only", children: t('admin.nav.open') })] }), _jsxs("form", { role: "search", action: "/admin/search", method: "get", class: "relative w-full max-w-lg", children: [_jsxs("label", { for: "global-search", class: "input input-sm w-full border-transparent bg-base-200 focus-within:border-base-300 focus-within:bg-base-100", children: [_jsx(Icon, { name: "search", class: "opacity-60" }), _jsx("span", { class: "sr-only", children: t('admin.search.label') }), _jsx("input", { id: "global-search", name: "q", type: "search", class: "grow", placeholder: t('admin.search.placeholder'), autocomplete: "off", role: "combobox", "aria-expanded": "false", "aria-controls": "global-search-results", "aria-autocomplete": "list", "hx-get": "/admin/search", "hx-trigger": "input changed delay:250ms, focus", "hx-target": "#global-search-results", "hx-select": "#global-search-results", "hx-swap": "outerHTML" }), _jsx("kbd", { "aria-hidden": "true", class: "kbd kbd-sm", children: "/" })] }), _jsx("button", { type: "submit", class: "btn btn-sm sr-only focus:not-sr-only focus:absolute focus:right-0 focus:top-0", children: t('admin.search.submit') }), _jsx("div", { id: "global-search-results" })] }), _jsxs("div", { class: "ml-auto flex items-center gap-2", children: [locked && _jsx(PrivateBadge, { owner: owner }), _jsxs("a", { href: "/", class: "btn btn-ghost btn-sm hidden sm:inline-flex", children: [_jsx(Icon, { name: "external" }), t('admin.topbar.viewSite')] }), _jsxs("a", { id: "topbar-publish", href: "/admin/publish", "data-publish-dialog": true, "data-refresh": true, class: "btn btn-primary btn-sm", children: [_jsx(Icon, { name: "send" }), t('admin.topbar.publish'), pending > 0 && (_jsx("span", { "aria-hidden": "true", class: "badge badge-sm border-0 bg-primary-content/20 text-primary-content tabular-nums", children: pending })), pending > 0 && _jsx("span", { class: "sr-only", children: t('admin.topbar.pending', { count: pending }) })] })] })] }));
89
+ }
90
+ function Breadcrumbs({ items, compact }) {
91
+ if (items.length === 0)
92
+ return null;
93
+ return (_jsx("nav", { "aria-label": t('admin.breadcrumbs'), class: compact === true ? 'breadcrumbs p-0 text-xs text-base-content/70' : 'breadcrumbs text-sm', children: _jsx("ul", { children: items.map((item) => (_jsx("li", { children: _jsx("a", { href: item.href, children: item.label }) }))) }) }));
94
+ }
95
+ /** The icon beside the publish dialog's heading for each state of `#publish-panel`; states not listed have none. */
96
+ const PUBLISH_ICONS = [
97
+ { state: 'review', icon: 'send', tone: 'bg-primary text-primary-content' },
98
+ { state: 'unpublish', icon: 'x', tone: 'bg-base-200' },
99
+ { state: 'done', icon: 'check-circle', tone: 'bg-success text-success-content' },
100
+ { state: 'problems', icon: 'alert', tone: 'bg-error text-error-content' },
101
+ { state: 'changed', icon: 'refresh', tone: 'bg-warning text-warning-content' },
102
+ ];
103
+ /**
104
+ * The one dialog every publish and unpublish button opens in: `client/admin/publish.ts` loads the publish page's
105
+ * `#publish-panel` into its body. Without JS, those buttons go to the publish page itself.
106
+ */
107
+ export function PublishDialog() {
108
+ return (_jsxs("dialog", { id: "publish-dialog", "aria-labelledby": "publish-dialog-title", class: "modal", children: [_jsxs("div", { class: "modal-box flex max-w-xl flex-col gap-4", children: [_jsxs("div", { class: "flex items-center gap-3", children: [PUBLISH_ICONS.map(({ state, icon, tone }) => (_jsx("span", { "data-state-icon": state, hidden: true, class: `grid h-9 w-9 shrink-0 place-items-center rounded-full ${tone}`, children: _jsx(Icon, { name: icon }) }))), _jsx("h2", { id: "publish-dialog-title", class: "min-w-0 flex-1 text-lg font-semibold", children: t('admin.publish.title') }), _jsx("form", { method: "dialog", children: _jsx("button", { type: "submit", class: "btn btn-ghost btn-sm btn-square", "aria-label": t('admin.publish.close'), children: _jsx(Icon, { name: "x" }) }) })] }), _jsxs("div", { "data-publish-loading": true, hidden: true, class: "flex items-center gap-2 text-sm text-base-content/70", children: [_jsx("span", { class: "loading loading-spinner loading-sm" }), t('admin.publish.loading')] }), _jsx("div", { id: "publish-dialog-body" })] }), _jsx("form", { method: "dialog", class: "modal-backdrop", children: _jsx("button", { type: "submit", tabindex: "-1", children: t('admin.publish.close') }) })] }));
109
+ }
110
+ /** The one dialog every picker opens in; `client/admin/picker.ts` loads a picker fragment into its body. */
111
+ function PickerDialog() {
112
+ return (_jsx("dialog", { id: "inlay-picker", "aria-labelledby": "inlay-picker-title", class: "modal", children: _jsxs("div", { class: "modal-box flex max-w-3xl flex-col gap-4", children: [_jsxs("div", { class: "flex items-center justify-between gap-4", children: [_jsx("h2", { id: "inlay-picker-title", class: "text-lg font-semibold", children: t('admin.picker.title') }), _jsx("form", { method: "dialog", children: _jsx("button", { type: "submit", class: "btn btn-ghost btn-sm", children: t('admin.picker.close') }) })] }), _jsx("div", { id: "inlay-picker-body" })] }) }));
113
+ }
114
+ /**
115
+ * A signed-in admin page: the menu on the left (a drawer on small screens), the top bar, and `body` under the page's
116
+ * one heading.
117
+ */
118
+ export async function adminPage(ctx, opts, body) {
119
+ const scripts = ['admin.js', ...(opts.scripts ?? [])];
120
+ const notice = (opts.status ?? 200) < 400 ? opts.notice : undefined;
121
+ const [counts, pending, lock] = await Promise.all([ctx.core.countEntries(), ctx.core.listPendingChanges(), ctx.core.siteLock()]);
122
+ const workspace = opts.layout === 'workspace';
123
+ const page = (_jsxs("html", { lang: "en", "data-theme": ctx.branding.theme.name, children: [_jsx(Head, { ctx: ctx, title: opts.title, scripts: scripts }), _jsxs("body", { class: "min-h-screen bg-base-200 text-base-content", children: [_jsx(SkipLink, {}), _jsxs("div", { class: "drawer lg:drawer-open", children: [_jsx("input", { id: "admin-nav-toggle", type: "checkbox", class: "drawer-toggle lg:hidden", "aria-label": t('admin.nav.open') }), _jsxs("div", { class: workspace ? 'drawer-content flex h-screen flex-col' : 'drawer-content flex min-h-screen flex-col', children: [_jsx(TopBar, { pending: pending.length, locked: lock.enabled, owner: opts.actor.role === 'owner' }), _jsxs("main", { id: "main", tabindex: "-1", class: workspace ? 'flex min-h-0 w-full flex-1 flex-col focus:outline-none' : 'w-full flex-1 px-4 py-4 focus:outline-none lg:px-6 lg:py-5', children: [_jsxs("div", { class: workspace
124
+ ? 'flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2 border-b border-base-300 bg-base-100 px-4 py-2.5'
125
+ : 'mb-5 flex flex-wrap items-end justify-between gap-4', children: [_jsxs("div", { class: "min-w-0", children: [_jsx(Breadcrumbs, { items: opts.breadcrumbs ?? [], compact: workspace }), _jsx("h1", { class: workspace ? 'truncate text-lg font-semibold tracking-tight' : 'text-2xl font-semibold tracking-tight', children: opts.title }), opts.description !== undefined && _jsx("p", { class: "text-sm text-base-content/70", children: opts.description })] }), opts.actions !== undefined && (_jsx("div", { class: workspace ? 'flex min-w-0 flex-1 flex-wrap items-center gap-2' : 'flex flex-wrap items-center gap-2', children: opts.actions }))] }), ctx.readOnly && (_jsx("div", { role: "status", class: workspace ? `alert alert-info ${BAR}` : 'alert alert-info mb-4', children: ctx.release ? t('admin.readOnly', { name: ctx.release.name }) : t('admin.readOnly.unnamed') })), _jsx("noscript", { children: _jsx("p", { class: workspace ? `alert alert-warning ${BAR}` : 'alert alert-warning mb-4', children: t('admin.noscript') }) }), notice !== undefined && (_jsx("div", { role: "status", class: workspace ? `alert alert-success ${BAR}` : 'alert alert-success mb-4', children: notice })), workspace ? _jsx("div", { class: "flex min-h-0 flex-1 flex-col", children: body }) : body] })] }), _jsxs("div", { class: "drawer-side z-40", children: [_jsx("label", { for: "admin-nav-toggle", "aria-label": t('admin.nav.close'), class: "drawer-overlay", children: _jsx("span", { class: "sr-only", children: t('admin.nav.close') }) }), _jsxs("aside", { class: "flex min-h-full w-64 flex-col border-r border-base-300 bg-base-100", children: [_jsx("header", { class: "flex h-14 shrink-0 items-center border-b border-base-300 px-4", children: _jsx("a", { href: "/admin", class: "inline-flex min-w-0 items-center", children: _jsx(Brand, { ctx: ctx }) }) }), _jsx(Nav, { ctx: ctx, actor: opts.actor, section: opts.section, counts: counts })] })] })] }), _jsx(PickerDialog, {}), _jsx(PublishDialog, {})] })] }));
126
+ return `<!doctype html>${await renderToString(page)}`;
127
+ }
128
+ /** A page for someone who isn't signed in (setup, login, consent, uploads): a centered card with the brand, no navigation. */
129
+ export async function authPage(ctx, title, body) {
130
+ const page = (_jsxs("html", { lang: "en", "data-theme": ctx.branding.theme.name, children: [_jsx(Head, { ctx: ctx, title: title, scripts: ['admin.js'] }), _jsxs("body", { class: "min-h-screen bg-base-200 text-base-content", children: [_jsx(SkipLink, {}), _jsx("main", { id: "main", tabindex: "-1", class: "flex min-h-screen items-center justify-center p-4 focus:outline-none", children: _jsx("div", { class: "card w-full max-w-lg bg-base-100 shadow-md", children: _jsxs("div", { class: "card-body gap-4", children: [_jsx("header", { children: _jsx(Brand, { ctx: ctx }) }), _jsx("h1", { class: "text-2xl font-bold", children: title }), body] }) }) })] })] }));
131
+ return `<!doctype html>${await renderToString(page)}`;
132
+ }
133
+ /** A time in UTC, which `admin.js` rewrites into the reader's own time zone. */
134
+ export function Time({ iso, relative }) {
135
+ const date = new Date(iso);
136
+ if (Number.isNaN(date.getTime()))
137
+ return _jsx("time", { children: iso });
138
+ const text = t('admin.time.utc', { time: UTC.format(date) });
139
+ return (_jsx("time", { datetime: iso, "data-local": true, "data-relative": relative === true ? true : undefined, title: relative === true ? text : undefined, children: text }));
140
+ }
141
+ /** A message box; an error is announced as an alert. */
142
+ export function Alert({ kind, id, children }) {
143
+ const style = kind === 'error' ? 'alert alert-error' : kind === 'warning' ? 'alert alert-warning' : 'alert alert-info';
144
+ return (_jsx("div", { id: id, role: kind === 'error' ? 'alert' : undefined, class: style, children: children }));
145
+ }
@@ -0,0 +1,15 @@
1
+ import type { Renderable } from '../../../jsx/html.js';
2
+ export interface SheetProps {
3
+ id: string;
4
+ title: string;
5
+ description?: string;
6
+ size?: 'lg';
7
+ /** Open on page load: the server sent it back with values and problems, or `?sheet=` asked for it. */
8
+ open?: boolean;
9
+ action: string;
10
+ enctype?: 'multipart/form-data';
11
+ /** The main button's text. */
12
+ submit: string;
13
+ children?: Renderable;
14
+ }
15
+ export declare function Sheet({ id, title, description, size, open, action, enctype, submit, children }: SheetProps): import("../../../jsx/html.js").Html;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "inlaycms/jsx-runtime";
2
+ import { t } from '../../../core/messages/index.js';
3
+ import { Icon } from './icons.js';
4
+ export function Sheet({ id, title, description, size, open, action, enctype, submit, children }) {
5
+ return (_jsx("dialog", { id: id, class: size === 'lg' ? 'sheet sheet-lg' : 'sheet', "data-sheet": true, "data-sheet-autoopen": open ? '' : undefined, "aria-labelledby": `${id}-title`, "aria-describedby": description === undefined ? undefined : `${id}-desc`, children: _jsxs("form", { method: "post", action: action, enctype: enctype, class: "sheet-panel", children: [_jsxs("header", { class: "flex shrink-0 items-start gap-4 border-b border-base-300 px-5 py-4", children: [_jsxs("div", { class: "min-w-0 flex-1", children: [_jsx("h2", { id: `${id}-title`, class: "text-lg font-semibold tracking-tight", children: title }), description === undefined ? null : (_jsx("p", { id: `${id}-desc`, class: "text-sm text-base-content/70", children: description }))] }), _jsx("button", { type: "button", class: "btn btn-ghost btn-sm btn-square", "data-sheet-close": true, "aria-label": t('admin.sheet.close'), children: _jsx(Icon, { name: "x" }) })] }), _jsx("div", { class: "flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-5 py-5", children: children }), _jsxs("footer", { class: "flex shrink-0 items-center justify-end gap-2 border-t border-base-300 bg-base-100 px-5 py-3", children: [_jsx("button", { type: "button", class: "btn btn-ghost", "data-sheet-close": true, children: t('admin.sheet.cancel') }), _jsx("button", { type: "submit", class: "btn btn-primary", children: submit })] })] }) }));
6
+ }
@@ -0,0 +1,32 @@
1
+ import type { DocumentSummary, RevisionSource } from '../../../core/types.js';
2
+ import type { Renderable } from '../../../jsx/html.js';
3
+ export type DocumentStatus = 'deleted' | 'new' | 'changed' | 'published';
4
+ export declare function documentStatus(d: DocumentSummary): DocumentStatus;
5
+ type StatusTone = 'success' | 'warning' | 'info' | 'neutral';
6
+ export declare function statusTone(status: DocumentStatus): StatusTone;
7
+ /** A tinted color, or `ghost` (plain gray) and `outline` (just a border) for quiet badges. */
8
+ export type BadgeTone = StatusTone | 'ghost' | 'outline';
9
+ /** A badge's classes, for links and buttons that look like one; `md` lines up with the admin's small buttons. */
10
+ export declare function badgeClass(tone: BadgeTone, size?: 'sm' | 'md'): string;
11
+ /** A small label, such as a status or a count. `class` adds layout classes (margins, alignment). */
12
+ export declare function Badge({ tone, size, class: extra, children }: {
13
+ tone: BadgeTone;
14
+ size?: 'sm' | 'md';
15
+ class?: string;
16
+ children?: Renderable;
17
+ }): import("../../../jsx/html.js").Html;
18
+ /** A small colored dot; the status is always also written out. */
19
+ export declare function StatusDot({ status }: {
20
+ status: DocumentStatus;
21
+ }): import("../../../jsx/html.js").Html;
22
+ /** A status name with its colored dot. */
23
+ export declare function StatusLabel({ status }: {
24
+ status: DocumentStatus;
25
+ }): import("../../../jsx/html.js").Html;
26
+ /** What a document's status is called, and the style that goes with it. */
27
+ export declare function StatusBadge({ doc }: {
28
+ doc: DocumentSummary;
29
+ }): import("../../../jsx/html.js").Html;
30
+ /** The name of the channel a change came through. */
31
+ export declare function sourceLabel(s: RevisionSource): string;
32
+ export {};
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "inlaycms/jsx-runtime";
2
+ import { t } from '../../../core/messages/index.js';
3
+ export function documentStatus(d) {
4
+ if (d.deletedAt !== null)
5
+ return 'deleted';
6
+ if (d.publishedRev === null)
7
+ return 'new';
8
+ return d.publishedRev === d.headRev ? 'published' : 'changed';
9
+ }
10
+ export function statusTone(status) {
11
+ switch (status) {
12
+ case 'published':
13
+ return 'success';
14
+ case 'changed':
15
+ return 'warning';
16
+ case 'new':
17
+ return 'info';
18
+ case 'deleted':
19
+ return 'neutral';
20
+ }
21
+ }
22
+ const TONE_CLASS = {
23
+ success: 'badge-soft badge-success text-base-content',
24
+ warning: 'badge-soft badge-warning text-base-content',
25
+ info: 'badge-soft badge-info text-base-content',
26
+ neutral: 'badge-soft badge-neutral text-base-content',
27
+ ghost: 'badge-ghost',
28
+ outline: 'badge-outline',
29
+ };
30
+ /** A badge's classes, for links and buttons that look like one; `md` lines up with the admin's small buttons. */
31
+ export function badgeClass(tone, size = 'sm') {
32
+ const sized = size === 'md' ? 'badge-md gap-1.5 px-2.5' : 'badge-sm';
33
+ return `badge ${sized} ${TONE_CLASS[tone]}`;
34
+ }
35
+ /** A small label, such as a status or a count. `class` adds layout classes (margins, alignment). */
36
+ export function Badge({ tone, size, class: extra, children }) {
37
+ const cls = badgeClass(tone, size);
38
+ return _jsx("span", { class: extra === undefined ? cls : `${cls} ${extra}`, children: children });
39
+ }
40
+ const DOT_CLASS = {
41
+ success: 'size-1.5 rounded-full bg-success',
42
+ warning: 'size-1.5 rounded-full bg-warning',
43
+ info: 'size-1.5 rounded-full bg-info',
44
+ neutral: 'size-1.5 rounded-full bg-neutral',
45
+ };
46
+ /** A small colored dot; the status is always also written out. */
47
+ export function StatusDot({ status }) {
48
+ return _jsx("span", { class: DOT_CLASS[statusTone(status)], "aria-hidden": "true" });
49
+ }
50
+ /** A status name with its colored dot. */
51
+ export function StatusLabel({ status }) {
52
+ return (_jsxs(Badge, { tone: statusTone(status), children: [_jsx(StatusDot, { status: status }), t(`admin.status.${status}`)] }));
53
+ }
54
+ /** What a document's status is called, and the style that goes with it. */
55
+ export function StatusBadge({ doc }) {
56
+ return _jsx(StatusLabel, { status: documentStatus(doc) });
57
+ }
58
+ /** The name of the channel a change came through. */
59
+ export function sourceLabel(s) {
60
+ switch (s) {
61
+ case 'admin':
62
+ return t('source.admin');
63
+ case 'mcp':
64
+ return t('source.mcp');
65
+ case 'restore':
66
+ return t('source.restore');
67
+ case 'import':
68
+ return t('source.import');
69
+ case 'release':
70
+ return t('source.release');
71
+ case 'system':
72
+ return t('source.system');
73
+ }
74
+ }
@@ -0,0 +1,10 @@
1
+ import type { FastifyInstance } from 'fastify';
2
+ import type { AuthService } from '../../core/auth/service.js';
3
+ /**
4
+ * Mounts better-auth: `/api/auth/*` and the `.well-known` URLs are forwarded to `auth.handler` with their raw body
5
+ * and original content type. They live in their own encapsulated plugin, whose only body parser keeps the bytes.
6
+ */
7
+ export declare function registerAuthHandler(app: FastifyInstance, opts: {
8
+ service: AuthService;
9
+ baseUrl: string;
10
+ }): void;