@spiffcommerce/core 15.1.3 → 15.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +8 -7
- package/dist/module.js +8 -7
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -579,18 +579,19 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
|
|
|
579
579
|
`;class Rs extends Ps{constructor(t,e){super(t,e),Ys(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await Ia.getShadowGraphqlClient().mutate({mutation:ks,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const e=this.manager.getTransaction();this.manager.setTransaction({...e,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 Ia.getShadowGraphqlClient().mutate({mutation:Ns,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 Hs extends Ps{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return gs.selectVariant(this.step,t.getResource(),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 Wn(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const i=new Map;return i.set(t,e),gs.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),i)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?gs.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 Us extends Ps{constructor(t,e){super(t,e)}selectVariant(t){return hs.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Gs extends Ps{constructor(t,e){super(t,e)}selectVariant(t){return ds.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Ts extends Ps{constructor(t,e){super(t,e)}selectVariant(t){return ws.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Os extends Ps{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await Bs.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Js extends Ps{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return ms.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return ms.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return ms.availableColours(this.step)}setCustomColor(t){if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");return ms.setCustomColor(t,this.step,this.manager)}getCustomColor(){const t=this.manager.getStepStorage(this.step.stepName)?.colour;if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");if(!t)throw new Error("Color not available on step. Set a default on the workflow to fix this.");return t}}class Ls extends Ps{constructor(t,e){super(t,e)}async selectVariant(t){ys.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Ds.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableFillColors(){return this.step.data.colorPickerEnabled?ys.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await ys.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return ys.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await ys.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",i=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,n=t?i:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1});return this.setText(n)}setText(t){const e={input:t},i=ys.findLayoutElements(this.manager,this.step),n=ys.filterUnsupportedCharacters(t,i[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&n.length>this.step.data.maxLength||(e.input=n);const A=i.length<=0,a=A?{inputText:n,text:n}:{inputText:n};if(this.manager.updateStorage(this.step.stepName,a),this.manager.updateMetadata(this.step.stepName,{text:n}),A)return e;const{command:r,errors:o,helperText:s}=ys.updateInputText(n,i,this.step,this.manager);r&&this.manager.getCommandDispatcher()(r);const c=this.manager.getInformationResults(),l=o[0]?.localizationKey;if(l)this.manager.setInformationResults([...c,{message:`${l} - ${this.step.stepTitle}`,messageType:Ds.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return e.helperText=l||s,e.errorText=l,e}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 zs extends Ps{constructor(t,e){super(t,e)}async selectVariant(){}getContent(){return this.step.data.content}}class js{static get(t,e){switch(e.type){case oi.Information:return new zs(t,e);case oi.Question:return new Os(t,e);case oi.Text:return new Ls(t,e);case oi.Illustration:return new Hs(t,e);case oi.Picture:return new Ts(t,e);case oi.Shape:return new Js(t,e);case oi.Material:return new Us(t,e);case oi.Model:return new Gs(t,e);case oi.Frame:return new wl(t,e);case oi.Bulk:return new Rs(t,e);default:throw new ra(`Step type ${e.type} not yet supported in Core SDK`)}}}function Vs(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Ks=t.gql`
|
|
580
580
|
fragment CreateDesignTransaction on Transaction {
|
|
581
581
|
id
|
|
582
|
-
designName
|
|
583
582
|
bulk
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
externalDesignProductId
|
|
587
|
-
externalDesignProductVariantId
|
|
583
|
+
bulkEmailAddress
|
|
584
|
+
designName
|
|
588
585
|
externalCartProductId
|
|
589
586
|
externalCartProductVariantId
|
|
587
|
+
externalDesignProductId
|
|
588
|
+
externalDesignProductVariantId
|
|
589
|
+
lastSyncedAt
|
|
590
|
+
previewImageLink
|
|
591
|
+
priceModifierTotal
|
|
592
|
+
variationsCount
|
|
590
593
|
workflowViewerLink
|
|
591
594
|
workflowViewerReadOnlyLink
|
|
592
|
-
lastSyncedAt
|
|
593
|
-
bulkEmailAddress
|
|
594
595
|
}
|
|
595
596
|
`,Ws=t.gql`
|
|
596
597
|
${Ks}
|
package/dist/module.js
CHANGED
|
@@ -579,18 +579,19 @@ import{CommandContext as t,AssetType as e,BringForwardCommand as A,BringToFrontC
|
|
|
579
579
|
`;class ka extends Na{constructor(t,e){super(t,e),Ra(this,"transaction",this.manager.getTransaction())}selectVariant(){throw new Error("Bulk step does not support variants.")}async setDesignName(t){await ye.getShadowGraphqlClient().mutate({mutation:ba,variables:{transactionId:this.manager.getTransaction().id,designName:t}});const e=this.manager.getTransaction();this.manager.setTransaction({...e,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 ye.getShadowGraphqlClient().mutate({mutation:Ha,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 Ua extends Na{constructor(t,e){super(t,e)}async selectVariant(t){if(this.getCurrentVariant()!==t)return Ba.selectVariant(this.step,t.getResource(),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 y(t[0].id,this.manager.getAllLayoutData()).colors}catch(t){console.error(t)}}setColor(t,e){const A=new Map;return A.set(t,e),Ba.changeColors(this.step,this.manager.getRegionElements(this.step.stepName),this.manager,(()=>this.manager.getCommandContext().getAllLayouts()),A)}async getColorOption(){return this.step.data.colorOption}getAvailableColors(){return this.step.data.colorPickerEnabled?Ba.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 Ga extends Na{constructor(t,e){super(t,e)}selectVariant(t){return da.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Ja extends Na{constructor(t,e){super(t,e)}selectVariant(t){return wa.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class Ta extends Na{constructor(t,e){super(t,e)}selectVariant(t){return Ea.selectVariant(this.step,t.getResource(),this.manager,(t=>this.setUpdateState(t)))}}class La extends Na{constructor(t,e){super(t,e)}async selectVariant(t){if(!t.getId())throw new Error("Unable to select variant with a null ID");await ua.selectVariant(this.step,t.getId(),this.manager)}getDisplayType(){return this.step.option?.displayType}}class Oa extends Na{constructor(t,e){super(t,e)}selectVariant(t){const e=t.getResource();return Qa.selectVariant(this.step,{fill:e.color,stroke:e.color,variant:e},this.manager.getRegionElements(this.step.stepName)||[],this.manager)}setColor(t){return Qa.selectVariant(this.step,t,this.manager.getRegionElements(this.step.stepName)||[],this.manager)}getColors(){return Qa.availableColours(this.step)}setCustomColor(t){if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");return Qa.setCustomColor(t,this.step,this.manager)}getCustomColor(){const t=this.manager.getStepStorage(this.step.stepName)?.colour;if("#custom"!==this.getCurrentVariant()?.getColor())throw new Error("Custom colors can only be set on a non-custom variant. Please add a custom variant to the step.");if(!t)throw new Error("Color not available on step. Set a default on the workflow to fix this.");return t}}class za extends Na{constructor(t,e){super(t,e)}async selectVariant(t){Ia.selectVariant(this.step,t.getResource(),this.manager,(t=>{if(t)this.manager.setInformationResults([...this.manager.getInformationResults(),{message:"An issue has occured with test",messageType:Ma.Error,stepID:this.step.stepName}]);else{const t=this.manager.getInformationResults().filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}}),(t=>{}))}getAvailableFillColors(){return this.step.data.colorPickerEnabled?Ia.availableFillColors(this.step):[]}async setFillColor(t){const e=this.manager.getRegionElements(this.step.stepName);await Ia.changeFillColor(this.step,t,e,this.manager)}getFillColor(){return this.manager.getStepStorage(this.step.stepName)?.color||"#000000"}getAvailableFillImages(){return Ia.availableFillImages(this.step)}async setFillImage(t){const e=this.manager.getRegionElements(this.step.stepName);await Ia.changeFillImage(this.step,t,e,this.manager)}getFillImage(){return this.manager.getStepStorage(this.step.stepName)?.fillImage}setFullTextCustomization(t){const e=this.manager.getStepStorage(this.step.stepName)?.inputText||"",A=void 0!==this.step.data.replaceableText?this.step.data.replaceableText.replace("{{}}",e):e,n=t?A:this.step.data.defaultText;this.manager.updateStorage(this.step.stepName,{customiseAllText:t,text:n,defaultCleared:!1});return this.setText(n)}setText(t){const e={input:t},A=Ia.findLayoutElements(this.manager,this.step),n=Ia.filterUnsupportedCharacters(t,A[0]?.fontData);!!this.step.data&&!!this.step.data.maxLength&&n.length>this.step.data.maxLength||(e.input=n);const a=A.length<=0,i=a?{inputText:n,text:n}:{inputText:n};if(this.manager.updateStorage(this.step.stepName,i),this.manager.updateMetadata(this.step.stepName,{text:n}),a)return e;const{command:o,errors:r,helperText:s}=Ia.updateInputText(n,A,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:Ma.Error,stepID:this.step.stepName}]);else{const t=c.filter((t=>t.stepID!==this.step.stepName));this.manager.setInformationResults(t)}return e.helperText=g||s,e.errorText=g,e}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 ja extends Na{constructor(t,e){super(t,e)}async selectVariant(){}getContent(){return this.step.data.content}}class Ka{static get(t,e){switch(e.type){case m.Information:return new ja(t,e);case m.Question:return new La(t,e);case m.Text:return new za(t,e);case m.Illustration:return new Ua(t,e);case m.Picture:return new Ta(t,e);case m.Shape:return new Oa(t,e);case m.Material:return new Ga(t,e);case m.Model:return new Ja(t,e);case m.Frame:return new Eo(t,e);case m.Bulk:return new ka(t,e);default:throw new re(`Step type ${e.type} not yet supported in Core SDK`)}}}function Va(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}const Wa=It`
|
|
580
580
|
fragment CreateDesignTransaction on Transaction {
|
|
581
581
|
id
|
|
582
|
-
designName
|
|
583
582
|
bulk
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
externalDesignProductId
|
|
587
|
-
externalDesignProductVariantId
|
|
583
|
+
bulkEmailAddress
|
|
584
|
+
designName
|
|
588
585
|
externalCartProductId
|
|
589
586
|
externalCartProductVariantId
|
|
587
|
+
externalDesignProductId
|
|
588
|
+
externalDesignProductVariantId
|
|
589
|
+
lastSyncedAt
|
|
590
|
+
previewImageLink
|
|
591
|
+
priceModifierTotal
|
|
592
|
+
variationsCount
|
|
590
593
|
workflowViewerLink
|
|
591
594
|
workflowViewerReadOnlyLink
|
|
592
|
-
lastSyncedAt
|
|
593
|
-
bulkEmailAddress
|
|
594
595
|
}
|
|
595
596
|
`,Xa=It`
|
|
596
597
|
${Wa}
|
package/dist/types.d.ts
CHANGED
|
@@ -1490,7 +1490,7 @@ export class Variant {
|
|
|
1490
1490
|
getThumbnail(): string | undefined;
|
|
1491
1491
|
/**
|
|
1492
1492
|
* @returns The URL for the display image configured on this variant. Can be used for things like size charts.
|
|
1493
|
-
* @deprecated To be removed in a future version
|
|
1493
|
+
* @deprecated To be removed in a future version, Please use getThumbnail() instead
|
|
1494
1494
|
*/
|
|
1495
1495
|
getDisplayImage(): string | undefined;
|
|
1496
1496
|
/**
|