@licklist/design 0.70.9 → 0.70.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"VenueMapSetModal.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/VenueMapSetModal.tsx"],"names":[],"mappings":"AAeA,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,gBAAgB,4CAI1B,qBAAqB,4CAyMvB,CAAA"}
1
+ {"version":3,"file":"VenueMapSetModal.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/VenueMapSetModal.tsx"],"names":[],"mappings":"AAcA,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,gBAAgB,4CAI1B,qBAAqB,4CAyMvB,CAAA"}
@@ -3,7 +3,7 @@ import { useContext, useCallback, useMemo } from 'react';
3
3
  import { Modal, Form, Button } from 'react-bootstrap';
4
4
  import clsx from 'clsx';
5
5
  import { useTranslation } from 'react-i18next';
6
- import { useFormContext } from 'react-hook-form';
6
+ import { useFormContext, useWatch } from 'react-hook-form';
7
7
  import HookFormService from '@licklist/plugins/dist/services/Form/HookFormService';
8
8
  import '../../static/index.js';
9
9
  import { ProductSetLoadingContext } from './context.js';
@@ -219,12 +219,14 @@ var VenueMapSetModal = function(param) {
219
219
  'Validation'
220
220
  ]).t;
221
221
  var _useContext = useContext(ProductSetLoadingContext), _useContext_venueMapSets = _useContext.venueMapSets, venueMapSets = _useContext_venueMapSets === void 0 ? [] : _useContext_venueMapSets, providerHasMap = _useContext.providerHasMap;
222
- var _useFormContext = useFormContext(), register = _useFormContext.register, errors = _useFormContext.formState.errors, watch = _useFormContext.watch, setValue = _useFormContext.setValue, trigger = _useFormContext.trigger;
222
+ var _useFormContext = useFormContext(), register = _useFormContext.register, errors = _useFormContext.formState.errors, watch = _useFormContext.watch, setValue = _useFormContext.setValue, trigger = _useFormContext.trigger, control = _useFormContext.control;
223
223
  var key = "steps.".concat(stepIndex, ".venueMapSetId");
224
224
  var productPointsKey = "steps.".concat(stepIndex, ".pointProducts");
225
225
  var venueMapSetId = watch(key) || null;
226
- // eslint-disable-next-line react-hooks/exhaustive-deps
227
- var productCategories = watch("steps.".concat(stepIndex, ".productCategories")) || [];
226
+ var productCategories = useWatch({
227
+ control: control,
228
+ name: "steps.".concat(stepIndex, ".productCategories")
229
+ });
228
230
  var pointProducts = watch(productPointsKey) || [];
229
231
  var onCloseModal = function() {
230
232
  setIsVisible(false);
@@ -265,9 +267,7 @@ var VenueMapSetModal = function(param) {
265
267
  }, // eslint-disable-next-line react-hooks/exhaustive-deps
266
268
  []);
267
269
  var products = useMemo(function() {
268
- if (!productCategories || !productCategories.length) {
269
- return [];
270
- }
270
+ if (!(productCategories === null || productCategories === void 0 ? void 0 : productCategories.length)) return [];
271
271
  return productCategories.reduce(function(prevProducts, currentCategory) {
272
272
  return _to_consumable_array(prevProducts).concat(_to_consumable_array(currentCategory.products || []));
273
273
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.70.9",
3
+ "version": "0.70.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -2,7 +2,7 @@ import { useCallback, useContext, useMemo } from 'react'
2
2
  import { Modal, Button, Form } from 'react-bootstrap'
3
3
  import clsx from 'clsx'
4
4
  import { useTranslation } from 'react-i18next'
5
- import { useFormContext } from 'react-hook-form'
5
+ import { useFormContext, useWatch } from 'react-hook-form'
6
6
  import HookFormService from '@licklist/plugins/dist/services/Form/HookFormService'
7
7
  import { PointProduct } from '@licklist/core/dist/DataMapper/Product/PointProductDataMapper'
8
8
  import { VenueMap } from '@licklist/core/dist/DataMapper/Product/VenueMapDataMapper'
@@ -11,7 +11,6 @@ import { WarningMessage } from '../../static'
11
11
  import { ProductSetLoadingContext } from './context'
12
12
  import { ProductSetFormValues } from './ProductSetForm'
13
13
  import { VenueMapsControl } from './VenueMapsControl'
14
- import { ProductCategory } from '../types'
15
14
 
16
15
  type VenueMapSetModalProps = {
17
16
  isVisible: boolean
@@ -34,6 +33,7 @@ export const VenueMapSetModal = ({
34
33
  watch,
35
34
  setValue,
36
35
  trigger,
36
+ control,
37
37
  } = useFormContext<ProductSetFormValues>()
38
38
 
39
39
  const key = `steps.${stepIndex}.venueMapSetId` as const
@@ -41,9 +41,10 @@ export const VenueMapSetModal = ({
41
41
 
42
42
  const venueMapSetId: number | null = watch(key) || null
43
43
 
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
- const productCategories: ProductCategory[] =
46
- watch(`steps.${stepIndex}.productCategories` as const) || []
44
+ const productCategories = useWatch({
45
+ control,
46
+ name: `steps.${stepIndex}.productCategories`,
47
+ })
47
48
 
48
49
  const pointProducts: Partial<PointProduct>[] = watch(productPointsKey) || []
49
50
 
@@ -70,12 +71,10 @@ export const VenueMapSetModal = ({
70
71
  )
71
72
 
72
73
  const products = useMemo(() => {
73
- if (!productCategories || !productCategories.length) {
74
- return []
75
- }
74
+ if (!productCategories?.length) return []
76
75
 
77
76
  return productCategories.reduce(
78
- (prevProducts, currentCategory: ProductCategory) => [
77
+ (prevProducts, currentCategory) => [
79
78
  ...prevProducts,
80
79
  ...(currentCategory.products || []),
81
80
  ],