@orderingstack/front-components-product-configurator 1.4.2-beta.3 → 1.4.2-beta.5
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/components/DisplayState/DisplayState.d.ts.map +1 -1
- package/dist/components/ProductConfigurator/ProductConfigurator.d.ts.map +1 -1
- package/dist/components/ProductConfigurator/useProductConfigurator.d.ts +1 -0
- package/dist/components/ProductConfigurator/useProductConfigurator.d.ts.map +1 -1
- package/dist/hooks/useEmitFilter.d.ts.map +1 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +24 -10
- package/dist/index.es.js.map +1 -1
- package/dist/utils/filter.d.ts.map +1 -1
- package/dist/utils/setSelected.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -6686,6 +6686,7 @@ function useProductConfigurator(product) {
|
|
|
6686
6686
|
return {
|
|
6687
6687
|
encodedProduct,
|
|
6688
6688
|
initSelected,
|
|
6689
|
+
initFilter,
|
|
6689
6690
|
filter,
|
|
6690
6691
|
setCurrency,
|
|
6691
6692
|
setIsOnSubmittedOnTrue,
|
|
@@ -6851,16 +6852,25 @@ var ENotificationType;
|
|
|
6851
6852
|
ENotificationType2["ORDER_UPSELL"] = "OrderUpsell";
|
|
6852
6853
|
})(ENotificationType || (ENotificationType = {}));
|
|
6853
6854
|
const validateProductFilter = (product, stateFilter) => {
|
|
6855
|
+
var _a;
|
|
6854
6856
|
const { filter: productFilters = {}, fltCtx = "" } = product;
|
|
6855
6857
|
const stateFiltersWithFltCtx = stateFilter[fltCtx];
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
const commonFilters = Object.keys(stateFiltersWithFltCtx).filter(
|
|
6859
|
-
(filterName) => Object.keys(productFilters).includes(filterName) && productFilters[filterName].includes(stateFiltersWithFltCtx[filterName])
|
|
6860
|
-
);
|
|
6861
|
-
return commonFilters.length > 0;
|
|
6858
|
+
if (!productFilters || !Object.keys(productFilters).length || !stateFiltersWithFltCtx) {
|
|
6859
|
+
return true;
|
|
6862
6860
|
}
|
|
6863
|
-
|
|
6861
|
+
const commonFilters = (_a = Object.keys(stateFiltersWithFltCtx)) == null ? void 0 : _a.filter(
|
|
6862
|
+
(filterName) => {
|
|
6863
|
+
var _a2;
|
|
6864
|
+
const matchingFilters = (_a2 = Object.keys(productFilters == null ? void 0 : productFilters[filterName])) == null ? void 0 : _a2.filter((x2) => {
|
|
6865
|
+
var _a3;
|
|
6866
|
+
if (((_a3 = productFilters == null ? void 0 : productFilters[filterName]) == null ? void 0 : _a3[x2]) === (stateFiltersWithFltCtx == null ? void 0 : stateFiltersWithFltCtx[filterName])) {
|
|
6867
|
+
return true;
|
|
6868
|
+
}
|
|
6869
|
+
});
|
|
6870
|
+
return (matchingFilters == null ? void 0 : matchingFilters.length) > 0;
|
|
6871
|
+
}
|
|
6872
|
+
);
|
|
6873
|
+
return (commonFilters == null ? void 0 : commonFilters.length) > 0;
|
|
6864
6874
|
};
|
|
6865
6875
|
const getProductToChangeInForm = (product, isFilterValidated) => {
|
|
6866
6876
|
const { items, filter } = product;
|
|
@@ -8795,7 +8805,7 @@ function Counter(props) {
|
|
|
8795
8805
|
});
|
|
8796
8806
|
}
|
|
8797
8807
|
function useEmitFilter(product) {
|
|
8798
|
-
const { watch } = useFormContext();
|
|
8808
|
+
const { watch, setValue } = useFormContext();
|
|
8799
8809
|
const setFilter = useStore((state) => state.setFilter);
|
|
8800
8810
|
const { id, selCtx, emit = {}, fltCtx } = product;
|
|
8801
8811
|
const value = watch(`selected.${selCtx}.${id}`);
|
|
@@ -9217,10 +9227,12 @@ const DisplayState = () => {
|
|
|
9217
9227
|
watch
|
|
9218
9228
|
} = useFormContext();
|
|
9219
9229
|
const selected = watch("selected");
|
|
9230
|
+
const filter = watch("filter");
|
|
9220
9231
|
const validationMap = useStore((state) => state.validationMap);
|
|
9221
9232
|
console.log({
|
|
9222
9233
|
selected,
|
|
9223
|
-
validationMap
|
|
9234
|
+
validationMap,
|
|
9235
|
+
filter
|
|
9224
9236
|
});
|
|
9225
9237
|
return /* @__PURE__ */ jsxs("div", {
|
|
9226
9238
|
className: "flex flex-col items-center py-4",
|
|
@@ -10875,6 +10887,7 @@ function ProductConfigurator(props) {
|
|
|
10875
10887
|
const {
|
|
10876
10888
|
encodedProduct,
|
|
10877
10889
|
initSelected,
|
|
10890
|
+
initFilter,
|
|
10878
10891
|
filter,
|
|
10879
10892
|
productQuantity,
|
|
10880
10893
|
setIsOnSubmittedOnTrue,
|
|
@@ -10899,7 +10912,8 @@ function ProductConfigurator(props) {
|
|
|
10899
10912
|
});
|
|
10900
10913
|
const methods = useForm({
|
|
10901
10914
|
defaultValues: {
|
|
10902
|
-
selected: initSelected
|
|
10915
|
+
selected: initSelected,
|
|
10916
|
+
filter: initFilter
|
|
10903
10917
|
}
|
|
10904
10918
|
});
|
|
10905
10919
|
const {
|