@cimplify/sdk 0.9.2 → 0.9.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.
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * Derive a human-readable display name for a variant.
3
3
  *
4
- * Priority: explicit name display_attributes joined"Default"/"Option" fallback.
4
+ * Priority: display_attributes name (stripped of product prefix) → fallback.
5
+ *
6
+ * Pass `productName` to strip redundant product-name prefixes from variant names
7
+ * (e.g. "Fried rice-Small" → "Small" when productName is "Fried rice").
5
8
  */
6
9
  declare function getVariantDisplayName(variant: {
7
10
  name?: string;
@@ -9,7 +12,7 @@ declare function getVariantDisplayName(variant: {
9
12
  value_name: string;
10
13
  }>;
11
14
  is_default?: boolean;
12
- }): string;
15
+ }, productName?: string): string;
13
16
 
14
17
  type AdSlot = "banner" | "sidebar" | "in-content" | "native" | "footer";
15
18
  type AdPosition = "static" | "sticky" | "fixed";
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * Derive a human-readable display name for a variant.
3
3
  *
4
- * Priority: explicit name display_attributes joined"Default"/"Option" fallback.
4
+ * Priority: display_attributes name (stripped of product prefix) → fallback.
5
+ *
6
+ * Pass `productName` to strip redundant product-name prefixes from variant names
7
+ * (e.g. "Fried rice-Small" → "Small" when productName is "Fried rice").
5
8
  */
6
9
  declare function getVariantDisplayName(variant: {
7
10
  name?: string;
@@ -9,7 +12,7 @@ declare function getVariantDisplayName(variant: {
9
12
  value_name: string;
10
13
  }>;
11
14
  is_default?: boolean;
12
- }): string;
15
+ }, productName?: string): string;
13
16
 
14
17
  type AdSlot = "banner" | "sidebar" | "in-content" | "native" | "footer";
15
18
  type AdPosition = "static" | "sticky" | "fixed";
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ export { QueryBuilder, query } from './advanced.mjs';
3
3
  import { A as ApiError } from './payment-DsGQPORm.mjs';
4
4
  export { G as AddOn, av as AddOnDetails, aR as AddOnGroupDetails, J as AddOnOption, aQ as AddOnOptionDetails, K as AddOnOptionPrice, H as AddOnWithOptions, aW as AddToCartInput, ak as AdjustmentType, ar as AppliedDiscount, b0 as AuthorizationType, aq as BenefitType, W as Bundle, $ as BundleComponentData, a0 as BundleComponentInfo, U as BundlePriceType, Y as BundleProduct, aA as BundleSelectionData, ay as BundleSelectionInput, az as BundleStoredSelection, X as BundleSummary, _ as BundleWithDetails, aF as Cart, aw as CartAddOn, ai as CartChannel, aG as CartItem, aT as CartItemDetails, ah as CartStatus, aY as CartSummary, aH as CartTotals, N as Category, O as CategorySummary, ap as ChosenPrice, h as CimplifyError, Q as Collection, T as CollectionProduct, R as CollectionSummary, a6 as ComponentGroup, a7 as ComponentGroupWithComponents, ab as ComponentPriceBreakdown, a9 as ComponentSelectionInput, a3 as ComponentSourceType, a4 as Composite, a8 as CompositeComponent, aC as CompositePriceBreakdown, aa as CompositePriceResult, a1 as CompositePricingMode, aD as CompositeSelectionData, a9 as CompositeSelectionInput, aB as CompositeStoredSelection, a5 as CompositeWithDetails, b as Currency, C as CurrencyCode, r as DepositType, q as DigitalProductType, as as DiscountBreakdown, at as DiscountDetails, aK as DisplayAddOn, aL as DisplayAddOnOption, aI as DisplayCart, aJ as DisplayCartItem, D as DisplayMode, g as ERROR_HINTS, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, a2 as GroupPricingBehavior, b4 as InitializePaymentResult, I as InventoryType, aE as LineConfiguration, ae as LocationProductPrice, M as Money, d as Pagination, P as PaginationParams, b3 as Payment, b7 as PaymentErrorDetails, b2 as PaymentMethod, a$ as PaymentMethodType, b1 as PaymentProcessingState, a_ as PaymentProvider, b5 as PaymentResponse, aZ as PaymentStatus, b6 as PaymentStatusResponse, ad as Price, al as PriceAdjustment, ao as PriceDecisionPath, ac as PriceEntryType, an as PricePathTaxInfo, aj as PriceSource, s as Product, L as ProductAddOn, af as ProductAvailability, p as ProductRenderHint, ag as ProductTimeProfile, o as ProductType, u as ProductVariant, z as ProductVariantValue, t as ProductWithDetails, S as SalesChannel, au as SelectedAddOnOption, b8 as SubmitAuthorizationInput, am as TaxPathComponent, aU as UICart, aM as UICartBusiness, aO as UICartCustomer, aN as UICartLocation, aP as UICartPricing, aV as UICartResponse, aX as UpdateCartItemInput, w as VariantAxis, F as VariantAxisSelection, y as VariantAxisValue, x as VariantAxisWithValues, ax as VariantDetails, aS as VariantDetailsDTO, v as VariantDisplayAttribute, B as VariantLocationAvailability, V as VariantStrategy, Z as ZERO, c as currencyCode, l as enrichError, k as getErrorHint, j as isCimplifyError, n as isRetryableError, i as isSupportedCurrency, m as money, a as moneyFromNumber } from './payment-DsGQPORm.mjs';
5
5
  export { C as CURRENCY_SYMBOLS, B as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, A as ProductWithPrice, T as TaxComponent, z as TaxInfo, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-4Ke_FJa6.mjs';
6
- export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme, g as getVariantDisplayName } from './ads-DeL3PGzf.mjs';
6
+ export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme, g as getVariantDisplayName } from './ads-MkGm5l1T.mjs';
7
7
 
8
8
  /** Context sent with every request to scope operations to a specific location/branch */
9
9
  interface FrontendContext {
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { QueryBuilder, query } from './advanced.js';
3
3
  import { A as ApiError } from './payment-DsGQPORm.js';
4
4
  export { G as AddOn, av as AddOnDetails, aR as AddOnGroupDetails, J as AddOnOption, aQ as AddOnOptionDetails, K as AddOnOptionPrice, H as AddOnWithOptions, aW as AddToCartInput, ak as AdjustmentType, ar as AppliedDiscount, b0 as AuthorizationType, aq as BenefitType, W as Bundle, $ as BundleComponentData, a0 as BundleComponentInfo, U as BundlePriceType, Y as BundleProduct, aA as BundleSelectionData, ay as BundleSelectionInput, az as BundleStoredSelection, X as BundleSummary, _ as BundleWithDetails, aF as Cart, aw as CartAddOn, ai as CartChannel, aG as CartItem, aT as CartItemDetails, ah as CartStatus, aY as CartSummary, aH as CartTotals, N as Category, O as CategorySummary, ap as ChosenPrice, h as CimplifyError, Q as Collection, T as CollectionProduct, R as CollectionSummary, a6 as ComponentGroup, a7 as ComponentGroupWithComponents, ab as ComponentPriceBreakdown, a9 as ComponentSelectionInput, a3 as ComponentSourceType, a4 as Composite, a8 as CompositeComponent, aC as CompositePriceBreakdown, aa as CompositePriceResult, a1 as CompositePricingMode, aD as CompositeSelectionData, a9 as CompositeSelectionInput, aB as CompositeStoredSelection, a5 as CompositeWithDetails, b as Currency, C as CurrencyCode, r as DepositType, q as DigitalProductType, as as DiscountBreakdown, at as DiscountDetails, aK as DisplayAddOn, aL as DisplayAddOnOption, aI as DisplayCart, aJ as DisplayCartItem, D as DisplayMode, g as ERROR_HINTS, E as ErrorCode, e as ErrorCodeType, f as ErrorHint, a2 as GroupPricingBehavior, b4 as InitializePaymentResult, I as InventoryType, aE as LineConfiguration, ae as LocationProductPrice, M as Money, d as Pagination, P as PaginationParams, b3 as Payment, b7 as PaymentErrorDetails, b2 as PaymentMethod, a$ as PaymentMethodType, b1 as PaymentProcessingState, a_ as PaymentProvider, b5 as PaymentResponse, aZ as PaymentStatus, b6 as PaymentStatusResponse, ad as Price, al as PriceAdjustment, ao as PriceDecisionPath, ac as PriceEntryType, an as PricePathTaxInfo, aj as PriceSource, s as Product, L as ProductAddOn, af as ProductAvailability, p as ProductRenderHint, ag as ProductTimeProfile, o as ProductType, u as ProductVariant, z as ProductVariantValue, t as ProductWithDetails, S as SalesChannel, au as SelectedAddOnOption, b8 as SubmitAuthorizationInput, am as TaxPathComponent, aU as UICart, aM as UICartBusiness, aO as UICartCustomer, aN as UICartLocation, aP as UICartPricing, aV as UICartResponse, aX as UpdateCartItemInput, w as VariantAxis, F as VariantAxisSelection, y as VariantAxisValue, x as VariantAxisWithValues, ax as VariantDetails, aS as VariantDetailsDTO, v as VariantDisplayAttribute, B as VariantLocationAvailability, V as VariantStrategy, Z as ZERO, c as currencyCode, l as enrichError, k as getErrorHint, j as isCimplifyError, n as isRetryableError, i as isSupportedCurrency, m as money, a as moneyFromNumber } from './payment-DsGQPORm.js';
5
5
  export { C as CURRENCY_SYMBOLS, B as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, A as ProductWithPrice, T as TaxComponent, z as TaxInfo, s as categorizePaymentError, y as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, j as formatPriceWithTax, e as formatProductPrice, m as getBasePrice, k as getCurrencySymbol, o as getDiscountPercentage, l as getDisplayPrice, q as getMarkupPercentage, r as getProductCurrency, g as getTaxAmount, h as hasTaxInfo, n as isOnSale, v as isPaymentStatusFailure, w as isPaymentStatusRequiresAction, x as isPaymentStatusSuccess, i as isTaxInclusive, t as normalizePaymentResponse, u as normalizeStatusResponse, p as parsePrice } from './index-ynsh8lBa.js';
6
- export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme, g as getVariantDisplayName } from './ads-DeL3PGzf.js';
6
+ export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme, g as getVariantDisplayName } from './ads-MkGm5l1T.js';
7
7
 
8
8
  /** Context sent with every request to scope operations to a specific location/branch */
9
9
  interface FrontendContext {
package/dist/index.js CHANGED
@@ -4252,12 +4252,40 @@ function query(entity) {
4252
4252
  }
4253
4253
 
4254
4254
  // src/utils/variant.ts
4255
- function getVariantDisplayName(variant) {
4256
- if (variant.name) return variant.name;
4255
+ function stripProductPrefix(variantName, productName) {
4256
+ if (!variantName || !productName) return variantName || productName;
4257
+ const lower = variantName.toLowerCase().trim();
4258
+ if (lower === "default" || lower === "standard") return productName;
4259
+ if (lower.endsWith("-default") || lower.endsWith("-standard")) return productName;
4260
+ if (variantName.startsWith(productName)) {
4261
+ const rest = variantName.slice(productName.length);
4262
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
4263
+ if (match && match[1].length > 0) return match[1];
4264
+ }
4265
+ const lowerProduct = productName.toLowerCase().trim();
4266
+ if (lower.startsWith(lowerProduct)) {
4267
+ const rest = variantName.slice(productName.length);
4268
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
4269
+ if (match && match[1].length > 0) return match[1];
4270
+ }
4271
+ const lastDash = variantName.lastIndexOf("-");
4272
+ if (lastDash > 0 && lastDash < variantName.length - 1) {
4273
+ const prefix = variantName.slice(0, lastDash).trim();
4274
+ const suffix = variantName.slice(lastDash + 1).trim();
4275
+ if (suffix.length > 0 && prefix.length > suffix.length * 2) {
4276
+ return suffix;
4277
+ }
4278
+ }
4279
+ return variantName;
4280
+ }
4281
+ function getVariantDisplayName(variant, productName) {
4257
4282
  if (variant.display_attributes?.length) {
4258
4283
  return variant.display_attributes.map((a) => a.value_name).join(" / ");
4259
4284
  }
4260
- return variant.is_default ? "Default" : "Option";
4285
+ if (variant.name) {
4286
+ return productName ? stripProductPrefix(variant.name, productName) : variant.name;
4287
+ }
4288
+ return productName || (variant.is_default ? "Default" : "Option");
4261
4289
  }
4262
4290
 
4263
4291
  exports.AUTHORIZATION_TYPE = AUTHORIZATION_TYPE;
package/dist/index.mjs CHANGED
@@ -4250,12 +4250,40 @@ function query(entity) {
4250
4250
  }
4251
4251
 
4252
4252
  // src/utils/variant.ts
4253
- function getVariantDisplayName(variant) {
4254
- if (variant.name) return variant.name;
4253
+ function stripProductPrefix(variantName, productName) {
4254
+ if (!variantName || !productName) return variantName || productName;
4255
+ const lower = variantName.toLowerCase().trim();
4256
+ if (lower === "default" || lower === "standard") return productName;
4257
+ if (lower.endsWith("-default") || lower.endsWith("-standard")) return productName;
4258
+ if (variantName.startsWith(productName)) {
4259
+ const rest = variantName.slice(productName.length);
4260
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
4261
+ if (match && match[1].length > 0) return match[1];
4262
+ }
4263
+ const lowerProduct = productName.toLowerCase().trim();
4264
+ if (lower.startsWith(lowerProduct)) {
4265
+ const rest = variantName.slice(productName.length);
4266
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
4267
+ if (match && match[1].length > 0) return match[1];
4268
+ }
4269
+ const lastDash = variantName.lastIndexOf("-");
4270
+ if (lastDash > 0 && lastDash < variantName.length - 1) {
4271
+ const prefix = variantName.slice(0, lastDash).trim();
4272
+ const suffix = variantName.slice(lastDash + 1).trim();
4273
+ if (suffix.length > 0 && prefix.length > suffix.length * 2) {
4274
+ return suffix;
4275
+ }
4276
+ }
4277
+ return variantName;
4278
+ }
4279
+ function getVariantDisplayName(variant, productName) {
4255
4280
  if (variant.display_attributes?.length) {
4256
4281
  return variant.display_attributes.map((a) => a.value_name).join(" / ");
4257
4282
  }
4258
- return variant.is_default ? "Default" : "Option";
4283
+ if (variant.name) {
4284
+ return productName ? stripProductPrefix(variant.name, productName) : variant.name;
4285
+ }
4286
+ return productName || (variant.is_default ? "Default" : "Option");
4259
4287
  }
4260
4288
 
4261
4289
  export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CONTACT_TYPE, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyElement, CimplifyElements, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, DEVICE_TYPE, ELEMENT_TYPES, ERROR_HINTS, EVENT_TYPES, ErrorCode, FxService, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MESSAGE_TYPES, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, ZERO, categorizePaymentError, combine, combineObject, createCimplifyClient, createElements, currencyCode, detectMobileMoneyProvider, enrichError, err, flatMap, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatPriceWithTax, formatProductPrice, fromPromise, generateIdempotencyKey, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getErrorHint, getMarkupPercentage, getOrElse, getProductCurrency, getTaxAmount, getVariantDisplayName, hasTaxInfo, isCimplifyError, isErr, isOk, isOnSale, isPaymentStatusFailure, isPaymentStatusRequiresAction, isPaymentStatusSuccess, isRetryableError, isSupportedCurrency, isTaxInclusive, mapError, mapResult, money, moneyFromNumber, normalizePaymentResponse, normalizeStatusResponse, ok, parsePrice, query, toNullable, tryCatch, unwrap };
package/dist/react.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-DeL3PGzf.mjs';
3
- export { c as AdConfig, g as getVariantDisplayName } from './ads-DeL3PGzf.mjs';
2
+ import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-MkGm5l1T.mjs';
3
+ export { c as AdConfig, g as getVariantDisplayName } from './ads-MkGm5l1T.mjs';
4
4
  import { C as CimplifyClient, Y as ProcessCheckoutResult, _ as CheckoutStatus, $ as CheckoutStatusContext, bq as Location, bn as Business, aS as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, w as ElementsOptions, cK as AuthenticatedData, cG as AddressInfo, cH as PaymentMethodInfo, s as CimplifyElements, cM as ElementsCheckoutResult, X as ProcessCheckoutOptions } from './client-D_3KMWI_.mjs';
5
5
  import { s as Product, d as Pagination, h as CimplifyError, t as ProductWithDetails, N as Category, ay as BundleSelectionInput, a9 as ComponentSelectionInput, Q as Collection, _ as BundleWithDetails, a5 as CompositeWithDetails, aa as CompositePriceResult, C as CurrencyCode, u as ProductVariant, x as VariantAxisWithValues, M as Money, H as AddOnWithOptions } from './payment-DsGQPORm.mjs';
6
6
 
@@ -424,6 +424,7 @@ interface VariantSelectorProps {
424
424
  basePrice?: Money;
425
425
  selectedVariantId?: string;
426
426
  onVariantChange: (variantId: string | undefined, variant: ProductVariant | undefined) => void;
427
+ productName?: string;
427
428
  className?: string;
428
429
  }
429
430
  /**
@@ -432,7 +433,7 @@ interface VariantSelectorProps {
432
433
  * Axis mode: one row of chips per axis (e.g. Size, Temperature).
433
434
  * Direct mode: a vertical list showing variant name + full effective price.
434
435
  */
435
- declare function VariantSelector({ variants, variantAxes, basePrice, selectedVariantId, onVariantChange, className, }: VariantSelectorProps): React.ReactElement | null;
436
+ declare function VariantSelector({ variants, variantAxes, basePrice, selectedVariantId, onVariantChange, productName, className, }: VariantSelectorProps): React.ReactElement | null;
436
437
 
437
438
  interface AddOnSelectorProps {
438
439
  addOns: AddOnWithOptions[];
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-DeL3PGzf.js';
3
- export { c as AdConfig, g as getVariantDisplayName } from './ads-DeL3PGzf.js';
2
+ import { A as AdSlot, a as AdPosition, e as AdContextValue } from './ads-MkGm5l1T.js';
3
+ export { c as AdConfig, g as getVariantDisplayName } from './ads-MkGm5l1T.js';
4
4
  import { C as CimplifyClient, Y as ProcessCheckoutResult, _ as CheckoutStatus, $ as CheckoutStatusContext, bq as Location, bn as Business, aS as Order, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, P as PriceQuote, g as QuoteUiMessage, w as ElementsOptions, cK as AuthenticatedData, cG as AddressInfo, cH as PaymentMethodInfo, s as CimplifyElements, cM as ElementsCheckoutResult, X as ProcessCheckoutOptions } from './client-BFqLTbxI.js';
5
5
  import { s as Product, d as Pagination, h as CimplifyError, t as ProductWithDetails, N as Category, ay as BundleSelectionInput, a9 as ComponentSelectionInput, Q as Collection, _ as BundleWithDetails, a5 as CompositeWithDetails, aa as CompositePriceResult, C as CurrencyCode, u as ProductVariant, x as VariantAxisWithValues, M as Money, H as AddOnWithOptions } from './payment-DsGQPORm.js';
6
6
 
@@ -424,6 +424,7 @@ interface VariantSelectorProps {
424
424
  basePrice?: Money;
425
425
  selectedVariantId?: string;
426
426
  onVariantChange: (variantId: string | undefined, variant: ProductVariant | undefined) => void;
427
+ productName?: string;
427
428
  className?: string;
428
429
  }
429
430
  /**
@@ -432,7 +433,7 @@ interface VariantSelectorProps {
432
433
  * Axis mode: one row of chips per axis (e.g. Size, Temperature).
433
434
  * Direct mode: a vertical list showing variant name + full effective price.
434
435
  */
435
- declare function VariantSelector({ variants, variantAxes, basePrice, selectedVariantId, onVariantChange, className, }: VariantSelectorProps): React.ReactElement | null;
436
+ declare function VariantSelector({ variants, variantAxes, basePrice, selectedVariantId, onVariantChange, productName, className, }: VariantSelectorProps): React.ReactElement | null;
436
437
 
437
438
  interface AddOnSelectorProps {
438
439
  addOns: AddOnWithOptions[];
package/dist/react.js CHANGED
@@ -6799,12 +6799,40 @@ function QuantitySelector({
6799
6799
  }
6800
6800
 
6801
6801
  // src/utils/variant.ts
6802
- function getVariantDisplayName(variant) {
6803
- if (variant.name) return variant.name;
6802
+ function stripProductPrefix(variantName, productName) {
6803
+ if (!variantName || !productName) return variantName || productName;
6804
+ const lower = variantName.toLowerCase().trim();
6805
+ if (lower === "default" || lower === "standard") return productName;
6806
+ if (lower.endsWith("-default") || lower.endsWith("-standard")) return productName;
6807
+ if (variantName.startsWith(productName)) {
6808
+ const rest = variantName.slice(productName.length);
6809
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
6810
+ if (match && match[1].length > 0) return match[1];
6811
+ }
6812
+ const lowerProduct = productName.toLowerCase().trim();
6813
+ if (lower.startsWith(lowerProduct)) {
6814
+ const rest = variantName.slice(productName.length);
6815
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
6816
+ if (match && match[1].length > 0) return match[1];
6817
+ }
6818
+ const lastDash = variantName.lastIndexOf("-");
6819
+ if (lastDash > 0 && lastDash < variantName.length - 1) {
6820
+ const prefix = variantName.slice(0, lastDash).trim();
6821
+ const suffix = variantName.slice(lastDash + 1).trim();
6822
+ if (suffix.length > 0 && prefix.length > suffix.length * 2) {
6823
+ return suffix;
6824
+ }
6825
+ }
6826
+ return variantName;
6827
+ }
6828
+ function getVariantDisplayName(variant, productName) {
6804
6829
  if (variant.display_attributes?.length) {
6805
6830
  return variant.display_attributes.map((a) => a.value_name).join(" / ");
6806
6831
  }
6807
- return variant.is_default ? "Default" : "Option";
6832
+ if (variant.name) {
6833
+ return productName ? stripProductPrefix(variant.name, productName) : variant.name;
6834
+ }
6835
+ return productName || (variant.is_default ? "Default" : "Option");
6808
6836
  }
6809
6837
  function VariantSelector({
6810
6838
  variants,
@@ -6812,6 +6840,7 @@ function VariantSelector({
6812
6840
  basePrice,
6813
6841
  selectedVariantId,
6814
6842
  onVariantChange,
6843
+ productName,
6815
6844
  className
6816
6845
  }) {
6817
6846
  const [axisSelections, setAxisSelections] = React3.useState({});
@@ -6891,7 +6920,7 @@ function VariantSelector({
6891
6920
  "data-cimplify-variant-option": true,
6892
6921
  "data-selected": isSelected || void 0,
6893
6922
  children: [
6894
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-variant-name": true, children: getVariantDisplayName(variant) }),
6923
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-variant-name": true, children: getVariantDisplayName(variant, productName) }),
6895
6924
  /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, children: [
6896
6925
  adjustment !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-adjustment": true, children: [
6897
6926
  adjustment > 0 ? "+" : "",
@@ -7284,7 +7313,7 @@ function BundleComponentCard({
7284
7313
  "data-cimplify-bundle-variant-option": true,
7285
7314
  "data-selected": isSelected || void 0,
7286
7315
  children: [
7287
- getVariantDisplayName(variant),
7316
+ getVariantDisplayName(variant, product.name),
7288
7317
  adjustment !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-bundle-variant-adjustment": true, children: [
7289
7318
  adjustment > 0 ? "+" : "",
7290
7319
  /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: variant.price_adjustment })
@@ -7618,7 +7647,7 @@ function CartSummary({
7618
7647
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item": true, children: [
7619
7648
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-cart-item-info": true, children: [
7620
7649
  /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-name": true, children: item.product.name }),
7621
- item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: getVariantDisplayName(item.variant) }),
7650
+ item.variant && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-cart-item-variant": true, children: getVariantDisplayName(item.variant, item.product.name) }),
7622
7651
  item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
7623
7652
  "+ ",
7624
7653
  item.addOnOptions.map((opt) => opt.name).join(", ")
package/dist/react.mjs CHANGED
@@ -6793,12 +6793,40 @@ function QuantitySelector({
6793
6793
  }
6794
6794
 
6795
6795
  // src/utils/variant.ts
6796
- function getVariantDisplayName(variant) {
6797
- if (variant.name) return variant.name;
6796
+ function stripProductPrefix(variantName, productName) {
6797
+ if (!variantName || !productName) return variantName || productName;
6798
+ const lower = variantName.toLowerCase().trim();
6799
+ if (lower === "default" || lower === "standard") return productName;
6800
+ if (lower.endsWith("-default") || lower.endsWith("-standard")) return productName;
6801
+ if (variantName.startsWith(productName)) {
6802
+ const rest = variantName.slice(productName.length);
6803
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
6804
+ if (match && match[1].length > 0) return match[1];
6805
+ }
6806
+ const lowerProduct = productName.toLowerCase().trim();
6807
+ if (lower.startsWith(lowerProduct)) {
6808
+ const rest = variantName.slice(productName.length);
6809
+ const match = rest.match(/^\s*[-–—]\s*(.*)/);
6810
+ if (match && match[1].length > 0) return match[1];
6811
+ }
6812
+ const lastDash = variantName.lastIndexOf("-");
6813
+ if (lastDash > 0 && lastDash < variantName.length - 1) {
6814
+ const prefix = variantName.slice(0, lastDash).trim();
6815
+ const suffix = variantName.slice(lastDash + 1).trim();
6816
+ if (suffix.length > 0 && prefix.length > suffix.length * 2) {
6817
+ return suffix;
6818
+ }
6819
+ }
6820
+ return variantName;
6821
+ }
6822
+ function getVariantDisplayName(variant, productName) {
6798
6823
  if (variant.display_attributes?.length) {
6799
6824
  return variant.display_attributes.map((a) => a.value_name).join(" / ");
6800
6825
  }
6801
- return variant.is_default ? "Default" : "Option";
6826
+ if (variant.name) {
6827
+ return productName ? stripProductPrefix(variant.name, productName) : variant.name;
6828
+ }
6829
+ return productName || (variant.is_default ? "Default" : "Option");
6802
6830
  }
6803
6831
  function VariantSelector({
6804
6832
  variants,
@@ -6806,6 +6834,7 @@ function VariantSelector({
6806
6834
  basePrice,
6807
6835
  selectedVariantId,
6808
6836
  onVariantChange,
6837
+ productName,
6809
6838
  className
6810
6839
  }) {
6811
6840
  const [axisSelections, setAxisSelections] = useState({});
@@ -6885,7 +6914,7 @@ function VariantSelector({
6885
6914
  "data-cimplify-variant-option": true,
6886
6915
  "data-selected": isSelected || void 0,
6887
6916
  children: [
6888
- /* @__PURE__ */ jsx("span", { "data-cimplify-variant-name": true, children: getVariantDisplayName(variant) }),
6917
+ /* @__PURE__ */ jsx("span", { "data-cimplify-variant-name": true, children: getVariantDisplayName(variant, productName) }),
6889
6918
  /* @__PURE__ */ jsxs("span", { "data-cimplify-variant-pricing": true, children: [
6890
6919
  adjustment !== 0 && /* @__PURE__ */ jsxs("span", { "data-cimplify-variant-adjustment": true, children: [
6891
6920
  adjustment > 0 ? "+" : "",
@@ -7278,7 +7307,7 @@ function BundleComponentCard({
7278
7307
  "data-cimplify-bundle-variant-option": true,
7279
7308
  "data-selected": isSelected || void 0,
7280
7309
  children: [
7281
- getVariantDisplayName(variant),
7310
+ getVariantDisplayName(variant, product.name),
7282
7311
  adjustment !== 0 && /* @__PURE__ */ jsxs("span", { "data-cimplify-bundle-variant-adjustment": true, children: [
7283
7312
  adjustment > 0 ? "+" : "",
7284
7313
  /* @__PURE__ */ jsx(Price, { amount: variant.price_adjustment })
@@ -7612,7 +7641,7 @@ function CartSummary({
7612
7641
  return /* @__PURE__ */ jsxs("div", { "data-cimplify-cart-item": true, children: [
7613
7642
  /* @__PURE__ */ jsxs("div", { "data-cimplify-cart-item-info": true, children: [
7614
7643
  /* @__PURE__ */ jsx("span", { "data-cimplify-cart-item-name": true, children: item.product.name }),
7615
- item.variant && /* @__PURE__ */ jsx("span", { "data-cimplify-cart-item-variant": true, children: getVariantDisplayName(item.variant) }),
7644
+ item.variant && /* @__PURE__ */ jsx("span", { "data-cimplify-cart-item-variant": true, children: getVariantDisplayName(item.variant, item.product.name) }),
7616
7645
  item.addOnOptions && item.addOnOptions.length > 0 && /* @__PURE__ */ jsxs("span", { "data-cimplify-cart-item-addons": true, children: [
7617
7646
  "+ ",
7618
7647
  item.addOnOptions.map((opt) => opt.name).join(", ")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",