@spiffcommerce/core 21.2.0 → 21.2.1-alpha.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/index.js +2 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7932,7 +7932,7 @@ class gA {
|
|
|
7932
7932
|
* @param targetExperiences Optionally filter the steps to only those in the given experiences.
|
|
7933
7933
|
*/
|
|
7934
7934
|
getSharedSteps(e) {
|
|
7935
|
-
|
|
7935
|
+
const A = e ?? this.bundle.getWorkflowExperiences(), t = A.flatMap(
|
|
7936
7936
|
(n) => n.getSteps().filter((a) => {
|
|
7937
7937
|
var i;
|
|
7938
7938
|
return (i = a.getRaw().globalPropertyAspectConfigurations) == null ? void 0 : i.some(
|
|
@@ -7943,6 +7943,7 @@ class gA {
|
|
|
7943
7943
|
);
|
|
7944
7944
|
})
|
|
7945
7945
|
);
|
|
7946
|
+
return console.log(`getting shared steps for ${A.length} - found ${t.length}`, t), t;
|
|
7946
7947
|
}
|
|
7947
7948
|
getStateValue() {
|
|
7948
7949
|
return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);
|
package/dist/index.umd.cjs
CHANGED
|
@@ -2279,7 +2279,7 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
|
|
|
2279
2279
|
id
|
|
2280
2280
|
}
|
|
2281
2281
|
}
|
|
2282
|
-
`;class Zn{constructor(e){this.handleCache={},this.bundle=e}async getHandle(e){if(this.handleCache[e.name])return this.handleCache[e.name];const t=await this.createHandle(e);return this.handleCache[e.name]=t,t}async getHandles(){var t;if(!((t=this.bundle.getProductCollection())!=null&&t.getResource().globalPropertyConfiguration))return[];const e=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(e.aspects.map(A=>this.getHandle(A)))}applyConditionsFromState(e,t){return t?e.filter(A=>this.aspectConditionsSatisfied(A.getRawProperty(),t)):e}aspectConditionsSatisfied(e,t){return!e.conditions||e.conditions.length===0?!0:e.conditions.some(A=>{const n=t.aspects.find(a=>a.name===A.targetAspectName);return n?A.requiredVariantSelections.some(a=>a===n.value):!1})}async createHandle(e){switch(e.type){case g.AspectType.FileUpload:return new qt(this.bundle,e);case g.AspectType.Option:{const t=e.entityId?await L.getOption(e.entityId):void 0;return(t==null?void 0:t.type)==="Color"?new $t(this.bundle,e,t):new Ke(this.bundle,e,t)}case g.AspectType.Text:return new Zt(this.bundle,e)}}}class Se{constructor(e,t){this.bundle=e,this.property=t}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(e){
|
|
2282
|
+
`;class Zn{constructor(e){this.handleCache={},this.bundle=e}async getHandle(e){if(this.handleCache[e.name])return this.handleCache[e.name];const t=await this.createHandle(e);return this.handleCache[e.name]=t,t}async getHandles(){var t;if(!((t=this.bundle.getProductCollection())!=null&&t.getResource().globalPropertyConfiguration))return[];const e=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(e.aspects.map(A=>this.getHandle(A)))}applyConditionsFromState(e,t){return t?e.filter(A=>this.aspectConditionsSatisfied(A.getRawProperty(),t)):e}aspectConditionsSatisfied(e,t){return!e.conditions||e.conditions.length===0?!0:e.conditions.some(A=>{const n=t.aspects.find(a=>a.name===A.targetAspectName);return n?A.requiredVariantSelections.some(a=>a===n.value):!1})}async createHandle(e){switch(e.type){case g.AspectType.FileUpload:return new qt(this.bundle,e);case g.AspectType.Option:{const t=e.entityId?await L.getOption(e.entityId):void 0;return(t==null?void 0:t.type)==="Color"?new $t(this.bundle,e,t):new Ke(this.bundle,e,t)}case g.AspectType.Text:return new Zt(this.bundle,e)}}}class Se{constructor(e,t){this.bundle=e,this.property=t}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(e){const t=e??this.bundle.getWorkflowExperiences(),A=t.flatMap(n=>n.getSteps().filter(a=>{var i;return(i=a.getRaw().globalPropertyAspectConfigurations)==null?void 0:i.some(o=>{var s,r;return o.globalPropertyConfigurationId===((r=(s=this.bundle.getProductCollection())==null?void 0:s.getResource().globalPropertyConfiguration)==null?void 0:r.id)&&o.aspectName===this.property.name})}));return console.log(`getting shared steps for ${t.length} - found ${A.length}`,A),A}getStateValue(){return this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name)}}class qt extends Se{constructor(e,t){super(e,t)}async selectImage(e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,e.key),this.applyImageSelection(e)])}hasImage(){return!!this.getStateValue()}async getImage(){const e=this.getStateValue();if(e)return k.getLocalOrFromServer(e)}async applyGlobalState(e){const t=this.getStateValue();if(!t)return Promise.resolve();const A=await k.getLocalOrFromServer(t);return A?this.applyImageSelection(A,e):Promise.resolve()}async applyImageSelection(e,t){const n=this.getSharedSteps(t).map(a=>a.selectImage(e));await Promise.all(n)}}class Zt extends Se{constructor(e,t){super(e,t)}getText(){const e=this.getStateValue();return e||""}async setText(e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,e),this.applyTextSelection(e)])}async applyGlobalState(e){const t=this.getStateValue();if(!t)return Promise.resolve();await this.applyTextSelection(t,e)}async applyTextSelection(e,t){const n=this.getSharedSteps(t).map(a=>{a.setText(e)});await Promise.all(n)}}class Ke extends Se{constructor(e,t,A){super(e,t),this.optionResource=A}getCurrentVariant(){var t,A;if(!this.optionResource)return;const e=this.getStateValue();if(e){const n=(A=this.optionResource.variants)==null?void 0:A.find(a=>a.id===e);return n?new K(n):void 0}else{const n=(t=this.optionResource.variants)==null?void 0:t.find(a=>{var i,o;return a.id===((o=(i=this.optionResource)==null?void 0:i.defaultVariant)==null?void 0:o.id)});return n?new K(n):void 0}}getAvailableVariants(){var t,A;return(((A=(t=this.optionResource)==null?void 0:t.variants)==null?void 0:A.filter(n=>n.enabled))||[]).map(n=>new K(n))}getAllVariants(){var t;return(((t=this.optionResource)==null?void 0:t.variants)||[]).map(A=>new K(A))}async selectVariant(e){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,e.getId()),this.applyVariantSelection(e)])}async applyGlobalState(e){var n,a;const t=this.getStateValue();if(!t)return Promise.resolve();const A=(a=(n=this.optionResource)==null?void 0:n.variants)==null?void 0:a.find(i=>i.id===t);return A?this.applyVariantSelection(new K(A),e):Promise.resolve()}async applyVariantSelection(e,t){const n=this.getSharedSteps(t).map(a=>a.selectVariant(e));await Promise.all(n)}}class $t extends Ke{constructor(e,t,A){super(e,t,A)}setCustomColor(e){this.getSharedSteps().forEach(A=>A.setCustomColor(e))}getCustomColor(){return this.getSharedSteps()[0].getCustomColor()}}const $n=M.gql`
|
|
2283
2283
|
mutation CreateGlobalPropertyState($bundleId: String!) {
|
|
2284
2284
|
globalPropertyStateCreate(bundleId: $bundleId) {
|
|
2285
2285
|
id
|