@claspo/renderer 18.8.0-nonlinear4 → 18.8.0-nonlinear5

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.
@@ -1 +1 @@
1
- import FormControlValidator from"./FormControlValidator";import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import FormControlEvents from"./FormControlEvents";import debounce from"@claspo/common/async/debounce";export class FormControl extends DefaultEventEmitter{constructor(e,t,i,s,n){super(),this.componentId=e.componentId,this.viewIdx=Number.isInteger(e.viewIdx)?e.viewIdx:null,this.name=e.name,this.defaultValue=e.defaultValue,this.value=e.defaultValue?e.defaultValue:void 0,this.validator=new FormControlValidator(this,e.validation,i,s),this.errorKeys=this.validator.getSyncErrorKeys(this.getValue()),this.valid=!this.errorKeys.length,this.disabled=!1,this.pending=!1,this.debounceValue=e.hasOwnProperty("debounceValue")?e.debounceValue:300,this.tracking=n,this.touched=!1,this.valueChanged=!1,this.elementRef=null,this.debouncedValidate=()=>{},this._init(e,t)}inputElementValueChanged(e){this.tracking.send("FormStartFilling_[Name]"),this.setValue(e)}setDisabled(){this.disabled=!0,this.elementRef&&this.elementRef.setAttribute("disabled","disabled")}setEnabled(){this.disabled=!1,this.elementRef&&this.elementRef.removeAttribute("disabled")}setPending(e){this.pending=e}getName(){return this.name}getValue(){return this.value}getComponentId(){return this.componentId}setValue(e="",t={silent:!1,skipValidation:!1,skipElementUpdate:!1}){t.skipElementUpdate||(this.valueChanged=this.value!==e),this.value=e,this.elementRef&&!t.skipElementUpdate&&("checkbox"===this.elementRef.getAttribute("type")?this.elementRef.checked=!!e:this.elementRef.value=e),t.skipValidation?!t.silent&&this.valueChanged&&this.emit(FormControlEvents.valueChanged,e):(this.pending=!0,this.emit(FormControlEvents.validationStatusChanged,"pending"),this.debouncedValidate(t)),t.silent||t.skipValidation||this.elementRef||this.markAsTouched()}isValid(){return this.valid}isPending(){return this.pending}async validate(e={silent:!1}){this.pending=!0;const t=await this.validator.getErrorKeys(this.getValue());return this.valid=!t.length,this.errorKeys=t,this.pending=!1,e.silent||(this.emit(FormControlEvents.validationStatusChanged,this.valid?"valid":"invalid"),this.valueChanged&&(this.emit(FormControlEvents.valueChanged,this.getValue()),this.valueChanged=!1)),this.valid}adoptValidationState(e){e&&(this.touched=e.isTouched(),e.isPending()?this.validate():this.valid&&!e.isValid()&&(this.valid=!1,this.errorKeys=e.getErrorKeys()))}markAsTouched(){this.touched=!0,this.emit(FormControlEvents.touchedStatusChanged,null)}isTouched(){return this.touched}getErrorKeys(){return this.errorKeys}destroy(){super.destroy()}_init(e,t){const i=t?t.getAttribute("type"):null;if(t&&e.defaultValue&&("checkbox"===i?t.checked=e.defaultValue:t.value=e.defaultValue),t){const s=e.triggerEvent?e.triggerEvent:"input",n="checkbox"===i;t.addEventListener(s,e=>{const t=e.target;this.inputElementValueChanged(n?t.checked:t.value)}),t.addEventListener("blur",()=>{this.markAsTouched()}),this.elementRef=t}this.debouncedValidate=this.debounceValue?debounce(e=>this.validate(e),this.debounceValue):this.validate.bind(this)}}
1
+ import FormControlValidator from"./FormControlValidator";import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import FormControlEvents from"./FormControlEvents";import debounce from"@claspo/common/async/debounce";export class FormControl extends DefaultEventEmitter{constructor(e,t,i,s,n){super(),this.componentId=e.componentId,this.viewIdx=Number.isInteger(e.viewIdx)?e.viewIdx:null,this.name=e.name,this.defaultValue=e.defaultValue,this.value=e.defaultValue?e.defaultValue:void 0,this.validator=new FormControlValidator(this,e.validation,i,s),this.errorKeys=this.validator.getSyncErrorKeys(this.getValue()),this.valid=!this.errorKeys.length,this.disabled=!1,this.pending=!1,this.debounceValue=e.hasOwnProperty("debounceValue")?e.debounceValue:300,this.tracking=n,this.touched=!1,this.valueChanged=!1,this.elementRef=null,this.debouncedValidate=()=>{},this._init(e,t)}inputElementValueChanged(e){this.tracking.send("FormStartFilling_[Name]"),this.setValue(e)}setDisabled(){this.disabled=!0,this.elementRef&&this.elementRef.setAttribute("disabled","disabled")}setEnabled(){this.disabled=!1,this.elementRef&&this.elementRef.removeAttribute("disabled")}setPending(e){this.pending=e}getName(){return this.name}getValue(){return this.value}getComponentId(){return this.componentId}setValue(e="",t={silent:!1,skipValidation:!1,skipElementUpdate:!1}){t.skipElementUpdate||(this.valueChanged=this.value!==e),this.value=e,this.elementRef&&!t.skipElementUpdate&&("checkbox"===this.elementRef.getAttribute("type")?this.elementRef.checked=!!e:this.elementRef.value=e),t.skipValidation?!t.silent&&this.valueChanged&&this.emit(FormControlEvents.valueChanged,e):(this.pending=!0,this.emit(FormControlEvents.validationStatusChanged,"pending"),this.debouncedValidate(t)),t.silent||t.skipValidation||this.elementRef||this.markAsTouched()}isValid(){return this.valid}isPending(){return this.pending}async validate(e={silent:!1}){this.pending=!0;const t=await this.validator.getErrorKeys(this.getValue());return this.valid=!t.length,this.errorKeys=t,this.pending=!1,e.silent||(this.emit(FormControlEvents.validationStatusChanged,this.valid?"valid":"invalid"),this.valueChanged&&(this.emit(FormControlEvents.valueChanged,this.getValue()),this.valueChanged=!1)),this.valid}adoptValidationState(e){e&&(e.isPending()?this.validate():this.valid&&!e.isValid()&&(this.valid=!1,this.errorKeys=e.getErrorKeys()))}markAsTouched(){this.touched=!0,this.emit(FormControlEvents.touchedStatusChanged,null)}isTouched(){return this.touched}getErrorKeys(){return this.errorKeys}destroy(){super.destroy()}_init(e,t){const i=t?t.getAttribute("type"):null;if(t&&e.defaultValue&&("checkbox"===i?t.checked=e.defaultValue:t.value=e.defaultValue),t){const s=e.triggerEvent?e.triggerEvent:"input",n="checkbox"===i;t.addEventListener(s,e=>{const t=e.target;this.inputElementValueChanged(n?t.checked:t.value)}),t.addEventListener("blur",()=>{this.markAsTouched()}),this.elementRef=t}this.debouncedValidate=this.debounceValue?debounce(e=>this.validate(e),this.debounceValue):this.validate.bind(this)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claspo/renderer",
3
- "version": "18.8.0-nonlinear4",
3
+ "version": "18.8.0-nonlinear5",
4
4
  "scripts": {
5
5
  "dev": " tsc --project tsconfig.json --watch",
6
6
  "build": "rm -rf out && tsc --project tsconfig.json && npm run minify",
@@ -15,7 +15,7 @@
15
15
  "node": ">=18.16.0"
16
16
  },
17
17
  "dependencies": {
18
- "@claspo/common": "7.4.0-nonlinear2",
18
+ "@claspo/common": "7.4.0-nonlinear3",
19
19
  "@testing-library/dom": "^10.4.0"
20
20
  },
21
21
  "devDependencies": {
@@ -44,6 +44,7 @@ export interface AsyncValidatorsMapI {
44
44
  }
45
45
  export default class WcControlledElement extends WcElement {
46
46
  _createControl: (config?: CreateControlConfigI, ...restControlArgs: any[]) => FormControl;
47
+ _validateAutofilledValue: (control: FormControl) => void;
47
48
  createControlWithValidation: (validators?: ValidatorFnT[], options?: ControlValidationOptionsI) => FormControl;
48
49
  _prepareAsyncValidators: (validators?: ValidatorFnT[]) => AsyncValidatorsMapI;
49
50
  _handleControlStatusChange: (params: ControlStatusHandlerParamsI) => void;
@@ -1 +1 @@
1
- var __rest=this&&this.__rest||function(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(t);l<n.length;l++)e.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(t,n[l])&&(o[n[l]]=t[n[l]])}return o};import FormControlEvents from"../form/FormControlEvents";import{setInvalidStyle,setValidStyles,setPendingStyle}from"./FormUtils";import{getTranslation}from"./TranslationUtils";import WcElement from"./WcElement";import{REQUIRED_SYMBOL,required}from"./validators/required";function noop(){}export const ControlStatus={PENDING:"pending",VALID:"valid",INVALID:"invalid"};export default class WcControlledElement extends WcElement{constructor(){super(...arguments),this._createControl=(t={},...e)=>{const{element:o}=t,n=__rest(t,["element"]),l=this.getProps(),i=this.getModel(),a=Object.assign(Object.assign(Object.assign({},l.control),{componentId:i.id,viewIdx:i.path[0]}),n),r=this.services.form,s=[a,o,...e];return r.hasControl(l.control.name)?r.updateControl(...s):r.registerControl(...s)},this.createControlWithValidation=(t=[],e={})=>{const{element:o=this.getElement("input"),tooltipElement:n=this.getRootElement().querySelector(".input-tooltip"),validCallback:l=noop,invalidCallback:i=noop,pendingCallback:a=noop,elementToListen:r=o,validationMap:s={},listenStatusChange:c=!0}=e,d=__rest(e,["element","tooltipElement","validCallback","invalidCallback","pendingCallback","elementToListen","validationMap","listenStatusChange"]);if(n&&(n.style.visibility="hidden"),!t||!Array.isArray(t))throw new Error("Validators should be an array");const u=this.getProps().control.validation,p=(null==u?void 0:u.validator)?s[u.validator]:void 0,h=t.some(t=>t[REQUIRED_SYMBOL]),m=!!(null==u?void 0:u.required),v=m||h,C=[...t];m&&!h&&C.unshift(required()),p&&C.push(p);const b=this._prepareAsyncValidators(C),g=this._createControl({element:o,validation:{validator:"custom",required:v}},void 0,b);return c&&this._handleControlStatusChange(Object.assign({control:g,element:r,tooltipElement:n,configService:this.services.config,i18n:this.manifest.i18n,validCallback:l,invalidCallback:i,pendingCallback:a},d)),g},this._prepareAsyncValidators=(t=[])=>t.reduce((t,e,o)=>{if("function"!=typeof e)return console.warn(`Validator ${o} should be a function, so it will be skipped`),t;return t[`custom_${o}`]=async(...t)=>{const o=await Promise.resolve(e(...t));return"object"==typeof o&&"isValid"in o?Object.assign(Object.assign({},o),{errorKey:o.isValid?null:o.errorKey}):{isValid:!1,errorKey:"INVALID_VALIDATOR_RESPONSE"}},t},{}),this._handleControlStatusChange=t=>{t.control.on(FormControlEvents.validationStatusChanged,e=>{this._handleValidationStatus(t,e)}),t.control.on(FormControlEvents.touchedStatusChanged,()=>{let e=ControlStatus.PENDING;switch(!0){case t.control.pending:e=ControlStatus.PENDING;break;case t.control.valid:e=ControlStatus.VALID;break;default:e=ControlStatus.INVALID}this._handleValidationStatus(t,e)})},this._handleValidationStatus=(t,e)=>{const{control:o,element:n,tooltipElement:l,validCallback:i,invalidCallback:a,errorMessageMapper:r,pendingCallback:s}=t,c=this.services.config,d=this.manifest.i18n;switch(e){case ControlStatus.VALID:setValidStyles(n,l),i&&i();break;case ControlStatus.INVALID:if(o.touched){const t=o.getErrorKeys();if(!t)break;const e=t[0];let i=getTranslation(c,d,e);r&&(i=r(e,i)),setInvalidStyle(n,l,i,this.htmlDocumentObject),a&&a()}break;case ControlStatus.PENDING:o.touched&&(setPendingStyle(n,l),s&&s())}}}}
1
+ var __rest=this&&this.__rest||function(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(t);l<n.length;l++)e.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(t,n[l])&&(o[n[l]]=t[n[l]])}return o};import FormControlEvents from"../form/FormControlEvents";import{setInvalidStyle,setValidStyles,setPendingStyle}from"./FormUtils";import{getTranslation}from"./TranslationUtils";import WcElement from"./WcElement";import{REQUIRED_SYMBOL,required}from"./validators/required";function noop(){}export const ControlStatus={PENDING:"pending",VALID:"valid",INVALID:"invalid"};export default class WcControlledElement extends WcElement{constructor(){super(...arguments),this._createControl=(t={},...e)=>{const{element:o}=t,n=__rest(t,["element"]),l=this.getProps(),i=this.getModel(),a=Object.assign(Object.assign(Object.assign({},l.control),{componentId:i.id,viewIdx:i.path[0]}),n),r=this.getAutofillValue();void 0!==r&&(a.defaultValue=r);const s=this.services.form,c=[a,o,...e],d=s.hasControl(l.control.name)?s.updateControl(...c):s.registerControl(...c);return void 0!==r&&d.getValue()===r&&this._validateAutofilledValue(d),d},this._validateAutofilledValue=t=>{t.validate({silent:!0}).then(e=>{e||t.markAsTouched(),this.syncAutofillContextRecord(e,t.getValue())})},this.createControlWithValidation=(t=[],e={})=>{const{element:o=this.getElement("input"),tooltipElement:n=this.getRootElement().querySelector(".input-tooltip"),validCallback:l=noop,invalidCallback:i=noop,pendingCallback:a=noop,elementToListen:r=o,validationMap:s={},listenStatusChange:c=!0}=e,d=__rest(e,["element","tooltipElement","validCallback","invalidCallback","pendingCallback","elementToListen","validationMap","listenStatusChange"]);if(n&&(n.style.visibility="hidden"),!t||!Array.isArray(t))throw new Error("Validators should be an array");const u=this.getProps().control.validation,h=(null==u?void 0:u.validator)?s[u.validator]:void 0,p=t.some(t=>t[REQUIRED_SYMBOL]),m=!!(null==u?void 0:u.required),v=m||p,C=[...t];m&&!p&&C.unshift(required()),h&&C.push(h);const g=this._prepareAsyncValidators(C),f=this._createControl({element:o,validation:{validator:"custom",required:v}},void 0,g);return c&&this._handleControlStatusChange(Object.assign({control:f,element:r,tooltipElement:n,configService:this.services.config,i18n:this.manifest.i18n,validCallback:l,invalidCallback:i,pendingCallback:a},d)),f},this._prepareAsyncValidators=(t=[])=>t.reduce((t,e,o)=>{if("function"!=typeof e)return console.warn(`Validator ${o} should be a function, so it will be skipped`),t;return t[`custom_${o}`]=async(...t)=>{const o=await Promise.resolve(e(...t));return"object"==typeof o&&"isValid"in o?Object.assign(Object.assign({},o),{errorKey:o.isValid?null:o.errorKey}):{isValid:!1,errorKey:"INVALID_VALIDATOR_RESPONSE"}},t},{}),this._handleControlStatusChange=t=>{t.control.on(FormControlEvents.validationStatusChanged,e=>{this._handleValidationStatus(t,e)}),t.control.on(FormControlEvents.touchedStatusChanged,()=>{let e=ControlStatus.PENDING;switch(!0){case t.control.pending:e=ControlStatus.PENDING;break;case t.control.valid:e=ControlStatus.VALID;break;default:e=ControlStatus.INVALID}this._handleValidationStatus(t,e)})},this._handleValidationStatus=(t,e)=>{const{control:o,element:n,tooltipElement:l,validCallback:i,invalidCallback:a,errorMessageMapper:r,pendingCallback:s}=t,c=this.services.config,d=this.manifest.i18n;switch(e){case ControlStatus.VALID:setValidStyles(n,l),i&&i();break;case ControlStatus.INVALID:if(o.touched){const t=o.getErrorKeys();if(!t)break;const e=t[0];let i=getTranslation(c,d,e);r&&(i=r(e,i)),setInvalidStyle(n,l,i,this.htmlDocumentObject),a&&a()}break;case ControlStatus.PENDING:o.touched&&(setPendingStyle(n,l),s&&s())}}}}
@@ -9,6 +9,7 @@ import { ObserversI } from "../wc-renderer/observers/createObservers";
9
9
  import { SubscriptionsI } from "../wc-renderer/subscriptions/createSubscriptions";
10
10
  import { ComponentManifestI } from '@claspo/common/component-manifest/ComponentManifest.interface';
11
11
  import ConfigService from '../common/ConfigService';
12
+ import { AutofillI } from '@claspo/common/document/autofill.interface';
12
13
  import { MergeTagsProcessorFactory } from './merge-tags/MergeTagsProcessorFactory';
13
14
  import ContextSDK from './context/ContextSDK';
14
15
  import FormGroup from '../form/FormGroup';
@@ -26,6 +27,7 @@ export interface ControlConfigI {
26
27
  defaultValue?: string;
27
28
  integrationName?: string;
28
29
  validation?: ValidationConfigI;
30
+ autofill?: AutofillI;
29
31
  [key: string]: any;
30
32
  }
31
33
  export interface ValidationConfigI {
@@ -82,6 +84,8 @@ export default class WcElement extends HTMLElement {
82
84
  handlers: HandlerInstanceI[] | null;
83
85
  htmlDocumentObject: Document;
84
86
  skipGameBlur: boolean;
87
+ isAutofillValidated: boolean;
88
+ validatedAutofillValue: string | undefined;
85
89
  static define: {
86
90
  name: string;
87
91
  model: string;
@@ -125,6 +129,9 @@ export default class WcElement extends HTMLElement {
125
129
  static _resolveTogglableStylesForElementModel: (elementModel: ClBaseComponentElementParamsI) => ClBaseComponentElementParamsI;
126
130
  static _resolveTogglableStyles: (styles: ClComponentStyleAttributesI) => ClComponentStyleAttributesI;
127
131
  updateContext: () => void;
132
+ getAutofillValue: () => string | undefined;
133
+ getValidatedAutofillValue: () => string | undefined;
134
+ syncAutofillContextRecord: (isValid: boolean, value: string) => void;
128
135
  addContextRecord: () => void;
129
136
  getContextRecordLabel: (props: ClBaseComponentPropsI) => string | undefined;
130
137
  capitalizeFirstLetter: (string: string) => string;
package/sdk/WcElement.js CHANGED
@@ -1 +1 @@
1
- import HandlerFactory from"../handler/HandlerFactory";import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import addEventListenerToElement from"@claspo/common/utils/addEventListener";import DefaultState from"../common/DefaultState";import{EditorToWidgetEventType}from"../document-model/DocumentModelService";import DefaultMediaQueryListener from"../renderer/style/DefaultMediaQueryListener";import{applySysAttrPrefix,applySysClassPrefix,RenderConstants}from"../renderer/RenderConstants";import StyleAttributeAccessor from"./accessor/StyleAttributeAccessor";import CommonStylesService from"../renderer/style/CommonStylesService";import ColorSchemaListener from"../renderer/style/ColorSchemaListener";import HttpClient from"@claspo/common/network/HttpClient";import omitKeys from"@claspo/common/object/omitKeys";import{CaseTransformer}from"@claspo/common/utils/CaseTransformer";import ComponentResourceManager from"../resource-management/ComponentResourceManager";import createObservers from"../wc-renderer/observers/createObservers";import observerType from"../wc-renderer/observers/observerType";import createSubscriptions from"../wc-renderer/subscriptions/createSubscriptions";import recursiveFindParentNodeByAttribute from"@claspo/common/element/recursiveFindParentNodeByAttribute";import{getTranslationsMap,getWidgetLanguages}from"./TranslationUtils";import ActionCategory from"../action/actions/ActionCategory";import SysActionTypes from"../action/SysActionTypes";import mergeAdaptiveStylesWithEnvIndependentStyles from"../document-model/MergeAdaptiveStylesWithEnvIndependentStyles";import{applySharedClasses,getAdaptiveStylesForPlatform}from"./ModelStyleUtils";import insertHtmlIntoElement from"@claspo/common/dom/insertHtmlIntoElement";import{PayloadEvent}from"./PayloadEvent";import{RenderMode}from"@claspo/common/RenderMode";import{WidgetToEditorEventType}from"../renderer/WidgetToEditorEventType";class WcElement extends HTMLElement{constructor(){var e;super(),this.skipGameBlur=!0,this.construct=()=>{let e;const t=this.getAttribute(applySysAttrPrefix("id")),s=this.getWidgetContainerNode();if(!s)throw new Error("Widget container not found in construct");const o=s.closest(`[${applySysAttrPrefix("widget-id")}]`);let r;o&&(r=o.getAttribute(applySysAttrPrefix("widget-id")));let i=new PayloadEvent("cl-props-request",{nodeName:this.nodeName,path:this.getAttribute(applySysAttrPrefix("path")),id:t,widgetId:r},{bubbles:!0,composed:!0});this.dispatchEvent(i),e=i.detail.props,Object.assign(this,e),this.observers=createObservers(observerType.PROPS,observerType.SHARED,observerType.ENVIRONMENT),this.subscriptions=createSubscriptions(),this.state=new DefaultState({}),this.componentEventEmitter=new DefaultEventEmitter,this.componentResourceManager=new ComponentResourceManager(this.model.id,this.services.eventEmitter,this.isStaticRenderMode()),this.mergeTagsProcessor=this.services.mergeTagsProcessorFactory.create(),this._actionFactory=this.services.actionFactory,this._handlerFactory=new HandlerFactory(this._actionFactory,this.services.actionRegister),this.prevProps=this.model.props,this.prevEnvironment=this.getEnvironment(),this.documentModel.on(`${EditorToWidgetEventType.COMPONENT_PROPS_UPDATE}_${this.model.id}`,e=>{this.model.props=e,this.observers.get(observerType.PROPS).forEach(t=>t(this.prevProps,e)),this.prevProps=e;const t=this.getHostElement(),s=applySysAttrPrefix("floating");e.floating&&!t.getAttribute(s)?t.setAttribute(s,"true"):!e.floating&&t.getAttribute(s)&&t.removeAttribute(s)}),this.documentModel.on(`${EditorToWidgetEventType.COMPONENT_UPDATE}_${this.model.id}`,e=>{Object.assign(this.model,e)}),this.documentModel.on(EditorToWidgetEventType.SHARED_UPDATE_ALL,()=>{this.applyAutoAdaptiveStyles(this.prevProps.adaptiveStyles,this.prevProps.styles),this.observers.get(observerType.SHARED).forEach(e=>e(this.getShared()))}),this.model.props.backgroundDynamicInlineSVGElements&&(this.colorSchemaListener=new ColorSchemaListener(this.documentModel,this.getHostElement(),()=>this.getShared(),()=>this.model.props,()=>this.getEnvironment(),HttpClient),this.colorSchemaListener.apply(this.getEnvironment()).then(()=>{this.subscriptions.push(this.colorSchemaListener.on())})),this.prevProps.adaptiveStyles&&this.subscriptions.push(this.resizeListener.on(DefaultMediaQueryListener.changeEventName,()=>{this.applyAutoAdaptiveStyles(this.prevProps.adaptiveStyles,this.prevProps.styles);const e=this.getEnvironment();this.observers.get(observerType.ENVIRONMENT).forEach(t=>t(this.prevEnvironment,e)),this.prevEnvironment=e})),this.subscriptions.push(this.services.eventEmitter.on(WidgetToEditorEventType.GAME_PHASE_READY_TO_PLAY,()=>{this.skipGameBlur||this.getHostElement().classList.add("cl-game-spotlight-component")})),this.subscriptions.push(this.services.eventEmitter.on(WidgetToEditorEventType.GAME_PHASE_COMPLETED,()=>{this.skipGameBlur||this.getHostElement().classList.remove("cl-game-spotlight-component")}))},this.attachHandlers=()=>{this.getHandlers().map(e=>this._handlerFactory.get(e)).map(e=>()=>e.activate(this.state,this.componentEventEmitter,this.getHostElement.bind(this))).forEach(e=>e())},this.postponeHandlers=()=>{var e;null===(e=this.handlers)||void 0===e||e.forEach(e=>e.postpone())},this.releaseHandlers=()=>{var e;null===(e=this.handlers)||void 0===e||e.forEach(e=>e.release())},this.getProps=()=>{var e;return null===(e=this.getModel())||void 0===e?void 0:e.props},this.getShared=()=>this.documentModel.getShared(),this.getEnvironment=()=>this.resizeListener.isMobile()?"mobile":"desktop",this.isStaticRenderMode=()=>this.services.config.getConfig("renderMode")===RenderMode.STATIC,this.isUpdatingRenderMode=()=>this.services.config.getConfig("renderMode")===RenderMode.UPDATING,this.getRootElement=()=>this.shadowRoot?this.shadowRoot:this,this.getHostElement=()=>this,this.observeProps=e=>{this.observers.get(observerType.PROPS).push(e),e(null,this.prevProps)},this.observeShared=e=>{this.observers.get(observerType.SHARED).push(e),e(this.getShared())},this.observeEnvironment=e=>{this.observers.get(observerType.ENVIRONMENT).push(e),e(null,this.getEnvironment())},this.getElements=()=>[this.getHostElement(),...Array.from(this.getRootElement().querySelectorAll(`[${applySysAttrPrefix("element")}]`)).filter(e=>!e.hasAttribute(applySysAttrPrefix("component")))],this.getElement=(e,t)=>this.getElements().find(s=>t?s.getAttribute(applySysAttrPrefix("element"))===e&&s.id===t:s.getAttribute(applySysAttrPrefix("element"))===e),this.applyAutoAdaptiveStyles=(e,t)=>{if(!e&&!t)return;const s=this.getElements();if(!s.length)return;const o=mergeAdaptiveStylesWithEnvIndependentStyles(e,t),r=applySysAttrPrefix("type"),i="element-styles";let n=this.getRootElement().querySelector(`style[${r}="${i}"]`);n||(n=document.createElement("style"),n.setAttribute(r,i),this.getRootElement().appendChild(n)),insertHtmlIntoElement({element:n,html:""}),s.forEach(e=>{let t=e.getAttribute(applySysAttrPrefix("element"));const s=this.getEnvironment();let r=getAdaptiveStylesForPlatform(o,s,t);if(r){if(this.resizeListener.isMobile()){const e=getAdaptiveStylesForPlatform(o,"desktop",t);e&&(r=Object.assign(Object.assign({},r),{styleAttributes:Object.assign(Object.assign({},e.styleAttributes),r.styleAttributes)}))}this.applyStylesToElement(e,this.applySharedClassesToElementModel(r),n)}}),this._addLinkColor(n,this.getShared())},this.registerComponentResourceManagement=()=>{this.viewResourceManager.registerComponent(this.model.id,this.componentResourceManager)},this.applyStyles=(e,t={})=>{if(!e||!e.style)return!1;for(const[s,o]of Object.entries(t))e.style[s]=o;return!0},this.applyStylesToElement=(e,t,s)=>{var o,r;const i=[];if("host"===(t=WcElement._resolveTogglableStylesForElementModel(t)).element){CommonStylesService.applyHostStyles(this.model.type,e,null,this.layoutType);!!("desktop"===this.getEnvironment()&&(null===(o=this.model.props.backgroundDynamicInlineSVGElements)||void 0===o?void 0:o.desktop)||"mobile"===this.getEnvironment()&&(null===(r=this.model.props.backgroundDynamicInlineSVGElements)||void 0===r?void 0:r.mobile))&&(this.colorSchemaListener.apply(this.getEnvironment()),i.push("background"))}let n=t.styleAttributes.background,l=n&&n.match(/url\("([^"]*)"\)/);if(this.manifest.waitForResourcesLoad&&l){this.componentResourceManager.getPending().increment();const e=new Image;e.src=l[1],addEventListenerToElement(e,"load",()=>{this.componentResourceManager.getPending().decrement()}),addEventListenerToElement(e,"error",()=>{this.componentResourceManager.onResourceLoadFailure(e.src),this.isUpdatingRenderMode&&this.componentResourceManager.getPending().decrement()})}const a=Object.assign(Object.assign({},t),{styleAttributes:omitKeys(t.styleAttributes,i)});if(StyleAttributeAccessor.set(e,a),this._setClassAttributes(e,t),s){if(t.hoverStyleAttributes){let o=Object.assign({},t.hoverStyleAttributes);if("FILL_UP"===t.hoverAnimationType){e.style.boxShadow="inset 0px 0px 0px 0px rgb(0, 0, 0, 0)",e.style.overflow="hidden";const s=e.tagName.toLowerCase(),r=`flip-up-animation-${t.element}`;let i=this.getRootElement().querySelector(`#${r}`);i||(i=document.createElement("style"),i.id=r,e.appendChild(i)),insertHtmlIntoElement({element:i,html:`\n ${s}::before {\n content: '';\n background: ${o.background};\n position: absolute;\n left: 0;\n top: ${e.getBoundingClientRect().height}px;\n height: ${e.getBoundingClientRect().height}px;\n width: 100%;\n z-index: -10;\n }\n ${s}:hover::before {\n top: 0;\n transition: 0.3s;\n }\n `}),o=Object.assign(Object.assign({},t.hoverStyleAttributes),{background:"transparent",position:"relative"})}o.borderTopWidth&&"0px"!==o.borderTopWidth||delete o.borderTopColor;o.borderBottomWidth&&"0px"!==o.borderBottomWidth||delete o.borderBottomColor;o.borderLeftWidth&&"0px"!==o.borderLeftWidth||delete o.borderLeftColor;o.borderRightWidth&&"0px"!==o.borderRightWidth||delete o.borderRightColor,this._addStylesToStyleElement(s,t.element,o,`:not(.${applySysAttrPrefix("no-hover")}):hover`,!0)}t.placeholderStyleAttributes&&this._addStylesToStyleElement(s,t.element,t.placeholderStyleAttributes,"::placeholder"),this._addFontStylesToStyleElement(s,this.getShared()),this.stylesAppliedToElement(e,t,s)}},this.applySharedClassesToElementModel=e=>{const t=this.documentModel.getShared();return applySharedClasses(e,t)},this.getModel=()=>this.model,this._addStylesToStyleElement=(e,t,s,o="",r)=>{const i=Object.keys(s).reduce((e,t)=>e+` ${CaseTransformer.camelCaseToDashCase(t)}: ${s[t]}${r?" !important;":";"}`,"");insertHtmlIntoElement({element:e,html:`[${applySysAttrPrefix("element")}="${t}"]${o} { ${i} }`,appendHtml:!0})},this._addFontStylesToStyleElement=(e,t)=>{insertHtmlIntoElement({element:e,html:`[cl-type] {font-family:${t.textFontFamily||"inherit"}}`,appendHtml:!0})},this._addLinkColor=(e,t)=>{var s,o,r,i;t.linkColor&&insertHtmlIntoElement({element:e,html:`a {color: ${t.linkColor}}, a:visited {color: ${t.linkColor}}`,appendHtml:!0}),(null===(s=t.linkParams)||void 0===s?void 0:s.color)&&insertHtmlIntoElement({element:e,html:`a {color: ${null===(o=t.linkParams)||void 0===o?void 0:o.color}}, a:visited {color: ${null===(r=t.linkParams)||void 0===r?void 0:r.color}}`,appendHtml:!0}),(null===(i=t.linkParams)||void 0===i?void 0:i.removeUnderline)&&insertHtmlIntoElement({element:e,html:"a {text-decoration: none}, a:visited {text-decoration: none}",appendHtml:!0})},this._setClassAttributes=(e,t)=>{Array.from(e.classList).filter(e=>e!==applySysClassPrefix("hovered")&&e!==applySysClassPrefix("focused")).forEach(t=>{t.startsWith(RenderConstants.SYSTEM_CLASS_PREFIX)&&e.classList.remove(t)});const s=((e.getAttribute("class")||"")+" "+t.classes).trim();e.setAttribute("class",s)},this.getParentComponent=()=>recursiveFindParentNodeByAttribute(this.parentNode,applySysAttrPrefix("element"),"host"),this.getWidgetContainerNode=()=>{const e=null==this?void 0:this.getAttribute(applySysAttrPrefix("path"));return 1===(null==e?void 0:e.split(",").length)?this.parentNode:recursiveFindParentNodeByAttribute(this.parentNode,applySysAttrPrefix("path"),void 0,e=>1===(null==e?void 0:e.split(",").length))},this.getWidgetLanguages=()=>getWidgetLanguages(this.services.config),this.getPreferredWidgetLanguage=()=>this.getWidgetLanguages()[0],this.getTranslationsMap=e=>getTranslationsMap(e,this.getWidgetLanguages()),this.stylesAppliedToElement=(e,t,s)=>{},this.updateContext=()=>{var e;const t=this.getModel();this.services.context.updateRecord(t.id,{label:this.getContextRecordLabel(t.props),viewIndex:null===(e=t.path)||void 0===e?void 0:e[0]})},this.addContextRecord=()=>{var e;const t=this.getModel();this.services.context.addRecord(t.id,{recordKey:t.id,id:t.props.control.name,label:this.getContextRecordLabel(t.props),value:t.props.control.defaultValue||"",viewIndex:null===(e=t.path)||void 0===e?void 0:e[0],sourceId:"FORM",initialData:{fallbackValue:"",exampleValue:this.getContextRecordExampleValue(t.props)}})},this.getContextRecordLabel=e=>{var t,s,o,r,i,n;const l=e.control.name;if(["email","first_name","last_name"].includes(l))return l.toUpperCase();if((null===(t=e.content)||void 0===t?void 0:t.label)&&(null===(r=null===(o=null===(s=e.adaptiveStyles)||void 0===s?void 0:s.desktop.find(e=>"label"===e.element))||void 0===o?void 0:o.params)||void 0===r?void 0:r.enabled)){const t=(new DOMParser).parseFromString(e.content.label,"text/html");return this.capitalizeFirstLetter(t.body.textContent||"")}return(null===(i=e.content)||void 0===i?void 0:i.placeholder)?this.capitalizeFirstLetter(e.content.placeholder):(null===(n=e.control)||void 0===n?void 0:n.integrationName)?this.capitalizeFirstLetter(e.control.integrationName).replace(new RegExp("_","g")," "):void 0},this.capitalizeFirstLetter=e=>e.charAt(0).toUpperCase()+e.slice(1),this.getContextRecordExampleValue=e=>{var t;switch(null===(t=e.control)||void 0===t?void 0:t.name){case"email":return"myemail@example.com";case"first_name":return"Maria";case"last_name":return"Taylor";default:return this.getContextRecordLabel(e)}},this.completeSubmitAction=e=>{const t=e||{},s=this.services.actionRegister.getRegisteredActions().find(e=>e.category===ActionCategory.SUBMIT);s?null==s||s.execute(void 0,void 0,!0,t):this.services.actionFactory.get({type:SysActionTypes.REQUEST}).execute(void 0,void 0,!0,t)},this.getHandlers=()=>{var e;return(null===(e=this.getProps())||void 0===e?void 0:e.handlers)&&this.getProps().handlers.length?[...this.getProps().handlers]:[]},this.assets=(e="")=>`${this.services.config.getConfig("staticResourcesUrl").replace(/\/$/,"")}/${this.manifest.name}/assets${e?`/${e}`:""}`,this.attachShadow({mode:"open"}),this.manifest=this.manifest||(null===(e=this.constructor.define)||void 0===e?void 0:e.manifest)}connectedCallback(){this.construct(),this.registerComponentResourceManagement(),Promise.resolve().then(()=>{this.attachHandlers()});const e=document.createElement("style");e.textContent='\n :host(.cl-game-spotlight-component)::after {\n content: "";\n position: absolute;\n background-size: 100% 100%;\n background-repeat: no-repeat;\n overflow: visible;\n \n backdrop-filter: blur(4px);\n \n inset: -30px;\n mask-image: \n linear-gradient(to bottom, transparent, grey 30px, grey calc(100% - 30px), transparent),\n linear-gradient(to right, transparent, grey 30px, grey calc(100% - 30px), transparent);\n mask-composite: intersect;\n -webkit-mask-composite: source-in; /* for Chrome/Safari */\n \n transition: opacity 0.35s ease;\n pointer-events: auto;\n }\n ',this.getRootElement().prepend(e)}disconnectedCallback(){var e;this.observers.clear(),this.subscriptions.off(),this.state.destroy(),this.componentEventEmitter.destroy(),null===(e=this.mergeTagsProcessor)||void 0===e||e.destroy()}}WcElement._resolveTogglableStylesForElementModel=e=>{const t=Object.assign({},e);return Object.keys(t).forEach(e=>{e.toLowerCase().includes("styleattributes")&&(t[e]=WcElement._resolveTogglableStyles(t[e]))}),t},WcElement._resolveTogglableStyles=e=>{const t=Object.assign({},e),s=(e,s,o)=>{s in t&&(e.forEach(e=>{e in t&&(t[e]=t[s]?t[e]:o)}),delete t[s])};return s(["marginTop","marginBottom","marginLeft","marginRight"],"_marginEnabled","0px"),s(["paddingTop","paddingBottom","paddingLeft","paddingRight"],"_paddingEnabled","0px"),t};export default WcElement;
1
+ import HandlerFactory from"../handler/HandlerFactory";import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import addEventListenerToElement from"@claspo/common/utils/addEventListener";import DefaultState from"../common/DefaultState";import{EditorToWidgetEventType}from"../document-model/DocumentModelService";import DefaultMediaQueryListener from"../renderer/style/DefaultMediaQueryListener";import{applySysAttrPrefix,applySysClassPrefix,RenderConstants}from"../renderer/RenderConstants";import StyleAttributeAccessor from"./accessor/StyleAttributeAccessor";import CommonStylesService from"../renderer/style/CommonStylesService";import ColorSchemaListener from"../renderer/style/ColorSchemaListener";import HttpClient from"@claspo/common/network/HttpClient";import omitKeys from"@claspo/common/object/omitKeys";import{CaseTransformer}from"@claspo/common/utils/CaseTransformer";import ComponentResourceManager from"../resource-management/ComponentResourceManager";import createObservers from"../wc-renderer/observers/createObservers";import observerType from"../wc-renderer/observers/observerType";import createSubscriptions from"../wc-renderer/subscriptions/createSubscriptions";import recursiveFindParentNodeByAttribute from"@claspo/common/element/recursiveFindParentNodeByAttribute";import{getTranslationsMap,getWidgetLanguages}from"./TranslationUtils";import ActionCategory from"../action/actions/ActionCategory";import SysActionTypes from"../action/SysActionTypes";import mergeAdaptiveStylesWithEnvIndependentStyles from"../document-model/MergeAdaptiveStylesWithEnvIndependentStyles";import{applySharedClasses,getAdaptiveStylesForPlatform}from"./ModelStyleUtils";import insertHtmlIntoElement from"@claspo/common/dom/insertHtmlIntoElement";import{PayloadEvent}from"./PayloadEvent";import{RenderMode}from"@claspo/common/RenderMode";import InputFieldsAutofillHydrator from"./autofill/InputFieldsAutofillHydrator";import{WidgetToEditorEventType}from"../renderer/WidgetToEditorEventType";class WcElement extends HTMLElement{constructor(){var e;super(),this.skipGameBlur=!0,this.isAutofillValidated=!1,this.validatedAutofillValue=void 0,this.construct=()=>{let e;const t=this.getAttribute(applySysAttrPrefix("id")),s=this.getWidgetContainerNode();if(!s)throw new Error("Widget container not found in construct");const o=s.closest(`[${applySysAttrPrefix("widget-id")}]`);let i;o&&(i=o.getAttribute(applySysAttrPrefix("widget-id")));let r=new PayloadEvent("cl-props-request",{nodeName:this.nodeName,path:this.getAttribute(applySysAttrPrefix("path")),id:t,widgetId:i},{bubbles:!0,composed:!0});this.dispatchEvent(r),e=r.detail.props,Object.assign(this,e),this.observers=createObservers(observerType.PROPS,observerType.SHARED,observerType.ENVIRONMENT),this.subscriptions=createSubscriptions(),this.state=new DefaultState({}),this.componentEventEmitter=new DefaultEventEmitter,this.componentResourceManager=new ComponentResourceManager(this.model.id,this.services.eventEmitter,this.isStaticRenderMode()),this.mergeTagsProcessor=this.services.mergeTagsProcessorFactory.create(),this._actionFactory=this.services.actionFactory,this._handlerFactory=new HandlerFactory(this._actionFactory,this.services.actionRegister),this.prevProps=this.model.props,this.prevEnvironment=this.getEnvironment(),this.documentModel.on(`${EditorToWidgetEventType.COMPONENT_PROPS_UPDATE}_${this.model.id}`,e=>{this.model.props=e,this.observers.get(observerType.PROPS).forEach(t=>t(this.prevProps,e)),this.prevProps=e;const t=this.getHostElement(),s=applySysAttrPrefix("floating");e.floating&&!t.getAttribute(s)?t.setAttribute(s,"true"):!e.floating&&t.getAttribute(s)&&t.removeAttribute(s)}),this.documentModel.on(`${EditorToWidgetEventType.COMPONENT_UPDATE}_${this.model.id}`,e=>{Object.assign(this.model,e)}),this.documentModel.on(EditorToWidgetEventType.SHARED_UPDATE_ALL,()=>{this.applyAutoAdaptiveStyles(this.prevProps.adaptiveStyles,this.prevProps.styles),this.observers.get(observerType.SHARED).forEach(e=>e(this.getShared()))}),this.model.props.backgroundDynamicInlineSVGElements&&(this.colorSchemaListener=new ColorSchemaListener(this.documentModel,this.getHostElement(),()=>this.getShared(),()=>this.model.props,()=>this.getEnvironment(),HttpClient),this.colorSchemaListener.apply(this.getEnvironment()).then(()=>{this.subscriptions.push(this.colorSchemaListener.on())})),this.prevProps.adaptiveStyles&&this.subscriptions.push(this.resizeListener.on(DefaultMediaQueryListener.changeEventName,()=>{this.applyAutoAdaptiveStyles(this.prevProps.adaptiveStyles,this.prevProps.styles);const e=this.getEnvironment();this.observers.get(observerType.ENVIRONMENT).forEach(t=>t(this.prevEnvironment,e)),this.prevEnvironment=e})),this.subscriptions.push(this.services.eventEmitter.on(WidgetToEditorEventType.GAME_PHASE_READY_TO_PLAY,()=>{this.skipGameBlur||this.getHostElement().classList.add("cl-game-spotlight-component")})),this.subscriptions.push(this.services.eventEmitter.on(WidgetToEditorEventType.GAME_PHASE_COMPLETED,()=>{this.skipGameBlur||this.getHostElement().classList.remove("cl-game-spotlight-component")}))},this.attachHandlers=()=>{this.getHandlers().map(e=>this._handlerFactory.get(e)).map(e=>()=>e.activate(this.state,this.componentEventEmitter,this.getHostElement.bind(this))).forEach(e=>e())},this.postponeHandlers=()=>{var e;null===(e=this.handlers)||void 0===e||e.forEach(e=>e.postpone())},this.releaseHandlers=()=>{var e;null===(e=this.handlers)||void 0===e||e.forEach(e=>e.release())},this.getProps=()=>{var e;return null===(e=this.getModel())||void 0===e?void 0:e.props},this.getShared=()=>this.documentModel.getShared(),this.getEnvironment=()=>this.resizeListener.isMobile()?"mobile":"desktop",this.isStaticRenderMode=()=>this.services.config.getConfig("renderMode")===RenderMode.STATIC,this.isUpdatingRenderMode=()=>this.services.config.getConfig("renderMode")===RenderMode.UPDATING,this.getRootElement=()=>this.shadowRoot?this.shadowRoot:this,this.getHostElement=()=>this,this.observeProps=e=>{this.observers.get(observerType.PROPS).push(e),e(null,this.prevProps)},this.observeShared=e=>{this.observers.get(observerType.SHARED).push(e),e(this.getShared())},this.observeEnvironment=e=>{this.observers.get(observerType.ENVIRONMENT).push(e),e(null,this.getEnvironment())},this.getElements=()=>[this.getHostElement(),...Array.from(this.getRootElement().querySelectorAll(`[${applySysAttrPrefix("element")}]`)).filter(e=>!e.hasAttribute(applySysAttrPrefix("component")))],this.getElement=(e,t)=>this.getElements().find(s=>t?s.getAttribute(applySysAttrPrefix("element"))===e&&s.id===t:s.getAttribute(applySysAttrPrefix("element"))===e),this.applyAutoAdaptiveStyles=(e,t)=>{if(!e&&!t)return;const s=this.getElements();if(!s.length)return;const o=mergeAdaptiveStylesWithEnvIndependentStyles(e,t),i=applySysAttrPrefix("type"),r="element-styles";let n=this.getRootElement().querySelector(`style[${i}="${r}"]`);n||(n=document.createElement("style"),n.setAttribute(i,r),this.getRootElement().appendChild(n)),insertHtmlIntoElement({element:n,html:""}),s.forEach(e=>{let t=e.getAttribute(applySysAttrPrefix("element"));const s=this.getEnvironment();let i=getAdaptiveStylesForPlatform(o,s,t);if(i){if(this.resizeListener.isMobile()){const e=getAdaptiveStylesForPlatform(o,"desktop",t);e&&(i=Object.assign(Object.assign({},i),{styleAttributes:Object.assign(Object.assign({},e.styleAttributes),i.styleAttributes)}))}this.applyStylesToElement(e,this.applySharedClassesToElementModel(i),n)}}),this._addLinkColor(n,this.getShared())},this.registerComponentResourceManagement=()=>{this.viewResourceManager.registerComponent(this.model.id,this.componentResourceManager)},this.applyStyles=(e,t={})=>{if(!e||!e.style)return!1;for(const[s,o]of Object.entries(t))e.style[s]=o;return!0},this.applyStylesToElement=(e,t,s)=>{var o,i;const r=[];if("host"===(t=WcElement._resolveTogglableStylesForElementModel(t)).element){CommonStylesService.applyHostStyles(this.model.type,e,null,this.layoutType);!!("desktop"===this.getEnvironment()&&(null===(o=this.model.props.backgroundDynamicInlineSVGElements)||void 0===o?void 0:o.desktop)||"mobile"===this.getEnvironment()&&(null===(i=this.model.props.backgroundDynamicInlineSVGElements)||void 0===i?void 0:i.mobile))&&(this.colorSchemaListener.apply(this.getEnvironment()),r.push("background"))}let n=t.styleAttributes.background,l=n&&n.match(/url\("([^"]*)"\)/);if(this.manifest.waitForResourcesLoad&&l){this.componentResourceManager.getPending().increment();const e=new Image;e.src=l[1],addEventListenerToElement(e,"load",()=>{this.componentResourceManager.getPending().decrement()}),addEventListenerToElement(e,"error",()=>{this.componentResourceManager.onResourceLoadFailure(e.src),this.isUpdatingRenderMode&&this.componentResourceManager.getPending().decrement()})}const a=Object.assign(Object.assign({},t),{styleAttributes:omitKeys(t.styleAttributes,r)});if(StyleAttributeAccessor.set(e,a),this._setClassAttributes(e,t),s){if(t.hoverStyleAttributes){let o=Object.assign({},t.hoverStyleAttributes);if("FILL_UP"===t.hoverAnimationType){e.style.boxShadow="inset 0px 0px 0px 0px rgb(0, 0, 0, 0)",e.style.overflow="hidden";const s=e.tagName.toLowerCase(),i=`flip-up-animation-${t.element}`;let r=this.getRootElement().querySelector(`#${i}`);r||(r=document.createElement("style"),r.id=i,e.appendChild(r)),insertHtmlIntoElement({element:r,html:`\n ${s}::before {\n content: '';\n background: ${o.background};\n position: absolute;\n left: 0;\n top: ${e.getBoundingClientRect().height}px;\n height: ${e.getBoundingClientRect().height}px;\n width: 100%;\n z-index: -10;\n }\n ${s}:hover::before {\n top: 0;\n transition: 0.3s;\n }\n `}),o=Object.assign(Object.assign({},t.hoverStyleAttributes),{background:"transparent",position:"relative"})}o.borderTopWidth&&"0px"!==o.borderTopWidth||delete o.borderTopColor;o.borderBottomWidth&&"0px"!==o.borderBottomWidth||delete o.borderBottomColor;o.borderLeftWidth&&"0px"!==o.borderLeftWidth||delete o.borderLeftColor;o.borderRightWidth&&"0px"!==o.borderRightWidth||delete o.borderRightColor,this._addStylesToStyleElement(s,t.element,o,`:not(.${applySysAttrPrefix("no-hover")}):hover`,!0)}t.placeholderStyleAttributes&&this._addStylesToStyleElement(s,t.element,t.placeholderStyleAttributes,"::placeholder"),this._addFontStylesToStyleElement(s,this.getShared()),this.stylesAppliedToElement(e,t,s)}},this.applySharedClassesToElementModel=e=>{const t=this.documentModel.getShared();return applySharedClasses(e,t)},this.getModel=()=>this.model,this._addStylesToStyleElement=(e,t,s,o="",i)=>{const r=Object.keys(s).reduce((e,t)=>e+` ${CaseTransformer.camelCaseToDashCase(t)}: ${s[t]}${i?" !important;":";"}`,"");insertHtmlIntoElement({element:e,html:`[${applySysAttrPrefix("element")}="${t}"]${o} { ${r} }`,appendHtml:!0})},this._addFontStylesToStyleElement=(e,t)=>{insertHtmlIntoElement({element:e,html:`[cl-type] {font-family:${t.textFontFamily||"inherit"}}`,appendHtml:!0})},this._addLinkColor=(e,t)=>{var s,o,i,r;t.linkColor&&insertHtmlIntoElement({element:e,html:`a {color: ${t.linkColor}}, a:visited {color: ${t.linkColor}}`,appendHtml:!0}),(null===(s=t.linkParams)||void 0===s?void 0:s.color)&&insertHtmlIntoElement({element:e,html:`a {color: ${null===(o=t.linkParams)||void 0===o?void 0:o.color}}, a:visited {color: ${null===(i=t.linkParams)||void 0===i?void 0:i.color}}`,appendHtml:!0}),(null===(r=t.linkParams)||void 0===r?void 0:r.removeUnderline)&&insertHtmlIntoElement({element:e,html:"a {text-decoration: none}, a:visited {text-decoration: none}",appendHtml:!0})},this._setClassAttributes=(e,t)=>{Array.from(e.classList).filter(e=>e!==applySysClassPrefix("hovered")&&e!==applySysClassPrefix("focused")).forEach(t=>{t.startsWith(RenderConstants.SYSTEM_CLASS_PREFIX)&&e.classList.remove(t)});const s=((e.getAttribute("class")||"")+" "+t.classes).trim();e.setAttribute("class",s)},this.getParentComponent=()=>recursiveFindParentNodeByAttribute(this.parentNode,applySysAttrPrefix("element"),"host"),this.getWidgetContainerNode=()=>{const e=null==this?void 0:this.getAttribute(applySysAttrPrefix("path"));return 1===(null==e?void 0:e.split(",").length)?this.parentNode:recursiveFindParentNodeByAttribute(this.parentNode,applySysAttrPrefix("path"),void 0,e=>1===(null==e?void 0:e.split(",").length))},this.getWidgetLanguages=()=>getWidgetLanguages(this.services.config),this.getPreferredWidgetLanguage=()=>this.getWidgetLanguages()[0],this.getTranslationsMap=e=>getTranslationsMap(e,this.getWidgetLanguages()),this.stylesAppliedToElement=(e,t,s)=>{},this.updateContext=()=>{var e;const t=this.getModel();this.services.context.updateRecord(t.id,{label:this.getContextRecordLabel(t.props),viewIndex:null===(e=t.path)||void 0===e?void 0:e[0]})},this.getAutofillValue=()=>{var e;const t=this.getModel();return new InputFieldsAutofillHydrator(this.services.config,this.services.context.getRegistry()).resolveValue(null===(e=t.props.control)||void 0===e?void 0:e.autofill,t.id)},this.getValidatedAutofillValue=()=>this.isAutofillValidated?this.validatedAutofillValue:void 0,this.syncAutofillContextRecord=(e,t)=>{this.isAutofillValidated=!0,this.validatedAutofillValue=e?t:void 0,e&&this.services.context.updateRecord(this.getModel().id,{value:t})},this.addContextRecord=()=>{var e,t;const s=this.getModel();this.services.context.addRecord(s.id,{recordKey:s.id,id:s.props.control.name,label:this.getContextRecordLabel(s.props),value:null!==(e=this.getValidatedAutofillValue())&&void 0!==e?e:s.props.control.defaultValue||"",viewIndex:null===(t=s.path)||void 0===t?void 0:t[0],sourceId:"FORM",initialData:{fallbackValue:"",exampleValue:this.getContextRecordExampleValue(s.props)}})},this.getContextRecordLabel=e=>{var t,s,o,i,r,n;const l=e.control.name;if(["email","first_name","last_name"].includes(l))return l.toUpperCase();if((null===(t=e.content)||void 0===t?void 0:t.label)&&(null===(i=null===(o=null===(s=e.adaptiveStyles)||void 0===s?void 0:s.desktop.find(e=>"label"===e.element))||void 0===o?void 0:o.params)||void 0===i?void 0:i.enabled)){const t=(new DOMParser).parseFromString(e.content.label,"text/html");return this.capitalizeFirstLetter(t.body.textContent||"")}return(null===(r=e.content)||void 0===r?void 0:r.placeholder)?this.capitalizeFirstLetter(e.content.placeholder):(null===(n=e.control)||void 0===n?void 0:n.integrationName)?this.capitalizeFirstLetter(e.control.integrationName).replace(new RegExp("_","g")," "):void 0},this.capitalizeFirstLetter=e=>e.charAt(0).toUpperCase()+e.slice(1),this.getContextRecordExampleValue=e=>{var t;switch(null===(t=e.control)||void 0===t?void 0:t.name){case"email":return"myemail@example.com";case"first_name":return"Maria";case"last_name":return"Taylor";default:return this.getContextRecordLabel(e)}},this.completeSubmitAction=e=>{const t=e||{},s=this.services.actionRegister.getRegisteredActions().find(e=>e.category===ActionCategory.SUBMIT);s?null==s||s.execute(void 0,void 0,!0,t):this.services.actionFactory.get({type:SysActionTypes.REQUEST}).execute(void 0,void 0,!0,t)},this.getHandlers=()=>{var e;return(null===(e=this.getProps())||void 0===e?void 0:e.handlers)&&this.getProps().handlers.length?[...this.getProps().handlers]:[]},this.assets=(e="")=>`${this.services.config.getConfig("staticResourcesUrl").replace(/\/$/,"")}/${this.manifest.name}/assets${e?`/${e}`:""}`,this.attachShadow({mode:"open"}),this.manifest=this.manifest||(null===(e=this.constructor.define)||void 0===e?void 0:e.manifest)}connectedCallback(){this.construct(),this.registerComponentResourceManagement(),Promise.resolve().then(()=>{this.attachHandlers()});const e=document.createElement("style");e.textContent='\n :host(.cl-game-spotlight-component)::after {\n content: "";\n position: absolute;\n background-size: 100% 100%;\n background-repeat: no-repeat;\n overflow: visible;\n \n backdrop-filter: blur(4px);\n \n inset: -30px;\n mask-image: \n linear-gradient(to bottom, transparent, grey 30px, grey calc(100% - 30px), transparent),\n linear-gradient(to right, transparent, grey 30px, grey calc(100% - 30px), transparent);\n mask-composite: intersect;\n -webkit-mask-composite: source-in; /* for Chrome/Safari */\n \n transition: opacity 0.35s ease;\n pointer-events: auto;\n }\n ',this.getRootElement().prepend(e)}disconnectedCallback(){var e;this.observers.clear(),this.subscriptions.off(),this.state.destroy(),this.componentEventEmitter.destroy(),null===(e=this.mergeTagsProcessor)||void 0===e||e.destroy()}}WcElement._resolveTogglableStylesForElementModel=e=>{const t=Object.assign({},e);return Object.keys(t).forEach(e=>{e.toLowerCase().includes("styleattributes")&&(t[e]=WcElement._resolveTogglableStyles(t[e]))}),t},WcElement._resolveTogglableStyles=e=>{const t=Object.assign({},e),s=(e,s,o)=>{s in t&&(e.forEach(e=>{e in t&&(t[e]=t[s]?t[e]:o)}),delete t[s])};return s(["marginTop","marginBottom","marginLeft","marginRight"],"_marginEnabled","0px"),s(["paddingTop","paddingBottom","paddingLeft","paddingRight"],"_paddingEnabled","0px"),t};export default WcElement;
@@ -0,0 +1,9 @@
1
+ import { AutofillI } from '@claspo/common/document/autofill.interface';
2
+ import ConfigService from '../../common/ConfigService';
3
+ import SourceRegistry from '../source/SourceRegistry';
4
+ export default class InputFieldsAutofillHydrator {
5
+ configService: ConfigService;
6
+ registry: SourceRegistry;
7
+ constructor(configService: ConfigService, registry: SourceRegistry);
8
+ resolveValue(autofill: AutofillI | undefined, key: string): string | undefined;
9
+ }
@@ -0,0 +1 @@
1
+ import{RenderMode}from"@claspo/common/RenderMode";import{resolveSourceValue}from"../source/resolveSourceValue";export default class InputFieldsAutofillHydrator{constructor(e,r){this.configService=e,this.registry=r}resolveValue(e,r){if(!(null==e?void 0:e.enabled)||!e.sourceType||this.configService.getConfig("renderMode")===RenderMode.UPDATING)return;const o=resolveSourceValue(this.registry,e.sourceType,e.config,r);if(void 0===o)return;const i=o.trim();return""===i?void 0:i}}
@@ -6,5 +6,4 @@ export default class HiddenFieldsContextHydrator {
6
6
  constructor(context: ContextSDK, hiddenFields?: AnyHiddenFieldSharedI[]);
7
7
  hydrate(hiddenFields?: AnyHiddenFieldSharedI[]): void;
8
8
  private resolveFieldValue;
9
- private static normalizeValue;
10
9
  }
@@ -1 +1 @@
1
- import{SourceType}from"@claspo/common/document/hidden-fields.interface";export default class HiddenFieldsContextHydrator{constructor(e,i=[]){this.context=e,this.hiddenFields=i||[]}hydrate(e=this.hiddenFields){this.hiddenFields=e||[],this.hiddenFields.forEach(e=>{const i=this.resolveFieldValue(e);void 0!==i&&this.context.addRecord(e.id,{recordKey:e.id,id:e.name,label:e.label,value:i})})}resolveFieldValue(e){var i;if(!(null==e?void 0:e.name)||!e.sourceType)return;if(e.sourceType===SourceType.STATIC)return HiddenFieldsContextHydrator.normalizeValue(null===(i=e.config)||void 0===i?void 0:i.value);const t=this.context.getRegistry().getSource(e.sourceType);if(!t)return;const o=t.getValue(e.id),d="function"==typeof(null==o?void 0:o.processor)?o.processor(t,Object.assign({id:e.id},e.config)):null==o?void 0:o.value;return HiddenFieldsContextHydrator.normalizeValue(d)}static normalizeValue(e){if(null!=e&&""!==e)return"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):String(e)}}
1
+ import{resolveSourceValue}from"../source/resolveSourceValue";export default class HiddenFieldsContextHydrator{constructor(e,d=[]){this.context=e,this.hiddenFields=d||[]}hydrate(e=this.hiddenFields){this.hiddenFields=e||[],this.hiddenFields.forEach(e=>{const d=this.resolveFieldValue(e);void 0!==d&&this.context.addRecord(e.id,{recordKey:e.id,id:e.name,label:e.label,value:d})})}resolveFieldValue(e){if((null==e?void 0:e.name)&&e.sourceType)return resolveSourceValue(this.context.getRegistry(),e.sourceType,e.config,e.id)}}
@@ -0,0 +1,4 @@
1
+ import { SourceArgumentsConfigI, SourceType, StaticSourceConfigI } from '@claspo/common/document/source.interface';
2
+ import SourceRegistry from './SourceRegistry';
3
+ export declare function normalizeSourceValue(value: any): string | undefined;
4
+ export declare function resolveSourceValue(registry: SourceRegistry, sourceType: SourceType, config: StaticSourceConfigI | SourceArgumentsConfigI, key: string): string | undefined;
@@ -0,0 +1 @@
1
+ import{SourceType}from"@claspo/common/document/source.interface";export function normalizeSourceValue(e){if(null!=e&&""!==e)return"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):String(e)}export function resolveSourceValue(e,o,r,u){if(!o)return;if(o===SourceType.STATIC)return normalizeSourceValue(null==r?void 0:r.value);const n=e.getSource(o);if(!n)return;const t=n.getValue(u);return normalizeSourceValue("function"==typeof(null==t?void 0:t.processor)?t.processor(n,Object.assign({id:u},r)):null==t?void 0:t.value)}
@@ -1,6 +1,6 @@
1
1
  import DefaultEventEmitter from "@claspo/common/DefaultEventEmitter";
2
2
  import { SourceUpdateDataI } from '../../context/ContextSDK';
3
- import { SourceType } from "@claspo/common/document/hidden-fields.interface";
3
+ import { SourceType } from "@claspo/common/document/source.interface";
4
4
  declare global {
5
5
  interface Window {
6
6
  [key: string]: any;
@@ -1 +1 @@
1
- import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import{SourceType}from"@claspo/common/document/hidden-fields.interface";import resolveVariableValue from"./resolveVariableValue";class JSApiVariablesSource extends DefaultEventEmitter{constructor(e={}){super(),this.instanceName=e.instanceName}get appInstance(){return window[this.instanceName]}get variables(){var e;return(null===(e=this.appInstance)||void 0===e?void 0:e.variables)||{}}subscribe(e){this.on("CHANGE",({values:r})=>{for(let a in r)e({key:a,value:r[a]})})}getValue(e){return e?{processor:(e,r)=>JSApiVariablesSource.processModel(r,this.instanceName)}:{}}addValues(e){if(!this.appInstance)throw new Error("Instatiate first");if(!e||"object"!=typeof e)throw new Error("Values should be object");Object.keys(e).length&&(this.appInstance.variables=Object.assign(Object.assign({},this.variables),e),this.emit("CHANGE",{values:e}))}static processModel(e,r){var a;if(!e.arguments)return"";const t=e.arguments.find(e=>"JavaScriptVariable"===e.name);if(!(null==t?void 0:t.value)||!r||!(null===(a=window[r])||void 0===a?void 0:a.variables))return"";try{const e=resolveVariableValue(window[r].variables,t.value);return null==e?"":e}catch(r){return console.error("JSApiVariablesSource: error while getting variable. Model: ",e,"Error: ",r),""}}}JSApiVariablesSource.sourceId=SourceType.JS_API_VARIABLE;export default JSApiVariablesSource;
1
+ import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import{SourceType}from"@claspo/common/document/source.interface";import resolveVariableValue from"./resolveVariableValue";class JSApiVariablesSource extends DefaultEventEmitter{constructor(e={}){super(),this.instanceName=e.instanceName}get appInstance(){return window[this.instanceName]}get variables(){var e;return(null===(e=this.appInstance)||void 0===e?void 0:e.variables)||{}}subscribe(e){this.on("CHANGE",({values:r})=>{for(let a in r)e({key:a,value:r[a]})})}getValue(e){return e?{processor:(e,r)=>JSApiVariablesSource.processModel(r,this.instanceName)}:{}}addValues(e){if(!this.appInstance)throw new Error("Instatiate first");if(!e||"object"!=typeof e)throw new Error("Values should be object");Object.keys(e).length&&(this.appInstance.variables=Object.assign(Object.assign({},this.variables),e),this.emit("CHANGE",{values:e}))}static processModel(e,r){var a;if(!e.arguments)return"";const t=e.arguments.find(e=>"JavaScriptVariable"===e.name);if(!(null==t?void 0:t.value)||!r||!(null===(a=window[r])||void 0===a?void 0:a.variables))return"";try{const e=resolveVariableValue(window[r].variables,t.value);return null==e?"":e}catch(r){return console.error("JSApiVariablesSource: error while getting variable. Model: ",e,"Error: ",r),""}}}JSApiVariablesSource.sourceId=SourceType.JS_API_VARIABLE;export default JSApiVariablesSource;