@cimplify/sdk 0.9.8 → 0.9.10

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/react.js CHANGED
@@ -6752,6 +6752,525 @@ function AddOnSelector({
6752
6752
  ] }, addOn.id);
6753
6753
  }) });
6754
6754
  }
6755
+ function BundleSelector({
6756
+ components,
6757
+ bundlePrice,
6758
+ discountValue,
6759
+ onSelectionsChange,
6760
+ onReady,
6761
+ className
6762
+ }) {
6763
+ const [variantChoices, setVariantChoices] = React3.useState({});
6764
+ React3.useEffect(() => {
6765
+ const defaults = {};
6766
+ for (const comp of components) {
6767
+ if (comp.variant_id) {
6768
+ defaults[comp.id] = comp.variant_id;
6769
+ } else if (comp.available_variants.length > 0) {
6770
+ const defaultVariant = comp.available_variants.find((v) => v.is_default) || comp.available_variants[0];
6771
+ if (defaultVariant) {
6772
+ defaults[comp.id] = defaultVariant.id;
6773
+ }
6774
+ }
6775
+ }
6776
+ setVariantChoices(defaults);
6777
+ }, [components]);
6778
+ const selections = React3.useMemo(() => {
6779
+ return components.map((comp) => ({
6780
+ component_id: comp.id,
6781
+ variant_id: variantChoices[comp.id],
6782
+ quantity: comp.quantity
6783
+ }));
6784
+ }, [components, variantChoices]);
6785
+ React3.useEffect(() => {
6786
+ onSelectionsChange(selections);
6787
+ }, [selections, onSelectionsChange]);
6788
+ React3.useEffect(() => {
6789
+ onReady?.(components.length > 0 && selections.length > 0);
6790
+ }, [components, selections, onReady]);
6791
+ const handleVariantChange = React3.useCallback(
6792
+ (componentId, variantId) => {
6793
+ setVariantChoices((prev) => ({ ...prev, [componentId]: variantId }));
6794
+ },
6795
+ []
6796
+ );
6797
+ if (components.length === 0) {
6798
+ return null;
6799
+ }
6800
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bundle-selector": true, className, children: [
6801
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-bundle-heading": true, children: "Included in this bundle" }),
6802
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-bundle-components": true, children: components.map((comp) => /* @__PURE__ */ jsxRuntime.jsx(
6803
+ BundleComponentCard,
6804
+ {
6805
+ component: comp,
6806
+ selectedVariantId: variantChoices[comp.id],
6807
+ onVariantChange: (variantId) => handleVariantChange(comp.id, variantId)
6808
+ },
6809
+ comp.id
6810
+ )) }),
6811
+ bundlePrice && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bundle-summary": true, children: [
6812
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Bundle price" }),
6813
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: bundlePrice })
6814
+ ] }),
6815
+ discountValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bundle-savings": true, children: [
6816
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "You save" }),
6817
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: discountValue })
6818
+ ] })
6819
+ ] });
6820
+ }
6821
+ function BundleComponentCard({
6822
+ component,
6823
+ selectedVariantId,
6824
+ onVariantChange
6825
+ }) {
6826
+ const showVariantPicker = component.allow_variant_choice && component.available_variants.length > 1;
6827
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bundle-component": true, children: [
6828
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bundle-component-header": true, children: [
6829
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
6830
+ component.quantity > 1 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-bundle-component-qty": true, children: [
6831
+ "\xD7",
6832
+ component.quantity
6833
+ ] }),
6834
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-bundle-component-name": true, children: component.product_name })
6835
+ ] }),
6836
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: component.product_default_price })
6837
+ ] }),
6838
+ showVariantPicker && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-bundle-variant-picker": true, children: component.available_variants.map((variant) => {
6839
+ const isSelected = selectedVariantId === variant.id;
6840
+ const adjustment = parsePrice(variant.price_adjustment);
6841
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6842
+ "button",
6843
+ {
6844
+ type: "button",
6845
+ "aria-selected": isSelected,
6846
+ onClick: () => onVariantChange(variant.id),
6847
+ "data-cimplify-bundle-variant-option": true,
6848
+ "data-selected": isSelected || void 0,
6849
+ children: [
6850
+ variant.display_name,
6851
+ adjustment !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-bundle-variant-adjustment": true, children: [
6852
+ adjustment > 0 ? "+" : "",
6853
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: variant.price_adjustment })
6854
+ ] })
6855
+ ]
6856
+ },
6857
+ variant.id
6858
+ );
6859
+ }) })
6860
+ ] });
6861
+ }
6862
+ function CompositeSelector({
6863
+ compositeId,
6864
+ groups,
6865
+ onSelectionsChange,
6866
+ onPriceChange,
6867
+ onReady,
6868
+ className
6869
+ }) {
6870
+ const { client } = useCimplify();
6871
+ const [groupSelections, setGroupSelections] = React3.useState({});
6872
+ const [priceResult, setPriceResult] = React3.useState(null);
6873
+ const [isPriceLoading, setIsPriceLoading] = React3.useState(false);
6874
+ const selections = React3.useMemo(() => {
6875
+ const result = [];
6876
+ for (const groupSels of Object.values(groupSelections)) {
6877
+ for (const [componentId, qty] of Object.entries(groupSels)) {
6878
+ if (qty > 0) {
6879
+ result.push({ component_id: componentId, quantity: qty });
6880
+ }
6881
+ }
6882
+ }
6883
+ return result;
6884
+ }, [groupSelections]);
6885
+ React3.useEffect(() => {
6886
+ onSelectionsChange(selections);
6887
+ }, [selections, onSelectionsChange]);
6888
+ React3.useEffect(() => {
6889
+ onPriceChange?.(priceResult);
6890
+ }, [priceResult, onPriceChange]);
6891
+ const allGroupsSatisfied = React3.useMemo(() => {
6892
+ for (const group of groups) {
6893
+ const groupSels = groupSelections[group.id] || {};
6894
+ const totalSelected = Object.values(groupSels).reduce((sum, q) => sum + q, 0);
6895
+ if (totalSelected < group.min_selections) return false;
6896
+ }
6897
+ return true;
6898
+ }, [groups, groupSelections]);
6899
+ React3.useEffect(() => {
6900
+ onReady?.(allGroupsSatisfied);
6901
+ }, [allGroupsSatisfied, onReady]);
6902
+ React3.useEffect(() => {
6903
+ if (!allGroupsSatisfied || selections.length === 0) return;
6904
+ let cancelled = false;
6905
+ setIsPriceLoading(true);
6906
+ void client.catalogue.calculateCompositePrice(compositeId, selections).then((result) => {
6907
+ if (cancelled) return;
6908
+ if (result.ok) {
6909
+ setPriceResult(result.value);
6910
+ }
6911
+ }).finally(() => {
6912
+ if (!cancelled) setIsPriceLoading(false);
6913
+ });
6914
+ return () => {
6915
+ cancelled = true;
6916
+ };
6917
+ }, [selections, allGroupsSatisfied, compositeId, client]);
6918
+ const toggleComponent = React3.useCallback(
6919
+ (group, component) => {
6920
+ setGroupSelections((prev) => {
6921
+ const groupSels = { ...prev[group.id] || {} };
6922
+ const currentQty = groupSels[component.id] || 0;
6923
+ if (currentQty > 0) {
6924
+ if (group.min_selections > 0) {
6925
+ const totalOthers = Object.entries(groupSels).filter(([id]) => id !== component.id).reduce((sum, [, q]) => sum + q, 0);
6926
+ if (totalOthers < group.min_selections) {
6927
+ return prev;
6928
+ }
6929
+ }
6930
+ delete groupSels[component.id];
6931
+ } else {
6932
+ const totalSelected = Object.values(groupSels).reduce((sum, q) => sum + q, 0);
6933
+ if (group.max_selections && totalSelected >= group.max_selections) {
6934
+ if (group.max_selections === 1) {
6935
+ return { ...prev, [group.id]: { [component.id]: 1 } };
6936
+ }
6937
+ return prev;
6938
+ }
6939
+ groupSels[component.id] = 1;
6940
+ }
6941
+ return { ...prev, [group.id]: groupSels };
6942
+ });
6943
+ },
6944
+ []
6945
+ );
6946
+ const updateQuantity = React3.useCallback(
6947
+ (group, componentId, delta) => {
6948
+ setGroupSelections((prev) => {
6949
+ const groupSels = { ...prev[group.id] || {} };
6950
+ const current = groupSels[componentId] || 0;
6951
+ const next = Math.max(0, current + delta);
6952
+ if (group.max_quantity_per_component && next > group.max_quantity_per_component) {
6953
+ return prev;
6954
+ }
6955
+ if (next === 0) {
6956
+ delete groupSels[componentId];
6957
+ } else {
6958
+ groupSels[componentId] = next;
6959
+ }
6960
+ return { ...prev, [group.id]: groupSels };
6961
+ });
6962
+ },
6963
+ []
6964
+ );
6965
+ if (groups.length === 0) {
6966
+ return null;
6967
+ }
6968
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-selector": true, className, children: [
6969
+ [...groups].sort((a, b) => a.display_order - b.display_order).map((group) => {
6970
+ const groupSels = groupSelections[group.id] || {};
6971
+ const totalSelected = Object.values(groupSels).reduce((sum, q) => sum + q, 0);
6972
+ const minMet = totalSelected >= group.min_selections;
6973
+ const isSingleSelect = group.max_selections === 1;
6974
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-group": true, children: [
6975
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-group-header": true, children: [
6976
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
6977
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-composite-group-name": true, children: [
6978
+ group.name,
6979
+ group.min_selections > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-required": true, children: " *" })
6980
+ ] }),
6981
+ group.description && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-group-description": true, children: group.description }),
6982
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-group-constraint": true, children: group.min_selections > 0 && group.max_selections ? `Choose ${group.min_selections}\u2013${group.max_selections}` : group.min_selections > 0 ? `Choose at least ${group.min_selections}` : group.max_selections ? `Choose up to ${group.max_selections}` : "Choose as many as you like" })
6983
+ ] }),
6984
+ !minMet && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-validation": true, children: "Required" })
6985
+ ] }),
6986
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-composite-components": true, children: group.components.filter((c) => c.is_available && !c.is_archived).sort((a, b) => a.display_order - b.display_order).map((component) => {
6987
+ const qty = groupSels[component.id] || 0;
6988
+ const isSelected = qty > 0;
6989
+ const displayName = component.display_name || component.id;
6990
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6991
+ "button",
6992
+ {
6993
+ type: "button",
6994
+ role: isSingleSelect ? "radio" : "checkbox",
6995
+ "aria-checked": isSelected,
6996
+ onClick: () => toggleComponent(group, component),
6997
+ "data-cimplify-composite-component": true,
6998
+ "data-selected": isSelected || void 0,
6999
+ children: [
7000
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-component-info": true, children: [
7001
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-component-name": true, children: displayName }),
7002
+ component.is_popular && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-badge": "popular", children: "Popular" }),
7003
+ component.is_premium && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-badge": "premium", children: "Premium" }),
7004
+ component.display_description && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-component-description": true, children: component.display_description }),
7005
+ component.calories != null && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-composite-component-calories": true, children: [
7006
+ component.calories,
7007
+ " cal"
7008
+ ] })
7009
+ ] }),
7010
+ group.allow_quantity && isSelected && /* @__PURE__ */ jsxRuntime.jsxs(
7011
+ "span",
7012
+ {
7013
+ "data-cimplify-composite-qty": true,
7014
+ onClick: (e) => e.stopPropagation(),
7015
+ children: [
7016
+ /* @__PURE__ */ jsxRuntime.jsx(
7017
+ "button",
7018
+ {
7019
+ type: "button",
7020
+ onClick: () => updateQuantity(group, component.id, -1),
7021
+ "aria-label": `Decrease ${displayName} quantity`,
7022
+ children: "\u2212"
7023
+ }
7024
+ ),
7025
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: qty }),
7026
+ /* @__PURE__ */ jsxRuntime.jsx(
7027
+ "button",
7028
+ {
7029
+ type: "button",
7030
+ onClick: () => updateQuantity(group, component.id, 1),
7031
+ "aria-label": `Increase ${displayName} quantity`,
7032
+ children: "+"
7033
+ }
7034
+ )
7035
+ ]
7036
+ }
7037
+ ),
7038
+ component.price && component.price !== "0" && /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: component.price, prefix: "+" })
7039
+ ]
7040
+ },
7041
+ component.id
7042
+ );
7043
+ }) })
7044
+ ] }, group.id);
7045
+ }),
7046
+ priceResult && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-summary": true, children: [
7047
+ priceResult.base_price !== "0" && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-summary-line": true, children: [
7048
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Base" }),
7049
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: priceResult.base_price })
7050
+ ] }),
7051
+ priceResult.components_total !== "0" && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-summary-line": true, children: [
7052
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Selections" }),
7053
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: priceResult.components_total })
7054
+ ] }),
7055
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-summary-total": true, children: [
7056
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Total" }),
7057
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: priceResult.final_price })
7058
+ ] })
7059
+ ] }),
7060
+ isPriceLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-composite-calculating": true, children: "Calculating price..." })
7061
+ ] });
7062
+ }
7063
+ function ProductCustomizer({
7064
+ product,
7065
+ onAddToCart,
7066
+ className
7067
+ }) {
7068
+ const [quantity, setQuantity] = React3.useState(1);
7069
+ const [isAdded, setIsAdded] = React3.useState(false);
7070
+ const [isSubmitting, setIsSubmitting] = React3.useState(false);
7071
+ const [selectedVariantId, setSelectedVariantId] = React3.useState();
7072
+ const [selectedVariant, setSelectedVariant] = React3.useState();
7073
+ const [selectedAddOnOptionIds, setSelectedAddOnOptionIds] = React3.useState([]);
7074
+ const [compositeSelections, setCompositeSelections] = React3.useState([]);
7075
+ const [compositePrice, setCompositePrice] = React3.useState(null);
7076
+ const [compositeReady, setCompositeReady] = React3.useState(false);
7077
+ const [bundleSelections, setBundleSelections] = React3.useState([]);
7078
+ const [bundleReady, setBundleReady] = React3.useState(false);
7079
+ const cart = useCart();
7080
+ const productType = product.type || "product";
7081
+ const isComposite = productType === "composite";
7082
+ const isBundle = productType === "bundle";
7083
+ const isStandard = !isComposite && !isBundle;
7084
+ const hasVariants = isStandard && product.variants && product.variants.length > 0;
7085
+ const hasAddOns = isStandard && product.add_ons && product.add_ons.length > 0;
7086
+ React3.useEffect(() => {
7087
+ setQuantity(1);
7088
+ setIsAdded(false);
7089
+ setIsSubmitting(false);
7090
+ setSelectedVariantId(void 0);
7091
+ setSelectedVariant(void 0);
7092
+ setSelectedAddOnOptionIds([]);
7093
+ setCompositeSelections([]);
7094
+ setCompositePrice(null);
7095
+ setCompositeReady(false);
7096
+ setBundleSelections([]);
7097
+ setBundleReady(false);
7098
+ }, [product.id]);
7099
+ const selectedAddOnOptions = React3.useMemo(() => {
7100
+ if (!product.add_ons) return [];
7101
+ const options = [];
7102
+ for (const addOn of product.add_ons) {
7103
+ for (const option of addOn.options) {
7104
+ if (selectedAddOnOptionIds.includes(option.id)) {
7105
+ options.push(option);
7106
+ }
7107
+ }
7108
+ }
7109
+ return options;
7110
+ }, [product.add_ons, selectedAddOnOptionIds]);
7111
+ const normalizedAddOnOptionIds = React3.useMemo(() => {
7112
+ if (selectedAddOnOptionIds.length === 0) return [];
7113
+ return Array.from(new Set(selectedAddOnOptionIds.map((id) => id.trim()).filter(Boolean))).sort();
7114
+ }, [selectedAddOnOptionIds]);
7115
+ const localTotalPrice = React3.useMemo(() => {
7116
+ if (isComposite && compositePrice) {
7117
+ return parsePrice(compositePrice.final_price) * quantity;
7118
+ }
7119
+ let price = parsePrice(product.default_price);
7120
+ if (selectedVariant?.price_adjustment) {
7121
+ price += parsePrice(selectedVariant.price_adjustment);
7122
+ }
7123
+ for (const option of selectedAddOnOptions) {
7124
+ if (option.default_price) {
7125
+ price += parsePrice(option.default_price);
7126
+ }
7127
+ }
7128
+ return price * quantity;
7129
+ }, [product.default_price, selectedVariant, selectedAddOnOptions, quantity, isComposite, compositePrice]);
7130
+ const requiredAddOnsSatisfied = React3.useMemo(() => {
7131
+ if (!product.add_ons) return true;
7132
+ for (const addOn of product.add_ons) {
7133
+ if (addOn.is_required) {
7134
+ const selectedInGroup = selectedAddOnOptionIds.filter(
7135
+ (id) => addOn.options.some((opt) => opt.id === id)
7136
+ ).length;
7137
+ const minRequired = addOn.min_selections || 1;
7138
+ if (selectedInGroup < minRequired) {
7139
+ return false;
7140
+ }
7141
+ }
7142
+ }
7143
+ return true;
7144
+ }, [product.add_ons, selectedAddOnOptionIds]);
7145
+ const quoteInput = React3.useMemo(
7146
+ () => ({
7147
+ productId: product.id,
7148
+ quantity,
7149
+ variantId: selectedVariantId,
7150
+ addOnOptionIds: normalizedAddOnOptionIds.length > 0 ? normalizedAddOnOptionIds : void 0
7151
+ }),
7152
+ [product.id, quantity, selectedVariantId, normalizedAddOnOptionIds]
7153
+ );
7154
+ const { quote } = useQuote(quoteInput, {
7155
+ enabled: isStandard && requiredAddOnsSatisfied
7156
+ });
7157
+ const quoteId = quote?.quote_id;
7158
+ const quotedTotalPrice = React3.useMemo(() => {
7159
+ if (!quote) return void 0;
7160
+ const quotedTotal = quote.quoted_total_price_info?.final_price ?? quote.final_price_info.final_price;
7161
+ return quotedTotal === void 0 || quotedTotal === null ? void 0 : parsePrice(quotedTotal);
7162
+ }, [quote]);
7163
+ const displayTotalPrice = quotedTotalPrice ?? localTotalPrice;
7164
+ const canAddToCart = React3.useMemo(() => {
7165
+ if (isComposite) return compositeReady;
7166
+ if (isBundle) return bundleReady;
7167
+ return requiredAddOnsSatisfied;
7168
+ }, [isComposite, isBundle, compositeReady, bundleReady, requiredAddOnsSatisfied]);
7169
+ const handleVariantChange = React3.useCallback(
7170
+ (variantId, variant) => {
7171
+ setSelectedVariantId(variantId);
7172
+ setSelectedVariant(variant);
7173
+ },
7174
+ []
7175
+ );
7176
+ const handleAddToCart = async () => {
7177
+ if (isSubmitting) return;
7178
+ setIsSubmitting(true);
7179
+ const options = {
7180
+ variantId: selectedVariantId,
7181
+ variant: selectedVariant ? { id: selectedVariant.id, name: selectedVariant.name || "", price_adjustment: selectedVariant.price_adjustment } : void 0,
7182
+ quoteId,
7183
+ addOnOptionIds: normalizedAddOnOptionIds.length > 0 ? normalizedAddOnOptionIds : void 0,
7184
+ addOnOptions: selectedAddOnOptions.length > 0 ? selectedAddOnOptions.map((opt) => ({
7185
+ id: opt.id,
7186
+ name: opt.name,
7187
+ add_on_id: opt.add_on_id,
7188
+ default_price: opt.default_price
7189
+ })) : void 0,
7190
+ compositeSelections: isComposite && compositeSelections.length > 0 ? compositeSelections : void 0,
7191
+ bundleSelections: isBundle && bundleSelections.length > 0 ? bundleSelections : void 0
7192
+ };
7193
+ try {
7194
+ if (onAddToCart) {
7195
+ await onAddToCart(product, quantity, options);
7196
+ } else {
7197
+ await cart.addItem(product, quantity, options);
7198
+ }
7199
+ setIsAdded(true);
7200
+ setTimeout(() => {
7201
+ setIsAdded(false);
7202
+ setQuantity(1);
7203
+ }, 2e3);
7204
+ } catch {
7205
+ } finally {
7206
+ setIsSubmitting(false);
7207
+ }
7208
+ };
7209
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customizer": true, className, children: [
7210
+ isComposite && product.groups && product.composite_id && /* @__PURE__ */ jsxRuntime.jsx(
7211
+ CompositeSelector,
7212
+ {
7213
+ compositeId: product.composite_id,
7214
+ groups: product.groups,
7215
+ onSelectionsChange: setCompositeSelections,
7216
+ onPriceChange: setCompositePrice,
7217
+ onReady: setCompositeReady
7218
+ }
7219
+ ),
7220
+ isBundle && product.components && /* @__PURE__ */ jsxRuntime.jsx(
7221
+ BundleSelector,
7222
+ {
7223
+ components: product.components,
7224
+ bundlePrice: product.bundle_price,
7225
+ discountValue: product.discount_value,
7226
+ onSelectionsChange: setBundleSelections,
7227
+ onReady: setBundleReady
7228
+ }
7229
+ ),
7230
+ hasVariants && /* @__PURE__ */ jsxRuntime.jsx(
7231
+ VariantSelector,
7232
+ {
7233
+ variants: product.variants,
7234
+ variantAxes: product.variant_axes,
7235
+ basePrice: product.default_price,
7236
+ selectedVariantId,
7237
+ onVariantChange: handleVariantChange
7238
+ }
7239
+ ),
7240
+ hasAddOns && /* @__PURE__ */ jsxRuntime.jsx(
7241
+ AddOnSelector,
7242
+ {
7243
+ addOns: product.add_ons,
7244
+ selectedOptions: selectedAddOnOptionIds,
7245
+ onOptionsChange: setSelectedAddOnOptionIds
7246
+ }
7247
+ ),
7248
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customizer-actions": true, children: [
7249
+ /* @__PURE__ */ jsxRuntime.jsx(
7250
+ QuantitySelector,
7251
+ {
7252
+ value: quantity,
7253
+ onChange: setQuantity,
7254
+ min: 1
7255
+ }
7256
+ ),
7257
+ /* @__PURE__ */ jsxRuntime.jsx(
7258
+ "button",
7259
+ {
7260
+ type: "button",
7261
+ onClick: handleAddToCart,
7262
+ disabled: isAdded || isSubmitting || !canAddToCart,
7263
+ "data-cimplify-customizer-submit": true,
7264
+ children: isAdded ? "Added to Cart" : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7265
+ "Add to Cart \xB7 ",
7266
+ /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: displayTotalPrice })
7267
+ ] })
7268
+ }
7269
+ )
7270
+ ] }),
7271
+ !canAddToCart && /* @__PURE__ */ jsxRuntime.jsx("p", { "data-cimplify-customizer-validation": true, children: "Please select all required options" })
7272
+ ] });
7273
+ }
6755
7274
  var ASPECT_STYLES = {
6756
7275
  square: { aspectRatio: "1/1" },
6757
7276
  "4/3": { aspectRatio: "4/3" },
@@ -6933,12 +7452,15 @@ exports.AdProvider = AdProvider;
6933
7452
  exports.AddOnSelector = AddOnSelector;
6934
7453
  exports.AddressElement = AddressElement;
6935
7454
  exports.AuthElement = AuthElement;
7455
+ exports.BundleSelector = BundleSelector;
6936
7456
  exports.CartSummary = CartSummary;
6937
7457
  exports.CimplifyCheckout = CimplifyCheckout;
6938
7458
  exports.CimplifyProvider = CimplifyProvider;
7459
+ exports.CompositeSelector = CompositeSelector;
6939
7460
  exports.ElementsProvider = ElementsProvider;
6940
7461
  exports.PaymentElement = PaymentElement;
6941
7462
  exports.Price = Price;
7463
+ exports.ProductCustomizer = ProductCustomizer;
6942
7464
  exports.ProductImageGallery = ProductImageGallery;
6943
7465
  exports.QuantitySelector = QuantitySelector;
6944
7466
  exports.VariantSelector = VariantSelector;