@cellarnode/ui 0.187.0 → 0.189.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/dist/brand/brand-assets-api.d.ts +65 -0
- package/dist/brand/brand-assets-api.d.ts.map +1 -0
- package/dist/brand/brand-assets-api.js +172 -0
- package/dist/brand/brand-assets-api.js.map +1 -0
- package/dist/brand/brand-assets-section-copy.d.ts +63 -0
- package/dist/brand/brand-assets-section-copy.d.ts.map +1 -0
- package/dist/brand/brand-assets-section-copy.js +56 -0
- package/dist/brand/brand-assets-section-copy.js.map +1 -0
- package/dist/brand/brand-assets-section.d.ts +62 -0
- package/dist/brand/brand-assets-section.d.ts.map +1 -0
- package/dist/brand/brand-assets-section.js +172 -0
- package/dist/brand/brand-assets-section.js.map +1 -0
- package/dist/brand/brand-font-family.d.ts +37 -0
- package/dist/brand/brand-font-family.d.ts.map +1 -0
- package/dist/brand/brand-font-family.js +83 -0
- package/dist/brand/brand-font-family.js.map +1 -0
- package/dist/brand/brand-font-upload.d.ts +17 -0
- package/dist/brand/brand-font-upload.d.ts.map +1 -0
- package/dist/brand/brand-font-upload.js +42 -0
- package/dist/brand/brand-font-upload.js.map +1 -0
- package/dist/brand/brand-generation-client.d.ts +8 -0
- package/dist/brand/brand-generation-client.d.ts.map +1 -1
- package/dist/brand/brand-generation-client.js +1 -1
- package/dist/brand/brand-generation-client.js.map +1 -1
- package/dist/brand/brand-generation-start.d.ts +49 -0
- package/dist/brand/brand-generation-start.d.ts.map +1 -0
- package/dist/brand/brand-generation-start.js +48 -0
- package/dist/brand/brand-generation-start.js.map +1 -0
- package/dist/brand/brand-image-chooser.d.ts +3 -1
- package/dist/brand/brand-image-chooser.d.ts.map +1 -1
- package/dist/brand/brand-image-chooser.js +7 -1
- package/dist/brand/brand-image-chooser.js.map +1 -1
- package/dist/brand/brand-image-choosers.d.ts +37 -0
- package/dist/brand/brand-image-choosers.d.ts.map +1 -0
- package/dist/brand/brand-image-choosers.js +76 -0
- package/dist/brand/brand-image-choosers.js.map +1 -0
- package/dist/brand/brand-workspace-change-notice.d.ts +20 -0
- package/dist/brand/brand-workspace-change-notice.d.ts.map +1 -0
- package/dist/brand/brand-workspace-change-notice.js +19 -0
- package/dist/brand/brand-workspace-change-notice.js.map +1 -0
- package/dist/brand/index.d.ts +23 -0
- package/dist/brand/index.d.ts.map +1 -1
- package/dist/brand/index.js +21 -0
- package/dist/brand/index.js.map +1 -1
- package/dist/brand/scan-page-banner.d.ts +21 -0
- package/dist/brand/scan-page-banner.d.ts.map +1 -0
- package/dist/brand/scan-page-banner.js +48 -0
- package/dist/brand/scan-page-banner.js.map +1 -0
- package/dist/brand/use-brand-image-operation-result.d.ts +43 -0
- package/dist/brand/use-brand-image-operation-result.d.ts.map +1 -0
- package/dist/brand/use-brand-image-operation-result.js +162 -0
- package/dist/brand/use-brand-image-operation-result.js.map +1 -0
- package/dist/brand/use-brand-profile-acceptance.d.ts +38 -0
- package/dist/brand/use-brand-profile-acceptance.d.ts.map +1 -0
- package/dist/brand/use-brand-profile-acceptance.js +84 -0
- package/dist/brand/use-brand-profile-acceptance.js.map +1 -0
- package/dist/brand/use-brand-public-visibility.d.ts +59 -0
- package/dist/brand/use-brand-public-visibility.d.ts.map +1 -0
- package/dist/brand/use-brand-public-visibility.js +69 -0
- package/dist/brand/use-brand-public-visibility.js.map +1 -0
- package/dist/brand/use-brand-workspace-concurrency.d.ts +131 -0
- package/dist/brand/use-brand-workspace-concurrency.d.ts.map +1 -0
- package/dist/brand/use-brand-workspace-concurrency.js +251 -0
- package/dist/brand/use-brand-workspace-concurrency.js.map +1 -0
- package/dist/brand/use-brand-workspace-image-candidates.d.ts +19 -0
- package/dist/brand/use-brand-workspace-image-candidates.d.ts.map +1 -0
- package/dist/brand/use-brand-workspace-image-candidates.js +39 -0
- package/dist/brand/use-brand-workspace-image-candidates.js.map +1 -0
- package/dist/moderation/focus-upload-control.d.ts +15 -0
- package/dist/moderation/focus-upload-control.d.ts.map +1 -0
- package/dist/moderation/focus-upload-control.js +21 -0
- package/dist/moderation/focus-upload-control.js.map +1 -0
- package/dist/moderation/index.d.ts +1 -0
- package/dist/moderation/index.d.ts.map +1 -1
- package/dist/moderation/index.js +1 -0
- package/dist/moderation/index.js.map +1 -1
- package/dist/moderation/moderation-event.d.ts +2 -0
- package/dist/moderation/moderation-event.d.ts.map +1 -1
- package/dist/moderation/moderation-event.js +7 -0
- package/dist/moderation/moderation-event.js.map +1 -1
- package/dist/moderation/moderation-scope.d.ts +31 -0
- package/dist/moderation/moderation-scope.d.ts.map +1 -0
- package/dist/moderation/moderation-scope.js +109 -0
- package/dist/moderation/moderation-scope.js.map +1 -0
- package/dist/moderation/moderation-store.d.ts.map +1 -1
- package/dist/moderation/moderation-store.js +4 -2
- package/dist/moderation/moderation-store.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { BrandImageChooser } from "./brand-image-chooser.js";
|
|
4
|
+
import { candidateAssetSlot } from "./use-brand-workspace-image-candidates.js";
|
|
5
|
+
import { useBrandImageOperationResult, } from "./use-brand-image-operation-result.js";
|
|
6
|
+
export const DEFAULT_BRAND_IMAGE_CHOOSERS_COPY = {
|
|
7
|
+
avatarLabel: "Profile picture",
|
|
8
|
+
bannerLabel: "Banner",
|
|
9
|
+
uploadRequiresProfile: "Save your brand profile once before adding images.",
|
|
10
|
+
uploadFailed: "Upload failed. Please try again.",
|
|
11
|
+
logoUploaded: "Logo uploaded",
|
|
12
|
+
bannerUploaded: "Banner updated",
|
|
13
|
+
};
|
|
14
|
+
function targetDefaultSlot(target) {
|
|
15
|
+
return target === "banner" ? "banner" : "primary";
|
|
16
|
+
}
|
|
17
|
+
function sourceFileName(source) {
|
|
18
|
+
const raw = source.kind === "upload"
|
|
19
|
+
? source.file.name.replace(/\.[^./\\]+$/, "")
|
|
20
|
+
: source.candidate.sourceLabel || source.candidate.role;
|
|
21
|
+
const slug = raw
|
|
22
|
+
.trim()
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
25
|
+
.replace(/^-+|-+$/g, "");
|
|
26
|
+
return slug || "brand-image";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* CEL-2127 — the logo + banner choosers of the brand workspace. Mount with a
|
|
30
|
+
* `key` of the profile id so a profile switch (org switch, or the target
|
|
31
|
+
* flipping between approved profile and generated draft) remounts it and no
|
|
32
|
+
* stale "checking"/"saved" moderation state leaks across profiles.
|
|
33
|
+
*
|
|
34
|
+
* It owns persistence (the upload call) and correlating the moderation verdict
|
|
35
|
+
* back to the chooser. It must sit inside a `ModerationVerdictProvider`.
|
|
36
|
+
*/
|
|
37
|
+
export function BrandImageChoosers({ brandProfileId, avatarCandidateSet, bannerCandidateSet, allowedImageOrigins, assetsApi, notify, copy, }) {
|
|
38
|
+
const text = { ...DEFAULT_BRAND_IMAGE_CHOOSERS_COPY, ...copy };
|
|
39
|
+
const avatarLabelId = useId();
|
|
40
|
+
const bannerLabelId = useId();
|
|
41
|
+
const avatarOperation = useBrandImageOperationResult(assetsApi.fetchModeration);
|
|
42
|
+
const bannerOperation = useBrandImageOperationResult(assetsApi.fetchModeration);
|
|
43
|
+
const applyImage = async (target, operation, result) => {
|
|
44
|
+
// No profile exists yet in the manual-create flow. Fail fast: no network
|
|
45
|
+
// call and no operationId the chooser could never resolve (a chooser stuck
|
|
46
|
+
// "saved"/"checking" forever), plus a clear reason for the user.
|
|
47
|
+
if (!brandProfileId) {
|
|
48
|
+
notify?.({ tone: "error", message: text.uploadRequiresProfile });
|
|
49
|
+
throw new Error("Cannot upload a brand image before a brand profile exists");
|
|
50
|
+
}
|
|
51
|
+
const slot = result.source.kind === "candidate"
|
|
52
|
+
? candidateAssetSlot(result.source.candidate)
|
|
53
|
+
: targetDefaultSlot(target);
|
|
54
|
+
const file = new File([result.blob], `${sourceFileName(result.source)}.webp`, {
|
|
55
|
+
type: result.blob.type || "image/webp",
|
|
56
|
+
});
|
|
57
|
+
// Snapshot before the request goes out, so an inline verdict published
|
|
58
|
+
// while it is in flight is honoured instead of gated out as pre-existing.
|
|
59
|
+
const startSeq = operation.beginOperation();
|
|
60
|
+
try {
|
|
61
|
+
const asset = await assetsApi.upload({ profileId: brandProfileId, slot, file });
|
|
62
|
+
operation.startOperation(asset.id, { brandProfileId, slot }, startSeq);
|
|
63
|
+
notify?.({
|
|
64
|
+
tone: "success",
|
|
65
|
+
message: slot === "banner" ? text.bannerUploaded : text.logoUploaded,
|
|
66
|
+
});
|
|
67
|
+
return { operationId: asset.id };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
notify?.({ tone: "error", message: text.uploadFailed });
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return (_jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [_jsxs("section", { "aria-labelledby": avatarLabelId, children: [_jsx("p", { id: avatarLabelId, className: "mb-2 text-sm font-medium text-foreground", children: text.avatarLabel }), _jsx(BrandImageChooser, { target: "profilePicture", candidates: avatarCandidateSet.available, unavailableCandidates: avatarCandidateSet.unavailable, allowedImageOrigins: allowedImageOrigins, copy: text.chooser, cropAspect: 1, cropCircularMask: true, cropOutput: { type: "image/webp", quality: 0.9, maxDimension: 2048 }, onApply: (result) => applyImage("profilePicture", avatarOperation, result), operationResult: avatarOperation.operationResult, onRetry: avatarOperation.reset, onDismiss: avatarOperation.reset })] }), _jsxs("section", { "aria-labelledby": bannerLabelId, children: [_jsx("p", { id: bannerLabelId, className: "mb-2 text-sm font-medium text-foreground", children: text.bannerLabel }), _jsx(BrandImageChooser, { target: "banner", candidates: bannerCandidateSet.available, unavailableCandidates: bannerCandidateSet.unavailable, allowedImageOrigins: allowedImageOrigins, copy: text.chooser, cropAspect: 3, cropOutput: { type: "image/webp", quality: 0.9, maxDimension: 2048 }, onApply: (result) => applyImage("banner", bannerOperation, result), operationResult: bannerOperation.operationResult, onRetry: bannerOperation.reset, onDismiss: bannerOperation.reset })] })] }));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=brand-image-choosers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-image-choosers.js","sourceRoot":"","sources":["../../src/brand/brand-image-choosers.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAQ1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EACL,4BAA4B,GAE7B,MAAM,oCAAoC,CAAC;AAiB5C,MAAM,CAAC,MAAM,iCAAiC,GAA2B;IACvE,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,QAAQ;IACrB,qBAAqB,EAAE,oDAAoD;IAC3E,YAAY,EAAE,kCAAkC;IAChD,YAAY,EAAE,eAAe;IAC7B,cAAc,EAAE,gBAAgB;CACjC,CAAC;AAcF,SAAS,iBAAiB,CAAC,MAAwB;IACjD,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC;AAED,SAAS,cAAc,CAAC,MAA+B;IACrD,MAAM,GAAG,GACP,MAAM,CAAC,IAAI,KAAK,QAAQ;QACtB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;QAC7C,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;IAC5D,MAAM,IAAI,GAAG,GAAG;SACb,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SA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AAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EACpE,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,eAAe,EAAE,MAAM,CAAC,EAC1E,eAAe,EAAE,eAAe,CAAC,eAAe,EAChD,OAAO,EAAE,eAAe,CAAC,KAAK,EAC9B,SAAS,EAAE,eAAe,CAAC,KAAK,GAChC,IACM,EACV,sCAA0B,aAAa,aACrC,YAAG,EAAE,EAAE,aAAa,EAAE,SAAS,EAAC,0CAA0C,YACvE,IAAI,CAAC,WAAW,GACf,EACJ,KAAC,iBAAiB,IAChB,MAAM,EAAC,QAAQ,EACf,UAAU,EAAE,kBAAkB,CAAC,SAAS,EACxC,qBAAqB,EAAE,kBAAkB,CAAC,WAAW,EACrD,mBAAmB,EAAE,mBAAmB,EACxC,IAAI,EAAE,IAAI,CAAC,OAAO,EAClB,UAAU,EAAE,CAAC,EACb,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EACpE,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,CAAC,EAClE,eAAe,EAAE,eAAe,CAAC,eAAe,EAChD,OAAO,EAAE,eAAe,CAAC,KAAK,EAC9B,SAAS,EAAE,eAAe,CAAC,KAAK,GAChC,IACM,IACN,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface BrandWorkspaceChangeNoticeCopy {
|
|
2
|
+
readonly message: string;
|
|
3
|
+
readonly reloadAction: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY: BrandWorkspaceChangeNoticeCopy;
|
|
6
|
+
export interface BrandWorkspaceChangeNoticeProps {
|
|
7
|
+
/** `serverChanged` from `useBrandWorkspaceConcurrency`. Renders nothing when false. */
|
|
8
|
+
readonly visible: boolean;
|
|
9
|
+
readonly onReload: () => void;
|
|
10
|
+
/** Disables the action while a write or a reload is in flight. */
|
|
11
|
+
readonly disabled?: boolean;
|
|
12
|
+
readonly copy?: Partial<BrandWorkspaceChangeNoticeCopy>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* CEL-2127 — shown above an open brand workspace when the server's profile
|
|
16
|
+
* moved underneath it. Saving is blocked until the user reloads, so the form
|
|
17
|
+
* never silently overwrites a newer version.
|
|
18
|
+
*/
|
|
19
|
+
export declare function BrandWorkspaceChangeNotice({ visible, onReload, disabled, copy, }: BrandWorkspaceChangeNoticeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
+
//# sourceMappingURL=brand-workspace-change-notice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-workspace-change-notice.d.ts","sourceRoot":"","sources":["../../src/brand/brand-workspace-change-notice.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,0CAA0C,EAAE,8BAGxD,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,uFAAuF;IACvF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;CACzD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,OAAO,EACP,QAAQ,EACR,QAAgB,EAChB,IAAI,GACL,EAAE,+BAA+B,kDAiBjC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TriangleAlertIcon } from "lucide-react";
|
|
3
|
+
import { Button } from "../components/button.js";
|
|
4
|
+
export const DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY = {
|
|
5
|
+
message: "Brand profile changed elsewhere. Review latest values before saving.",
|
|
6
|
+
reloadAction: "Reload latest",
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* CEL-2127 — shown above an open brand workspace when the server's profile
|
|
10
|
+
* moved underneath it. Saving is blocked until the user reloads, so the form
|
|
11
|
+
* never silently overwrites a newer version.
|
|
12
|
+
*/
|
|
13
|
+
export function BrandWorkspaceChangeNotice({ visible, onReload, disabled = false, copy, }) {
|
|
14
|
+
if (!visible)
|
|
15
|
+
return null;
|
|
16
|
+
const resolved = { ...DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY, ...copy };
|
|
17
|
+
return (_jsxs("div", { role: "status", className: "flex flex-wrap items-center justify-between gap-3 rounded-lg border border-[var(--tone-warning-fg)]/30 bg-[var(--tone-warning-soft)] px-3 py-2 text-sm/6 text-[var(--tone-warning-fg)]", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [_jsx(TriangleAlertIcon, { "aria-hidden": "true", className: "size-5 shrink-0" }), resolved.message] }), _jsx(Button, { outline: true, onClick: onReload, disabled: disabled, children: resolved.reloadAction })] }));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=brand-workspace-change-notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-workspace-change-notice.js","sourceRoot":"","sources":["../../src/brand/brand-workspace-change-notice.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAO9C,MAAM,CAAC,MAAM,0CAA0C,GAAmC;IACxF,OAAO,EAAE,sEAAsE;IAC/E,YAAY,EAAE,eAAe;CAC9B,CAAC;AAWF;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,EACzC,OAAO,EACP,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,IAAI,GAC4B;IAChC,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,QAAQ,GAAG,EAAE,GAAG,0CAA0C,EAAE,GAAG,IAAI,EAAE,CAAC;IAC5E,OAAO,CACL,eACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,wLAAwL,aAElM,gBAAM,SAAS,EAAC,iCAAiC,aAC/C,KAAC,iBAAiB,mBAAa,MAAM,EAAC,SAAS,EAAC,iBAAiB,GAAG,EACnE,QAAQ,CAAC,OAAO,IACZ,EACP,KAAC,MAAM,IAAC,OAAO,QAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,YAClD,QAAQ,CAAC,YAAY,GACf,IACL,CACP,CAAC;AACJ,CAAC"}
|
package/dist/brand/index.d.ts
CHANGED
|
@@ -57,4 +57,27 @@ export type { BrandImageOperationResult, BrandImageOperationStatus, } from "./br
|
|
|
57
57
|
export { BRAND_PALETTE_MAX_COLORS } from "./brand-visual-form-values.js";
|
|
58
58
|
export type { BrandManualTypographyPatch, BrandTypographyFormValues, } from "./brand-visual-form-values.js";
|
|
59
59
|
export type { BrandVisualFormCopy } from "./brand-profile-form-visual.js";
|
|
60
|
+
export { classifyBrandProfileApiError, useBrandWorkspaceConcurrency, } from "./use-brand-workspace-concurrency.js";
|
|
61
|
+
export type { BrandWorkspaceEvent, BrandWorkspaceSaveFailure, BrandWorkspaceSnapshot, BrandWorkspaceTarget, BrandWorkspaceWriteBody, UseBrandWorkspaceConcurrencyOptions, UseBrandWorkspaceConcurrencyResult, } from "./use-brand-workspace-concurrency.js";
|
|
62
|
+
export { BrandWorkspaceChangeNotice, DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY, } from "./brand-workspace-change-notice.js";
|
|
63
|
+
export type { BrandWorkspaceChangeNoticeCopy, BrandWorkspaceChangeNoticeProps, } from "./brand-workspace-change-notice.js";
|
|
64
|
+
export { useBrandPublicVisibility } from "./use-brand-public-visibility.js";
|
|
65
|
+
export type { BrandPublicVisibilityApi, BrandPublicVisibilityEvent, BrandPublicVisibilityWrite, BrandVisibilityProfile, UseBrandPublicVisibilityOptions, } from "./use-brand-public-visibility.js";
|
|
66
|
+
export { BrandAssetsRequestError, createBrandAssetsClient, resolveBrandAssetMimeType, } from "./brand-assets-api.js";
|
|
67
|
+
export type { BrandAssetModeration, BrandAssetRecord, BrandAssetsApi, BrandAssetsClientOptions, UploadBrandAssetArgs, } from "./brand-assets-api.js";
|
|
68
|
+
export { candidateAssetSlot, useBrandWorkspaceImageCandidates, } from "./use-brand-workspace-image-candidates.js";
|
|
69
|
+
export { useBrandImageOperationResult } from "./use-brand-image-operation-result.js";
|
|
70
|
+
export type { BrandImageOperationController } from "./use-brand-image-operation-result.js";
|
|
71
|
+
export { BrandImageChoosers, DEFAULT_BRAND_IMAGE_CHOOSERS_COPY } from "./brand-image-choosers.js";
|
|
72
|
+
export type { BrandImageChoosersCopy, BrandImageChoosersProps } from "./brand-image-choosers.js";
|
|
73
|
+
export { BrandGenerationStart, DEFAULT_BRAND_GENERATION_START_COPY, } from "./brand-generation-start.js";
|
|
74
|
+
export type { BrandGenerationStartCopy, BrandGenerationStartProps } from "./brand-generation-start.js";
|
|
75
|
+
export { DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY, useBrandProfileAcceptance, } from "./use-brand-profile-acceptance.js";
|
|
76
|
+
export type { BrandProfileAcceptanceCopy, BrandWorkspaceNotice, UseBrandProfileAcceptanceOptions, } from "./use-brand-profile-acceptance.js";
|
|
77
|
+
export { readBrandAssetModeration } from "./brand-assets-api.js";
|
|
78
|
+
export * from "./brand-assets-section.js";
|
|
79
|
+
export * from "./brand-assets-section-copy.js";
|
|
80
|
+
export { BrandFontUpload, type BrandFontUploadProps } from "./brand-font-upload.js";
|
|
81
|
+
export { ScanPageBanner, type ScanPageBannerProps } from "./scan-page-banner.js";
|
|
82
|
+
export { isUsableBrandFontFamily, resolveBrandFontFamily, type BrandVisualFontSources, } from "./brand-font-family.js";
|
|
60
83
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/brand/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAK9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,YAAY,EACV,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,kCAAkC,EAClC,0BAA0B,EAC1B,uBAAuB,EACvB,8BAA8B,EAC9B,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,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9E,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC"}
|
package/dist/brand/index.js
CHANGED
|
@@ -48,4 +48,25 @@ export { defaultBrandGenerationCopy, resolveBrandGenerationCopy } from "./brand-
|
|
|
48
48
|
export { BrandImageChooser } from "./brand-image-chooser.js";
|
|
49
49
|
export { isBrandImageOperationFailed, isBrandImageOperationIndeterminate, isBrandImageOperationSettled, } from "./brand-image-chooser-types.js";
|
|
50
50
|
export { BRAND_PALETTE_MAX_COLORS } from "./brand-visual-form-values.js";
|
|
51
|
+
// CEL-2127 lift 2: the rest of producer's brand workspace. Concurrency (409
|
|
52
|
+
// reload / keep-mine, TARGET_MISMATCH, server-changed detection), the public
|
|
53
|
+
// visibility toggle handler, the logo/banner choosers with their assets API,
|
|
54
|
+
// the idle start form and generated-profile acceptance. The data layer is
|
|
55
|
+
// injected and every string is a prop with an English default.
|
|
56
|
+
export { classifyBrandProfileApiError, useBrandWorkspaceConcurrency, } from "./use-brand-workspace-concurrency.js";
|
|
57
|
+
export { BrandWorkspaceChangeNotice, DEFAULT_BRAND_WORKSPACE_CHANGE_NOTICE_COPY, } from "./brand-workspace-change-notice.js";
|
|
58
|
+
export { useBrandPublicVisibility } from "./use-brand-public-visibility.js";
|
|
59
|
+
export { BrandAssetsRequestError, createBrandAssetsClient, resolveBrandAssetMimeType, } from "./brand-assets-api.js";
|
|
60
|
+
export { candidateAssetSlot, useBrandWorkspaceImageCandidates, } from "./use-brand-workspace-image-candidates.js";
|
|
61
|
+
export { useBrandImageOperationResult } from "./use-brand-image-operation-result.js";
|
|
62
|
+
export { BrandImageChoosers, DEFAULT_BRAND_IMAGE_CHOOSERS_COPY } from "./brand-image-choosers.js";
|
|
63
|
+
export { BrandGenerationStart, DEFAULT_BRAND_GENERATION_START_COPY, } from "./brand-generation-start.js";
|
|
64
|
+
export { DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY, useBrandProfileAcceptance, } from "./use-brand-profile-acceptance.js";
|
|
65
|
+
// CEL-2127: shared brand assets section (logos, banner, font, moderation notices).
|
|
66
|
+
export { readBrandAssetModeration } from "./brand-assets-api.js";
|
|
67
|
+
export * from "./brand-assets-section.js";
|
|
68
|
+
export * from "./brand-assets-section-copy.js";
|
|
69
|
+
export { BrandFontUpload } from "./brand-font-upload.js";
|
|
70
|
+
export { ScanPageBanner } from "./scan-page-banner.js";
|
|
71
|
+
export { isUsableBrandFontFamily, resolveBrandFontFamily, } from "./brand-font-family.js";
|
|
51
72
|
//# sourceMappingURL=index.js.map
|
package/dist/brand/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/brand/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,qCAAqC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAM5D,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,wEAAwE;AACxE,0EAA0E;AAC1E,gBAAgB;AAChB,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAanF,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAA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ElC,OAAO,EACL,qCAAqC,EACrC,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AAOxC,mFAAmF;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,eAAe,EAA6B,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,cAAc,EAA4B,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GAEvB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ScanPageBannerCopy } from "./brand-assets-section-copy.js";
|
|
2
|
+
import type { BrandAsset } from "./types.js";
|
|
3
|
+
export interface ScanPageBannerProps {
|
|
4
|
+
/** The uploaded banner-slot asset, when it has replaced the scrape. */
|
|
5
|
+
asset: BrandAsset | null;
|
|
6
|
+
/** `visual.bannerImage` value: the web scrape's banner, already re-hosted. */
|
|
7
|
+
scrapedUrl: string | null;
|
|
8
|
+
onUpload: (file: File) => void;
|
|
9
|
+
onClear: () => void;
|
|
10
|
+
uploading?: boolean;
|
|
11
|
+
clearing?: boolean;
|
|
12
|
+
/** Server-side failure for this slot, surfaced inline. */
|
|
13
|
+
error?: string | null;
|
|
14
|
+
copy?: Partial<ScanPageBannerCopy>;
|
|
15
|
+
/** Extra origins the preview may load from (non-https dev deployments). https image URLs always pass the shared safety check. */
|
|
16
|
+
allowedImageOrigins?: readonly string[];
|
|
17
|
+
/** Hide the Remove action when the host cannot clear this banner. Default true. */
|
|
18
|
+
canClear?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function ScanPageBanner({ asset, scrapedUrl, onUpload, onClear, uploading, clearing, error, copy: copyOverrides, allowedImageOrigins, canClear, }: ScanPageBannerProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=scan-page-banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-page-banner.d.ts","sourceRoot":"","sources":["../../src/brand/scan-page-banner.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAiB1C,MAAM,WAAW,mBAAmB;IAClC,uEAAuE;IACvE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,8EAA8E;IAC9E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACnC,iIAAiI;IACjI,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAiB,EACjB,QAAgB,EAChB,KAAY,EACZ,IAAI,EAAE,aAAa,EACnB,mBAAmB,EACnB,QAAe,GAChB,EAAE,mBAAmB,2CAmHrB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useRef, useState } from "react";
|
|
3
|
+
import { DEFAULT_SCAN_PAGE_BANNER_COPY, } from "./brand-assets-section-copy.js";
|
|
4
|
+
import { BrandSafeImage } from "./brand-safe-image.js";
|
|
5
|
+
/**
|
|
6
|
+
* Org-level banner for the scanned e-label landing (CEL-1234).
|
|
7
|
+
*
|
|
8
|
+
* Not `BrandAssetUploader`, because the banner has two sources (an uploaded
|
|
9
|
+
* asset AND the scraped `visual.bannerImage`, which the scan page falls back
|
|
10
|
+
* to), a clear that empties both, and a full-bleed preview. One banner per
|
|
11
|
+
* brand profile, shown on every scan page of the org.
|
|
12
|
+
*
|
|
13
|
+
* SVG is absent from the accepted types for this slot only (CEL-1283): it can
|
|
14
|
+
* carry arbitrary text, so the backend refuses it for the banner.
|
|
15
|
+
*/
|
|
16
|
+
const ACCEPTED_MIME_TYPES = ["image/png", "image/jpeg", "image/webp"];
|
|
17
|
+
/** Mirrors the backend's `BRAND_ASSET_MAX_BYTES`. */
|
|
18
|
+
const MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
|
19
|
+
export function ScanPageBanner({ asset, scrapedUrl, onUpload, onClear, uploading = false, clearing = false, error = null, copy: copyOverrides, allowedImageOrigins, canClear = true, }) {
|
|
20
|
+
const copy = { ...DEFAULT_SCAN_PAGE_BANNER_COPY, ...copyOverrides };
|
|
21
|
+
const inputRef = useRef(null);
|
|
22
|
+
const errorId = useId();
|
|
23
|
+
const [validationError, setValidationError] = useState(null);
|
|
24
|
+
const shownError = validationError ?? error;
|
|
25
|
+
const currentUrl = asset?.fileUrl ?? scrapedUrl;
|
|
26
|
+
const isScraped = !asset && scrapedUrl !== null;
|
|
27
|
+
const busy = uploading || clearing;
|
|
28
|
+
const handleFile = (file) => {
|
|
29
|
+
if (file.size > MAX_FILE_SIZE_BYTES) {
|
|
30
|
+
setValidationError(copy.tooLarge(Math.round(MAX_FILE_SIZE_BYTES / (1024 * 1024))));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!ACCEPTED_MIME_TYPES.some((accepted) => accepted === file.type)) {
|
|
34
|
+
setValidationError(copy.unsupported(file.type));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
setValidationError(null);
|
|
38
|
+
onUpload(file);
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs("section", { className: "flex flex-col gap-3", "data-testid": "scan-page-banner", children: [_jsxs("div", { children: [_jsx("h3", { className: "text-sm font-semibold text-foreground", children: copy.title }), _jsx("p", { className: "max-w-prose text-sm text-muted-foreground", children: copy.subtitle })] }), _jsxs("div", { className: "rounded-xl border border-border/60 bg-card p-4", children: [currentUrl ? (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx(BrandSafeImage, { src: currentUrl, alt: copy.previewAlt, allowedOrigins: allowedImageOrigins, className: "h-28 w-full rounded-lg border border-border/60 object-cover", fallback: _jsx("span", { role: "status", className: "flex h-28 w-full items-center justify-center rounded-lg border border-border/60 text-xs text-muted-foreground", children: copy.previewUnavailable }) }), _jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: isScraped ? copy.fromWebsite : (asset?.fileName ?? "") }), _jsx("button", { type: "button", onClick: () => inputRef.current?.click(), disabled: busy, className: "shrink-0 rounded-lg px-2 py-1 text-xs font-medium text-primary hover:underline disabled:cursor-not-allowed disabled:opacity-50", children: uploading ? copy.uploading : copy.replace }), canClear ? (_jsx("button", { type: "button", onClick: onClear, disabled: busy, className: "shrink-0 rounded-lg px-2 py-1 text-xs font-medium text-[var(--tone-danger-fg)] hover:underline disabled:cursor-not-allowed disabled:opacity-50", children: clearing ? copy.removing : copy.remove })) : null] })] })) : (_jsxs("button", { type: "button", onClick: () => inputRef.current?.click(), "aria-describedby": shownError ? errorId : undefined, "aria-invalid": shownError ? true : undefined, disabled: busy, className: "flex w-full cursor-pointer items-center justify-center rounded-lg border border-dashed border-border/60 px-3 py-6 text-xs text-muted-foreground hover:border-primary hover:text-primary disabled:cursor-not-allowed disabled:opacity-50", children: [_jsx("span", { className: "sr-only", children: copy.inputLabel }), _jsx("span", { "aria-hidden": "true", children: uploading ? copy.uploading : copy.upload })] })), shownError ? (_jsx("p", { role: "alert", id: errorId, className: "mt-2 text-xs font-medium text-[var(--tone-danger-fg)]", children: shownError })) : null, _jsx("input", { ref: inputRef, type: "file", accept: ACCEPTED_MIME_TYPES.join(","), tabIndex: -1, className: "sr-only", "aria-label": copy.inputLabel, disabled: busy, onChange: (event) => {
|
|
41
|
+
const file = event.target.files?.[0];
|
|
42
|
+
if (file)
|
|
43
|
+
handleFile(file);
|
|
44
|
+
// Reset so re-picking the same file still fires `change`.
|
|
45
|
+
event.target.value = "";
|
|
46
|
+
} })] })] }));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=scan-page-banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-page-banner.js","sourceRoot":"","sources":["../../src/brand/scan-page-banner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EACL,6BAA6B,GAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;;;;;;;;GAUG;AACH,MAAM,mBAAmB,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAU,CAAC;AAC/E,qDAAqD;AACrD,MAAM,mBAAmB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAoB5C,MAAM,UAAU,cAAc,CAAC,EAC7B,KAAK,EACL,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,IAAI,EACZ,IAAI,EAAE,aAAa,EACnB,mBAAmB,EACnB,QAAQ,GAAG,IAAI,GACK;IACpB,MAAM,IAAI,GAAG,EAAE,GAAG,6BAA6B,EAAE,GAAG,aAAa,EAAE,CAAC;IACpE,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IACxB,MAAM,CAAC,eAA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,8BAAkB,MAAM,YAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAQ,IACnE,CACV,EAEA,UAAU,CAAC,CAAC,CAAC,CACZ,YACE,IAAI,EAAC,OAAO,EACZ,EAAE,EAAE,OAAO,EACX,SAAS,EAAC,uDAAuD,YAEhE,UAAU,GACT,CACL,CAAC,CAAC,CAAC,IAAI,EAGR,gBACE,GAAG,EAAE,QAAQ,EACb,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EACrC,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAC,SAAS,gBACP,IAAI,CAAC,UAAU,EAC3B,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;4BAClB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;4BACrC,IAAI,IAAI;gCAAE,UAAU,CAAC,IAAI,CAAC,CAAC;4BAC3B,0DAA0D;4BAC1D,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;wBAC1B,CAAC,GACD,IACE,IACE,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ModerationPersistedRead, type ModerationSubjectMatch } from "../moderation/index.js";
|
|
2
|
+
import type { BrandImageOperationResult } from "./brand-image-chooser-types.js";
|
|
3
|
+
export interface BrandImageOperationController {
|
|
4
|
+
/** `null` when no operation has started yet — the chooser's own idle
|
|
5
|
+
* default. */
|
|
6
|
+
readonly operationResult: BrandImageOperationResult | null;
|
|
7
|
+
/**
|
|
8
|
+
* Call once `onApply`'s upload/candidate-select call has been accepted by
|
|
9
|
+
* the backend: a caller-generated id that correlates a later verdict back
|
|
10
|
+
* to THIS call (never a previous operation on the same subject slot), and
|
|
11
|
+
* the subject to watch. The subject is passed HERE rather than fixed at
|
|
12
|
+
* the hook call site because it depends on which slot the upload actually
|
|
13
|
+
* landed in — a candidate's OWN role can route it to a different slot than
|
|
14
|
+
* the chooser instance's own target (e.g. a favicon-role candidate picked
|
|
15
|
+
* through the "profile picture" chooser still saves to the favicon slot;
|
|
16
|
+
* see `candidateAssetSlot` in `useBrandImageCandidates.ts`). Also marks the
|
|
17
|
+
* subject "checking" in the shared moderation store so every OTHER surface
|
|
18
|
+
* watching it (e.g. `BrandAssetsSection`'s `ModerationSurfaceNotice`) sees
|
|
19
|
+
* it too.
|
|
20
|
+
*/
|
|
21
|
+
readonly startOperation: (operationId: string, subject: ModerationSubjectMatch, startSeq?: number) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Call BEFORE issuing the upload request and pass the result to
|
|
24
|
+
* `startOperation`. The backend can publish a verdict for the asset while
|
|
25
|
+
* the upload's HTTP response is still in flight; without this snapshot that
|
|
26
|
+
* event is gated out as "pre-existing" and the operation hangs at
|
|
27
|
+
* `checking` until it gives up.
|
|
28
|
+
*/
|
|
29
|
+
readonly beginOperation: () => number;
|
|
30
|
+
/** Drops tracking — e.g. when the chooser is dismissed/closed. */
|
|
31
|
+
readonly reset: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Owns the chooser's current upload identity and adapts the shared moderation
|
|
35
|
+
* operation (including its exact-asset durable read) to the chooser result.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useBrandImageOperationResult(
|
|
38
|
+
/**
|
|
39
|
+
* The durable, asset-id-keyed read (`BrandAssetsApi.fetchModeration`) used
|
|
40
|
+
* when no live verdict event arrives.
|
|
41
|
+
*/
|
|
42
|
+
fetchModeration: (profileId: string, assetId: string) => Promise<ModerationPersistedRead | null>): BrandImageOperationController;
|
|
43
|
+
//# sourceMappingURL=use-brand-image-operation-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-brand-image-operation-result.d.ts","sourceRoot":"","sources":["../../src/brand/use-brand-image-operation-result.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,6BAA6B,CAAC;AAmCrC,MAAM,WAAW,6BAA6B;IAC5C;kBACc;IACd,QAAQ,CAAC,eAAe,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC3D;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,cAAc,EAAE,CACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,CAAC,EAAE,MAAM,KACd,IAAI,CAAC;IACV;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,MAAM,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B;AAC1C;;;GAGG;AACH,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,GAC/F,6BAA6B,CA0I/B"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { GIVE_UP_AFTER_MS, useModerationCheckControls, useModerationOperation, } from "../moderation/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* CEL-2127 (from producer, CEL-1682/CEL-1681) — maps the CEL-1320 moderation read model's 8-state
|
|
5
|
+
* `ModerationStatus` (checking/passed/rejected/in-review/
|
|
6
|
+
* approved-after-review/changes-requested/unpublished/escalated) onto
|
|
7
|
+
* `BrandImageChooser`'s narrower `BrandImageOperationStatus` contract
|
|
8
|
+
* (saved/checking/passed/rejected/unknown/error). A future backend status
|
|
9
|
+
* this map doesn't know about degrades to "unknown" rather than being
|
|
10
|
+
* dropped, mirroring the shared event parser's forward-compatibility
|
|
11
|
+
* stance.
|
|
12
|
+
*/
|
|
13
|
+
function mapModerationStatus(status) {
|
|
14
|
+
switch (status) {
|
|
15
|
+
case "checking":
|
|
16
|
+
case "in-review":
|
|
17
|
+
return "checking";
|
|
18
|
+
case "passed":
|
|
19
|
+
case "approved-after-review":
|
|
20
|
+
return "passed";
|
|
21
|
+
case "rejected":
|
|
22
|
+
case "changes-requested":
|
|
23
|
+
return "rejected";
|
|
24
|
+
default:
|
|
25
|
+
return "unknown";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A server verdict may be stamped slightly before the client's own clock. Kept
|
|
30
|
+
* small: it is also the window in which a leftover verdict for a previous
|
|
31
|
+
* upload could be mistaken for this one when the event carries no `assetId`.
|
|
32
|
+
*/
|
|
33
|
+
const CLOCK_SKEW_TOLERANCE_MS = 2_000;
|
|
34
|
+
/**
|
|
35
|
+
* Owns the chooser's current upload identity and adapts the shared moderation
|
|
36
|
+
* operation (including its exact-asset durable read) to the chooser result.
|
|
37
|
+
*/
|
|
38
|
+
export function useBrandImageOperationResult(
|
|
39
|
+
/**
|
|
40
|
+
* The durable, asset-id-keyed read (`BrandAssetsApi.fetchModeration`) used
|
|
41
|
+
* when no live verdict event arrives.
|
|
42
|
+
*/
|
|
43
|
+
fetchModeration) {
|
|
44
|
+
const [operation, setOperation] = useState(null);
|
|
45
|
+
const { markChecking, clearChecking, beginOperation: beginStoreOperation, } = useModerationCheckControls();
|
|
46
|
+
const beganAtRef = useRef(null);
|
|
47
|
+
// Read through a ref: an inline `fetchModeration` must not change
|
|
48
|
+
// `fetchPersisted`'s identity every render and restart the durable poll.
|
|
49
|
+
const fetchModerationRef = useRef(fetchModeration);
|
|
50
|
+
fetchModerationRef.current = fetchModeration;
|
|
51
|
+
const fetchPersisted = useMemo(() => {
|
|
52
|
+
const profileId = operation?.subject.brandProfileId;
|
|
53
|
+
return profileId && operation
|
|
54
|
+
? () => fetchModerationRef.current(profileId, operation.id)
|
|
55
|
+
: undefined;
|
|
56
|
+
}, [operation]);
|
|
57
|
+
const subjectState = useModerationOperation({
|
|
58
|
+
match: operation?.subject ?? null,
|
|
59
|
+
identity: operation?.id,
|
|
60
|
+
fetchPersisted,
|
|
61
|
+
});
|
|
62
|
+
const startOperation = useCallback((operationId, subject, startSeq) => {
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
// An inline verdict is published while the upload request is in flight,
|
|
65
|
+
// i.e. BEFORE `now`; anchor staleness at when the request began (minus
|
|
66
|
+
// clock skew), not at when its response came back.
|
|
67
|
+
// Only a begin that this start is paired with (it carries the store's
|
|
68
|
+
// `startSeq`) counts; a begin whose upload failed must not leak into
|
|
69
|
+
// a later, unrelated operation.
|
|
70
|
+
const began = startSeq !== undefined ? (beganAtRef.current ?? now) : now;
|
|
71
|
+
beganAtRef.current = null;
|
|
72
|
+
setOperation({
|
|
73
|
+
id: operationId,
|
|
74
|
+
subject,
|
|
75
|
+
appliedAt: now,
|
|
76
|
+
notBefore: began - CLOCK_SKEW_TOLERANCE_MS,
|
|
77
|
+
});
|
|
78
|
+
markChecking(subject, operationId, startSeq);
|
|
79
|
+
}, [markChecking]);
|
|
80
|
+
const beginOperation = useCallback(() => {
|
|
81
|
+
beganAtRef.current = Date.now();
|
|
82
|
+
return beginStoreOperation();
|
|
83
|
+
}, [beginStoreOperation]);
|
|
84
|
+
const reset = useCallback(() => {
|
|
85
|
+
setOperation((current) => {
|
|
86
|
+
if (current)
|
|
87
|
+
clearChecking(current.subject);
|
|
88
|
+
return null;
|
|
89
|
+
});
|
|
90
|
+
}, [clearChecking]);
|
|
91
|
+
const operationResult = useMemo(() => {
|
|
92
|
+
if (!operation)
|
|
93
|
+
return null;
|
|
94
|
+
// A verdict landed for this subject. Guard against a STALE result from a
|
|
95
|
+
// PREVIOUS operation on the same slot (e.g. re-uploading a rejected
|
|
96
|
+
// banner) — the chooser's own contract: "old verdict cannot complete
|
|
97
|
+
// newer upload." An event older than this operation's start is ignored,
|
|
98
|
+
// falling through to the in-flight branches below. CEL-1682 review
|
|
99
|
+
// fixup (reviewer A, P3): an UNPARSEABLE `occurredAt` must also count as
|
|
100
|
+
// stale — `Number.isFinite(NaN)` is `false`, so the original
|
|
101
|
+
// `finite && older` test let a malformed prior verdict slip through as
|
|
102
|
+
// "not stale" and complete a newer, still-in-flight upload.
|
|
103
|
+
if (subjectState.event) {
|
|
104
|
+
const event = subjectState.event;
|
|
105
|
+
// A verdict that names its asset is matched EXACTLY: it belongs to this
|
|
106
|
+
// operation iff it is this asset's, whatever the clocks say. A verdict
|
|
107
|
+
// that does not (the wire cannot always carry it) is matched on slot
|
|
108
|
+
// alone, so it must also not predate this operation: one older than the
|
|
109
|
+
// upload's start is a leftover from a PREVIOUS upload into the same slot
|
|
110
|
+
// ("old verdict cannot complete newer upload"). An unparseable
|
|
111
|
+
// `occurredAt` counts as stale for the same reason.
|
|
112
|
+
let isStale;
|
|
113
|
+
if (event.subject?.assetId !== undefined) {
|
|
114
|
+
isStale = event.subject.assetId !== operation.id;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const eventTime = Date.parse(event.occurredAt);
|
|
118
|
+
isStale = !Number.isFinite(eventTime) || eventTime < operation.notBefore;
|
|
119
|
+
}
|
|
120
|
+
if (!isStale) {
|
|
121
|
+
const status = mapModerationStatus(subjectState.event.state);
|
|
122
|
+
return {
|
|
123
|
+
status,
|
|
124
|
+
operationId: operation.id,
|
|
125
|
+
reason: status === "rejected"
|
|
126
|
+
? (subjectState.event.detail ?? subjectState.event.headline ?? null)
|
|
127
|
+
: undefined,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (subjectState.status === "checking") {
|
|
132
|
+
return {
|
|
133
|
+
status: subjectState.slow ? "unknown" : "checking",
|
|
134
|
+
operationId: operation.id,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// A durable, asset-id-keyed read may resolve without a live event. The
|
|
138
|
+
// shared operation reconciler gives that answer precedence over a stale
|
|
139
|
+
// same-slot event; the chooser receives only the coarse status here.
|
|
140
|
+
if (subjectState.persistedOnly && subjectState.status) {
|
|
141
|
+
return { status: mapModerationStatus(subjectState.status), operationId: operation.id };
|
|
142
|
+
}
|
|
143
|
+
if (subjectState.status === "unknown" && !subjectState.event) {
|
|
144
|
+
return { status: "unknown", operationId: operation.id };
|
|
145
|
+
}
|
|
146
|
+
// No event yet, no local pending mark. Either `markChecking` hasn't run
|
|
147
|
+
// yet (a same-tick gap right after `startOperation`) or the store gave
|
|
148
|
+
// up waiting after GIVE_UP_AFTER_MS and dropped the mark — the store
|
|
149
|
+
// itself no longer distinguishes those, so use this operation's own
|
|
150
|
+
// `appliedAt` timestamp to tell them apart. This is a `useMemo`, so
|
|
151
|
+
// noticing the GIVE_UP transition depends on getting a fresh render —
|
|
152
|
+
// in practice the shared store's sweep interval delivers one while any
|
|
153
|
+
// check is pending, including the tick that drops the mark. This never polls
|
|
154
|
+
// `Date.now()` on its own between renders.
|
|
155
|
+
if (Date.now() - operation.appliedAt > GIVE_UP_AFTER_MS) {
|
|
156
|
+
return { status: "unknown", operationId: operation.id };
|
|
157
|
+
}
|
|
158
|
+
return { status: "saved", operationId: operation.id };
|
|
159
|
+
}, [operation, subjectState]);
|
|
160
|
+
return { operationResult, startOperation, beginOperation, reset };
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=use-brand-image-operation-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-brand-image-operation-result.js","sourceRoot":"","sources":["../../src/brand/use-brand-image-operation-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,GAGvB,MAAM,eAAe,CAAC;AAMvB;;;;;;;;;GASG;AACH,SAAS,mBAAmB,CAAC,MAAc;IACzC,QAA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AE,SAAS,CAAC,EAAE;aAC1B,CAAC;QACJ,CAAC;QAED,uEAAuE;QACvE,wEAAwE;QACxE,qEAAqE;QACrE,IAAI,YAAY,CAAC,aAAa,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;YACtD,OAAO,EAAE,MAAM,EAAE,mBAAmB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;QACzF,CAAC;QACD,IAAI,YAAY,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAC7D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;QAC1D,CAAC;QAED,wEAAwE;QACxE,uEAAuE;QACvE,qEAAqE;QACrE,oEAAoE;QACpE,oEAAoE;QACpE,sEAAsE;QACtE,uEAAuE;QACvE,6EAA6E;QAC7E,2CAA2C;QAC3C,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,SAAS,GAAG,gBAAgB,EAAE,CAAC;YACxD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;QAC1D,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;IACxD,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IAE9B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { UseBrandGenerationResult } from "./use-brand-generation.js";
|
|
2
|
+
export interface BrandWorkspaceNotice {
|
|
3
|
+
readonly tone: "success" | "error" | "info";
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BrandProfileAcceptanceCopy {
|
|
7
|
+
readonly acceptFailed: string;
|
|
8
|
+
readonly acceptEarlyRequested: string;
|
|
9
|
+
readonly acceptRunIncomplete: string;
|
|
10
|
+
readonly accepted: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const DEFAULT_BRAND_PROFILE_ACCEPTANCE_COPY: BrandProfileAcceptanceCopy;
|
|
13
|
+
export interface UseBrandProfileAcceptanceOptions {
|
|
14
|
+
readonly orgId: string;
|
|
15
|
+
readonly brandGeneration: Pick<UseBrandGenerationResult, "job" | "accept" | "reset">;
|
|
16
|
+
/**
|
|
17
|
+
* Approves the generated draft (the injected data layer). With TanStack
|
|
18
|
+
* Query: `(handlers) => approve.mutate(undefined, handlers)`.
|
|
19
|
+
*/
|
|
20
|
+
readonly approve: (handlers: {
|
|
21
|
+
onSuccess: () => void;
|
|
22
|
+
onError: () => void;
|
|
23
|
+
}) => void;
|
|
24
|
+
readonly notify?: (notice: BrandWorkspaceNotice) => void;
|
|
25
|
+
readonly copy?: Partial<BrandProfileAcceptanceCopy>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* CEL-2127 — "Accept profile" for a generated draft, shared by producer and
|
|
29
|
+
* importer. While the run is still going it asks the backend to wrap up
|
|
30
|
+
* (early accept); once completed it approves the draft and resets the flow.
|
|
31
|
+
* Either path is single-flight per org and never reports into another org's
|
|
32
|
+
* session after an org switch.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useBrandProfileAcceptance({ orgId, brandGeneration, approve, notify, copy, }: UseBrandProfileAcceptanceOptions): {
|
|
35
|
+
accept: () => void;
|
|
36
|
+
signalPending: boolean;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=use-brand-profile-acceptance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-brand-profile-acceptance.d.ts","sourceRoot":"","sources":["../../src/brand/use-brand-profile-acceptance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,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