@lime-bundles/react 6.1.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/README.md +7 -1
- package/dist/index.cjs +673 -543
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -42
- package/dist/index.d.ts +35 -42
- package/dist/index.js +589 -460
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1929 -0
- package/docs/hydrogen.md +28 -3
- package/docs/react-nextjs.md +23 -3
- 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, 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.
|
|
@@ -55,7 +55,26 @@ interface BundleComponentProps {
|
|
|
55
55
|
|
|
56
56
|
declare function FixedBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
interface MixMatchBundleProps extends BundleComponentProps {
|
|
59
|
+
/**
|
|
60
|
+
* Handle of the product page this component is rendered on, when there is
|
|
61
|
+
* one. Enables the theme widget's courtesy seed: with no required products,
|
|
62
|
+
* the bundle starts with this product (or the first that qualifies)
|
|
63
|
+
* pre-added at its rule minimum. Omit on non-product pages to start empty.
|
|
64
|
+
*/
|
|
65
|
+
productHandle?: string | null;
|
|
66
|
+
}
|
|
67
|
+
declare function MixMatchBundle(props: MixMatchBundleProps): react_jsx_runtime.JSX.Element | null;
|
|
68
|
+
|
|
69
|
+
interface BundleCountdownProps {
|
|
70
|
+
/** The bundle's ISO end date; renders nothing when null. */
|
|
71
|
+
endsAt: string | null | undefined;
|
|
72
|
+
/** The bundle's widget config — gates on `countdown.showCountdown`. */
|
|
73
|
+
widgetConfig: WidgetConfig | undefined;
|
|
74
|
+
/** Label text; defaults to the theme's translation default. */
|
|
75
|
+
label?: string;
|
|
76
|
+
}
|
|
77
|
+
declare function BundleCountdown({ endsAt, widgetConfig, label, }: BundleCountdownProps): react_jsx_runtime.JSX.Element | null;
|
|
59
78
|
|
|
60
79
|
declare function VolumeBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
61
80
|
|
|
@@ -84,8 +103,9 @@ interface UseVariantSelectionOptions {
|
|
|
84
103
|
/** Positional option names for the product, e.g. `['Size', 'Color']`. */
|
|
85
104
|
optionNames: ReadonlyArray<string>;
|
|
86
105
|
/**
|
|
87
|
-
* Optional initial variant. Defaults to the first
|
|
88
|
-
* 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.
|
|
89
109
|
*/
|
|
90
110
|
initialVariant?: ProductVariant | null;
|
|
91
111
|
/**
|
|
@@ -95,6 +115,12 @@ interface UseVariantSelectionOptions {
|
|
|
95
115
|
* order is variant-discovery order (which may not match Shopify admin).
|
|
96
116
|
*/
|
|
97
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;
|
|
98
124
|
}
|
|
99
125
|
interface UseVariantSelectionResult {
|
|
100
126
|
/** Positional option values matching `optionNames`. */
|
|
@@ -109,7 +135,7 @@ interface UseVariantSelectionResult {
|
|
|
109
135
|
disabled: boolean;
|
|
110
136
|
}>;
|
|
111
137
|
}
|
|
112
|
-
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
138
|
+
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, requiredQtyFor, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
113
139
|
|
|
114
140
|
/**
|
|
115
141
|
* Framework-agnostic async fetcher for bundle data.
|
|
@@ -162,27 +188,6 @@ interface FetchBundleDataOptions {
|
|
|
162
188
|
}
|
|
163
189
|
declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
|
|
164
190
|
|
|
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
191
|
interface FetchShopSettingsOptions {
|
|
187
192
|
shopDomain: string;
|
|
188
193
|
storefrontAccessToken: string;
|
|
@@ -192,26 +197,14 @@ interface FetchShopSettingsOptions {
|
|
|
192
197
|
interface ShopSettings {
|
|
193
198
|
/** Raw, unsanitized merchant CSS. Null when unset. */
|
|
194
199
|
customCss: string | null;
|
|
195
|
-
/** Shop-wide handling of products the store can't sell. */
|
|
196
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
197
200
|
}
|
|
198
201
|
declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
199
202
|
/**
|
|
200
|
-
* Same fetch, never rejects
|
|
201
|
-
*
|
|
202
|
-
* from appearing.
|
|
203
|
+
* Same fetch, never rejects — a failed settings request must not stop a
|
|
204
|
+
* bundle from appearing.
|
|
203
205
|
*/
|
|
204
206
|
declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
205
207
|
|
|
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
208
|
type FetchShopCustomCssOptions = FetchShopSettingsOptions;
|
|
216
209
|
/** @deprecated Use `fetchShopSettings().customCss`. */
|
|
217
210
|
declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
|
|
@@ -285,4 +278,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
|
|
|
285
278
|
|
|
286
279
|
declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
|
|
287
280
|
|
|
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
|
|
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, 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.
|
|
@@ -55,7 +55,26 @@ interface BundleComponentProps {
|
|
|
55
55
|
|
|
56
56
|
declare function FixedBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
interface MixMatchBundleProps extends BundleComponentProps {
|
|
59
|
+
/**
|
|
60
|
+
* Handle of the product page this component is rendered on, when there is
|
|
61
|
+
* one. Enables the theme widget's courtesy seed: with no required products,
|
|
62
|
+
* the bundle starts with this product (or the first that qualifies)
|
|
63
|
+
* pre-added at its rule minimum. Omit on non-product pages to start empty.
|
|
64
|
+
*/
|
|
65
|
+
productHandle?: string | null;
|
|
66
|
+
}
|
|
67
|
+
declare function MixMatchBundle(props: MixMatchBundleProps): react_jsx_runtime.JSX.Element | null;
|
|
68
|
+
|
|
69
|
+
interface BundleCountdownProps {
|
|
70
|
+
/** The bundle's ISO end date; renders nothing when null. */
|
|
71
|
+
endsAt: string | null | undefined;
|
|
72
|
+
/** The bundle's widget config — gates on `countdown.showCountdown`. */
|
|
73
|
+
widgetConfig: WidgetConfig | undefined;
|
|
74
|
+
/** Label text; defaults to the theme's translation default. */
|
|
75
|
+
label?: string;
|
|
76
|
+
}
|
|
77
|
+
declare function BundleCountdown({ endsAt, widgetConfig, label, }: BundleCountdownProps): react_jsx_runtime.JSX.Element | null;
|
|
59
78
|
|
|
60
79
|
declare function VolumeBundle(props: BundleComponentProps): react_jsx_runtime.JSX.Element | null;
|
|
61
80
|
|
|
@@ -84,8 +103,9 @@ interface UseVariantSelectionOptions {
|
|
|
84
103
|
/** Positional option names for the product, e.g. `['Size', 'Color']`. */
|
|
85
104
|
optionNames: ReadonlyArray<string>;
|
|
86
105
|
/**
|
|
87
|
-
* Optional initial variant. Defaults to the first
|
|
88
|
-
* 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.
|
|
89
109
|
*/
|
|
90
110
|
initialVariant?: ProductVariant | null;
|
|
91
111
|
/**
|
|
@@ -95,6 +115,12 @@ interface UseVariantSelectionOptions {
|
|
|
95
115
|
* order is variant-discovery order (which may not match Shopify admin).
|
|
96
116
|
*/
|
|
97
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;
|
|
98
124
|
}
|
|
99
125
|
interface UseVariantSelectionResult {
|
|
100
126
|
/** Positional option values matching `optionNames`. */
|
|
@@ -109,7 +135,7 @@ interface UseVariantSelectionResult {
|
|
|
109
135
|
disabled: boolean;
|
|
110
136
|
}>;
|
|
111
137
|
}
|
|
112
|
-
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
138
|
+
declare function useVariantSelection({ variants, optionNames, initialVariant, optionValuesByPosition, requiredQtyFor, }: UseVariantSelectionOptions): UseVariantSelectionResult;
|
|
113
139
|
|
|
114
140
|
/**
|
|
115
141
|
* Framework-agnostic async fetcher for bundle data.
|
|
@@ -162,27 +188,6 @@ interface FetchBundleDataOptions {
|
|
|
162
188
|
}
|
|
163
189
|
declare function fetchBundleData(options: FetchBundleDataOptions): Promise<ParsedBundle>;
|
|
164
190
|
|
|
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
191
|
interface FetchShopSettingsOptions {
|
|
187
192
|
shopDomain: string;
|
|
188
193
|
storefrontAccessToken: string;
|
|
@@ -192,26 +197,14 @@ interface FetchShopSettingsOptions {
|
|
|
192
197
|
interface ShopSettings {
|
|
193
198
|
/** Raw, unsanitized merchant CSS. Null when unset. */
|
|
194
199
|
customCss: string | null;
|
|
195
|
-
/** Shop-wide handling of products the store can't sell. */
|
|
196
|
-
outOfStockBehavior: OutOfStockBehavior;
|
|
197
200
|
}
|
|
198
201
|
declare function fetchShopSettings(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
199
202
|
/**
|
|
200
|
-
* Same fetch, never rejects
|
|
201
|
-
*
|
|
202
|
-
* from appearing.
|
|
203
|
+
* Same fetch, never rejects — a failed settings request must not stop a
|
|
204
|
+
* bundle from appearing.
|
|
203
205
|
*/
|
|
204
206
|
declare function fetchShopSettingsOrDefault(options: FetchShopSettingsOptions): Promise<ShopSettings>;
|
|
205
207
|
|
|
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
208
|
type FetchShopCustomCssOptions = FetchShopSettingsOptions;
|
|
216
209
|
/** @deprecated Use `fetchShopSettings().customCss`. */
|
|
217
210
|
declare function fetchShopCustomCss(options: FetchShopCustomCssOptions): Promise<string | null>;
|
|
@@ -285,4 +278,4 @@ declare function useAnalytics(options: UseAnalyticsOptions): {
|
|
|
285
278
|
|
|
286
279
|
declare function useWidgetConfigVars(config: WidgetConfig | null | undefined): (el: HTMLElement | null) => void;
|
|
287
280
|
|
|
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
|
|
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 };
|