@cosmicdrift/kumiko-document-designer 0.383.1 → 0.385.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/web/cells.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { formatWhen, useQuery, useTranslation, } from "@cosmicdrift/kumiko-renderer";
|
|
2
|
+
import { formatWhen, useTranslation, } from "@cosmicdrift/kumiko-renderer";
|
|
4
3
|
import { EMPTY_VALUE_PLACEHOLDER, toInstant } from "@cosmicdrift/kumiko-renderer/headless";
|
|
5
4
|
import { StatusBadge } from "@cosmicdrift/kumiko-renderer/web";
|
|
6
5
|
import { parseOverviewRow } from "./overview-row.js";
|
|
@@ -65,22 +64,16 @@ function formatModifiedDate(value) {
|
|
|
65
64
|
export function ModifiedCell({ row }) {
|
|
66
65
|
return withRow(row, (r) => r.modifiedAt === "" ? (EMPTY_VALUE_PLACEHOLDER) : (_jsx("span", { className: "whitespace-nowrap", title: formatWhen(r.modifiedAt), children: formatModifiedDate(r.modifiedAt) })));
|
|
67
66
|
}
|
|
68
|
-
function OverriddenByCount({
|
|
67
|
+
function OverriddenByCount({ overriddenBy, }) {
|
|
69
68
|
const t = useTranslation();
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
kind,
|
|
73
|
-
});
|
|
74
|
-
if (data === null)
|
|
75
|
-
return EMPTY_VALUE_PLACEHOLDER;
|
|
76
|
-
const label = data.totalTenants === null
|
|
77
|
-
? t("documentDesigner.overriddenBy.tenants", { active: data.activeOverrides })
|
|
69
|
+
const label = overriddenBy.total === null
|
|
70
|
+
? t("documentDesigner.overriddenBy.tenants", { active: overriddenBy.active })
|
|
78
71
|
: t("documentDesigner.overriddenBy.ofTotal", {
|
|
79
|
-
active:
|
|
80
|
-
total:
|
|
72
|
+
active: overriddenBy.active,
|
|
73
|
+
total: overriddenBy.total,
|
|
81
74
|
});
|
|
82
75
|
return _jsx("span", { children: label });
|
|
83
76
|
}
|
|
84
77
|
export function OverriddenByCell({ row }) {
|
|
85
|
-
return withRow(row, (r) => r.origin === "system" ? (_jsx(OverriddenByCount, {
|
|
78
|
+
return withRow(row, (r) => r.origin === "system" && r.overriddenBy !== null ? (_jsx(OverriddenByCount, { overriddenBy: r.overriddenBy })) : (EMPTY_VALUE_PLACEHOLDER));
|
|
86
79
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type ClientFeatureDefinition } from "@cosmicdrift/kumiko-renderer/web";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
3
|
/**
|
|
4
4
|
* Custom screen body: the template comes from the URL (`?slug=...&locale=...`),
|
|
5
5
|
* because custom screens receive no props.
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { textBlocksClient } from "@cosmicdrift/kumiko-bundled-features/template-resolver/web";
|
|
3
3
|
import { mergeTranslations, translationsByLocaleFromKeys, useNav, } from "@cosmicdrift/kumiko-renderer";
|
|
4
|
+
import { LoadingState } from "@cosmicdrift/kumiko-renderer/web";
|
|
5
|
+
import { lazy, Suspense } from "react";
|
|
4
6
|
import { createLocalesCell, KindCell, ModifiedCell, OriginCell, OverriddenByCell, StatusCell, TitleCell, UsedByCell, } from "./cells.js";
|
|
5
7
|
import { DEFAULT_TEMPLATE_LOCALES, DOCUMENT_DESIGNER_FEATURE, DocumentDesignerCells, LAYOUT_EDITOR_SCREEN_ID, MAIL_EDITOR_SCREEN_ID, PDF_TEMPLATE_EDITOR_SCREEN_ID, } from "./constants.js";
|
|
6
8
|
import { documentDesignerTranslations } from "./default-translations.js";
|
|
7
9
|
import { DOCUMENT_DESIGNER_I18N } from "./i18n.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
// The editors pull tiptap, MJML preview and the page canvas; load them on first mount.
|
|
11
|
+
const LazyLayoutEditor = lazy(() => import("./layout-editor.js").then((module) => ({ default: module.LayoutEditor })));
|
|
12
|
+
const LazyPdfTemplateEditor = lazy(() => import("./pdf-template-editor.js").then((module) => ({ default: module.PdfTemplateEditor })));
|
|
13
|
+
function LayoutEditorScreen() {
|
|
14
|
+
return (_jsx(Suspense, { fallback: _jsx(LoadingState, {}), children: _jsx(LazyLayoutEditor, {}) }));
|
|
15
|
+
}
|
|
16
|
+
function createLazyMailEditor(appLocales) {
|
|
17
|
+
const LazyMailEditor = lazy(() => import("./mail-editor.js").then((module) => ({
|
|
18
|
+
default: module.createMailEditor(appLocales),
|
|
19
|
+
})));
|
|
20
|
+
return function MailEditorScreen() {
|
|
21
|
+
return (_jsx(Suspense, { fallback: _jsx(LoadingState, {}), children: _jsx(LazyMailEditor, {}) }));
|
|
22
|
+
};
|
|
23
|
+
}
|
|
11
24
|
/**
|
|
12
25
|
* Custom screen body: the template comes from the URL (`?slug=...&locale=...`),
|
|
13
26
|
* because custom screens receive no props.
|
|
@@ -17,7 +30,7 @@ export function PdfTemplateEditorScreen() {
|
|
|
17
30
|
const slug = searchParams["slug"];
|
|
18
31
|
if (slug === undefined || slug === "")
|
|
19
32
|
return null;
|
|
20
|
-
return (_jsx(
|
|
33
|
+
return (_jsx(Suspense, { fallback: _jsx(LoadingState, {}), children: _jsx(LazyPdfTemplateEditor, { slug: slug, ...(searchParams["locale"] !== undefined && { locale: searchParams["locale"] }), onLocaleChange: (locale) => setSearchParams({ locale }) }) }));
|
|
21
34
|
}
|
|
22
35
|
export function documentDesignerClient(options = {}) {
|
|
23
36
|
return {
|
|
@@ -33,9 +46,9 @@ export function documentDesignerClient(options = {}) {
|
|
|
33
46
|
[DocumentDesignerCells.overriddenBy]: OverriddenByCell,
|
|
34
47
|
},
|
|
35
48
|
components: {
|
|
36
|
-
[LAYOUT_EDITOR_SCREEN_ID]:
|
|
49
|
+
[LAYOUT_EDITOR_SCREEN_ID]: LayoutEditorScreen,
|
|
37
50
|
[PDF_TEMPLATE_EDITOR_SCREEN_ID]: PdfTemplateEditorScreen,
|
|
38
|
-
[MAIL_EDITOR_SCREEN_ID]:
|
|
51
|
+
[MAIL_EDITOR_SCREEN_ID]: createLazyMailEditor(options.appLocales ?? DEFAULT_TEMPLATE_LOCALES),
|
|
39
52
|
},
|
|
40
53
|
translations: mergeTranslations(mergeTranslations(textBlocksClient().translations ?? {}, documentDesignerTranslations), translationsByLocaleFromKeys(DOCUMENT_DESIGNER_I18N)),
|
|
41
54
|
};
|
|
@@ -22,5 +22,10 @@ export type OverviewRowView = {
|
|
|
22
22
|
readonly modifiedAt: string;
|
|
23
23
|
readonly usedBy: readonly OverviewUsageView[];
|
|
24
24
|
readonly usedByCount: number;
|
|
25
|
+
/** SystemAdmin only, system-origin rows; total is null without the tenant feature. */
|
|
26
|
+
readonly overriddenBy: {
|
|
27
|
+
readonly active: number;
|
|
28
|
+
readonly total: number | null;
|
|
29
|
+
} | null;
|
|
25
30
|
};
|
|
26
31
|
export declare function parseOverviewRow(row: Readonly<Record<string, unknown>>): OverviewRowView | null;
|
package/dist/web/overview-row.js
CHANGED
|
@@ -20,8 +20,13 @@ function usageViewOf(value) {
|
|
|
20
20
|
}
|
|
21
21
|
const stringOr = (value, fallback) => typeof value === "string" ? value : fallback;
|
|
22
22
|
const numberOr = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
23
|
+
function overriddenByOf(value) {
|
|
24
|
+
if (!isRecord(value) || typeof value["active"] !== "number")
|
|
25
|
+
return null;
|
|
26
|
+
return { active: value["active"], total: numberOr(value["total"], null) };
|
|
27
|
+
}
|
|
23
28
|
export function parseOverviewRow(row) {
|
|
24
|
-
const { id, title, layoutSlug, slug, kind, origin, locales, status, version, draftVersion, systemVersion, lockedOverride, lockedOverrideI18nKey, modifiedAt, usedBy, usedByCount, } = row;
|
|
29
|
+
const { id, title, layoutSlug, slug, kind, origin, locales, status, version, draftVersion, systemVersion, lockedOverride, lockedOverrideI18nKey, modifiedAt, usedBy, usedByCount, overriddenBy, } = row;
|
|
25
30
|
if (typeof slug !== "string" || !isTemplateKind(kind) || !isStatus(status))
|
|
26
31
|
return null;
|
|
27
32
|
if (origin !== "tenant" && origin !== "system")
|
|
@@ -46,5 +51,6 @@ export function parseOverviewRow(row) {
|
|
|
46
51
|
modifiedAt: stringOr(modifiedAt, ""),
|
|
47
52
|
usedBy: usages,
|
|
48
53
|
usedByCount: numberOr(usedByCount, usages.length),
|
|
54
|
+
overriddenBy: overriddenByOf(overriddenBy),
|
|
49
55
|
};
|
|
50
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-document-designer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.385.0",
|
|
4
4
|
"description": "Document designer for Kumiko: template overview, layout editor (mail layout, PDF letterhead) and the PDF template editor.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"./web/styles.css": "./src/web/styles.css"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@cosmicdrift/kumiko-bundled-features": "0.
|
|
24
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
25
|
-
"@cosmicdrift/kumiko-renderer": "0.
|
|
26
|
-
"@cosmicdrift/kumiko-renderer-puppeteer-client": "0.
|
|
27
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
23
|
+
"@cosmicdrift/kumiko-bundled-features": "0.385.0",
|
|
24
|
+
"@cosmicdrift/kumiko-framework": "0.385.0",
|
|
25
|
+
"@cosmicdrift/kumiko-renderer": "0.385.0",
|
|
26
|
+
"@cosmicdrift/kumiko-renderer-puppeteer-client": "0.385.0",
|
|
27
|
+
"@cosmicdrift/kumiko-types": "0.385.0",
|
|
28
28
|
"react": "^19.2.6"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.384.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "Layout, mail and PDF template editors load lazily",
|
|
6
|
+
"detail": "The editors are split into their own chunks and show a loading state while they load. The PdfTemplateEditor export of the web barrel is unchanged."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.379.0",
|
|
4
10
|
"type": "fix",
|