@orderingstack/front-components-product-configurator 1.2.3 → 1.3.0

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
@@ -10257,6 +10257,25 @@ const MenuProductRoot = (props) => {
10257
10257
  });
10258
10258
  };
10259
10259
  var style = "";
10260
+ const ProductDataContext = React.createContext(null);
10261
+ function ProductDataProvider({
10262
+ rootProduct,
10263
+ children
10264
+ }) {
10265
+ return /* @__PURE__ */ jsx(ProductDataContext.Provider, {
10266
+ value: {
10267
+ rootProduct
10268
+ },
10269
+ children
10270
+ });
10271
+ }
10272
+ function useProductData() {
10273
+ const context = useContext(ProductDataContext);
10274
+ if (!context) {
10275
+ throw new Error("Missing ComponentsContext");
10276
+ }
10277
+ return context;
10278
+ }
10260
10279
  function ProductConfigurator(props) {
10261
10280
  const {
10262
10281
  product,
@@ -10302,7 +10321,6 @@ function ProductConfigurator(props) {
10302
10321
  }
10303
10322
  });
10304
10323
  const {
10305
- handleSubmit,
10306
10324
  getValues
10307
10325
  } = methods;
10308
10326
  const countedProductPrice = Number((parseFloat(price || "0") + countPrice(getValues("selected"), product)).toFixed(2));
@@ -10329,32 +10347,35 @@ function ProductConfigurator(props) {
10329
10347
  };
10330
10348
  const handleOnSubmit = () => onSubmit();
10331
10349
  return /* @__PURE__ */ jsx(Fragment, {
10332
- children: /* @__PURE__ */ jsx(ComponentsContext.Provider, {
10333
- value: props.components,
10334
- children: /* @__PURE__ */ jsx(FormProvider, {
10335
- ...methods,
10336
- children: /* @__PURE__ */ jsxs("form", {
10337
- children: [showDebugState && /* @__PURE__ */ jsx("div", {
10338
- className: "hidden",
10339
- children: /* @__PURE__ */ jsx(DisplayState, {})
10340
- }), /* @__PURE__ */ jsx(MenuProductRoot, {
10341
- product: encodedProduct,
10342
- productQuantity,
10343
- validationMap,
10344
- isOpen,
10345
- handleClose,
10346
- handleGoBack,
10347
- handleOnSubmit,
10348
- countedProductPrice,
10349
- countedProductTotalPrice: countedProductPrice * productQuantity,
10350
- increaseProductQuantity,
10351
- decreaseProductQuantity,
10352
- currency
10353
- })]
10350
+ children: /* @__PURE__ */ jsx(ProductDataProvider, {
10351
+ rootProduct: product,
10352
+ children: /* @__PURE__ */ jsx(ComponentsContext.Provider, {
10353
+ value: props.components,
10354
+ children: /* @__PURE__ */ jsx(FormProvider, {
10355
+ ...methods,
10356
+ children: /* @__PURE__ */ jsxs("form", {
10357
+ children: [showDebugState && /* @__PURE__ */ jsx("div", {
10358
+ className: "hidden",
10359
+ children: /* @__PURE__ */ jsx(DisplayState, {})
10360
+ }), /* @__PURE__ */ jsx(MenuProductRoot, {
10361
+ product: encodedProduct,
10362
+ productQuantity,
10363
+ validationMap,
10364
+ isOpen,
10365
+ handleClose,
10366
+ handleGoBack,
10367
+ handleOnSubmit,
10368
+ countedProductPrice,
10369
+ countedProductTotalPrice: countedProductPrice * productQuantity,
10370
+ increaseProductQuantity,
10371
+ decreaseProductQuantity,
10372
+ currency
10373
+ })]
10374
+ })
10354
10375
  })
10355
10376
  })
10356
10377
  })
10357
10378
  });
10358
10379
  }
10359
- export { ContextType, MainView, ProductConfigurator, ProductKinds, ProductTypes, SelMinSelMaxStatus, index_esm as hookForm };
10380
+ export { ContextType, MainView, ProductConfigurator, ProductKinds, ProductTypes, SelMinSelMaxStatus, index_esm as hookForm, useProductData };
10360
10381
  //# sourceMappingURL=index.es.js.map