@kardalum/plugin-sdk 0.0.0-stage → 0.15.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 (312) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/LICENSE +202 -0
  3. package/README.md +70 -2
  4. package/dist/admin-section-registry.d.ts +34 -0
  5. package/dist/admin-section-registry.js +49 -0
  6. package/dist/built-in-serializers.d.ts +3 -0
  7. package/dist/built-in-serializers.js +18 -0
  8. package/dist/built-in-settings-schemas.d.ts +14 -0
  9. package/dist/built-in-settings-schemas.js +225 -0
  10. package/dist/built-in-value-schemas.d.ts +4 -0
  11. package/dist/built-in-value-schemas.js +47 -0
  12. package/dist/built-ins.d.ts +1 -0
  13. package/dist/built-ins.js +257 -0
  14. package/dist/capabilities.d.ts +99 -0
  15. package/dist/capabilities.js +363 -0
  16. package/dist/data-type-plugin.d.ts +28 -0
  17. package/dist/data-type-plugin.js +1 -0
  18. package/dist/datatype-validation.d.ts +26 -0
  19. package/dist/datatype-validation.js +110 -0
  20. package/dist/datatypes-entry.d.ts +4 -0
  21. package/dist/datatypes-entry.js +18 -0
  22. package/dist/define-plugin.d.ts +25 -0
  23. package/dist/define-plugin.js +51 -0
  24. package/dist/entitlement-entry.d.ts +5 -0
  25. package/dist/entitlement-entry.js +24 -0
  26. package/dist/entitlement-gate.d.ts +36 -0
  27. package/dist/entitlement-gate.js +201 -0
  28. package/dist/entitlement-types.d.ts +39 -0
  29. package/dist/entitlement-types.js +1 -0
  30. package/dist/entitlement.d.ts +57 -0
  31. package/dist/entitlement.js +170 -0
  32. package/dist/host-entry.d.ts +1 -0
  33. package/dist/host-entry.js +11 -0
  34. package/dist/icon-name.d.ts +1 -0
  35. package/dist/icon-name.js +1 -0
  36. package/dist/icons.d.ts +2 -0
  37. package/dist/icons.js +10 -0
  38. package/dist/index.d.ts +28 -0
  39. package/dist/index.js +93 -0
  40. package/dist/license-verdict-keys.d.ts +18 -0
  41. package/dist/license-verdict-keys.js +22 -0
  42. package/dist/local-host.d.ts +3 -0
  43. package/dist/local-host.js +38 -0
  44. package/dist/manifest-entry.d.ts +8 -0
  45. package/dist/manifest-entry.js +13 -0
  46. package/dist/manifest-schema.d.ts +408 -0
  47. package/dist/manifest-schema.js +774 -0
  48. package/dist/manifest.d.ts +546 -0
  49. package/dist/manifest.js +86 -0
  50. package/dist/media/media-picker.d.ts +39 -0
  51. package/dist/media/media-picker.js +438 -0
  52. package/dist/media/upload-error.d.ts +12 -0
  53. package/dist/media/upload-error.js +30 -0
  54. package/dist/plugin-context.d.ts +75 -0
  55. package/dist/plugin-context.js +70 -0
  56. package/dist/plugin-screen-context.d.ts +40 -0
  57. package/dist/plugin-screen-context.js +16 -0
  58. package/dist/register-built-ins.d.ts +1 -0
  59. package/dist/register-built-ins.js +41 -0
  60. package/dist/registry.d.ts +4 -0
  61. package/dist/registry.js +17 -0
  62. package/dist/rendition-eligibility.d.ts +24 -0
  63. package/dist/rendition-eligibility.js +40 -0
  64. package/dist/richtext/block-panel.d.ts +27 -0
  65. package/dist/richtext/block-panel.js +232 -0
  66. package/dist/richtext/extensions.d.ts +19 -0
  67. package/dist/richtext/extensions.js +56 -0
  68. package/dist/richtext/insert-menu.d.ts +24 -0
  69. package/dist/richtext/insert-menu.js +142 -0
  70. package/dist/richtext/kardalum-block.d.ts +33 -0
  71. package/dist/richtext/kardalum-block.js +282 -0
  72. package/dist/richtext/style-listbox.d.ts +10 -0
  73. package/dist/richtext/style-listbox.js +69 -0
  74. package/dist/richtext/text-style-class.d.ts +18 -0
  75. package/dist/richtext/text-style-class.js +36 -0
  76. package/dist/simple-storage-value-provider.d.ts +9 -0
  77. package/dist/simple-storage-value-provider.js +96 -0
  78. package/dist/structured-storage-types.d.ts +61 -0
  79. package/dist/structured-storage-types.js +11 -0
  80. package/dist/tailwind.d.ts +1 -0
  81. package/dist/tailwind.js +5 -0
  82. package/dist/tokens/system-dark.css +75 -0
  83. package/dist/tokens/tokens.css +239 -0
  84. package/dist/tokens/tokens.json +212 -0
  85. package/dist/tokens.d.ts +1 -0
  86. package/dist/tokens.js +11 -0
  87. package/dist/ui-entry.d.ts +5 -0
  88. package/dist/ui-entry.js +42 -0
  89. package/dist/views/content-list-preview.d.ts +1 -0
  90. package/dist/views/content-list-preview.js +14 -0
  91. package/dist/views/content-list-settings-view.d.ts +1 -0
  92. package/dist/views/content-list-settings-view.js +97 -0
  93. package/dist/views/content-list-view.d.ts +19 -0
  94. package/dist/views/content-list-view.js +248 -0
  95. package/dist/views/crop-view.d.ts +55 -0
  96. package/dist/views/crop-view.js +161 -0
  97. package/dist/views/date-range-view.d.ts +6 -0
  98. package/dist/views/date-range-view.js +55 -0
  99. package/dist/views/file-upload-view.d.ts +43 -0
  100. package/dist/views/file-upload-view.js +104 -0
  101. package/dist/views/html-code-editor.d.ts +10 -0
  102. package/dist/views/html-code-editor.js +101 -0
  103. package/dist/views/html-view.d.ts +3 -0
  104. package/dist/views/html-view.js +53 -0
  105. package/dist/views/image-view.d.ts +3 -0
  106. package/dist/views/image-view.js +387 -0
  107. package/dist/views/rich-text-view.d.ts +2 -0
  108. package/dist/views/rich-text-view.js +429 -0
  109. package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
  110. package/node_modules/@kardalum/api-schemas/README.md +56 -0
  111. package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
  112. package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
  113. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +5 -0
  114. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
  115. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
  116. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -0
  117. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
  118. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
  119. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
  120. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
  121. package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
  122. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
  123. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +537 -0
  124. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
  126. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
  127. package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
  128. package/node_modules/@kardalum/api-schemas/dist/content-path.js +256 -0
  129. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
  130. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
  131. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +151 -0
  132. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
  133. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
  134. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
  135. package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
  136. package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
  137. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +302 -0
  138. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -0
  139. package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
  140. package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
  141. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +36 -0
  142. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
  143. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
  144. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
  145. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +296 -0
  146. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
  147. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
  148. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
  149. package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
  150. package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
  151. package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
  153. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +102 -0
  154. package/node_modules/@kardalum/api-schemas/dist/index.js +58 -0
  155. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
  156. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
  157. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +381 -0
  158. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
  159. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
  160. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -0
  161. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
  162. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
  163. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
  164. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
  165. package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
  166. package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
  167. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
  168. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
  169. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
  170. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
  171. package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
  172. package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
  173. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
  174. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
  175. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
  176. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
  177. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +169 -0
  178. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -0
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +89 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +369 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
  193. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +306 -0
  194. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -0
  195. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
  196. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
  197. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
  198. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
  199. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
  200. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
  201. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +90 -0
  202. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -0
  203. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
  204. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
  205. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +108 -0
  206. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -0
  207. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
  208. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
  209. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +43 -0
  210. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -0
  211. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
  212. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
  213. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
  214. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
  215. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
  216. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
  217. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
  218. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
  219. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +89 -0
  220. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -0
  221. package/node_modules/@kardalum/api-schemas/package.json +35 -0
  222. package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
  223. package/node_modules/@kardalum/design-tokens/README.md +29 -0
  224. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
  225. package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
  226. package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
  227. package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
  228. package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
  229. package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
  230. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
  231. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
  232. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
  233. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
  234. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
  235. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
  236. package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
  237. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
  238. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
  239. package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
  240. package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
  241. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
  242. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
  243. package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
  244. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
  245. package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
  246. package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
  247. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
  248. package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
  249. package/node_modules/@kardalum/design-tokens/package.json +42 -0
  250. package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
  251. package/node_modules/@kardalum/plugin-package/README.md +71 -0
  252. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
  253. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
  254. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
  255. package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
  256. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
  257. package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
  258. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
  259. package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
  260. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -0
  261. package/node_modules/@kardalum/plugin-package/dist/index.js +7 -0
  262. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
  263. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
  264. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
  265. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
  266. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +1 -0
  267. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
  268. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
  269. package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
  270. package/node_modules/@kardalum/plugin-package/package.json +49 -0
  271. package/node_modules/@kardalum/ui/LICENSE +202 -0
  272. package/node_modules/@kardalum/ui/README.md +35 -0
  273. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
  274. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
  275. package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
  276. package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
  277. package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
  278. package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
  279. package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
  280. package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
  281. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
  282. package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
  283. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
  284. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
  285. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
  286. package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
  287. package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
  288. package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
  289. package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
  290. package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
  291. package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
  292. package/node_modules/@kardalum/ui/dist/components/property-field.js +86 -0
  293. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
  294. package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
  295. package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
  296. package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
  297. package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
  298. package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
  299. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
  300. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
  301. package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
  302. package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
  303. package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
  304. package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
  305. package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
  306. package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
  307. package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
  308. package/node_modules/@kardalum/ui/dist/index.js +18 -0
  309. package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
  310. package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
  311. package/node_modules/@kardalum/ui/package.json +63 -0
  312. package/package.json +146 -4
@@ -0,0 +1,248 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
3
+ import { CONTENT_LIST_DEFAULT_SETTINGS, } from "@kardalum/api-schemas";
4
+ import { Badge, Button, Input } from "@kardalum/ui";
5
+ import { Lock } from "lucide-react";
6
+ import { useContentHost, usePluginApi, usePluginSettings, } from "../plugin-context.js";
7
+ /** Column headers for the six built-in row properties. */
8
+ export const CONTENT_LIST_PROPERTY_LABELS = {
9
+ name: "Name",
10
+ id: "Id",
11
+ url: "URL",
12
+ status: "Status",
13
+ updatedAt: "Updated",
14
+ publishedAt: "Published",
15
+ };
16
+ const STATUS_LABELS = {
17
+ draft: "Draft",
18
+ published: "Published",
19
+ changes: "Changes not published",
20
+ };
21
+ const STATUS_VARIANTS = {
22
+ draft: "neutral",
23
+ published: "success",
24
+ changes: "warning",
25
+ };
26
+ const PAGE_SIZE = 25;
27
+ const SEARCH_DEBOUNCE_MS = 300;
28
+ const LOAD_ERROR = "Could not load the children.";
29
+ // S278b (D1, D14): what a locked row says. A row the person may not read
30
+ // arrives with `fields: {}` (its name, url and status stay), so its field
31
+ // cells say so instead of rendering as empty.
32
+ const RESTRICTED_FOR_YOU = "Restricted for you";
33
+ const RESTRICTED_CELL = "Restricted";
34
+ /** D1: a restriction refused one of the row's actions. A refusal by the
35
+ * role is not the page's doing, so it lights no lock. */
36
+ function isRestrictedForYou(row) {
37
+ return Object.values(row.access?.denied ?? {}).some((denial) => denial?.reason === "not-granted");
38
+ }
39
+ function LockMark() {
40
+ return (_jsx("span", { role: "img", "aria-label": RESTRICTED_FOR_YOU, className: "inline-flex shrink-0 text-text-tertiary", children: _jsx(Lock, { "aria-hidden": "true", className: "size-3" }) }));
41
+ }
42
+ // The row's own keyboard stop: the name is the only control in a row, so
43
+ // it carries the focus ring the row would otherwise need.
44
+ const NAME_BUTTON_CLASS = "text-start text-sm font-medium text-primary-600 hover:underline " +
45
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600";
46
+ export const CONTENT_LIST_HEADER_CELL_CLASS = "border-b border-border-default px-2 py-2 text-start text-xs font-medium text-text-secondary";
47
+ /** A stable React key (and a settings identity) for one column. */
48
+ export function contentListColumnKey(column) {
49
+ return column.kind === "property" ? `property:${column.property}` : `field:${column.fieldId}`;
50
+ }
51
+ /** The field's name on the first page document type that declares it. */
52
+ export function findFieldInTypes(fieldId, documentTypes) {
53
+ for (const documentType of documentTypes ?? []) {
54
+ const field = documentType.fields.find((candidate) => candidate.id === fieldId);
55
+ if (field)
56
+ return { typeName: documentType.name, fieldName: field.name };
57
+ }
58
+ return null;
59
+ }
60
+ /** The header text for a column: an explicit label wins, then the field's
61
+ * own name where a document type declares it, then the raw alias. */
62
+ export function contentListColumnHeader(column, documentTypes) {
63
+ if (column.kind === "property")
64
+ return CONTENT_LIST_PROPERTY_LABELS[column.property];
65
+ if (column.label)
66
+ return column.label;
67
+ return findFieldInTypes(column.fieldId, documentTypes)?.fieldName ?? column.fieldId;
68
+ }
69
+ // A DataTypeConfig stores `settings: {}` until a webmaster opens the
70
+ // settings view (see TEXT_DEFAULT_SETTINGS), so "no columns" reaches the
71
+ // view as a real, expected state and means "the defaults", not "an empty
72
+ // table".
73
+ export function resolveContentListColumns(settings) {
74
+ return settings.columns && settings.columns.length > 0 ? settings.columns : CONTENT_LIST_DEFAULT_SETTINGS.columns;
75
+ }
76
+ function renderFieldValue(value) {
77
+ if (value === undefined || value === null)
78
+ return null;
79
+ if (typeof value === "string")
80
+ return _jsx("span", { dir: "auto", children: value });
81
+ if (typeof value === "number")
82
+ return _jsx("span", { dir: "auto", children: String(value) });
83
+ if (typeof value === "boolean")
84
+ return value ? "Yes" : "No";
85
+ if (typeof value !== "object")
86
+ return "Value";
87
+ const candidate = value;
88
+ // A TipTap/ProseMirror document. Deliberately named rather than
89
+ // flattened to text: a list cell is not where a body is read, and a
90
+ // partial flattening would misrepresent what the field holds.
91
+ if (candidate["type"] === "doc")
92
+ return "Rich text";
93
+ if (candidate["type"] === undefined && (candidate["mediaId"] !== undefined || candidate["id"] !== undefined)) {
94
+ return "Image";
95
+ }
96
+ // The built-in date range's real member names (built-in-value-schemas.ts
97
+ // and date-range-view.tsx), not from/to.
98
+ if (candidate["start"] !== undefined || candidate["end"] !== undefined)
99
+ return "Date range";
100
+ return "Value";
101
+ }
102
+ // A stored timestamp can be malformed (a hand-edited row, an import), and
103
+ // a list cell is not the place to take the whole editing screen down over
104
+ // it: an unreadable date renders as nothing.
105
+ function formatDate(formatter, iso) {
106
+ if (!iso)
107
+ return "";
108
+ const parsed = new Date(iso);
109
+ if (Number.isNaN(parsed.getTime()))
110
+ return "";
111
+ return formatter.format(parsed);
112
+ }
113
+ function ContentListTable({ canCreate = false }) {
114
+ const host = useContentHost();
115
+ const fetchApi = usePluginApi();
116
+ const settings = usePluginSettings();
117
+ const searchId = useId();
118
+ const columns = useMemo(() => resolveContentListColumns(settings), [settings]);
119
+ // Only the aliases the configured columns actually show, so the
120
+ // response stays bounded by the table rather than the whole document.
121
+ const fieldsParam = useMemo(() => columns.flatMap((column) => (column.kind === "field" ? [column.fieldId] : [])).join(","), [columns]);
122
+ const [items, setItems] = useState([]);
123
+ const [nextCursor, setNextCursor] = useState(null);
124
+ const [loading, setLoading] = useState(false);
125
+ const [error, setError] = useState(null);
126
+ const [search, setSearch] = useState("");
127
+ const [appliedSearch, setAppliedSearch] = useState("");
128
+ // The cursor the failed request asked for, so Retry asks for THAT page
129
+ // again instead of silently throwing away the rows already on screen and
130
+ // starting over. null is the first page, which is also what a failed
131
+ // first page should retry.
132
+ const [failedCursor, setFailedCursor] = useState(null);
133
+ // Set when Load more is clicked, to the row index the first appended row
134
+ // will land on. Load more can be the last page, in which case the button
135
+ // unmounts and focus would fall to the body.
136
+ const focusRowIndex = useRef(null);
137
+ const bodyRef = useRef(null);
138
+ // One check answers both "is there a page?" and "can I navigate?": the
139
+ // host's two branches keep the id and the navigations together.
140
+ const page = host?.page ?? null;
141
+ const nodeId = page?.nodeId ?? null;
142
+ const requestId = useRef(0);
143
+ useEffect(() => {
144
+ const timer = setTimeout(() => setAppliedSearch(search.trim()), SEARCH_DEBOUNCE_MS);
145
+ return () => clearTimeout(timer);
146
+ }, [search]);
147
+ const load = useCallback(async (cursor) => {
148
+ if (!nodeId)
149
+ return;
150
+ // Guards against an out-of-order response overwriting a newer one
151
+ // (a slow first page landing after a fast filtered page).
152
+ const id = ++requestId.current;
153
+ setLoading(true);
154
+ setError(null);
155
+ try {
156
+ const params = new URLSearchParams({ limit: String(PAGE_SIZE) });
157
+ if (fieldsParam)
158
+ params.set("fields", fieldsParam);
159
+ if (appliedSearch)
160
+ params.set("name", appliedSearch);
161
+ if (cursor)
162
+ params.set("cursor", cursor);
163
+ const response = await fetchApi(`/api/content/${nodeId}/list?${params.toString()}`);
164
+ if (!response.ok)
165
+ throw new Error(`Request failed (${response.status})`);
166
+ const body = (await response.json());
167
+ if (id !== requestId.current)
168
+ return;
169
+ setItems((previous) => (cursor ? [...previous, ...body.items] : body.items));
170
+ setNextCursor(body.nextCursor);
171
+ }
172
+ catch {
173
+ if (id !== requestId.current)
174
+ return;
175
+ setError(LOAD_ERROR);
176
+ setFailedCursor(cursor);
177
+ setNextCursor(null);
178
+ focusRowIndex.current = null;
179
+ }
180
+ finally {
181
+ if (id === requestId.current)
182
+ setLoading(false);
183
+ }
184
+ }, [appliedSearch, fetchApi, fieldsParam, nodeId]);
185
+ // `load` changes identity whenever the filter does, which is what makes
186
+ // a changed search term restart from the first page: a cursor minted
187
+ // against the unfiltered list points into a different result set and is
188
+ // never reused across a filter change.
189
+ useEffect(() => {
190
+ void load(null);
191
+ }, [load]);
192
+ // After an append, the first NEW row's name button takes focus, so a
193
+ // keyboard user lands on what they just asked for rather than on the
194
+ // body when the last page removes the Load more button. A table whose
195
+ // columns do not include the name has no button to move to, and focus
196
+ // is left alone.
197
+ useEffect(() => {
198
+ const index = focusRowIndex.current;
199
+ if (index === null || items.length <= index)
200
+ return;
201
+ focusRowIndex.current = null;
202
+ bodyRef.current?.querySelectorAll("tr")[index]?.querySelector("button")?.focus();
203
+ }, [items]);
204
+ const dateFormat = useMemo(() => new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }), []);
205
+ // A host with no page (the Data Types editor, which hosts this
206
+ // context only for its document types) is the same state as no host at
207
+ // all as far as a table of children goes.
208
+ if (!host || page === null) {
209
+ return _jsx("p", { className: "text-sm text-text-secondary", children: "Shown on a page's editing screen." });
210
+ }
211
+ // `page` is passed in rather than closed over: it is narrowed to a real
212
+ // page by the guard above, and TypeScript does not carry that narrowing
213
+ // into a nested function.
214
+ function renderCell(row, column, page) {
215
+ // D14: a row the person may not read is listed, locked and not
216
+ // openable; its fields were withheld, which is not the same as empty.
217
+ // A server from before S276 sent no flags: its rows are all readable.
218
+ const readable = row.access?.read !== false;
219
+ if (column.kind === "field") {
220
+ return readable ? (renderFieldValue(row.fields[column.fieldId])) : (_jsx("span", { className: "text-text-tertiary", children: RESTRICTED_CELL }));
221
+ }
222
+ switch (column.property) {
223
+ case "name":
224
+ return (_jsxs("span", { className: "inline-flex items-center gap-2", children: [readable ? (_jsx("button", { type: "button", dir: "auto", className: NAME_BUTTON_CLASS, onClick: () => page.openContent(row.id), children: row.name })) : (_jsx("span", { dir: "auto", className: "text-sm text-text-tertiary", children: row.name })), isRestrictedForYou(row) && _jsx(LockMark, {})] }));
225
+ case "id":
226
+ return _jsx("span", { className: "font-mono text-xs text-text-secondary", children: row.id });
227
+ case "url":
228
+ return _jsx("span", { dir: "auto", children: row.url });
229
+ case "status":
230
+ return _jsx(Badge, { variant: STATUS_VARIANTS[row.status], children: STATUS_LABELS[row.status] });
231
+ case "updatedAt":
232
+ return formatDate(dateFormat, row.updatedAt);
233
+ case "publishedAt":
234
+ return formatDate(dateFormat, row.publishedAt);
235
+ }
236
+ }
237
+ const documentTypes = host.documentTypes;
238
+ return (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsxs("div", { className: "flex flex-wrap items-end gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: searchId, className: "text-xs font-medium text-text-secondary", children: "Search by name" }), _jsx(Input, { id: searchId, value: search, onChange: (event) => setSearch(event.target.value) })] }), canCreate && (_jsx(Button, { type: "button", className: "ms-auto", onClick: () => page.createChild(page.nodeId), children: "New" }))] }), error && (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("p", { role: "alert", className: "text-sm text-danger-600", children: error }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => void load(failedCursor), children: "Retry" })] })), items.length > 0 && (_jsxs("table", { className: "w-full border-collapse text-sm text-text-primary", children: [_jsx("caption", { className: "sr-only", children: "Children" }), _jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", className: CONTENT_LIST_HEADER_CELL_CLASS, children: contentListColumnHeader(column, documentTypes) }, contentListColumnKey(column)))) }) }), _jsx("tbody", { ref: bodyRef, children: items.map((row) => (_jsx("tr", { children: columns.map((column) => (_jsx("td", { className: "border-b border-border-subtle px-2 py-2 align-top", children: renderCell(row, column, page) }, contentListColumnKey(column)))) }, row.id))) })] })), loading && (_jsx("p", { role: "status", className: "text-sm text-text-secondary", children: "Loading\u2026" })), !loading && !error && items.length === 0 && (_jsx("p", { role: "status", className: "text-sm text-text-secondary", children: appliedSearch ? "Nothing matches." : "No children yet." })), nextCursor !== null && (_jsx(Button, { type: "button", variant: "outline", size: "sm", className: "self-start", disabled: loading, onClick: () => {
239
+ focusRowIndex.current = items.length;
240
+ void load(nextCursor);
241
+ }, children: "Load more" }))] }));
242
+ }
243
+ export function ContentListInputView() {
244
+ return _jsx(ContentListTable, { canCreate: true });
245
+ }
246
+ export function ContentListReadOnlyView() {
247
+ return _jsx(ContentListTable, {});
248
+ }
@@ -0,0 +1,55 @@
1
+ import { type ReactNode } from "react";
2
+ export { RENDITION_INELIGIBLE_TYPES, isRenditionIneligible } from "../rendition-eligibility.js";
3
+ /**
4
+ * The Cut control, supplied by the host for the same reason the file
5
+ * upload's Replace is: cutting needs a media item, a cropper dialog and an
6
+ * i18n instance to name the button in, and all three live in the admin UI.
7
+ * A host that supplies no handler gets no control, rather than one that
8
+ * would throw when pressed.
9
+ */
10
+ export interface MediaRenditionCut {
11
+ /** Opens the host's cropper. Nothing is cut or uploaded here. */
12
+ onCut: () => void;
13
+ /**
14
+ * The control's visible label, from the host. The one kind of string in
15
+ * this package that is not hardcoded English (see built-ins.tsx's
16
+ * TextSettingsView for why the rest are): the host already has to be
17
+ * involved for the control to exist, and it has the translation this
18
+ * package cannot reach. Required, so this package never needs an English
19
+ * default for a string only the host can say.
20
+ */
21
+ label: string;
22
+ /** A cut is in flight: the control does not respond. */
23
+ busy: boolean;
24
+ }
25
+ /** What a rendition field learns about where it is being rendered. */
26
+ export interface MediaRenditionHost {
27
+ /**
28
+ * The media type of the file this field would be cut FROM, or null when
29
+ * the host has no file to name. Passed down rather than read off
30
+ * MediaFileProvider so a host can mount a Crops tab without also
31
+ * mounting the file field's context.
32
+ */
33
+ sourceMimeType: string | null;
34
+ /** The whole control, or nothing at all. */
35
+ cut: MediaRenditionCut | null;
36
+ }
37
+ export interface MediaRenditionProviderProps {
38
+ sourceMimeType: string | null;
39
+ /**
40
+ * Omitted by any host with nowhere to cut, and then no control renders.
41
+ * One object rather than a handler, a label and a busy flag side by
42
+ * side, so `label` is required at the type level: a host that offers the
43
+ * control cannot forget to name it.
44
+ */
45
+ cut?: MediaRenditionCut;
46
+ children: ReactNode;
47
+ }
48
+ export declare function MediaRenditionProvider({ sourceMimeType, cut, children }: MediaRenditionProviderProps): import("react").JSX.Element;
49
+ export declare function useMediaRendition(): MediaRenditionHost | null;
50
+ export declare function CropInputView(): import("react").JSX.Element;
51
+ export declare function CropReadOnlyView(): import("react").JSX.Element;
52
+ export declare function ThumbnailInputView(): import("react").JSX.Element;
53
+ export declare function ThumbnailReadOnlyView(): import("react").JSX.Element;
54
+ export declare function CropSettingsView(): import("react").JSX.Element;
55
+ export declare function ThumbnailSettingsView(): import("react").JSX.Element;
@@ -0,0 +1,161 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { createContext, useContext, useState } from "react";
3
+ import { CROP_EDITOR_ID, CropSettingsSchema, THUMBNAIL_EDITOR_ID, ThumbnailSettingsSchema, renditionName, } from "@kardalum/api-schemas";
4
+ import { Button, Input, PropertyField } from "@kardalum/ui";
5
+ import { usePluginSettings, usePluginSettingsValue, usePluginValue } from "../plugin-context.js";
6
+ import { isRenditionIneligible } from "../rendition-eligibility.js";
7
+ // S234c: the crop and thumbnail editors' field views. A media document
8
+ // type carries one field per rendition it wants, and this is the tile the
9
+ // admin renders for each of them.
10
+ //
11
+ // What is here and what is not. These views show what the field IS (its
12
+ // ratio, the suffix its rendition is filed under, whether this version has
13
+ // been cut) and hand the one action back to the host. The cropper dialog,
14
+ // the canvas cut and the Crops tab that arranges the tiles all live in the
15
+ // admin, because they need the media item's versions and its API, neither
16
+ // of which this package has.
17
+ //
18
+ // Unlike the file upload editor (file-upload-view.tsx), a crop field DOES
19
+ // store a value: the rectangle it last cut, as fractions of the source
20
+ // (spec section 7). So these views read usePluginValue() like an ordinary
21
+ // built-in. What they take from the host context below is only what the
22
+ // field cannot know: which file the item holds, and whether there is
23
+ // anywhere to cut it.
24
+ //
25
+ // A thumbnail is the other half of that split: it is automatic, cut
26
+ // whenever bytes arrive, so its field stores nothing and its tile offers
27
+ // no action at all.
28
+ // The set and the question live in ../rendition-eligibility.js, which has
29
+ // no React in it, because the SERVER refuses the same formats at the cut
30
+ // route and must be able to read them without importing this file. They
31
+ // are re-exported here so every browser-side caller still reaches them
32
+ // where the crop view lives.
33
+ export { RENDITION_INELIGIBLE_TYPES, isRenditionIneligible } from "../rendition-eligibility.js";
34
+ // Null outside a provider, the same non-throwing shape useContentHost()
35
+ // uses and for the same reason: the Data Types editor and the document
36
+ // type builder's field preview render these views where no media item
37
+ // exists, which is a real state and not a host wiring bug.
38
+ const MediaRenditionContext = createContext(null);
39
+ // The context value is rebuilt on every render rather than memoized, the
40
+ // same trade MediaFileProvider makes: both members are things the host
41
+ // owns and re-renders with, and the only consumers are the four views
42
+ // below, which re-render with the host regardless.
43
+ export function MediaRenditionProvider({ sourceMimeType, cut, children }) {
44
+ return (_jsx(MediaRenditionContext.Provider, { value: { sourceMimeType, cut: cut ?? null }, children: children }));
45
+ }
46
+ export function useMediaRendition() {
47
+ return useContext(MediaRenditionContext);
48
+ }
49
+ // A rectangle is fractions of the source, so a whole number of percent is
50
+ // the readable form of it. Rounded, and never presented as the pixel size
51
+ // of the result: that depends on the source, which this view has not seen.
52
+ function percent(fraction) {
53
+ return `${Math.round(fraction * 100)}%`;
54
+ }
55
+ // Shared by the input and read-only views. `actionable` is the only
56
+ // difference between them, exactly as in file-upload-view.tsx: read-only
57
+ // means read-only, however willing the host is.
58
+ function CropDisplay({ actionable }) {
59
+ const settings = usePluginSettings();
60
+ const { value } = usePluginValue();
61
+ const host = useMediaRendition();
62
+ // The builder's field preview mounts every view with an unset value
63
+ // (field-row.tsx's FieldPreview), so undefined and null are one state
64
+ // here: this field holds no rectangle.
65
+ const rect = value ?? null;
66
+ const uncuttable = host !== null && isRenditionIneligible(host.sourceMimeType);
67
+ const cut = actionable && !uncuttable ? (host?.cut ?? null) : null;
68
+ // A presence check, not a validity one. `renditionName` reads the ratio
69
+ // straight off the settings, so a row with no ratio at all would throw
70
+ // inside it; a row with a ratio nothing can cut is a different problem,
71
+ // and one this view is not the place to catch.
72
+ const ratio = settings.ratio;
73
+ const status = uncuttable
74
+ ? "This format cannot be cut."
75
+ : rect === null
76
+ ? "Not cut yet."
77
+ : `Cut from a region ${percent(rect.w)} wide and ${percent(rect.h)} tall.`;
78
+ return (_jsxs("div", { className: "flex flex-col gap-1 text-sm text-text-primary", children: [ratio ? (_jsxs("p", { className: "font-medium", children: ["Ratio ", _jsx("span", { className: "font-mono", children: ratio })] })) : (_jsx("p", { className: "font-medium", children: "No ratio set." })), ratio ? (_jsxs("p", { className: "text-xs text-text-secondary", children: ["Saves as the", " ", _jsx("span", { className: "font-mono", children: renditionName({
79
+ editorId: CROP_EDITOR_ID,
80
+ settings: { ratio, maxWidth: settings.maxWidth ?? null },
81
+ }) }), " ", "rendition."] })) : null, settings.maxWidth != null ? (_jsxs("p", { className: "text-xs text-text-secondary", children: ["At most ", settings.maxWidth, " px wide."] })) : null, _jsx("p", { className: "text-xs text-text-secondary", children: status }), cut ? (_jsx("div", { className: "mt-2 flex items-center gap-2", children: _jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: cut.busy, onClick: cut.onCut, children: cut.label }) })) : null] }));
82
+ }
83
+ export function CropInputView() {
84
+ return _jsx(CropDisplay, { actionable: true });
85
+ }
86
+ export function CropReadOnlyView() {
87
+ return _jsx(CropDisplay, { actionable: false });
88
+ }
89
+ // One display for all three thumbnail slots: there is nothing to press on
90
+ // any of them, so input and read-only are the same tile.
91
+ function ThumbnailDisplay() {
92
+ const settings = usePluginSettings();
93
+ const host = useMediaRendition();
94
+ const longestEdge = settings.longestEdge;
95
+ if (host !== null && isRenditionIneligible(host.sourceMimeType)) {
96
+ return _jsx("p", { className: "text-xs text-text-secondary", children: "This format cannot be cut." });
97
+ }
98
+ return (_jsxs("div", { className: "flex flex-col gap-1 text-sm text-text-primary", children: [_jsx("p", { className: "font-medium", children: "Automatic" }), longestEdge != null ? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "text-xs text-text-secondary", children: ["Longest edge ", longestEdge, " px."] }), _jsxs("p", { className: "text-xs text-text-secondary", children: ["Saves as the", " ", _jsx("span", { className: "font-mono", children: renditionName({ editorId: THUMBNAIL_EDITOR_ID, settings: { longestEdge } }) }), " ", "rendition."] })] })) : null] }));
99
+ }
100
+ export function ThumbnailInputView() {
101
+ return _jsx(ThumbnailDisplay, {});
102
+ }
103
+ export function ThumbnailReadOnlyView() {
104
+ return _jsx(ThumbnailDisplay, {});
105
+ }
106
+ // Rendered by the Data Types editor only, so both settings views below
107
+ // take the settings-EDITING hook (usePluginSettingsValue), the split every
108
+ // other built-in follows.
109
+ //
110
+ // Both keep the text being typed in local state rather than writing every
111
+ // keystroke into the settings object. CropSettings and ThumbnailSettings
112
+ // have no optional member, so a half-typed ratio or a longest edge of "4"
113
+ // on its way to "480" is not a value the row may hold: the settings object
114
+ // is what gets saved, and the server validates it against the JSON Schema
115
+ // mirror of these same Zod schemas (built-in-settings-schemas.ts).
116
+ export function CropSettingsView() {
117
+ const { value: settings, onChange } = usePluginSettingsValue();
118
+ const [ratio, setRatio] = useState(settings.ratio ?? "");
119
+ const [maxWidth, setMaxWidth] = useState(settings.maxWidth == null ? "" : String(settings.maxWidth));
120
+ // The whole object, parsed by the schema that owns the shape, and
121
+ // committed only when it parses. `parsed.data` rather than a spread of
122
+ // the old settings: the mirror refuses unknown properties, so carrying
123
+ // one forward would make the row unsaveable.
124
+ function commit(nextRatio, nextMaxWidth) {
125
+ const parsed = CropSettingsSchema.safeParse({
126
+ ratio: nextRatio,
127
+ maxWidth: nextMaxWidth === "" ? null : Number(nextMaxWidth),
128
+ });
129
+ if (parsed.success)
130
+ onChange(parsed.data);
131
+ }
132
+ const ratioError = ratio === "" || CropSettingsSchema.shape.ratio.safeParse(ratio).success
133
+ ? undefined
134
+ : "A ratio looks like 3:4, with no leading zeros.";
135
+ const maxWidthError = maxWidth === "" || CropSettingsSchema.shape.maxWidth.safeParse(Number(maxWidth)).success
136
+ ? undefined
137
+ : "A maximum width is a whole number of pixels, at least 1.";
138
+ return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(PropertyField, { label: "Ratio", htmlFor: "crop-settings-ratio", required: true, requiredText: "Required", helpText: "The shape the cropper locks to, width first, such as 3:4.", error: ratioError, children: _jsx(Input, { id: "crop-settings-ratio", value: ratio, onChange: (e) => {
139
+ setRatio(e.target.value);
140
+ commit(e.target.value, maxWidth);
141
+ } }) }), _jsx(PropertyField, { label: "Maximum width", htmlFor: "crop-settings-max-width", helpText: "A ceiling in pixels. Leave blank for none: the cut then keeps the source region's own resolution, and it never enlarges.", error: maxWidthError, children: _jsx(Input, { id: "crop-settings-max-width", type: "number", min: 1, value: maxWidth, onChange: (e) => {
142
+ setMaxWidth(e.target.value);
143
+ commit(ratio, e.target.value);
144
+ } }) })] }));
145
+ }
146
+ export function ThumbnailSettingsView() {
147
+ const { value: settings, onChange } = usePluginSettingsValue();
148
+ const [longestEdge, setLongestEdge] = useState(settings.longestEdge == null ? "" : String(settings.longestEdge));
149
+ function commit(next) {
150
+ const parsed = ThumbnailSettingsSchema.safeParse({ longestEdge: Number(next) });
151
+ if (parsed.success)
152
+ onChange(parsed.data);
153
+ }
154
+ const longestEdgeError = longestEdge === "" || ThumbnailSettingsSchema.safeParse({ longestEdge: Number(longestEdge) }).success
155
+ ? undefined
156
+ : "A longest edge is a whole number of pixels, at least 1.";
157
+ return (_jsx("div", { className: "flex flex-col gap-4", children: _jsx(PropertyField, { label: "Longest edge", htmlFor: "thumbnail-settings-longest-edge", required: true, requiredText: "Required", helpText: "The thumbnail's longer side in pixels. The shorter side follows the source's own shape.", error: longestEdgeError, children: _jsx(Input, { id: "thumbnail-settings-longest-edge", type: "number", min: 1, value: longestEdge, onChange: (e) => {
158
+ setLongestEdge(e.target.value);
159
+ commit(e.target.value);
160
+ } }) }) }));
161
+ }
@@ -0,0 +1,6 @@
1
+ export interface DateRangeValue {
2
+ start: string | null;
3
+ end: string | null;
4
+ }
5
+ export declare function DateRangeInputView(): import("react").JSX.Element;
6
+ export declare function DateRangeReadOnlyView(): import("react").JSX.Element;
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { Input, usePropertyFieldControl } from "@kardalum/ui";
4
+ import { usePluginValue } from "../plugin-context.js";
5
+ const EMPTY_RANGE = { start: null, end: null };
6
+ // Two independently-labeled <input type="date"> controls, not one — unlike
7
+ // every other built-in view, this value has two members a person needs to
8
+ // tell apart by NAME ("Start" vs "End"), so each gets its own visible
9
+ // <label>. That's why this doesn't follow the single-control idiom the
10
+ // other built-ins use (spreading usePropertyFieldControl() straight onto
11
+ // one <Input>, letting PropertyField's clone give it the field's own
12
+ // label): PropertyField cannot clone two children, and even if it could,
13
+ // aria-labelledby pointing both inputs at the outer field's label would
14
+ // override their own <label for> text in the accessible-name computation,
15
+ // making "Start" and "End" indistinguishable to a screen reader. Per
16
+ // property-field.tsx's own doc comment for this exact case ("a composite
17
+ // child is left unchanged ... the control deep inside it calls
18
+ // usePropertyFieldControl() itself"), each half still shares the outer
19
+ // field's help/error text (aria-describedby) and invalid state
20
+ // (aria-invalid) — one field, one error message underneath both inputs —
21
+ // it just doesn't take the field's id/aria-labelledby.
22
+ export function DateRangeInputView() {
23
+ const { value, onChange } = usePluginValue();
24
+ const field = usePropertyFieldControl();
25
+ const range = value ?? EMPTY_RANGE;
26
+ const reactId = useId();
27
+ const startId = `${field.id ?? reactId}-start`;
28
+ const endId = `${field.id ?? reactId}-end`;
29
+ // Clearing a date input hands back "" — normalized to null so downstream
30
+ // (the validate hook, isEmpty, serialization) only ever sees the two
31
+ // states asDateRange() understands: a real ISO string or null, never an
32
+ // empty string standing in for "no value".
33
+ function update(member, raw) {
34
+ onChange({ ...range, [member]: raw === "" ? null : raw });
35
+ }
36
+ const shared = {
37
+ "aria-describedby": field["aria-describedby"],
38
+ "aria-invalid": field["aria-invalid"],
39
+ };
40
+ return (_jsxs("div", { className: "flex flex-wrap items-end gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: startId, className: "text-xs font-medium text-text-secondary", children: "Start" }), _jsx(Input, { id: startId, type: "date", value: range.start ?? "", onChange: (e) => update("start", e.target.value), ...shared })] }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { htmlFor: endId, className: "text-xs font-medium text-text-secondary", children: "End" }), _jsx(Input, { id: endId, type: "date", value: range.end ?? "", onChange: (e) => update("end", e.target.value), ...shared })] })] }));
41
+ }
42
+ export function DateRangeReadOnlyView() {
43
+ const { value } = usePluginValue();
44
+ const range = value ?? EMPTY_RANGE;
45
+ // A half-filled or fully-empty range never reaches a saved, validated
46
+ // value (the hook above rejects both), but this view renders whatever
47
+ // it's handed — an in-progress preview, say — without crashing on it.
48
+ // An en dash, not an arrow: "→" is a fixed left-to-right glyph that
49
+ // still points right in an RTL locale, where the two dates read the
50
+ // other way round. A dash carries the same "from … to" sense in both.
51
+ const text = range.start !== null && range.end !== null
52
+ ? `${range.start} – ${range.end}`
53
+ : (range.start ?? range.end ?? "");
54
+ return _jsx("p", { children: text });
55
+ }
@@ -0,0 +1,43 @@
1
+ import { type ReactNode } from "react";
2
+ export interface CurrentMediaFile {
3
+ filename: string;
4
+ size: number;
5
+ mimeType: string;
6
+ }
7
+ export interface MediaFileReplace {
8
+ /**
9
+ * Hands the host the file the person chose. Nothing is confirmed or
10
+ * uploaded here: the host asks the question and writes the bytes.
11
+ */
12
+ onReplace: (file: File) => void;
13
+ /**
14
+ * The control's visible label, from the host. The one place in this
15
+ * package where a string is not hardcoded English (see built-ins.tsx's
16
+ * TextSettingsView for why the rest are): the host already has to be
17
+ * involved for the control to exist at all, and it has the translation
18
+ * this package cannot reach. Required, so this package never needs an
19
+ * English default for a string only the host can say.
20
+ */
21
+ label: string;
22
+ /** A replace is in flight: the control does not respond. */
23
+ busy: boolean;
24
+ }
25
+ export interface MediaFileProviderProps {
26
+ file: CurrentMediaFile | null;
27
+ /**
28
+ * The whole control, or nothing. Omitted by any host with no item to
29
+ * replace (the Data Types editor's per-field preview), and then no
30
+ * control renders. One object rather than a handler, a label and a busy
31
+ * flag side by side, so `label` is required at the type level: a host
32
+ * that offers the control cannot forget to name it, and this package
33
+ * needs no English default for a string only the host can translate.
34
+ */
35
+ replace?: MediaFileReplace;
36
+ children: ReactNode;
37
+ }
38
+ export declare function MediaFileProvider({ file, replace, children }: MediaFileProviderProps): import("react").JSX.Element;
39
+ export declare function useMediaFile(): CurrentMediaFile | null;
40
+ export declare function useMediaFileReplace(): MediaFileReplace | null;
41
+ export declare function FileUploadInputView(): import("react").JSX.Element;
42
+ export declare function FileUploadReadOnlyView(): import("react").JSX.Element;
43
+ export declare function FileUploadSettingsView(): import("react").JSX.Element;