@orderingstack/front-components-product-configurator 1.4.2-beta.23 → 1.4.2-beta.25

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/index.es.js CHANGED
@@ -6915,12 +6915,10 @@ const selectProductsInForm = (productToSelect, setValueInForm, initialSelectedSt
6915
6915
  };
6916
6916
  function useMenuOptions(product, nestedLvl, parentKind, parentSelCtx) {
6917
6917
  const { selCtx, attrs = {} } = product;
6918
- useStore((state) => state.filter);
6919
6918
  const initialSelected = useStore((state) => state.initialSelected);
6920
6919
  const currency = useStore((state) => state.currency);
6921
- const { setValue, getValues, watch } = useFormContext();
6922
- const selected = watch("selected");
6923
- const filter = watch("filter");
6920
+ const { setValue, getValues } = useFormContext();
6921
+ const { selected = {}, filter = {} } = getValues();
6924
6922
  const isFilterValidated = validateProductFilter(product, filter);
6925
6923
  const isOnSubmitted = useStore((state) => state.isOnSubmitted);
6926
6924
  const setValidationMap = useStore((state) => state.setValidationMap);
@@ -6947,9 +6945,9 @@ function useMenuOptions(product, nestedLvl, parentKind, parentSelCtx) {
6947
6945
  console.log("LOG1 useMenuOptions useEffect isFilterValidated", isFilterValidated, product);
6948
6946
  console.log("LOG1 useMenuOptions useEffect productsToUnselect", productsToUnselect);
6949
6947
  console.log("LOG1 useMenuOptions useEffect productsToSelect", productsToSelect);
6950
- selectProductsInForm(productsToSelect, setValue, initialSelected);
6951
6948
  unselectProductsInForm(productsToUnselect, setValue);
6952
- }, [isFilterValidated]);
6949
+ selectProductsInForm(productsToSelect, setValue, initialSelected);
6950
+ }, [filter, isFilterValidated, selected]);
6953
6951
  return {
6954
6952
  isFilterValidated,
6955
6953
  selected,
@@ -8942,16 +8940,16 @@ const selectUnselectProduct = (setValue, getValues, product, isChecked, unregist
8942
8940
  });
8943
8941
  };
8944
8942
  checkSubProducts(items);
8945
- (_a = Object.keys(emit)) == null ? void 0 : _a.forEach((x2) => {
8946
- const formPath = `filterWithCnt.${fltCtx}.${x2}.${emit[x2]}`;
8947
- const cnt = getValues(formPath) || 0;
8948
- if (cnt < 2) {
8949
- unregister(formPath);
8950
- } else {
8951
- setValue(formPath, cnt - 1);
8952
- }
8953
- });
8954
8943
  if (nestedLvl && nestedLvl < 2 && !isEmpty(emit)) {
8944
+ (_a = Object.keys(emit)) == null ? void 0 : _a.forEach((x2) => {
8945
+ const formPath = `filterWithCnt.${fltCtx}.${x2}.${emit[x2]}`;
8946
+ const cnt = getValues(formPath) || 0;
8947
+ if (cnt < 2) {
8948
+ unregister(formPath);
8949
+ } else {
8950
+ setValue(formPath, cnt - 1);
8951
+ }
8952
+ });
8955
8953
  const groupsPath = `filterWithCnt.${fltCtx}`;
8956
8954
  const groupCntPath = `filterWithCnt.${fltCtx}.${selCtx}`;
8957
8955
  const fltCtxPath = `filter.${fltCtx}`;