@claspo/templates 16.0.2 → 16.0.4
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/Template.interface.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import SortableRecordI from "./SortableRecord.interface";
|
|
|
6
6
|
import { PrizePoolModelI } from '@claspo/common/PrizePool.interface';
|
|
7
7
|
import { WidgetType } from '@claspo/common/WidgetType';
|
|
8
8
|
import { ThemeI } from "@claspo/common/document/Document.interface";
|
|
9
|
+
import InlineBackgroundI from './InlineBackground.interface';
|
|
9
10
|
export default interface TemplateI<RuleT, LayoutT, DocumentT = Record<string, any>, SyncT = Record<string, any> | null> extends SortableRecordI {
|
|
10
11
|
id: number;
|
|
11
12
|
name: string;
|
|
@@ -22,10 +23,7 @@ export default interface TemplateI<RuleT, LayoutT, DocumentT = Record<string, an
|
|
|
22
23
|
[key: string]: string;
|
|
23
24
|
};
|
|
24
25
|
theme?: ThemeI;
|
|
25
|
-
backgroundInline:
|
|
26
|
-
path: number[];
|
|
27
|
-
props: Record<string, any>;
|
|
28
|
-
}[];
|
|
26
|
+
backgroundInline: InlineBackgroundI;
|
|
29
27
|
};
|
|
30
28
|
launchers: TemplateLauncherItemI[];
|
|
31
29
|
layouts: LayoutT[];
|
package/TemplateMapper.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import TemplateBriefI from "./TemplateBrief.interface";
|
|
2
2
|
export default class TemplateMapper {
|
|
3
3
|
static mapTemplates(rawItems: TemplateBriefI[]): TemplateBriefI[];
|
|
4
|
+
private static migrateCssVarsToTheme;
|
|
5
|
+
private static applyThemeToDocument;
|
|
6
|
+
private static applyInlineBackgroundToDocument;
|
|
7
|
+
private static cleanupTemplateIfItWasChangedFromDynamicToStatic;
|
|
4
8
|
}
|
package/TemplateMapper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TemplateType}from"./TemplateType.enum";import DocumentCssVarsReplace from"@claspo/common/document/DocumentCssVarsReplace";import DocumentUtils from"@claspo/common/document/DocumentUtils";import{prepareKeys}from"@claspo/common/element/ThemeCssVars";export default class TemplateMapper{static mapTemplates(e){return e.map(e=>{var
|
|
1
|
+
import{TemplateType}from"./TemplateType.enum";import DocumentCssVarsReplace from"@claspo/common/document/DocumentCssVarsReplace";import DocumentUtils from"@claspo/common/document/DocumentUtils";import{DefaultSchemaTokens}from"@claspo/common/document/Document.interface";import{prepareKeys}from"@claspo/common/element/ThemeCssVars";import{createTheme,toCssVarToken}from"@claspo/common/theme/theme.utils";export default class TemplateMapper{static mapTemplates(e){return e.map(e=>{var a;if(e.type===TemplateType.STATIC)return TemplateMapper.cleanupTemplateIfItWasChangedFromDynamicToStatic(e),e;const t=TemplateMapper.migrateCssVarsToTheme(e);t&&TemplateMapper.applyThemeToDocument(e,t);const o=null===(a=e.dynamicParams)||void 0===a?void 0:a.backgroundInline;return o&&TemplateMapper.applyInlineBackgroundToDocument(e,o),e})}static migrateCssVarsToTheme(e){var a,t;const o=null===(a=e.dynamicParams)||void 0===a?void 0:a.cssVars;let m=null===(t=e.dynamicParams)||void 0===t?void 0:t.theme;if(!m&&o){const e=o[toCssVarToken(DefaultSchemaTokens.ACCENT)];e&&(m=createTheme({[DefaultSchemaTokens.ACCENT]:e}))}return m||null}static applyThemeToDocument(e,a){const t=e.json.document,o=prepareKeys((null==a?void 0:a.schema)||{});e.json.document=DocumentCssVarsReplace.replaceValues(t,o),e.json.document.shared||(e.json.document.shared={}),e.json.document.shared.theme=a}static applyInlineBackgroundToDocument(e,a){null==a||a.forEach(({path:a,props:t})=>{const o=DocumentUtils.getNodeByPath(e.json.document.views,a);o&&(o.props=Object.assign(Object.assign({},o.props),t))})}static cleanupTemplateIfItWasChangedFromDynamicToStatic(e){if(e.dynamicParams){delete e.dynamicParams.theme,delete e.dynamicParams.cssVars;const a=e.json.document;(null==a?void 0:a.shared)&&(delete a.shared.theme,delete a.shared.cssVars)}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claspo/templates",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.4",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18.16.0"
|
|
6
6
|
},
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"package": "npm i && npm run test && npm run build && cp package.json out && cd out && npm publish --access=public && cd .."
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@claspo/common": "7.0.
|
|
16
|
-
"@claspo/document-connector": "16.0.
|
|
17
|
-
"@claspo/renderer": "18.0.
|
|
15
|
+
"@claspo/common": "7.0.2",
|
|
16
|
+
"@claspo/document-connector": "16.0.3",
|
|
17
|
+
"@claspo/renderer": "18.0.2",
|
|
18
18
|
"@claspo/components": "1.2.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|