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