@cmssy/next 0.1.4 → 0.1.6

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/index.cjs CHANGED
@@ -83,12 +83,19 @@ function createCmssyPage(config, blocks, options) {
83
83
  if (!page) {
84
84
  navigation.notFound();
85
85
  }
86
- if (editMode) {
87
- if (!Editor) {
88
- throw new Error(
89
- 'cmssy: edit mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
90
- );
91
- }
86
+ if (editMode && !Editor) {
87
+ throw new Error(
88
+ 'cmssy: edit mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
89
+ );
90
+ }
91
+ const resolvedForms = await react.resolveForms(
92
+ clientConfig,
93
+ page.blocks,
94
+ locale,
95
+ defaultLocale
96
+ );
97
+ const forms = Object.keys(resolvedForms).length > 0 ? resolvedForms : void 0;
98
+ if (editMode && Editor) {
92
99
  const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
93
100
  return /* @__PURE__ */ jsxRuntime.jsx(
94
101
  Editor,
@@ -97,7 +104,8 @@ function createCmssyPage(config, blocks, options) {
97
104
  locale,
98
105
  defaultLocale,
99
106
  enabledLocales: config.enabledLocales,
100
- edit: { editorOrigin: bridgeOrigin }
107
+ edit: { editorOrigin: bridgeOrigin },
108
+ forms
101
109
  }
102
110
  );
103
111
  }
@@ -108,7 +116,8 @@ function createCmssyPage(config, blocks, options) {
108
116
  blocks,
109
117
  locale,
110
118
  defaultLocale,
111
- enabledLocales: config.enabledLocales
119
+ enabledLocales: config.enabledLocales,
120
+ forms
112
121
  }
113
122
  );
114
123
  };
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentType } from 'react';
3
- import { CmssyPageData, BlockDefinition } from '@cmssy/react';
3
+ import { CmssyPageData, CmssyFormDefinition, BlockDefinition } from '@cmssy/react';
4
4
  import { EditBridgeConfig } from '@cmssy/react/client';
5
5
 
6
6
  interface CmssyNextConfig {
@@ -20,6 +20,7 @@ interface CmssyEditorProps {
20
20
  defaultLocale: string;
21
21
  enabledLocales?: string[];
22
22
  edit: EditBridgeConfig;
23
+ forms?: Record<string, CmssyFormDefinition>;
23
24
  }
24
25
  interface CreateCmssyPageOptions {
25
26
  editor?: ComponentType<CmssyEditorProps>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentType } from 'react';
3
- import { CmssyPageData, BlockDefinition } from '@cmssy/react';
3
+ import { CmssyPageData, CmssyFormDefinition, BlockDefinition } from '@cmssy/react';
4
4
  import { EditBridgeConfig } from '@cmssy/react/client';
5
5
 
6
6
  interface CmssyNextConfig {
@@ -20,6 +20,7 @@ interface CmssyEditorProps {
20
20
  defaultLocale: string;
21
21
  enabledLocales?: string[];
22
22
  edit: EditBridgeConfig;
23
+ forms?: Record<string, CmssyFormDefinition>;
23
24
  }
24
25
  interface CreateCmssyPageOptions {
25
26
  editor?: ComponentType<CmssyEditorProps>;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { draftMode, headers } from 'next/headers';
2
2
  import { notFound, redirect } from 'next/navigation';
3
- import { fetchPage, CmssyServerPage } from '@cmssy/react';
3
+ import { fetchPage, resolveForms, CmssyServerPage } from '@cmssy/react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import { createHash, timingSafeEqual } from 'crypto';
6
6
 
@@ -81,12 +81,19 @@ function createCmssyPage(config, blocks, options) {
81
81
  if (!page) {
82
82
  notFound();
83
83
  }
84
- if (editMode) {
85
- if (!Editor) {
86
- throw new Error(
87
- 'cmssy: edit mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
88
- );
89
- }
84
+ if (editMode && !Editor) {
85
+ throw new Error(
86
+ 'cmssy: edit mode requires options.editor \u2014 pass a "use client" editor that imports your blocks and renders <CmssyEditablePage blocks={blocks} \u2026 />'
87
+ );
88
+ }
89
+ const resolvedForms = await resolveForms(
90
+ clientConfig,
91
+ page.blocks,
92
+ locale,
93
+ defaultLocale
94
+ );
95
+ const forms = Object.keys(resolvedForms).length > 0 ? resolvedForms : void 0;
96
+ if (editMode && Editor) {
90
97
  const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
91
98
  return /* @__PURE__ */ jsx(
92
99
  Editor,
@@ -95,7 +102,8 @@ function createCmssyPage(config, blocks, options) {
95
102
  locale,
96
103
  defaultLocale,
97
104
  enabledLocales: config.enabledLocales,
98
- edit: { editorOrigin: bridgeOrigin }
105
+ edit: { editorOrigin: bridgeOrigin },
106
+ forms
99
107
  }
100
108
  );
101
109
  }
@@ -106,7 +114,8 @@ function createCmssyPage(config, blocks, options) {
106
114
  blocks,
107
115
  locale,
108
116
  defaultLocale,
109
- enabledLocales: config.enabledLocales
117
+ enabledLocales: config.enabledLocales,
118
+ forms
110
119
  }
111
120
  );
112
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -36,7 +36,7 @@
36
36
  "dist"
37
37
  ],
38
38
  "peerDependencies": {
39
- "@cmssy/react": "^0.1.4",
39
+ "@cmssy/react": "^0.1.6",
40
40
  "next": ">=15",
41
41
  "react": "^18.2.0 || ^19.0.0",
42
42
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -49,7 +49,7 @@
49
49
  "tsup": "^8.3.0",
50
50
  "typescript": "^5.6.0",
51
51
  "vitest": "^2.1.0",
52
- "@cmssy/react": "0.1.4"
52
+ "@cmssy/react": "0.1.6"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsup",