@se-studio/core-ui 1.0.13 → 1.0.15
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 +78 -14
- package/dist/CmsRendererConfig.d.ts +122 -0
- package/dist/CmsRendererConfig.d.ts.map +1 -1
- package/dist/analytics/AnalyticsProvider.d.ts +16 -0
- package/dist/analytics/AnalyticsProvider.d.ts.map +1 -0
- package/dist/analytics/AnalyticsProvider.js +22 -0
- package/dist/analytics/AnalyticsProvider.js.map +1 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.d.ts +12 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.d.ts.map +1 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.js +21 -0
- package/dist/analytics/adapters/ConsoleAnalyticsAdapter.js.map +1 -0
- package/dist/analytics/adapters/index.d.ts +2 -0
- package/dist/analytics/adapters/index.d.ts.map +1 -0
- package/dist/analytics/adapters/index.js +2 -0
- package/dist/analytics/adapters/index.js.map +1 -0
- package/dist/analytics/types.d.ts +41 -0
- package/dist/analytics/types.d.ts.map +1 -0
- package/dist/analytics/types.js +2 -0
- package/dist/analytics/types.js.map +1 -0
- package/dist/analytics/useAnalytics.d.ts +45 -0
- package/dist/analytics/useAnalytics.d.ts.map +1 -0
- package/dist/analytics/useAnalytics.js +70 -0
- package/dist/analytics/useAnalytics.js.map +1 -0
- package/dist/components/ClientMonitor.d.ts +1 -0
- package/dist/components/ClientMonitor.d.ts.map +1 -1
- package/dist/components/ClientMonitor.js +223 -18
- package/dist/components/ClientMonitor.js.map +1 -1
- package/dist/components/CmsCollection.d.ts +47 -0
- package/dist/components/CmsCollection.d.ts.map +1 -1
- package/dist/components/CmsCollection.js +7 -0
- package/dist/components/CmsCollection.js.map +1 -1
- package/dist/components/CmsComponent.d.ts +47 -0
- package/dist/components/CmsComponent.d.ts.map +1 -1
- package/dist/components/CmsComponent.js +7 -0
- package/dist/components/CmsComponent.js.map +1 -1
- package/dist/components/CmsContent.d.ts +62 -0
- package/dist/components/CmsContent.d.ts.map +1 -1
- package/dist/components/CmsContent.js +53 -0
- package/dist/components/CmsContent.js.map +1 -1
- package/dist/components/CmsConversionErrors.js +2 -0
- package/dist/components/CmsConversionErrors.js.map +1 -1
- package/dist/components/CmsEmbeddedContent.d.ts +3 -0
- package/dist/components/CmsEmbeddedContent.d.ts.map +1 -1
- package/dist/components/CmsEmbeddedContent.js +3 -0
- package/dist/components/CmsEmbeddedContent.js.map +1 -1
- package/dist/components/CmsExternalComponent.d.ts +44 -0
- package/dist/components/CmsExternalComponent.d.ts.map +1 -1
- package/dist/components/CmsExternalComponent.js +7 -0
- package/dist/components/CmsExternalComponent.js.map +1 -1
- package/dist/components/ImageKitClientVideo.js +1 -0
- package/dist/components/ImageKitClientVideo.js.map +1 -1
- package/dist/components/SvgComponent.js +3 -1
- package/dist/components/SvgComponent.js.map +1 -1
- package/dist/components/VisualComponent.d.ts +47 -0
- package/dist/components/VisualComponent.d.ts.map +1 -1
- package/dist/components/VisualComponent.js +47 -0
- package/dist/components/VisualComponent.js.map +1 -1
- package/dist/elements/TrackedLink.d.ts +24 -0
- package/dist/elements/TrackedLink.d.ts.map +1 -0
- package/dist/elements/TrackedLink.js +76 -0
- package/dist/elements/TrackedLink.js.map +1 -0
- package/dist/framework/BackgroundMedia.js +5 -1
- package/dist/framework/BackgroundMedia.js.map +1 -1
- package/dist/framework/ComponentErrorIndicator.js +7 -4
- package/dist/framework/ComponentErrorIndicator.js.map +1 -1
- package/dist/framework/componentErrors.d.ts +8 -0
- package/dist/framework/componentErrors.d.ts.map +1 -1
- package/dist/framework/componentErrors.js +10 -0
- package/dist/framework/componentErrors.js.map +1 -1
- package/dist/hooks/useClickTracking.d.ts +39 -0
- package/dist/hooks/useClickTracking.d.ts.map +1 -1
- package/dist/hooks/useClickTracking.js +29 -0
- package/dist/hooks/useClickTracking.js.map +1 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/dist/rtf/rtf.d.ts +41 -0
- package/dist/rtf/rtf.d.ts.map +1 -1
- package/dist/rtf/rtf.js +36 -0
- package/dist/rtf/rtf.js.map +1 -1
- package/dist/utils/UnsupportedWarning.d.ts +23 -0
- package/dist/utils/UnsupportedWarning.d.ts.map +1 -1
- package/dist/utils/UnsupportedWarning.js +24 -0
- package/dist/utils/UnsupportedWarning.js.map +1 -1
- package/dist/utils/UnusedChecker.d.ts +39 -0
- package/dist/utils/UnusedChecker.d.ts.map +1 -1
- package/dist/utils/UnusedChecker.js +47 -3
- package/dist/utils/UnusedChecker.js.map +1 -1
- package/dist/utils/buildPageMetadata.d.ts +45 -0
- package/dist/utils/buildPageMetadata.d.ts.map +1 -1
- package/dist/utils/buildPageMetadata.js +37 -0
- package/dist/utils/buildPageMetadata.js.map +1 -1
- package/dist/utils/cn.d.ts +26 -0
- package/dist/utils/cn.d.ts.map +1 -1
- package/dist/utils/cn.js +26 -0
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/componentUtils.d.ts +121 -0
- package/dist/utils/componentUtils.d.ts.map +1 -1
- package/dist/utils/componentUtils.js +80 -0
- package/dist/utils/componentUtils.js.map +1 -1
- package/dist/utils/convertText.js +10 -2
- package/dist/utils/convertText.js.map +1 -1
- package/dist/utils/errorHandling.d.ts +27 -0
- package/dist/utils/errorHandling.d.ts.map +1 -1
- package/dist/utils/errorHandling.js +33 -0
- package/dist/utils/errorHandling.js.map +1 -1
- package/dist/utils/previewUtils.js +2 -0
- package/dist/utils/previewUtils.js.map +1 -1
- package/package.json +22 -8
- package/dist/elements/UtmLinkOrDiv.d.ts +0 -5
- package/dist/elements/UtmLinkOrDiv.d.ts.map +0 -1
- package/dist/elements/UtmLinkOrDiv.js +0 -9
- package/dist/elements/UtmLinkOrDiv.js.map +0 -1
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import type { CSSProperties, PropsWithChildren } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Development utility component that displays a warning message for unsupported features or configurations.
|
|
4
|
+
*
|
|
5
|
+
* This helps identify areas where content or features are not yet supported,
|
|
6
|
+
* making it easier to spot missing functionality during development.
|
|
7
|
+
*
|
|
8
|
+
* Only shows warnings in development mode (NODE_ENV !== 'production').
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const MyComponent = ({ data }) => {
|
|
13
|
+
* if (data.type === 'unsupported') {
|
|
14
|
+
* return (
|
|
15
|
+
* <UnsupportedWarning className="my-warning">
|
|
16
|
+
* This content type is not yet supported
|
|
17
|
+
* </UnsupportedWarning>
|
|
18
|
+
* );
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* return <div>{data.content}</div>;
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
2
25
|
export declare const UnsupportedWarning: React.FC<PropsWithChildren<{
|
|
3
26
|
className?: string;
|
|
4
27
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnsupportedWarning.d.ts","sourceRoot":"","sources":["../../src/utils/UnsupportedWarning.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"UnsupportedWarning.d.ts","sourceRoot":"","sources":["../../src/utils/UnsupportedWarning.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CACvC,iBAAiB,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC,CA0BH,CAAC"}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Development utility component that displays a warning message for unsupported features or configurations.
|
|
4
|
+
*
|
|
5
|
+
* This helps identify areas where content or features are not yet supported,
|
|
6
|
+
* making it easier to spot missing functionality during development.
|
|
7
|
+
*
|
|
8
|
+
* Only shows warnings in development mode (NODE_ENV !== 'production').
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const MyComponent = ({ data }) => {
|
|
13
|
+
* if (data.type === 'unsupported') {
|
|
14
|
+
* return (
|
|
15
|
+
* <UnsupportedWarning className="my-warning">
|
|
16
|
+
* This content type is not yet supported
|
|
17
|
+
* </UnsupportedWarning>
|
|
18
|
+
* );
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* return <div>{data.content}</div>;
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
2
25
|
export const UnsupportedWarning = ({ children, className, style, showWarnings = true }) => {
|
|
26
|
+
// Only show in development mode
|
|
3
27
|
if ((typeof process !== 'undefined' && process.env?.NODE_ENV === 'production') || !showWarnings) {
|
|
4
28
|
return null;
|
|
5
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnsupportedWarning.js","sourceRoot":"","sources":["../../src/utils/UnsupportedWarning.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"UnsupportedWarning.js","sourceRoot":"","sources":["../../src/utils/UnsupportedWarning.tsx"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAM3B,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,EAAE,EAAE,EAAE;IAC1D,gCAAgC;IAChC,IAAI,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,QAAQ,KAAK,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAChG,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAkB;QAClC,eAAe,EAAE,SAAS;QAC1B,MAAM,EAAE,mBAAmB;QAC3B,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,cAAc;KACxB,CAAC;IAEF,MAAM,WAAW,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,KAAK,EAAE,CAAC;IAElD,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,YAC1C,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Set of property names that are commonly unused and should not trigger warnings.
|
|
4
|
+
* Projects can extend this list by wrapping UnusedChecker or using their own implementation.
|
|
5
|
+
*/
|
|
2
6
|
declare const DEFAULT_ALLOWED_UNUSED: Set<string>;
|
|
3
7
|
type FieldsType = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Development utility component that warns about unused component/collection properties.
|
|
10
|
+
*
|
|
11
|
+
* This helps catch cases where CMS content includes fields that aren't being rendered,
|
|
12
|
+
* which could indicate missing functionality or unnecessary data fetching.
|
|
13
|
+
*
|
|
14
|
+
* Only shows warnings in development mode (NODE_ENV !== 'production').
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const USED_FIELDS = new Set(['heading', 'body', 'visual']);
|
|
19
|
+
*
|
|
20
|
+
* const MyComponent = ({ information }) => {
|
|
21
|
+
* const { componentType, ...allFields } = information;
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <UnusedChecker
|
|
25
|
+
* componentName="MyComponent"
|
|
26
|
+
* allFields={allFields}
|
|
27
|
+
* usedFields={USED_FIELDS}
|
|
28
|
+
* additionalAllowedUnused={new Set(['customField'])}
|
|
29
|
+
* showWarnings={true}
|
|
30
|
+
* >
|
|
31
|
+
* <div>
|
|
32
|
+
* <h2>{information.heading}</h2>
|
|
33
|
+
* <p>{information.body}</p>
|
|
34
|
+
* </div>
|
|
35
|
+
* </UnusedChecker>
|
|
36
|
+
* );
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
4
40
|
export declare const UnusedChecker: React.FC<PropsWithChildren<{
|
|
5
41
|
componentName: string;
|
|
6
42
|
allFields: FieldsType;
|
|
@@ -8,5 +44,8 @@ export declare const UnusedChecker: React.FC<PropsWithChildren<{
|
|
|
8
44
|
additionalAllowedUnused?: Set<string>;
|
|
9
45
|
showWarnings?: boolean;
|
|
10
46
|
}>>;
|
|
47
|
+
/**
|
|
48
|
+
* Export the default allowed unused set so projects can extend it
|
|
49
|
+
*/
|
|
11
50
|
export { DEFAULT_ALLOWED_UNUSED };
|
|
12
51
|
//# sourceMappingURL=UnusedChecker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnusedChecker.d.ts","sourceRoot":"","sources":["../../src/utils/UnusedChecker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"UnusedChecker.d.ts","sourceRoot":"","sources":["../../src/utils/UnusedChecker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C;;;GAGG;AACH,QAAA,MAAM,sBAAsB,aAmB1B,CAAC;AAEH,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAuB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,uBAAuB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC,CA6CH,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Set of property names that are commonly unused and should not trigger warnings.
|
|
4
|
+
* Projects can extend this list by wrapping UnusedChecker or using their own implementation.
|
|
5
|
+
*/
|
|
2
6
|
const DEFAULT_ALLOWED_UNUSED = new Set([
|
|
3
7
|
'componentType',
|
|
4
8
|
'CollectionType',
|
|
@@ -19,18 +23,55 @@ const DEFAULT_ALLOWED_UNUSED = new Set([
|
|
|
19
23
|
'backgroundVisual',
|
|
20
24
|
'backgroundOverlayOpacity',
|
|
21
25
|
]);
|
|
26
|
+
/**
|
|
27
|
+
* Get fields that have values but are not in the allowed sets or used fields
|
|
28
|
+
*/
|
|
22
29
|
function getUnusedFields(allFields, usedFields, additionalAllowedUnused) {
|
|
30
|
+
// Combine default allowed unused with any additional project-specific ones
|
|
23
31
|
const allowedUnused = new Set([...DEFAULT_ALLOWED_UNUSED, ...(additionalAllowedUnused || [])]);
|
|
24
32
|
const fieldsWithValues = Object.entries(allFields)
|
|
25
|
-
.filter(([name]) => !allowedUnused.has(name))
|
|
26
|
-
.filter(([name]) => !usedFields?.has(name))
|
|
27
|
-
.filter(([, value]) => typeof value !== 'undefined' && value !== null)
|
|
33
|
+
.filter(([name]) => !allowedUnused.has(name)) // Not in allowed unused sets
|
|
34
|
+
.filter(([name]) => !usedFields?.has(name)) // Not in used fields
|
|
35
|
+
.filter(([, value]) => typeof value !== 'undefined' && value !== null) // Has actual value
|
|
28
36
|
.map(([name]) => name);
|
|
29
37
|
if (fieldsWithValues.length > 0)
|
|
30
38
|
return fieldsWithValues;
|
|
31
39
|
return undefined;
|
|
32
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Development utility component that warns about unused component/collection properties.
|
|
43
|
+
*
|
|
44
|
+
* This helps catch cases where CMS content includes fields that aren't being rendered,
|
|
45
|
+
* which could indicate missing functionality or unnecessary data fetching.
|
|
46
|
+
*
|
|
47
|
+
* Only shows warnings in development mode (NODE_ENV !== 'production').
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* const USED_FIELDS = new Set(['heading', 'body', 'visual']);
|
|
52
|
+
*
|
|
53
|
+
* const MyComponent = ({ information }) => {
|
|
54
|
+
* const { componentType, ...allFields } = information;
|
|
55
|
+
*
|
|
56
|
+
* return (
|
|
57
|
+
* <UnusedChecker
|
|
58
|
+
* componentName="MyComponent"
|
|
59
|
+
* allFields={allFields}
|
|
60
|
+
* usedFields={USED_FIELDS}
|
|
61
|
+
* additionalAllowedUnused={new Set(['customField'])}
|
|
62
|
+
* showWarnings={true}
|
|
63
|
+
* >
|
|
64
|
+
* <div>
|
|
65
|
+
* <h2>{information.heading}</h2>
|
|
66
|
+
* <p>{information.body}</p>
|
|
67
|
+
* </div>
|
|
68
|
+
* </UnusedChecker>
|
|
69
|
+
* );
|
|
70
|
+
* };
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
33
73
|
export const UnusedChecker = ({ children, componentName, allFields, usedFields, additionalAllowedUnused, showWarnings = true, }) => {
|
|
74
|
+
// Only check in development mode
|
|
34
75
|
if ((typeof process !== 'undefined' && process.env?.NODE_ENV === 'production') || !showWarnings) {
|
|
35
76
|
return _jsx(_Fragment, { children: children });
|
|
36
77
|
}
|
|
@@ -48,5 +89,8 @@ export const UnusedChecker = ({ children, componentName, allFields, usedFields,
|
|
|
48
89
|
}
|
|
49
90
|
return _jsx(_Fragment, { children: children });
|
|
50
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Export the default allowed unused set so projects can extend it
|
|
94
|
+
*/
|
|
51
95
|
export { DEFAULT_ALLOWED_UNUSED };
|
|
52
96
|
//# sourceMappingURL=UnusedChecker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnusedChecker.js","sourceRoot":"","sources":["../../src/utils/UnusedChecker.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"UnusedChecker.js","sourceRoot":"","sources":["../../src/utils/UnusedChecker.tsx"],"names":[],"mappings":";AAEA;;;GAGG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,eAAe;IACf,gBAAgB;IAChB,IAAI;IACJ,MAAM;IACN,MAAM;IACN,OAAO;IACP,aAAa;IACb,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,eAAe;IACf,kBAAkB;IAClB,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,kBAAkB;IAClB,0BAA0B;CAC3B,CAAC,CAAC;AAIH;;GAEG;AACH,SAAS,eAAe,CACtB,SAAqB,EACrB,UAAwB,EACxB,uBAAqC;IAErC,2EAA2E;IAC3E,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,sBAAsB,EAAE,GAAG,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE/F,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SAC/C,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,6BAA6B;SAC1E,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,GAA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AAC,IAAI,CAAC,IACrC,IACA,EACL,QAAQ,IACR,CACJ,CAAC;IACJ,CAAC;IAED,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,11 +1,56 @@
|
|
|
1
1
|
import type { IBaseModel } from '@se-studio/core-data-types';
|
|
2
2
|
import type { Metadata, ResolvingMetadata } from 'next';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for building page metadata.
|
|
5
|
+
*/
|
|
3
6
|
export interface IBuildInformation {
|
|
7
|
+
/** Base URL for the site (e.g., 'https://example.com') */
|
|
4
8
|
baseUrl: string;
|
|
9
|
+
/** Whether the site is in production mode */
|
|
5
10
|
isProduction: boolean;
|
|
11
|
+
/** Whether the site is in development mode */
|
|
6
12
|
isDevelopment: boolean;
|
|
13
|
+
/** Customer/client name for metadata */
|
|
7
14
|
customerName: string;
|
|
15
|
+
/** Optional application name (defaults to customerName) */
|
|
8
16
|
applicationName?: string;
|
|
9
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds Next.js metadata object from CMS page model.
|
|
20
|
+
*
|
|
21
|
+
* Generates comprehensive SEO metadata including:
|
|
22
|
+
* - Title and description
|
|
23
|
+
* - Open Graph tags for social sharing
|
|
24
|
+
* - Twitter Card metadata
|
|
25
|
+
* - Canonical URL
|
|
26
|
+
* - Robots directives (index/follow based on production mode)
|
|
27
|
+
* - Featured image for OG/Twitter
|
|
28
|
+
*
|
|
29
|
+
* @param model - Page model from CMS (must include title, description, featuredImage, indexed)
|
|
30
|
+
* @param path - URL path for the page (e.g., '/about-us')
|
|
31
|
+
* @param buildInfo - Build configuration (baseUrl, environment flags, customer info)
|
|
32
|
+
* @param _parent - Next.js parent metadata resolver (unused, for API compatibility)
|
|
33
|
+
* @returns Next.js Metadata object ready for use in page metadata exports
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { buildPageMetadata } from '@se-studio/core-ui';
|
|
38
|
+
*
|
|
39
|
+
* export async function generateMetadata({ params }): Promise<Metadata> {
|
|
40
|
+
* const page = await contentfulPageRest(config, params.slug);
|
|
41
|
+
* return buildPageMetadata(
|
|
42
|
+
* page,
|
|
43
|
+
* `/${params.slug}`,
|
|
44
|
+
* {
|
|
45
|
+
* baseUrl: process.env.NEXT_PUBLIC_BASE_URL!,
|
|
46
|
+
* isProduction: process.env.NODE_ENV === 'production',
|
|
47
|
+
* isDevelopment: process.env.NODE_ENV === 'development',
|
|
48
|
+
* customerName: 'My Company',
|
|
49
|
+
* },
|
|
50
|
+
* undefined
|
|
51
|
+
* );
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
10
55
|
export declare function buildPageMetadata(model: Omit<IBaseModel, 'textColour' | 'backgroundColour'>, path: string, { baseUrl, isProduction, customerName, applicationName }: IBuildInformation, _parent: ResolvingMetadata): Metadata;
|
|
11
56
|
//# sourceMappingURL=buildPageMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPageMetadata.d.ts","sourceRoot":"","sources":["../../src/utils/buildPageMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAExD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,YAAY,GAAG,kBAAkB,CAAC,EAC1D,IAAI,EAAE,MAAM,EACZ,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,EAAE,iBAAiB,EAC3E,OAAO,EAAE,iBAAiB,GACzB,QAAQ,CA8CV"}
|
|
1
|
+
{"version":3,"file":"buildPageMetadata.d.ts","sourceRoot":"","sources":["../../src/utils/buildPageMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,YAAY,EAAE,OAAO,CAAC;IACtB,8CAA8C;IAC9C,aAAa,EAAE,OAAO,CAAC;IACvB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,YAAY,GAAG,kBAAkB,CAAC,EAC1D,IAAI,EAAE,MAAM,EACZ,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,EAAE,iBAAiB,EAC3E,OAAO,EAAE,iBAAiB,GACzB,QAAQ,CA8CV"}
|
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds Next.js metadata object from CMS page model.
|
|
3
|
+
*
|
|
4
|
+
* Generates comprehensive SEO metadata including:
|
|
5
|
+
* - Title and description
|
|
6
|
+
* - Open Graph tags for social sharing
|
|
7
|
+
* - Twitter Card metadata
|
|
8
|
+
* - Canonical URL
|
|
9
|
+
* - Robots directives (index/follow based on production mode)
|
|
10
|
+
* - Featured image for OG/Twitter
|
|
11
|
+
*
|
|
12
|
+
* @param model - Page model from CMS (must include title, description, featuredImage, indexed)
|
|
13
|
+
* @param path - URL path for the page (e.g., '/about-us')
|
|
14
|
+
* @param buildInfo - Build configuration (baseUrl, environment flags, customer info)
|
|
15
|
+
* @param _parent - Next.js parent metadata resolver (unused, for API compatibility)
|
|
16
|
+
* @returns Next.js Metadata object ready for use in page metadata exports
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { buildPageMetadata } from '@se-studio/core-ui';
|
|
21
|
+
*
|
|
22
|
+
* export async function generateMetadata({ params }): Promise<Metadata> {
|
|
23
|
+
* const page = await contentfulPageRest(config, params.slug);
|
|
24
|
+
* return buildPageMetadata(
|
|
25
|
+
* page,
|
|
26
|
+
* `/${params.slug}`,
|
|
27
|
+
* {
|
|
28
|
+
* baseUrl: process.env.NEXT_PUBLIC_BASE_URL!,
|
|
29
|
+
* isProduction: process.env.NODE_ENV === 'production',
|
|
30
|
+
* isDevelopment: process.env.NODE_ENV === 'development',
|
|
31
|
+
* customerName: 'My Company',
|
|
32
|
+
* },
|
|
33
|
+
* undefined
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
1
38
|
export function buildPageMetadata(model, path, { baseUrl, isProduction, customerName, applicationName }, _parent) {
|
|
2
39
|
const { title, description, featuredImage } = model;
|
|
3
40
|
const indexed = isProduction ? model.indexed : false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPageMetadata.js","sourceRoot":"","sources":["../../src/utils/buildPageMetadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildPageMetadata.js","sourceRoot":"","sources":["../../src/utils/buildPageMetadata.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAA0D,EAC1D,IAAY,EACZ,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAqB,EAC3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ist/utils/cn.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
import { type ClassValue } from 'clsx';
|
|
2
|
+
/**
|
|
3
|
+
* Utility function for merging Tailwind CSS classes.
|
|
4
|
+
*
|
|
5
|
+
* Combines clsx for conditional class names with tailwind-merge to intelligently
|
|
6
|
+
* merge Tailwind classes, resolving conflicts by keeping the last conflicting class.
|
|
7
|
+
*
|
|
8
|
+
* @param inputs - Variable number of class name inputs (strings, objects, arrays)
|
|
9
|
+
* @returns Merged class name string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { cn } from '@se-studio/core-ui';
|
|
14
|
+
*
|
|
15
|
+
* // Basic usage
|
|
16
|
+
* cn('text-lg', 'font-bold') // 'text-lg font-bold'
|
|
17
|
+
*
|
|
18
|
+
* // Conditional classes
|
|
19
|
+
* cn('text-lg', isActive && 'text-blue-500') // 'text-lg text-blue-500' or 'text-lg'
|
|
20
|
+
*
|
|
21
|
+
* // Resolving conflicts
|
|
22
|
+
* cn('text-lg', 'text-sm') // 'text-sm' (last one wins)
|
|
23
|
+
*
|
|
24
|
+
* // With Tailwind classes
|
|
25
|
+
* cn('p-4', 'p-2') // 'p-2' (conflict resolved)
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
2
28
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
3
29
|
//# sourceMappingURL=cn.d.ts.map
|
package/dist/utils/cn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../../src/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAC;AAG7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
1
|
+
{"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../../src/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
package/dist/utils/cn.js
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
/**
|
|
4
|
+
* Utility function for merging Tailwind CSS classes.
|
|
5
|
+
*
|
|
6
|
+
* Combines clsx for conditional class names with tailwind-merge to intelligently
|
|
7
|
+
* merge Tailwind classes, resolving conflicts by keeping the last conflicting class.
|
|
8
|
+
*
|
|
9
|
+
* @param inputs - Variable number of class name inputs (strings, objects, arrays)
|
|
10
|
+
* @returns Merged class name string
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { cn } from '@se-studio/core-ui';
|
|
15
|
+
*
|
|
16
|
+
* // Basic usage
|
|
17
|
+
* cn('text-lg', 'font-bold') // 'text-lg font-bold'
|
|
18
|
+
*
|
|
19
|
+
* // Conditional classes
|
|
20
|
+
* cn('text-lg', isActive && 'text-blue-500') // 'text-lg text-blue-500' or 'text-lg'
|
|
21
|
+
*
|
|
22
|
+
* // Resolving conflicts
|
|
23
|
+
* cn('text-lg', 'text-sm') // 'text-sm' (last one wins)
|
|
24
|
+
*
|
|
25
|
+
* // With Tailwind classes
|
|
26
|
+
* cn('p-4', 'p-2') // 'p-2' (conflict resolved)
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
3
29
|
export function cn(...inputs) {
|
|
4
30
|
return twMerge(clsx(inputs));
|
|
5
31
|
}
|
package/dist/utils/cn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cn.js","sourceRoot":"","sources":["../../src/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
1
|
+
{"version":3,"file":"cn.js","sourceRoot":"","sources":["../../src/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { IBaseCollection, IBaseComponent, IPageContext } from '@se-studio/core-data-types';
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
export type ArrayToUnion<T extends ReadonlyArray<unknown>> = T[number];
|
|
4
|
+
/**
|
|
5
|
+
* Since we've moved to non-generic base types, component utilities now work
|
|
6
|
+
* with the base types directly. Projects can extend these base types with
|
|
7
|
+
* additional properties and use type assertions at the component level.
|
|
8
|
+
*/
|
|
4
9
|
export interface ComponentConfig<TAdditional = Record<string, unknown>> {
|
|
5
10
|
componentProps: ReadonlyArray<keyof IBaseComponent>;
|
|
6
11
|
contextProps: ReadonlyArray<keyof IPageContext>;
|
|
@@ -16,11 +21,127 @@ export type CollectionPropsFromConfig<T extends CollectionConfig> = T['collectio
|
|
|
16
21
|
export type ContextPropsFromConfig<T extends ComponentConfig | CollectionConfig> = Pick<IPageContext, ArrayToUnion<T['contextProps']>>;
|
|
17
22
|
export type GeneratePropsFromComponentConfig<T extends ComponentConfig> = ComponentPropsFromConfig<T> & ContextPropsFromConfig<T> & (T['additionalProps'] extends Record<string, unknown> ? T['additionalProps'] : Record<string, never>);
|
|
18
23
|
export type GeneratePropsFromCollectionConfig<T extends CollectionConfig> = CollectionPropsFromConfig<T> & ContextPropsFromConfig<T> & (T['additionalProps'] extends Record<string, unknown> ? T['additionalProps'] : Record<string, never>);
|
|
24
|
+
/**
|
|
25
|
+
* Extract specific component information fields that a component needs.
|
|
26
|
+
* This is used when you only need a subset of the component fields.
|
|
27
|
+
*
|
|
28
|
+
* @param information - The full component information object
|
|
29
|
+
* @param keys - Array of keys to extract from the information object
|
|
30
|
+
* @returns Object with only the specified keys
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const props = extractComponentInfo(information, ['heading', 'body', 'links']);
|
|
35
|
+
* // props will have type { heading?: string | null, body?: unknown, links?: ReadonlyArray<ILinkProps> }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
19
38
|
export declare function extractComponentInfo<K extends keyof IBaseComponent>(information: IBaseComponent, keys: ReadonlyArray<K>): Pick<IBaseComponent, K>;
|
|
39
|
+
/**
|
|
40
|
+
* Extract specific collection information fields that a collection needs.
|
|
41
|
+
* This is used when you only need a subset of the collection fields.
|
|
42
|
+
*
|
|
43
|
+
* @param information - The full collection information object
|
|
44
|
+
* @param keys - Array of keys to extract from the information object
|
|
45
|
+
* @returns Object with only the specified keys
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* const props = extractCollectionInfo(information, ['heading', 'body', 'contents']);
|
|
50
|
+
* // props will have type { heading?: string | null, body?: unknown, contents?: ReadonlyArray<CollectionContent> }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
20
53
|
export declare function extractCollectionInfo<K extends keyof IBaseCollection>(information: IBaseCollection, keys: ReadonlyArray<K>): Pick<IBaseCollection, K>;
|
|
54
|
+
/**
|
|
55
|
+
* Extract specific page context fields that a component needs.
|
|
56
|
+
*
|
|
57
|
+
* @param pageContext - The full page context object
|
|
58
|
+
* @param keys - Array of keys to extract from the page context
|
|
59
|
+
* @returns Object with only the specified keys
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* const contextProps = extractPageContext(pageContext, ['articleLink', 'pageLink']);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
21
66
|
export declare function extractPageContext<K extends keyof IPageContext>(pageContext: IPageContext, keys: ReadonlyArray<K>): Pick<IPageContext, K>;
|
|
67
|
+
/**
|
|
68
|
+
* Helper type to create a component renderer function with specific prop requirements.
|
|
69
|
+
* This provides better type safety when defining component renderers.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* const config = {
|
|
74
|
+
* componentProps: ['heading', 'body', 'links'],
|
|
75
|
+
* contextProps: ['pageLink'],
|
|
76
|
+
* additionalProps: { theme: 'dark' as const }
|
|
77
|
+
* } as const satisfies ComponentConfig;
|
|
78
|
+
*
|
|
79
|
+
* const MyComponent: ComponentRenderer<typeof config> = ({ heading, body, links, pageLink, theme }) => {
|
|
80
|
+
* // All props are properly typed
|
|
81
|
+
* return <div>{heading}</div>;
|
|
82
|
+
* };
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
22
85
|
export type ComponentRenderer<T extends ComponentConfig> = (props: GeneratePropsFromComponentConfig<T>) => React.ReactElement | null;
|
|
86
|
+
/**
|
|
87
|
+
* Helper type to create a collection renderer function with specific prop requirements.
|
|
88
|
+
* This provides better type safety when defining collection renderers.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* const config = {
|
|
93
|
+
* collectionProps: ['heading', 'body', 'contents'],
|
|
94
|
+
* contextProps: ['articleLink'],
|
|
95
|
+
* additionalProps: { layout: 'grid' as const }
|
|
96
|
+
* } as const satisfies CollectionConfig;
|
|
97
|
+
*
|
|
98
|
+
* const MyCollection: CollectionRenderer<typeof config> = ({ heading, body, contents, articleLink, layout }) => {
|
|
99
|
+
* // All props are properly typed
|
|
100
|
+
* return <div>{heading}</div>;
|
|
101
|
+
* };
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
23
104
|
export type CollectionRenderer<T extends CollectionConfig> = (props: GeneratePropsFromCollectionConfig<T>) => React.ReactElement | null;
|
|
105
|
+
/**
|
|
106
|
+
* Create props object for a component renderer from component information and page context.
|
|
107
|
+
* This function extracts the specified fields and combines them with additional props.
|
|
108
|
+
*
|
|
109
|
+
* @param config - Configuration specifying which props to extract
|
|
110
|
+
* @param information - The component information object
|
|
111
|
+
* @param pageContext - The page context object
|
|
112
|
+
* @param additionalProps - Additional props to include (optional)
|
|
113
|
+
* @returns Combined props object ready to pass to the component
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* const config = {
|
|
118
|
+
* componentProps: ['heading', 'body'],
|
|
119
|
+
* contextProps: ['pageLink'],
|
|
120
|
+
* } as const;
|
|
121
|
+
*
|
|
122
|
+
* const props = createComponentProps(config, information, pageContext);
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
24
125
|
export declare function createComponentProps<T extends ComponentConfig>(config: T, information: IBaseComponent, pageContext: IPageContext, additionalProps?: T['additionalProps']): GeneratePropsFromComponentConfig<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Create props object for a collection renderer from collection information and page context.
|
|
128
|
+
* This function extracts the specified fields and combines them with additional props.
|
|
129
|
+
*
|
|
130
|
+
* @param config - Configuration specifying which props to extract
|
|
131
|
+
* @param information - The collection information object
|
|
132
|
+
* @param pageContext - The page context object
|
|
133
|
+
* @param additionalProps - Additional props to include (optional)
|
|
134
|
+
* @returns Combined props object ready to pass to the collection
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* const config = {
|
|
139
|
+
* collectionProps: ['heading', 'contents'],
|
|
140
|
+
* contextProps: ['articleLink'],
|
|
141
|
+
* } as const;
|
|
142
|
+
*
|
|
143
|
+
* const props = createCollectionProps(config, information, pageContext);
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
25
146
|
export declare function createCollectionProps<T extends CollectionConfig>(config: T, information: IBaseCollection, pageContext: IPageContext, additionalProps?: T['additionalProps']): GeneratePropsFromCollectionConfig<T>;
|
|
26
147
|
//# sourceMappingURL=componentUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentUtils.d.ts","sourceRoot":"","sources":["../../src/utils/componentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"componentUtils.d.ts","sourceRoot":"","sources":["../../src/utils/componentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvE;;;;GAIG;AAGH,MAAM,WAAW,eAAe,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEpE,cAAc,EAAE,aAAa,CAAC,MAAM,cAAc,CAAC,CAAC;IAEpD,YAAY,EAAE,aAAa,CAAC,MAAM,YAAY,CAAC,CAAC;IAEhD,eAAe,CAAC,EAAE,WAAW,CAAC;CAC/B;AAGD,MAAM,WAAW,gBAAgB,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAErE,eAAe,EAAE,aAAa,CAAC,MAAM,eAAe,CAAC,CAAC;IAEtD,YAAY,EAA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