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