@spiffcommerce/core 3.0.0 → 3.1.0

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/dist/main.js CHANGED
@@ -434,7 +434,7 @@ var t=require("@apollo/client"),A=require("lodash.clonedeep"),e=require("react/j
434
434
  id
435
435
  }
436
436
  }
437
- `;class io extends to{constructor(t,A){super(t,A),Ao(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await An.getShadowGraphqlClient().mutate({mutation:no,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const A=this.manager.getTransaction();this.manager.setTransaction({...A,designName:t})}addVariationRecord(){const t=this.manager.addVariationRecord({transactionId:this.transaction.id,values:[]});return this.manager.setCurrentVariationRecord(t),t}updateBulkIsConnected(t){this.manager.updateStorage(this.getId(),{bulkIsConnected:t})}openBulkSourceUrl(){window.open(this.transaction.bulkSourceUrl,"_blank")}async sendGoogleSheetLinkToEmail(t){await An.getShadowGraphqlClient().mutate({mutation:eo,variables:{id:this.transaction.id,details:{emailAddress:t},type:"Owner"}}),this.openBulkSourceUrl()}deleteVariationRecord(t){this.manager.removeVariationRecord(t)}getAspects(){return this.step.data.aspects}}class ao extends to{constructor(t,A){super(t,A)}async selectVariant(t){if(await this.getCurrentVariant()!==t)return Ha.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],(t=>this.setUpdateState(t)),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(0!==t.length)try{return SA(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,A){const e=new Map;return e.set(t,A),Ha.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),e)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?Ha.availableColors(this.step,this.manager):Promise.resolve([])}hasVaryingSelection(){return this.step.data.varySelection}hasVaryingColors(){return this.step.data.varyColors}isColorPickerEnabled(){return this.step.data.colorPickerEnabled}}class oo extends to{constructor(t,A){super(t,A)}selectVariant(t){return Pa.selectVariant(this.step,t,this.manager,(t=>this.setUpdateState(t)))}}class ro extends to{constructor(t,A){super(t,A)}selectVariant(t){return Ua.selectVariant(this.step,t,this.manager,(t=>this.setUpdateState(t)))}}class so extends to{constructor(t,A){super(t,A)}selectVariant(t){return ba.selectVariant(this.step,t,this.manager,(t=>this.setUpdateState(t)))}}class co extends to{constructor(t,A){super(t,A)}async selectVariant(t){if(!t.id)throw new Error("Unable to select variant with a null ID");await ka.selectVariant(this.step,t.id,this.manager)}getDisplayType(){return this.step.option?.displayType}}class go extends to{constructor(t,A){super(t,A)}selectVariant(t){return Promise.resolve()}setColor(t){return Ja.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return Ja.availableColours(this.step)}}class lo extends to{constructor(t,A){super(t,A)}async selectVariant(t){Va.selectVariant(this.step,t,this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Xa.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableColors(){return this.step.data.colorPickerEnabled?Va.availableColors(this.step):[]}async setFill(t){const A=this.manager.getRegionElements(this.step.stepName);await Va.changeFill(this.step,t,A,this.manager)}getFill(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}setFullTextCustomization(t){const A=this.manager.getStepStorage(this.step.stepName)?.inputText||"",e=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",A):A,n=t?e:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1});return this.setText(n)}setText(t){const A={input:t},e=Va.findLayoutElements(this.manager,this.step),n=Va.filterUnsupportedCharacters(t,e[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&n.length>this.step.data.maxLength||(A.input=n);const i=e.length<=0,a=i?{inputText:n,text:n}:{inputText:n};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:n}),i)return A;const{command:o,errors:r,helperText:s}=Va.updateInputText(n,e,this.step,this.manager);o&&this.manager.getCommandDispatcher()(o);const c=this.manager.getInformationResults(),g=r[0]?.localizationKey;if(g)this.manager.setInformationResults([...c,{message:`${g} - ${this.step.stepTitle}`,messageType:Xa.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return A.helperText=g||s,A.errorText=g,A}getText(){const t=this.step.data.defaultText;return this.manager.getStepStorage(this.step.stepName)?.text||t||""}isReplaceable(){return this.step.data.userCanReplaceText}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const t=this.setText("");return this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""}),t}}hasVaryingText(){return this.step.data.varyText}hasVaryingColor(){return this.step.data.varyColor}hasVaryingSelection(){return this.step.data.varySelection}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}}class Bo{static get(t,A){switch(A.type){case K.Question:return new co(t,A);case K.Text:return new lo(t,A);case K.Illustration:return new ao(t,A);case K.Picture:return new so(t,A);case K.Shape:return new go(t,A);case K.Material:return new oo(t,A);case K.Model:return new ro(t,A);case K.Frame:return new Go(t,A);case K.Bulk:return new io(t,A);default:throw new Oe(`Step type ${A.type} not yet supported in Core SDK`)}}}function wo(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}const ho=t.gql`
437
+ `;class io extends to{constructor(t,A){super(t,A),Ao(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await An.getShadowGraphqlClient().mutate({mutation:no,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const A=this.manager.getTransaction();this.manager.setTransaction({...A,designName:t})}addVariationRecord(){const t=this.manager.addVariationRecord({transactionId:this.transaction.id,values:[]});return this.manager.setCurrentVariationRecord(t),t}updateBulkIsConnected(t){this.manager.updateStorage(this.getId(),{bulkIsConnected:t})}openBulkSourceUrl(){window.open(this.transaction.bulkSourceUrl,"_blank")}async sendGoogleSheetLinkToEmail(t){await An.getShadowGraphqlClient().mutate({mutation:eo,variables:{id:this.transaction.id,details:{emailAddress:t},type:"Owner"}}),this.openBulkSourceUrl()}deleteVariationRecord(t){this.manager.removeVariationRecord(t)}getAspects(){return this.step.data.aspects}}class ao extends to{constructor(t,A){super(t,A)}async selectVariant(t){if(await this.getCurrentVariant()!==t)return Ha.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],(t=>this.setUpdateState(t)),this.manager)}getColors(){const t=this.manager.getRegionElements(this.step.stepName)||[];if(0!==t.length)try{return SA(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,A){const e=new Map;return e.set(t,A),Ha.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),e)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?Ha.availableColors(this.step,this.manager):Promise.resolve([])}hasVaryingSelection(){return this.step.data.varySelection}hasVaryingColors(){return this.step.data.varyColors}isColorPickerEnabled(){return this.step.data.colorPickerEnabled}}class oo extends to{constructor(t,A){super(t,A)}selectVariant(t){return Pa.selectVariant(this.step,t,this.manager,(t=>this.setUpdateState(t)))}}class ro extends to{constructor(t,A){super(t,A)}selectVariant(t){return Ua.selectVariant(this.step,t,this.manager,(t=>this.setUpdateState(t)))}}class so extends to{constructor(t,A){super(t,A)}selectVariant(t){return ba.selectVariant(this.step,t,this.manager,(t=>this.setUpdateState(t)))}}class co extends to{constructor(t,A){super(t,A)}async selectVariant(t){if(!t.id)throw new Error("Unable to select variant with a null ID");await ka.selectVariant(this.step,t.id,this.manager)}getDisplayType(){return this.step.option?.displayType}}class go extends to{constructor(t,A){super(t,A)}selectVariant(t){return Promise.resolve()}setColor(t){return Ja.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return Ja.availableColours(this.step)}}class lo extends to{constructor(t,A){super(t,A)}async selectVariant(t){Va.selectVariant(this.step,t,this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Xa.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableColors(){return this.step.data.colorPickerEnabled?Va.availableColors(this.step):[]}async setFill(t){const A=this.manager.getRegionElements(this.step.stepName);await Va.changeFill(this.step,t,A,this.manager)}getFill(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}setFullTextCustomization(t){const A=this.manager.getStepStorage(this.step.stepName)?.inputText||"",e=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",A):A,n=t?e:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1});return this.setText(n)}setText(t){const A={input:t},e=Va.findLayoutElements(this.manager,this.step),n=Va.filterUnsupportedCharacters(t,e[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&n.length>this.step.data.maxLength||(A.input=n);const i=e.length<=0,a=i?{inputText:n,text:n}:{inputText:n};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:n}),i)return A;const{command:o,errors:r,helperText:s}=Va.updateInputText(n,e,this.step,this.manager);o&&this.manager.getCommandDispatcher()(o);const c=this.manager.getInformationResults(),g=r[0]?.localizationKey;if(g)this.manager.setInformationResults([...c,{message:`${g} - ${this.step.stepTitle}`,messageType:Xa.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return A.helperText=g||s,A.errorText=g,A}getText(){const t=this.step.data.defaultText;return this.manager.getStepStorage(this.step.stepName)?.text||t||""}isReplaceable(){return this.step.data.userCanReplaceText}clearDefaultTextIfNecessary(){if(!this.manager.getStepStorage(this.step.stepName)?.defaultCleared&&this.step.data.deleteDefaultOnFocus){const t=this.setText("");return this.manager.updateStorage(this.step.stepName,{defaultCleared:!0,inputText:""}),t}}hasVaryingText(){return this.step.data.varyText}hasVaryingColor(){return this.step.data.varyColor}hasVaryingSelection(){return this.step.data.varySelection}hasColorPicker(){return this.step.data.colorPickerEnabled}getRegions(){return this.step.data.regions}getCharacterLimit(){return this.step.data.maxLength}getCharactersRemaining(){const t=this.step.data.maxLength;if(void 0===t)return;return t-this.getText().length}}class Bo{static get(t,A){switch(A.type){case K.Question:return new co(t,A);case K.Text:return new lo(t,A);case K.Illustration:return new ao(t,A);case K.Picture:return new so(t,A);case K.Shape:return new go(t,A);case K.Material:return new oo(t,A);case K.Model:return new ro(t,A);case K.Frame:return new Go(t,A);case K.Bulk:return new io(t,A);default:throw new Oe(`Step type ${A.type} not yet supported in Core SDK`)}}}function wo(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}const ho=t.gql`
438
438
  mutation CreateDesign(
439
439
  $name: String!
440
440
  $layouts: [LayoutInput]!