@cimplify/sdk 0.10.1 → 0.10.3
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.d.mts +93 -24
- package/dist/react.d.ts +93 -24
- package/dist/react.js +649 -267
- package/dist/react.mjs +649 -267
- package/package.json +1 -1
- package/registry/add-on-selector.json +1 -1
- package/registry/bundle-selector.json +1 -1
- package/registry/composite-selector.json +1 -1
- package/registry/order-summary.json +1 -1
- package/registry/product-customizer.json +1 -1
- package/registry/quantity-selector.json +1 -1
- package/registry/variant-selector.json +1 -1
package/dist/react.js
CHANGED
|
@@ -7819,38 +7819,65 @@ function useCheckout() {
|
|
|
7819
7819
|
);
|
|
7820
7820
|
return { submit, process, isLoading };
|
|
7821
7821
|
}
|
|
7822
|
+
function cn(...inputs) {
|
|
7823
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
7824
|
+
}
|
|
7822
7825
|
function QuantitySelector({
|
|
7823
7826
|
value,
|
|
7824
7827
|
onChange,
|
|
7825
7828
|
min = 1,
|
|
7826
7829
|
max,
|
|
7827
|
-
className
|
|
7830
|
+
className,
|
|
7831
|
+
classNames
|
|
7828
7832
|
}) {
|
|
7829
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7833
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7834
|
+
"div",
|
|
7835
|
+
{
|
|
7836
|
+
"data-cimplify-quantity": true,
|
|
7837
|
+
className: cn("inline-flex items-center gap-3 border border-border px-2", className, classNames?.root),
|
|
7838
|
+
children: [
|
|
7839
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7840
|
+
"button",
|
|
7841
|
+
{
|
|
7842
|
+
type: "button",
|
|
7843
|
+
onClick: () => onChange(Math.max(min, value - 1)),
|
|
7844
|
+
disabled: value <= min,
|
|
7845
|
+
"aria-label": "Decrease quantity",
|
|
7846
|
+
"data-cimplify-quantity-decrement": true,
|
|
7847
|
+
className: cn(
|
|
7848
|
+
"w-10 h-10 flex items-center justify-center hover:text-primary transition-colors disabled:opacity-30",
|
|
7849
|
+
classNames?.button
|
|
7850
|
+
),
|
|
7851
|
+
children: "\u2212"
|
|
7852
|
+
}
|
|
7853
|
+
),
|
|
7854
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7855
|
+
"span",
|
|
7856
|
+
{
|
|
7857
|
+
"data-cimplify-quantity-value": true,
|
|
7858
|
+
"aria-live": "polite",
|
|
7859
|
+
className: cn("w-8 text-center font-medium", classNames?.value),
|
|
7860
|
+
children: value
|
|
7861
|
+
}
|
|
7862
|
+
),
|
|
7863
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7864
|
+
"button",
|
|
7865
|
+
{
|
|
7866
|
+
type: "button",
|
|
7867
|
+
onClick: () => onChange(max != null ? Math.min(max, value + 1) : value + 1),
|
|
7868
|
+
disabled: max != null && value >= max,
|
|
7869
|
+
"aria-label": "Increase quantity",
|
|
7870
|
+
"data-cimplify-quantity-increment": true,
|
|
7871
|
+
className: cn(
|
|
7872
|
+
"w-10 h-10 flex items-center justify-center hover:text-primary transition-colors disabled:opacity-30",
|
|
7873
|
+
classNames?.button
|
|
7874
|
+
),
|
|
7875
|
+
children: "+"
|
|
7876
|
+
}
|
|
7877
|
+
)
|
|
7878
|
+
]
|
|
7879
|
+
}
|
|
7880
|
+
);
|
|
7854
7881
|
}
|
|
7855
7882
|
|
|
7856
7883
|
// src/utils/variant.ts
|
|
@@ -7896,7 +7923,8 @@ function VariantSelector({
|
|
|
7896
7923
|
selectedVariantId,
|
|
7897
7924
|
onVariantChange,
|
|
7898
7925
|
productName,
|
|
7899
|
-
className
|
|
7926
|
+
className,
|
|
7927
|
+
classNames
|
|
7900
7928
|
}) {
|
|
7901
7929
|
const [axisSelections, setAxisSelections] = React3.useState({});
|
|
7902
7930
|
const initialized = React3.useRef(false);
|
|
@@ -7936,33 +7964,59 @@ function VariantSelector({
|
|
|
7936
7964
|
}
|
|
7937
7965
|
const basePriceNum = basePrice != null ? parsePrice(basePrice) : 0;
|
|
7938
7966
|
if (variantAxes && variantAxes.length > 0) {
|
|
7939
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-variant-selector": true, className, children: variantAxes.map((axis) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-variant-axis": true, children: [
|
|
7940
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
"
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7967
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-variant-selector": true, className: cn("space-y-5", className, classNames?.root), children: variantAxes.map((axis) => /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-variant-axis": true, children: [
|
|
7968
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7969
|
+
"label",
|
|
7970
|
+
{
|
|
7971
|
+
"data-cimplify-variant-axis-label": true,
|
|
7972
|
+
className: cn("block text-xs font-medium uppercase tracking-wider text-muted-foreground mb-3", classNames?.axisLabel),
|
|
7973
|
+
children: axis.name
|
|
7974
|
+
}
|
|
7975
|
+
),
|
|
7976
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7977
|
+
"div",
|
|
7978
|
+
{
|
|
7979
|
+
"data-cimplify-variant-axis-options": true,
|
|
7980
|
+
className: cn("flex flex-wrap gap-2", classNames?.axisOptions),
|
|
7981
|
+
children: axis.values.map((value) => {
|
|
7982
|
+
const isSelected = axisSelections[axis.id] === value.id;
|
|
7983
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7984
|
+
"button",
|
|
7985
|
+
{
|
|
7986
|
+
type: "button",
|
|
7987
|
+
"aria-selected": isSelected,
|
|
7988
|
+
onClick: () => {
|
|
7989
|
+
setAxisSelections((prev) => ({
|
|
7990
|
+
...prev,
|
|
7991
|
+
[axis.id]: value.id
|
|
7992
|
+
}));
|
|
7993
|
+
},
|
|
7994
|
+
"data-cimplify-variant-option": true,
|
|
7995
|
+
"data-selected": isSelected || void 0,
|
|
7996
|
+
className: cn(
|
|
7997
|
+
"px-4 py-2 border text-sm font-medium transition-colors border-border hover:border-primary/50",
|
|
7998
|
+
isSelected && "bg-primary text-primary-foreground border-primary",
|
|
7999
|
+
isSelected ? classNames?.optionSelected : classNames?.option
|
|
8000
|
+
),
|
|
8001
|
+
children: value.name
|
|
8002
|
+
},
|
|
8003
|
+
value.id
|
|
8004
|
+
);
|
|
8005
|
+
})
|
|
8006
|
+
}
|
|
8007
|
+
)
|
|
7961
8008
|
] }, axis.id)) });
|
|
7962
8009
|
}
|
|
7963
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-variant-selector": true, className, children: [
|
|
7964
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7965
|
-
|
|
8010
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-variant-selector": true, className: cn("space-y-5", className, classNames?.root), children: [
|
|
8011
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8012
|
+
"label",
|
|
8013
|
+
{
|
|
8014
|
+
"data-cimplify-variant-list-label": true,
|
|
8015
|
+
className: cn("block text-xs font-medium uppercase tracking-wider text-muted-foreground mb-3", classNames?.listLabel),
|
|
8016
|
+
children: "Options"
|
|
8017
|
+
}
|
|
8018
|
+
),
|
|
8019
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-variant-list": true, className: cn("space-y-2", classNames?.list), children: variants.map((variant) => {
|
|
7966
8020
|
const isSelected = selectedVariantId === variant.id;
|
|
7967
8021
|
const adjustment = parsePrice(variant.price_adjustment);
|
|
7968
8022
|
const effectivePrice = basePriceNum + adjustment;
|
|
@@ -7974,14 +8028,36 @@ function VariantSelector({
|
|
|
7974
8028
|
onClick: () => onVariantChange(variant.id, variant),
|
|
7975
8029
|
"data-cimplify-variant-option": true,
|
|
7976
8030
|
"data-selected": isSelected || void 0,
|
|
8031
|
+
className: cn(
|
|
8032
|
+
"w-full flex items-center justify-between px-4 py-3 border transition-colors border-border hover:border-primary/50",
|
|
8033
|
+
isSelected && "bg-primary/5 border-primary",
|
|
8034
|
+
isSelected ? classNames?.optionSelected : classNames?.option
|
|
8035
|
+
),
|
|
7977
8036
|
children: [
|
|
7978
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
8037
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8038
|
+
"span",
|
|
8039
|
+
{
|
|
8040
|
+
"data-cimplify-variant-name": true,
|
|
8041
|
+
className: cn("font-medium", isSelected && "text-primary", classNames?.name),
|
|
8042
|
+
children: getVariantDisplayName(variant, productName)
|
|
8043
|
+
}
|
|
8044
|
+
),
|
|
8045
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-variant-pricing": true, className: cn("text-sm", classNames?.pricing), children: [
|
|
8046
|
+
adjustment !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8047
|
+
"span",
|
|
8048
|
+
{
|
|
8049
|
+
"data-cimplify-variant-adjustment": true,
|
|
8050
|
+
className: cn(
|
|
8051
|
+
adjustment > 0 ? "text-muted-foreground" : "text-green-600",
|
|
8052
|
+
classNames?.adjustment
|
|
8053
|
+
),
|
|
8054
|
+
children: [
|
|
8055
|
+
adjustment > 0 ? "+" : "",
|
|
8056
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: variant.price_adjustment })
|
|
8057
|
+
]
|
|
8058
|
+
}
|
|
8059
|
+
),
|
|
8060
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: effectivePrice, className: "text-muted-foreground" })
|
|
7985
8061
|
] })
|
|
7986
8062
|
]
|
|
7987
8063
|
},
|
|
@@ -7994,7 +8070,8 @@ function AddOnSelector({
|
|
|
7994
8070
|
addOns,
|
|
7995
8071
|
selectedOptions,
|
|
7996
8072
|
onOptionsChange,
|
|
7997
|
-
className
|
|
8073
|
+
className,
|
|
8074
|
+
classNames
|
|
7998
8075
|
}) {
|
|
7999
8076
|
const isOptionSelected = React3.useCallback(
|
|
8000
8077
|
(optionId) => selectedOptions.includes(optionId),
|
|
@@ -8032,49 +8109,118 @@ function AddOnSelector({
|
|
|
8032
8109
|
if (!addOns || addOns.length === 0) {
|
|
8033
8110
|
return null;
|
|
8034
8111
|
}
|
|
8035
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-addon-selector": true, className, children: addOns.map((addOn) => {
|
|
8112
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-addon-selector": true, className: cn("space-y-6", className, classNames?.root), children: addOns.map((addOn) => {
|
|
8036
8113
|
const currentSelections = selectedOptions.filter(
|
|
8037
8114
|
(id) => addOn.options.some((o) => o.id === id)
|
|
8038
8115
|
).length;
|
|
8039
8116
|
const minMet = !addOn.min_selections || currentSelections >= addOn.min_selections;
|
|
8040
8117
|
const isSingleSelect = addOn.is_mutually_exclusive || !addOn.is_multiple_allowed;
|
|
8041
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8118
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8119
|
+
"div",
|
|
8120
|
+
{
|
|
8121
|
+
"data-cimplify-addon-group": true,
|
|
8122
|
+
className: cn("border border-border p-5", classNames?.group),
|
|
8123
|
+
children: [
|
|
8124
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8125
|
+
"div",
|
|
8126
|
+
{
|
|
8127
|
+
"data-cimplify-addon-header": true,
|
|
8128
|
+
className: cn("flex items-center justify-between mb-4", classNames?.header),
|
|
8129
|
+
children: [
|
|
8130
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8131
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8132
|
+
"span",
|
|
8133
|
+
{
|
|
8134
|
+
"data-cimplify-addon-name": true,
|
|
8135
|
+
className: cn("text-xs font-medium uppercase tracking-wider text-muted-foreground", classNames?.name),
|
|
8136
|
+
children: [
|
|
8137
|
+
addOn.name,
|
|
8138
|
+
addOn.is_required && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8139
|
+
"span",
|
|
8140
|
+
{
|
|
8141
|
+
"data-cimplify-addon-required": true,
|
|
8142
|
+
className: cn("text-destructive ml-1", classNames?.required),
|
|
8143
|
+
children: [
|
|
8144
|
+
" ",
|
|
8145
|
+
"*"
|
|
8146
|
+
]
|
|
8147
|
+
}
|
|
8148
|
+
)
|
|
8149
|
+
]
|
|
8150
|
+
}
|
|
8151
|
+
),
|
|
8152
|
+
(addOn.min_selections || addOn.max_selections) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8153
|
+
"span",
|
|
8154
|
+
{
|
|
8155
|
+
"data-cimplify-addon-constraint": true,
|
|
8156
|
+
className: cn("text-xs text-muted-foreground/70 mt-1", classNames?.constraint),
|
|
8157
|
+
children: addOn.min_selections && addOn.max_selections ? `Choose ${addOn.min_selections}\u2013${addOn.max_selections}` : addOn.min_selections ? `Choose at least ${addOn.min_selections}` : `Choose up to ${addOn.max_selections}`
|
|
8158
|
+
}
|
|
8159
|
+
)
|
|
8160
|
+
] }),
|
|
8161
|
+
!minMet && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8162
|
+
"span",
|
|
8163
|
+
{
|
|
8164
|
+
"data-cimplify-addon-validation": true,
|
|
8165
|
+
className: cn("text-xs text-destructive font-medium", classNames?.validation),
|
|
8166
|
+
children: "Required"
|
|
8167
|
+
}
|
|
8168
|
+
)
|
|
8169
|
+
]
|
|
8170
|
+
}
|
|
8171
|
+
),
|
|
8172
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8173
|
+
"div",
|
|
8174
|
+
{
|
|
8175
|
+
"data-cimplify-addon-options": true,
|
|
8176
|
+
className: cn("space-y-1", classNames?.options),
|
|
8177
|
+
children: addOn.options.map((option) => {
|
|
8178
|
+
const isSelected = isOptionSelected(option.id);
|
|
8179
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8180
|
+
"button",
|
|
8181
|
+
{
|
|
8182
|
+
type: "button",
|
|
8183
|
+
role: isSingleSelect ? "radio" : "checkbox",
|
|
8184
|
+
"aria-checked": isSelected,
|
|
8185
|
+
onClick: () => toggleOption(addOn, option.id),
|
|
8186
|
+
"data-cimplify-addon-option": true,
|
|
8187
|
+
"data-selected": isSelected || void 0,
|
|
8188
|
+
className: cn(
|
|
8189
|
+
"w-full flex items-center gap-3 px-4 py-3 border transition-colors text-left border-transparent hover:bg-muted/50",
|
|
8190
|
+
isSelected && "bg-primary/5 border-primary",
|
|
8191
|
+
isSelected ? classNames?.optionSelected : classNames?.option
|
|
8192
|
+
),
|
|
8193
|
+
children: [
|
|
8194
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8195
|
+
"span",
|
|
8196
|
+
{
|
|
8197
|
+
"data-cimplify-addon-option-name": true,
|
|
8198
|
+
className: cn(
|
|
8199
|
+
"flex-1 min-w-0 text-sm font-medium",
|
|
8200
|
+
isSelected && "text-primary",
|
|
8201
|
+
classNames?.optionName
|
|
8202
|
+
),
|
|
8203
|
+
children: option.name
|
|
8204
|
+
}
|
|
8205
|
+
),
|
|
8206
|
+
option.default_price != null && parsePrice(option.default_price) !== 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8207
|
+
Price,
|
|
8208
|
+
{
|
|
8209
|
+
amount: option.default_price,
|
|
8210
|
+
prefix: "+"
|
|
8211
|
+
}
|
|
8212
|
+
)
|
|
8213
|
+
]
|
|
8214
|
+
},
|
|
8215
|
+
option.id
|
|
8216
|
+
);
|
|
8217
|
+
})
|
|
8218
|
+
}
|
|
8219
|
+
)
|
|
8220
|
+
]
|
|
8221
|
+
},
|
|
8222
|
+
addOn.id
|
|
8223
|
+
);
|
|
8078
8224
|
}) });
|
|
8079
8225
|
}
|
|
8080
8226
|
function BundleSelector({
|
|
@@ -8085,7 +8231,8 @@ function BundleSelector({
|
|
|
8085
8231
|
onSelectionsChange,
|
|
8086
8232
|
onPriceChange,
|
|
8087
8233
|
onReady,
|
|
8088
|
-
className
|
|
8234
|
+
className,
|
|
8235
|
+
classNames
|
|
8089
8236
|
}) {
|
|
8090
8237
|
const [variantChoices, setVariantChoices] = React3.useState({});
|
|
8091
8238
|
const lastComponentIds = React3.useRef("");
|
|
@@ -8146,25 +8293,47 @@ function BundleSelector({
|
|
|
8146
8293
|
if (components.length === 0) {
|
|
8147
8294
|
return null;
|
|
8148
8295
|
}
|
|
8149
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bundle-selector": true, className, children: [
|
|
8150
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8151
|
-
|
|
8296
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-bundle-selector": true, className: cn("space-y-4", className, classNames?.root), children: [
|
|
8297
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8298
|
+
"span",
|
|
8299
|
+
{
|
|
8300
|
+
"data-cimplify-bundle-heading": true,
|
|
8301
|
+
className: cn("text-xs font-medium uppercase tracking-wider text-muted-foreground", classNames?.heading),
|
|
8302
|
+
children: "Included in this bundle"
|
|
8303
|
+
}
|
|
8304
|
+
),
|
|
8305
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-cimplify-bundle-components": true, className: cn("space-y-3", classNames?.components), children: components.map((comp) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
8152
8306
|
BundleComponentCard,
|
|
8153
8307
|
{
|
|
8154
8308
|
component: comp,
|
|
8155
8309
|
selectedVariantId: variantChoices[comp.id],
|
|
8156
|
-
onVariantChange: (variantId) => handleVariantChange(comp.id, variantId)
|
|
8310
|
+
onVariantChange: (variantId) => handleVariantChange(comp.id, variantId),
|
|
8311
|
+
classNames
|
|
8157
8312
|
},
|
|
8158
8313
|
comp.id
|
|
8159
8314
|
)) }),
|
|
8160
|
-
bundlePrice && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8315
|
+
bundlePrice && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8316
|
+
"div",
|
|
8317
|
+
{
|
|
8318
|
+
"data-cimplify-bundle-summary": true,
|
|
8319
|
+
className: cn("border-t border-border pt-4 flex justify-between text-sm", classNames?.summary),
|
|
8320
|
+
children: [
|
|
8321
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Bundle price" }),
|
|
8322
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: bundlePrice, className: "font-medium text-primary" })
|
|
8323
|
+
]
|
|
8324
|
+
}
|
|
8325
|
+
),
|
|
8326
|
+
discountValue && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8327
|
+
"div",
|
|
8328
|
+
{
|
|
8329
|
+
"data-cimplify-bundle-savings": true,
|
|
8330
|
+
className: cn("flex justify-between text-sm", classNames?.savings),
|
|
8331
|
+
children: [
|
|
8332
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "You save" }),
|
|
8333
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: discountValue, className: "text-green-600 font-medium" })
|
|
8334
|
+
]
|
|
8335
|
+
}
|
|
8336
|
+
)
|
|
8168
8337
|
] });
|
|
8169
8338
|
}
|
|
8170
8339
|
function getComponentPrice(component, selectedVariantId) {
|
|
@@ -8182,47 +8351,95 @@ function getComponentPrice(component, selectedVariantId) {
|
|
|
8182
8351
|
function BundleComponentCard({
|
|
8183
8352
|
component,
|
|
8184
8353
|
selectedVariantId,
|
|
8185
|
-
onVariantChange
|
|
8354
|
+
onVariantChange,
|
|
8355
|
+
classNames
|
|
8186
8356
|
}) {
|
|
8187
8357
|
const showVariantPicker = component.allow_variant_choice && component.available_variants.length > 1;
|
|
8188
8358
|
const displayPrice = React3.useMemo(
|
|
8189
8359
|
() => getComponentPrice(component, selectedVariantId),
|
|
8190
8360
|
[component, selectedVariantId]
|
|
8191
8361
|
);
|
|
8192
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8362
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8363
|
+
"div",
|
|
8364
|
+
{
|
|
8365
|
+
"data-cimplify-bundle-component": true,
|
|
8366
|
+
className: cn("border border-border p-4", classNames?.component),
|
|
8367
|
+
children: [
|
|
8368
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8369
|
+
"div",
|
|
8370
|
+
{
|
|
8371
|
+
"data-cimplify-bundle-component-header": true,
|
|
8372
|
+
className: cn("flex items-start justify-between gap-3", classNames?.componentHeader),
|
|
8373
|
+
children: [
|
|
8374
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8375
|
+
component.quantity > 1 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8376
|
+
"span",
|
|
8377
|
+
{
|
|
8378
|
+
"data-cimplify-bundle-component-qty": true,
|
|
8379
|
+
className: cn("text-xs font-medium text-primary bg-primary/10 px-1.5 py-0.5", classNames?.componentQty),
|
|
8380
|
+
children: [
|
|
8381
|
+
"\xD7",
|
|
8382
|
+
component.quantity
|
|
8383
|
+
]
|
|
8384
|
+
}
|
|
8385
|
+
),
|
|
8386
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8387
|
+
"span",
|
|
8388
|
+
{
|
|
8389
|
+
"data-cimplify-bundle-component-name": true,
|
|
8390
|
+
className: cn("font-medium text-sm", classNames?.componentName),
|
|
8391
|
+
children: component.product_name
|
|
8392
|
+
}
|
|
8393
|
+
)
|
|
8394
|
+
] }),
|
|
8395
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: displayPrice })
|
|
8396
|
+
]
|
|
8397
|
+
}
|
|
8398
|
+
),
|
|
8399
|
+
showVariantPicker && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8400
|
+
"div",
|
|
8401
|
+
{
|
|
8402
|
+
"data-cimplify-bundle-variant-picker": true,
|
|
8403
|
+
className: cn("mt-3 flex flex-wrap gap-2", classNames?.variantPicker),
|
|
8404
|
+
children: component.available_variants.map((variant) => {
|
|
8405
|
+
const isSelected = selectedVariantId === variant.id;
|
|
8406
|
+
const adjustment = parsePrice(variant.price_adjustment);
|
|
8407
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8408
|
+
"button",
|
|
8409
|
+
{
|
|
8410
|
+
type: "button",
|
|
8411
|
+
"aria-pressed": isSelected,
|
|
8412
|
+
onClick: () => onVariantChange(variant.id),
|
|
8413
|
+
"data-cimplify-bundle-variant-option": true,
|
|
8414
|
+
"data-selected": isSelected || void 0,
|
|
8415
|
+
className: cn(
|
|
8416
|
+
"px-3 py-1.5 border text-xs font-medium transition-colors border-border hover:border-primary/50",
|
|
8417
|
+
isSelected && "bg-primary text-primary-foreground border-primary",
|
|
8418
|
+
isSelected ? classNames?.variantOptionSelected : classNames?.variantOption
|
|
8419
|
+
),
|
|
8420
|
+
children: [
|
|
8421
|
+
variant.display_name,
|
|
8422
|
+
adjustment !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8423
|
+
"span",
|
|
8424
|
+
{
|
|
8425
|
+
"data-cimplify-bundle-variant-adjustment": true,
|
|
8426
|
+
className: cn("ml-1 opacity-70", classNames?.variantAdjustment),
|
|
8427
|
+
children: [
|
|
8428
|
+
adjustment > 0 ? "+" : "",
|
|
8429
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: variant.price_adjustment })
|
|
8430
|
+
]
|
|
8431
|
+
}
|
|
8432
|
+
)
|
|
8433
|
+
]
|
|
8434
|
+
},
|
|
8435
|
+
variant.id
|
|
8436
|
+
);
|
|
8437
|
+
})
|
|
8438
|
+
}
|
|
8439
|
+
)
|
|
8440
|
+
]
|
|
8441
|
+
}
|
|
8442
|
+
);
|
|
8226
8443
|
}
|
|
8227
8444
|
function CompositeSelector({
|
|
8228
8445
|
compositeId,
|
|
@@ -8231,7 +8448,8 @@ function CompositeSelector({
|
|
|
8231
8448
|
onPriceChange,
|
|
8232
8449
|
onReady,
|
|
8233
8450
|
skipPriceFetch,
|
|
8234
|
-
className
|
|
8451
|
+
className,
|
|
8452
|
+
classNames
|
|
8235
8453
|
}) {
|
|
8236
8454
|
const { client } = useCimplify();
|
|
8237
8455
|
const [groupSelections, setGroupSelections] = React3.useState({});
|
|
@@ -8351,114 +8569,261 @@ function CompositeSelector({
|
|
|
8351
8569
|
if (groups.length === 0) {
|
|
8352
8570
|
return null;
|
|
8353
8571
|
}
|
|
8354
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-selector": true, className, children: [
|
|
8572
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-selector": true, className: cn("space-y-6", className, classNames?.root), children: [
|
|
8355
8573
|
[...groups].sort((a, b) => a.display_order - b.display_order).map((group) => {
|
|
8356
8574
|
const groupSels = groupSelections[group.id] || {};
|
|
8357
8575
|
const totalSelected = Object.values(groupSels).reduce((sum, q) => sum + q, 0);
|
|
8358
8576
|
const minMet = totalSelected >= group.min_selections;
|
|
8359
8577
|
const isSingleSelect = group.max_selections === 1;
|
|
8360
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
{
|
|
8375
|
-
"data-cimplify-composite-components": true,
|
|
8376
|
-
role: isSingleSelect ? "radiogroup" : "group",
|
|
8377
|
-
"aria-label": group.name,
|
|
8378
|
-
children: group.components.filter((c) => c.is_available && !c.is_archived).sort((a, b) => a.display_order - b.display_order).map((component) => {
|
|
8379
|
-
const qty = groupSels[component.id] || 0;
|
|
8380
|
-
const isSelected = qty > 0;
|
|
8381
|
-
const displayName = component.display_name || component.id;
|
|
8382
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8383
|
-
"button",
|
|
8384
|
-
{
|
|
8385
|
-
type: "button",
|
|
8386
|
-
role: isSingleSelect ? "radio" : "checkbox",
|
|
8387
|
-
"aria-checked": isSelected,
|
|
8388
|
-
onClick: () => toggleComponent(group, component),
|
|
8389
|
-
"data-cimplify-composite-component": true,
|
|
8390
|
-
"data-selected": isSelected || void 0,
|
|
8391
|
-
children: [
|
|
8392
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-composite-component-info": true, children: [
|
|
8393
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-component-name": true, children: displayName }),
|
|
8394
|
-
component.is_popular && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-badge": "popular", children: "Popular" }),
|
|
8395
|
-
component.is_premium && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-badge": "premium", children: "Premium" }),
|
|
8396
|
-
component.display_description && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-cimplify-composite-component-description": true, children: component.display_description }),
|
|
8397
|
-
component.calories != null && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-cimplify-composite-component-calories": true, children: [
|
|
8398
|
-
component.calories,
|
|
8399
|
-
" cal"
|
|
8400
|
-
] })
|
|
8401
|
-
] }),
|
|
8402
|
-
group.allow_quantity && isSelected && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8578
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8579
|
+
"div",
|
|
8580
|
+
{
|
|
8581
|
+
"data-cimplify-composite-group": true,
|
|
8582
|
+
className: cn("border border-border p-5", classNames?.group),
|
|
8583
|
+
children: [
|
|
8584
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8585
|
+
"div",
|
|
8586
|
+
{
|
|
8587
|
+
"data-cimplify-composite-group-header": true,
|
|
8588
|
+
className: cn("flex items-center justify-between mb-4", classNames?.groupHeader),
|
|
8589
|
+
children: [
|
|
8590
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
8591
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8403
8592
|
"span",
|
|
8404
8593
|
{
|
|
8405
|
-
"data-cimplify-composite-
|
|
8406
|
-
|
|
8594
|
+
"data-cimplify-composite-group-name": true,
|
|
8595
|
+
className: cn("text-xs font-medium uppercase tracking-wider text-muted-foreground", classNames?.groupName),
|
|
8407
8596
|
children: [
|
|
8408
|
-
|
|
8409
|
-
|
|
8597
|
+
group.name,
|
|
8598
|
+
group.min_selections > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8599
|
+
"span",
|
|
8410
8600
|
{
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: qty }),
|
|
8418
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8419
|
-
"button",
|
|
8420
|
-
{
|
|
8421
|
-
type: "button",
|
|
8422
|
-
onClick: () => updateQuantity(group, component.id, 1),
|
|
8423
|
-
"aria-label": `Increase ${displayName} quantity`,
|
|
8424
|
-
children: "+"
|
|
8601
|
+
"data-cimplify-composite-required": true,
|
|
8602
|
+
className: cn("text-destructive ml-1", classNames?.required),
|
|
8603
|
+
children: [
|
|
8604
|
+
" ",
|
|
8605
|
+
"*"
|
|
8606
|
+
]
|
|
8425
8607
|
}
|
|
8426
8608
|
)
|
|
8427
8609
|
]
|
|
8428
8610
|
}
|
|
8429
8611
|
),
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8612
|
+
group.description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8613
|
+
"span",
|
|
8614
|
+
{
|
|
8615
|
+
"data-cimplify-composite-group-description": true,
|
|
8616
|
+
className: cn("text-xs text-muted-foreground/70 mt-0.5", classNames?.groupDescription),
|
|
8617
|
+
children: group.description
|
|
8618
|
+
}
|
|
8619
|
+
),
|
|
8620
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8621
|
+
"span",
|
|
8622
|
+
{
|
|
8623
|
+
"data-cimplify-composite-group-constraint": true,
|
|
8624
|
+
className: cn("text-xs text-muted-foreground/70 mt-1", classNames?.groupConstraint),
|
|
8625
|
+
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"
|
|
8626
|
+
}
|
|
8627
|
+
)
|
|
8628
|
+
] }),
|
|
8629
|
+
!minMet && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8630
|
+
"span",
|
|
8631
|
+
{
|
|
8632
|
+
"data-cimplify-composite-validation": true,
|
|
8633
|
+
className: cn("text-xs text-destructive font-medium", classNames?.validation),
|
|
8634
|
+
children: "Required"
|
|
8635
|
+
}
|
|
8636
|
+
)
|
|
8637
|
+
]
|
|
8638
|
+
}
|
|
8639
|
+
),
|
|
8640
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8641
|
+
"div",
|
|
8642
|
+
{
|
|
8643
|
+
"data-cimplify-composite-components": true,
|
|
8644
|
+
role: isSingleSelect ? "radiogroup" : "group",
|
|
8645
|
+
"aria-label": group.name,
|
|
8646
|
+
className: cn("space-y-1", classNames?.components),
|
|
8647
|
+
children: group.components.filter((c) => c.is_available && !c.is_archived).sort((a, b) => a.display_order - b.display_order).map((component) => {
|
|
8648
|
+
const qty = groupSels[component.id] || 0;
|
|
8649
|
+
const isSelected = qty > 0;
|
|
8650
|
+
const displayName = component.display_name || component.id;
|
|
8651
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8652
|
+
"button",
|
|
8653
|
+
{
|
|
8654
|
+
type: "button",
|
|
8655
|
+
role: isSingleSelect ? "radio" : "checkbox",
|
|
8656
|
+
"aria-checked": isSelected,
|
|
8657
|
+
onClick: () => toggleComponent(group, component),
|
|
8658
|
+
"data-cimplify-composite-component": true,
|
|
8659
|
+
"data-selected": isSelected || void 0,
|
|
8660
|
+
className: cn(
|
|
8661
|
+
"w-full flex items-center gap-3 px-4 py-3 border transition-colors text-left border-transparent hover:bg-muted/50",
|
|
8662
|
+
isSelected && "bg-primary/5 border-primary",
|
|
8663
|
+
isSelected ? classNames?.componentSelected : classNames?.component
|
|
8664
|
+
),
|
|
8665
|
+
children: [
|
|
8666
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8667
|
+
"div",
|
|
8668
|
+
{
|
|
8669
|
+
"data-cimplify-composite-component-info": true,
|
|
8670
|
+
className: cn("flex-1 min-w-0", classNames?.componentInfo),
|
|
8671
|
+
children: [
|
|
8672
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8673
|
+
"span",
|
|
8674
|
+
{
|
|
8675
|
+
"data-cimplify-composite-component-name": true,
|
|
8676
|
+
className: cn("text-sm font-medium", isSelected && "text-primary", classNames?.componentName),
|
|
8677
|
+
children: displayName
|
|
8678
|
+
}
|
|
8679
|
+
),
|
|
8680
|
+
component.is_popular && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8681
|
+
"span",
|
|
8682
|
+
{
|
|
8683
|
+
"data-cimplify-composite-badge": "popular",
|
|
8684
|
+
className: cn("text-[10px] uppercase tracking-wider text-primary font-medium", classNames?.badgePopular),
|
|
8685
|
+
children: "Popular"
|
|
8686
|
+
}
|
|
8687
|
+
),
|
|
8688
|
+
component.is_premium && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8689
|
+
"span",
|
|
8690
|
+
{
|
|
8691
|
+
"data-cimplify-composite-badge": "premium",
|
|
8692
|
+
className: cn("text-[10px] uppercase tracking-wider text-amber-600 font-medium", classNames?.badgePremium),
|
|
8693
|
+
children: "Premium"
|
|
8694
|
+
}
|
|
8695
|
+
),
|
|
8696
|
+
component.display_description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8697
|
+
"span",
|
|
8698
|
+
{
|
|
8699
|
+
"data-cimplify-composite-component-description": true,
|
|
8700
|
+
className: cn("text-xs text-muted-foreground truncate", classNames?.componentDescription),
|
|
8701
|
+
children: component.display_description
|
|
8702
|
+
}
|
|
8703
|
+
),
|
|
8704
|
+
component.calories != null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8705
|
+
"span",
|
|
8706
|
+
{
|
|
8707
|
+
"data-cimplify-composite-component-calories": true,
|
|
8708
|
+
className: cn("text-xs text-muted-foreground/60", classNames?.componentCalories),
|
|
8709
|
+
children: [
|
|
8710
|
+
component.calories,
|
|
8711
|
+
" cal"
|
|
8712
|
+
]
|
|
8713
|
+
}
|
|
8714
|
+
)
|
|
8715
|
+
]
|
|
8716
|
+
}
|
|
8717
|
+
),
|
|
8718
|
+
group.allow_quantity && isSelected && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8719
|
+
"span",
|
|
8720
|
+
{
|
|
8721
|
+
"data-cimplify-composite-qty": true,
|
|
8722
|
+
onClick: (e) => e.stopPropagation(),
|
|
8723
|
+
className: cn("flex items-center gap-2", classNames?.qty),
|
|
8724
|
+
children: [
|
|
8725
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8726
|
+
"button",
|
|
8727
|
+
{
|
|
8728
|
+
type: "button",
|
|
8729
|
+
onClick: () => updateQuantity(group, component.id, -1),
|
|
8730
|
+
"aria-label": `Decrease ${displayName} quantity`,
|
|
8731
|
+
className: cn("w-6 h-6 border border-border flex items-center justify-center text-xs hover:bg-muted", classNames?.qtyButton),
|
|
8732
|
+
children: "\u2212"
|
|
8733
|
+
}
|
|
8734
|
+
),
|
|
8735
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm font-medium w-4 text-center", classNames?.qtyValue), children: qty }),
|
|
8736
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8737
|
+
"button",
|
|
8738
|
+
{
|
|
8739
|
+
type: "button",
|
|
8740
|
+
onClick: () => updateQuantity(group, component.id, 1),
|
|
8741
|
+
"aria-label": `Increase ${displayName} quantity`,
|
|
8742
|
+
className: cn("w-6 h-6 border border-border flex items-center justify-center text-xs hover:bg-muted", classNames?.qtyButton),
|
|
8743
|
+
children: "+"
|
|
8744
|
+
}
|
|
8745
|
+
)
|
|
8746
|
+
]
|
|
8747
|
+
}
|
|
8748
|
+
),
|
|
8749
|
+
component.price != null && parsePrice(component.price) !== 0 && /* @__PURE__ */ jsxRuntime.jsx(Price, { amount: component.price, prefix: "+" })
|
|
8750
|
+
]
|
|
8751
|
+
},
|
|
8752
|
+
component.id
|
|
8753
|
+
);
|
|
8754
|
+
})
|
|
8755
|
+
}
|
|
8756
|
+
)
|
|
8757
|
+
]
|
|
8758
|
+
},
|
|
8759
|
+
group.id
|
|
8760
|
+
);
|
|
8439
8761
|
}),
|
|
8440
|
-
priceResult && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8762
|
+
priceResult && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8763
|
+
"div",
|
|
8764
|
+
{
|
|
8765
|
+
"data-cimplify-composite-summary": true,
|
|
8766
|
+
className: cn("border-t border-border pt-4 space-y-1 text-sm", classNames?.summary),
|
|
8767
|
+
children: [
|
|
8768
|
+
parsePrice(priceResult.base_price) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8769
|
+
"div",
|
|
8770
|
+
{
|
|
8771
|
+
"data-cimplify-composite-summary-line": true,
|
|
8772
|
+
className: cn("flex justify-between text-muted-foreground", classNames?.summaryLine),
|
|
8773
|
+
children: [
|
|
8774
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Base" }),
|
|
8775
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: priceResult.base_price })
|
|
8776
|
+
]
|
|
8777
|
+
}
|
|
8778
|
+
),
|
|
8779
|
+
parsePrice(priceResult.components_total) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8780
|
+
"div",
|
|
8781
|
+
{
|
|
8782
|
+
"data-cimplify-composite-summary-line": true,
|
|
8783
|
+
className: cn("flex justify-between text-muted-foreground", classNames?.summaryLine),
|
|
8784
|
+
children: [
|
|
8785
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Selections" }),
|
|
8786
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: priceResult.components_total })
|
|
8787
|
+
]
|
|
8788
|
+
}
|
|
8789
|
+
),
|
|
8790
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8791
|
+
"div",
|
|
8792
|
+
{
|
|
8793
|
+
"data-cimplify-composite-summary-total": true,
|
|
8794
|
+
className: cn("flex justify-between font-medium pt-1 border-t border-border", classNames?.summaryTotal),
|
|
8795
|
+
children: [
|
|
8796
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Total" }),
|
|
8797
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: priceResult.final_price, className: "text-primary" })
|
|
8798
|
+
]
|
|
8799
|
+
}
|
|
8800
|
+
)
|
|
8801
|
+
]
|
|
8802
|
+
}
|
|
8803
|
+
),
|
|
8804
|
+
isPriceLoading && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8805
|
+
"div",
|
|
8806
|
+
{
|
|
8807
|
+
"data-cimplify-composite-calculating": true,
|
|
8808
|
+
className: cn("flex items-center gap-2 text-sm text-muted-foreground", classNames?.calculating),
|
|
8809
|
+
children: "Calculating price..."
|
|
8810
|
+
}
|
|
8811
|
+
),
|
|
8812
|
+
priceError && !isPriceLoading && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8813
|
+
"div",
|
|
8814
|
+
{
|
|
8815
|
+
"data-cimplify-composite-price-error": true,
|
|
8816
|
+
className: cn("text-sm text-destructive", classNames?.priceError),
|
|
8817
|
+
children: "Unable to calculate price"
|
|
8818
|
+
}
|
|
8819
|
+
)
|
|
8456
8820
|
] });
|
|
8457
8821
|
}
|
|
8458
8822
|
function ProductCustomizer({
|
|
8459
8823
|
product,
|
|
8460
8824
|
onAddToCart,
|
|
8461
|
-
className
|
|
8825
|
+
className,
|
|
8826
|
+
classNames
|
|
8462
8827
|
}) {
|
|
8463
8828
|
const [quantity, setQuantity] = React3.useState(1);
|
|
8464
8829
|
const [isAdded, setIsAdded] = React3.useState(false);
|
|
@@ -8604,7 +8969,7 @@ function ProductCustomizer({
|
|
|
8604
8969
|
setIsSubmitting(false);
|
|
8605
8970
|
}
|
|
8606
8971
|
};
|
|
8607
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customizer": true, className, children: [
|
|
8972
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-customizer": true, className: cn("space-y-6", className, classNames?.root), children: [
|
|
8608
8973
|
isComposite && product.groups && product.composite_id && /* @__PURE__ */ jsxRuntime.jsx(
|
|
8609
8974
|
CompositeSelector,
|
|
8610
8975
|
{
|
|
@@ -8646,31 +9011,51 @@ function ProductCustomizer({
|
|
|
8646
9011
|
onOptionsChange: setSelectedAddOnOptionIds
|
|
8647
9012
|
}
|
|
8648
9013
|
),
|
|
8649
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
9014
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9015
|
+
"div",
|
|
9016
|
+
{
|
|
9017
|
+
"data-cimplify-customizer-actions": true,
|
|
9018
|
+
className: cn("flex items-center gap-4 pt-4 border-t border-border", classNames?.actions),
|
|
9019
|
+
children: [
|
|
9020
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9021
|
+
QuantitySelector,
|
|
9022
|
+
{
|
|
9023
|
+
value: quantity,
|
|
9024
|
+
onChange: setQuantity,
|
|
9025
|
+
min: 1
|
|
9026
|
+
}
|
|
9027
|
+
),
|
|
9028
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9029
|
+
"button",
|
|
9030
|
+
{
|
|
9031
|
+
type: "button",
|
|
9032
|
+
onClick: handleAddToCart,
|
|
9033
|
+
disabled: isAdded || isSubmitting || !quoteEnabled,
|
|
9034
|
+
"aria-describedby": !quoteEnabled ? "cimplify-customizer-validation" : void 0,
|
|
9035
|
+
"data-cimplify-customizer-submit": true,
|
|
9036
|
+
className: cn(
|
|
9037
|
+
"flex-1 h-14 text-base bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
9038
|
+
isAdded && classNames?.submitButtonAdded,
|
|
9039
|
+
classNames?.submitButton
|
|
9040
|
+
),
|
|
9041
|
+
children: isAdded ? "Added to Cart" : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9042
|
+
"Add to Cart \xB7 ",
|
|
9043
|
+
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: displayTotalPrice })
|
|
9044
|
+
] })
|
|
9045
|
+
}
|
|
9046
|
+
)
|
|
9047
|
+
]
|
|
9048
|
+
}
|
|
9049
|
+
),
|
|
9050
|
+
!quoteEnabled && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9051
|
+
"p",
|
|
9052
|
+
{
|
|
9053
|
+
id: "cimplify-customizer-validation",
|
|
9054
|
+
"data-cimplify-customizer-validation": true,
|
|
9055
|
+
className: cn("text-sm text-destructive mt-2", classNames?.validation),
|
|
9056
|
+
children: "Please select all required options"
|
|
9057
|
+
}
|
|
9058
|
+
)
|
|
8674
9059
|
] });
|
|
8675
9060
|
}
|
|
8676
9061
|
var ASPECT_STYLES = {
|
|
@@ -8853,9 +9238,6 @@ function CartSummary({
|
|
|
8853
9238
|
)
|
|
8854
9239
|
] }) });
|
|
8855
9240
|
}
|
|
8856
|
-
function cn(...inputs) {
|
|
8857
|
-
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
8858
|
-
}
|
|
8859
9241
|
function AvailabilityBadge({
|
|
8860
9242
|
product,
|
|
8861
9243
|
isAvailable,
|
|
@@ -9793,15 +10175,15 @@ function OrderSummary({
|
|
|
9793
10175
|
] }, item.id)
|
|
9794
10176
|
) }),
|
|
9795
10177
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-totals": true, className: classNames?.totals, children: [
|
|
9796
|
-
order.total_discount != null && order.total_discount !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-discount": true, children: [
|
|
10178
|
+
order.total_discount != null && parsePrice(order.total_discount) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-discount": true, children: [
|
|
9797
10179
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Discount" }),
|
|
9798
10180
|
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.total_discount, prefix: "-" })
|
|
9799
10181
|
] }),
|
|
9800
|
-
order.service_charge != null && order.service_charge !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-service-charge": true, children: [
|
|
10182
|
+
order.service_charge != null && parsePrice(order.service_charge) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-service-charge": true, children: [
|
|
9801
10183
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Service charge" }),
|
|
9802
10184
|
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.service_charge })
|
|
9803
10185
|
] }),
|
|
9804
|
-
order.tax != null && order.tax !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-tax": true, children: [
|
|
10186
|
+
order.tax != null && parsePrice(order.tax) !== 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-cimplify-order-tax": true, children: [
|
|
9805
10187
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Tax" }),
|
|
9806
10188
|
/* @__PURE__ */ jsxRuntime.jsx(Price, { amount: order.tax })
|
|
9807
10189
|
] }),
|