@lime-bundles/react 6.2.0 → 7.1.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/README.md +1 -0
- package/dist/index.cjs +307 -305
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -41
- package/dist/index.d.ts +23 -41
- package/dist/index.js +142 -142
- 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.
|
|
@@ -51,6 +51,14 @@ interface BundleComponentProps {
|
|
|
51
51
|
* `marketIds` doesn't include this market.
|
|
52
52
|
*/
|
|
53
53
|
marketId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The product page this component is rendered on — full GID
|
|
56
|
+
* (`gid://shopify/Product/123`) or bare numeric id. Multi-product
|
|
57
|
+
* renderers (`<VolumeBundle>`) price and sell this product; without it
|
|
58
|
+
* they fall back to the bundle's first product, so any bundle spanning
|
|
59
|
+
* more than one product should pass it.
|
|
60
|
+
*/
|
|
61
|
+
productId?: string;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
declare function FixedBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
@@ -103,8 +111,9 @@ interface UseVariantSelectionOptions {
|
|
|
103
111
|
/** Positional option names for the product, e.g. `['Size', 'Color']`. */
|
|
104
112
|
optionNames: ReadonlyArray<string>;
|
|
105
113
|
/**
|
|
106
|
-
* Optional initial variant. Defaults to the first
|
|
107
|
-
* the
|
|
114
|
+
* Optional initial variant. Defaults to the first variant that can cover
|
|
115
|
+
* the slot (per `requiredQtyFor` when supplied), then the first available
|
|
116
|
+
* variant, then the first variant.
|
|
108
117
|
*/
|
|
109
118
|
initialVariant?: ProductVariant | null;
|
|
110
119
|
/**
|
|
@@ -114,6 +123,12 @@ interface UseVariantSelectionOptions {
|
|
|
114
123
|
* order is variant-discovery order (which may not match Shopify admin).
|
|
115
124
|
*/
|
|
116
125
|
optionValuesByPosition?: ReadonlyArray<ReadonlyArray<string>>;
|
|
126
|
+
/**
|
|
127
|
+
* Per-variant required quantity for the bundle slot this picker fills.
|
|
128
|
+
* When provided, dropdown availability is quantity-aware (a variant short
|
|
129
|
+
* of the bundle's needs greys out) instead of plain `availableForSale`.
|
|
130
|
+
*/
|
|
131
|
+
requiredQtyFor?: (variantId: string) => number;
|
|
117
132
|
}
|
|
118
133
|
interface UseVariantSelectionResult {
|
|
119
134
|
/** Positional option values matching `optionNames`. */
|
|
@@ -128,7 +143,7 @@ interface UseVariantSelectionResult {
|
|
|
128
143
|
disabled: boolean;
|
|
129
144
|
}>;
|
|
130
145
|
}
|
|
131
|
-
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
146
|
+
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, requiredQtyFor, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
132
147
|
|
|
133
148
|
/**
|
|
134
149
|
* Framework-agnostic async fetcher for bundle data.
|
|
@@ -181,27 +196,6 @@ interface FetchBundleDataOptions {
|
|
|
181
196
|
}
|
|
182
197
|
declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
|
|
183
198
|
|
|
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
199
|
interface FetchShopSettingsOptions {
|
|
206
200
|
shopDomain: string;
|
|
207
201
|
storefrontAccessToken: string;
|
|
@@ -211,26 +205,14 @@ interface FetchShopSettingsOptions {
|
|
|
211
205
|
interface ShopSettings {
|
|
212
206
|
/** Raw, unsanitized merchant CSS. Null when unset. */
|
|
213
207
|
customCss: string | null;
|
|
214
|
-
/** Shop-wide handling of products the store can't sell. */
|
|
215
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
216
208
|
}
|
|
217
209
|
declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
218
210
|
/**
|
|
219
|
-
* Same fetch, never rejects
|
|
220
|
-
*
|
|
221
|
-
* from appearing.
|
|
211
|
+
* Same fetch, never rejects — a failed settings request must not stop a
|
|
212
|
+
* bundle from appearing.
|
|
222
213
|
*/
|
|
223
214
|
declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
224
215
|
|
|
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
216
|
type FetchShopCustomCssOptions = FetchShopSettingsOptions;
|
|
235
217
|
/** @deprecated Use `fetchShopSettings().customCss`. */
|
|
236
218
|
declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
|
|
@@ -304,4 +286,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
|
|
|
304
286
|
|
|
305
287
|
declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
|
|
306
288
|
|
|
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
|
|
289
|
+
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.
|
|
@@ -51,6 +51,14 @@ interface BundleComponentProps {
|
|
|
51
51
|
* `marketIds` doesn't include this market.
|
|
52
52
|
*/
|
|
53
53
|
marketId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The product page this component is rendered on — full GID
|
|
56
|
+
* (`gid://shopify/Product/123`) or bare numeric id. Multi-product
|
|
57
|
+
* renderers (`<VolumeBundle>`) price and sell this product; without it
|
|
58
|
+
* they fall back to the bundle's first product, so any bundle spanning
|
|
59
|
+
* more than one product should pass it.
|
|
60
|
+
*/
|
|
61
|
+
productId?: string;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
declare function FixedBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
@@ -103,8 +111,9 @@ interface UseVariantSelectionOptions {
|
|
|
103
111
|
/** Positional option names for the product, e.g. `['Size', 'Color']`. */
|
|
104
112
|
optionNames: ReadonlyArray<string>;
|
|
105
113
|
/**
|
|
106
|
-
* Optional initial variant. Defaults to the first
|
|
107
|
-
* the
|
|
114
|
+
* Optional initial variant. Defaults to the first variant that can cover
|
|
115
|
+
* the slot (per `requiredQtyFor` when supplied), then the first available
|
|
116
|
+
* variant, then the first variant.
|
|
108
117
|
*/
|
|
109
118
|
initialVariant?: ProductVariant | null;
|
|
110
119
|
/**
|
|
@@ -114,6 +123,12 @@ interface UseVariantSelectionOptions {
|
|
|
114
123
|
* order is variant-discovery order (which may not match Shopify admin).
|
|
115
124
|
*/
|
|
116
125
|
optionValuesByPosition?: ReadonlyArray<ReadonlyArray<string>>;
|
|
126
|
+
/**
|
|
127
|
+
* Per-variant required quantity for the bundle slot this picker fills.
|
|
128
|
+
* When provided, dropdown availability is quantity-aware (a variant short
|
|
129
|
+
* of the bundle's needs greys out) instead of plain `availableForSale`.
|
|
130
|
+
*/
|
|
131
|
+
requiredQtyFor?: (variantId: string) => number;
|
|
117
132
|
}
|
|
118
133
|
interface UseVariantSelectionResult {
|
|
119
134
|
/** Positional option values matching `optionNames`. */
|
|
@@ -128,7 +143,7 @@ interface UseVariantSelectionResult {
|
|
|
128
143
|
disabled: boolean;
|
|
129
144
|
}>;
|
|
130
145
|
}
|
|
131
|
-
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
146
|
+
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, requiredQtyFor, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
132
147
|
|
|
133
148
|
/**
|
|
134
149
|
* Framework-agnostic async fetcher for bundle data.
|
|
@@ -181,27 +196,6 @@ interface FetchBundleDataOptions {
|
|
|
181
196
|
}
|
|
182
197
|
declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
|
|
183
198
|
|
|
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
199
|
interface FetchShopSettingsOptions {
|
|
206
200
|
shopDomain: string;
|
|
207
201
|
storefrontAccessToken: string;
|
|
@@ -211,26 +205,14 @@ interface FetchShopSettingsOptions {
|
|
|
211
205
|
interface ShopSettings {
|
|
212
206
|
/** Raw, unsanitized merchant CSS. Null when unset. */
|
|
213
207
|
customCss: string | null;
|
|
214
|
-
/** Shop-wide handling of products the store can't sell. */
|
|
215
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
216
208
|
}
|
|
217
209
|
declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
218
210
|
/**
|
|
219
|
-
* Same fetch, never rejects
|
|
220
|
-
*
|
|
221
|
-
* from appearing.
|
|
211
|
+
* Same fetch, never rejects — a failed settings request must not stop a
|
|
212
|
+
* bundle from appearing.
|
|
222
213
|
*/
|
|
223
214
|
declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
224
215
|
|
|
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
216
|
type FetchShopCustomCssOptions = FetchShopSettingsOptions;
|
|
235
217
|
/** @deprecated Use `fetchShopSettings().customCss`. */
|
|
236
218
|
declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
|
|
@@ -304,4 +286,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
|
|
|
304
286
|
|
|
305
287
|
declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
|
|
306
288
|
|
|
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
|
|
289
|
+
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 };
|