@sitecore-content-sdk/content 2.2.1 → 2.3.0-beta.atoms.20260721120640

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.
Files changed (82) hide show
  1. package/atoms.d.ts +1 -0
  2. package/dist/cjs/atoms/design-library-bridge/constants.js +18 -0
  3. package/dist/cjs/atoms/design-library-bridge/events.js +88 -0
  4. package/dist/cjs/atoms/design-library-bridge/index.js +18 -0
  5. package/dist/cjs/atoms/index.js +8 -0
  6. package/dist/cjs/atoms/types.js +2 -0
  7. package/dist/cjs/client/sitecore-client.js +6 -1
  8. package/dist/cjs/config/define-config.js +55 -86
  9. package/dist/cjs/config/index.js +1 -4
  10. package/dist/cjs/editing/models.js +2 -0
  11. package/dist/cjs/form/form.js +2 -2
  12. package/dist/cjs/layout/index.js +0 -15
  13. package/dist/cjs/site/index.js +1 -2
  14. package/dist/cjs/site/utils.js +0 -34
  15. package/dist/cjs/tools/index.js +1 -3
  16. package/dist/cjs/tools/templating/components.js +3 -13
  17. package/dist/cjs/tools/templating/index.js +1 -4
  18. package/dist/esm/atoms/design-library-bridge/constants.js +15 -0
  19. package/dist/esm/atoms/design-library-bridge/events.js +80 -0
  20. package/dist/esm/atoms/design-library-bridge/index.js +2 -0
  21. package/dist/esm/atoms/index.js +1 -0
  22. package/dist/esm/atoms/types.js +1 -0
  23. package/dist/esm/client/sitecore-client.js +6 -1
  24. package/dist/esm/config/define-config.js +56 -86
  25. package/dist/esm/config/index.js +1 -1
  26. package/dist/esm/editing/models.js +2 -0
  27. package/dist/esm/form/form.js +2 -2
  28. package/dist/esm/layout/index.js +0 -1
  29. package/dist/esm/site/index.js +1 -1
  30. package/dist/esm/site/utils.js +0 -33
  31. package/dist/esm/tools/index.js +1 -1
  32. package/dist/esm/tools/templating/components.js +2 -11
  33. package/dist/esm/tools/templating/index.js +0 -1
  34. package/package.json +38 -34
  35. package/types/atoms/design-library-bridge/constants.d.ts +16 -0
  36. package/types/atoms/design-library-bridge/constants.d.ts.map +1 -0
  37. package/types/atoms/design-library-bridge/events.d.ts +41 -0
  38. package/types/atoms/design-library-bridge/events.d.ts.map +1 -0
  39. package/types/atoms/design-library-bridge/index.d.ts +3 -0
  40. package/types/atoms/design-library-bridge/index.d.ts.map +1 -0
  41. package/types/atoms/design-library-bridge/types.d.ts +63 -0
  42. package/types/atoms/design-library-bridge/types.d.ts.map +1 -0
  43. package/types/atoms/index.d.ts +3 -0
  44. package/types/atoms/index.d.ts.map +1 -0
  45. package/types/atoms/types.d.ts +68 -0
  46. package/types/atoms/types.d.ts.map +1 -0
  47. package/types/client/edge-proxy.d.ts.map +1 -1
  48. package/types/client/sitecore-client.d.ts +4 -0
  49. package/types/client/sitecore-client.d.ts.map +1 -1
  50. package/types/config/define-config.d.ts +2 -17
  51. package/types/config/define-config.d.ts.map +1 -1
  52. package/types/config/index.d.ts +1 -1
  53. package/types/config/index.d.ts.map +1 -1
  54. package/types/config/models.d.ts +17 -1
  55. package/types/config/models.d.ts.map +1 -1
  56. package/types/editing/models.d.ts +3 -1
  57. package/types/editing/models.d.ts.map +1 -1
  58. package/types/form/form.d.ts +1 -1
  59. package/types/form/form.d.ts.map +1 -1
  60. package/types/layout/content-styles.d.ts.map +1 -1
  61. package/types/layout/index.d.ts +0 -1
  62. package/types/layout/index.d.ts.map +1 -1
  63. package/types/layout/rewrite-edge-host.d.ts.map +1 -1
  64. package/types/layout/themes.d.ts.map +1 -1
  65. package/types/site/index.d.ts +1 -1
  66. package/types/site/index.d.ts.map +1 -1
  67. package/types/site/utils.d.ts +0 -11
  68. package/types/site/utils.d.ts.map +1 -1
  69. package/types/tools/index.d.ts +1 -1
  70. package/types/tools/index.d.ts.map +1 -1
  71. package/types/tools/templating/components.d.ts +2 -8
  72. package/types/tools/templating/components.d.ts.map +1 -1
  73. package/types/tools/templating/index.d.ts +0 -1
  74. package/types/tools/templating/index.d.ts.map +1 -1
  75. package/dist/cjs/tools/templating/utils.js +0 -167
  76. package/dist/esm/tools/templating/utils.js +0 -159
  77. package/types/layout/field-types.d.ts +0 -75
  78. package/types/layout/field-types.d.ts.map +0 -1
  79. package/types/tools/templating/utils.d.ts +0 -44
  80. package/types/tools/templating/utils.d.ts.map +0 -1
  81. /package/dist/cjs/{layout/field-types.js → atoms/design-library-bridge/types.js} +0 -0
  82. /package/dist/esm/{layout/field-types.js → atoms/design-library-bridge/types.js} +0 -0
@@ -1,159 +0,0 @@
1
- import path from 'path';
2
- const DEFAULT_HEADER_COMMENT = "Below are built-in components that are available in the app, it's recommended to keep them as is";
3
- /**
4
- * Transform component description entries for the component map.
5
- * @param {ComponentSource[]} components - The components to transform.
6
- * @param {object} opts - The options for the transformation.
7
- * @param {boolean} opts.includeVariants - Whether to include variants in the component map.
8
- * @param {boolean} opts.shouldAnnotateClient - Whether to annotate the client in the component map. Used in frameworks that make server/client distinction.
9
- * @returns {ComponentMapEntry[]} The transformed component description entries.
10
- * @internal
11
- */
12
- export const prepareComponentsForMap = (components, opts) => {
13
- var _a;
14
- const groups = new Map();
15
- const getPrefix = (name) => {
16
- const index = name.indexOf('.');
17
- return index === -1 ? name : name.slice(0, index);
18
- };
19
- for (const file of components) {
20
- const dir = path.dirname(file.filePath).replace(/\\/g, '/');
21
- const prefix = getPrefix(file.componentName);
22
- const key = `${dir}::${prefix}`;
23
- let group = groups.get(key);
24
- if (!group) {
25
- group = { dir, prefix, neighbors: [] };
26
- groups.set(key, group);
27
- }
28
- if (file.componentName === prefix)
29
- group.base = file;
30
- else
31
- group.neighbors.push(file);
32
- }
33
- const entries = [];
34
- for (const group of groups.values()) {
35
- const imports = [];
36
- if (opts.includeVariants) {
37
- const spreads = [];
38
- for (const neighbor of group.neighbors) {
39
- imports.push(`import * as ${neighbor.moduleName} from '${neighbor.importPath}';`);
40
- spreads.push(`...${neighbor.moduleName}`);
41
- }
42
- if (group.base) {
43
- imports.push(`import * as ${group.base.moduleName} from '${group.base.importPath}';`);
44
- spreads.push(`...${group.base.moduleName}`);
45
- }
46
- const annotateClient = opts.shouldAnnotateClient
47
- ? !!group.base && 'componentType' in group.base && group.base.componentType === 'client'
48
- : false;
49
- let valueExpr;
50
- if (spreads.length) {
51
- valueExpr = spreads.join(', ');
52
- }
53
- else {
54
- valueExpr = group.base ? group.base.moduleName : group.neighbors[0].moduleName;
55
- }
56
- entries.push({
57
- key: group.prefix,
58
- imports,
59
- valueExpr,
60
- annotateClient,
61
- });
62
- }
63
- else {
64
- // Variants disabled: single entry per group
65
- if (group.base) {
66
- imports.push(`import * as ${group.base.moduleName} from '${group.base.importPath}';`);
67
- const annotateClient = opts.shouldAnnotateClient
68
- ? 'componentType' in group.base && group.base.componentType === 'client'
69
- : false;
70
- entries.push({
71
- key: group.prefix,
72
- imports,
73
- valueExpr: group.base.moduleName,
74
- annotateClient,
75
- });
76
- }
77
- else if (group.neighbors.length) {
78
- const first = group.neighbors[0];
79
- imports.push(`import * as ${first.moduleName} from '${first.importPath}';`);
80
- entries.push({
81
- key: group.prefix,
82
- imports,
83
- valueExpr: first.moduleName,
84
- annotateClient: (_a = opts.shouldAnnotateClient) !== null && _a !== void 0 ? _a : false,
85
- });
86
- }
87
- }
88
- }
89
- return entries;
90
- };
91
- /**
92
- * Cross framework function to build the component map content.
93
- * @param {ComponentMapEntry[]} entries - The entries to build the component map content for.
94
- * @param {ComponentImport[] | undefined} componentImports - The component imports to build the component map content for.
95
- * @param {TemplateOptions} options - The options for the buildComponentMapContent function.
96
- * @returns {string} The component map content.
97
- * @internal
98
- */
99
- export const buildComponentMapContent = (entries, componentImports, options) => {
100
- const { headerComment = DEFAULT_HEADER_COMMENT, isClientMap = false, framework, builtInImports = '', builtInMapEntries = [], } = options;
101
- if (!framework) {
102
- throw new Error('options.framework is required to build the component map');
103
- }
104
- const frameworkComponentTypeName = `${framework.charAt(0).toUpperCase() + framework.slice(1)}ContentSdkComponent`;
105
- const frameworkImportString = `import { ${frameworkComponentTypeName} } from '@sitecore-content-sdk/${framework}';\n`;
106
- const wildcardImports = [];
107
- const namedImports = [];
108
- // Add per-entry imports
109
- entries.forEach((e) => wildcardImports.push(...e.imports));
110
- // Handle package imports
111
- componentImports === null || componentImports === void 0 ? void 0 : componentImports.forEach((pkg) => {
112
- if (pkg.importInfo.namedImports) {
113
- namedImports.push(`import { ${pkg.importInfo.namedImports.join(', ')} } from '${pkg.importInfo.importFrom}';`);
114
- }
115
- else {
116
- wildcardImports.push(`import * as ${pkg.importName} from '${pkg.importInfo.importFrom}';`);
117
- }
118
- });
119
- const importLines = [
120
- builtInImports.length ? '// end of built-in import section' : null,
121
- ...wildcardImports,
122
- ...namedImports,
123
- ].filter(Boolean);
124
- const importsSection = importLines.length ? `\n${importLines.join('\n')}` : '';
125
- // Clone to avoid mutating the caller's array
126
- const componentMapEntries = structuredClone(builtInMapEntries);
127
- for (const e of entries) {
128
- const value = !isClientMap && e.annotateClient
129
- ? `{ ${e.valueExpr}, componentType: 'client' }`
130
- : e.valueExpr.includes('...')
131
- ? `{ ${e.valueExpr} }`
132
- : e.valueExpr;
133
- componentMapEntries.push(`['${e.key}', ${value}]`);
134
- }
135
- // Add package-based entries
136
- componentImports === null || componentImports === void 0 ? void 0 : componentImports.forEach((pkg) => {
137
- if (pkg.importInfo.namedImports) {
138
- pkg.importInfo.namedImports.forEach((name) => {
139
- componentMapEntries.push(`['${name}', ${name}]`);
140
- });
141
- }
142
- else {
143
- componentMapEntries.push(`['${pkg.importName}', ${pkg.importName}]`);
144
- }
145
- });
146
- return `// ${headerComment}
147
- ${frameworkImportString}
148
- ${builtInImports}${importsSection}
149
-
150
- export const componentMap = new Map<string, ${frameworkComponentTypeName}>([
151
- ${componentMapEntries
152
- .map((component) => {
153
- return ` ${component},\n`;
154
- })
155
- .join('')}]);
156
-
157
- export default componentMap;
158
- `;
159
- };
@@ -1,75 +0,0 @@
1
- import type { FieldMetadata } from './models';
2
- /**
3
- * The interface for the Link field value.
4
- * @public
5
- */
6
- export interface LinkFieldValue {
7
- [attributeName: string]: unknown;
8
- href?: string;
9
- className?: string;
10
- class?: string;
11
- title?: string;
12
- target?: string;
13
- text?: string;
14
- anchor?: string;
15
- querystring?: string;
16
- linktype?: string;
17
- }
18
- /**
19
- * The interface for the Link field.
20
- * @public
21
- */
22
- export interface LinkField {
23
- value: LinkFieldValue;
24
- }
25
- /**
26
- * The interface for the Image field value.
27
- * @public
28
- */
29
- export interface ImageFieldValue {
30
- [attributeName: string]: unknown;
31
- src?: string;
32
- }
33
- /**
34
- * The interface for the Image field.
35
- * @public
36
- */
37
- export interface ImageField {
38
- value?: ImageFieldValue;
39
- }
40
- /**
41
- * The interface for the Image size parameters.
42
- * @public
43
- */
44
- export interface ImageSizeParameters {
45
- [attr: string]: string | number | undefined;
46
- /** Fixed width of the image */
47
- w?: number;
48
- /** Fixed height of the image */
49
- h?: number;
50
- /** Max width of the image */
51
- mw?: number;
52
- /** Max height of the image */
53
- mh?: number;
54
- /** Ignore aspect ratio */
55
- iar?: 1 | 0;
56
- /** Allow stretch */
57
- as?: 1 | 0;
58
- /** Image scale. Defaults to 1.0 */
59
- sc?: number;
60
- }
61
- /**
62
- * The interface for the Text field.
63
- * @public
64
- */
65
- export interface TextField extends FieldMetadata {
66
- value?: string | number;
67
- }
68
- /**
69
- * The interface for the Rich Text field.
70
- * @public
71
- */
72
- export interface RichTextField extends FieldMetadata {
73
- value?: string;
74
- }
75
- //# sourceMappingURL=field-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../src/layout/field-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MA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} from './components';
2
- /**
3
- * A component source can be either a file or a file with type information.
4
- */
5
- type ComponentSource = ComponentFile | ComponentFileWithType;
6
- /**
7
- * Template options for component map generation
8
- */
9
- type TemplateOptions = {
10
- /** Custom header comment for the generated map */
11
- headerComment?: string;
12
- /** Whether this is a client-only map (no need for componentType annotations). Only used in frameworks that make server/client distinction. */
13
- isClientMap?: boolean;
14
- /** Built-in imports string to include in the map */
15
- builtInImports?: string;
16
- /** Built-in map entries to include in the map */
17
- builtInMapEntries?: string[];
18
- /** Framework name to use in the component map */
19
- framework: string;
20
- };
21
- /**
22
- * Transform component description entries for the component map.
23
- * @param {ComponentSource[]} components - The components to transform.
24
- * @param {object} opts - The options for the transformation.
25
- * @param {boolean} opts.includeVariants - Whether to include variants in the component map.
26
- * @param {boolean} opts.shouldAnnotateClient - Whether to annotate the client in the component map. Used in frameworks that make server/client distinction.
27
- * @returns {ComponentMapEntry[]} The transformed component description entries.
28
- * @internal
29
- */
30
- export declare const prepareComponentsForMap: (components: ComponentSource[], opts: {
31
- includeVariants: boolean;
32
- shouldAnnotateClient?: boolean;
33
- }) => ComponentMapEntry[];
34
- /**
35
- * Cross framework function to build the component map content.
36
- * @param {ComponentMapEntry[]} entries - The entries to build the component map content for.
37
- * @param {ComponentImport[] | undefined} componentImports - The component imports to build the component map content for.
38
- * @param {TemplateOptions} options - The options for the buildComponentMapContent function.
39
- * @returns {string} The component map content.
40
- * @internal
41
- */
42
- export declare const buildComponentMapContent: (entries: ComponentMapEntry[], componentImports: ComponentImport[] | undefined, options: TemplateOptions) => string;
43
- export {};
44
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/templating/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAKtB;;GAEG;AACH,KAAK,eAAe,GAAG,aAAa,GAAG,qBAAqB,CAAC;AAE7D;;GAEG;AACH,KAAK,eAAe,GAAG;IACrB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8IAA8I;IAC9I,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAY,eAAe,EAAE,EAC7B,MAAM;IAAE,eAAe,EAAE,OAAO,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAE,KACjE,iBAAiB,EAqFnB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,iBAAiB,EAAE,EAC5B,kBAAkB,eAAe,EAAE,GAAG,SAAS,EAC/C,SAAS,eAAe,KACvB,MA8EF,CAAC"}