@claspo/common 6.0.4 → 6.0.6

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,6 @@
1
+ export declare enum InAppLayoutType {
2
+ SLIDE_UP = "SLIDE_UP",
3
+ POP_UP = "POP_UP",
4
+ FULL = "FULL",
5
+ BOTTOM_BAR = "BOTTOM_BAR"
6
+ }
@@ -0,0 +1 @@
1
+ export var InAppLayoutType;!function(p){p.SLIDE_UP="SLIDE_UP",p.POP_UP="POP_UP",p.FULL="FULL",p.BOTTOM_BAR="BOTTOM_BAR"}(InAppLayoutType||(InAppLayoutType={}));
@@ -0,0 +1,8 @@
1
+ export declare enum LayoutType {
2
+ BUILT_IN = "BUILT_IN",
3
+ DETACHED = "DETACHED",
4
+ FLOATING_BOX = "FLOATING_BOX",
5
+ FLOATING_BAR = "FLOATING_BAR",
6
+ LAUNCHER = "LAUNCHER",
7
+ CONTENT_LOCKER = "CONTENT_LOCKER"
8
+ }
package/LayoutType.js ADDED
@@ -0,0 +1 @@
1
+ export var LayoutType;!function(T){T.BUILT_IN="BUILT_IN",T.DETACHED="DETACHED",T.FLOATING_BOX="FLOATING_BOX",T.FLOATING_BAR="FLOATING_BAR",T.LAUNCHER="LAUNCHER",T.CONTENT_LOCKER="CONTENT_LOCKER"}(LayoutType||(LayoutType={}));
package/RenderMode.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- declare const RenderMode: {
2
- readonly STATIC: "STATIC";
3
- readonly UPDATING: "UPDATING";
4
- };
5
- export type RenderModeT = typeof RenderMode[keyof typeof RenderMode];
6
- export default RenderMode;
1
+ export declare enum RenderMode {
2
+ STATIC = "STATIC",
3
+ UPDATING = "UPDATING"
4
+ }
package/RenderMode.js CHANGED
@@ -1 +1 @@
1
- const RenderMode={STATIC:"STATIC",UPDATING:"UPDATING"};export default RenderMode;
1
+ export var RenderMode;!function(e){e.STATIC="STATIC",e.UPDATING="UPDATING"}(RenderMode||(RenderMode={}));
@@ -1,6 +1,8 @@
1
1
  import { PrizePoolModelI } from './PrizePool.interface';
2
2
  import { ClDocumentI } from './document/Document.interface';
3
- import type { RenderModeT } from './RenderMode';
3
+ import { WidgetType } from './WidgetType';
4
+ import { LayoutType } from './LayoutType';
5
+ import { RenderMode } from './RenderMode';
4
6
  export interface TrackingServiceI {
5
7
  send: (eventName: string, payload?: any) => void;
6
8
  trackClick: (elementId: string, payload?: any) => void;
@@ -9,13 +11,16 @@ export interface TrackingServiceI {
9
11
  export type TranslationsI = Record<string, Record<string, string>>;
10
12
  export interface WidgetInitConfigI {
11
13
  documentModel: ClDocumentI;
14
+ layoutType: LayoutType;
15
+ widgetType: WidgetType;
16
+ staticResourcesUrl: string;
12
17
  formVariantId?: string;
13
- staticResourcesUrl?: string;
14
18
  siteId?: string;
15
19
  browserLanguage?: string;
16
20
  optionalDocumentStyles?: Record<string, string>;
17
21
  previewMode?: boolean;
18
22
  editorPreviewMode?: boolean;
23
+ demoMode?: boolean;
19
24
  branded?: boolean;
20
25
  upgradePlanButton?: boolean;
21
26
  viewIndex?: number;
@@ -23,8 +28,6 @@ export interface WidgetInitConfigI {
23
28
  actionFactoryClass?: any;
24
29
  widgetId?: number;
25
30
  prizePoolModels?: PrizePoolModelI[];
26
- layoutType?: string;
27
- widgetType?: string;
28
31
  bundledComponentClasses?: any[];
29
32
  translations?: TranslationsI;
30
33
  trackingService?: TrackingServiceI;
@@ -37,6 +40,9 @@ export interface WidgetInitConfigI {
37
40
  disableScrollbarCalculation?: boolean;
38
41
  disableLayoutAnimations?: boolean;
39
42
  displayPosition?: string;
40
- renderMode?: RenderModeT;
43
+ renderMode?: RenderMode;
44
+ disableGlobalScroll?: boolean;
45
+ hostUrl?: string;
46
+ subscribeContactUrl?: string;
41
47
  [key: string]: any;
42
48
  }
@@ -0,0 +1,8 @@
1
+ export declare enum WidgetType {
2
+ SUBSCRIPTION_FORM = "SUBSCRIPTION_FORM",
3
+ INFORMER = "INFORMER",
4
+ REQUEST_FORM = "REQUEST_FORM",
5
+ LAUNCHER = "LAUNCHER",
6
+ AGE_VERIFY = "AGE_VERIFY",
7
+ TEASER = "TEASER"
8
+ }
package/WidgetType.js ADDED
@@ -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={}));
@@ -1,7 +1,6 @@
1
- declare const ComponentInsertType: {
2
- BEFORE: string;
3
- AFTER: string;
4
- INSIDE: string;
5
- INSTEAD: string;
6
- };
7
- export default ComponentInsertType;
1
+ export declare enum ComponentInsertType {
2
+ BEFORE = "BEFORE",
3
+ AFTER = "AFTER",
4
+ INSIDE = "INSIDE",
5
+ INSTEAD = "INSTEAD"
6
+ }
@@ -1 +1 @@
1
- const ComponentInsertType={BEFORE:"BEFORE",AFTER:"AFTER",INSIDE:"INSIDE",INSTEAD:"INSTEAD"};export default ComponentInsertType;
1
+ export var ComponentInsertType;!function(n){n.BEFORE="BEFORE",n.AFTER="AFTER",n.INSIDE="INSIDE",n.INSTEAD="INSTEAD"}(ComponentInsertType||(ComponentInsertType={}));
@@ -1 +1 @@
1
- import ComponentInsertType from"./ComponentInsertType";import HandlerTypes from"../handler/HandlerTypes";export default class DocumentUtils{static removeNode(t,e){const n=this.getParentPath(e),r=e[e.length-1],i=this.getNodeByPath(t,n);if(i&&i.children&&i.path){const t=i.children.splice(r,1)[0];return t.prevPath=e,t.path=null,DocumentUtils.reIndex(i,i.path),t}{const n=t.splice(r,1)[0];return n.prevPath=e,n.path=null,t.forEach((t,e)=>{t.path=[e],DocumentUtils.reIndex(t,t.path)}),n}}static insertNode(t,e,n,r){const i=DocumentUtils.getPathToInsert(e,r,n,t),l=r===ComponentInsertType.INSIDE?e:this.getParentPath(i),o=this.getNodeByPath(n,l),s=i[i.length-1];return o&&o.children&&o.path?(o.children.splice(s,0,t),DocumentUtils.reIndex(o,o.path),t):(n.splice(s,0,t),n.forEach((t,e)=>{t.path=[e],DocumentUtils.reIndex(t,t.path)}),t)}static moveNode(t,e,n,r){const i=DocumentUtils.getNodeByPath(t,n);if(!i)return;const l=DocumentUtils.removeNode(t,e),o=DocumentUtils.getNodeById(t,i.id);o&&o.path&&DocumentUtils.insertNode(l,o.path,t,r)}static iterateDepthFirst(t,e){return iterateDepthFirst(t,e)}static reIndex(t,e){t.path=e,t.children&&t.children.forEach((t,n)=>{DocumentUtils.reIndex(t,e.concat(n))})}static getRelativePath(t){return t.slice(1,t.length)}static getParentPath(t){return t.slice(0,-1)}static getNodeByPath(t,e){let n=t;for(let t=0;t<e.length;t++){if(t===e.length-1)return n[e[t]]||null;if(!n[e[t]]||!n[e[t]].children)return null;n=n[e[t]].children}return null}static getNodeById(t,e){let n=null;for(let r=0;r<t.length;r++){const i=t[r];if(n)break;if(i.id===e){n=i;break}i.children&&i.children.length&&(n=this.getNodeById(i.children,e))}return n}static getPathToInsert(t,e,n,r){var i,l;let o;const s=t[t.length-1];switch(e){case ComponentInsertType.BEFORE:o=t;break;case ComponentInsertType.AFTER:o=t.slice(),o[t.length-1]=s+1;break;case ComponentInsertType.INSIDE:{const e=DocumentUtils.getNodeByPath(n,t),r=null!==(l=null===(i=null==e?void 0:e.children)||void 0===i?void 0:i.length)&&void 0!==l?l:0;o=t.concat([r]);break}case ComponentInsertType.INSTEAD:{const e=null==r?void 0:r.prevPath;o=(null==e?void 0:e.at(-1))<=s?[...t.slice(0,-1),s+1]:t;break}default:o=t}return o}static getNodeOnClickData(t){let e=[],n={};return DocumentUtils.iterateDepthFirst(t,t=>{var r,i,l,o;const s=null===(l=null===(i=null===(r=t.props)||void 0===r?void 0:r.handlers)||void 0===i?void 0:i.find(t=>t.type===HandlerTypes.CLICK))||void 0===l?void 0:l.actions;(null==s?void 0:s.length)&&(e=[...e,...s]),Object.keys((null===(o=t.props)||void 0===o?void 0:o.content)||{}).filter(t=>["detractor","passive","promoter"].includes(t)).map(e=>{var n;return((null===(n=t.props)||void 0===n?void 0:n.content)||{})[e]||null}).filter(t=>t).forEach(t=>n[t]=t)}),{actions:e,npsViewIds:Object.keys(n)}}}export function iterateDepthFirst(t,e){t.children&&t.children.forEach(t=>iterateDepthFirst(t,e)),e(t)}
1
+ import{ClDocumentHandlerType}from"./Document.interface";import{ComponentInsertType}from"./ComponentInsertType";export default class DocumentUtils{static removeNode(t,e){const n=this.getParentPath(e),r=e[e.length-1],i=this.getNodeByPath(t,n);if(i&&i.children&&i.path){const t=i.children.splice(r,1)[0];return t.prevPath=e,t.path=null,DocumentUtils.reIndex(i,i.path),t}{const n=t.splice(r,1)[0];return n.prevPath=e,n.path=null,t.forEach((t,e)=>{t.path=[e],DocumentUtils.reIndex(t,t.path)}),n}}static insertNode(t,e,n,r){const i=DocumentUtils.getPathToInsert(e,r,n,t),o=r===ComponentInsertType.INSIDE?e:this.getParentPath(i),l=this.getNodeByPath(n,o),c=i[i.length-1];return l&&l.children&&l.path?(l.children.splice(c,0,t),DocumentUtils.reIndex(l,l.path),t):(n.splice(c,0,t),n.forEach((t,e)=>{t.path=[e],DocumentUtils.reIndex(t,t.path)}),t)}static moveNode(t,e,n,r){const i=DocumentUtils.getNodeByPath(t,n);if(!i)return;const o=DocumentUtils.removeNode(t,e),l=DocumentUtils.getNodeById(t,i.id);l&&l.path&&DocumentUtils.insertNode(o,l.path,t,r)}static iterateDepthFirst(t,e){return iterateDepthFirst(t,e)}static reIndex(t,e){t.path=e,t.children&&t.children.forEach((t,n)=>{DocumentUtils.reIndex(t,e.concat(n))})}static getRelativePath(t){return t.slice(1,t.length)}static getParentPath(t){return t.slice(0,-1)}static getNodeByPath(t,e){let n=t;for(let t=0;t<e.length;t++){if(t===e.length-1)return n[e[t]]||null;if(!n[e[t]]||!n[e[t]].children)return null;n=n[e[t]].children}return null}static getNodeById(t,e){let n=null;for(let r=0;r<t.length;r++){const i=t[r];if(n)break;if(i.id===e){n=i;break}i.children&&i.children.length&&(n=this.getNodeById(i.children,e))}return n}static getPathToInsert(t,e,n,r){var i,o;let l;const c=t[t.length-1];switch(e){case ComponentInsertType.BEFORE:l=t;break;case ComponentInsertType.AFTER:l=t.slice(),l[t.length-1]=c+1;break;case ComponentInsertType.INSIDE:{const e=DocumentUtils.getNodeByPath(n,t),r=null!==(o=null===(i=null==e?void 0:e.children)||void 0===i?void 0:i.length)&&void 0!==o?o:0;l=t.concat([r]);break}case ComponentInsertType.INSTEAD:{const e=null==r?void 0:r.prevPath;l=(null==e?void 0:e.at(-1))<=c?[...t.slice(0,-1),c+1]:t;break}default:l=t}return l}static getNodeOnClickData(t){let e=[],n={};return DocumentUtils.iterateDepthFirst(t,t=>{var r,i,o,l;const c=null===(o=null===(i=null===(r=t.props)||void 0===r?void 0:r.handlers)||void 0===i?void 0:i.find(t=>t.type===ClDocumentHandlerType.CLICK))||void 0===o?void 0:o.actions;(null==c?void 0:c.length)&&(e=[...e,...c]),Object.keys((null===(l=t.props)||void 0===l?void 0:l.content)||{}).filter(t=>["detractor","passive","promoter"].includes(t)).map(e=>{var n;return((null===(n=t.props)||void 0===n?void 0:n.content)||{})[e]||null}).filter(t=>t).forEach(t=>n[t]=t)}),{actions:e,npsViewIds:Object.keys(n)}}}export function iterateDepthFirst(t,e){t.children&&t.children.forEach(t=>iterateDepthFirst(t,e)),e(t)}
@@ -1,5 +1,4 @@
1
- declare const HandlerTypes: {
2
- CLICK: string;
3
- COMPONENT_EVENT: string;
4
- };
5
- export default HandlerTypes;
1
+ export declare enum HandlerTypes {
2
+ CLICK = "CLICK",
3
+ COMPONENT_EVENT = "COMPONENT_EVENT"
4
+ }
@@ -1 +1 @@
1
- const HandlerTypes={CLICK:"CLICK",COMPONENT_EVENT:"COMPONENT_EVENT"};export default HandlerTypes;
1
+ export var HandlerTypes;!function(e){e.CLICK="CLICK",e.COMPONENT_EVENT="COMPONENT_EVENT"}(HandlerTypes||(HandlerTypes={}));
@@ -1,5 +1,4 @@
1
- declare const HttpStatus: {
2
- EMPTY_RESPONSE: number;
3
- TOO_MANY_REQUESTS: number;
4
- };
5
- export default HttpStatus;
1
+ export declare enum HttpStatus {
2
+ EMPTY_RESPONSE = 204,
3
+ TOO_MANY_REQUESTS = 429
4
+ }
@@ -1 +1 @@
1
- const HttpStatus={EMPTY_RESPONSE:204,TOO_MANY_REQUESTS:429};export default HttpStatus;
1
+ export var HttpStatus;!function(t){t[t.EMPTY_RESPONSE=204]="EMPTY_RESPONSE",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS"}(HttpStatus||(HttpStatus={}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claspo/common",
3
- "version": "6.0.4",
3
+ "version": "6.0.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -1,7 +0,0 @@
1
- declare const InAppLayoutType: {
2
- SLIDE_UP: string;
3
- POP_UP: string;
4
- FULL: string;
5
- BOTTOM_BAR: string;
6
- };
7
- export default InAppLayoutType;
@@ -1 +0,0 @@
1
- const InAppLayoutType={SLIDE_UP:"SLIDE_UP",POP_UP:"POP_UP",FULL:"FULL",BOTTOM_BAR:"BOTTOM_BAR"};export default InAppLayoutType;
@@ -1,9 +0,0 @@
1
- declare const LayoutType: {
2
- BUILT_IN: string;
3
- DETACHED: string;
4
- FLOATING_BOX: string;
5
- FLOATING_BAR: string;
6
- LAUNCHER: string;
7
- CONTENT_LOCKER: string;
8
- };
9
- export default LayoutType;
@@ -1 +0,0 @@
1
- const LayoutType={BUILT_IN:"BUILT_IN",DETACHED:"DETACHED",FLOATING_BOX:"FLOATING_BOX",FLOATING_BAR:"FLOATING_BAR",LAUNCHER:"LAUNCHER",CONTENT_LOCKER:"CONTENT_LOCKER"};export default LayoutType;
@@ -1,9 +0,0 @@
1
- declare const WidgetType: {
2
- SUBSCRIPTION_FORM: string;
3
- INFORMER: string;
4
- REQUEST_FORM: string;
5
- LAUNCHER: string;
6
- AGE_VERIFY: string;
7
- TEASER: string;
8
- };
9
- export default WidgetType;
@@ -1 +0,0 @@
1
- const WidgetType={SUBSCRIPTION_FORM:"SUBSCRIPTION_FORM",INFORMER:"INFORMER",REQUEST_FORM:"REQUEST_FORM",LAUNCHER:"LAUNCHER",AGE_VERIFY:"AGE_VERIFY",TEASER:"TEASER"};export default WidgetType;