@vectoriox/iox-ui 5.167.0 → 5.169.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.
@@ -1976,6 +1976,18 @@ function variantSlotOf(product, choice, quantity = 1) {
1976
1976
  const variant = options.length ? findVariant(options, views, pick) : views[0] ?? null;
1977
1977
  return variant ? { ...variant, productId: product._id, words: variantWords(variant.choice, options), quantity } : null;
1978
1978
  }
1979
+ function productListPrice(product) {
1980
+ if (!product || !productOptions(product).length)
1981
+ return null;
1982
+ const priced = productVariants(product).filter(v => v.enabled && v.price);
1983
+ const sellable = priced.filter(v => v.sellable);
1984
+ const pool = sellable.length ? sellable : priced;
1985
+ if (!pool.length)
1986
+ return null;
1987
+ const cheapest = pool.reduce((low, v) => (v.price.amount < low.price.amount ? v : low));
1988
+ const from = pool.some(v => v.price.amount !== cheapest.price.amount);
1989
+ return { price: cheapest.price, compareAt: from ? null : cheapest.compareAt, from };
1990
+ }
1979
1991
 
1980
1992
  /**
1981
1993
  * The quantity a buyer may ask for — the stepper on a product page and on every cart line (commerce plan §3i). Whole
@@ -2222,6 +2234,8 @@ var ShopWord;
2222
2234
  ShopWord["VatNote"] = "vatNote";
2223
2235
  ShopWord["CheckOut"] = "checkOut";
2224
2236
  ShopWord["KeepShopping"] = "keepShopping";
2237
+ /** A list card's price for a product whose options differ in price (vectoriox/iox-ui#142). */
2238
+ ShopWord["PriceFrom"] = "priceFrom";
2225
2239
  })(ShopWord || (ShopWord = {}));
2226
2240
  /** `{name}` / `{n}` / `{amount}` are filled by `shopWord`. */
2227
2241
  const SHOP_WORDS = Object.freeze({
@@ -2246,6 +2260,7 @@ const SHOP_WORDS = Object.freeze({
2246
2260
  [ShopWord.VatNote]: { en: 'Includes VAT. Delivery is chosen at checkout.', he: 'כולל מע״מ. המשלוח נבחר בקופה.' },
2247
2261
  [ShopWord.CheckOut]: { en: 'Check out', he: 'לקופה' },
2248
2262
  [ShopWord.KeepShopping]: { en: 'Keep shopping', he: 'המשך בקניות' },
2263
+ [ShopWord.PriceFrom]: { en: 'From {amount}', he: 'החל מ־{amount}' },
2249
2264
  });
2250
2265
  function shopWord(word, lang, fill = {}) {
2251
2266
  const primary = String(lang ?? '').toLowerCase().split(/[-_]/)[0];
@@ -2253,6 +2268,42 @@ function shopWord(word, lang, fill = {}) {
2253
2268
  const raw = primary === 'he' || primary === 'iw' ? label.he : label.en;
2254
2269
  return raw.replace(/\{(\w+)\}/g, (all, key) => (key in fill ? String(fill[key]) : all));
2255
2270
  }
2271
+ /** The stored price paths of a product a list binds (generation-core `SHOP_ROLES` `price` / `compareAt`). */
2272
+ var ProductPricePath;
2273
+ (function (ProductPricePath) {
2274
+ ProductPricePath["Price"] = "pricing.price";
2275
+ ProductPricePath["CompareAt"] = "pricing.compareat";
2276
+ })(ProductPricePath || (ProductPricePath = {}));
2277
+ /**
2278
+ * vectoriox/iox-ui#142 — a product's PRICE PATH read on a list card, for a product whose options carry the prices: the
2279
+ * `money` pipe asks it with the row the binding read and the path it read, so every list a studio already holds (bound
2280
+ * `pricing.price | money` to its row) shows "From ₪89.00" with no rebuild. `undefined` when it does not apply — not a
2281
+ * product with options, not a price path, no priced variant — and the pipe formats the stored value as before.
2282
+ * `currency` is used only when the product names none (the pipe's argument, else the studio's).
2283
+ */
2284
+ function listPriceField(row, path, locale, currency) {
2285
+ if (path !== ProductPricePath.Price && path !== ProductPricePath.CompareAt)
2286
+ return undefined;
2287
+ if (!row || typeof row !== 'object' || Array.isArray(row))
2288
+ return undefined;
2289
+ const product = row;
2290
+ if (!product.productVariants)
2291
+ return undefined;
2292
+ const fallback = String(currency ?? '').trim().toUpperCase();
2293
+ const listed = productListPrice(product.currency || !isCurrencyCode(fallback) ? product : { ...product, currency: fallback });
2294
+ if (!listed)
2295
+ return undefined;
2296
+ const lang = locale || DEFAULT_MONEY_LOCALE;
2297
+ try {
2298
+ if (path === ProductPricePath.CompareAt)
2299
+ return listed.compareAt ? formatMoney(listed.compareAt, lang) : '';
2300
+ const amount = formatMoney(listed.price, lang);
2301
+ return listed.from ? shopWord(ShopWord.PriceFrom, lang, { amount }) : amount;
2302
+ }
2303
+ catch {
2304
+ return undefined;
2305
+ }
2306
+ }
2256
2307
  // ── the sample a canvas shows when no product is bound (commerce board 10, "Studio Kadar") ────────────────────────
2257
2308
  /** Board 10's tall speckled vase: Glaze (Sand · Ash · Charcoal — Charcoal sold out) × Size (24 · 32 · 40 cm — 40 sold
2258
2309
  * out), ₪240 against ₪280. Major units, as the storefront serves them. */
@@ -2989,5 +3040,5 @@ const REMINDER_SUBJECT_WORDS = Object.freeze({
2989
3040
  * Generated bundle index. Do not edit.
2990
3041
  */
2991
3042
 
2992
- export { ABANDONED_AFTER_MS, Availability, BuyerPaymentStage, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_FRAME_PARAM, ORDER_FRAME_VALUE, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PAYMENT_RETURNED, PAYMENT_VERDICT_LABELS, PaymentAttemptStatus, PaymentChannel, PaymentField, PaymentMethodKind, PaymentMismatch, PaymentProvider, PaymentResultStatus, PaymentVerdictKind, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteOrderAction, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, buyerMayPay, buyerPaymentStage, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isOrderFrameReturn, isPaymentMethodKind, isPaymentReturnedMessage, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderFrameReturnHref, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodConnected, paymentMethodProblems, paymentMethodReady, paymentReturnedMessage, paymentVerdict, percentOf, priceCart, productCurrency, productInScope, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationDue, reservationExpiresAt, reusableAttempt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteOrderActionPath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
3043
+ export { ABANDONED_AFTER_MS, Availability, BuyerPaymentStage, CART_COOKIE_PREFIX, CART_ISSUE_LABELS, CART_TRANSPORT_ERROR_LABELS, CHECKOUT_FORM_STEPS, CHECKOUT_GATE_RULES, CHECKOUT_PATH, CHECKOUT_STEPS, CHECKOUT_STEP_LABELS, CHECKOUT_WORDS, COUPON_CODE_MAX, COUPON_CODE_MIN, COUPON_REFUSAL_LABELS, CURRENCY_CODES, CURRENCY_EXPONENTS, CartIssueCode, CartTransportError, CartTransportErrorCode, CheckoutAskedField, CheckoutFieldMode, CheckoutGateArea, CheckoutGateCode, CheckoutSlot, CheckoutStep, CheckoutWord, CommerceLanguage, CouponKind, CouponProblem, CouponRefusal, CurrencyCode, DEFAULT_JOURNEY_DAYS, DEFAULT_MONEY_LOCALE, DEFAULT_REMINDER_SETTINGS, DEFAULT_VARIANT_NAME, DeliveryFit, FINAL_ORDER_STATES, FUNNEL_STAGES, FunnelStage, JOURNEY_PERIODS_DAYS, JourneyEventKind, LegalPage, MAX_CART_AMOUNT, MAX_CART_LINES, MAX_LINE_QUANTITY, MAX_VAT_PERCENT, MIN_LINE_QUANTITY, MoneyError, MoneyErrorCode, NO_CART_TRANSPORT, ORDER_FRAME_PARAM, ORDER_FRAME_VALUE, ORDER_PATH, ORDER_STATE_LABELS, ORDER_STOCK_HOLD, ORDER_TRANSITIONS, OrderActor, OrderEvent, OrderRefusal, OrderSnapshotRefusal, OrderState, PAYMENT_FIELD_LABELS, PAYMENT_METHODS, PAYMENT_RETURNED, PAYMENT_VERDICT_LABELS, PaymentAttemptStatus, PaymentChannel, PaymentField, PaymentMethodKind, PaymentMismatch, PaymentProvider, PaymentResultStatus, PaymentVerdictKind, ProductPricePath, QuantityStep, RECOVERY_PATH, RECOVERY_WORDS, REMINDER_LATE_MS, REMINDER_SEQUENCE, REMINDER_STEPS, REMINDER_SUBJECT_WORDS, REMINDER_WORDS_MAX, RecoveryWord, ReminderOutcome, ReminderSkip, ReminderStep, ReminderStop, SAMPLE_CART_LINE, SAMPLE_PRODUCT, SAMPLE_STUDIO, SAMPLE_SWATCHES, SHIPPING_KINDS, SHOP_SLOTS, SHOP_WORDS, SITE_REFUSALS, STOCK_EFFECTS, STOCK_RESERVATION_MINUTES, STOREFRONT_COMPUTED_FIELDS, STOREFRONT_FIELDS, ShippingField, ShippingMethodKind, ShopSlot, ShopWord, SiteCommerceRoute, SiteOrderAction, SiteRefusalCode, StockEffect, StockHold, StorefrontCollection, UNSUBSCRIBE_PATH, VARIANT_NAME_SEPARATOR, VAT_PERCENT_MAX_DECIMALS, addMoney, addressLine, availableShippingMethods, biggestDrop, buyerMayPay, buyerPaymentStage, canBuy, canStep, cartCookieName, cartEndpointPath, cartIssueWords, cartLineId, cartOf, cartTransportErrorFor, cartViewOf, catalogKey, checkoutGate, checkoutHref, checkoutWord, chooseValue, clampQuantity, commerceLanguage, couponDiscount, couponOfferWords, couponProblems, couponRefusalWords, currencyExponent, currentCheckoutStep, defaultChoice, emptyCartView, fieldAsked, fieldRequired, findVariant, formatMoney, formatMoneyValue, freeShippingRemaining, funnelOf, furthestStep, includedVat, isAbandoned, isCouponCode, isCurrencyCode, isMoney, isOrderFrameReturn, isPaymentMethodKind, isPaymentReturnedMessage, isShippingMethodKind, isStorefrontField, isStorefrontProduct, isVatPercent, labelIn, listPriceField, looksLikeEmail, looksLikePhone, majorToMinor, marketingAllowed, maskEmail, mergeCarts, migrateMajorPrice, minorToMajor, money, nextOrderState, nextReminder, normalizeCouponCode, openingOrderState, optionValueStates, orderFrameReturnHref, orderHref, orderSnapshot, paymentChannelOf, paymentInstructions, paymentMethodConnected, paymentMethodProblems, paymentMethodReady, paymentReturnedMessage, paymentVerdict, percentOf, priceCart, productCurrency, productInScope, productListPrice, productOptions, productVariants, quantityBounds, quoteShipping, recoveryHref, recoveryWord, reminderNumber, reminderSettingsOf, reservationDue, reservationExpiresAt, reusableAttempt, sellableQuantity, shippingMethodProblems, shippingMethodReady, shippingNeedsAddress, shopWord, simulatedCartTransport, siteCartView, siteCommercePath, siteOrderActionPath, siteRefusalsOf, stepQuantity, stockEffect, stoppedAt, storefrontBindPaths, storefrontCatalog, storefrontMoney, subtractMoney, timesMoney, unsubscribeHref, usablePaymentMethods, variantChoiceOf, variantSlotOf, variantWords };
2993
3044
  //# sourceMappingURL=vectoriox-iox-ui-commerce-core.mjs.map