@kardalum/plugin-sdk 0.17.0 → 0.19.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 (247) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/README.md +4 -3
  3. package/dist/assets/asset-picker.d.ts +11 -0
  4. package/dist/assets/asset-picker.js +109 -0
  5. package/dist/assets/asset-tree.d.ts +30 -0
  6. package/dist/assets/asset-tree.js +150 -0
  7. package/dist/built-in-editor-ids.d.ts +1 -0
  8. package/dist/built-in-editor-ids.js +20 -0
  9. package/dist/built-in-serializers.js +1 -1
  10. package/dist/built-in-settings-schemas.d.ts +2 -0
  11. package/dist/built-in-settings-schemas.js +31 -4
  12. package/dist/built-in-value-schemas.js +3 -0
  13. package/dist/built-ins.js +20 -11
  14. package/dist/capabilities.js +5 -0
  15. package/dist/data-type-plugin.d.ts +2 -2
  16. package/dist/datatype-validation.d.ts +2 -2
  17. package/dist/datatype-validation.js +20 -6
  18. package/dist/datatypes-entry.d.ts +1 -0
  19. package/dist/datatypes-entry.js +1 -0
  20. package/dist/define-plugin.d.ts +4 -4
  21. package/dist/define-plugin.js +5 -5
  22. package/dist/entitlement-entry.d.ts +3 -2
  23. package/dist/entitlement-entry.js +13 -1
  24. package/dist/entitlement-gate.d.ts +18 -0
  25. package/dist/entitlement-gate.js +95 -21
  26. package/dist/entitlement-plan.d.ts +21 -0
  27. package/dist/entitlement-plan.js +26 -0
  28. package/dist/entitlement-types.d.ts +21 -4
  29. package/dist/entitlement.d.ts +29 -1
  30. package/dist/entitlement.js +39 -0
  31. package/dist/grid-arrow-step.d.ts +7 -0
  32. package/dist/grid-arrow-step.js +20 -0
  33. package/dist/index.d.ts +8 -1
  34. package/dist/index.js +11 -12
  35. package/dist/manifest-entry.d.ts +4 -0
  36. package/dist/manifest-entry.js +4 -0
  37. package/dist/manifest-schema.d.ts +5 -1
  38. package/dist/manifest-schema.js +14 -2
  39. package/dist/manifest.d.ts +21 -1
  40. package/dist/media/media-picker.js +34 -34
  41. package/dist/notify.d.ts +17 -0
  42. package/dist/notify.js +17 -0
  43. package/dist/plugin-context.js +3 -3
  44. package/dist/register-built-ins.js +6 -6
  45. package/dist/registry.js +1 -1
  46. package/dist/richtext/block-panel.js +19 -20
  47. package/dist/richtext/extensions.js +17 -8
  48. package/dist/richtext/insert-menu.js +4 -4
  49. package/dist/richtext/kardalum-block.js +17 -17
  50. package/dist/richtext/style-listbox.js +2 -2
  51. package/dist/richtext/text-style-class.js +1 -1
  52. package/dist/richtext-html-entry.d.ts +35 -0
  53. package/dist/richtext-html-entry.js +73 -0
  54. package/dist/simple-storage-value-provider.js +3 -3
  55. package/dist/structured-storage-types.d.ts +12 -1
  56. package/dist/structured-storage-types.js +2 -2
  57. package/dist/tailwind.js +10 -3
  58. package/dist/tokens/tailwind-theme.css +176 -0
  59. package/dist/tokens/tokens.css +1 -0
  60. package/dist/tokens/tokens.json +2 -1
  61. package/dist/ui-entry.js +3 -3
  62. package/dist/vendor-check.d.ts +39 -0
  63. package/dist/vendor-check.js +79 -0
  64. package/dist/vendor-entry.d.ts +3 -0
  65. package/dist/vendor-entry.js +9 -0
  66. package/dist/vendor-service.d.ts +20 -0
  67. package/dist/vendor-service.js +20 -0
  68. package/dist/views/asset-view.d.ts +6 -0
  69. package/dist/views/asset-view.js +55 -0
  70. package/dist/views/content-list-settings-view.js +1 -1
  71. package/dist/views/content-list-view.js +1 -1
  72. package/dist/views/date-range-view.js +5 -5
  73. package/dist/views/html-code-editor.js +2 -3
  74. package/dist/views/html-view.js +7 -7
  75. package/dist/views/image-view.js +5 -5
  76. package/dist/views/rich-text-view.js +33 -32
  77. package/node_modules/@kardalum/api-schemas/README.md +1 -1
  78. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
  79. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +17 -15
  80. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
  81. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
  82. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +1 -0
  83. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
  84. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
  85. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
  86. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
  87. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +13 -0
  88. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +30 -9
  89. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -3
  90. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +1 -1
  91. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +12 -6
  92. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
  93. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
  94. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +26 -6
  95. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
  96. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +6 -3
  97. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
  98. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
  99. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +90 -0
  100. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +56 -6
  101. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +8 -8
  102. package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
  103. package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
  104. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +48 -19
  105. package/node_modules/@kardalum/api-schemas/dist/index.js +34 -12
  106. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
  107. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
  108. package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.d.ts +46 -0
  109. package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.js +52 -0
  110. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +162 -1
  111. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +144 -9
  112. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
  113. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
  114. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
  115. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +15 -9
  116. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
  117. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
  118. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +5 -5
  119. package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
  120. package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
  121. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
  122. package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
  123. package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
  124. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
  125. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
  126. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +7 -2
  127. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
  128. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +1 -0
  129. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +251 -0
  130. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +196 -31
  131. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
  132. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
  133. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +1 -1
  134. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +3 -3
  135. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +10 -1
  136. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
  137. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
  138. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -20
  139. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +4 -4
  140. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +1 -1
  141. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
  142. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
  143. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +207 -0
  144. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +147 -0
  145. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +11 -0
  146. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -8
  147. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +14 -0
  148. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
  149. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
  150. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
  151. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
  152. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
  153. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +27 -12
  154. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
  155. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
  156. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +1 -1
  157. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +1 -1
  158. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +12 -0
  159. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +6 -1
  160. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
  161. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
  162. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
  163. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
  164. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +13 -0
  165. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
  166. package/node_modules/@kardalum/design-tokens/README.md +1 -1
  167. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +1 -1
  168. package/node_modules/@kardalum/design-tokens/dist/build-css.js +2 -2
  169. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
  170. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
  171. package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
  172. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
  173. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
  174. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +3 -3
  175. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +2 -2
  176. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +2 -2
  177. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +2 -2
  178. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +3 -3
  179. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +3 -3
  180. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +1 -1
  181. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +1 -1
  182. package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
  183. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +3 -3
  184. package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -5
  185. package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
  186. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -1
  187. package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
  188. package/node_modules/@kardalum/design-tokens/package.json +6 -3
  189. package/node_modules/@kardalum/plugin-package/README.md +1 -1
  190. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
  191. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
  192. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
  193. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
  194. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
  195. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
  196. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
  197. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +9 -4
  198. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
  199. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -1
  200. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +2 -2
  201. package/node_modules/@kardalum/plugin-package/dist/envelope.js +2 -2
  202. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +3 -3
  203. package/node_modules/@kardalum/plugin-package/dist/extract.js +10 -10
  204. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +1 -1
  205. package/node_modules/@kardalum/plugin-package/dist/hash.js +1 -1
  206. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
  207. package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
  208. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
  209. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
  210. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +2 -2
  211. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +5 -5
  212. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +1 -1
  213. package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
  214. package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
  215. package/node_modules/@kardalum/ui/README.md +1 -1
  216. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +1 -1
  217. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +8 -3
  218. package/node_modules/@kardalum/ui/dist/components/badge.js +1 -1
  219. package/node_modules/@kardalum/ui/dist/components/button.js +2 -2
  220. package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
  221. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
  222. package/node_modules/@kardalum/ui/dist/components/dialog.js +52 -4
  223. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
  224. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +20 -7
  225. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +4 -4
  226. package/node_modules/@kardalum/ui/dist/components/input.js +6 -1
  227. package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
  228. package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
  229. package/node_modules/@kardalum/ui/dist/components/property-field.js +3 -3
  230. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +1 -1
  231. package/node_modules/@kardalum/ui/dist/components/sheet.js +15 -9
  232. package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
  233. package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
  234. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
  235. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
  236. package/node_modules/@kardalum/ui/dist/components/toast.js +4 -3
  237. package/node_modules/@kardalum/ui/dist/components/tooltip.d.ts +27 -0
  238. package/node_modules/@kardalum/ui/dist/components/tooltip.js +82 -0
  239. package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +11 -0
  240. package/node_modules/@kardalum/ui/dist/components/truncated-text.js +94 -0
  241. package/node_modules/@kardalum/ui/dist/components/use-toast.js +2 -2
  242. package/node_modules/@kardalum/ui/dist/index.d.ts +4 -1
  243. package/node_modules/@kardalum/ui/dist/index.js +4 -1
  244. package/node_modules/@kardalum/ui/dist/lib/menu-host.d.ts +5 -0
  245. package/node_modules/@kardalum/ui/dist/lib/menu-host.js +17 -0
  246. package/node_modules/@kardalum/ui/package.json +8 -6
  247. package/package.json +21 -7
@@ -0,0 +1,24 @@
1
+ import { type VendorTokenPayload } from "@kardalum/api-schemas";
2
+ import type { TrustedKey } from "./types.js";
3
+ export declare const VENDOR_TOKEN_SIGNING_PREFIX: string;
4
+ /** Spec 3e: clock leeway either side. */
5
+ export declare const VENDOR_TOKEN_LEEWAY_SECONDS = 60;
6
+ export type VendorTokenFailure = "missing" | "malformed" | "bad_signature" | "expired";
7
+ export type VendorTokenVerifyResult = {
8
+ ok: true;
9
+ payload: VendorTokenPayload;
10
+ } | {
11
+ ok: false;
12
+ reason: VendorTokenFailure;
13
+ };
14
+ /** The marketplace's signer. Throws RangeError for a payload the schema refuses or past the caps. */
15
+ export declare function signVendorToken(payload: VendorTokenPayload, privateKeyBase64: string): string;
16
+ /**
17
+ * The author's server's check of the signature and the clock (spec 3e). It
18
+ * does not check the plugin, the audience or `live`: createVendorLicenceCheck
19
+ * (@kardalum/plugin-sdk/vendor) does, because only it knows what it expects.
20
+ */
21
+ export declare function verifyVendorToken(token: unknown, trustedKeys: TrustedKey[], opts?: {
22
+ now?: Date;
23
+ leewaySeconds?: number;
24
+ }): VendorTokenVerifyResult;
@@ -0,0 +1,118 @@
1
+ import { createPrivateKey, createPublicKey, sign, verify } from "node:crypto";
2
+ import { VENDOR_TOKEN_MAX_LENGTH, VENDOR_TOKEN_PAYLOAD_MAX_BYTES, VENDOR_TOKEN_TYPE, VendorTokenPayloadSchema, } from "@kardalum/api-schemas";
3
+ import { deriveKeyId } from "./envelope.js";
4
+ // S320 (spec 3a, D4, D5): the vendor token. `<payload>.<signature>`, both
5
+ // base64url without padding. The signature is Ed25519, by the licence verdict
6
+ // key, over the purpose string and the payload segment as it travels (plan
7
+ // P1), so a token's bytes can never be a verdict's canonical JSON (which
8
+ // starts with "{") and the reverse. Parsed without a regex: split on the last
9
+ // ".", linear checks, length caps, then the schema.
10
+ export const VENDOR_TOKEN_SIGNING_PREFIX = `${VENDOR_TOKEN_TYPE}.`;
11
+ /** Spec 3e: clock leeway either side. */
12
+ export const VENDOR_TOKEN_LEEWAY_SECONDS = 60;
13
+ const SIGNATURE_BYTES = 64;
14
+ const termStatesMatch = true;
15
+ void termStatesMatch;
16
+ function signedBytes(payloadSegment) {
17
+ return Buffer.from(VENDOR_TOKEN_SIGNING_PREFIX + payloadSegment, "ascii");
18
+ }
19
+ /** The payload's JSON in the schema's field order, so one payload has one spelling. */
20
+ function payloadText(p) {
21
+ return JSON.stringify({
22
+ typ: p.typ, kid: p.kid, pluginId: p.pluginId, aud: p.aud, domain: p.domain, live: p.live,
23
+ plan: { id: p.plan.id, key: p.plan.key, name: p.plan.name },
24
+ term: { state: p.term.state, endsAt: p.term.endsAt },
25
+ iat: p.iat, exp: p.exp, jti: p.jti,
26
+ });
27
+ }
28
+ /** The marketplace's signer. Throws RangeError for a payload the schema refuses or past the caps. */
29
+ export function signVendorToken(payload, privateKeyBase64) {
30
+ const parsed = VendorTokenPayloadSchema.safeParse(payload);
31
+ if (!parsed.success)
32
+ throw new RangeError("signVendorToken: the payload is malformed");
33
+ const text = Buffer.from(payloadText(parsed.data), "utf8");
34
+ if (text.length > VENDOR_TOKEN_PAYLOAD_MAX_BYTES)
35
+ throw new RangeError("signVendorToken: the payload is over 4 KiB");
36
+ const segment = text.toString("base64url");
37
+ const key = createPrivateKey({ key: Buffer.from(privateKeyBase64, "base64"), format: "der", type: "pkcs8" });
38
+ const token = `${segment}.${sign(null, signedBytes(segment), key).toString("base64url")}`;
39
+ if (token.length > VENDOR_TOKEN_MAX_LENGTH)
40
+ throw new RangeError("signVendorToken: the token is too long");
41
+ return token;
42
+ }
43
+ /** Plan P2: a segment counts only in its one canonical base64url spelling. */
44
+ function decodeSegment(segment) {
45
+ if (segment.length === 0)
46
+ return null;
47
+ const bytes = Buffer.from(segment, "base64url");
48
+ return bytes.toString("base64url") === segment ? bytes : null;
49
+ }
50
+ function keyFor(kid, trustedKeys) {
51
+ return trustedKeys.find((k) => {
52
+ try {
53
+ return deriveKeyId(k.publicKey) === kid;
54
+ }
55
+ catch {
56
+ return false;
57
+ }
58
+ });
59
+ }
60
+ /**
61
+ * The author's server's check of the signature and the clock (spec 3e). It
62
+ * does not check the plugin, the audience or `live`: createVendorLicenceCheck
63
+ * (@kardalum/plugin-sdk/vendor) does, because only it knows what it expects.
64
+ */
65
+ export function verifyVendorToken(token, trustedKeys, opts = {}) {
66
+ if (token === undefined || token === null || token === "")
67
+ return { ok: false, reason: "missing" };
68
+ if (typeof token !== "string" || token.length > VENDOR_TOKEN_MAX_LENGTH)
69
+ return { ok: false, reason: "malformed" };
70
+ const dot = token.lastIndexOf(".");
71
+ if (dot <= 0 || dot === token.length - 1)
72
+ return { ok: false, reason: "malformed" };
73
+ const payloadSegment = token.slice(0, dot);
74
+ if (payloadSegment.includes("."))
75
+ return { ok: false, reason: "malformed" };
76
+ // Cheap bound before decoding: 4 KiB of bytes is at most 5462 base64url characters.
77
+ if (payloadSegment.length > Math.ceil((VENDOR_TOKEN_PAYLOAD_MAX_BYTES * 4) / 3))
78
+ return { ok: false, reason: "malformed" };
79
+ const payloadBytes = decodeSegment(payloadSegment);
80
+ const signature = decodeSegment(token.slice(dot + 1));
81
+ if (!payloadBytes || !signature || signature.length !== SIGNATURE_BYTES || payloadBytes.length > VENDOR_TOKEN_PAYLOAD_MAX_BYTES) {
82
+ return { ok: false, reason: "malformed" };
83
+ }
84
+ let json;
85
+ try {
86
+ json = JSON.parse(payloadBytes.toString("utf8"));
87
+ }
88
+ catch {
89
+ return { ok: false, reason: "malformed" };
90
+ }
91
+ const parsed = VendorTokenPayloadSchema.safeParse(json);
92
+ if (!parsed.success)
93
+ return { ok: false, reason: "malformed" };
94
+ const match = keyFor(parsed.data.kid, trustedKeys);
95
+ if (!match)
96
+ return { ok: false, reason: "bad_signature" };
97
+ let authentic = false;
98
+ try {
99
+ authentic = verify(null, signedBytes(payloadSegment), createPublicKey({ key: Buffer.from(match.publicKey, "base64"), format: "der", type: "spki" }), signature);
100
+ }
101
+ catch {
102
+ authentic = false;
103
+ }
104
+ if (!authentic)
105
+ return { ok: false, reason: "bad_signature" };
106
+ const nowSeconds = Math.floor((opts.now ?? new Date()).getTime() / 1000);
107
+ const leeway = opts.leewaySeconds ?? VENDOR_TOKEN_LEEWAY_SECONDS;
108
+ // An invalid clock would make every comparison below false and pass any token: a caller bug, refused loudly.
109
+ if (!Number.isFinite(nowSeconds))
110
+ throw new RangeError("verifyVendorToken: opts.now is not a valid date");
111
+ if (!Number.isFinite(leeway) || leeway < 0)
112
+ throw new RangeError("verifyVendorToken: opts.leewaySeconds must be a finite number of seconds, zero or more");
113
+ if (parsed.data.iat > nowSeconds + leeway)
114
+ return { ok: false, reason: "malformed" };
115
+ if (nowSeconds > parsed.data.exp + leeway)
116
+ return { ok: false, reason: "expired" };
117
+ return { ok: true, payload: parsed.data };
118
+ }
@@ -32,4 +32,4 @@ function Example() {
32
32
 
33
33
  Kardalum's source is not public. Questions and bug reports:
34
34
  [kardalum-devkit](https://github.com/kardalum/kardalum-devkit). Docs at
35
- https://docs.kardalum.com. Apache-2.0.
35
+ https://dev.kardalum.com/docs/. Apache-2.0.
@@ -4,7 +4,7 @@ declare const AlertDialog: React.FC<AlertDialogPrimitive.AlertDialogProps>;
4
4
  declare const AlertDialogTrigger: React.ForwardRefExoticComponent<AlertDialogPrimitive.AlertDialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
5
  declare const AlertDialogPortal: React.FC<AlertDialogPrimitive.AlertDialogPortalProps>;
6
6
  declare function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): React.JSX.Element;
7
- declare function AlertDialogContent({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content>): React.JSX.Element;
7
+ declare function AlertDialogContent({ className, children, ref, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content>): React.JSX.Element;
8
8
  declare function AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
9
9
  declare function AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
10
10
  declare function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): React.JSX.Element;
@@ -1,10 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
3
3
  import { cn } from '../lib/cn.js';
4
+ import { useMenuHost } from '../lib/menu-host.js';
5
+ import { DropdownMenuContainer } from './dropdown-menu.js';
4
6
  import { buttonVariants } from './button.js';
5
7
  // Ported from shadcn/ui's AlertDialog (Radix under the hood), retargeted
6
8
  // to @kardalum/design-tokens classes, no tailwindcss-animate dependency,
7
- // and no owned strings — title/description/action labels all come from
9
+ // and no owned strings: title/description/action labels all come from
8
10
  // the caller. For consequential confirmations (snapshot restore, future
9
11
  // destructive flows); Radix provides the focus trap, escape handling,
10
12
  // and aria wiring.
@@ -14,8 +16,11 @@ const AlertDialogPortal = AlertDialogPrimitive.Portal;
14
16
  function AlertDialogOverlay({ className, ...props }) {
15
17
  return (_jsx(AlertDialogPrimitive.Overlay, { className: cn('fixed inset-0 z-50 bg-background-overlay', className), ...props }));
16
18
  }
17
- function AlertDialogContent({ className, ...props }) {
18
- return (_jsxs(AlertDialogPortal, { children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Content, { className: cn('fixed start-1/2 top-1/2 z-50 w-full max-w-lg -translate-y-1/2 ltr:-translate-x-1/2 rtl:translate-x-1/2 rounded-xl border border-border-default bg-background-elevated p-6 shadow-xl', className), ...props })] }));
19
+ // S356: each modal surface hosts its own menus (see lib/menu-host.ts).
20
+ function AlertDialogContent({ className, children, ref, ...props }) {
21
+ const menuHost = useMenuHost(ref);
22
+ const host = menuHost.host;
23
+ return (_jsxs(AlertDialogPortal, { children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Content, { className: cn('fixed start-1/2 top-1/2 z-50 w-full max-w-lg -translate-y-1/2 ltr:-translate-x-1/2 rtl:translate-x-1/2 rounded-xl border border-border-default bg-background-elevated p-6 shadow-xl', className), ...props, ref: menuHost.ref, children: _jsx(DropdownMenuContainer, { container: host, children: children }) })] }));
19
24
  }
20
25
  function AlertDialogHeader({ className, ...props }) {
21
26
  return _jsx("div", { className: cn('flex flex-col gap-2 text-start', className), ...props });
@@ -3,7 +3,7 @@ import { cva } from 'class-variance-authority';
3
3
  import { cn } from '../lib/cn.js';
4
4
  // Status pill (Draft/Published/…). Soft style: 100-step fill + the
5
5
  // lightest text step that clears AA on that fill (S179: success/danger
6
- // 700, warning 800 — plain 600 measured 3.1–4.3:1, below the 4.5:1
6
+ // 700, warning 800; plain 600 measured 3.1–4.3:1, below the 4.5:1
7
7
  // minimum). Both steps are theme-remapped by the dark set, so the pill
8
8
  // stays readable in both themes without per-variant juggling. The
9
9
  // `primary` variant is the exception: it's an identity chip (role badges,
@@ -6,11 +6,11 @@ import { cn } from '../lib/cn.js';
6
6
  // @kardalum/design-tokens Tailwind theme: all of these classes resolve
7
7
  // to var(--...) references, never baked values (host-provided
8
8
  // components constraint).
9
- const buttonVariants = cva('inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors duration-fast focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:pointer-events-none disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50', {
9
+ const buttonVariants = cva('inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:pointer-events-none disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50', {
10
10
  variants: {
11
11
  variant: {
12
12
  // Action = primary-600 (S177): cerulean in light, the light blue
13
- // itself in dark — text.inverse flips with it.
13
+ // itself in dark, text.inverse flips with it.
14
14
  default: 'bg-primary-600 text-text-inverse hover:bg-primary-700',
15
15
  secondary: 'bg-secondary-500 text-text-inverse hover:bg-secondary-600',
16
16
  destructive: 'bg-danger-600 text-text-inverse hover:bg-danger-700',
@@ -2,6 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
3
3
  import { cn } from '../lib/cn.js';
4
4
  function Checkbox({ className, ...props }) {
5
- return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-neutral-500 bg-background-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary-600 data-[state=checked]:bg-primary-600 data-[state=checked]:text-text-inverse data-[state=indeterminate]:border-primary-600 data-[state=indeterminate]:text-primary-600', className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { className: "group flex items-center justify-center text-current", children: [_jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "h-3 w-3 group-data-[state=indeterminate]:hidden", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 8.5L6.5 11.5L12.5 4.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "hidden h-3 w-3 group-data-[state=indeterminate]:block", "aria-hidden": "true", children: _jsx("path", { d: "M4 8h8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })] }) }));
5
+ return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-neutral-500 bg-background-elevated focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary-600 data-[state=checked]:bg-primary-600 data-[state=checked]:text-text-inverse data-[state=indeterminate]:border-primary-600 data-[state=indeterminate]:text-primary-600', className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { className: "group flex items-center justify-center text-current", children: [_jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "h-3 w-3 group-data-[state=indeterminate]:hidden", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 8.5L6.5 11.5L12.5 4.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "hidden h-3 w-3 group-data-[state=indeterminate]:block", "aria-hidden": "true", children: _jsx("path", { d: "M4 8h8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })] }) }));
6
6
  }
7
7
  export { Checkbox };
@@ -5,7 +5,7 @@ declare const DialogTrigger: React.ForwardRefExoticComponent<DialogPrimitive.Dia
5
5
  declare const DialogPortal: React.FC<DialogPrimitive.DialogPortalProps>;
6
6
  declare const DialogClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
7
7
  declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
8
- declare function DialogContent({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Content>): React.JSX.Element;
8
+ declare function DialogContent({ className, children, ref, onOpenAutoFocus, ...props }: React.ComponentProps<typeof DialogPrimitive.Content>): React.JSX.Element;
9
9
  declare function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
10
10
  declare function DialogFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
11
11
  declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): React.JSX.Element;
@@ -1,12 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as DialogPrimitive from '@radix-ui/react-dialog';
3
3
  import { cn } from '../lib/cn.js';
4
+ import { IconTooltip } from './tooltip.js';
5
+ import { useMenuHost } from '../lib/menu-host.js';
6
+ import { DropdownMenuContainer } from './dropdown-menu.js';
4
7
  // Hand-ported from shadcn/ui's Dialog (Radix under the hood), retargeted to
5
8
  // @kardalum/design-tokens classes, no tailwindcss-animate dependency, and
6
- // no owned strings — title/description/close labels all come from the
9
+ // no owned strings: title/description/close labels all come from the
7
10
  // caller, same convention as AlertDialog. Radix supplies the focus trap,
8
11
  // Escape handling, and aria wiring; `onCloseAutoFocus` on DialogContent is
9
12
  // how a caller returns focus to its trigger (see the admin UI conventions).
13
+ // Radix hides the page behind with aria-hidden but never marks the dialog
14
+ // itself modal, so DialogContent sets aria-modal="true" as a default the
15
+ // caller can override (S314c4).
10
16
  const Dialog = DialogPrimitive.Root;
11
17
  const DialogTrigger = DialogPrimitive.Trigger;
12
18
  const DialogPortal = DialogPrimitive.Portal;
@@ -27,8 +33,50 @@ function DialogOverlay({ className, ...props }) {
27
33
  // and never reaches this scrollbar, while a caller that does nothing still
28
34
  // gets a reachable footer. 460px, the height a 920px screen gives at 200%
29
35
  // browser zoom, is the case this is measured against (WCAG 1.4.4).
30
- function DialogContent({ className, ...props }) {
31
- return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsx(DialogPrimitive.Content, { className: cn('fixed start-1/2 top-1/2 z-50 max-h-[calc(100dvh_-_var(--spacing-8))] w-full max-w-lg -translate-y-1/2 overflow-y-auto ltr:-translate-x-1/2 rtl:translate-x-1/2 rounded-xl border border-border-default bg-background-elevated p-6 shadow-xl', className), ...props })] }));
36
+ // S356: each modal surface hosts its own menus (see lib/menu-host.ts).
37
+ //
38
+ // S366c spec D6: a dialog opens on its first field (an input, select,
39
+ // textarea or editable region that takes focus), where the person's task
40
+ // starts. A dialog with none opens on the content itself (tabIndex -1), so no
41
+ // control, and no Close tooltip, is announced on every open. A caller's own
42
+ // onOpenAutoFocus runs first; one that prevents the default keeps control.
43
+ const FIRST_FIELD = 'input, select, textarea, [contenteditable="true"], [contenteditable=""]';
44
+ function fieldCandidates(content) {
45
+ const found = [];
46
+ for (const element of content.querySelectorAll(FIRST_FIELD)) {
47
+ if (element instanceof HTMLInputElement && element.type === 'hidden')
48
+ continue;
49
+ if (element.disabled === true)
50
+ continue;
51
+ if (element.closest('[hidden], [inert], [aria-hidden="true"]') !== null)
52
+ continue;
53
+ found.push(element);
54
+ }
55
+ return found;
56
+ }
57
+ // A field hidden by CSS cannot take focus, so each candidate is tried in order
58
+ // and the first that holds it wins; none, and the dialog itself takes it.
59
+ function focusFirstField(content) {
60
+ for (const element of fieldCandidates(content)) {
61
+ element.focus({ preventScroll: true });
62
+ if (document.activeElement === element)
63
+ return;
64
+ }
65
+ content.focus({ preventScroll: true });
66
+ }
67
+ function DialogContent({ className, children, ref, onOpenAutoFocus, ...props }) {
68
+ const menuHost = useMenuHost(ref);
69
+ const host = menuHost.host;
70
+ return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsx(DialogPrimitive.Content, { "aria-modal": "true", tabIndex: -1, onOpenAutoFocus: (event) => {
71
+ onOpenAutoFocus?.(event);
72
+ if (event.defaultPrevented)
73
+ return;
74
+ const content = event.currentTarget instanceof HTMLElement ? event.currentTarget : null;
75
+ if (content === null)
76
+ return;
77
+ event.preventDefault();
78
+ focusFirstField(content);
79
+ }, className: cn('fixed start-1/2 top-1/2 z-50 max-h-[calc(100dvh_-_var(--spacing-8))] w-full max-w-lg focus:outline-hidden -translate-y-1/2 overflow-y-auto ltr:-translate-x-1/2 rtl:translate-x-1/2 rounded-xl border border-border-default bg-background-elevated p-6 shadow-xl', className), ...props, ref: menuHost.ref, children: _jsx(DropdownMenuContainer, { container: host, children: children }) })] }));
32
80
  }
33
81
  function DialogHeader({ className, ...props }) {
34
82
  return (_jsx("div", { className: cn('flex items-center gap-2 text-start', className), ...props }));
@@ -43,6 +91,6 @@ function DialogDescription({ className, ...props }) {
43
91
  return (_jsx(DialogPrimitive.Description, { className: cn('text-sm text-text-secondary', className), ...props }));
44
92
  }
45
93
  function DialogCloseButton({ className, ...props }) {
46
- return (_jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
94
+ return (_jsx(IconTooltip, { children: _jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }) }));
47
95
  }
48
96
  export { Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogClose, DialogCloseButton, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
@@ -1,6 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
3
3
  declare function DropdownMenu({ modal, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>): React.JSX.Element;
4
+ declare function DropdownMenuContainer({ container, children, }: {
5
+ container: HTMLElement | null;
6
+ children: React.ReactNode;
7
+ }): React.JSX.Element;
4
8
  declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>>;
5
9
  declare const DropdownMenuPortal: React.FC<DropdownMenuPrimitive.DropdownMenuPortalProps>;
6
10
  declare const DropdownMenuGroup: React.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>>;
@@ -15,4 +19,4 @@ declare function DropdownMenuLabel({ className, inset, ...props }: React.Compone
15
19
  inset?: boolean;
16
20
  }): React.JSX.Element;
17
21
  declare function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>): React.JSX.Element;
18
- export { DropdownMenu, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuGroup, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, };
22
+ export { DropdownMenu, DropdownMenuContainer, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuGroup, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, };
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
2
3
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
3
4
  import { cn } from '../lib/cn.js';
4
5
  // Ported from shadcn/ui's DropdownMenu (Radix under the hood), retargeted
@@ -12,13 +13,13 @@ import { cn } from '../lib/cn.js';
12
13
  //
13
14
  // 1. It marks the rest of the page `aria-hidden="true"` while the menu is
14
15
  // open, leaving every focusable control on the screen inside an
15
- // aria-hidden subtree — a genuine 4.1.2 failure, which axe reports as
16
+ // aria-hidden subtree, which is a genuine 4.1.2 failure that axe reports as
16
17
  // `aria-hidden-focus`.
17
18
  // 2. It locks `pointer-events: none` onto <body>. When a menu item opens
18
19
  // a dialog (the tree row's ⋯ → Delete), the menu's layer and the
19
20
  // dialog's layer both own that lock; the menu unmounts first, the
20
21
  // dialog restores the value the menu had already set, and closing the
21
- // dialog leaves `pointer-events: none` on <body> permanently — the
22
+ // dialog leaves `pointer-events: none` on <body> permanently: the
22
23
  // entire admin stops responding to the mouse until a page reload.
23
24
  //
24
25
  // Non-modal is also what the WAI-ARIA menu button pattern describes: Tab
@@ -27,20 +28,32 @@ import { cn } from '../lib/cn.js';
27
28
  function DropdownMenu({ modal = false, ...props }) {
28
29
  return _jsx(DropdownMenuPrimitive.Root, { modal: modal, ...props });
29
30
  }
31
+ // S356 (D5): where a menu's content mounts. A surface that traps focus (the
32
+ // admin's phone tree sheet, a modal Radix Dialog) keeps focus inside its own
33
+ // DOM, so a menu portalled to <body> from inside it has its focus pulled back
34
+ // and dismisses itself at once. Such a surface names its element here, and
35
+ // every menu rendered inside it mounts there instead; outside one, menus
36
+ // mount on <body> as before. Non-modal is unchanged: this is about where the
37
+ // content lives, not about the menu's own modality.
38
+ const DropdownMenuContainerContext = React.createContext(null);
39
+ function DropdownMenuContainer({ container, children, }) {
40
+ return _jsx(DropdownMenuContainerContext.Provider, { value: container, children: children });
41
+ }
30
42
  const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
31
43
  const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
32
44
  const DropdownMenuGroup = DropdownMenuPrimitive.Group;
33
45
  const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
34
- // Radio item with a check indicator at the inline start — the shape a
46
+ // Radio item with a check indicator at the inline start: the shape a
35
47
  // "pick one" preference (theme mode, language) takes inside a menu.
36
48
  function DropdownMenuRadioItem({ className, children, ...props }) {
37
- return (_jsxs(DropdownMenuPrimitive.RadioItem, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm py-2 pe-2 ps-8 text-sm text-text-primary outline-none transition-colors data-[highlighted]:bg-background-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), ...props, children: [_jsx("span", { className: "absolute start-2 flex size-4 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "size-4 text-primary-600", children: _jsx("path", { d: "M20 6 9 17l-5-5" }) }) }) }), children] }));
49
+ return (_jsxs(DropdownMenuPrimitive.RadioItem, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm py-2 pe-2 ps-8 text-sm text-text-primary outline-hidden transition-colors data-[highlighted]:bg-background-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className), ...props, children: [_jsx("span", { className: "absolute start-2 flex size-4 items-center justify-center", children: _jsx(DropdownMenuPrimitive.ItemIndicator, { children: _jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "size-4 text-primary-600", children: _jsx("path", { d: "M20 6 9 17l-5-5" }) }) }) }), children] }));
38
50
  }
39
51
  function DropdownMenuContent({ className, sideOffset = 4, ...props }) {
40
- return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { sideOffset: sideOffset, className: cn('z-50 min-w-[10rem] overflow-hidden rounded-lg border border-border-default bg-background-elevated p-1 text-text-primary shadow-lg', className), ...props }) }));
52
+ const container = React.useContext(DropdownMenuContainerContext);
53
+ return (_jsx(DropdownMenuPrimitive.Portal, { container: container ?? undefined, children: _jsx(DropdownMenuPrimitive.Content, { sideOffset: sideOffset, className: cn('z-50 min-w-[10rem] overflow-hidden rounded-lg border border-border-default bg-background-elevated p-1 text-text-primary shadow-lg', className), ...props }) }));
41
54
  }
42
55
  function DropdownMenuItem({ className, inset, variant = 'default', ...props }) {
43
- return (_jsx(DropdownMenuPrimitive.Item, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50', variant === 'destructive'
56
+ return (_jsx(DropdownMenuPrimitive.Item, { className: cn('relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50', variant === 'destructive'
44
57
  ? 'text-danger-600 data-[highlighted]:bg-danger-100 data-[highlighted]:text-danger-700'
45
58
  : 'text-text-primary data-[highlighted]:bg-background-hover', inset && 'ps-8', className), ...props }));
46
59
  }
@@ -50,4 +63,4 @@ function DropdownMenuLabel({ className, inset, ...props }) {
50
63
  function DropdownMenuSeparator({ className, ...props }) {
51
64
  return (_jsx(DropdownMenuPrimitive.Separator, { className: cn('-mx-1 my-1 h-px bg-border-default', className), ...props }));
52
65
  }
53
- export { DropdownMenu, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuGroup, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, };
66
+ export { DropdownMenu, DropdownMenuContainer, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuGroup, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, };
@@ -1,15 +1,15 @@
1
1
  import * as React from 'react';
2
2
  export interface EmptyStateProps extends React.ComponentProps<'div'> {
3
- /** Icon element (e.g. a lucide icon) — sized/colored by the caller. */
3
+ /** Icon element (e.g. a lucide icon), sized/colored by the caller. */
4
4
  icon?: React.ReactNode;
5
- /** Translated title — this component owns no strings. */
5
+ /** Translated title: this component owns no strings. */
6
6
  title: string;
7
7
  /** Optional translated supporting text. */
8
8
  description?: string;
9
9
  /** Optional primary action (usually a Button). */
10
10
  action?: React.ReactNode;
11
11
  /**
12
- * Element used for the title — a paragraph by default, because most
12
+ * Element used for the title, a paragraph by default, because most
13
13
  * empty states sit *inside* a screen that already owns its <h1>.
14
14
  * Where the empty state IS the whole screen (the unmatched-route view,
15
15
  * a section's "nothing selected yet" landing), pass a heading so the
@@ -17,7 +17,7 @@ export interface EmptyStateProps extends React.ComponentProps<'div'> {
17
17
  */
18
18
  titleAs?: 'p' | 'h1' | 'h2' | 'h3';
19
19
  /**
20
- * Extra props for the title element — the host app uses this to mark a
20
+ * Extra props for the title element: the host app uses this to mark a
21
21
  * screen-level title as its focus target on navigation. Kept as a
22
22
  * pass-through so this primitive stays ignorant of the shell's
23
23
  * conventions.
@@ -1,6 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from '../lib/cn.js';
3
3
  function Input({ className, type, ...props }) {
4
- return (_jsx("input", { type: type, "data-slot": "input", className: cn('flex h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary placeholder:text-text-disabled file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-text-primary transition-colors duration-fast focus-visible:border-primary-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary-50 disabled:cursor-not-allowed disabled:opacity-50', className), ...props }));
4
+ return (_jsx("input", { type: type, "data-slot": "input", className: cn(
5
+ // S354 (D1): the placeholder is text-tertiary on background-elevated,
6
+ // 5.64:1 light (#616966 on #FFFFFF) and 5.46:1 dark (#969C99 on
7
+ // #232625), above AA's 4.5:1. It was text-disabled, 3.11:1 and
8
+ // 3.25:1; the site's Input (packages/site-ui) moved the same way in S256.
9
+ 'flex h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary placeholder:text-text-tertiary file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-text-primary transition-colors duration-fast focus-visible:border-primary-600 focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-primary-50 disabled:cursor-not-allowed disabled:opacity-50', className), ...props }));
5
10
  }
6
11
  export { Input };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
3
+ declare function PopoverPanel({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Content>): React.JSX.Element;
4
+ export { PopoverPanel };
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
3
+ import { cn } from '../lib/cn.js';
4
+ // S314n2: a small panel pinned under the app bar at the inline end, the content of a
5
+ // non-modal Dialog (`<Dialog modal={false}>`): the bell's notifications. Radix supplies
6
+ // Escape, the outside click that closes it and the return of focus to its trigger; being
7
+ // non-modal, the page behind stays live and gets no overlay. Never wider than the viewport
8
+ // less a gutter, so at a phone's width it spans the screen. No owned strings: the caller
9
+ // gives it a DialogTitle.
10
+ function PopoverPanel({ className, ...props }) {
11
+ return (_jsx(DialogPrimitive.Portal, { children: _jsx(DialogPrimitive.Content, { className: cn('fixed end-4 top-14 z-50 flex max-h-[calc(100dvh_-_var(--spacing-16))] w-[calc(100vw_-_var(--spacing-8))] max-w-md flex-col overflow-hidden rounded-lg border border-border-default bg-background-elevated shadow-xl', className), ...props }) }));
12
+ }
13
+ export { PopoverPanel };
@@ -7,13 +7,13 @@ const PropertyFieldContext = React.createContext(null);
7
7
  // component, not a DOM element, so there is no child element to attach
8
8
  // `id`/`aria-*` to. Any control rendered *anywhere* under a PropertyField
9
9
  // can spread the result of this hook onto itself and be correctly named,
10
- // described and marked invalid — which is how a third-party data-type
10
+ // described and marked invalid, which is how a third-party data-type
11
11
  // plugin's editor gets an accessible name without the host knowing
12
12
  // anything about its internals.
13
13
  //
14
14
  // Returns an EMPTY object outside a PropertyField (never null), so every
15
- // call site can spread the result unconditionally —
16
- // `<input {...usePropertyFieldControl()} />` — and a view stays usable
15
+ // call site can spread the result unconditionally
16
+ // (`<input {...usePropertyFieldControl()} />`), and a view stays usable
17
17
  // both inside and outside a field without a `?? {}` at each use.
18
18
  const NO_PROPERTY_FIELD = Object.freeze({});
19
19
  export function usePropertyFieldControl() {
@@ -5,7 +5,7 @@ declare const SheetTrigger: React.ForwardRefExoticComponent<DialogPrimitive.Dial
5
5
  declare const SheetPortal: React.FC<DialogPrimitive.DialogPortalProps>;
6
6
  declare const SheetClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
7
7
  declare function SheetOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
8
- declare function SheetContent({ className, children, ...props }: React.ComponentProps<typeof DialogPrimitive.Content>): React.JSX.Element;
8
+ declare function SheetContent({ className, children, ref, ...props }: React.ComponentProps<typeof DialogPrimitive.Content>): React.JSX.Element;
9
9
  declare function SheetHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
10
10
  declare function SheetFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
11
11
  declare function SheetTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): React.JSX.Element;
@@ -2,18 +2,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import * as DialogPrimitive from '@radix-ui/react-dialog';
4
4
  import { cn } from '../lib/cn.js';
5
- // A right-side drawer variant of Dialog — same Radix primitive underneath
5
+ import { IconTooltip } from './tooltip.js';
6
+ import { useMenuHost } from '../lib/menu-host.js';
7
+ import { DropdownMenuContainer } from './dropdown-menu.js';
8
+ // A right-side drawer variant of Dialog, with the same Radix primitive underneath
6
9
  // (focus trap, Escape handling, aria wiring: SheetContent is still a
7
- // DialogPrimitive.Content, so it still carries role="dialog"/aria-modal
8
- // the way DialogContent does), just a different Content shell: a
10
+ // DialogPrimitive.Content, so it carries role="dialog", and like
11
+ // DialogContent it sets aria-modal="true" itself as an overridable default,
12
+ // because Radix does not), just a different Content shell: a
9
13
  // fixed-width panel pinned to the inline end of the viewport instead of a
10
14
  // centered card. Ported by hand in the shadcn/ui model (same convention as
11
15
  // dialog.tsx/alert-dialog.tsx: retargeted to @kardalum/design-tokens
12
16
  // classes, no tailwindcss-animate dependency, no owned strings). First
13
- // added for S197 Item 5's media picker drawer — the first place this
17
+ // added for S197 Item 5's media picker drawer, the first place this
14
18
  // admin needs a side-sheet through this primitive rather than a centered
15
19
  // dialog (block-overlay.tsx's on-page block param panel is its own
16
- // bespoke non-Radix side panel, not a Dialog at all — see that file's own
20
+ // bespoke non-Radix side panel, not a Dialog at all; see that file's own
17
21
  // doc comment for why it needed a manual focus trap instead of this).
18
22
  const Sheet = DialogPrimitive.Root;
19
23
  const SheetTrigger = DialogPrimitive.Trigger;
@@ -24,18 +28,20 @@ function SheetOverlay({ className, ...props }) {
24
28
  }
25
29
  // Slides in from the inline end on mount via a plain CSS transition, not
26
30
  // Radix's own animation data-attributes (this package takes no
27
- // tailwindcss-animate dependency — see dialog.tsx's own doc comment).
31
+ // tailwindcss-animate dependency; see dialog.tsx's own doc comment).
28
32
  // `motion-safe:`/`motion-reduce:` gate the transition itself, same guard
29
33
  // overlay-insert.tsx's "+" button already uses for its own color
30
34
  // transition: under prefers-reduced-motion the panel still ends up in its
31
35
  // final position on the very next frame, just without the slide.
32
- function SheetContent({ className, children, ...props }) {
36
+ function SheetContent({ className, children, ref, ...props }) {
37
+ const menuHost = useMenuHost(ref);
38
+ const host = menuHost.host;
33
39
  const [entered, setEntered] = React.useState(false);
34
40
  React.useEffect(() => {
35
41
  const frame = requestAnimationFrame(() => setEntered(true));
36
42
  return () => cancelAnimationFrame(frame);
37
43
  }, []);
38
- return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsx(DialogPrimitive.Content, { className: cn('fixed inset-y-0 end-0 z-50 flex h-full w-full max-w-md flex-col border-s border-border-default bg-background-elevated shadow-xl', 'motion-safe:transition-transform motion-safe:duration-normal motion-safe:ease-standard motion-reduce:transition-none', entered ? 'translate-x-0' : 'ltr:translate-x-full rtl:-translate-x-full', className), ...props, children: children })] }));
44
+ return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsx(DialogPrimitive.Content, { "aria-modal": "true", className: cn('fixed inset-y-0 end-0 z-50 flex h-full w-full max-w-md flex-col border-s border-border-default bg-background-elevated shadow-xl', 'motion-safe:transition-transform motion-safe:duration-normal motion-safe:ease-standard motion-reduce:transition-none', entered ? 'translate-x-0' : 'ltr:translate-x-full rtl:-translate-x-full', className), ...props, ref: menuHost.ref, children: _jsx(DropdownMenuContainer, { container: host, children: children }) })] }));
39
45
  }
40
46
  function SheetHeader({ className, ...props }) {
41
47
  return (_jsx("div", { className: cn('flex shrink-0 items-center gap-2 border-b border-border-default px-4 py-3 text-start', className), ...props }));
@@ -50,6 +56,6 @@ function SheetDescription({ className, ...props }) {
50
56
  return (_jsx(DialogPrimitive.Description, { className: cn('text-sm text-text-secondary', className), ...props }));
51
57
  }
52
58
  function SheetCloseButton({ className, ...props }) {
53
- return (_jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }));
59
+ return (_jsx(IconTooltip, { children: _jsx(DialogPrimitive.Close, { className: cn('ms-auto shrink-0 rounded-md p-1 text-text-secondary opacity-70 transition-colors duration-fast hover:bg-background-hover hover:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600', className), ...props, children: _jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-4 w-4", children: [_jsx("path", { d: "M18 6 6 18" }), _jsx("path", { d: "m6 6 12 12" })] }) }) }));
54
60
  }
55
61
  export { Sheet, SheetTrigger, SheetPortal, SheetClose, SheetCloseButton, SheetOverlay, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, };
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from '../lib/cn.js';
3
3
  // Loading placeholder for async lists. background.hover is deliberately
4
- // reused as the shimmer base — it's the "subtle wash" token and is
4
+ // reused as the shimmer base: it's the "subtle wash" token and is
5
5
  // theme-remapped, so the skeleton stays subtle in dark mode too.
6
6
  function Skeleton({ className, ...props }) {
7
7
  return (_jsx("div", { "data-slot": "skeleton", "aria-hidden": "true", className: cn('animate-pulse rounded-md bg-background-hover', className), ...props }));
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as SwitchPrimitive from '@radix-ui/react-switch';
3
3
  import { cn } from '../lib/cn.js';
4
4
  function Switch({ className, ...props }) {
5
- return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", className: cn('peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary-600 data-[state=unchecked]:bg-border-strong', className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "pointer-events-none block h-5 w-5 rounded-full bg-background-elevated shadow-sm ring-0 transition-transform data-[state=unchecked]:translate-x-0 ltr:data-[state=checked]:translate-x-5 rtl:data-[state=checked]:-translate-x-5" }) }));
5
+ return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", className: cn('peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary-600 data-[state=unchecked]:bg-border-strong', className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "pointer-events-none block h-5 w-5 rounded-full bg-background-elevated shadow-sm ring-0 transition-transform data-[state=unchecked]:translate-x-0 ltr:data-[state=checked]:translate-x-5 rtl:data-[state=checked]:-translate-x-5" }) }));
6
6
  }
7
7
  export { Switch };
@@ -15,15 +15,15 @@ export interface TabStripProps {
15
15
  tabs: TabStripItem[];
16
16
  activeId: string;
17
17
  onChange: (id: string) => void;
18
- /** Accessible name for the tablist — pass translated text. */
18
+ /** Accessible name for the tablist: pass translated text. */
19
19
  label: string;
20
20
  /** Appended to a tab's accessible name when that tab's `hasError` is
21
- * set (e.g. "Has an error") — pass translated text. Only needed if any
21
+ * set (e.g. "Has an error"), so pass translated text. Only needed if any
22
22
  * tab uses `hasError`. */
23
23
  errorLabel?: string;
24
24
  /**
25
25
  * Prefix for the generated tab/panel DOM ids so aria-controls /
26
- * aria-labelledby wiring stays consistent — pair with tabStripTabId /
26
+ * aria-labelledby wiring stays consistent: pair with tabStripTabId /
27
27
  * tabStripPanelId on the consumer's panel element.
28
28
  */
29
29
  idPrefix: string;