@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.
- package/CHANGELOG.md +109 -0
- package/README.md +4 -3
- package/dist/assets/asset-picker.d.ts +11 -0
- package/dist/assets/asset-picker.js +109 -0
- package/dist/assets/asset-tree.d.ts +30 -0
- package/dist/assets/asset-tree.js +150 -0
- package/dist/built-in-editor-ids.d.ts +1 -0
- package/dist/built-in-editor-ids.js +20 -0
- package/dist/built-in-serializers.js +1 -1
- package/dist/built-in-settings-schemas.d.ts +2 -0
- package/dist/built-in-settings-schemas.js +31 -4
- package/dist/built-in-value-schemas.js +3 -0
- package/dist/built-ins.js +20 -11
- package/dist/capabilities.js +5 -0
- package/dist/data-type-plugin.d.ts +2 -2
- package/dist/datatype-validation.d.ts +2 -2
- package/dist/datatype-validation.js +20 -6
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +1 -0
- package/dist/define-plugin.d.ts +4 -4
- package/dist/define-plugin.js +5 -5
- package/dist/entitlement-entry.d.ts +3 -2
- package/dist/entitlement-entry.js +13 -1
- package/dist/entitlement-gate.d.ts +18 -0
- package/dist/entitlement-gate.js +95 -21
- package/dist/entitlement-plan.d.ts +21 -0
- package/dist/entitlement-plan.js +26 -0
- package/dist/entitlement-types.d.ts +21 -4
- package/dist/entitlement.d.ts +29 -1
- package/dist/entitlement.js +39 -0
- package/dist/grid-arrow-step.d.ts +7 -0
- package/dist/grid-arrow-step.js +20 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +11 -12
- package/dist/manifest-entry.d.ts +4 -0
- package/dist/manifest-entry.js +4 -0
- package/dist/manifest-schema.d.ts +5 -1
- package/dist/manifest-schema.js +14 -2
- package/dist/manifest.d.ts +21 -1
- package/dist/media/media-picker.js +34 -34
- package/dist/notify.d.ts +17 -0
- package/dist/notify.js +17 -0
- package/dist/plugin-context.js +3 -3
- package/dist/register-built-ins.js +6 -6
- package/dist/registry.js +1 -1
- package/dist/richtext/block-panel.js +19 -20
- package/dist/richtext/extensions.js +17 -8
- package/dist/richtext/insert-menu.js +4 -4
- package/dist/richtext/kardalum-block.js +17 -17
- package/dist/richtext/style-listbox.js +2 -2
- package/dist/richtext/text-style-class.js +1 -1
- package/dist/richtext-html-entry.d.ts +35 -0
- package/dist/richtext-html-entry.js +73 -0
- package/dist/simple-storage-value-provider.js +3 -3
- package/dist/structured-storage-types.d.ts +12 -1
- package/dist/structured-storage-types.js +2 -2
- package/dist/tailwind.js +10 -3
- package/dist/tokens/tailwind-theme.css +176 -0
- package/dist/tokens/tokens.css +1 -0
- package/dist/tokens/tokens.json +2 -1
- package/dist/ui-entry.js +3 -3
- package/dist/vendor-check.d.ts +39 -0
- package/dist/vendor-check.js +79 -0
- package/dist/vendor-entry.d.ts +3 -0
- package/dist/vendor-entry.js +9 -0
- package/dist/vendor-service.d.ts +20 -0
- package/dist/vendor-service.js +20 -0
- package/dist/views/asset-view.d.ts +6 -0
- package/dist/views/asset-view.js +55 -0
- package/dist/views/content-list-settings-view.js +1 -1
- package/dist/views/content-list-view.js +1 -1
- package/dist/views/date-range-view.js +5 -5
- package/dist/views/html-code-editor.js +2 -3
- package/dist/views/html-view.js +7 -7
- package/dist/views/image-view.js +5 -5
- package/dist/views/rich-text-view.js +33 -32
- package/node_modules/@kardalum/api-schemas/README.md +1 -1
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +17 -15
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +30 -9
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +12 -6
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +26 -6
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +6 -3
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +56 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +8 -8
- package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +48 -19
- package/node_modules/@kardalum/api-schemas/dist/index.js +34 -12
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.js +52 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +162 -1
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +144 -9
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +15 -9
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +5 -5
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +7 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +251 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +196 -31
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +10 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -20
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +207 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -8
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +27 -12
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +6 -1
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
- package/node_modules/@kardalum/design-tokens/README.md +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +2 -2
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -5
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
- package/node_modules/@kardalum/design-tokens/package.json +6 -3
- package/node_modules/@kardalum/plugin-package/README.md +1 -1
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -1
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +3 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +10 -10
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/hash.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +5 -5
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
- package/node_modules/@kardalum/ui/README.md +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +8 -3
- package/node_modules/@kardalum/ui/dist/components/badge.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +52 -4
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +20 -7
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +4 -4
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -1
- package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/sheet.js +15 -9
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/toast.js +4 -3
- package/node_modules/@kardalum/ui/dist/components/tooltip.d.ts +27 -0
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +82 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +94 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +2 -2
- package/node_modules/@kardalum/ui/dist/index.d.ts +4 -1
- package/node_modules/@kardalum/ui/dist/index.js +4 -1
- package/node_modules/@kardalum/ui/dist/lib/menu-host.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/lib/menu-host.js +17 -0
- package/node_modules/@kardalum/ui/package.json +8 -6
- 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
|
+
}
|
|
@@ -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
|
|
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
|
-
|
|
18
|
-
|
|
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
|
|
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-
|
|
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
|
|
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-
|
|
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
|
|
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
|
-
|
|
31
|
-
|
|
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-
|
|
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
|
|
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
|
|
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
|
|
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-
|
|
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
|
-
|
|
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-
|
|
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)
|
|
3
|
+
/** Icon element (e.g. a lucide icon), sized/colored by the caller. */
|
|
4
4
|
icon?: React.ReactNode;
|
|
5
|
-
/** Translated title
|
|
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
|
|
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
|
|
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(
|
|
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,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
|
|
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()} />`
|
|
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
|
-
|
|
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
|
|
8
|
-
//
|
|
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
|
|
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
|
|
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
|
|
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-
|
|
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
|
|
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-
|
|
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
|
|
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")
|
|
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
|
|
26
|
+
* aria-labelledby wiring stays consistent: pair with tabStripTabId /
|
|
27
27
|
* tabStripPanelId on the consumer's panel element.
|
|
28
28
|
*/
|
|
29
29
|
idPrefix: string;
|