@cmssy/react 0.11.0 → 0.13.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 CHANGED
@@ -485,6 +485,13 @@ function getBlockContentForLanguage(content, locale, defaultLocale = "en", avail
485
485
  const chosen = localeMap[locale] ?? localeMap[defaultLocale] ?? localeMap[fallbackKey];
486
486
  return { ...nonTranslatable, ...chosen };
487
487
  }
488
+ function mergeBlockValues(content, style, advanced) {
489
+ return {
490
+ ...content,
491
+ ...isPlainObject(style) ? style : {},
492
+ ...isPlainObject(advanced) ? advanced : {}
493
+ };
494
+ }
488
495
  var WARN_CAP = 256;
489
496
  var warned = /* @__PURE__ */ new Set();
490
497
  function UnknownBlock({ type }) {
@@ -507,7 +514,8 @@ function CmssyBlock({
507
514
  }) {
508
515
  const Component = Object.hasOwn(blockMap, block.type) ? blockMap[block.type] : void 0;
509
516
  const base = getBlockContentForLanguage(block.content, locale, defaultLocale);
510
- const content = patchedContent ? { ...base, ...patchedContent } : base;
517
+ const resolved = patchedContent ? { ...base, ...patchedContent } : base;
518
+ const content = mergeBlockValues(resolved, block.style, block.advanced);
511
519
  return /* @__PURE__ */ jsxRuntime.jsx(
512
520
  "div",
513
521
  {
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-DXT2RQlm.cjs';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-DXT2RQlm.cjs';
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-ClCU8FZN.cjs';
3
+ export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-ClCU8FZN.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-DXT2RQlm.js';
3
- export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-DXT2RQlm.js';
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-ClCU8FZN.js';
3
+ export { i as CmssyCartDiscount, j as CmssyCartItem, k as CmssyCartItemSnapshot, l as CmssyOrderItem, m as CmssyProductVariant } from './commerce-queries-ClCU8FZN.js';
4
4
  import { ReactNode } from 'react';
5
5
  import '@cmssy/types';
6
6
 
package/dist/client.js CHANGED
@@ -483,6 +483,13 @@ function getBlockContentForLanguage(content, locale, defaultLocale = "en", avail
483
483
  const chosen = localeMap[locale] ?? localeMap[defaultLocale] ?? localeMap[fallbackKey];
484
484
  return { ...nonTranslatable, ...chosen };
485
485
  }
486
+ function mergeBlockValues(content, style, advanced) {
487
+ return {
488
+ ...content,
489
+ ...isPlainObject(style) ? style : {},
490
+ ...isPlainObject(advanced) ? advanced : {}
491
+ };
492
+ }
486
493
  var WARN_CAP = 256;
487
494
  var warned = /* @__PURE__ */ new Set();
488
495
  function UnknownBlock({ type }) {
@@ -505,7 +512,8 @@ function CmssyBlock({
505
512
  }) {
506
513
  const Component = Object.hasOwn(blockMap, block.type) ? blockMap[block.type] : void 0;
507
514
  const base = getBlockContentForLanguage(block.content, locale, defaultLocale);
508
- const content = patchedContent ? { ...base, ...patchedContent } : base;
515
+ const resolved = patchedContent ? { ...base, ...patchedContent } : base;
516
+ const content = mergeBlockValues(resolved, block.style, block.advanced);
509
517
  return /* @__PURE__ */ jsx(
510
518
  "div",
511
519
  {
@@ -36,6 +36,8 @@ interface RawBlock {
36
36
  id: string;
37
37
  type: string;
38
38
  content: unknown;
39
+ style?: unknown;
40
+ advanced?: unknown;
39
41
  }
40
42
  interface CmssyPageData {
41
43
  id: string;
@@ -45,6 +47,8 @@ interface RawLayoutBlock {
45
47
  id: string;
46
48
  type: string;
47
49
  content: unknown;
50
+ style?: unknown;
51
+ advanced?: unknown;
48
52
  order: number;
49
53
  isActive: boolean;
50
54
  }
@@ -36,6 +36,8 @@ interface RawBlock {
36
36
  id: string;
37
37
  type: string;
38
38
  content: unknown;
39
+ style?: unknown;
40
+ advanced?: unknown;
39
41
  }
40
42
  interface CmssyPageData {
41
43
  id: string;
@@ -45,6 +47,8 @@ interface RawLayoutBlock {
45
47
  id: string;
46
48
  type: string;
47
49
  content: unknown;
50
+ style?: unknown;
51
+ advanced?: unknown;
48
52
  order: number;
49
53
  isActive: boolean;
50
54
  }
package/dist/index.cjs CHANGED
@@ -101,6 +101,13 @@ function getBlockContentForLanguage(content, locale, defaultLocale = "en", avail
101
101
  const chosen = localeMap[locale] ?? localeMap[defaultLocale] ?? localeMap[fallbackKey];
102
102
  return { ...nonTranslatable, ...chosen };
103
103
  }
104
+ function mergeBlockValues(content, style, advanced) {
105
+ return {
106
+ ...content,
107
+ ...isPlainObject(style) ? style : {},
108
+ ...isPlainObject(advanced) ? advanced : {}
109
+ };
110
+ }
104
111
 
105
112
  // src/components/block-context.ts
106
113
  function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
@@ -129,12 +136,13 @@ function UnknownBlock({ type }) {
129
136
  function renderResolvedBlock(block, map, locale, defaultLocale, options = {}) {
130
137
  const { context, data, resolvedContent, enabledLocales } = options;
131
138
  const Component = Object.hasOwn(map, block.type) ? map[block.type] : void 0;
132
- const content = resolvedContent ?? getBlockContentForLanguage(
139
+ const resolved = resolvedContent ?? getBlockContentForLanguage(
133
140
  block.content,
134
141
  locale,
135
142
  defaultLocale,
136
143
  enabledLocales?.length ? enabledLocales : void 0
137
144
  );
145
+ const content = mergeBlockValues(resolved, block.style, block.advanced);
138
146
  return /* @__PURE__ */ jsxRuntime.jsx(
139
147
  "div",
140
148
  {
@@ -312,8 +320,8 @@ var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String
312
320
  page {
313
321
  get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
314
322
  id
315
- blocks { id type content }
316
- publishedBlocks { id type content }
323
+ blocks { id type content style advanced }
324
+ publishedBlocks { id type content style advanced }
317
325
  }
318
326
  }
319
327
  }
@@ -323,8 +331,8 @@ var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: St
323
331
  page {
324
332
  get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
325
333
  id
326
- blocks { id type content }
327
- publishedBlocks { id type content }
334
+ blocks { id type content style advanced }
335
+ publishedBlocks { id type content style advanced }
328
336
  }
329
337
  }
330
338
  }
@@ -334,7 +342,7 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
334
342
  page {
335
343
  getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
336
344
  id
337
- publishedBlocks { id type content }
345
+ publishedBlocks { id type content style advanced }
338
346
  }
339
347
  }
340
348
  }
@@ -369,7 +377,7 @@ var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!
369
377
  page {
370
378
  layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
371
379
  position
372
- blocks { id type content order isActive }
380
+ blocks { id type content style advanced order isActive }
373
381
  }
374
382
  }
375
383
  }
@@ -889,7 +897,8 @@ function CmssyBlock({
889
897
  }) {
890
898
  const Component = Object.hasOwn(blockMap, block.type) ? blockMap[block.type] : void 0;
891
899
  const base = getBlockContentForLanguage(block.content, locale, defaultLocale);
892
- const content = patchedContent ? { ...base, ...patchedContent } : base;
900
+ const resolved = patchedContent ? { ...base, ...patchedContent } : base;
901
+ const content = mergeBlockValues(resolved, block.style, block.advanced);
893
902
  return /* @__PURE__ */ jsxRuntime.jsx(
894
903
  "div",
895
904
  {
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-DXT2RQlm.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 } from './commerce-queries-DXT2RQlm.cjs';
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-ClCU8FZN.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 } from './commerce-queries-ClCU8FZN.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-DXT2RQlm.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 } from './commerce-queries-DXT2RQlm.js';
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-ClCU8FZN.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 } from './commerce-queries-ClCU8FZN.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
@@ -99,6 +99,13 @@ function getBlockContentForLanguage(content, locale, defaultLocale = "en", avail
99
99
  const chosen = localeMap[locale] ?? localeMap[defaultLocale] ?? localeMap[fallbackKey];
100
100
  return { ...nonTranslatable, ...chosen };
101
101
  }
102
+ function mergeBlockValues(content, style, advanced) {
103
+ return {
104
+ ...content,
105
+ ...isPlainObject(style) ? style : {},
106
+ ...isPlainObject(advanced) ? advanced : {}
107
+ };
108
+ }
102
109
 
103
110
  // src/components/block-context.ts
104
111
  function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
@@ -127,12 +134,13 @@ function UnknownBlock({ type }) {
127
134
  function renderResolvedBlock(block, map, locale, defaultLocale, options = {}) {
128
135
  const { context, data, resolvedContent, enabledLocales } = options;
129
136
  const Component = Object.hasOwn(map, block.type) ? map[block.type] : void 0;
130
- const content = resolvedContent ?? getBlockContentForLanguage(
137
+ const resolved = resolvedContent ?? getBlockContentForLanguage(
131
138
  block.content,
132
139
  locale,
133
140
  defaultLocale,
134
141
  enabledLocales?.length ? enabledLocales : void 0
135
142
  );
143
+ const content = mergeBlockValues(resolved, block.style, block.advanced);
136
144
  return /* @__PURE__ */ jsx(
137
145
  "div",
138
146
  {
@@ -310,8 +318,8 @@ var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String
310
318
  page {
311
319
  get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
312
320
  id
313
- blocks { id type content }
314
- publishedBlocks { id type content }
321
+ blocks { id type content style advanced }
322
+ publishedBlocks { id type content style advanced }
315
323
  }
316
324
  }
317
325
  }
@@ -321,8 +329,8 @@ var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: St
321
329
  page {
322
330
  get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
323
331
  id
324
- blocks { id type content }
325
- publishedBlocks { id type content }
332
+ blocks { id type content style advanced }
333
+ publishedBlocks { id type content style advanced }
326
334
  }
327
335
  }
328
336
  }
@@ -332,7 +340,7 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
332
340
  page {
333
341
  getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
334
342
  id
335
- publishedBlocks { id type content }
343
+ publishedBlocks { id type content style advanced }
336
344
  }
337
345
  }
338
346
  }
@@ -367,7 +375,7 @@ var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!
367
375
  page {
368
376
  layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
369
377
  position
370
- blocks { id type content order isActive }
378
+ blocks { id type content style advanced order isActive }
371
379
  }
372
380
  }
373
381
  }
@@ -887,7 +895,8 @@ function CmssyBlock({
887
895
  }) {
888
896
  const Component = Object.hasOwn(blockMap, block.type) ? blockMap[block.type] : void 0;
889
897
  const base = getBlockContentForLanguage(block.content, locale, defaultLocale);
890
- const content = patchedContent ? { ...base, ...patchedContent } : base;
898
+ const resolved = patchedContent ? { ...base, ...patchedContent } : base;
899
+ const content = mergeBlockValues(resolved, block.style, block.advanced);
891
900
  return /* @__PURE__ */ jsx(
892
901
  "div",
893
902
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",