@lime-bundles/react 6.2.0 → 7.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.cjs +304 -303
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -41
- package/dist/index.d.ts +15 -41
- package/dist/index.js +138 -140
- package/dist/index.js.map +1 -1
- package/dist/styles.css +35 -7
- package/package.json +2 -2
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, WidgetConfig, ProductVariant, ParsedBundle
|
|
3
|
-
export { BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BogoBundleData, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig,
|
|
2
|
+
import { CartLineInput, BuyerResolver, WidgetConfig, ProductVariant, ParsedBundle } from '@lime-bundles/core';
|
|
3
|
+
export { BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BogoBundleData, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig, DiscountConfig, FixedBundleData, FixedBundlePricing, HeaderConfig, ImageTransform, LayoutConfig, MixMatchBundleData, MultiStepBundleData, 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, percentageDiscountUnit, productsForStep, reportAddToCart, reportImpression, sanitizeCustomCss, stepHeadroom, thumbnailRatioVars, transformImageUrl, validateQuantity } from '@lime-bundles/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared props for bundle components.
|
|
@@ -103,8 +103,9 @@ interface UseVariantSelectionOptions {
|
|
|
103
103
|
/** Positional option names for the product, e.g. `['Size', 'Color']`. */
|
|
104
104
|
optionNames: ReadonlyArray<string>;
|
|
105
105
|
/**
|
|
106
|
-
* Optional initial variant. Defaults to the first
|
|
107
|
-
* the
|
|
106
|
+
* Optional initial variant. Defaults to the first variant that can cover
|
|
107
|
+
* the slot (per `requiredQtyFor` when supplied), then the first available
|
|
108
|
+
* variant, then the first variant.
|
|
108
109
|
*/
|
|
109
110
|
initialVariant?: ProductVariant | null;
|
|
110
111
|
/**
|
|
@@ -114,6 +115,12 @@ interface UseVariantSelectionOptions {
|
|
|
114
115
|
* order is variant-discovery order (which may not match Shopify admin).
|
|
115
116
|
*/
|
|
116
117
|
optionValuesByPosition?: ReadonlyArray<ReadonlyArray<string>>;
|
|
118
|
+
/**
|
|
119
|
+
* Per-variant required quantity for the bundle slot this picker fills.
|
|
120
|
+
* When provided, dropdown availability is quantity-aware (a variant short
|
|
121
|
+
* of the bundle's needs greys out) instead of plain `availableForSale`.
|
|
122
|
+
*/
|
|
123
|
+
requiredQtyFor?: (variantId: string) => number;
|
|
117
124
|
}
|
|
118
125
|
interface UseVariantSelectionResult {
|
|
119
126
|
/** Positional option values matching `optionNames`. */
|
|
@@ -128,7 +135,7 @@ interface UseVariantSelectionResult {
|
|
|
128
135
|
disabled: boolean;
|
|
129
136
|
}>;
|
|
130
137
|
}
|
|
131
|
-
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
138
|
+
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, requiredQtyFor, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
132
139
|
|
|
133
140
|
/**
|
|
134
141
|
* Framework-agnostic async fetcher for bundle data.
|
|
@@ -181,27 +188,6 @@ interface FetchBundleDataOptions {
|
|
|
181
188
|
}
|
|
182
189
|
declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
|
|
183
190
|
|
|
184
|
-
/**
|
|
185
|
-
* Best-effort fetch for the shop's `$app` settings metafields.
|
|
186
|
-
*
|
|
187
|
-
* Returns the raw custom CSS (still needs sanitization before injection — see
|
|
188
|
-
* `injectCustomCss` from core) and the shop-wide out-of-stock behaviour.
|
|
189
|
-
*
|
|
190
|
-
* **Per-shop in-memory cache.** Multiple `<FixedBundle>` / `<VolumeBundle>` /
|
|
191
|
-
* `<MixMatchBundle>` components on the same page share one network request —
|
|
192
|
-
* the first caller fetches, concurrent callers await the same promise, and
|
|
193
|
-
* resolved values are cached so subsequent mounts return instantly. Failures
|
|
194
|
-
* are NOT cached so the next caller retries.
|
|
195
|
-
*
|
|
196
|
-
* The cache lives for the life of the JS module (typically one page load).
|
|
197
|
-
* Merchants updating settings see changes on the next page load. The cache is
|
|
198
|
-
* exposed as `__clearShopSettingsCache` for test use only.
|
|
199
|
-
*
|
|
200
|
-
* Both metafields ride in one query. The out-of-stock behaviour must be in hand
|
|
201
|
-
* *before* a bundle renders — a component can't retroactively un-render itself —
|
|
202
|
-
* so components await this alongside their bundle data rather than after it.
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
191
|
interface FetchShopSettingsOptions {
|
|
206
192
|
shopDomain: string;
|
|
207
193
|
storefrontAccessToken: string;
|
|
@@ -211,26 +197,14 @@ interface FetchShopSettingsOptions {
|
|
|
211
197
|
interface ShopSettings {
|
|
212
198
|
/** Raw, unsanitized merchant CSS. Null when unset. */
|
|
213
199
|
customCss: string | null;
|
|
214
|
-
/** Shop-wide handling of products the store can't sell. */
|
|
215
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
216
200
|
}
|
|
217
201
|
declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
218
202
|
/**
|
|
219
|
-
* Same fetch, never rejects
|
|
220
|
-
*
|
|
221
|
-
* from appearing.
|
|
203
|
+
* Same fetch, never rejects — a failed settings request must not stop a
|
|
204
|
+
* bundle from appearing.
|
|
222
205
|
*/
|
|
223
206
|
declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
224
207
|
|
|
225
|
-
interface UseShopSettingsOptions {
|
|
226
|
-
shopDomain: string;
|
|
227
|
-
storefrontAccessToken: string;
|
|
228
|
-
}
|
|
229
|
-
interface UseShopSettingsResult {
|
|
230
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
231
|
-
}
|
|
232
|
-
declare function useShopSettings(options: UseShopSettingsOptions): UseShopSettingsResult;
|
|
233
|
-
|
|
234
208
|
type FetchShopCustomCssOptions = FetchShopSettingsOptions;
|
|
235
209
|
/** @deprecated Use `fetchShopSettings().customCss`. */
|
|
236
210
|
declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
|
|
@@ -304,4 +278,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
|
|
|
304
278
|
|
|
305
279
|
declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
|
|
306
280
|
|
|
307
|
-
export { BogoBundle, type BundleComponentProps, BundleCountdown, type BundleCountdownProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, type FetchShopSettingsOptions, FixedBundle, MixMatchBundle, type MixMatchBundleProps, MultiStepBundle, type ShopSettings, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type
|
|
281
|
+
export { BogoBundle, type BundleComponentProps, BundleCountdown, type BundleCountdownProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, type FetchShopSettingsOptions, FixedBundle, MixMatchBundle, type MixMatchBundleProps, MultiStepBundle, type ShopSettings, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type UseVariantSelectionOptions, type UseVariantSelectionResult, VariantDropdown, type VariantDropdownOption, type VariantDropdownProps, VolumeBundle, fetchBundleData, fetchShopCustomCss, fetchShopSettings, fetchShopSettingsOrDefault, useAnalytics, useBundleData, useBundlesForProduct, 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, WidgetConfig, ProductVariant, ParsedBundle
|
|
3
|
-
export { BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BogoBundleData, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig,
|
|
2
|
+
import { CartLineInput, BuyerResolver, WidgetConfig, ProductVariant, ParsedBundle } from '@lime-bundles/core';
|
|
3
|
+
export { BUNDLES_FOR_PRODUCT_QUERY, BUNDLE_METAOBJECT_QUERY, BogoBundleData, BundleParseError, BundleType, CartLineInput, CountdownConfig, CtaConfig, DiscountConfig, FixedBundleData, FixedBundlePricing, HeaderConfig, ImageTransform, LayoutConfig, MixMatchBundleData, MultiStepBundleData, 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, percentageDiscountUnit, productsForStep, reportAddToCart, reportImpression, sanitizeCustomCss, stepHeadroom, thumbnailRatioVars, transformImageUrl, validateQuantity } from '@lime-bundles/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared props for bundle components.
|
|
@@ -103,8 +103,9 @@ interface UseVariantSelectionOptions {
|
|
|
103
103
|
/** Positional option names for the product, e.g. `['Size', 'Color']`. */
|
|
104
104
|
optionNames: ReadonlyArray<string>;
|
|
105
105
|
/**
|
|
106
|
-
* Optional initial variant. Defaults to the first
|
|
107
|
-
* the
|
|
106
|
+
* Optional initial variant. Defaults to the first variant that can cover
|
|
107
|
+
* the slot (per `requiredQtyFor` when supplied), then the first available
|
|
108
|
+
* variant, then the first variant.
|
|
108
109
|
*/
|
|
109
110
|
initialVariant?: ProductVariant | null;
|
|
110
111
|
/**
|
|
@@ -114,6 +115,12 @@ interface UseVariantSelectionOptions {
|
|
|
114
115
|
* order is variant-discovery order (which may not match Shopify admin).
|
|
115
116
|
*/
|
|
116
117
|
optionValuesByPosition?: ReadonlyArray<ReadonlyArray<string>>;
|
|
118
|
+
/**
|
|
119
|
+
* Per-variant required quantity for the bundle slot this picker fills.
|
|
120
|
+
* When provided, dropdown availability is quantity-aware (a variant short
|
|
121
|
+
* of the bundle's needs greys out) instead of plain `availableForSale`.
|
|
122
|
+
*/
|
|
123
|
+
requiredQtyFor?: (variantId: string) => number;
|
|
117
124
|
}
|
|
118
125
|
interface UseVariantSelectionResult {
|
|
119
126
|
/** Positional option values matching `optionNames`. */
|
|
@@ -128,7 +135,7 @@ interface UseVariantSelectionResult {
|
|
|
128
135
|
disabled: boolean;
|
|
129
136
|
}>;
|
|
130
137
|
}
|
|
131
|
-
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
138
|
+
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, requiredQtyFor, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
132
139
|
|
|
133
140
|
/**
|
|
134
141
|
* Framework-agnostic async fetcher for bundle data.
|
|
@@ -181,27 +188,6 @@ interface FetchBundleDataOptions {
|
|
|
181
188
|
}
|
|
182
189
|
declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
|
|
183
190
|
|
|
184
|
-
/**
|
|
185
|
-
* Best-effort fetch for the shop's `$app` settings metafields.
|
|
186
|
-
*
|
|
187
|
-
* Returns the raw custom CSS (still needs sanitization before injection — see
|
|
188
|
-
* `injectCustomCss` from core) and the shop-wide out-of-stock behaviour.
|
|
189
|
-
*
|
|
190
|
-
* **Per-shop in-memory cache.** Multiple `<FixedBundle>` / `<VolumeBundle>` /
|
|
191
|
-
* `<MixMatchBundle>` components on the same page share one network request —
|
|
192
|
-
* the first caller fetches, concurrent callers await the same promise, and
|
|
193
|
-
* resolved values are cached so subsequent mounts return instantly. Failures
|
|
194
|
-
* are NOT cached so the next caller retries.
|
|
195
|
-
*
|
|
196
|
-
* The cache lives for the life of the JS module (typically one page load).
|
|
197
|
-
* Merchants updating settings see changes on the next page load. The cache is
|
|
198
|
-
* exposed as `__clearShopSettingsCache` for test use only.
|
|
199
|
-
*
|
|
200
|
-
* Both metafields ride in one query. The out-of-stock behaviour must be in hand
|
|
201
|
-
* *before* a bundle renders — a component can't retroactively un-render itself —
|
|
202
|
-
* so components await this alongside their bundle data rather than after it.
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
191
|
interface FetchShopSettingsOptions {
|
|
206
192
|
shopDomain: string;
|
|
207
193
|
storefrontAccessToken: string;
|
|
@@ -211,26 +197,14 @@ interface FetchShopSettingsOptions {
|
|
|
211
197
|
interface ShopSettings {
|
|
212
198
|
/** Raw, unsanitized merchant CSS. Null when unset. */
|
|
213
199
|
customCss: string | null;
|
|
214
|
-
/** Shop-wide handling of products the store can't sell. */
|
|
215
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
216
200
|
}
|
|
217
201
|
declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
218
202
|
/**
|
|
219
|
-
* Same fetch, never rejects
|
|
220
|
-
*
|
|
221
|
-
* from appearing.
|
|
203
|
+
* Same fetch, never rejects — a failed settings request must not stop a
|
|
204
|
+
* bundle from appearing.
|
|
222
205
|
*/
|
|
223
206
|
declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
224
207
|
|
|
225
|
-
interface UseShopSettingsOptions {
|
|
226
|
-
shopDomain: string;
|
|
227
|
-
storefrontAccessToken: string;
|
|
228
|
-
}
|
|
229
|
-
interface UseShopSettingsResult {
|
|
230
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
231
|
-
}
|
|
232
|
-
declare function useShopSettings(options: UseShopSettingsOptions): UseShopSettingsResult;
|
|
233
|
-
|
|
234
208
|
type FetchShopCustomCssOptions = FetchShopSettingsOptions;
|
|
235
209
|
/** @deprecated Use `fetchShopSettings().customCss`. */
|
|
236
210
|
declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
|
|
@@ -304,4 +278,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
|
|
|
304
278
|
|
|
305
279
|
declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
|
|
306
280
|
|
|
307
|
-
export { BogoBundle, type BundleComponentProps, BundleCountdown, type BundleCountdownProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, type FetchShopSettingsOptions, FixedBundle, MixMatchBundle, type MixMatchBundleProps, MultiStepBundle, type ShopSettings, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type
|
|
281
|
+
export { BogoBundle, type BundleComponentProps, BundleCountdown, type BundleCountdownProps, type FetchBundleDataOptions, type FetchShopCustomCssOptions, type FetchShopSettingsOptions, FixedBundle, MixMatchBundle, type MixMatchBundleProps, MultiStepBundle, type ShopSettings, type UseBundleDataOptions, type UseBundleDataResult, type UseBundlesForProductOptions, type UseBundlesForProductResult, type UseVariantSelectionOptions, type UseVariantSelectionResult, VariantDropdown, type VariantDropdownOption, type VariantDropdownProps, VolumeBundle, fetchBundleData, fetchShopCustomCss, fetchShopSettings, fetchShopSettingsOrDefault, useAnalytics, useBundleData, useBundlesForProduct, useVariantSelection, useWidgetConfigVars };
|