@lime-bundles/react 4.1.0 → 6.0.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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CartLineInput, BuyerResolver, ProductVariant, ParsedBundle, WidgetConfig } from '@lime-bundles/core';
3
- export { ABVariantOverrides, BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig, DiscountConfig, FixedBundleData, FixedBundlePricing, HeaderConfig, ImageTransform, LayoutConfig, MixMatchBundleData, ParsedBundle, PopularBadgeConfig, PricingConfig, PricingRow, Product, ProductListConfig, ProductVariant, SHOP_CUSTOM_CSS_QUERY, SavingsBarConfig, StorefrontApiError, ThumbnailRatio, VolumeBundleData, VolumeTier, WIDGET_CONFIG_DEFAULTS, WidgetConfig, applyABVariantB, applyWidgetConfigVars, calculateDiscount, calculateTierSavings, computeBundleSaleCents, computeFixedPricing, createStorefrontClient, fetchBundlesForProduct, formatCents, formatCountdown, formatMoney, formatUnitPrice, getABTestAssignment, getActiveTier, hasConsent, injectCustomCss, mergeWidgetConfig, observeImpression, parseCents, parseMetaobjectBundle, parseMetaobjectBundleStrict, percentageDiscountUnit, reportAddToCart, reportImpression, sanitizeCustomCss, setConsent, thumbnailRatioVars, transformImageUrl, validateQuantity } from '@lime-bundles/core';
2
+ import { CartLineInput, BuyerResolver, ProductVariant, ParsedBundle, OutOfStockBehavior, WidgetConfig } from '@lime-bundles/core';
3
+ export { BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BogoBundleData, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig, DEFAULT_OUT_OF_STOCK_BEHAVIOR, DiscountConfig, FixedBundleData, FixedBundlePricing, HeaderConfig, ImageTransform, LayoutConfig, MixMatchBundleData, MultiStepBundleData, OutOfStockBehavior, ParsedBundle, ParsedMultiStep, PopularBadgeConfig, PricingConfig, PricingRow, Product, ProductListConfig, ProductVariant, SHOP_SETTINGS_QUERY, SavingsBarConfig, StorefrontApiError, ThumbnailRatio, VolumeBundleData, VolumeTier, WIDGET_CONFIG_DEFAULTS, WidgetConfig, applyWidgetConfigVars, calculateDiscount, calculateTierSavings, computeBundleSaleCents, computeFixedPricing, createStorefrontClient, fetchBundlesForProduct, formatCents, formatCountdown, formatMoney, formatUnitPrice, getActiveTier, injectCustomCss, mergeWidgetConfig, observeImpression, parseCents, parseMetaobjectBundle, parseMetaobjectBundleStrict, parseOutOfStockBehavior, percentageDiscountUnit, productsForStep, reportAddToCart, reportImpression, sanitizeCustomCss, stepHeadroom, thumbnailRatioVars, transformImageUrl, validateQuantity } from '@lime-bundles/core';
4
4
 
5
5
  /**
6
6
  * Shared props for bundle components.
@@ -59,6 +59,10 @@ declare function MixMatchBundle(props: BundleComponentProps): react_jsx_runtime.
59
59
 
60
60
  declare function VolumeBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
61
61
 
62
+ declare function BogoBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
63
+
64
+ declare function MultiStepBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
65
+
62
66
  interface VariantDropdownOption {
63
67
  value: string;
64
68
  label: string;
@@ -158,12 +162,58 @@ interface FetchBundleDataOptions {
158
162
  }
159
163
  declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
160
164
 
161
- interface FetchShopCustomCssOptions {
165
+ /**
166
+ * Best-effort fetch for the shop's `$app` settings metafields.
167
+ *
168
+ * Returns the raw custom CSS (still needs sanitization before injection — see
169
+ * `injectCustomCss` from core) and the shop-wide out-of-stock behaviour.
170
+ *
171
+ * **Per-shop in-memory cache.** Multiple `<FixedBundle>` / `<VolumeBundle>` /
172
+ * `<MixMatchBundle>` components on the same page share one network request —
173
+ * the first caller fetches, concurrent callers await the same promise, and
174
+ * resolved values are cached so subsequent mounts return instantly. Failures
175
+ * are NOT cached so the next caller retries.
176
+ *
177
+ * The cache lives for the life of the JS module (typically one page load).
178
+ * Merchants updating settings see changes on the next page load. The cache is
179
+ * exposed as `__clearShopSettingsCache` for test use only.
180
+ *
181
+ * Both metafields ride in one query. The out-of-stock behaviour must be in hand
182
+ * *before* a bundle renders — a component can't retroactively un-render itself —
183
+ * so components await this alongside their bundle data rather than after it.
184
+ */
185
+
186
+ interface FetchShopSettingsOptions {
162
187
  shopDomain: string;
163
188
  storefrontAccessToken: string;
164
189
  buyerIp?: string;
165
190
  signal?: AbortSignal;
166
191
  }
192
+ interface ShopSettings {
193
+ /** Raw, unsanitized merchant CSS. Null when unset. */
194
+ customCss: string | null;
195
+ /** Shop-wide handling of products the store can't sell. */
196
+ outOfStockBehavior: OutOfStockBehavior;
197
+ }
198
+ declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
199
+ /**
200
+ * Same fetch, never rejects. Components that need the out-of-stock behaviour
201
+ * to render at all use this — a failed settings request must not stop a bundle
202
+ * from appearing.
203
+ */
204
+ declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
205
+
206
+ interface UseShopSettingsOptions {
207
+ shopDomain: string;
208
+ storefrontAccessToken: string;
209
+ }
210
+ interface UseShopSettingsResult {
211
+ outOfStockBehavior: OutOfStockBehavior;
212
+ }
213
+ declare function useShopSettings(options: UseShopSettingsOptions): UseShopSettingsResult;
214
+
215
+ type FetchShopCustomCssOptions = FetchShopSettingsOptions;
216
+ /** @deprecated Use `fetchShopSettings().customCss`. */
167
217
  declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
168
218
 
169
219
  interface UseBundleDataOptions {
@@ -222,8 +272,6 @@ interface UseAnalyticsOptions {
222
272
  bundleGid: string;
223
273
  bundleType: string;
224
274
  enabled?: boolean;
225
- abTestId?: string;
226
- abVariant?: string;
227
275
  }
228
276
  declare function useAnalytics(options: UseAnalyticsOptions): {
229
277
  elementRef: (el: HTMLElement | null) => void;
@@ -237,4 +285,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
237
285
 
238
286
  declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
239
287
 
240
- export { type BundleComponentProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, FixedBundle, MixMatchBundle, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type UseVariantSelectionOptions, type UseVariantSelectionResult, VariantDropdown, type VariantDropdownOption, type VariantDropdownProps, VolumeBundle, fetchBundleData, fetchShopCustomCss, useAnalytics, useBundleData, useBundlesForProduct, useVariantSelection, useWidgetConfigVars };
288
+ export { BogoBundle, type BundleComponentProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, type FetchShopSettingsOptions, FixedBundle, MixMatchBundle, MultiStepBundle, type ShopSettings, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type UseShopSettingsOptions, type UseShopSettingsResult, type UseVariantSelectionOptions, type UseVariantSelectionResult, VariantDropdown, type VariantDropdownOption, type VariantDropdownProps, VolumeBundle, fetchBundleData, fetchShopCustomCss, fetchShopSettings, fetchShopSettingsOrDefault, useAnalytics, useBundleData, useBundlesForProduct, useShopSettings, useVariantSelection, useWidgetConfigVars };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CartLineInput, BuyerResolver, ProductVariant, ParsedBundle, WidgetConfig } from '@lime-bundles/core';
3
- export { ABVariantOverrides, BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig, DiscountConfig, FixedBundleData, FixedBundlePricing, HeaderConfig, ImageTransform, LayoutConfig, MixMatchBundleData, ParsedBundle, PopularBadgeConfig, PricingConfig, PricingRow, Product, ProductListConfig, ProductVariant, SHOP_CUSTOM_CSS_QUERY, SavingsBarConfig, StorefrontApiError, ThumbnailRatio, VolumeBundleData, VolumeTier, WIDGET_CONFIG_DEFAULTS, WidgetConfig, applyABVariantB, applyWidgetConfigVars, calculateDiscount, calculateTierSavings, computeBundleSaleCents, computeFixedPricing, createStorefrontClient, fetchBundlesForProduct, formatCents, formatCountdown, formatMoney, formatUnitPrice, getABTestAssignment, getActiveTier, hasConsent, injectCustomCss, mergeWidgetConfig, observeImpression, parseCents, parseMetaobjectBundle, parseMetaobjectBundleStrict, percentageDiscountUnit, reportAddToCart, reportImpression, sanitizeCustomCss, setConsent, thumbnailRatioVars, transformImageUrl, validateQuantity } from '@lime-bundles/core';
2
+ import { CartLineInput, BuyerResolver, ProductVariant, ParsedBundle, OutOfStockBehavior, WidgetConfig } from '@lime-bundles/core';
3
+ export { BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BogoBundleData, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig, DEFAULT_OUT_OF_STOCK_BEHAVIOR, DiscountConfig, FixedBundleData, FixedBundlePricing, HeaderConfig, ImageTransform, LayoutConfig, MixMatchBundleData, MultiStepBundleData, OutOfStockBehavior, ParsedBundle, ParsedMultiStep, PopularBadgeConfig, PricingConfig, PricingRow, Product, ProductListConfig, ProductVariant, SHOP_SETTINGS_QUERY, SavingsBarConfig, StorefrontApiError, ThumbnailRatio, VolumeBundleData, VolumeTier, WIDGET_CONFIG_DEFAULTS, WidgetConfig, applyWidgetConfigVars, calculateDiscount, calculateTierSavings, computeBundleSaleCents, computeFixedPricing, createStorefrontClient, fetchBundlesForProduct, formatCents, formatCountdown, formatMoney, formatUnitPrice, getActiveTier, injectCustomCss, mergeWidgetConfig, observeImpression, parseCents, parseMetaobjectBundle, parseMetaobjectBundleStrict, parseOutOfStockBehavior, percentageDiscountUnit, productsForStep, reportAddToCart, reportImpression, sanitizeCustomCss, stepHeadroom, thumbnailRatioVars, transformImageUrl, validateQuantity } from '@lime-bundles/core';
4
4
 
5
5
  /**
6
6
  * Shared props for bundle components.
@@ -59,6 +59,10 @@ declare function MixMatchBundle(props: BundleComponentProps): react_jsx_runtime.
59
59
 
60
60
  declare function VolumeBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
61
61
 
62
+ declare function BogoBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
63
+
64
+ declare function MultiStepBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
65
+
62
66
  interface VariantDropdownOption {
63
67
  value: string;
64
68
  label: string;
@@ -158,12 +162,58 @@ interface FetchBundleDataOptions {
158
162
  }
159
163
  declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
160
164
 
161
- interface FetchShopCustomCssOptions {
165
+ /**
166
+ * Best-effort fetch for the shop's `$app` settings metafields.
167
+ *
168
+ * Returns the raw custom CSS (still needs sanitization before injection — see
169
+ * `injectCustomCss` from core) and the shop-wide out-of-stock behaviour.
170
+ *
171
+ * **Per-shop in-memory cache.** Multiple `<FixedBundle>` / `<VolumeBundle>` /
172
+ * `<MixMatchBundle>` components on the same page share one network request —
173
+ * the first caller fetches, concurrent callers await the same promise, and
174
+ * resolved values are cached so subsequent mounts return instantly. Failures
175
+ * are NOT cached so the next caller retries.
176
+ *
177
+ * The cache lives for the life of the JS module (typically one page load).
178
+ * Merchants updating settings see changes on the next page load. The cache is
179
+ * exposed as `__clearShopSettingsCache` for test use only.
180
+ *
181
+ * Both metafields ride in one query. The out-of-stock behaviour must be in hand
182
+ * *before* a bundle renders — a component can't retroactively un-render itself —
183
+ * so components await this alongside their bundle data rather than after it.
184
+ */
185
+
186
+ interface FetchShopSettingsOptions {
162
187
  shopDomain: string;
163
188
  storefrontAccessToken: string;
164
189
  buyerIp?: string;
165
190
  signal?: AbortSignal;
166
191
  }
192
+ interface ShopSettings {
193
+ /** Raw, unsanitized merchant CSS. Null when unset. */
194
+ customCss: string | null;
195
+ /** Shop-wide handling of products the store can't sell. */
196
+ outOfStockBehavior: OutOfStockBehavior;
197
+ }
198
+ declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
199
+ /**
200
+ * Same fetch, never rejects. Components that need the out-of-stock behaviour
201
+ * to render at all use this — a failed settings request must not stop a bundle
202
+ * from appearing.
203
+ */
204
+ declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
205
+
206
+ interface UseShopSettingsOptions {
207
+ shopDomain: string;
208
+ storefrontAccessToken: string;
209
+ }
210
+ interface UseShopSettingsResult {
211
+ outOfStockBehavior: OutOfStockBehavior;
212
+ }
213
+ declare function useShopSettings(options: UseShopSettingsOptions): UseShopSettingsResult;
214
+
215
+ type FetchShopCustomCssOptions = FetchShopSettingsOptions;
216
+ /** @deprecated Use `fetchShopSettings().customCss`. */
167
217
  declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
168
218
 
169
219
  interface UseBundleDataOptions {
@@ -222,8 +272,6 @@ interface UseAnalyticsOptions {
222
272
  bundleGid: string;
223
273
  bundleType: string;
224
274
  enabled?: boolean;
225
- abTestId?: string;
226
- abVariant?: string;
227
275
  }
228
276
  declare function useAnalytics(options: UseAnalyticsOptions): {
229
277
  elementRef: (el: HTMLElement | null) => void;
@@ -237,4 +285,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
237
285
 
238
286
  declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
239
287
 
240
- export { type BundleComponentProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, FixedBundle, MixMatchBundle, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type UseVariantSelectionOptions, type UseVariantSelectionResult, VariantDropdown, type VariantDropdownOption, type VariantDropdownProps, VolumeBundle, fetchBundleData, fetchShopCustomCss, useAnalytics, useBundleData, useBundlesForProduct, useVariantSelection, useWidgetConfigVars };
288
+ export { BogoBundle, type BundleComponentProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, type FetchShopSettingsOptions, FixedBundle, MixMatchBundle, MultiStepBundle, type ShopSettings, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type UseShopSettingsOptions, type UseShopSettingsResult, type UseVariantSelectionOptions, type UseVariantSelectionResult, VariantDropdown, type VariantDropdownOption, type VariantDropdownProps, VolumeBundle, fetchBundleData, fetchShopCustomCss, fetchShopSettings, fetchShopSettingsOrDefault, useAnalytics, useBundleData, useBundlesForProduct, useShopSettings, useVariantSelection, useWidgetConfigVars };