@orderingstack/front-components-product-configurator 1.4.2-beta.0 → 1.4.2-beta.2

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
@@ -6855,7 +6855,6 @@ const validateProductFilter = (product, stateFilter) => {
6855
6855
  const stateFiltersWithFltCtx = stateFilter[fltCtx];
6856
6856
  const hasProductFilters = !!Object.keys(productFilters).length;
6857
6857
  if (hasProductFilters && stateFiltersWithFltCtx) {
6858
- console.log("12345", productFilters);
6859
6858
  const commonFilters = Object.keys(stateFiltersWithFltCtx).filter(
6860
6859
  (filterName) => Object.keys(productFilters).includes(filterName) && productFilters[filterName].includes(stateFiltersWithFltCtx[filterName])
6861
6860
  );
@@ -8800,9 +8799,6 @@ function useEmitFilter(product) {
8800
8799
  const setFilter = useStore((state) => state.setFilter);
8801
8800
  const { id, selCtx, emit = {}, fltCtx } = product;
8802
8801
  const value = watch(`selected.${selCtx}.${id}`);
8803
- if (id === "MI1001001") {
8804
- console.log("use emit filter", value, fltCtx, emit);
8805
- }
8806
8802
  useEffect(() => {
8807
8803
  if (value && fltCtx && !isEmpty(emit)) {
8808
8804
  setFilter(fltCtx, emit);
@@ -8842,9 +8838,13 @@ const selectUnselectProduct = (setValue, getValues, items, isChecked, state) =>
8842
8838
  if (isChecked) {
8843
8839
  addProductToState(selected, setValue);
8844
8840
  const checkSubProducts = (items2) => {
8841
+ var _a;
8845
8842
  if (!Array.isArray(items2) || isEmpty(state == null ? void 0 : state.selected))
8846
8843
  return;
8847
- items2.map((product) => {
8844
+ (_a = items2 == null ? void 0 : items2.filter((x2) => {
8845
+ var _a2, _b;
8846
+ return !!((_b = (_a2 = state.selected) == null ? void 0 : _a2[`${x2.selCtx}`]) == null ? void 0 : _b[`${x2.id}`]);
8847
+ })) == null ? void 0 : _a.map((product) => {
8848
8848
  if (product.state && "selected" in product.state) {
8849
8849
  const {
8850
8850
  state: { selected: selected2 }
@@ -8913,6 +8913,19 @@ function useMenuProduct(product, parentAttrs) {
8913
8913
  setValue(`selected.${selCtx}.${id}`, `${decrementedValue}`);
8914
8914
  if (isCheckbox && decrementedValue === 0) {
8915
8915
  setValue(`selected.${selCtx}.${id}`, false);
8916
+ const checkSubProducts = (items) => {
8917
+ if (!Array.isArray(items))
8918
+ return;
8919
+ items.map((product2) => {
8920
+ const { selCtx: selCtx2 } = product2;
8921
+ const changedSelCtx = getValues(`selected.${selCtx2}`);
8922
+ if (changedSelCtx) {
8923
+ removeProductFromState(selCtx2, getValues, setValue);
8924
+ }
8925
+ checkSubProducts(product2.items);
8926
+ });
8927
+ };
8928
+ checkSubProducts(product.items);
8916
8929
  }
8917
8930
  };
8918
8931
  const handleOnInputChange = (e2) => {
@@ -9208,14 +9221,11 @@ const DisplayState = () => {
9208
9221
  const {
9209
9222
  watch
9210
9223
  } = useFormContext();
9211
- const form = useFormContext();
9212
9224
  const selected = watch("selected");
9213
- const filter = form.getValues("filter");
9214
9225
  const validationMap = useStore((state) => state.validationMap);
9215
9226
  console.log({
9216
9227
  selected,
9217
- validationMap,
9218
- filter
9228
+ validationMap
9219
9229
  });
9220
9230
  return /* @__PURE__ */ jsxs("div", {
9221
9231
  className: "flex flex-col items-center py-4",
@@ -10912,7 +10922,6 @@ function ProductConfigurator(props) {
10912
10922
  });
10913
10923
  } else {
10914
10924
  console.log("selected", getValues("selected"));
10915
- console.log("filter", getValues("filter"));
10916
10925
  const decodedCleanedSelected = decodeSelected(cleanSelected(getValues("selected")));
10917
10926
  console.log("decodedCleanedSelected: ", decodedCleanedSelected);
10918
10927
  handleAddToCart({