@cmssy/react 14.0.0 → 14.1.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/client.cjs +3 -1
- package/dist/client.d.cts +4 -2
- package/dist/client.d.ts +4 -2
- package/dist/client.js +3 -1
- package/dist/index.cjs +67 -8
- package/dist/index.d.cts +41 -8
- package/dist/index.d.ts +41 -8
- package/dist/index.js +67 -9
- package/dist/{registry-CwJ2cby4.d.cts → internal-server-CP0tEgpM.d.cts} +36 -2
- package/dist/{registry-CwJ2cby4.d.ts → internal-server-CP0tEgpM.d.ts} +36 -2
- package/dist/internal-server.cjs +2 -1
- package/dist/internal-server.d.cts +2 -37
- package/dist/internal-server.d.ts +2 -37
- package/dist/internal-server.js +2 -1
- package/package.json +3 -3
package/dist/client.cjs
CHANGED
|
@@ -1012,6 +1012,7 @@ function CmssyEditableLayout({
|
|
|
1012
1012
|
groups,
|
|
1013
1013
|
blocks,
|
|
1014
1014
|
position,
|
|
1015
|
+
page,
|
|
1015
1016
|
locale = "en",
|
|
1016
1017
|
defaultLocale = "en",
|
|
1017
1018
|
enabledLocales,
|
|
@@ -1032,9 +1033,10 @@ function CmssyEditableLayout({
|
|
|
1032
1033
|
const patches = useLayoutPatchBridge(position, edit);
|
|
1033
1034
|
const context = react.useMemo(
|
|
1034
1035
|
() => internal.buildBlockContext(locale, defaultLocale, enabledLocales, true, void 0, {
|
|
1036
|
+
page,
|
|
1035
1037
|
app: appContext
|
|
1036
1038
|
}),
|
|
1037
|
-
[locale, defaultLocale, enabledLocales, appContext]
|
|
1039
|
+
[locale, defaultLocale, enabledLocales, page, appContext]
|
|
1038
1040
|
);
|
|
1039
1041
|
if (layoutBlocks.length === 0) return null;
|
|
1040
1042
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: layoutBlocks.map((block) => /* @__PURE__ */ jsxRuntime.jsx(
|
package/dist/client.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BlockSchema, BlockMeta, LayoutRegion, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition } from './
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage } from './internal-server-CP0tEgpM.cjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface EditBridgeConfig {
|
|
@@ -72,6 +72,7 @@ interface CmssyEditableLayoutProps {
|
|
|
72
72
|
groups: CmssyLayoutGroup[];
|
|
73
73
|
blocks: BlockDefinition[];
|
|
74
74
|
position: string;
|
|
75
|
+
page?: LayoutBlockPage;
|
|
75
76
|
locale?: string;
|
|
76
77
|
defaultLocale?: string;
|
|
77
78
|
enabledLocales?: string[];
|
|
@@ -80,11 +81,12 @@ interface CmssyEditableLayoutProps {
|
|
|
80
81
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
81
82
|
appContext?: Record<string, unknown>;
|
|
82
83
|
}
|
|
83
|
-
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
84
|
+
declare function CmssyEditableLayout({ groups, blocks, position, page, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
84
85
|
|
|
85
86
|
interface CmssyLazyLayoutProps {
|
|
86
87
|
groups: CmssyLayoutGroup[];
|
|
87
88
|
position: string;
|
|
89
|
+
page?: LayoutBlockPage;
|
|
88
90
|
locale?: string;
|
|
89
91
|
defaultLocale?: string;
|
|
90
92
|
enabledLocales?: string[];
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BlockSchema, BlockMeta, LayoutRegion, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition } from './
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage } from './internal-server-CP0tEgpM.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface EditBridgeConfig {
|
|
@@ -72,6 +72,7 @@ interface CmssyEditableLayoutProps {
|
|
|
72
72
|
groups: CmssyLayoutGroup[];
|
|
73
73
|
blocks: BlockDefinition[];
|
|
74
74
|
position: string;
|
|
75
|
+
page?: LayoutBlockPage;
|
|
75
76
|
locale?: string;
|
|
76
77
|
defaultLocale?: string;
|
|
77
78
|
enabledLocales?: string[];
|
|
@@ -80,11 +81,12 @@ interface CmssyEditableLayoutProps {
|
|
|
80
81
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
81
82
|
appContext?: Record<string, unknown>;
|
|
82
83
|
}
|
|
83
|
-
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
84
|
+
declare function CmssyEditableLayout({ groups, blocks, position, page, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
84
85
|
|
|
85
86
|
interface CmssyLazyLayoutProps {
|
|
86
87
|
groups: CmssyLayoutGroup[];
|
|
87
88
|
position: string;
|
|
89
|
+
page?: LayoutBlockPage;
|
|
88
90
|
locale?: string;
|
|
89
91
|
defaultLocale?: string;
|
|
90
92
|
enabledLocales?: string[];
|
package/dist/client.js
CHANGED
|
@@ -1010,6 +1010,7 @@ function CmssyEditableLayout({
|
|
|
1010
1010
|
groups,
|
|
1011
1011
|
blocks,
|
|
1012
1012
|
position,
|
|
1013
|
+
page,
|
|
1013
1014
|
locale = "en",
|
|
1014
1015
|
defaultLocale = "en",
|
|
1015
1016
|
enabledLocales,
|
|
@@ -1030,9 +1031,10 @@ function CmssyEditableLayout({
|
|
|
1030
1031
|
const patches = useLayoutPatchBridge(position, edit);
|
|
1031
1032
|
const context = useMemo(
|
|
1032
1033
|
() => buildBlockContext(locale, defaultLocale, enabledLocales, true, void 0, {
|
|
1034
|
+
page,
|
|
1033
1035
|
app: appContext
|
|
1034
1036
|
}),
|
|
1035
|
-
[locale, defaultLocale, enabledLocales, appContext]
|
|
1037
|
+
[locale, defaultLocale, enabledLocales, page, appContext]
|
|
1036
1038
|
);
|
|
1037
1039
|
if (layoutBlocks.length === 0) return null;
|
|
1038
1040
|
return /* @__PURE__ */ jsx(Fragment, { children: layoutBlocks.map((block) => /* @__PURE__ */ jsx(
|
package/dist/index.cjs
CHANGED
|
@@ -364,6 +364,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
364
364
|
groups,
|
|
365
365
|
blocks,
|
|
366
366
|
position,
|
|
367
|
+
page,
|
|
367
368
|
locale,
|
|
368
369
|
defaultLocale,
|
|
369
370
|
enabledLocales,
|
|
@@ -382,7 +383,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
382
383
|
enabledLocales,
|
|
383
384
|
isPreview,
|
|
384
385
|
forms,
|
|
385
|
-
{ app: appContext }
|
|
386
|
+
{ page, app: appContext }
|
|
386
387
|
);
|
|
387
388
|
const resolved = await resolveBlocks(
|
|
388
389
|
layoutBlocks,
|
|
@@ -395,12 +396,16 @@ async function resolveEditorLayoutBlockData({
|
|
|
395
396
|
);
|
|
396
397
|
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
397
398
|
}
|
|
399
|
+
function layoutSlotPage(slug) {
|
|
400
|
+
return { slug, path: slug.split("/").filter(Boolean) };
|
|
401
|
+
}
|
|
398
402
|
async function resolveCmssyLayoutSlot(config, options) {
|
|
399
403
|
const {
|
|
400
404
|
position,
|
|
401
405
|
blocks,
|
|
402
406
|
editMode,
|
|
403
|
-
|
|
407
|
+
preview = false,
|
|
408
|
+
page: explicitPage,
|
|
404
409
|
forms,
|
|
405
410
|
appContext,
|
|
406
411
|
path,
|
|
@@ -412,13 +417,15 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
412
417
|
const fromPath = path ? locale.splitLocaleFromPath(path, siteLocales) : { locale: siteLocales.defaultLocale, path: [] };
|
|
413
418
|
const locale$1 = explicitLocale ?? fromPath.locale;
|
|
414
419
|
const slugSegments = fromPath.path ?? [];
|
|
415
|
-
const
|
|
416
|
-
const groups = await internal.fetchLayouts(config,
|
|
417
|
-
previewSecret: editMode ? config.draftSecret : void 0,
|
|
420
|
+
const page = layoutSlotPage(explicitPage ?? "/" + slugSegments.join("/"));
|
|
421
|
+
const groups = await internal.fetchLayouts(config, page.slug, {
|
|
422
|
+
previewSecret: editMode || preview ? config.draftSecret : void 0,
|
|
418
423
|
...requestOptions
|
|
419
424
|
});
|
|
420
425
|
const base = {
|
|
421
426
|
groups,
|
|
427
|
+
settings: groups.find((g) => g.position === position)?.settings ?? null,
|
|
428
|
+
page,
|
|
422
429
|
locale: locale$1,
|
|
423
430
|
defaultLocale: siteLocales.defaultLocale,
|
|
424
431
|
enabledLocales: siteLocales.locales,
|
|
@@ -429,6 +436,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
429
436
|
groups,
|
|
430
437
|
blocks,
|
|
431
438
|
position,
|
|
439
|
+
page,
|
|
432
440
|
locale: locale$1,
|
|
433
441
|
defaultLocale: siteLocales.defaultLocale,
|
|
434
442
|
enabledLocales: siteLocales.locales,
|
|
@@ -448,12 +456,14 @@ async function CmssyServerLayout({
|
|
|
448
456
|
groups,
|
|
449
457
|
blocks,
|
|
450
458
|
position,
|
|
459
|
+
page,
|
|
451
460
|
locale: localeProp,
|
|
452
461
|
defaultLocale: defaultLocaleProp,
|
|
453
462
|
enabledLocales: enabledLocalesProp,
|
|
454
463
|
config,
|
|
455
464
|
appContext,
|
|
456
|
-
editMode
|
|
465
|
+
editMode,
|
|
466
|
+
preview = false
|
|
457
467
|
}) {
|
|
458
468
|
const { locale, defaultLocale, enabledLocales } = await resolveRenderLocale({
|
|
459
469
|
locale: localeProp,
|
|
@@ -470,9 +480,9 @@ async function CmssyServerLayout({
|
|
|
470
480
|
locale,
|
|
471
481
|
defaultLocale,
|
|
472
482
|
enabledLocales,
|
|
473
|
-
|
|
483
|
+
preview,
|
|
474
484
|
void 0,
|
|
475
|
-
{ app: appContext }
|
|
485
|
+
{ page, app: appContext }
|
|
476
486
|
);
|
|
477
487
|
const resolved = await resolveBlocks(
|
|
478
488
|
layoutBlocks,
|
|
@@ -494,6 +504,54 @@ async function CmssyServerLayout({
|
|
|
494
504
|
})
|
|
495
505
|
) });
|
|
496
506
|
}
|
|
507
|
+
async function resolveCmssyLayout(config, options) {
|
|
508
|
+
const { editable: Editable, ...slotOptions } = options;
|
|
509
|
+
if (slotOptions.editMode && !Editable) {
|
|
510
|
+
throw new Error(
|
|
511
|
+
"cmssy: resolveCmssyLayout needs an `editable` component in edit mode - the editor bridge lives on the client"
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
const resolved = await resolveCmssyLayoutSlot(
|
|
515
|
+
config,
|
|
516
|
+
slotOptions
|
|
517
|
+
);
|
|
518
|
+
const { groups, settings, page, locale, defaultLocale, enabledLocales } = resolved;
|
|
519
|
+
const shared = {
|
|
520
|
+
groups,
|
|
521
|
+
position: options.position,
|
|
522
|
+
page,
|
|
523
|
+
locale,
|
|
524
|
+
defaultLocale,
|
|
525
|
+
enabledLocales,
|
|
526
|
+
appContext: options.appContext
|
|
527
|
+
};
|
|
528
|
+
const element = slotOptions.editMode && Editable ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
529
|
+
Editable,
|
|
530
|
+
{
|
|
531
|
+
...shared,
|
|
532
|
+
edit: { editorOrigin: resolved.editorOrigin ?? "" },
|
|
533
|
+
data: resolved.data,
|
|
534
|
+
resolvedContent: resolved.resolvedContent
|
|
535
|
+
}
|
|
536
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
537
|
+
CmssyServerLayout,
|
|
538
|
+
{
|
|
539
|
+
...shared,
|
|
540
|
+
blocks: options.blocks,
|
|
541
|
+
config,
|
|
542
|
+
preview: slotOptions.preview
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
return {
|
|
546
|
+
groups,
|
|
547
|
+
settings,
|
|
548
|
+
page,
|
|
549
|
+
locale,
|
|
550
|
+
defaultLocale,
|
|
551
|
+
enabledLocales,
|
|
552
|
+
element
|
|
553
|
+
};
|
|
554
|
+
}
|
|
497
555
|
function CmssyBlock({
|
|
498
556
|
block,
|
|
499
557
|
locale,
|
|
@@ -635,6 +693,7 @@ exports.CmssyServerPage = CmssyServerPage;
|
|
|
635
693
|
exports.UnknownBlock = UnknownBlock;
|
|
636
694
|
exports.buildBlockMap = buildBlockMap;
|
|
637
695
|
exports.defineBlock = defineBlock;
|
|
696
|
+
exports.resolveCmssyLayout = resolveCmssyLayout;
|
|
638
697
|
exports.resolveCmssyLayoutSlot = resolveCmssyLayoutSlot;
|
|
639
698
|
exports.resolveEditorBlockData = resolveEditorBlockData;
|
|
640
699
|
exports.resolveEditorLayoutBlockData = resolveEditorLayoutBlockData;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, RetryOption, CmssyConfig, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
-
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutPosition, LayoutRegion, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition, a as BlockMap } from './
|
|
4
|
-
export { b as BlockProps, c as
|
|
1
|
+
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
+
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutPosition, LayoutRegion, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-CP0tEgpM.cjs';
|
|
4
|
+
export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-CP0tEgpM.cjs';
|
|
5
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
6
6
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
7
|
export { buildBlockContext } from '@cmssy/core/internal';
|
|
8
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
import 'react';
|
|
9
|
+
import { ReactElement, ComponentType } from 'react';
|
|
11
10
|
|
|
12
11
|
interface CmssyServerPageProps {
|
|
13
12
|
page: CmssyPageData | null;
|
|
@@ -28,6 +27,7 @@ interface ResolveCmssyLayoutSlotBase {
|
|
|
28
27
|
position: string;
|
|
29
28
|
blocks: BlockDefinition[];
|
|
30
29
|
editMode: boolean;
|
|
30
|
+
preview?: boolean;
|
|
31
31
|
page?: string;
|
|
32
32
|
forms?: Record<string, CmssyFormDefinition>;
|
|
33
33
|
appContext?: Record<string, unknown>;
|
|
@@ -43,6 +43,8 @@ type CmssyLayoutSlotLocaleSource = {
|
|
|
43
43
|
type ResolveCmssyLayoutSlotOptions = ResolveCmssyLayoutSlotBase & CmssyLayoutSlotLocaleSource;
|
|
44
44
|
interface CmssyLayoutSlotResolution {
|
|
45
45
|
groups: CmssyLayoutGroup[];
|
|
46
|
+
settings: Record<string, unknown> | null;
|
|
47
|
+
page: CmssyBlockPage;
|
|
46
48
|
locale: string;
|
|
47
49
|
defaultLocale: string;
|
|
48
50
|
enabledLocales: string[];
|
|
@@ -53,18 +55,49 @@ interface CmssyLayoutSlotResolution {
|
|
|
53
55
|
}
|
|
54
56
|
declare function resolveCmssyLayoutSlot(config: CmssyConfig, options: ResolveCmssyLayoutSlotOptions): Promise<CmssyLayoutSlotResolution>;
|
|
55
57
|
|
|
58
|
+
interface CmssyLayoutEditableProps {
|
|
59
|
+
groups: CmssyLayoutGroup[];
|
|
60
|
+
position: string;
|
|
61
|
+
page?: CmssyBlockPage;
|
|
62
|
+
locale: string;
|
|
63
|
+
defaultLocale: string;
|
|
64
|
+
enabledLocales: string[];
|
|
65
|
+
edit: {
|
|
66
|
+
editorOrigin: string | string[];
|
|
67
|
+
};
|
|
68
|
+
data?: Record<string, unknown>;
|
|
69
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
70
|
+
appContext?: Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>> = Omit<ResolveCmssyLayoutSlotOptions, "position" | keyof CmssyLayoutSlotLocaleSource> & CmssyLayoutSlotLocaleSource & {
|
|
73
|
+
position: P;
|
|
74
|
+
editable?: ComponentType<CmssyLayoutEditableProps>;
|
|
75
|
+
};
|
|
76
|
+
interface CmssyLayoutResolution<C extends CmssyConfig = CmssyConfig, P extends CmssyRegionOf<C> = CmssyRegionOf<C>> {
|
|
77
|
+
groups: CmssyLayoutGroup[];
|
|
78
|
+
settings: CmssyRegionSettingsOf<C, P> | null;
|
|
79
|
+
page: CmssyBlockPage;
|
|
80
|
+
locale: string;
|
|
81
|
+
defaultLocale: string;
|
|
82
|
+
enabledLocales: string[];
|
|
83
|
+
element: ReactElement<Record<string, unknown>>;
|
|
84
|
+
}
|
|
85
|
+
declare function resolveCmssyLayout<C extends CmssyConfig, P extends CmssyRegionOf<C>>(config: C, options: ResolveCmssyLayoutOptions<C, P>): Promise<CmssyLayoutResolution<C, P>>;
|
|
86
|
+
|
|
56
87
|
interface CmssyServerLayoutProps {
|
|
57
88
|
groups: CmssyLayoutGroup[];
|
|
58
89
|
blocks: BlockDefinition[];
|
|
59
90
|
position: string;
|
|
91
|
+
page?: LayoutBlockPage;
|
|
60
92
|
locale?: string;
|
|
61
93
|
defaultLocale?: string;
|
|
62
94
|
enabledLocales?: string[];
|
|
63
95
|
config?: CmssyClientConfig;
|
|
64
96
|
appContext?: Record<string, unknown>;
|
|
65
97
|
editMode?: boolean;
|
|
98
|
+
preview?: boolean;
|
|
66
99
|
}
|
|
67
|
-
declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
100
|
+
declare function CmssyServerLayout({ groups, blocks, position, page, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, preview, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
68
101
|
|
|
69
102
|
interface CmssyBlockProps {
|
|
70
103
|
block: RawBlock;
|
|
@@ -89,4 +122,4 @@ interface UnknownBlockProps {
|
|
|
89
122
|
}
|
|
90
123
|
declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
|
|
91
124
|
|
|
92
|
-
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayoutSlot };
|
|
125
|
+
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, type CmssyLayoutEditableProps, type CmssyLayoutResolution, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, LayoutBlockPage, type ResolveCmssyLayoutOptions, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayout, resolveCmssyLayoutSlot };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, RetryOption, CmssyConfig, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
-
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutPosition, LayoutRegion, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition, a as BlockMap } from './
|
|
4
|
-
export { b as BlockProps, c as
|
|
1
|
+
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
+
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutPosition, LayoutRegion, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-CP0tEgpM.js';
|
|
4
|
+
export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-CP0tEgpM.js';
|
|
5
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
6
6
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
7
|
export { buildBlockContext } from '@cmssy/core/internal';
|
|
8
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
import 'react';
|
|
9
|
+
import { ReactElement, ComponentType } from 'react';
|
|
11
10
|
|
|
12
11
|
interface CmssyServerPageProps {
|
|
13
12
|
page: CmssyPageData | null;
|
|
@@ -28,6 +27,7 @@ interface ResolveCmssyLayoutSlotBase {
|
|
|
28
27
|
position: string;
|
|
29
28
|
blocks: BlockDefinition[];
|
|
30
29
|
editMode: boolean;
|
|
30
|
+
preview?: boolean;
|
|
31
31
|
page?: string;
|
|
32
32
|
forms?: Record<string, CmssyFormDefinition>;
|
|
33
33
|
appContext?: Record<string, unknown>;
|
|
@@ -43,6 +43,8 @@ type CmssyLayoutSlotLocaleSource = {
|
|
|
43
43
|
type ResolveCmssyLayoutSlotOptions = ResolveCmssyLayoutSlotBase & CmssyLayoutSlotLocaleSource;
|
|
44
44
|
interface CmssyLayoutSlotResolution {
|
|
45
45
|
groups: CmssyLayoutGroup[];
|
|
46
|
+
settings: Record<string, unknown> | null;
|
|
47
|
+
page: CmssyBlockPage;
|
|
46
48
|
locale: string;
|
|
47
49
|
defaultLocale: string;
|
|
48
50
|
enabledLocales: string[];
|
|
@@ -53,18 +55,49 @@ interface CmssyLayoutSlotResolution {
|
|
|
53
55
|
}
|
|
54
56
|
declare function resolveCmssyLayoutSlot(config: CmssyConfig, options: ResolveCmssyLayoutSlotOptions): Promise<CmssyLayoutSlotResolution>;
|
|
55
57
|
|
|
58
|
+
interface CmssyLayoutEditableProps {
|
|
59
|
+
groups: CmssyLayoutGroup[];
|
|
60
|
+
position: string;
|
|
61
|
+
page?: CmssyBlockPage;
|
|
62
|
+
locale: string;
|
|
63
|
+
defaultLocale: string;
|
|
64
|
+
enabledLocales: string[];
|
|
65
|
+
edit: {
|
|
66
|
+
editorOrigin: string | string[];
|
|
67
|
+
};
|
|
68
|
+
data?: Record<string, unknown>;
|
|
69
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
70
|
+
appContext?: Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>> = Omit<ResolveCmssyLayoutSlotOptions, "position" | keyof CmssyLayoutSlotLocaleSource> & CmssyLayoutSlotLocaleSource & {
|
|
73
|
+
position: P;
|
|
74
|
+
editable?: ComponentType<CmssyLayoutEditableProps>;
|
|
75
|
+
};
|
|
76
|
+
interface CmssyLayoutResolution<C extends CmssyConfig = CmssyConfig, P extends CmssyRegionOf<C> = CmssyRegionOf<C>> {
|
|
77
|
+
groups: CmssyLayoutGroup[];
|
|
78
|
+
settings: CmssyRegionSettingsOf<C, P> | null;
|
|
79
|
+
page: CmssyBlockPage;
|
|
80
|
+
locale: string;
|
|
81
|
+
defaultLocale: string;
|
|
82
|
+
enabledLocales: string[];
|
|
83
|
+
element: ReactElement<Record<string, unknown>>;
|
|
84
|
+
}
|
|
85
|
+
declare function resolveCmssyLayout<C extends CmssyConfig, P extends CmssyRegionOf<C>>(config: C, options: ResolveCmssyLayoutOptions<C, P>): Promise<CmssyLayoutResolution<C, P>>;
|
|
86
|
+
|
|
56
87
|
interface CmssyServerLayoutProps {
|
|
57
88
|
groups: CmssyLayoutGroup[];
|
|
58
89
|
blocks: BlockDefinition[];
|
|
59
90
|
position: string;
|
|
91
|
+
page?: LayoutBlockPage;
|
|
60
92
|
locale?: string;
|
|
61
93
|
defaultLocale?: string;
|
|
62
94
|
enabledLocales?: string[];
|
|
63
95
|
config?: CmssyClientConfig;
|
|
64
96
|
appContext?: Record<string, unknown>;
|
|
65
97
|
editMode?: boolean;
|
|
98
|
+
preview?: boolean;
|
|
66
99
|
}
|
|
67
|
-
declare function CmssyServerLayout({ groups, blocks, position, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
100
|
+
declare function CmssyServerLayout({ groups, blocks, position, page, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, preview, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
68
101
|
|
|
69
102
|
interface CmssyBlockProps {
|
|
70
103
|
block: RawBlock;
|
|
@@ -89,4 +122,4 @@ interface UnknownBlockProps {
|
|
|
89
122
|
}
|
|
90
123
|
declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
|
|
91
124
|
|
|
92
|
-
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayoutSlot };
|
|
125
|
+
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, type CmssyLayoutEditableProps, type CmssyLayoutResolution, type CmssyLayoutSlotLocaleSource, type CmssyLayoutSlotResolution, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, LayoutBlockPage, type ResolveCmssyLayoutOptions, type ResolveCmssyLayoutSlotOptions, UnknownBlock, type UnknownBlockProps, resolveCmssyLayout, resolveCmssyLayoutSlot };
|
package/dist/index.js
CHANGED
|
@@ -364,6 +364,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
364
364
|
groups,
|
|
365
365
|
blocks,
|
|
366
366
|
position,
|
|
367
|
+
page,
|
|
367
368
|
locale,
|
|
368
369
|
defaultLocale,
|
|
369
370
|
enabledLocales,
|
|
@@ -382,7 +383,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
382
383
|
enabledLocales,
|
|
383
384
|
isPreview,
|
|
384
385
|
forms,
|
|
385
|
-
{ app: appContext }
|
|
386
|
+
{ page, app: appContext }
|
|
386
387
|
);
|
|
387
388
|
const resolved = await resolveBlocks(
|
|
388
389
|
layoutBlocks,
|
|
@@ -395,12 +396,16 @@ async function resolveEditorLayoutBlockData({
|
|
|
395
396
|
);
|
|
396
397
|
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
397
398
|
}
|
|
399
|
+
function layoutSlotPage(slug) {
|
|
400
|
+
return { slug, path: slug.split("/").filter(Boolean) };
|
|
401
|
+
}
|
|
398
402
|
async function resolveCmssyLayoutSlot(config, options) {
|
|
399
403
|
const {
|
|
400
404
|
position,
|
|
401
405
|
blocks,
|
|
402
406
|
editMode,
|
|
403
|
-
|
|
407
|
+
preview = false,
|
|
408
|
+
page: explicitPage,
|
|
404
409
|
forms,
|
|
405
410
|
appContext,
|
|
406
411
|
path,
|
|
@@ -412,13 +417,15 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
412
417
|
const fromPath = path ? splitLocaleFromPath(path, siteLocales) : { locale: siteLocales.defaultLocale, path: [] };
|
|
413
418
|
const locale = explicitLocale ?? fromPath.locale;
|
|
414
419
|
const slugSegments = fromPath.path ?? [];
|
|
415
|
-
const
|
|
416
|
-
const groups = await fetchLayouts(config,
|
|
417
|
-
previewSecret: editMode ? config.draftSecret : void 0,
|
|
420
|
+
const page = layoutSlotPage(explicitPage ?? "/" + slugSegments.join("/"));
|
|
421
|
+
const groups = await fetchLayouts(config, page.slug, {
|
|
422
|
+
previewSecret: editMode || preview ? config.draftSecret : void 0,
|
|
418
423
|
...requestOptions
|
|
419
424
|
});
|
|
420
425
|
const base = {
|
|
421
426
|
groups,
|
|
427
|
+
settings: groups.find((g) => g.position === position)?.settings ?? null,
|
|
428
|
+
page,
|
|
422
429
|
locale,
|
|
423
430
|
defaultLocale: siteLocales.defaultLocale,
|
|
424
431
|
enabledLocales: siteLocales.locales,
|
|
@@ -429,6 +436,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
429
436
|
groups,
|
|
430
437
|
blocks,
|
|
431
438
|
position,
|
|
439
|
+
page,
|
|
432
440
|
locale,
|
|
433
441
|
defaultLocale: siteLocales.defaultLocale,
|
|
434
442
|
enabledLocales: siteLocales.locales,
|
|
@@ -448,12 +456,14 @@ async function CmssyServerLayout({
|
|
|
448
456
|
groups,
|
|
449
457
|
blocks,
|
|
450
458
|
position,
|
|
459
|
+
page,
|
|
451
460
|
locale: localeProp,
|
|
452
461
|
defaultLocale: defaultLocaleProp,
|
|
453
462
|
enabledLocales: enabledLocalesProp,
|
|
454
463
|
config,
|
|
455
464
|
appContext,
|
|
456
|
-
editMode
|
|
465
|
+
editMode,
|
|
466
|
+
preview = false
|
|
457
467
|
}) {
|
|
458
468
|
const { locale, defaultLocale, enabledLocales } = await resolveRenderLocale({
|
|
459
469
|
locale: localeProp,
|
|
@@ -470,9 +480,9 @@ async function CmssyServerLayout({
|
|
|
470
480
|
locale,
|
|
471
481
|
defaultLocale,
|
|
472
482
|
enabledLocales,
|
|
473
|
-
|
|
483
|
+
preview,
|
|
474
484
|
void 0,
|
|
475
|
-
{ app: appContext }
|
|
485
|
+
{ page, app: appContext }
|
|
476
486
|
);
|
|
477
487
|
const resolved = await resolveBlocks(
|
|
478
488
|
layoutBlocks,
|
|
@@ -494,6 +504,54 @@ async function CmssyServerLayout({
|
|
|
494
504
|
})
|
|
495
505
|
) });
|
|
496
506
|
}
|
|
507
|
+
async function resolveCmssyLayout(config, options) {
|
|
508
|
+
const { editable: Editable, ...slotOptions } = options;
|
|
509
|
+
if (slotOptions.editMode && !Editable) {
|
|
510
|
+
throw new Error(
|
|
511
|
+
"cmssy: resolveCmssyLayout needs an `editable` component in edit mode - the editor bridge lives on the client"
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
const resolved = await resolveCmssyLayoutSlot(
|
|
515
|
+
config,
|
|
516
|
+
slotOptions
|
|
517
|
+
);
|
|
518
|
+
const { groups, settings, page, locale, defaultLocale, enabledLocales } = resolved;
|
|
519
|
+
const shared = {
|
|
520
|
+
groups,
|
|
521
|
+
position: options.position,
|
|
522
|
+
page,
|
|
523
|
+
locale,
|
|
524
|
+
defaultLocale,
|
|
525
|
+
enabledLocales,
|
|
526
|
+
appContext: options.appContext
|
|
527
|
+
};
|
|
528
|
+
const element = slotOptions.editMode && Editable ? /* @__PURE__ */ jsx(
|
|
529
|
+
Editable,
|
|
530
|
+
{
|
|
531
|
+
...shared,
|
|
532
|
+
edit: { editorOrigin: resolved.editorOrigin ?? "" },
|
|
533
|
+
data: resolved.data,
|
|
534
|
+
resolvedContent: resolved.resolvedContent
|
|
535
|
+
}
|
|
536
|
+
) : /* @__PURE__ */ jsx(
|
|
537
|
+
CmssyServerLayout,
|
|
538
|
+
{
|
|
539
|
+
...shared,
|
|
540
|
+
blocks: options.blocks,
|
|
541
|
+
config,
|
|
542
|
+
preview: slotOptions.preview
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
return {
|
|
546
|
+
groups,
|
|
547
|
+
settings,
|
|
548
|
+
page,
|
|
549
|
+
locale,
|
|
550
|
+
defaultLocale,
|
|
551
|
+
enabledLocales,
|
|
552
|
+
element
|
|
553
|
+
};
|
|
554
|
+
}
|
|
497
555
|
function CmssyBlock({
|
|
498
556
|
block,
|
|
499
557
|
locale,
|
|
@@ -573,4 +631,4 @@ function CmssyBlock({
|
|
|
573
631
|
);
|
|
574
632
|
}
|
|
575
633
|
|
|
576
|
-
export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, defineBlock, resolveCmssyLayoutSlot, resolveEditorBlockData, resolveEditorLayoutBlockData };
|
|
634
|
+
export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock, buildBlockMap, defineBlock, resolveCmssyLayout, resolveCmssyLayoutSlot, resolveEditorBlockData, resolveEditorLayoutBlockData };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent, BlockSchema, BuildBlockContextExtra, CmssyPageData, CmssyFormDefinition, CmssyClientConfig, CmssyLayoutGroup } from '@cmssy/core';
|
|
1
2
|
import { ComponentType } from 'react';
|
|
2
|
-
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent, BlockSchema } from '@cmssy/core';
|
|
3
3
|
|
|
4
4
|
interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
5
5
|
content: InferBlockContent<P>;
|
|
@@ -67,4 +67,38 @@ type BlockMap = Record<string, ComponentType<{
|
|
|
67
67
|
declare function buildBlockMap(blocks: BlockDefinition[]): BlockMap;
|
|
68
68
|
declare function blocksToSchemas(blocks: BlockDefinition[]): Record<string, BlockSchema>;
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
type LayoutBlockPage = NonNullable<BuildBlockContextExtra["page"]>;
|
|
71
|
+
interface EditorBlockData {
|
|
72
|
+
data: Record<string, unknown>;
|
|
73
|
+
content: Record<string, Record<string, unknown>>;
|
|
74
|
+
}
|
|
75
|
+
interface ResolveBlockDataOptions {
|
|
76
|
+
page: CmssyPageData | null;
|
|
77
|
+
blocks: BlockDefinition[];
|
|
78
|
+
locale: string;
|
|
79
|
+
defaultLocale: string;
|
|
80
|
+
enabledLocales?: string[];
|
|
81
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
82
|
+
isPreview?: boolean;
|
|
83
|
+
config?: CmssyClientConfig;
|
|
84
|
+
appContext?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
87
|
+
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
88
|
+
interface ResolveLayoutBlockDataOptions {
|
|
89
|
+
groups: CmssyLayoutGroup[];
|
|
90
|
+
blocks: BlockDefinition[];
|
|
91
|
+
position: string;
|
|
92
|
+
page?: LayoutBlockPage;
|
|
93
|
+
locale: string;
|
|
94
|
+
defaultLocale: string;
|
|
95
|
+
enabledLocales?: string[];
|
|
96
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
97
|
+
isPreview?: boolean;
|
|
98
|
+
config?: CmssyClientConfig;
|
|
99
|
+
appContext?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
declare function resolveEditorLayoutBlockData({ groups, blocks, position, page, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
102
|
+
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
103
|
+
|
|
104
|
+
export { type BlockDefinition as B, type EditorBlockData as E, type LayoutBlockPage as L, type ResolveBlockDataOptions as R, type BlockMap as a, type BlockProps as b, type ResolveLayoutBlockDataOptions as c, buildBlockMap as d, defineBlock as e, resolveEditorLayoutBlockData as f, blocksToSchemas as g, resolveBlockData as h, resolveLayoutBlockData as i, resolveEditorBlockData as r };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent, BlockSchema, BuildBlockContextExtra, CmssyPageData, CmssyFormDefinition, CmssyClientConfig, CmssyLayoutGroup } from '@cmssy/core';
|
|
1
2
|
import { ComponentType } from 'react';
|
|
2
|
-
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent, BlockSchema } from '@cmssy/core';
|
|
3
3
|
|
|
4
4
|
interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
5
5
|
content: InferBlockContent<P>;
|
|
@@ -67,4 +67,38 @@ type BlockMap = Record<string, ComponentType<{
|
|
|
67
67
|
declare function buildBlockMap(blocks: BlockDefinition[]): BlockMap;
|
|
68
68
|
declare function blocksToSchemas(blocks: BlockDefinition[]): Record<string, BlockSchema>;
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
type LayoutBlockPage = NonNullable<BuildBlockContextExtra["page"]>;
|
|
71
|
+
interface EditorBlockData {
|
|
72
|
+
data: Record<string, unknown>;
|
|
73
|
+
content: Record<string, Record<string, unknown>>;
|
|
74
|
+
}
|
|
75
|
+
interface ResolveBlockDataOptions {
|
|
76
|
+
page: CmssyPageData | null;
|
|
77
|
+
blocks: BlockDefinition[];
|
|
78
|
+
locale: string;
|
|
79
|
+
defaultLocale: string;
|
|
80
|
+
enabledLocales?: string[];
|
|
81
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
82
|
+
isPreview?: boolean;
|
|
83
|
+
config?: CmssyClientConfig;
|
|
84
|
+
appContext?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
87
|
+
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
88
|
+
interface ResolveLayoutBlockDataOptions {
|
|
89
|
+
groups: CmssyLayoutGroup[];
|
|
90
|
+
blocks: BlockDefinition[];
|
|
91
|
+
position: string;
|
|
92
|
+
page?: LayoutBlockPage;
|
|
93
|
+
locale: string;
|
|
94
|
+
defaultLocale: string;
|
|
95
|
+
enabledLocales?: string[];
|
|
96
|
+
forms?: Record<string, CmssyFormDefinition>;
|
|
97
|
+
isPreview?: boolean;
|
|
98
|
+
config?: CmssyClientConfig;
|
|
99
|
+
appContext?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
declare function resolveEditorLayoutBlockData({ groups, blocks, position, page, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
102
|
+
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
103
|
+
|
|
104
|
+
export { type BlockDefinition as B, type EditorBlockData as E, type LayoutBlockPage as L, type ResolveBlockDataOptions as R, type BlockMap as a, type BlockProps as b, type ResolveLayoutBlockDataOptions as c, buildBlockMap as d, defineBlock as e, resolveEditorLayoutBlockData as f, blocksToSchemas as g, resolveBlockData as h, resolveLayoutBlockData as i, resolveEditorBlockData as r };
|
package/dist/internal-server.cjs
CHANGED
|
@@ -137,6 +137,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
137
137
|
groups,
|
|
138
138
|
blocks,
|
|
139
139
|
position,
|
|
140
|
+
page,
|
|
140
141
|
locale,
|
|
141
142
|
defaultLocale,
|
|
142
143
|
enabledLocales,
|
|
@@ -155,7 +156,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
155
156
|
enabledLocales,
|
|
156
157
|
isPreview,
|
|
157
158
|
forms,
|
|
158
|
-
{ app: appContext }
|
|
159
|
+
{ page, app: appContext }
|
|
159
160
|
);
|
|
160
161
|
const resolved = await resolveBlocks(
|
|
161
162
|
layoutBlocks,
|
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export { e as blocksToSchemas } from './registry-CwJ2cby4.cjs';
|
|
1
|
+
export { E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, g as blocksToSchemas, h as resolveBlockData, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData, i as resolveLayoutBlockData } from './internal-server-CP0tEgpM.cjs';
|
|
2
|
+
import '@cmssy/core';
|
|
4
3
|
import 'react';
|
|
5
|
-
|
|
6
|
-
interface EditorBlockData {
|
|
7
|
-
data: Record<string, unknown>;
|
|
8
|
-
content: Record<string, Record<string, unknown>>;
|
|
9
|
-
}
|
|
10
|
-
interface ResolveBlockDataOptions {
|
|
11
|
-
page: CmssyPageData | null;
|
|
12
|
-
blocks: BlockDefinition[];
|
|
13
|
-
locale: string;
|
|
14
|
-
defaultLocale: string;
|
|
15
|
-
enabledLocales?: string[];
|
|
16
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
17
|
-
isPreview?: boolean;
|
|
18
|
-
config?: CmssyClientConfig;
|
|
19
|
-
appContext?: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
22
|
-
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
23
|
-
interface ResolveLayoutBlockDataOptions {
|
|
24
|
-
groups: CmssyLayoutGroup[];
|
|
25
|
-
blocks: BlockDefinition[];
|
|
26
|
-
position: string;
|
|
27
|
-
locale: string;
|
|
28
|
-
defaultLocale: string;
|
|
29
|
-
enabledLocales?: string[];
|
|
30
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
31
|
-
isPreview?: boolean;
|
|
32
|
-
config?: CmssyClientConfig;
|
|
33
|
-
appContext?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
36
|
-
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
37
|
-
|
|
38
|
-
export { type EditorBlockData, type ResolveBlockDataOptions, type ResolveLayoutBlockDataOptions, resolveBlockData, resolveEditorBlockData, resolveEditorLayoutBlockData, resolveLayoutBlockData };
|
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export { e as blocksToSchemas } from './registry-CwJ2cby4.js';
|
|
1
|
+
export { E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, g as blocksToSchemas, h as resolveBlockData, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData, i as resolveLayoutBlockData } from './internal-server-CP0tEgpM.js';
|
|
2
|
+
import '@cmssy/core';
|
|
4
3
|
import 'react';
|
|
5
|
-
|
|
6
|
-
interface EditorBlockData {
|
|
7
|
-
data: Record<string, unknown>;
|
|
8
|
-
content: Record<string, Record<string, unknown>>;
|
|
9
|
-
}
|
|
10
|
-
interface ResolveBlockDataOptions {
|
|
11
|
-
page: CmssyPageData | null;
|
|
12
|
-
blocks: BlockDefinition[];
|
|
13
|
-
locale: string;
|
|
14
|
-
defaultLocale: string;
|
|
15
|
-
enabledLocales?: string[];
|
|
16
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
17
|
-
isPreview?: boolean;
|
|
18
|
-
config?: CmssyClientConfig;
|
|
19
|
-
appContext?: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
22
|
-
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
23
|
-
interface ResolveLayoutBlockDataOptions {
|
|
24
|
-
groups: CmssyLayoutGroup[];
|
|
25
|
-
blocks: BlockDefinition[];
|
|
26
|
-
position: string;
|
|
27
|
-
locale: string;
|
|
28
|
-
defaultLocale: string;
|
|
29
|
-
enabledLocales?: string[];
|
|
30
|
-
forms?: Record<string, CmssyFormDefinition>;
|
|
31
|
-
isPreview?: boolean;
|
|
32
|
-
config?: CmssyClientConfig;
|
|
33
|
-
appContext?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
36
|
-
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
37
|
-
|
|
38
|
-
export { type EditorBlockData, type ResolveBlockDataOptions, type ResolveLayoutBlockDataOptions, resolveBlockData, resolveEditorBlockData, resolveEditorLayoutBlockData, resolveLayoutBlockData };
|
package/dist/internal-server.js
CHANGED
|
@@ -135,6 +135,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
135
135
|
groups,
|
|
136
136
|
blocks,
|
|
137
137
|
position,
|
|
138
|
+
page,
|
|
138
139
|
locale,
|
|
139
140
|
defaultLocale,
|
|
140
141
|
enabledLocales,
|
|
@@ -153,7 +154,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
153
154
|
enabledLocales,
|
|
154
155
|
isPreview,
|
|
155
156
|
forms,
|
|
156
|
-
{ app: appContext }
|
|
157
|
+
{ page, app: appContext }
|
|
157
158
|
);
|
|
158
159
|
const resolved = await resolveBlocks(
|
|
159
160
|
layoutBlocks,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/react",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"vitest": "^2.1.0"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@cmssy/types": "0.
|
|
100
|
-
"@cmssy/core": "14.
|
|
99
|
+
"@cmssy/types": "0.39.0",
|
|
100
|
+
"@cmssy/core": "14.1.0"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"build": "tsup",
|