@cmssy/react 0.17.1 → 1.0.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/README.md +9 -2
- package/dist/client.cjs +17 -3
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +17 -3
- package/dist/{commerce-queries-CxUeiT52.d.cts → commerce-queries-BReujpXO.d.cts} +4 -4
- package/dist/{commerce-queries-CxUeiT52.d.ts → commerce-queries-BReujpXO.d.ts} +4 -4
- package/dist/index.cjs +39 -23
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +39 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,7 +39,10 @@ the CMS at runtime.
|
|
|
39
39
|
```tsx
|
|
40
40
|
import { fetchPage, CmssyServerPage } from "@cmssy/react";
|
|
41
41
|
|
|
42
|
-
const page = await fetchPage(
|
|
42
|
+
const page = await fetchPage(
|
|
43
|
+
{ org: "acme-org", workspaceSlug: "acme" },
|
|
44
|
+
pathSegments,
|
|
45
|
+
);
|
|
43
46
|
|
|
44
47
|
return <CmssyServerPage page={page} blocks={blocks} locale="en" />;
|
|
45
48
|
```
|
|
@@ -62,7 +65,11 @@ const cmssy = createCmssyClient({ org: "acme-org", workspaceSlug: "acme" });
|
|
|
62
65
|
await cmssy.query(MY_QUERY, vars);
|
|
63
66
|
|
|
64
67
|
// workspace-scoped (auto x-workspace-id header + $workspaceId var)
|
|
65
|
-
const {
|
|
68
|
+
const {
|
|
69
|
+
public: {
|
|
70
|
+
model: { records },
|
|
71
|
+
},
|
|
72
|
+
} = await cmssy.queryScoped(MODEL_RECORDS_QUERY, {
|
|
66
73
|
modelSlug: "posts",
|
|
67
74
|
});
|
|
68
75
|
```
|
package/dist/client.cjs
CHANGED
|
@@ -145,6 +145,18 @@ function collectRects() {
|
|
|
145
145
|
}
|
|
146
146
|
return rects;
|
|
147
147
|
}
|
|
148
|
+
function findBlockEl(blockId) {
|
|
149
|
+
if (typeof document === "undefined") return null;
|
|
150
|
+
const escaped = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(blockId) : blockId.replace(/["\\]/g, "\\$&");
|
|
151
|
+
try {
|
|
152
|
+
return document.querySelector(`[data-block-id="${escaped}"]`);
|
|
153
|
+
} catch {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function prefersReducedMotion() {
|
|
158
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
159
|
+
}
|
|
148
160
|
function collectLayoutBlocks(rects, pageIds) {
|
|
149
161
|
const out = [];
|
|
150
162
|
if (typeof document === "undefined") return out;
|
|
@@ -253,6 +265,10 @@ function useEditBridge(page, config) {
|
|
|
253
265
|
} else if (message.type === "cmssy:select") {
|
|
254
266
|
setSelected(message.blockId);
|
|
255
267
|
selectedIdRef.current = message.blockId;
|
|
268
|
+
findBlockEl(message.blockId)?.scrollIntoView({
|
|
269
|
+
behavior: prefersReducedMotion() ? "auto" : "smooth",
|
|
270
|
+
block: "nearest"
|
|
271
|
+
});
|
|
256
272
|
} else if (message.type === "cmssy:insert") {
|
|
257
273
|
setInserted((prev) => {
|
|
258
274
|
const next = prev.filter((b) => b.blockId !== message.blockId);
|
|
@@ -305,9 +321,7 @@ function useEditBridge(page, config) {
|
|
|
305
321
|
boundsRaf = 0;
|
|
306
322
|
const id = selectedIdRef.current;
|
|
307
323
|
if (!id) return;
|
|
308
|
-
const el =
|
|
309
|
-
`[data-block-id="${id.replace(/["\\]/g, "\\$&")}"]`
|
|
310
|
-
);
|
|
324
|
+
const el = findBlockEl(id);
|
|
311
325
|
if (!el) return;
|
|
312
326
|
const r = el.getBoundingClientRect();
|
|
313
327
|
try {
|
package/dist/client.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-
|
|
3
|
-
export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-
|
|
2
|
+
import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-BReujpXO.cjs';
|
|
3
|
+
export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-BReujpXO.cjs';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import '@cmssy/types';
|
|
6
6
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-
|
|
3
|
-
export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-
|
|
2
|
+
import { B as BlockSchema, a as BlockMeta, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, d as CmssyLayoutGroup, e as CmssyLocaleContext, f as CmssyCart, g as CmssyOrder, h as CmssyProduct } from './commerce-queries-BReujpXO.js';
|
|
3
|
+
export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-BReujpXO.js';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import '@cmssy/types';
|
|
6
6
|
|
package/dist/client.js
CHANGED
|
@@ -143,6 +143,18 @@ function collectRects() {
|
|
|
143
143
|
}
|
|
144
144
|
return rects;
|
|
145
145
|
}
|
|
146
|
+
function findBlockEl(blockId) {
|
|
147
|
+
if (typeof document === "undefined") return null;
|
|
148
|
+
const escaped = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(blockId) : blockId.replace(/["\\]/g, "\\$&");
|
|
149
|
+
try {
|
|
150
|
+
return document.querySelector(`[data-block-id="${escaped}"]`);
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function prefersReducedMotion() {
|
|
156
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
157
|
+
}
|
|
146
158
|
function collectLayoutBlocks(rects, pageIds) {
|
|
147
159
|
const out = [];
|
|
148
160
|
if (typeof document === "undefined") return out;
|
|
@@ -251,6 +263,10 @@ function useEditBridge(page, config) {
|
|
|
251
263
|
} else if (message.type === "cmssy:select") {
|
|
252
264
|
setSelected(message.blockId);
|
|
253
265
|
selectedIdRef.current = message.blockId;
|
|
266
|
+
findBlockEl(message.blockId)?.scrollIntoView({
|
|
267
|
+
behavior: prefersReducedMotion() ? "auto" : "smooth",
|
|
268
|
+
block: "nearest"
|
|
269
|
+
});
|
|
254
270
|
} else if (message.type === "cmssy:insert") {
|
|
255
271
|
setInserted((prev) => {
|
|
256
272
|
const next = prev.filter((b) => b.blockId !== message.blockId);
|
|
@@ -303,9 +319,7 @@ function useEditBridge(page, config) {
|
|
|
303
319
|
boundsRaf = 0;
|
|
304
320
|
const id = selectedIdRef.current;
|
|
305
321
|
if (!id) return;
|
|
306
|
-
const el =
|
|
307
|
-
`[data-block-id="${id.replace(/["\\]/g, "\\$&")}"]`
|
|
308
|
-
);
|
|
322
|
+
const el = findBlockEl(id);
|
|
309
323
|
if (!el) return;
|
|
310
324
|
const r = el.getBoundingClientRect();
|
|
311
325
|
try {
|
|
@@ -131,8 +131,8 @@ interface CmssyRecordList {
|
|
|
131
131
|
total: number;
|
|
132
132
|
hasMore: boolean;
|
|
133
133
|
}
|
|
134
|
-
declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n
|
|
135
|
-
declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {\n
|
|
134
|
+
declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
|
|
135
|
+
declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {\n items { id modelId data status createdAt updatedAt }\n total\n hasMore\n }\n }\n }\n}";
|
|
136
136
|
interface CmssyFormField {
|
|
137
137
|
id: string;
|
|
138
138
|
name: string;
|
|
@@ -177,8 +177,8 @@ interface SubmitFormInput {
|
|
|
177
177
|
data: Record<string, unknown>;
|
|
178
178
|
website?: string;
|
|
179
179
|
}
|
|
180
|
-
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n
|
|
181
|
-
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n
|
|
180
|
+
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
|
|
181
|
+
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
|
|
182
182
|
|
|
183
183
|
interface CmssyLocaleContext {
|
|
184
184
|
current: string;
|
|
@@ -131,8 +131,8 @@ interface CmssyRecordList {
|
|
|
131
131
|
total: number;
|
|
132
132
|
hasMore: boolean;
|
|
133
133
|
}
|
|
134
|
-
declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n
|
|
135
|
-
declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {\n
|
|
134
|
+
declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
|
|
135
|
+
declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {\n items { id modelId data status createdAt updatedAt }\n total\n hasMore\n }\n }\n }\n}";
|
|
136
136
|
interface CmssyFormField {
|
|
137
137
|
id: string;
|
|
138
138
|
name: string;
|
|
@@ -177,8 +177,8 @@ interface SubmitFormInput {
|
|
|
177
177
|
data: Record<string, unknown>;
|
|
178
178
|
website?: string;
|
|
179
179
|
}
|
|
180
|
-
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n
|
|
181
|
-
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n
|
|
180
|
+
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
|
|
181
|
+
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
|
|
182
182
|
|
|
183
183
|
interface CmssyLocaleContext {
|
|
184
184
|
current: string;
|
package/dist/index.cjs
CHANGED
|
@@ -678,38 +678,54 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
678
678
|
}
|
|
679
679
|
}`;
|
|
680
680
|
var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String!) {
|
|
681
|
-
|
|
682
|
-
|
|
681
|
+
public {
|
|
682
|
+
model {
|
|
683
|
+
definitions(workspaceId: $workspaceId) {
|
|
684
|
+
id name slug description icon color displayField recordCount
|
|
685
|
+
}
|
|
686
|
+
}
|
|
683
687
|
}
|
|
684
688
|
}`;
|
|
685
689
|
var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
+
public {
|
|
691
|
+
model {
|
|
692
|
+
records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {
|
|
693
|
+
items { id modelId data status createdAt updatedAt }
|
|
694
|
+
total
|
|
695
|
+
hasMore
|
|
696
|
+
}
|
|
697
|
+
}
|
|
690
698
|
}
|
|
691
699
|
}`;
|
|
692
700
|
var FORM_QUERY = `query PublicForm($formId: ID!) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
701
|
+
public {
|
|
702
|
+
form {
|
|
703
|
+
get(formId: $formId) {
|
|
704
|
+
id
|
|
705
|
+
name
|
|
706
|
+
slug
|
|
707
|
+
description
|
|
708
|
+
fields {
|
|
709
|
+
id name fieldType label placeholder helpText
|
|
710
|
+
defaultValue width order showWhen requiredWhen
|
|
711
|
+
options { value label disabled }
|
|
712
|
+
validation { required minLength maxLength minValue maxValue pattern customMessage }
|
|
713
|
+
}
|
|
714
|
+
settings {
|
|
715
|
+
actionType submitButtonLabel successMessage errorMessage
|
|
716
|
+
redirectUrl requireLogin enableCaptcha
|
|
717
|
+
}
|
|
718
|
+
}
|
|
707
719
|
}
|
|
708
720
|
}
|
|
709
721
|
}`;
|
|
710
722
|
var SUBMIT_FORM_MUTATION = `mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {
|
|
711
|
-
|
|
712
|
-
|
|
723
|
+
public {
|
|
724
|
+
form {
|
|
725
|
+
submit(formId: $formId, input: $input) {
|
|
726
|
+
success message submissionId redirectUrl accessToken customer
|
|
727
|
+
}
|
|
728
|
+
}
|
|
713
729
|
}
|
|
714
730
|
}`;
|
|
715
731
|
|
|
@@ -804,7 +820,7 @@ async function resolveForms(config, blocks, locale, defaultLocale, options) {
|
|
|
804
820
|
ids.map(async (id) => {
|
|
805
821
|
try {
|
|
806
822
|
const data = await client.queryScoped(FORM_QUERY, { formId: id }, options);
|
|
807
|
-
return [id, data.
|
|
823
|
+
return [id, data.public.form.get];
|
|
808
824
|
} catch (err) {
|
|
809
825
|
if (typeof console !== "undefined") {
|
|
810
826
|
console.warn(`[cmssy] failed to resolve form ${id}`, err);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, n as CmssyBlockAuthContext, o as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, p as FetchLike, q as CmssyClientConfig, r as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, s as BlockMap, t as CmssyBlockContext } from './commerce-queries-
|
|
2
|
-
export { a as BlockMeta, u as BlockRect, B as BlockSchema, v as BoundsMessage, w as BuildBlockContextExtra, x as ClickMessage, y as CmssyBlockMember, z as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, D as CmssyFormField, G as CmssyFormSettings, H as CmssyFormSubmitResponse, I as CmssyLocalizedValue, J as CmssyModelDefinition, K as CmssyModelRecord, g as CmssyOrder, L as CmssyPageMeta, M as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, N as CmssyRecordList, O as DEFAULT_CMSSY_API_URL, P as FORM_QUERY, Q as FetchLikeResponse, S as FetchPageOptions, T as MODEL_DEFINITIONS_QUERY, U as MODEL_RECORDS_QUERY, V as PROTOCOL_VERSION, W as ParentReadyMessage, X as PatchMessage, Y as RawLayoutBlock, Z as ReadyMessage, _ as SITE_CONFIG_QUERY, $ as SUBMIT_FORM_MUTATION, a0 as SelectMessage, a1 as SubmitFormInput, a2 as blocksToMeta, a3 as blocksToSchemas, a4 as buildBlockContext, a5 as buildBlockMap, a6 as defineBlock, a7 as fetchLayouts, a8 as fetchPage, a9 as fetchPageById, aa as fetchPageMeta, ab as fetchPages, ac as isProtocolCompatible, ad as normalizeSlug, ae as resolveApiUrl, af as resolvePublicUrl } from './commerce-queries-
|
|
1
|
+
import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, n as CmssyBlockAuthContext, o as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, p as FetchLike, q as CmssyClientConfig, r as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, s as BlockMap, t as CmssyBlockContext } from './commerce-queries-BReujpXO.cjs';
|
|
2
|
+
export { a as BlockMeta, u as BlockRect, B as BlockSchema, v as BoundsMessage, w as BuildBlockContextExtra, x as ClickMessage, y as CmssyBlockMember, z as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, D as CmssyFormField, G as CmssyFormSettings, H as CmssyFormSubmitResponse, I as CmssyLocalizedValue, J as CmssyModelDefinition, K as CmssyModelRecord, g as CmssyOrder, L as CmssyPageMeta, M as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, N as CmssyRecordList, O as DEFAULT_CMSSY_API_URL, P as FORM_QUERY, Q as FetchLikeResponse, S as FetchPageOptions, T as MODEL_DEFINITIONS_QUERY, U as MODEL_RECORDS_QUERY, V as PROTOCOL_VERSION, W as ParentReadyMessage, X as PatchMessage, Y as RawLayoutBlock, Z as ReadyMessage, _ as SITE_CONFIG_QUERY, $ as SUBMIT_FORM_MUTATION, a0 as SelectMessage, a1 as SubmitFormInput, a2 as blocksToMeta, a3 as blocksToSchemas, a4 as buildBlockContext, a5 as buildBlockMap, a6 as defineBlock, a7 as fetchLayouts, a8 as fetchPage, a9 as fetchPageById, aa as fetchPageMeta, ab as fetchPages, ac as isProtocolCompatible, ad as normalizeSlug, ae as resolveApiUrl, af as resolvePublicUrl } from './commerce-queries-BReujpXO.cjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldType, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
5
5
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, n as CmssyBlockAuthContext, o as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, p as FetchLike, q as CmssyClientConfig, r as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, s as BlockMap, t as CmssyBlockContext } from './commerce-queries-
|
|
2
|
-
export { a as BlockMeta, u as BlockRect, B as BlockSchema, v as BoundsMessage, w as BuildBlockContextExtra, x as ClickMessage, y as CmssyBlockMember, z as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, D as CmssyFormField, G as CmssyFormSettings, H as CmssyFormSubmitResponse, I as CmssyLocalizedValue, J as CmssyModelDefinition, K as CmssyModelRecord, g as CmssyOrder, L as CmssyPageMeta, M as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, N as CmssyRecordList, O as DEFAULT_CMSSY_API_URL, P as FORM_QUERY, Q as FetchLikeResponse, S as FetchPageOptions, T as MODEL_DEFINITIONS_QUERY, U as MODEL_RECORDS_QUERY, V as PROTOCOL_VERSION, W as ParentReadyMessage, X as PatchMessage, Y as RawLayoutBlock, Z as ReadyMessage, _ as SITE_CONFIG_QUERY, $ as SUBMIT_FORM_MUTATION, a0 as SelectMessage, a1 as SubmitFormInput, a2 as blocksToMeta, a3 as blocksToSchemas, a4 as buildBlockContext, a5 as buildBlockMap, a6 as defineBlock, a7 as fetchLayouts, a8 as fetchPage, a9 as fetchPageById, aa as fetchPageMeta, ab as fetchPages, ac as isProtocolCompatible, ad as normalizeSlug, ae as resolveApiUrl, af as resolvePublicUrl } from './commerce-queries-
|
|
1
|
+
import { F as FieldDefinition, C as CmssyPageData, b as BlockDefinition, c as CmssyFormDefinition, n as CmssyBlockAuthContext, o as CmssyBlockWorkspace, d as CmssyLayoutGroup, E as EditorToAppMessage, A as AppToEditorMessage, p as FetchLike, q as CmssyClientConfig, r as CmssySiteConfig, R as RawBlock, e as CmssyLocaleContext, s as BlockMap, t as CmssyBlockContext } from './commerce-queries-BReujpXO.js';
|
|
2
|
+
export { a as BlockMeta, u as BlockRect, B as BlockSchema, v as BoundsMessage, w as BuildBlockContextExtra, x as ClickMessage, y as CmssyBlockMember, z as CmssyBranding, f as CmssyCart, i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, D as CmssyFormField, G as CmssyFormSettings, H as CmssyFormSubmitResponse, I as CmssyLocalizedValue, J as CmssyModelDefinition, K as CmssyModelRecord, g as CmssyOrder, L as CmssyPageMeta, M as CmssyPageSummary, h as CmssyProduct, m as CmssyProductVariant, N as CmssyRecordList, O as DEFAULT_CMSSY_API_URL, P as FORM_QUERY, Q as FetchLikeResponse, S as FetchPageOptions, T as MODEL_DEFINITIONS_QUERY, U as MODEL_RECORDS_QUERY, V as PROTOCOL_VERSION, W as ParentReadyMessage, X as PatchMessage, Y as RawLayoutBlock, Z as ReadyMessage, _ as SITE_CONFIG_QUERY, $ as SUBMIT_FORM_MUTATION, a0 as SelectMessage, a1 as SubmitFormInput, a2 as blocksToMeta, a3 as blocksToSchemas, a4 as buildBlockContext, a5 as buildBlockMap, a6 as defineBlock, a7 as fetchLayouts, a8 as fetchPage, a9 as fetchPageById, aa as fetchPageMeta, ab as fetchPages, ac as isProtocolCompatible, ad as normalizeSlug, ae as resolveApiUrl, af as resolvePublicUrl } from './commerce-queries-BReujpXO.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldType, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
5
5
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -676,38 +676,54 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
676
676
|
}
|
|
677
677
|
}`;
|
|
678
678
|
var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String!) {
|
|
679
|
-
|
|
680
|
-
|
|
679
|
+
public {
|
|
680
|
+
model {
|
|
681
|
+
definitions(workspaceId: $workspaceId) {
|
|
682
|
+
id name slug description icon color displayField recordCount
|
|
683
|
+
}
|
|
684
|
+
}
|
|
681
685
|
}
|
|
682
686
|
}`;
|
|
683
687
|
var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $limit: Int, $offset: Int, $populate: [String!]) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
+
public {
|
|
689
|
+
model {
|
|
690
|
+
records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, limit: $limit, offset: $offset, populate: $populate) {
|
|
691
|
+
items { id modelId data status createdAt updatedAt }
|
|
692
|
+
total
|
|
693
|
+
hasMore
|
|
694
|
+
}
|
|
695
|
+
}
|
|
688
696
|
}
|
|
689
697
|
}`;
|
|
690
698
|
var FORM_QUERY = `query PublicForm($formId: ID!) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
699
|
+
public {
|
|
700
|
+
form {
|
|
701
|
+
get(formId: $formId) {
|
|
702
|
+
id
|
|
703
|
+
name
|
|
704
|
+
slug
|
|
705
|
+
description
|
|
706
|
+
fields {
|
|
707
|
+
id name fieldType label placeholder helpText
|
|
708
|
+
defaultValue width order showWhen requiredWhen
|
|
709
|
+
options { value label disabled }
|
|
710
|
+
validation { required minLength maxLength minValue maxValue pattern customMessage }
|
|
711
|
+
}
|
|
712
|
+
settings {
|
|
713
|
+
actionType submitButtonLabel successMessage errorMessage
|
|
714
|
+
redirectUrl requireLogin enableCaptcha
|
|
715
|
+
}
|
|
716
|
+
}
|
|
705
717
|
}
|
|
706
718
|
}
|
|
707
719
|
}`;
|
|
708
720
|
var SUBMIT_FORM_MUTATION = `mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {
|
|
709
|
-
|
|
710
|
-
|
|
721
|
+
public {
|
|
722
|
+
form {
|
|
723
|
+
submit(formId: $formId, input: $input) {
|
|
724
|
+
success message submissionId redirectUrl accessToken customer
|
|
725
|
+
}
|
|
726
|
+
}
|
|
711
727
|
}
|
|
712
728
|
}`;
|
|
713
729
|
|
|
@@ -802,7 +818,7 @@ async function resolveForms(config, blocks, locale, defaultLocale, options) {
|
|
|
802
818
|
ids.map(async (id) => {
|
|
803
819
|
try {
|
|
804
820
|
const data = await client.queryScoped(FORM_QUERY, { formId: id }, options);
|
|
805
|
-
return [id, data.
|
|
821
|
+
return [id, data.public.form.get];
|
|
806
822
|
} catch (err) {
|
|
807
823
|
if (typeof console !== "undefined") {
|
|
808
824
|
console.warn(`[cmssy] failed to resolve form ${id}`, err);
|