@gem-sdk/core 1.27.8 → 1.27.11

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.
@@ -2,12 +2,15 @@
2
2
 
3
3
  var variant = require('./variant.js');
4
4
 
5
- function getSelectedVariant(variants, choices) {
5
+ function getSelectedVariant(variants, choices, variantId) {
6
6
  /**
7
7
  * Ensure the user has selected all the required options, not just some.
8
8
  */ if (!variants || !variants.length || !choices || variants[0]?.selectedOptions.length !== Object.keys(choices).length) {
9
9
  return;
10
10
  }
11
+ if (variantId) {
12
+ return variants.find((variant)=>variant?.id === variantId);
13
+ }
11
14
  return variants.find((variant)=>{
12
15
  return Object.entries(choices).every(([name, value])=>{
13
16
  return variant?.selectedOptions.some((option)=>option.name === name && option.value === value);
@@ -1,11 +1,14 @@
1
1
  import { checkInStock } from './variant.js';
2
2
 
3
- function getSelectedVariant(variants, choices) {
3
+ function getSelectedVariant(variants, choices, variantId) {
4
4
  /**
5
5
  * Ensure the user has selected all the required options, not just some.
6
6
  */ if (!variants || !variants.length || !choices || variants[0]?.selectedOptions.length !== Object.keys(choices).length) {
7
7
  return;
8
8
  }
9
+ if (variantId) {
10
+ return variants.find((variant)=>variant?.id === variantId);
11
+ }
9
12
  return variants.find((variant)=>{
10
13
  return Object.entries(choices).every(([name, value])=>{
11
14
  return variant?.selectedOptions.some((option)=>option.name === name && option.value === value);
@@ -9515,7 +9515,7 @@ declare const composeRadiusResponsive: (radiusValue?: ObjectDevices<CornerRadius
9515
9515
  declare const getRadiusStyleActiveState: (radiusValue?: StateProp<CornerRadius>) => React.CSSProperties;
9516
9516
  declare const composeCornerCss: (value?: CornerRadius | undefined, important?: boolean) => string | undefined;
9517
9517
 
9518
- declare function getSelectedVariant(variants?: Maybe<VariantSelectFragment>[], choices?: Record<string, string>): Maybe<VariantSelectFragment>;
9518
+ declare function getSelectedVariant(variants?: Maybe<VariantSelectFragment>[], choices?: Record<string, string>, variantId?: string | null): Maybe<VariantSelectFragment>;
9519
9519
  declare function parseSelectedOption(options: SelectedOption[]): SelectedOption | undefined;
9520
9520
  declare function checkAvailableVariantInStock(variants: Maybe<VariantSelectFragment>[] | undefined, optionId: string, optionValue: string): boolean;
9521
9521
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.27.8",
3
+ "version": "1.27.11",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@gem-sdk/adapter-shopify": "1.25.0",
28
- "@gem-sdk/styles": "1.25.29"
28
+ "@gem-sdk/styles": "1.27.9"
29
29
  },
30
30
  "dependencies": {
31
31
  "react-error-boundary": "4.0.10",