@cntrl-site/sdk-nextjs 1.9.55-2 → 1.9.55-3

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.
@@ -37,7 +37,9 @@ const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
37
37
  const layoutParameters = effectiveLayout ? (_e = item.layoutParams[effectiveLayout]) === null || _e === void 0 ? void 0 : _e.parameters : undefined;
38
38
  const commonParameters = item.commonParams.parameters;
39
39
  const parameters = layoutParameters ? Object.assign(Object.assign({}, layoutParameters), { settings: Object.assign(Object.assign({}, layoutParameters.settings), commonParameters === null || commonParameters === void 0 ? void 0 : commonParameters.settings) }) : undefined;
40
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_f = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _f !== void 0 ? _f : 'none' }), children: parameters && Element && ((0, jsx_runtime_1.jsx)(Element, Object.assign({ metadata: {
40
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined
41
+ ? { opacity: layout == null ? 0 : opacity }
42
+ : layout == null ? { opacity: 0 } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_f = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _f !== void 0 ? _f : 'none' }), children: parameters && Element && ((0, jsx_runtime_1.jsx)(Element, Object.assign({ metadata: {
41
43
  itemId: item.id,
42
44
  submitUrl: sdk.getSubmitUrl(commonParameters === null || commonParameters === void 0 ? void 0 : commonParameters.pluginConfigId)
43
45
  }, portalId: "component-portal", content: item.commonParams.content }, parameters))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
@@ -27,7 +27,7 @@ class CntrlSdkContext {
27
27
  const resolvers = sections.map(section => {
28
28
  const resolver = section.name ? this.customSections.getResolver(section.name) : undefined;
29
29
  if (!resolver)
30
- return;
30
+ return undefined;
31
31
  return {
32
32
  name: section.name,
33
33
  resolver
@@ -36,8 +36,11 @@ class CntrlSdkContext {
36
36
  return Object.fromEntries(yield Promise.all(resolvers.map(({ name, resolver }) => __awaiter(this, void 0, void 0, function* () { return [name, yield resolver()]; }))));
37
37
  });
38
38
  }
39
- init({ project, article, customComponents }) {
39
+ init({ project, article, publicApiBase, customComponents }) {
40
40
  this._projectId = project.id;
41
+ if (publicApiBase) {
42
+ this._publicApiBase = publicApiBase;
43
+ }
41
44
  this.setLayouts(project.layouts);
42
45
  this.setComponents(components_1.components);
43
46
  if (customComponents) {
@@ -52,9 +55,6 @@ class CntrlSdkContext {
52
55
  get projectId() {
53
56
  return this._projectId;
54
57
  }
55
- get publicApiBase() {
56
- return this._publicApiBase;
57
- }
58
58
  getSubmitUrl(pluginConfigId) {
59
59
  if (!this._publicApiBase || !this._projectId || !pluginConfigId)
60
60
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.9.55-2",
3
+ "version": "1.9.55-3",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "@cntrl-site/color": "^1.0.0",
34
34
  "@cntrl-site/components": "^1.0.1-alpha.16",
35
35
  "@cntrl-site/effects": "^1.4.0",
36
- "@cntrl-site/sdk": "^1.26.1",
36
+ "@cntrl-site/sdk": "^1.26.2",
37
37
  "@types/vimeo__player": "^2.18.0",
38
38
  "@vimeo/player": "^2.25.0",
39
39
  "html-react-parser": "^3.0.1",
@@ -19,6 +19,7 @@ export interface PageProps {
19
19
  meta: Meta;
20
20
  keyframes: KeyframeAny[];
21
21
  sectionData: Record<SectionName, any>;
22
+ publicApiBase?: string;
22
23
  customComponentBundles?: CustomComponentBundlesData;
23
24
  }
24
25
 
@@ -41,7 +41,10 @@ export const ComponentItem: FC<ItemProps<TComponentItem>> = ({ item, sectionId,
41
41
  className={`custom-component-${item.id}`}
42
42
  ref={setRef}
43
43
  style={{
44
- ...(opacity !== undefined ? { opacity } : {}),
44
+ // preventing layout shift while supporting SSG for proper SEO
45
+ ...(opacity !== undefined
46
+ ? { opacity: layout == null ? 0 : opacity }
47
+ : layout == null ? { opacity: 0 } : {}),
45
48
  ...(angle !== undefined ? { transform: `rotate(${angle}deg)` } : {}),
46
49
  ...(blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {}),
47
50
  willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset',
@@ -6,6 +6,7 @@ import { CustomSectionRegistry } from './CustomSectionRegistry';
6
6
  interface SdkContextInitProps {
7
7
  project: Project;
8
8
  article: Article;
9
+ publicApiBase?: string;
9
10
  customComponents?: Map<string, TComponent>;
10
11
  }
11
12
 
@@ -25,7 +26,7 @@ export class CntrlSdkContext {
25
26
  async resolveSectionData(sections: Section[]): Promise<Record<string, any>> {
26
27
  const resolvers = sections.map(section => {
27
28
  const resolver = section.name ? this.customSections.getResolver(section.name) : undefined;
28
- if (!resolver) return;
29
+ if (!resolver) return undefined;
29
30
  return {
30
31
  name: section.name,
31
32
  resolver
@@ -36,8 +37,11 @@ export class CntrlSdkContext {
36
37
  );
37
38
  }
38
39
 
39
- init({ project, article, customComponents }: SdkContextInitProps) {
40
+ init({ project, article, publicApiBase, customComponents }: SdkContextInitProps) {
40
41
  this._projectId = project.id;
42
+ if (publicApiBase) {
43
+ this._publicApiBase = publicApiBase;
44
+ }
41
45
  this.setLayouts(project.layouts);
42
46
  this.setComponents(components);
43
47
  if (customComponents) {
@@ -55,10 +59,6 @@ export class CntrlSdkContext {
55
59
  return this._projectId;
56
60
  }
57
61
 
58
- get publicApiBase(): string | undefined {
59
- return this._publicApiBase;
60
- }
61
-
62
62
  getSubmitUrl(pluginConfigId: string | undefined): string | undefined {
63
63
  if (!this._publicApiBase || !this._projectId || !pluginConfigId) return undefined;
64
64
  return `${this._publicApiBase}/projects/${this._projectId}/forms/${pluginConfigId}/submit`;