@redneckz/wildless-cms-uni-blocks 0.14.668 → 0.14.670

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.
Files changed (61) hide show
  1. package/bundle/bundle.umd.js +21 -21
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/ui-kit/YandexMap/YandexMap.d.ts +0 -1
  4. package/dist/components/CreditCardForm/CreditCardForm.js +5 -1
  5. package/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
  6. package/dist/components/CreditForm/CreditForm.js +5 -1
  7. package/dist/components/CreditForm/CreditForm.js.map +1 -1
  8. package/dist/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
  9. package/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
  10. package/dist/ui-kit/FormField/validators.js +1 -1
  11. package/dist/ui-kit/FormField/validators.js.map +1 -1
  12. package/dist/ui-kit/YandexMap/YandexMap.d.ts +0 -1
  13. package/dist/ui-kit/YandexMap/YandexMap.js +6 -15
  14. package/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
  15. package/lib/components/CreditCardForm/CreditCardForm.js +6 -2
  16. package/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
  17. package/lib/components/CreditForm/CreditForm.js +6 -2
  18. package/lib/components/CreditForm/CreditForm.js.map +1 -1
  19. package/lib/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
  20. package/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
  21. package/lib/ui-kit/FormField/validators.js +1 -1
  22. package/lib/ui-kit/FormField/validators.js.map +1 -1
  23. package/lib/ui-kit/YandexMap/YandexMap.d.ts +0 -1
  24. package/lib/ui-kit/YandexMap/YandexMap.js +6 -15
  25. package/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
  26. package/mobile/bundle/bundle.umd.js +21 -21
  27. package/mobile/bundle/bundle.umd.min.js +1 -1
  28. package/mobile/bundle/ui-kit/YandexMap/YandexMap.d.ts +0 -1
  29. package/mobile/dist/components/CreditCardForm/CreditCardForm.js +5 -1
  30. package/mobile/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
  31. package/mobile/dist/components/CreditForm/CreditForm.js +5 -1
  32. package/mobile/dist/components/CreditForm/CreditForm.js.map +1 -1
  33. package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
  34. package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
  35. package/mobile/dist/ui-kit/FormField/validators.js +1 -1
  36. package/mobile/dist/ui-kit/FormField/validators.js.map +1 -1
  37. package/mobile/dist/ui-kit/YandexMap/YandexMap.d.ts +0 -1
  38. package/mobile/dist/ui-kit/YandexMap/YandexMap.js +6 -15
  39. package/mobile/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
  40. package/mobile/lib/components/CreditCardForm/CreditCardForm.js +6 -2
  41. package/mobile/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
  42. package/mobile/lib/components/CreditForm/CreditForm.js +6 -2
  43. package/mobile/lib/components/CreditForm/CreditForm.js.map +1 -1
  44. package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
  45. package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
  46. package/mobile/lib/ui-kit/FormField/validators.js +1 -1
  47. package/mobile/lib/ui-kit/FormField/validators.js.map +1 -1
  48. package/mobile/lib/ui-kit/YandexMap/YandexMap.d.ts +0 -1
  49. package/mobile/lib/ui-kit/YandexMap/YandexMap.js +6 -15
  50. package/mobile/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
  51. package/mobile/src/components/CreditCardForm/CreditCardForm.tsx +10 -2
  52. package/mobile/src/components/CreditForm/CreditForm.tsx +10 -2
  53. package/mobile/src/ui-kit/FormField/Fields/AddressRetailField.tsx +2 -6
  54. package/mobile/src/ui-kit/FormField/validators.ts +1 -1
  55. package/mobile/src/ui-kit/YandexMap/YandexMap.tsx +47 -59
  56. package/package.json +1 -1
  57. package/src/components/CreditCardForm/CreditCardForm.tsx +10 -2
  58. package/src/components/CreditForm/CreditForm.tsx +10 -2
  59. package/src/ui-kit/FormField/Fields/AddressRetailField.tsx +2 -6
  60. package/src/ui-kit/FormField/validators.ts +1 -1
  61. package/src/ui-kit/YandexMap/YandexMap.tsx +47 -59
@@ -16,7 +16,6 @@ interface YandexMapProps {
16
16
  className?: string;
17
17
  zoom?: number;
18
18
  isLoad?: boolean;
19
- selectedAddress?: string;
20
19
  }
21
20
 
22
21
  export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
@@ -25,70 +24,59 @@ export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
25
24
  // Сейчас реализован поиск среди тестовых данных
26
25
  // TODO: Также выяснить что делать когда ничего не найдено
27
26
  // TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
28
- export const YandexMap = JSX<YandexMapProps>(
29
- ({ points, className = '', zoom = 5, isLoad, selectedAddress }) => {
30
- const map = useRef<ymaps.Map | null>(null);
31
-
32
- const yandexMaps = useYandexMaps();
33
-
34
- useEffect(() => {
35
- if (map.current) {
36
- renderClusterer({ yandexMaps, map: map.current, points, isLoad, selectedAddress });
37
- } else {
38
- yandexMaps?.ready(() => {
39
- // Ready function may be called few times, but must be called once
40
- if (map.current) {
41
- renderClusterer({ yandexMaps, map: map.current, points, isLoad });
42
-
43
- return;
44
- }
45
-
46
- map.current = new yandexMaps.Map('map', {
47
- center: getCenterPoint(points),
48
- zoom,
49
- controls: [],
50
- suppressMapOpenBlock: true,
51
- });
27
+ export const YandexMap = JSX<YandexMapProps>(({ points, className = '', zoom = 5, isLoad }) => {
28
+ const map = useRef<ymaps.Map | null>(null);
52
29
 
30
+ const parentDiv = useRef<HTMLElement>(null);
31
+
32
+ const yandexMaps = useYandexMaps();
33
+
34
+ useEffect(() => {
35
+ if (map.current) {
36
+ renderClusterer({ yandexMaps, map: map.current, points, isLoad });
37
+ } else {
38
+ yandexMaps?.ready(() => {
39
+ // Ready function may be called few times, but must be called once
40
+ if (map.current) {
53
41
  renderClusterer({ yandexMaps, map: map.current, points, isLoad });
42
+
43
+ return;
44
+ }
45
+
46
+ map.current = new yandexMaps.Map(parentDiv.current, {
47
+ center: getCenterPoint(points),
48
+ zoom,
49
+ controls: [],
50
+ suppressMapOpenBlock: true,
54
51
  });
55
- }
56
- }, [yandexMaps, points, zoom, isLoad, selectedAddress]);
57
-
58
- useEffect(() => {
59
- if (map.current && selectedAddress) {
60
- yandexMaps?.geocode(selectedAddress).then((res) => {
61
- const firstGeoObject = res.geoObjects.get(0);
62
- const coords = firstGeoObject.geometry.getCoordinates() as number[];
63
- map.current.setCenter(coords);
64
- map.current.setZoom(18);
65
- });
66
- }
67
- }, [selectedAddress]);
68
52
 
69
- if (!yandexMaps) {
70
- return null;
53
+ renderClusterer({ yandexMaps, map: map.current, points, isLoad });
54
+ });
71
55
  }
72
-
73
- const zIndex = 'z-10';
74
-
75
- return (
76
- <div id="map" className={style('relative', 'w-full', className)}>
77
- {isLoad ? <Loader /> : null}
78
- <div
79
- className={style(
80
- 'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
81
- zIndex,
82
- )}
83
- >
84
- <ZoomButton yandexMaps={map} />
85
- <ZoomButton yandexMaps={map} direction="out" />
86
- </div>
87
- {renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
56
+ }, [yandexMaps, points, zoom, isLoad]);
57
+
58
+ if (!yandexMaps) {
59
+ return null;
60
+ }
61
+
62
+ const zIndex = 'z-10';
63
+
64
+ return (
65
+ <div ref={parentDiv} className={style('relative', 'w-full', className)}>
66
+ {isLoad ? <Loader /> : null}
67
+ <div
68
+ className={style(
69
+ 'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
70
+ zIndex,
71
+ )}
72
+ >
73
+ <ZoomButton yandexMaps={map} />
74
+ <ZoomButton yandexMaps={map} direction="out" />
88
75
  </div>
89
- );
90
- },
91
- );
76
+ {renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
77
+ </div>
78
+ );
79
+ });
92
80
 
93
81
  const getCenterPoint = (points?: BalloonPoints[]) => {
94
82
  const centerCoords = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.668",
3
+ "version": "0.14.670",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -1,5 +1,5 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { updateRefreshToken } from '../../api/RetailAPI/updateRefreshToken';
4
4
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
5
5
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
@@ -25,15 +25,23 @@ const WIZARD_TITLES = [
25
25
  export const CreditCardForm = JSX<CreditCardFormWizardProps>(({ className, ...rest }) => {
26
26
  const [step, setStep] = useState(0);
27
27
 
28
+ const formContainerRef = useRef<HTMLDivElement | null>(null);
29
+ const scrollToTop = useCallback(
30
+ () => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }),
31
+ [formContainerRef],
32
+ );
33
+
28
34
  useEffect(updateRefreshToken, []);
29
35
 
30
36
  const handleNextStep = useCallback(() => {
31
37
  setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
38
+ scrollToTop();
32
39
  }, []);
33
40
 
34
41
  const handlePrevStep = useCallback(() => {
35
42
  //TODO search hook - 1,
36
43
  setStep((_) => Math.max(_ - 1, 0));
44
+ scrollToTop();
37
45
  }, []);
38
46
 
39
47
  const sections = useMemo(() => stepsSectionsMap[step], [step]);
@@ -42,7 +50,7 @@ export const CreditCardForm = JSX<CreditCardFormWizardProps>(({ className, ...re
42
50
 
43
51
  return (
44
52
  <BlockWrapper className={style('bg-transparent', className)} defaultPadding="p-0" {...rest}>
45
- <div className="container grid grid-cols-12">
53
+ <div ref={formContainerRef} className="container grid grid-cols-12">
46
54
  {isFormFinished ? null : (
47
55
  <CreditCardFormProgress
48
56
  stepsTitles={WIZARD_TITLES}
@@ -1,5 +1,5 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { updateRefreshToken } from '../../api/RetailAPI/updateRefreshToken';
4
4
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
5
5
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
@@ -26,15 +26,23 @@ const WIZARD_TITLES = [
26
26
  export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) => {
27
27
  const [step, setStep] = useState(0);
28
28
 
29
+ const formContainerRef = useRef<HTMLDivElement | null>(null);
30
+ const scrollToTop = useCallback(
31
+ () => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }),
32
+ [formContainerRef],
33
+ );
34
+
29
35
  useEffect(updateRefreshToken, []);
30
36
 
31
37
  const handleNextStep = useCallback(() => {
32
38
  setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
39
+ scrollToTop();
33
40
  }, []);
34
41
 
35
42
  const handlePrevStep = useCallback(() => {
36
43
  //TODO search hook - 1,
37
44
  setStep((_) => Math.max(_ - 1, 0));
45
+ scrollToTop();
38
46
  }, []);
39
47
 
40
48
  const sections = useMemo(() => stepsSectionsMap[step], [step]);
@@ -44,7 +52,7 @@ export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) =>
44
52
 
45
53
  return (
46
54
  <BlockWrapper className={style('bg-transparent', className)} defaultPadding="p-0" {...rest}>
47
- <div className="container grid grid-cols-12">
55
+ <div ref={formContainerRef} className="container grid grid-cols-12">
48
56
  {isStartStep || isFormFinished ? null : (
49
57
  <CreditFormProgress stepsTitles={WIZARD_TITLES} step={step} totalSteps={WIZARD_STEPS} />
50
58
  )}
@@ -16,6 +16,7 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
16
16
  const { data } = useLeadFormData('REGION_RF');
17
17
 
18
18
  const regionValue = field('regionRetail')?.value || {};
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
20
  const fieldBranch = field('addressRetail');
20
21
 
21
22
  useEffect(() => {
@@ -56,12 +57,7 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
56
57
  />
57
58
  <div className="h-[600px]">
58
59
  <ClientOnly>
59
- <YandexMap
60
- points={points}
61
- isLoad={!data}
62
- className="h-full"
63
- selectedAddress={fieldBranch?.value?.text}
64
- />
60
+ <YandexMap points={points} isLoad={!data} className="h-full" />
65
61
  </ClientOnly>
66
62
  </div>
67
63
  </div>
@@ -67,7 +67,7 @@ export const emailValidator = (errorMsg: string) =>
67
67
  validator((_: string) => emailValidate(_))(errorMsg);
68
68
 
69
69
  const addressDaDataValidate = (address: Address) =>
70
- Boolean(address.qc === '0' && address.qcComplete === '0' && address.qcHouse === '2');
70
+ Boolean(address.region && address.city && address.house);
71
71
 
72
72
  export const addressDaDataValidator = () =>
73
73
  validator(addressDaDataValidate)('Укажите регион, город/населенный пункт, улицу, дом, квартиру');
@@ -16,7 +16,6 @@ interface YandexMapProps {
16
16
  className?: string;
17
17
  zoom?: number;
18
18
  isLoad?: boolean;
19
- selectedAddress?: string;
20
19
  }
21
20
 
22
21
  export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
@@ -25,70 +24,59 @@ export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
25
24
  // Сейчас реализован поиск среди тестовых данных
26
25
  // TODO: Также выяснить что делать когда ничего не найдено
27
26
  // TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
28
- export const YandexMap = JSX<YandexMapProps>(
29
- ({ points, className = '', zoom = 5, isLoad, selectedAddress }) => {
30
- const map = useRef<ymaps.Map | null>(null);
31
-
32
- const yandexMaps = useYandexMaps();
33
-
34
- useEffect(() => {
35
- if (map.current) {
36
- renderClusterer({ yandexMaps, map: map.current, points, isLoad, selectedAddress });
37
- } else {
38
- yandexMaps?.ready(() => {
39
- // Ready function may be called few times, but must be called once
40
- if (map.current) {
41
- renderClusterer({ yandexMaps, map: map.current, points, isLoad });
42
-
43
- return;
44
- }
45
-
46
- map.current = new yandexMaps.Map('map', {
47
- center: getCenterPoint(points),
48
- zoom,
49
- controls: [],
50
- suppressMapOpenBlock: true,
51
- });
27
+ export const YandexMap = JSX<YandexMapProps>(({ points, className = '', zoom = 5, isLoad }) => {
28
+ const map = useRef<ymaps.Map | null>(null);
52
29
 
30
+ const parentDiv = useRef<HTMLElement>(null);
31
+
32
+ const yandexMaps = useYandexMaps();
33
+
34
+ useEffect(() => {
35
+ if (map.current) {
36
+ renderClusterer({ yandexMaps, map: map.current, points, isLoad });
37
+ } else {
38
+ yandexMaps?.ready(() => {
39
+ // Ready function may be called few times, but must be called once
40
+ if (map.current) {
53
41
  renderClusterer({ yandexMaps, map: map.current, points, isLoad });
42
+
43
+ return;
44
+ }
45
+
46
+ map.current = new yandexMaps.Map(parentDiv.current, {
47
+ center: getCenterPoint(points),
48
+ zoom,
49
+ controls: [],
50
+ suppressMapOpenBlock: true,
54
51
  });
55
- }
56
- }, [yandexMaps, points, zoom, isLoad, selectedAddress]);
57
-
58
- useEffect(() => {
59
- if (map.current && selectedAddress) {
60
- yandexMaps?.geocode(selectedAddress).then((res) => {
61
- const firstGeoObject = res.geoObjects.get(0);
62
- const coords = firstGeoObject.geometry.getCoordinates() as number[];
63
- map.current.setCenter(coords);
64
- map.current.setZoom(18);
65
- });
66
- }
67
- }, [selectedAddress]);
68
52
 
69
- if (!yandexMaps) {
70
- return null;
53
+ renderClusterer({ yandexMaps, map: map.current, points, isLoad });
54
+ });
71
55
  }
72
-
73
- const zIndex = 'z-10';
74
-
75
- return (
76
- <div id="map" className={style('relative', 'w-full', className)}>
77
- {isLoad ? <Loader /> : null}
78
- <div
79
- className={style(
80
- 'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
81
- zIndex,
82
- )}
83
- >
84
- <ZoomButton yandexMaps={map} />
85
- <ZoomButton yandexMaps={map} direction="out" />
86
- </div>
87
- {renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
56
+ }, [yandexMaps, points, zoom, isLoad]);
57
+
58
+ if (!yandexMaps) {
59
+ return null;
60
+ }
61
+
62
+ const zIndex = 'z-10';
63
+
64
+ return (
65
+ <div ref={parentDiv} className={style('relative', 'w-full', className)}>
66
+ {isLoad ? <Loader /> : null}
67
+ <div
68
+ className={style(
69
+ 'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
70
+ zIndex,
71
+ )}
72
+ >
73
+ <ZoomButton yandexMaps={map} />
74
+ <ZoomButton yandexMaps={map} direction="out" />
88
75
  </div>
89
- );
90
- },
91
- );
76
+ {renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
77
+ </div>
78
+ );
79
+ });
92
80
 
93
81
  const getCenterPoint = (points?: BalloonPoints[]) => {
94
82
  const centerCoords = [