@orderingstack/front-components-product-configurator 1.4.2-beta.1 → 1.4.2-beta.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/index.es.js CHANGED
@@ -8913,17 +8913,25 @@ 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) => {
8919
8932
  const {
8920
8933
  target: { checked, name: selCtx2, defaultValue: productId }
8921
8934
  } = e2;
8922
- for (const key of Object.keys(selected || {})) {
8923
- if (key !== (product == null ? void 0 : product.selCtx) && (key == null ? void 0 : key.includes(product.selCtx)) && isRadio) {
8924
- setValue(`selected.${key}`, false);
8925
- }
8926
- }
8927
8935
  selectUnselectProduct(setValue, getValues, product.items, checked, product.state);
8928
8936
  if (isRadio) {
8929
8937
  console.log("handleOnInputChange radio", selCtx2, productId);