@claspo/templates 14.4.1
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/EnvManager.d.ts +28 -0
- package/EnvManager.js +1 -0
- package/HttpDebugTemplateLoader.d.ts +8 -0
- package/HttpDebugTemplateLoader.js +1 -0
- package/HttpTemplateLoader.d.ts +7 -0
- package/HttpTemplateLoader.js +1 -0
- package/MapGridOptions.d.ts +2 -0
- package/MapGridOptions.js +1 -0
- package/PubSub.interface.d.ts +5 -0
- package/PubSub.interface.js +1 -0
- package/SortWeightRecordI.d.ts +5 -0
- package/SortWeightRecordI.js +1 -0
- package/SortableRecord.interface.d.ts +5 -0
- package/SortableRecord.interface.js +1 -0
- package/Template.interface.d.ts +38 -0
- package/Template.interface.js +1 -0
- package/TemplateBrief.interface.d.ts +3 -0
- package/TemplateBrief.interface.js +1 -0
- package/TemplateDatasource.d.ts +43 -0
- package/TemplateDatasource.interface.d.ts +9 -0
- package/TemplateDatasource.interface.js +1 -0
- package/TemplateDatasource.js +1 -0
- package/TemplateLauncherItem.interface.d.ts +3 -0
- package/TemplateLauncherItem.interface.js +1 -0
- package/TemplateMapper.d.ts +4 -0
- package/TemplateMapper.js +1 -0
- package/TemplatePublishStatus.enum.d.ts +4 -0
- package/TemplatePublishStatus.enum.js +1 -0
- package/TemplateSize.interface.d.ts +4 -0
- package/TemplateSize.interface.js +1 -0
- package/TemplateType.enum.d.ts +6 -0
- package/TemplateType.enum.js +1 -0
- package/WidgetType.enum.d.ts +8 -0
- package/WidgetType.enum.js +1 -0
- package/data/DataStrategy.d.ts +12 -0
- package/data/DataStrategy.interface.d.ts +6 -0
- package/data/DataStrategy.interface.js +1 -0
- package/data/DataStrategy.js +1 -0
- package/data/strategies/default-strategy/DefaultStrategy.d.ts +7 -0
- package/data/strategies/default-strategy/DefaultStrategy.js +1 -0
- package/data/strategies/shuffle.d.ts +1 -0
- package/data/strategies/shuffle.js +1 -0
- package/data/strategies/similar-random-weight-strategy/SimilarRandomWeightStrategy.d.ts +9 -0
- package/data/strategies/similar-random-weight-strategy/SimilarRandomWeightStrategy.js +1 -0
- package/data/strategies/weight-strategy/WeightStrategy.d.ts +7 -0
- package/data/strategies/weight-strategy/WeightStrategy.js +1 -0
- package/data/strategies/weight-strategy/computeTemplateWeight.d.ts +3 -0
- package/data/strategies/weight-strategy/computeTemplateWeight.js +1 -0
- package/data/strategies/weight-strategy/getPreferredWeight.d.ts +4 -0
- package/data/strategies/weight-strategy/getPreferredWeight.js +1 -0
- package/data/strategies/weight-strategy/sortByWeightPredicate.d.ts +2 -0
- package/data/strategies/weight-strategy/sortByWeightPredicate.js +1 -0
- package/data/strategies/width-based-strategy/WidthBasedStrategy.d.ts +7 -0
- package/data/strategies/width-based-strategy/WidthBasedStrategy.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/buildRow.d.ts +2 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/buildRow.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/convertArrayToMapByField.d.ts +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/convertArrayToMapByField.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/createSizeModels.d.ts +7 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/createSizeModels.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/filterOffDuplicates.d.ts +2 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/filterOffDuplicates.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/findNextModel.d.ts +2 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/findNextModel.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/generateRandomValue.d.ts +2 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/generateRandomValue.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/getCurrentRowWidth.d.ts +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/getCurrentRowWidth.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/group.interface.d.ts +2 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/group.interface.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/groupModelsByPercentHeight.d.ts +3 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/groupModelsByPercentHeight.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/groupObjectMap.interface.d.ts +4 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/groupObjectMap.interface.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/isModelAlreadyPresent.d.ts +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/isModelAlreadyPresent.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/mapSizeModel.d.ts +3 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/mapSizeModel.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/sizeModelI.d.ts +6 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/sizeModelI.js +1 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/widthFirstAlgorithm.d.ts +3 -0
- package/data/strategies/width-based-strategy/width-first-algorithm/widthFirstAlgorithm.js +1 -0
- package/dialog/ClDialogSliderComponent.d.ts +35 -0
- package/dialog/ClDialogSliderComponent.js +1 -0
- package/error/TemplateGridConstructorArgumentsError.d.ts +3 -0
- package/error/TemplateGridConstructorArgumentsError.js +1 -0
- package/filter/FilterApplier.d.ts +10 -0
- package/filter/FilterApplier.js +1 -0
- package/filter/FilterGroup.d.ts +7 -0
- package/filter/FilterGroup.interface.d.ts +6 -0
- package/filter/FilterGroup.interface.js +1 -0
- package/filter/FilterGroup.js +1 -0
- package/filter/FilterGroupType.d.ts +7 -0
- package/filter/FilterGroupType.js +1 -0
- package/filter/FilterItem.d.ts +9 -0
- package/filter/FilterItem.interface.d.ts +9 -0
- package/filter/FilterItem.interface.js +1 -0
- package/filter/FilterItem.js +1 -0
- package/filter/FilterResponse.interface.d.ts +2 -0
- package/filter/FilterResponse.interface.js +1 -0
- package/filter/FilterTranslator.d.ts +9 -0
- package/filter/FilterTranslator.js +1 -0
- package/filter/FilterValue.interface.d.ts +2 -0
- package/filter/FilterValue.interface.js +1 -0
- package/filter/FilterValueGroup.interface.d.ts +7 -0
- package/filter/FilterValueGroup.interface.js +1 -0
- package/filter/HttpFilterLoader.d.ts +8 -0
- package/filter/HttpFilterLoader.js +1 -0
- package/filter/TemplateFilterDatasource.d.ts +17 -0
- package/filter/TemplateFilterDatasource.interface.d.ts +9 -0
- package/filter/TemplateFilterDatasource.interface.js +1 -0
- package/filter/TemplateFilterDatasource.js +1 -0
- package/filter/TemplateFilterObserver.d.ts +11 -0
- package/filter/TemplateFilterObserver.js +1 -0
- package/filter/mapFilterGroupTypeToTemplateField.d.ts +2 -0
- package/filter/mapFilterGroupTypeToTemplateField.js +1 -0
- package/grid/DefaultGridOptions.d.ts +2 -0
- package/grid/DefaultGridOptions.js +1 -0
- package/grid/GridAlgorithm.enum.d.ts +6 -0
- package/grid/GridAlgorithm.enum.js +1 -0
- package/grid/GridOptions.interface.d.ts +7 -0
- package/grid/GridOptions.interface.js +1 -0
- package/grid-preview/GridPreview.d.ts +17 -0
- package/grid-preview/GridPreview.js +1 -0
- package/grid-preview/GridPreviewInit.interface.d.ts +16 -0
- package/grid-preview/GridPreviewInit.interface.js +1 -0
- package/helpers.d.ts +19 -0
- package/helpers.js +1 -0
- package/package.json +32 -0
- package/slider/TemplateSlider.d.ts +14 -0
- package/slider/TemplateSlider.js +1 -0
package/EnvManager.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum EnvName {
|
|
2
|
+
LOCAL = "local",
|
|
3
|
+
STAGE = "stage",
|
|
4
|
+
PROD = "prod"
|
|
5
|
+
}
|
|
6
|
+
export declare enum EnvKey {
|
|
7
|
+
TEMPLATES_URL = "TEMPLATES_URL",
|
|
8
|
+
FILTERS_URL = "FILTERS_URL",
|
|
9
|
+
TEMPLATE_BY_ID_URL = "TEMPLATE_BY_ID_URL"
|
|
10
|
+
}
|
|
11
|
+
export declare class EnvManager {
|
|
12
|
+
private currentEnv;
|
|
13
|
+
static envs: {
|
|
14
|
+
local: {
|
|
15
|
+
TEMPLATES_URL: string;
|
|
16
|
+
FILTERS_URL: string;
|
|
17
|
+
TEMPLATE_BY_ID_URL: string;
|
|
18
|
+
};
|
|
19
|
+
prod: {
|
|
20
|
+
TEMPLATES_URL: string;
|
|
21
|
+
FILTERS_URL: string;
|
|
22
|
+
TEMPLATE_BY_ID_URL: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
constructor();
|
|
26
|
+
get(key: EnvKey): string;
|
|
27
|
+
private static getEnvName;
|
|
28
|
+
}
|
package/EnvManager.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var EnvName;!function(e){e.LOCAL="local",e.STAGE="stage",e.PROD="prod"}(EnvName||(EnvName={}));export var EnvKey;!function(e){e.TEMPLATES_URL="TEMPLATES_URL",e.FILTERS_URL="FILTERS_URL",e.TEMPLATE_BY_ID_URL="TEMPLATE_BY_ID_URL"}(EnvKey||(EnvKey={}));export class EnvManager{constructor(){this.currentEnv=EnvName.PROD,this.currentEnv=EnvManager.getEnvName()}get(e){return EnvManager.envs[this.currentEnv][e]}static getEnvName(){const e=window.localStorage.getItem("clTemplatesEnv"),n=window.localStorage.getItem("clTemplatesAdditionalEnvConfig");if(n){const e=JSON.parse(n);EnvManager.envs[e.env]=e.config}if(e)switch(e){case"local":return EnvName.LOCAL;case"stage":return EnvName.STAGE;default:return EnvName.PROD}return window.location.href.includes("localhost")?EnvName.LOCAL:EnvName.PROD}}EnvManager.envs={[EnvName.LOCAL]:{[EnvKey.TEMPLATES_URL]:"/library/templates.json",[EnvKey.FILTERS_URL]:"/library/v1/public/filters",[EnvKey.TEMPLATE_BY_ID_URL]:"/library/v1/public/template"},[EnvName.PROD]:{[EnvKey.TEMPLATES_URL]:"https://cdn.claspo.io/library/templates.json",[EnvKey.FILTERS_URL]:"https://my.claspo.io/library/v1/public/filters",[EnvKey.TEMPLATE_BY_ID_URL]:"https://my.claspo.io/library/v1/public/template"}};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import HttpAbortableLoader from '@claspo/common/HttpAbortableLoader';
|
|
2
|
+
import TemplateBriefI from "./TemplateBrief.interface";
|
|
3
|
+
export default class HttpDebugTemplateLoader extends HttpAbortableLoader {
|
|
4
|
+
private list;
|
|
5
|
+
constructor(url: string, headers?: object);
|
|
6
|
+
load(): Promise<TemplateBriefI[]>;
|
|
7
|
+
static getDebugTemplateIds(): number[];
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import HttpAbortableLoader from"@claspo/common/HttpAbortableLoader";import HttpClient from"@claspo/common/network/HttpClient";export default class HttpDebugTemplateLoader extends HttpAbortableLoader{constructor(t,e={}){super(t,e,HttpClient),this.list=[]}async load(){return(await Promise.all(HttpDebugTemplateLoader.getDebugTemplateIds().map(t=>HttpClient.execute(`${this.url}/${t}`,"GET",null,null,this.abortController).then(t=>t.ok?t.json():null).catch(()=>null)))).filter(t=>null!==t)}static getDebugTemplateIds(){let t=[];try{const e=localStorage.getItem("clDebugTemplateIds");return e&&(t=e.split(",").map(t=>+t.trim()).filter(t=>!isNaN(t))),t}catch(e){return t}}}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import HttpAbortableLoader from '@claspo/common/HttpAbortableLoader';
|
|
2
|
+
import TemplateBriefI from "./TemplateBrief.interface";
|
|
3
|
+
export default class HttpTemplateLoader extends HttpAbortableLoader {
|
|
4
|
+
private list;
|
|
5
|
+
constructor(url: string, headers?: object);
|
|
6
|
+
load(): Promise<TemplateBriefI[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import HttpAbortableLoader from"@claspo/common/HttpAbortableLoader";import HttpClient from"@claspo/common/network/HttpClient";export default class HttpTemplateLoader extends HttpAbortableLoader{constructor(t,o={}){super(t,o,HttpClient),this.list=[]}load(){return super.load().then(t=>t.json()).then(t=>(this.list=t,t))}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defaultGridOptions}from"./grid/DefaultGridOptions";export function mapGridOptions(i){return{algorithm:(null==i?void 0:i.algorithm)||defaultGridOptions.algorithm,zoomIndex:(null==i?void 0:i.zoomIndex)||defaultGridOptions.zoomIndex,gridGapPx:(null==i?void 0:i.gridGapPx)||defaultGridOptions.gridGapPx,rowGapPx:(null==i?void 0:i.rowGapPx)||defaultGridOptions.rowGapPx}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TemplatePublishStatus } from "./TemplatePublishStatus.enum";
|
|
2
|
+
import TemplateSizeI from "./TemplateSize.interface";
|
|
3
|
+
import TemplateLauncherItemI from "./TemplateLauncherItem.interface";
|
|
4
|
+
import { TemplateType } from "./TemplateType.enum";
|
|
5
|
+
import SortableRecordI from "./SortableRecord.interface";
|
|
6
|
+
import { WidgetType } from './WidgetType.enum';
|
|
7
|
+
export default interface TemplateI<ruleType, layoutType, documentType = any, syncType = any> extends SortableRecordI {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
publishStatus: TemplatePublishStatus;
|
|
11
|
+
rules: ruleType;
|
|
12
|
+
widgetType: WidgetType;
|
|
13
|
+
type: TemplateType;
|
|
14
|
+
json: {
|
|
15
|
+
document: documentType;
|
|
16
|
+
sync: syncType;
|
|
17
|
+
};
|
|
18
|
+
dynamicParams?: {
|
|
19
|
+
cssVars: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
backgroundInline: {
|
|
23
|
+
path: number[];
|
|
24
|
+
props: object;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
launchers: TemplateLauncherItemI[];
|
|
28
|
+
layouts: layoutType[];
|
|
29
|
+
useCases: string[];
|
|
30
|
+
industry: string[];
|
|
31
|
+
themes: string[];
|
|
32
|
+
features: string[];
|
|
33
|
+
imagePreviews: string[];
|
|
34
|
+
createdDate?: string;
|
|
35
|
+
updatedDate?: string;
|
|
36
|
+
prizePools?: any[];
|
|
37
|
+
size?: TemplateSizeI;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import TemplateBriefI from "./TemplateBrief.interface";
|
|
2
|
+
import { GridOptionsI } from "./grid/GridOptions.interface";
|
|
3
|
+
import TemplateDatasourceI from "./TemplateDatasource.interface";
|
|
4
|
+
import TemplateFilterObserver from "./filter/TemplateFilterObserver";
|
|
5
|
+
import TemplateFilterDatasourceI from "./filter/TemplateFilterDatasource.interface";
|
|
6
|
+
export interface DataFetched {
|
|
7
|
+
limit: number;
|
|
8
|
+
offset: number;
|
|
9
|
+
totalCount: number;
|
|
10
|
+
items: TemplateBriefI[];
|
|
11
|
+
}
|
|
12
|
+
export declare enum EVENTS {
|
|
13
|
+
DATA_FETCHED = 0
|
|
14
|
+
}
|
|
15
|
+
export type Subscription = {
|
|
16
|
+
off: () => void;
|
|
17
|
+
};
|
|
18
|
+
declare const TemplateDatasource_base: any;
|
|
19
|
+
export default class TemplateDatasource extends TemplateDatasource_base implements TemplateDatasourceI {
|
|
20
|
+
gridOptions: GridOptionsI;
|
|
21
|
+
private templateLoader;
|
|
22
|
+
private debugTemplateLoader;
|
|
23
|
+
private dataStrategy;
|
|
24
|
+
private maxRowWidthPx;
|
|
25
|
+
private filterObserver;
|
|
26
|
+
private filterDatasource;
|
|
27
|
+
private envManager;
|
|
28
|
+
private items;
|
|
29
|
+
private rawItems;
|
|
30
|
+
constructor(maxRowWidthPx: number, gridOptions: null | GridOptionsI, filterObserver: TemplateFilterObserver | null, filterDatasource: TemplateFilterDatasourceI);
|
|
31
|
+
onNext(cb: (payload: DataFetched) => void): Subscription;
|
|
32
|
+
getItems(): TemplateBriefI[];
|
|
33
|
+
getRawItems(): TemplateBriefI[];
|
|
34
|
+
publish(eventName: string, payload: any): void;
|
|
35
|
+
subscribe(eventName: EVENTS, subscription: (payload: any) => void): Subscription;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
findByIdRawItems(id: number): TemplateBriefI | undefined;
|
|
38
|
+
private computeData;
|
|
39
|
+
private onFilterValueChanged;
|
|
40
|
+
private transformFilterResponseToFilterValue;
|
|
41
|
+
private dispatchUpdate;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import TemplateBriefI from "./TemplateBrief.interface";
|
|
2
|
+
import { DataFetched, Subscription } from "./TemplateDatasource";
|
|
3
|
+
export default interface TemplateDatasourceI {
|
|
4
|
+
getItems(): TemplateBriefI[];
|
|
5
|
+
getRawItems(): TemplateBriefI[];
|
|
6
|
+
findByIdRawItems(id: number): TemplateBriefI | undefined;
|
|
7
|
+
onNext(cb: (payload: DataFetched) => void): Subscription;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import HttpTemplateLoader from"./HttpTemplateLoader";import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import{EnvKey,EnvManager}from"./EnvManager";import{DataStrategy}from"./data/DataStrategy";import{mapGridOptions}from"./MapGridOptions";import TemplateGridConstructorParamsError from"./error/TemplateGridConstructorArgumentsError";import FilterApplier from"./filter/FilterApplier";import TemplateMapper from"./TemplateMapper";import HttpDebugTemplateLoader from"./HttpDebugTemplateLoader";import{WidgetType}from"./WidgetType.enum";export var EVENTS;!function(t){t[t.DATA_FETCHED=0]="DATA_FETCHED"}(EVENTS||(EVENTS={}));export default class TemplateDatasource extends DefaultEventEmitter{constructor(t,e,r,i){if(super(),this.envManager=new EnvManager,this.items=[],this.rawItems=[],Number.isNaN(t)||t<1)throw new TemplateGridConstructorParamsError("'maxRowWidthPx' must be positive number, received: "+t);this.maxRowWidthPx=t,this.gridOptions=mapGridOptions(e),this.filterObserver=r,this.filterDatasource=i;const a=this.envManager.get(EnvKey.TEMPLATES_URL),s=this.envManager.get(EnvKey.TEMPLATE_BY_ID_URL);this.templateLoader=new HttpTemplateLoader(a,{}),this.debugTemplateLoader=new HttpDebugTemplateLoader(s,{}),this.dataStrategy=new DataStrategy(this.gridOptions.algorithm),Promise.all([this.filterDatasource.getAllFilterGroups(),this.templateLoader.load().then(TemplateMapper.mapTemplates),this.debugTemplateLoader.load().then(TemplateMapper.mapTemplates)]).then(([t,e,r])=>{this.rawItems=e.concat(r),this.items=this.computeData(this.rawItems,this.transformFilterResponseToFilterValue(this.filterDatasource.getInitialFilters())),this.dispatchUpdate()}),this.filterObserver&&this.filterObserver.subscribe(this.onFilterValueChanged.bind(this))}onNext(t){return this.subscribe(EVENTS.DATA_FETCHED,t)}getItems(){return this.items}getRawItems(){return this.rawItems}publish(t,e){this.emit(t,e)}subscribe(t,e){return this.on(t,e)}destroy(){super.destroy()}findByIdRawItems(t){return this.getRawItems().find(e=>e.id===t)}computeData(t,e){const r=FilterApplier.apply(t.filter(t=>!(t.dynamicParams&&t.dynamicParams.fromScratch||t.widgetType===WidgetType.TEASER)),e);return this.dataStrategy.execute(r,this.maxRowWidthPx,this.gridOptions,this.filterDatasource)}onFilterValueChanged(t){this.items=this.computeData(this.rawItems,t),this.dispatchUpdate()}transformFilterResponseToFilterValue(t){return t.map(t=>({type:t.type,items:t.items.reduce((t,e)=>Object.assign(Object.assign({},t),{[e.key]:e.isActive}),{})}))}dispatchUpdate(){const t={limit:0,offset:0,items:this.items,totalCount:0};this.emit(EVENTS.DATA_FETCHED,t)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TemplateType}from"./TemplateType.enum";import DocumentCssVarsReplace from"@claspo/common/document/DocumentCssVarsReplace";import DocumentUtils from"@claspo/common/document/DocumentUtils";export default class TemplateMapper{static mapTemplates(e){return e.map(e=>{var s,o;if(e.type===TemplateType.STATIC)return e;let t=null===(s=e.dynamicParams)||void 0===s?void 0:s.cssVars;const a=null===(o=e.dynamicParams)||void 0===o?void 0:o.backgroundInline;if(t){let s=e.json.document;e.json.document=DocumentCssVarsReplace.replaceValues(s,t),e.json.document.shared.cssVars=t}return a&&(null==a||a.forEach(({path:s,props:o})=>{const t=DocumentUtils.getNodeByPath(e.json.document.views,s);t.props=Object.assign(Object.assign({},t.props),o)})),e})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var TemplatePublishStatus;!function(t){t.PUBLISHED="PUBLISHED",t.DEBUG="DEBUG"}(TemplatePublishStatus||(TemplatePublishStatus={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var TemplateType;!function(e){e.STATIC="STATIC",e.DYNAMIC="DYNAMIC",e.DEMO="DEMO",e.DYNAMIC_DEMO="DYNAMIC_DEMO"}(TemplateType||(TemplateType={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var WidgetType;!function(R){R.SUBSCRIPTION_FORM="SUBSCRIPTION_FORM",R.INFORMER="INFORMER",R.REQUEST_FORM="REQUEST_FORM",R.LAUNCHER="LAUNCHER",R.AGE_VERIFY="AGE_VERIFY",R.TEASER="TEASER"}(WidgetType||(WidgetType={}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GridAlgorithm } from "../grid/GridAlgorithm.enum";
|
|
2
|
+
import { DataStrategyI } from "./DataStrategy.interface";
|
|
3
|
+
import TemplateBriefI from "../TemplateBrief.interface";
|
|
4
|
+
import { GridOptionsI } from "../grid/GridOptions.interface";
|
|
5
|
+
import TemplateFilterDatasource from "../filter/TemplateFilterDatasource";
|
|
6
|
+
export declare class DataStrategy implements DataStrategyI {
|
|
7
|
+
private algorithm;
|
|
8
|
+
private strategy;
|
|
9
|
+
constructor(algorithm: GridAlgorithm);
|
|
10
|
+
execute(array: TemplateBriefI[], maxRowWidthPx: number, gridOptions: GridOptionsI, filterDatasource: TemplateFilterDatasource): TemplateBriefI[];
|
|
11
|
+
private static applyConcreteStrategy;
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import TemplateBriefI from "../TemplateBrief.interface";
|
|
2
|
+
import { GridOptionsI } from "../grid/GridOptions.interface";
|
|
3
|
+
import TemplateFilterDatasourceI from "../filter/TemplateFilterDatasource.interface";
|
|
4
|
+
export interface DataStrategyI {
|
|
5
|
+
execute(array: TemplateBriefI[], maxRowWidthPx: number, gridOptions: GridOptionsI, filterDatasource: TemplateFilterDatasourceI): TemplateBriefI[];
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GridAlgorithm}from"../grid/GridAlgorithm.enum";import{DefaultStrategy}from"./strategies/default-strategy/DefaultStrategy";import WeightStrategy from"./strategies/weight-strategy/WeightStrategy";import SimilarRandomWeightStrategy from"./strategies/similar-random-weight-strategy/SimilarRandomWeightStrategy";export class DataStrategy{constructor(t){this.algorithm=t,this.strategy=DataStrategy.applyConcreteStrategy(this.algorithm)}execute(t,r,e,a){return this.strategy.execute(t,r,e,a)}static applyConcreteStrategy(t){switch(t){case GridAlgorithm.DEFAULT:return new DefaultStrategy;case GridAlgorithm.WEIGHT_FIRST:return new WeightStrategy;case GridAlgorithm.SIMILAR_RANDOM_WEIGHT:return new SimilarRandomWeightStrategy;default:throw new Error(`Strategy ${t} is not supported`)}}}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataStrategyI } from "../../DataStrategy.interface";
|
|
2
|
+
import TemplateBriefI from "../../../TemplateBrief.interface";
|
|
3
|
+
import { GridOptionsI } from "../../../grid/GridOptions.interface";
|
|
4
|
+
import TemplateFilterDatasourceI from "../../../filter/TemplateFilterDatasource.interface";
|
|
5
|
+
export declare class DefaultStrategy implements DataStrategyI {
|
|
6
|
+
execute(array: TemplateBriefI[], maxRowWidthPx: number, gridOptions: GridOptionsI, filterDatasource: TemplateFilterDatasourceI): TemplateBriefI[];
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class DefaultStrategy{execute(e,t,r,a){return e.sort((e,t)=>e.id>t.id?-1:1)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function shuffle(pristineArray: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function shuffle(t){const e=t.slice();let o,f=e.length;for(;0!=f;)o=Math.floor(Math.random()*f),f--,[e[f],e[o]]=[e[o],e[f]];return e}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataStrategyI } from "../../DataStrategy.interface";
|
|
2
|
+
import TemplateBriefI from "../../../TemplateBrief.interface";
|
|
3
|
+
import { GridOptionsI } from "../../../grid/GridOptions.interface";
|
|
4
|
+
import TemplateFilterDatasourceI from "../../../filter/TemplateFilterDatasource.interface";
|
|
5
|
+
import WeightStrategy from "../weight-strategy/WeightStrategy";
|
|
6
|
+
export default class SimilarRandomWeightStrategy extends WeightStrategy implements DataStrategyI {
|
|
7
|
+
constructor();
|
|
8
|
+
execute(array: TemplateBriefI[], maxRowWidthPx: number, gridOptions: GridOptionsI, filterDatasource: TemplateFilterDatasourceI): TemplateBriefI[];
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import shuffle from"../shuffle";import WeightStrategy from"../weight-strategy/WeightStrategy";export default class SimilarRandomWeightStrategy extends WeightStrategy{constructor(){super()}execute(e,t,r,g){return super.execute(shuffle(e),t,r,g)}}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataStrategyI } from "../../DataStrategy.interface";
|
|
2
|
+
import TemplateBriefI from "../../../TemplateBrief.interface";
|
|
3
|
+
import { GridOptionsI } from "../../../grid/GridOptions.interface";
|
|
4
|
+
import TemplateFilterDatasourceI from "../../../filter/TemplateFilterDatasource.interface";
|
|
5
|
+
export default class WeightStrategy implements DataStrategyI {
|
|
6
|
+
execute(array: TemplateBriefI[], maxRowWidthPx: number, gridOptions: GridOptionsI, filterDatasource: TemplateFilterDatasourceI): TemplateBriefI[];
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import computeTemplateWeight from"./computeTemplateWeight";function cache(t){const e=this.data||{};return function(c,r){return e[r]||(e[r]=t(c)),e[r]}}export default class WeightStrategy{execute(t,e,c,r){const n=cache.bind({data:{}})(t=>computeTemplateWeight(t,r.getAllFilterGroupsSync()));return t.sort((t,e)=>{const c=n(t,t.id);let r=n(e,e.id);return c>r?-1:c<r?1:0})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_SORT_WEIGHT,getPreferredWeight}from"./getPreferredWeight";export default function computeTemplateWeight(e,t){var r;const i=[],h=t.find(e=>"THEME"===e.type),l=h.items.filter(e=>{var t;return null===(t=e.sortWeight)||void 0===t?void 0:t.length}).map(getPreferredWeight),g=Math.max(...l);if((null===(r=e.sortWeight)||void 0===r?void 0:r.length)&&i.push(getPreferredWeight(e)),"LAUNCHER"===e.layouts[0]&&i.push(-(g+1)),"LAUNCHER"!==e.layouts[0]&&e.themes){const t=h.items.filter(t=>e.themes.includes(t.key)).filter(e=>{var t;return null===(t=e.sortWeight)||void 0===t?void 0:t.length}).map(getPreferredWeight),r=t.length?Math.max(...t):DEFAULT_SORT_WEIGHT.value;i.push(r)}return e.id%2?i.push(-.1):i.push(.1),i.length?i.reduce((e,t)=>e+t,0):0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_SORT_WEIGHT={startDate:null,endDate:null,value:0};function isBeforeOrEqual(e,t){if(!t)return!1;const[n,r,a]=t.split("-"),u="YYYY"===n?e.getFullYear():parseInt(n),i="MM"===r?e.getMonth():parseInt(r)-1,s="DD"===a?e.getDate():parseInt(a);return e<=new Date(u,i,s)}function isAfterOrEqual(e,t){if(!t)return!1;const[n,r,a]=t.split("-"),u="YYYY"===n?e.getFullYear():parseInt(n),i="MM"===r?e.getMonth():parseInt(r)-1,s="DD"===a?e.getDate():parseInt(a);return e>=new Date(u,i,s)}function isDateInRange(e,t,n){return t?n?isBeforeOrEqual(e,n)&&isAfterOrEqual(e,t):isAfterOrEqual(e,t):isBeforeOrEqual(e,n)}function getActiveRange(e=[DEFAULT_SORT_WEIGHT]){const t=new Date;t.setHours(0,0,0,0);return e.find(e=>isDateInRange(t,e.startDate,e.endDate))||e.find(e=>e.startDate===DEFAULT_SORT_WEIGHT.startDate&&e.endDate===DEFAULT_SORT_WEIGHT.endDate)||DEFAULT_SORT_WEIGHT}export function getPreferredWeight(e){var t;if(!(null===(t=null==e?void 0:e.sortWeight)||void 0===t?void 0:t.length))return DEFAULT_SORT_WEIGHT.value;const n=getActiveRange(e.sortWeight);return(null==n?void 0:n.value)||DEFAULT_SORT_WEIGHT.value}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPreferredWeight}from"./getPreferredWeight";export default function sortByWeightPredicate(e,r){return getPreferredWeight(e)>getPreferredWeight(r)?-1:1}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import TemplateBriefI from "../../../TemplateBrief.interface";
|
|
2
|
+
import { DataStrategyI } from "../../DataStrategy.interface";
|
|
3
|
+
import { GridOptionsI } from "../../../grid/GridOptions.interface";
|
|
4
|
+
import TemplateFilterDatasourceI from "../../../filter/TemplateFilterDatasource.interface";
|
|
5
|
+
export declare class WidthBasedStrategy implements DataStrategyI {
|
|
6
|
+
execute(array: TemplateBriefI[], maxRowWidthPx: number, gridOptions: GridOptionsI, filterDatasource: TemplateFilterDatasourceI): TemplateBriefI[];
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import widthFirstAlgorithm from"./width-first-algorithm/widthFirstAlgorithm";export class WidthBasedStrategy{execute(t,r,i,o){return widthFirstAlgorithm(t,r,i.zoomIndex,i.rowGapPx)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getCurrentRowWidth}from"./getCurrentRowWidth";import{findNextModel}from"./findNextModel";import filterOffDuplicates from"./filterOffDuplicates";export default function buildRow(t,e,i=1,r=0,f){let l=0;const o=[];let n=filterOffDuplicates(t,f);if(!n.length)return null;for(;n.length&&l<=n.length;){const t=getCurrentRowWidth(o,i,r);if(!(e-t>30))break;{const r=findNextModel(n,t,i,e);r&&(o.push(r),f.push(r.id),n=filterOffDuplicates(n,f).sort((t,e)=>t.id>e.id?-1:1))}l++}return o}
|
package/data/strategies/width-based-strategy/width-first-algorithm/convertArrayToMapByField.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertArrayToMapByField<T>(array: T[], propName: any): Map<number, T>;
|
package/data/strategies/width-based-strategy/width-first-algorithm/convertArrayToMapByField.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function convertArrayToMapByField(e,r){return e.reduce((e,n)=>(e.set(n[r],n),e),new Map)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mapSizeModel}from"./mapSizeModel";export function createSizeModels(e){let t=e.map(mapSizeModel).sort((e,t)=>e.heightPx>t.heightPx?1:-1);const i=t[t.length-1].heightPx;return t.map(e=>Object.assign(Object.assign({},e),{heightPercent:100*e.heightPx/i}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isModelAlreadyPresent}from"./isModelAlreadyPresent";export default function filterOffDuplicates(e,r){return e.filter(e=>!isModelAlreadyPresent(e.id,r))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function findNextModel(n,t,d,e){return n.find(n=>t+n.widthPx*d<=e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const generateRandomValue=(a,e)=>Math.floor(Math.random()*(e-a))+a;export default generateRandomValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCurrentRowWidth(row: any, zoomIndex: any, modelGapPx: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getCurrentRowWidth(t,e,n){const r=t.length*n;return t.reduce((t,n)=>t+ +n.widthPx*e,0)+r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/data/strategies/width-based-strategy/width-first-algorithm/groupModelsByPercentHeight.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import shuffle from"../../shuffle";export function groupModelsByPercentHeight(e,t){let f={};return e.forEach(e=>{const r=t.findIndex(t=>e.heightPercent<=t);f[r]?f[r].push(e):f[r]=[e]}),Object.keys(e=>{f[e]=shuffle(f[e])}),f}
|
package/data/strategies/width-based-strategy/width-first-algorithm/groupObjectMap.interface.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isModelAlreadyPresent(targetId: number, models: number[]): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function isModelAlreadyPresent(e,n){return!!n.find(n=>n===e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mapSizeModel(e){let t=e.json.document.shared.actualSize.desktop;return{id:e.id,widthPx:parseInt(t.width||"0"),heightPx:parseInt(t.height||"0"),heightPercent:0}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import buildRow from"./buildRow";import{convertArrayToMapByField}from"./convertArrayToMapByField";import{createSizeModels}from"./createSizeModels";import{groupModelsByPercentHeight}from"./groupModelsByPercentHeight";export default function widthFirstAlgorithm(e,t,o,r){let i=[],l=[];if(!e.length)return[];l=e.length<=3?[100]:[50,100];const n=convertArrayToMapByField(e,"id"),d=createSizeModels(e),c=groupModelsByPercentHeight(d,l),g=[];let p=0,a=0;for(;d.length>g.length&&!(a>e.length);){const e=c[p];if(e){const l=buildRow(e,t,o,r,g);if(l){const e=l.map(e=>n.get(e.id));i.push(e)}}p++,p===l.length&&(p=0),a++}return i.flat()}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface ClDialogSliderComponentI extends HTMLElement {
|
|
2
|
+
open(): void;
|
|
3
|
+
close(): void;
|
|
4
|
+
}
|
|
5
|
+
declare class ClDialogSliderComponent extends HTMLElement implements ClDialogSliderComponentI {
|
|
6
|
+
private _dynamicData;
|
|
7
|
+
private _boundEscapeListener;
|
|
8
|
+
static dialogSelector: string;
|
|
9
|
+
static dialogContentSelector: string;
|
|
10
|
+
static dialogCloseIconSelector: string;
|
|
11
|
+
static dialogLeftArrowSelector: string;
|
|
12
|
+
static dialogRightArrowSelector: string;
|
|
13
|
+
static template: string;
|
|
14
|
+
private dialogContainerElement;
|
|
15
|
+
private dialogLeftArrowElement;
|
|
16
|
+
private dialogRightArrowElement;
|
|
17
|
+
private dialogCloseIconElement;
|
|
18
|
+
private currentOverflowValue;
|
|
19
|
+
static get observedAttributes(): never[];
|
|
20
|
+
constructor();
|
|
21
|
+
get disabledLeft(): boolean | undefined;
|
|
22
|
+
set disabledLeft(disabled: boolean | undefined);
|
|
23
|
+
get disabledRight(): boolean | undefined;
|
|
24
|
+
set disabledRight(disabled: boolean | undefined);
|
|
25
|
+
get hideCloseBtn(): boolean | undefined;
|
|
26
|
+
set hideCloseBtn(isHidden: boolean | undefined);
|
|
27
|
+
open(): void;
|
|
28
|
+
close(): void;
|
|
29
|
+
attributeChangedCallback(): void;
|
|
30
|
+
disconnectedCallback(): void;
|
|
31
|
+
_upgradeProperty(prop: any): void;
|
|
32
|
+
keyboardListenerCallback(event: any): void;
|
|
33
|
+
_dispatchEvent(eventType: any): void;
|
|
34
|
+
}
|
|
35
|
+
export default ClDialogSliderComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var SliderEvents;!function(e){e.getPrev="getPrev",e.getNext="getNext"}(SliderEvents||(SliderEvents={}));class ClDialogSliderComponent extends HTMLElement{static get observedAttributes(){return[]}constructor(){var e,n,l,i;super();const t=this.attachShadow({mode:"open"}),o=document.createElement("div");o.insertAdjacentHTML("beforeend",ClDialogSliderComponent.template),t.appendChild(o),this.dialogContainerElement=t.querySelector(ClDialogSliderComponent.dialogSelector),this.dialogLeftArrowElement=t.querySelector(ClDialogSliderComponent.dialogLeftArrowSelector),this.dialogRightArrowElement=t.querySelector(ClDialogSliderComponent.dialogRightArrowSelector),this.dialogCloseIconElement=t.querySelector(ClDialogSliderComponent.dialogCloseIconSelector),this.currentOverflowValue=document.body.style.overflow,null===(e=this.dialogCloseIconElement)||void 0===e||e.addEventListener("click",()=>{this.close()}),null===(n=this.dialogLeftArrowElement)||void 0===n||n.addEventListener("click",()=>{this._dispatchEvent(SliderEvents.getPrev)}),null===(l=this.dialogRightArrowElement)||void 0===l||l.addEventListener("click",()=>{this._dispatchEvent(SliderEvents.getNext)}),null===(i=this.dialogContainerElement)||void 0===i||i.addEventListener("click",e=>{e.target===this.dialogContainerElement&&this.close()}),this._boundEscapeListener=this.keyboardListenerCallback.bind(this)}get disabledLeft(){var e;return null===(e=this.dialogLeftArrowElement)||void 0===e?void 0:e.hasAttribute("disabled")}set disabledLeft(e){var n,l;e?null===(n=this.dialogLeftArrowElement)||void 0===n||n.setAttribute("disabled",""):null===(l=this.dialogLeftArrowElement)||void 0===l||l.removeAttribute("disabled")}get disabledRight(){var e;return null===(e=this.dialogRightArrowElement)||void 0===e?void 0:e.hasAttribute("disabled")}set disabledRight(e){var n,l;e?null===(n=this.dialogRightArrowElement)||void 0===n||n.setAttribute("disabled",""):null===(l=this.dialogRightArrowElement)||void 0===l||l.removeAttribute("disabled")}get hideCloseBtn(){var e;return null===(e=this.dialogCloseIconElement)||void 0===e?void 0:e.classList.contains("cl-dialog-slider-close-icon--hidden")}set hideCloseBtn(e){var n,l;e?null===(n=this.dialogCloseIconElement)||void 0===n||n.classList.add("cl-dialog-slider-close-icon--hidden"):null===(l=this.dialogCloseIconElement)||void 0===l||l.classList.remove("cl-dialog-slider-close-icon--hidden")}open(){var e;document.body.style.overflow="hidden",this.setAttribute("open","true"),null===(e=this.dialogContainerElement)||void 0===e||e.classList.add("cl-dialog-slider-open");const n=this.querySelector("a,button,input");null==n||n.focus(),window.addEventListener("keyup",this._boundEscapeListener)}close(){var e;document.body.style.overflow=this.currentOverflowValue,this.removeAttribute("open"),null===(e=this.dialogContainerElement)||void 0===e||e.classList.remove("cl-dialog-slider-open"),this._dispatchEvent("closed"),window.removeEventListener("keyup",this._boundEscapeListener)}attributeChangedCallback(){}disconnectedCallback(){window.removeEventListener("keyup",this._boundEscapeListener)}_upgradeProperty(e){if(this.hasOwnProperty(e)){let n=this[e];delete this[e],this[e]=n}}keyboardListenerCallback(e){"Escape"===e.key?this.close():"ArrowLeft"===e.key?this._dispatchEvent(SliderEvents.getPrev):"ArrowRight"===e.key&&this._dispatchEvent(SliderEvents.getNext)}_dispatchEvent(e){this.dispatchEvent(new CustomEvent(e,{detail:{},bubbles:!0,composed:!0}))}}ClDialogSliderComponent.dialogSelector=".cl-dialog-slider",ClDialogSliderComponent.dialogContentSelector=".cl-dialog-slider-content",ClDialogSliderComponent.dialogCloseIconSelector=".cl-dialog-slider-close-icon",ClDialogSliderComponent.dialogLeftArrowSelector=".cl-dialog-slider-arrow-left",ClDialogSliderComponent.dialogRightArrowSelector=".cl-dialog-slider-arrow-right",ClDialogSliderComponent.template='\n<div class="cl-dialog-slider">\n <style>\n .cl-dialog-slider {\n z-index: -1;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n width: 0;\n height: 0;\n display: none;\n justify-content: center;\n align-items: center;\n background: rgba(0, 0, 0, 0.7);\n }\n\n .cl-dialog-slider-open {\n display: flex;\n width: 100%;\n height: 100%;\n z-index: 998;\n }\n\n .cl-dialog-slider-inner-content {\n position: relative;\n max-width: 100vw;\n background: #fff;\n }\n\n .cl-dialog-slider-close-icon {\n position: absolute;\n top: 30px;\n right: 50px;\n font-size: 9px;\n color: #000;\n opacity: .75;\n cursor: pointer;\n z-index: 99;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 44px;\n width: 44px;\n border-radius: 50%;\n }\n\n .cl-dialog-slider-close-icon:hover {\n opacity: 1;\n background-color: #e6e6e6;\n }\n\n .cl-dialog-slider-close-icon--hidden {\n display: none;\n }\n\n .cl-dialog-slider [cl-type="VIEW"] {\n max-height: calc(100vh - 170px);\n overflow-y: auto;\n overflow-x: hidden;\n }\n\n .cl-dialog-slider-arrow {\n display:flex;\n align-items:center;\n justify-content: center;\n height: 50px;\n width: 50px;\n border-radius: 25px;\n background: #FFFFFF;\n border: 2px solid #F3492C;\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(0, 0, 0, 0.07);\n position: absolute;\n top: 325px;\n z-index: 999999999;\n cursor: pointer;\n }\n\n button.cl-dialog-slider-arrow[disabled] {\n border: 2px solid #e2dede;\n }\n button.cl-dialog-slider-arrow[disabled] svg path {\n fill: #e2dede;\n }\n\n .cl-dialog-slider-arrow:hover {\n background: #e6e6e6;\n }\n\n .cl-dialog-slider-arrow-left {\n left: 20px;\n }\n\n .cl-dialog-slider-arrow-right {\n right: 20px;\n }\n\n .cl-no-scroll {\n overflow: hidden;\n }\n </style>\n <button class="cl-dialog-slider-arrow cl-dialog-slider-arrow-left" disabled>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M9 12L8.05719 11.0572L7.11438 12L8.05719 12.9428L9 12ZM14.0572 5.05719L8.05719 11.0572L9.94281 12.9428L15.9428 6.94281L14.0572 5.05719ZM8.05719 12.9428L14.0572 18.9428L15.9428 17.0572L9.94281 11.0572L8.05719 12.9428Z" fill="#5F5F5F"/>\n </svg>\n </button>\n\n\n <div class="cl-dialog-slider-inner-content">\n <div class="cl-dialog-slider-close-icon">\n <div class="cl-dialog-slider-close-icon-content"></div>\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M18 6L6 18M6 6L18 18" stroke="#2C2C2C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n\n <div class="cl-dialog-slider-content">\n <slot></slot>\n</div>\n </div>\n\n <button class="cl-dialog-slider-arrow cl-dialog-slider-arrow-right">\n <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M15 12L15.9428 11.0572L16.8856 12L15.9428 12.9428L15 12ZM9.94281 5.05719L15.9428 11.0572L14.0572 12.9428L8.05719 6.94281L9.94281 5.05719ZM15.9428 12.9428L9.94281 18.9428L8.05719 17.0572L14.0572 11.0572L15.9428 12.9428Z" fill="#5F5F5F"/>\n </svg>\n </button>\n</div>\n',customElements.get("cl-dialog-slider")||customElements.define("cl-dialog-slider",ClDialogSliderComponent);export default ClDialogSliderComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class TemplateGridConstructorArgumentsError extends Error{constructor(r){super(r),this.name=this.constructor.name}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import TemplateBriefI from "../TemplateBrief.interface";
|
|
2
|
+
import { FilterValueI } from "./FilterValue.interface";
|
|
3
|
+
import { FilterGroupType } from "./FilterGroupType";
|
|
4
|
+
export default class FilterApplier {
|
|
5
|
+
static apply(items: TemplateBriefI[], filterValue: FilterValueI | null): TemplateBriefI[];
|
|
6
|
+
static filterValuePredicate(t: TemplateBriefI, f: FilterValueI | null): boolean;
|
|
7
|
+
private static getSwitchedOnItemsFromGroup;
|
|
8
|
+
static templateHasAtLeastOneItem(t: TemplateBriefI, groupType: FilterGroupType, switchedOnItems: string[]): boolean;
|
|
9
|
+
private static templateHasItem;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import mapFilterGroupTypeToTemplateField from"./mapFilterGroupTypeToTemplateField";export default class FilterApplier{static apply(e,t){return e.filter(e=>FilterApplier.filterValuePredicate(e,t))}static filterValuePredicate(e,t){if(!t)return!0;let r=t.map(t=>!!Object.values(t.items).every(e=>!1===e&&e===Object.values(t.items)[0])||this.templateHasAtLeastOneItem(e,t.type,this.getSwitchedOnItemsFromGroup(t)));return r.filter(e=>e).length===r.length}static getSwitchedOnItemsFromGroup(e){return Object.keys(e.items).filter(t=>e.items[t])}static templateHasAtLeastOneItem(e,t,r){let i=!1;const l=mapFilterGroupTypeToTemplateField(t);return l&&e[l]?(i=!!e[l].find(e=>FilterApplier.templateHasItem(e.toString(),r)),i):i}static templateHasItem(e,t){return t.includes(e.toString())}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class FilterGroup{constructor(t,s){this.type=t,this.items=s}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var FilterGroupType;!function(E){E.USE_CASE="USE_CASE",E.LAYOUT="LAYOUT",E.INDUSTRY="INDUSTRY",E.THEME="THEME",E.FEATURES="FEATURES"}(FilterGroupType||(FilterGroupType={}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import FilterItemI from "./FilterItem.interface";
|
|
2
|
+
export default class FilterItem implements FilterItemI {
|
|
3
|
+
key: any;
|
|
4
|
+
translations: any;
|
|
5
|
+
sortWeight: any;
|
|
6
|
+
isActive: boolean;
|
|
7
|
+
hidden: boolean;
|
|
8
|
+
constructor(key: any, translations: any, sortWeight: any, isActive?: boolean, hidden?: boolean);
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class FilterItem{constructor(t,s,i,e=!1,h=!1){this.key=t,this.translations=s,this.sortWeight=i,this.isActive=e,this.hidden=h}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FilterGroupI } from "./FilterGroup.interface";
|
|
2
|
+
export default class FilterTranslator {
|
|
3
|
+
private lang;
|
|
4
|
+
private filterGroups;
|
|
5
|
+
private map;
|
|
6
|
+
constructor(lang: string, filterGroups: FilterGroupI[]);
|
|
7
|
+
translate(key: any): string;
|
|
8
|
+
getTranslationsMap(): Map<string, string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{flat}from"@claspo/common/flat";export default class FilterTranslator{constructor(t,a){this.lang=t,this.filterGroups=a,this.map=new Map,flat(a.map(t=>t.items)).forEach(a=>{this.map.set(a.key,a.translations[t]||a.key)})}translate(t){return this.map.get(t)||t}getTranslationsMap(){return this.map}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FilterResponseI } from "./FilterResponse.interface";
|
|
2
|
+
import HttpAbortableLoader from "@claspo/common/HttpAbortableLoader";
|
|
3
|
+
export default class HttpFilterLoader extends HttpAbortableLoader {
|
|
4
|
+
private filterResponse;
|
|
5
|
+
constructor(url: any, headers?: {});
|
|
6
|
+
load(): Promise<FilterResponseI>;
|
|
7
|
+
private map;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import HttpClient from"@claspo/common/network/HttpClient";import FilterGroup from"./FilterGroup";import FilterItem from"./FilterItem";import HttpAbortableLoader from"@claspo/common/HttpAbortableLoader";export default class HttpFilterLoader extends HttpAbortableLoader{constructor(t,e={}){super(t,e,HttpClient)}load(){return super.load().then(t=>t.json()).then(t=>this.map(t)).then(t=>(this.filterResponse=t,this.filterResponse))}map(t){return t.map(t=>new FilterGroup(t.type,t.items.map(t=>new FilterItem(t.key,t.translations,t.sortWeight,!1,t.hidden))))}}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FilterResponseI } from "./FilterResponse.interface";
|
|
2
|
+
import TemplateBriefI from "../TemplateBrief.interface";
|
|
3
|
+
import TemplateFilterDatasourceI from "./TemplateFilterDatasource.interface";
|
|
4
|
+
import { FilterGroupI } from "./FilterGroup.interface";
|
|
5
|
+
export default class TemplateFilterDatasource implements TemplateFilterDatasourceI {
|
|
6
|
+
private envManager;
|
|
7
|
+
private filterLoader;
|
|
8
|
+
private filterGroups;
|
|
9
|
+
private initialFilters;
|
|
10
|
+
constructor(initialFilters?: any);
|
|
11
|
+
get(items?: TemplateBriefI[]): Promise<FilterResponseI>;
|
|
12
|
+
getAllFilterGroups(): Promise<FilterResponseI>;
|
|
13
|
+
getAllFilterGroupsSync(): FilterResponseI;
|
|
14
|
+
getInitialFilters(): FilterGroupI[];
|
|
15
|
+
private filter;
|
|
16
|
+
static sort(filterGroups: FilterResponseI): FilterResponseI;
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FilterResponseI } from "./FilterResponse.interface";
|
|
2
|
+
import TemplateBriefI from "../TemplateBrief.interface";
|
|
3
|
+
interface TemplateFilterDatasourceI {
|
|
4
|
+
get(items: TemplateBriefI[]): Promise<FilterResponseI>;
|
|
5
|
+
getAllFilterGroups(): Promise<FilterResponseI>;
|
|
6
|
+
getAllFilterGroupsSync(): FilterResponseI;
|
|
7
|
+
getInitialFilters(): FilterResponseI;
|
|
8
|
+
}
|
|
9
|
+
export default TemplateFilterDatasourceI;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EnvKey,EnvManager}from"../EnvManager";import HttpFilterLoader from"./HttpFilterLoader";import{FilterGroupType}from"./FilterGroupType";import FilterApplier from"./FilterApplier";import FilterGroup from"./FilterGroup";import sortByWeightPredicate from"../data/strategies/weight-strategy/sortByWeightPredicate";import FilterItem from"./FilterItem";export default class TemplateFilterDatasource{constructor(t){this.envManager=new EnvManager,this.filterGroups=[],this.initialFilters=[],this.initialFilters=t||[],this.filterLoader=new HttpFilterLoader(this.envManager.get(EnvKey.FILTERS_URL))}get(t=[]){return this.getAllFilterGroups().then(e=>TemplateFilterDatasource.sort(this.filter(e,t)))}async getAllFilterGroups(){return this.filterGroups.length||(this.filterGroups=await this.filterLoader.load()),Promise.resolve(this.filterGroups)}getAllFilterGroupsSync(){return this.filterGroups}getInitialFilters(){return this.initialFilters}filter(t,e){let r=t.map(t=>{const r=this.initialFilters.find(e=>e.type===t.type);return new FilterGroup(t.type,t.items.filter(r=>!!e.find(e=>FilterApplier.templateHasAtLeastOneItem(e,t.type,[r.key]))).map(t=>{const e=r?r.items.find(e=>e.key===t.key):null,i=!!e&&e.isActive;return new FilterItem(t.key,t.translations,t.sortWeight,i,t.hidden)}))});return this.initialFilters.length&&(this.initialFilters=[]),r}static sort(t){let e=[];const r=[],i=[FilterGroupType.USE_CASE,FilterGroupType.FEATURES,FilterGroupType.LAYOUT,FilterGroupType.INDUSTRY,FilterGroupType.THEME];return t.forEach(t=>{t.items=t.items.sort(sortByWeightPredicate);const l=i.indexOf(t.type);-1!==l?e[l]=t:r.push(t)}),e=e.filter(Boolean),[...e,...r]}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FilterValueI } from "./FilterValue.interface";
|
|
2
|
+
declare const TemplateFilterObserver_base: any;
|
|
3
|
+
export default class TemplateFilterObserver extends TemplateFilterObserver_base {
|
|
4
|
+
static FILTER_CHANGED_EVENT_NAME: string;
|
|
5
|
+
constructor();
|
|
6
|
+
next(value: FilterValueI): void;
|
|
7
|
+
subscribe(listener: (value: FilterValueI) => void): {
|
|
8
|
+
off: () => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";export default class TemplateFilterObserver extends DefaultEventEmitter{constructor(){super()}next(e){this.emit(TemplateFilterObserver.FILTER_CHANGED_EVENT_NAME,e)}subscribe(e){return this.on(TemplateFilterObserver.FILTER_CHANGED_EVENT_NAME,e)}}TemplateFilterObserver.FILTER_CHANGED_EVENT_NAME="FILTER_CHANGED_EVENT_NAME";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FilterGroupType}from"./FilterGroupType";export default function mapFilterGroupTypeToTemplateField(e){switch(e){case FilterGroupType.LAYOUT:return"layouts";case FilterGroupType.USE_CASE:return"useCases";case FilterGroupType.INDUSTRY:return"industry";case FilterGroupType.THEME:return"themes";case FilterGroupType.FEATURES:return"features";default:return null}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GridAlgorithm}from"./GridAlgorithm.enum";export let defaultGridOptions={algorithm:GridAlgorithm.DEFAULT,zoomIndex:1,rowGapPx:0,gridGapPx:0};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var GridAlgorithm;!function(I){I.WIDTH_FIRST="WIDTH_FIRST",I.DEFAULT="DEFAULT",I.WEIGHT_FIRST="WEIGHT_FIRST",I.SIMILAR_RANDOM_WEIGHT="SIMILAR_RANDOM_WEIGHT"}(GridAlgorithm||(GridAlgorithm={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GridPreviewInitParamsI } from './GridPreviewInit.interface';
|
|
2
|
+
export default class GridPreview {
|
|
3
|
+
private documentConnector;
|
|
4
|
+
private viewComponentResourcesLoadedListener;
|
|
5
|
+
init(params: GridPreviewInitParamsI): HTMLElement;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
private renderDynamicPreviewInIframe;
|
|
8
|
+
private setWidgetStyles;
|
|
9
|
+
private shouldBeResized;
|
|
10
|
+
private resizeUntilScrollbarDisappears;
|
|
11
|
+
private adjustWidgetSize;
|
|
12
|
+
private applyScaleToPreviewInIframe;
|
|
13
|
+
private getWidgetWidth;
|
|
14
|
+
private getWidgetHeight;
|
|
15
|
+
private addClickHandlerToItem;
|
|
16
|
+
private createLoaderElement;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import LayoutType from"@claspo/common/form/common/LayoutType";import BaseElementInViewportHandler from"@claspo/common/element/BaseElementInViewportHandler";import StaticDocumentConnector from"@claspo/document-connector/StaticDocumentConnector";import PreviewBackgroundStyles from"@claspo/document-connector/PreviewBackgroundStyles";import SysTextComponent from"@claspo/components/SysTextComponent/SysTextComponent";import SysContainerComponent from"@claspo/components/SysContainerComponent/SysContainerComponent";import SysColumnsComponent from"@claspo/components/SysColumnsComponent/SysColumnsComponent";import SysColumnComponent from"@claspo/components/SysColumnComponent/SysColumnComponent";import SysImageComponent from"@claspo/components/SysImageComponent/SysImageComponent";import SysInputComponent from"@claspo/components/SysInputComponent/SysInputComponent";import SysButtonComponent from"@claspo/components/SysButtonComponent/SysButtonComponent";import{ViewRendererActionType}from"@claspo/renderer/sdk";export default class GridPreview{constructor(){this.documentConnector=null}init(e){const n=document.createElement("div");e.containerCssClasses&&(e.containerCssClasses.forEach(e=>n.classList.add(e)),e.containerCssClasses.includes("grid-item--placeholder")||(n.style.backgroundColor="lightgrey")),e.id&&(n.dataset.id=e.id.toString()),n.style.height=`${e.height}px`;return new BaseElementInViewportHandler(n,!1).handle(async()=>{n.classList.remove("grid-item--placeholder"),n.style.backgroundColor="",n.style.height=`${e.height}px`,await this.renderDynamicPreviewInIframe(e,n),e.templateVisibleCallback&&e.templateVisibleCallback()},()=>{var e;n.classList.add("grid-item--placeholder"),n.style.backgroundColor="lightgrey",this.documentConnector&&(null===(e=this.documentConnector)||void 0===e||e.destroy(),[...n.children].forEach(e=>e.remove()))}),n}destroy(){var e,n;null===(e=this.documentConnector)||void 0===e||e.destroy(),null===(n=this.viewComponentResourcesLoadedListener)||void 0===n||n.off()}async renderDynamicPreviewInIframe(e,n){const t=e.layoutType;let o;t!==LayoutType.DETACHED&&t!==LayoutType.BUILT_IN&&(o={width:"100%",height:"100%"});const i=Math.max(document.documentElement.clientWidth,window.innerWidth||0),l=Object.assign(Object.assign({},e.documentModel),{shared:Object.assign(Object.assign({},e.documentModel.shared),{launcher:Object.assign(Object.assign({},e.documentModel.shared.launcher),{entryAnimation:{type:null},loopAnimation:{type:null}}),floatingBox:Object.assign(Object.assign({},e.documentModel.shared.floatingBox),{entryAnimation:{type:null}}),dialog:Object.assign(Object.assign({},e.documentModel.shared.dialog),{background:"rgba(0, 0, 0, 0)"}),mobileBreakpointWidth:i-1})});this.documentConnector=new StaticDocumentConnector({layoutType:t,widgetType:e.widgetType,documentModel:l,bundledComponentClasses:e.useDefaultBundledComponentClasses?[SysTextComponent,SysContainerComponent,SysColumnsComponent,SysColumnComponent,SysImageComponent,SysInputComponent,SysButtonComponent]:e.bundledComponentClasses,config:{browserLanguage:navigator.language,optionalDocumentStyles:o,staticResourcesUrl:e.staticResourcesUrl,hostUrl:e.hostUrl,prizePoolModels:e.prizePoolModels,demoMode:!0},disabled:!0,disableSmartPosition:!0,disableScrollbarCalculation:!0,disableLayoutAnimations:!0});const s=document.createElement("iframe");s.style.border="0",t!==LayoutType.BUILT_IN&&(n.innerHTML=PreviewBackgroundStyles.getFullScreen(),n.style.position="relative",s.style.position="absolute",s.style.top="0px",s.style.left="0px"),s.addEventListener("load",async()=>{s.style.width="100%",s.style.height="100%";const n=s.contentWindow.document,o=this.createLoaderElement();n.body.appendChild(o),t===LayoutType.BUILT_IN&&n.body.append(PreviewBackgroundStyles.getBuiltInTopSection()),this.viewComponentResourcesLoadedListener=this.documentConnector.on(ViewRendererActionType.VIEW_COMPONENT_RESOURCES_LOADED,()=>{this.adjustWidgetSize(s)}),await this.documentConnector.connect(n.body),s.contentWindow&&s.contentWindow.document&&(o.remove(),t===LayoutType.BUILT_IN&&n.body.append(PreviewBackgroundStyles.getBuiltInBottomSection()),n.body.style.height="100%",n.body.style.margin="0px",n.body.style.cursor="pointer",this.addClickHandlerToItem(s.contentWindow.document.body,e.clickCallback),this.setWidgetStyles(l,t,t===LayoutType.BUILT_IN?e.width-40:e.width,t===LayoutType.BUILT_IN?e.height-40:e.height,s))}),n.appendChild(s)}setWidgetStyles(e,n,t,o,i){const l=i.contentWindow.document;i.style.width=`${t}px`,i.style.height=`${o}px`,i.style.border="none",i.style.transformOrigin="",i.style.transform="";const s=this.getWidgetHeight(n,e,"desktop"),r=this.getWidgetWidth(n,e,"desktop"),a=e=>this.applyScaleToPreviewInIframe(i,t,o,r,s,n,e);s&&s>o&&s-o>r-t?a(!1):r&&r>t&&a(!0),n===LayoutType.BUILT_IN&&(l.body.style.display="grid",l.body.style.gridTemplateRows="1fr auto 1fr",l.body.style.gridRowGap="15px",l.body.style.background="#F4F4F4")}shouldBeResized(e){const n=e.scrollWidth-e.clientWidth,t=e.scrollHeight-e.clientHeight;return n>0||t>0}resizeUntilScrollbarDisappears(e,n,t=.85){if(!(t<.5)&&this.shouldBeResized(e)){const o=t-.05;return n.style.transform=`scale(${o})`,n.style.transformOrigin="top left",this.resizeUntilScrollbarDisappears(e,n,o)}}adjustWidgetSize(e){var n;const t=null===(n=e.contentWindow)||void 0===n?void 0:n.document.body;if(!t)return;const o=t.querySelector(".cl-widget");o&&(t.querySelectorAll(".preview-placeholder-element").forEach(n=>{n instanceof HTMLElement&&(n.style.width=e.style.width)}),setTimeout(()=>{this.resizeUntilScrollbarDisappears(t,o)}))}applyScaleToPreviewInIframe(e,n,t,o,i,l,s){const r=s&&o>n?l===LayoutType.FLOATING_BAR?1366:o:n,a=!s&&i>t?i:t,d=s?n/r:t/a;e.style.transformOrigin="left top",e.style.transform=`scale(${d})`,e.style.width=s?`${r}px`:n/d+"px",e.style.height=s?t/d+"px":`${a}px`}getWidgetWidth(e,n,t){var o,i,l,s,r;if(!n||!n.shared.actualSize)return 0;const a=Array.isArray(n.shared.actualSize)?null===(l=null===(i=null===(o=n.shared.actualSize)||void 0===o?void 0:o[0])||void 0===i?void 0:i[t])||void 0===l?void 0:l.width:null===(r=null===(s=n.shared.actualSize)||void 0===s?void 0:s[t])||void 0===r?void 0:r.width;return a?parseFloat(a)+(e===LayoutType.BUILT_IN?0:100):0}getWidgetHeight(e,n,t){var o,i,l,s,r;if(!n||!n.shared.actualSize)return 0;const a=Array.isArray(n.shared.actualSize)?null===(l=null===(i=null===(o=n.shared.actualSize)||void 0===o?void 0:o[0])||void 0===i?void 0:i[t])||void 0===l?void 0:l.height:null===(r=null===(s=n.shared.actualSize)||void 0===s?void 0:s[t])||void 0===r?void 0:r.height;return a?parseFloat(a)+(e===LayoutType.BUILT_IN?0:100):0}addClickHandlerToItem(e,n){n&&e.addEventListener("click",()=>n())}createLoaderElement(){const e=document.createElement("div");return e.innerHTML='\n<style>\n body {\n display: flex;\n justify-content: center;\n align-items: center;\n overflow: hidden;\n } \n body > div{\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n padding: 20px;\n overflow: hidden;\n }\n .cl-grid-preview-loader {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n max-width: 223px;\n max-height: 252px;\n height: auto;\n padding: 24px 24px 33px;\n margin: auto;\n border-radius: 10px;\n border: 8px solid #E5E5E5;\n background: #FFF;\n box-shadow: 0 4px 15px 0 rgba(0, 0, 0, 0.10);\n }\n \n svg {\n max-width: 164px;\n width: 100%;\n }\n .skeleton--body {\n display: flex;\n flex-direction: column;\n padding-top: 5px;\n width: 100%;\n max-width: 164px;\n }\n .skeleton--row {\n display: inline-flex;\n height: 31px;\n width: 100%;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n }\n .skeleton--row:last-child {\n border-bottom: none;\n }\n .skeleton--cell {\n background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);\n background-size: 200% 100%;\n animation: skeleton-loading 1.5s infinite;\n border-radius: 4px;\n height: 100%;\n }\n\n @keyframes skeleton-loading {\n 0% {\n background-position: 200% 0;\n }\n 100% {\n background-position: -200% 0;\n }\n }\n .skeleton--row1 {\n width: 100%;\n max-width: 164px;\n flex: 1 0 0;\n }\n .skeleton--row2 {\n width: 74%;\n max-width: 121px;\n flex: 1 0 0;\n }\n .skeleton--row3 {\n width: 87%;\n max-width: 143px;\n flex: 1 0 0;\n }\n .skeleton--button {\n max-width: 104px;\n width: 63%;\n height: 32px;\n border-radius: 40px;\n margin-top: 20px;\n overflow: hidden;\n }\n \n @media (max-width: 250px) {\n body > div {\n width: 70%;\n padding: 5px;\n }\n \n .cl-grid-preview-loader {\n max-width: 100px;\n max-height: 80%;\n height: auto;\n padding: 4px 4px 3px;\n border: 4px solid #E5E5E5;\n }\n \n .skeleton--row {\n display: inline-flex;\n height: 10px;\n width: 100%;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n }\n \n .skeleton--row2, \n .skeleton--row3 {\n display: none;\n }\n \n .skeleton--button {\n height: 16px;\n border-radius: 10px;\n margin-top: 5px;\n }\n \n .skeleton--body {\n max-width: 100px;\n }\n }\n \n</style>\n<div class="cl-grid-preview-loader cl-widget">\n <svg viewBox="0 0 164 107" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g clip-path="url(#clip0_50190_912)">\n <rect width="164" height="107" rx="4" fill="#EDEDED"/>\n <circle opacity="0.5" cx="91.5" cy="76.5" r="6.5" fill="#D9D9D9"/>\n <path opacity="0.5" fill-rule="evenodd" clip-rule="evenodd" d="M60.7194 57.201C64.1524 68.884 59.1448 81.609 51.528 91.1123C44.0072 100.496 32.714 106.184 20.7141 107.115C9.22857 108.005 -1.55529 103.068 -10.5912 95.9283C-19.5451 88.8531 -26.4053 79.4895 -28.4443 68.2706C-30.6039 56.3878 -28.6454 44.0305 -21.8366 34.0526C-14.5839 23.4241 -3.84469 12.7642 9.02119 13.3666C21.2649 13.9399 26.2056 28.816 35.5508 36.7398C44.1237 44.0086 57.5529 46.4247 60.7194 57.201Z" fill="url(#paint0_linear_50190_912)" fill-opacity="0.1"/>\n <path opacity="0.5" fill-rule="evenodd" clip-rule="evenodd" d="M139.988 67.9364C145.776 66.7949 151.694 69.7714 155.944 73.8647C160.139 77.9064 162.386 83.6053 162.306 89.4354C162.23 95.0157 159.373 100.001 155.53 104.046C151.722 108.054 146.903 110.951 141.401 111.44C135.573 111.958 129.698 110.469 125.184 106.745C120.376 102.778 115.706 97.127 116.564 90.9465C117.379 85.0649 124.774 83.3367 129.008 79.1773C132.893 75.3617 134.65 68.9894 139.988 67.9364Z" fill="url(#paint1_linear_50190_912)" fill-opacity="0.1"/>\n <rect x="23" y="26" width="117" height="29" rx="4" fill="#D5D5D5"/>\n <rect x="41" y="50" width="81" height="29" rx="4" fill="#D5D5D5"/>\n <circle opacity="0.5" cx="139.5" cy="12.5" r="6.5" fill="#D9D9D9"/>\n <circle opacity="0.5" cx="154.5" cy="44.5" r="3.5" fill="#D9D9D9"/>\n <circle opacity="0.5" cx="78.5" cy="-5.5" r="17.5" fill="#D9D9D9"/>\n </g>\n <defs>\n <linearGradient id="paint0_linear_50190_912" x1="37.8107" y1="11.6845" x2="-13.6672" y2="88.7219" gradientUnits="userSpaceOnUse">\n <stop/>\n <stop offset="1" stop-opacity="0.53"/>\n </linearGradient>\n <linearGradient id="paint1_linear_50190_912" x1="117.02" y1="76.9833" x2="151.918" y2="105.212" gradientUnits="userSpaceOnUse">\n <stop/>\n <stop offset="1" stop-opacity="0.53"/>\n </linearGradient>\n <clipPath id="clip0_50190_912">\n <rect width="164" height="107" rx="4" fill="white"/>\n </clipPath>\n </defs>\n </svg>\n <div class="skeleton--body">\n <div class="skeleton--row">\n <div class="skeleton--cell skeleton--row1"></div>\n <div class="skeleton--cell skeleton--row2"></div>\n <div class="skeleton--cell skeleton--row3"></div>\n </div>\n </div>\n <div class="skeleton--button">\n <div class="skeleton--cell"></div>\n </div>\n</div>\n',e}}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface GridPreviewInitParamsI {
|
|
2
|
+
layoutType: string;
|
|
3
|
+
widgetType: string;
|
|
4
|
+
documentModel: any;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
staticResourcesUrl: string;
|
|
8
|
+
hostUrl?: string;
|
|
9
|
+
prizePoolModels?: any[];
|
|
10
|
+
id?: number;
|
|
11
|
+
clickCallback?: () => void;
|
|
12
|
+
containerCssClasses?: string[];
|
|
13
|
+
templateVisibleCallback?: () => void;
|
|
14
|
+
bundledComponentClasses?: any[];
|
|
15
|
+
useDefaultBundledComponentClasses?: any[];
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/helpers.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import TemplateBriefI from './TemplateBrief.interface';
|
|
2
|
+
import { SizeModelI } from './data/strategies/width-based-strategy/width-first-algorithm/sizeModelI';
|
|
3
|
+
declare const createModel: (id: any, widthPx: any, heightPx: any) => SizeModelI;
|
|
4
|
+
declare function createSizeModel(id: any, widthPx: any, heightPx: any, heightPercent: any): SizeModelI;
|
|
5
|
+
declare function createTemplateBrief(id: number, width: any, height: any, fallbackWeight: number): TemplateBriefI;
|
|
6
|
+
declare function createDocumentModelShell(): {
|
|
7
|
+
shared: {
|
|
8
|
+
textClasses: {
|
|
9
|
+
className: {
|
|
10
|
+
color: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
views: {
|
|
15
|
+
path: number[];
|
|
16
|
+
props: {};
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
export { createModel, createSizeModel, createTemplateBrief, createDocumentModelShell };
|
package/helpers.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TemplatePublishStatus}from"./TemplatePublishStatus.enum";import{TemplateType}from"./TemplateType.enum";import{WidgetType}from"./WidgetType.enum";const createModel=(e,t,a)=>({id:e,widthPx:t,heightPx:a,heightPercent:0});function createSizeModel(e,t,a,r){return{id:e,widthPx:t,heightPx:a,heightPercent:r}}function createTemplateBrief(e,t,a,r){return{id:e,name:"",imagePreviews:[],publishStatus:TemplatePublishStatus.PUBLISHED,json:{document:{shared:{actualSize:{desktop:{width:t,height:a}}}},sync:null},sortWeight:[{startDate:null,endDate:null,value:r}],industry:[],themes:[],rules:{},launchers:[],layouts:[],useCases:[],features:[],type:TemplateType.DYNAMIC,createdDate:"May 28, 2022, 11:43:16 AM",updatedDate:"May 28, 2022, 11:43:16 AM",widgetType:WidgetType.SUBSCRIPTION_FORM}}function createDocumentModelShell(){return{shared:{textClasses:{className:{color:"green"}}},views:[{path:[0],props:{}},{path:[1],props:{}},{path:[2],props:{}},{path:[3],props:{}}]}}export{createModel,createSizeModel,createTemplateBrief,createDocumentModelShell};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@claspo/templates",
|
|
3
|
+
"version": "14.4.1",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=18.16.0"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest --config=jest.config.ts --no-cache --coverage",
|
|
9
|
+
"build": "rm -rf out && tsc --project tsconfig.json && npm run minify",
|
|
10
|
+
"minify": "find out -name '*.js' ! -name '*.d.js' -exec terser {} --compress --mangle --output {} \\;",
|
|
11
|
+
"dev": "tsc --project tsconfig.json --watch",
|
|
12
|
+
"package": "npm i && npm run test && npm run build && cp package.json out && cd out && npm publish --access=public && cd .."
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@claspo/common": "5.2.1",
|
|
16
|
+
"@claspo/document-connector": "14.5.8",
|
|
17
|
+
"@claspo/renderer": "16.6.3",
|
|
18
|
+
"@claspo/components": "1.1.14"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/jest": "^27.5.1",
|
|
22
|
+
"jest": "^28.1.0",
|
|
23
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
24
|
+
"terser": "^5.37.0",
|
|
25
|
+
"ts-jest": "^28.0.3",
|
|
26
|
+
"ts-node": "^10.8.0",
|
|
27
|
+
"typescript": "^4.6.4"
|
|
28
|
+
},
|
|
29
|
+
"author": "alex-chernysh",
|
|
30
|
+
"license": "",
|
|
31
|
+
"homepage": "https://claspo.io/"
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import TemplateBriefI from "../TemplateBrief.interface";
|
|
2
|
+
import TemplateDatasourceI from "../TemplateDatasource.interface";
|
|
3
|
+
export default class TemplateSlider {
|
|
4
|
+
private datasource;
|
|
5
|
+
private currentTemplate;
|
|
6
|
+
constructor(datasource: TemplateDatasourceI);
|
|
7
|
+
setCurrent(template: TemplateBriefI): void;
|
|
8
|
+
getCurrent(): TemplateBriefI | null;
|
|
9
|
+
getPrev(): TemplateBriefI | null;
|
|
10
|
+
getNext(): TemplateBriefI | null;
|
|
11
|
+
hasPrev(): boolean;
|
|
12
|
+
hasNext(): boolean;
|
|
13
|
+
private getCurrentIndex;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class TemplateSlider{constructor(t){this.datasource=t,this.currentTemplate=null}setCurrent(t){this.currentTemplate=t}getCurrent(){return this.currentTemplate}getPrev(){return this.hasPrev()?(this.currentTemplate=this.datasource.getItems()[this.getCurrentIndex()-1],this.currentTemplate):null}getNext(){return this.hasNext()?(this.currentTemplate=this.datasource.getItems()[this.getCurrentIndex()+1],this.currentTemplate):null}hasPrev(){return!!this.datasource.getItems()[this.getCurrentIndex()-1]}hasNext(){return!!this.datasource.getItems()[this.getCurrentIndex()+1]}getCurrentIndex(){var t;const e=null===(t=this.currentTemplate)||void 0===t?void 0:t.id;return this.datasource.getItems().findIndex(t=>t.id===e)}}
|