Skip to content

Commit

Permalink
Merge branch 'development' into feat/pre-binding
Browse files Browse the repository at this point in the history
  • Loading branch information
chasepoirier committed Feb 19, 2025
2 parents c21fc67 + 5800e9d commit 7b55c28
Show file tree
Hide file tree
Showing 34 changed files with 909 additions and 168 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.31.1](https://github.com/contentful/experience-builder/compare/v1.31.1-beta.0...v1.31.1) (2025-02-19)

**Note:** Version bump only for package @contentful/experience

## [1.31.0](https://github.com/contentful/experience-builder/compare/v1.31.0-beta.0...v1.31.0) (2025-02-18)

**Note:** Version bump only for package @contentful/experience
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"npmClient": "npm",
"version": "1.31.0",
"version": "1.31.1",
"command": {
"version": {
"allowBranch": ["main", "next", "development"],
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.31.1](https://github.com/contentful/experience-builder/compare/v1.31.1-beta.0...v1.31.1) (2025-02-19)

**Note:** Version bump only for package @contentful/experiences-components-react

## [1.31.0](https://github.com/contentful/experience-builder/compare/v1.31.0-beta.0...v1.31.0) (2025-02-18)

**Note:** Version bump only for package @contentful/experiences-components-react
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentful/experiences-components-react",
"version": "1.31.0",
"version": "1.31.1",
"description": "A basic set of components to use with Studio Experiences",
"homepage": "https://github.com/contentful/experience-builder/tree/next/packages/components#readme",
"repository": {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.31.1](https://github.com/contentful/experience-builder/compare/v1.31.1-beta.0...v1.31.1) (2025-02-19)

**Note:** Version bump only for package @contentful/experiences-core

## [1.31.0](https://github.com/contentful/experience-builder/compare/v1.31.0-beta.0...v1.31.0) (2025-02-18)

**Note:** Version bump only for package @contentful/experiences-core
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentful/experiences-core",
"version": "1.31.0",
"version": "1.31.1",
"description": "",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
componentDefinition.variables.title,
componentDefinition.variables.title.type,
path,
);
expect(result).toEqual(entities[0].fields.title);
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
variableType,
variableType.type,
path,
) as OptimizedBackgroundImageAsset;
expect(result.url).toEqual(assets[0].fields.file?.url + '?w=1024&fm=jpg');
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
variableType,
variableType.type,
path,
) as OptimizedBackgroundImageAsset;
expect(result.url).toEqual(assets[0].fields.file?.url + '?w=600&fm=jpg');
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
variableType,
variableType.type,
path,
) as OptimizedBackgroundImageAsset;
expect(result.url).toEqual(assets[0].fields.file?.url + '?w=1024&fm=jpg');
Expand All @@ -223,7 +223,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
variableType,
variableType.type,
path,
);
expect(result).toEqual(assets[0].fields.file?.url);
Expand All @@ -246,7 +246,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
componentDefinition.variables.description,
componentDefinition.variables.description.type,
path,
);
expect(result).toEqual({
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
componentDefinition.variables.description,
componentDefinition.variables.description.type,
path,
);
expect(result).toEqual({
Expand Down Expand Up @@ -374,7 +374,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
componentDefinition.variables.description,
componentDefinition.variables.description.type,
path,
);
expect(result).toEqual({
Expand Down Expand Up @@ -410,7 +410,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
componentDefinition.variables.description,
componentDefinition.variables.description.type,
path,
);
expect(result).toEqual({
Expand Down Expand Up @@ -448,7 +448,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
componentDefinition.variables.referencedEntry,
componentDefinition.variables.referencedEntry.type,
path,
);
// @ts-expect-error -- deep referenced entry doesn't type well
Expand All @@ -475,7 +475,7 @@ describe('transformBoundContentValue', () => {
binding,
resolveDesignValue,
variableName,
componentDefinition.variables.referencedEntries,
componentDefinition.variables.referencedEntries.type,
path,
);
// @ts-expect-error -- deep referenced entry doesn't type well
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
BoundComponentPropertyTypes,
ComponentDefinitionVariable,
ComponentDefinitionVariableType,
ComponentTreeNode,
ResolveDesignValueType,
} from '@/types';
Expand All @@ -18,13 +18,13 @@ export const transformBoundContentValue = (
binding: UnresolvedLink<'Entry' | 'Asset'>,
resolveDesignValue: ResolveDesignValueType,
variableName: string,
variableDefinition: ComponentDefinitionVariable,
variableType: ComponentDefinitionVariableType,
path: string,
): BoundComponentPropertyTypes => {
const entityOrAsset = entityStore.getEntryOrAsset(binding, path);
if (!entityOrAsset) return;

switch (variableDefinition.type) {
switch (variableType) {
case 'Media':
// If we bound a normal entry field to the media variable we just return the bound value
if (entityOrAsset.sys.type === 'Entry') {
Expand Down
4 changes: 4 additions & 0 deletions packages/create-contentful-studio-experiences/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.31.1](https://github.com/contentful/experience-builder/compare/v1.31.1-beta.0...v1.31.1) (2025-02-19)

**Note:** Version bump only for package create-contentful-studio-experiences

## [1.31.0](https://github.com/contentful/experience-builder/compare/v1.31.0-beta.0...v1.31.0) (2025-02-18)

**Note:** Version bump only for package create-contentful-studio-experiences
Expand Down
2 changes: 1 addition & 1 deletion packages/create-contentful-studio-experiences/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-contentful-studio-experiences",
"version": "1.31.0",
"version": "1.31.1",
"description": "A CLI tool to get up and running with Contentful Studio Experiences quickly",
"homepage": "https://github.com/contentful/experience-builder/tree/next/packages/create-contentful-studio-experiences#readme",
"repository": {
Expand Down
4 changes: 4 additions & 0 deletions packages/experience-builder-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.31.1](https://github.com/contentful/experience-builder/compare/v1.31.1-beta.0...v1.31.1) (2025-02-19)

**Note:** Version bump only for package @contentful/experiences-sdk-react

## [1.31.0](https://github.com/contentful/experience-builder/compare/v1.31.0-beta.0...v1.31.0) (2025-02-18)

**Note:** Version bump only for package @contentful/experiences-sdk-react
Expand Down
2 changes: 1 addition & 1 deletion packages/experience-builder-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentful/experiences-sdk-react",
"version": "1.31.0",
"version": "1.31.1",
"main": "./dist/index.js",
"module": "./dist/index.js",
"typings": "./dist/src/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const TestComponent: React.FC<{ text: string }> = (props) => {

describe('CompositionBlock', () => {
const emptyEntityStore = {
breakpoints: [],
breakpoints: [{ id: 'desktop', query: '*' }],
dataSource: {},
unboundValues: {},
usedComponents: [],
Expand Down Expand Up @@ -384,30 +384,9 @@ describe('CompositionBlock', () => {
});

it('renders nested patterns', () => {
const ssrClassName = 'cfstyles-3da2d7a8871905d8079c313b36bcf404';
const ssrClassName = 'cfstyles-51f2b708351ac3f1f5247426bd52b4b5 contentful-container';
const unboundValueKey = 'some-unbound-value-key';
const patternEntry = createAssemblyEntry();
const nestedPatternEntry = createAssemblyEntry({
id: 'nested-pattern-id',
});
const updatedExperienceEntry = {
...experienceEntry,
fields: {
...experienceEntry.fields,
usedComponents: [patternEntry, nestedPatternEntry],
unboundValues: {
[unboundValueKey]: {
value: 'Nested pattern value',
},
},
},
} as ExperienceEntry;

const entityStore = new EntityStore({
experienceEntry: updatedExperienceEntry,
entities: [...entries, ...assets],
locale: 'en-US',
});
const unboundValueKey2 = 'some-unbound-value-key-2';

const nestedPatternNode: ComponentTreeNode = {
definitionId: 'nested-pattern-id',
Expand All @@ -424,7 +403,7 @@ describe('CompositionBlock', () => {
const patternNode: ComponentTreeNode = {
definitionId: defaultAssemblyId,
variables: {
[assemblyGeneratedVariableName]: { type: 'UnboundValue', key: unboundValueKey },
[assemblyGeneratedVariableName]: { type: 'UnboundValue', key: unboundValueKey2 },
cfSsrClassName: {
type: 'DesignValue',
valuesByBreakpoint: { desktop: ssrClassName },
Expand All @@ -433,7 +412,34 @@ describe('CompositionBlock', () => {
children: [],
};

patternEntry.fields.componentTree.children = [nestedPatternNode];
const nestedPatternEntry = createAssemblyEntry({
id: 'nested-pattern-id',
});
const patternEntry = createAssemblyEntry({
nestedPatterns: [{ entry: nestedPatternEntry, node: nestedPatternNode }],
});

const updatedExperienceEntry = {
...experienceEntry,
fields: {
...experienceEntry.fields,
usedComponents: [patternEntry],
unboundValues: {
[unboundValueKey]: {
value: 'Parent pattern value',
},
[unboundValueKey2]: {
value: 'Nested pattern value',
},
},
},
} as ExperienceEntry;

const entityStore = new EntityStore({
experienceEntry: updatedExperienceEntry,
entities: [...entries, ...assets, patternEntry as any, nestedPatternEntry as any],
locale: 'en-US',
});

render(
<CompositionBlock
Expand All @@ -448,6 +454,7 @@ describe('CompositionBlock', () => {
expect(screen.getAllByTestId('assembly')[0]).toHaveClass(ssrClassName);
expect(screen.getAllByTestId('assembly')[1]).toHaveClass(ssrClassName);
expect(screen.getAllByTestId('assembly')[1].firstChild).toHaveClass(ssrClassName);
expect(screen.getByText('Parent pattern value')).toBeInTheDocument();
expect(screen.getByText('Nested pattern value')).toBeInTheDocument();
});
});
Expand Down
Loading

0 comments on commit 7b55c28

Please sign in to comment.