@redneckz/wildless-cms-uni-blocks 0.14.675 → 0.14.677
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/bundle/EventBus/EventBus.d.ts +1 -8
- package/bundle/EventBus/defaultEventBus.d.ts +0 -9
- package/bundle/api/RetailAPI/updateRefreshToken.d.ts +1 -1
- package/bundle/bundle.umd.js +420 -143
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/hooks/useLocation.d.ts +4 -1
- package/bundle/hooks/useNavigator.d.ts +8 -0
- package/bundle/index.d.ts +1 -0
- package/bundle/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
- package/dist/EventBus/EventBus.d.ts +1 -8
- package/dist/EventBus/EventBus.js +2 -28
- package/dist/EventBus/EventBus.js.map +1 -1
- package/dist/EventBus/defaultEventBus.d.ts +0 -9
- package/dist/EventBus/defaultEventBus.js.map +1 -1
- package/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -1
- package/dist/api/RetailAPI/updateRefreshToken.js +6 -10
- package/dist/api/RetailAPI/updateRefreshToken.js.map +1 -1
- package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
- package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/dist/components/ContentPage/ContentPage.js +2 -0
- package/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/dist/components/CreditCardForm/CreditCardForm.js +4 -1
- package/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/dist/components/CreditForm/CreditForm.js +4 -1
- package/dist/components/CreditForm/CreditForm.js.map +1 -1
- package/dist/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
- package/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/dist/components/Header/HeaderSecondaryMenu.js +1 -1
- package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
- package/dist/components/OfficesAtmsMap/AtmsMap.js +1 -1
- package/dist/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
- package/dist/components/OfficesAtmsMap/OfficesMap.js +1 -1
- package/dist/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
- package/dist/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
- package/dist/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
- package/dist/hooks/useLocation.d.ts +4 -1
- package/dist/hooks/useLocation.js +16 -34
- package/dist/hooks/useLocation.js.map +1 -1
- package/dist/hooks/useNavigator.d.ts +8 -0
- package/dist/hooks/useNavigator.js +13 -0
- package/dist/hooks/useNavigator.js.map +1 -0
- package/dist/hooks/useRegions.js +3 -1
- package/dist/hooks/useRegions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/ui-kit/DialogManager/useDialogsList.js +3 -0
- package/dist/ui-kit/DialogManager/useDialogsList.js.map +1 -1
- package/dist/ui-kit/LocationDialog/LocationDialog.js +11 -14
- package/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
- package/dist/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
- package/dist/ui-kit/LocationDialog/SelectedLocation.js +15 -0
- package/dist/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
- package/dist/ui-kit/PopupManager/PopupManager.js +3 -0
- package/dist/ui-kit/PopupManager/PopupManager.js.map +1 -1
- package/lib/EventBus/EventBus.d.ts +1 -8
- package/lib/EventBus/EventBus.js +1 -27
- package/lib/EventBus/EventBus.js.map +1 -1
- package/lib/EventBus/defaultEventBus.d.ts +0 -9
- package/lib/EventBus/defaultEventBus.js.map +1 -1
- package/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -1
- package/lib/api/RetailAPI/updateRefreshToken.js +6 -10
- package/lib/api/RetailAPI/updateRefreshToken.js.map +1 -1
- package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
- package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/lib/components/ContentPage/ContentPage.js +2 -0
- package/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/lib/components/CreditCardForm/CreditCardForm.js +4 -1
- package/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/lib/components/CreditForm/CreditForm.js +4 -1
- package/lib/components/CreditForm/CreditForm.js.map +1 -1
- package/lib/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
- package/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/lib/components/Header/HeaderSecondaryMenu.js +1 -1
- package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
- package/lib/components/OfficesAtmsMap/AtmsMap.js +1 -1
- package/lib/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
- package/lib/components/OfficesAtmsMap/OfficesMap.js +1 -1
- package/lib/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
- package/lib/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
- package/lib/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
- package/lib/hooks/useLocation.d.ts +4 -1
- package/lib/hooks/useLocation.js +15 -34
- package/lib/hooks/useLocation.js.map +1 -1
- package/lib/hooks/useNavigator.d.ts +8 -0
- package/lib/hooks/useNavigator.js +10 -0
- package/lib/hooks/useNavigator.js.map +1 -0
- package/lib/hooks/useRegions.js +3 -1
- package/lib/hooks/useRegions.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/ui-kit/DialogManager/useDialogsList.js +3 -0
- package/lib/ui-kit/DialogManager/useDialogsList.js.map +1 -1
- package/lib/ui-kit/LocationDialog/LocationDialog.js +13 -16
- package/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
- package/lib/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
- package/lib/ui-kit/LocationDialog/SelectedLocation.js +13 -0
- package/lib/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
- package/lib/ui-kit/PopupManager/PopupManager.js +3 -0
- package/lib/ui-kit/PopupManager/PopupManager.js.map +1 -1
- package/mobile/bundle/EventBus/EventBus.d.ts +1 -8
- package/mobile/bundle/EventBus/defaultEventBus.d.ts +0 -9
- package/mobile/bundle/api/RetailAPI/updateRefreshToken.d.ts +1 -1
- package/mobile/bundle/bundle.umd.js +420 -143
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/hooks/useLocation.d.ts +4 -1
- package/mobile/bundle/hooks/useNavigator.d.ts +8 -0
- package/mobile/bundle/index.d.ts +1 -0
- package/mobile/bundle/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
- package/mobile/dist/EventBus/EventBus.d.ts +1 -8
- package/mobile/dist/EventBus/EventBus.js +2 -28
- package/mobile/dist/EventBus/EventBus.js.map +1 -1
- package/mobile/dist/EventBus/defaultEventBus.d.ts +0 -9
- package/mobile/dist/EventBus/defaultEventBus.js.map +1 -1
- package/mobile/dist/api/RetailAPI/updateRefreshToken.d.ts +1 -1
- package/mobile/dist/api/RetailAPI/updateRefreshToken.js +6 -10
- package/mobile/dist/api/RetailAPI/updateRefreshToken.js.map +1 -1
- package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
- package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/mobile/dist/components/ContentPage/ContentPage.js +2 -0
- package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/dist/components/CreditCardForm/CreditCardForm.js +4 -1
- package/mobile/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/mobile/dist/components/CreditForm/CreditForm.js +4 -1
- package/mobile/dist/components/CreditForm/CreditForm.js.map +1 -1
- package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
- package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/mobile/dist/components/Header/HeaderSecondaryMenu.js +1 -1
- package/mobile/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
- package/mobile/dist/components/OfficesAtmsMap/AtmsMap.js +1 -1
- package/mobile/dist/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
- package/mobile/dist/components/OfficesAtmsMap/OfficesMap.js +1 -1
- package/mobile/dist/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
- package/mobile/dist/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
- package/mobile/dist/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
- package/mobile/dist/hooks/useLocation.d.ts +4 -1
- package/mobile/dist/hooks/useLocation.js +16 -34
- package/mobile/dist/hooks/useLocation.js.map +1 -1
- package/mobile/dist/hooks/useNavigator.d.ts +8 -0
- package/mobile/dist/hooks/useNavigator.js +13 -0
- package/mobile/dist/hooks/useNavigator.js.map +1 -0
- package/mobile/dist/hooks/useRegions.js +3 -1
- package/mobile/dist/hooks/useRegions.js.map +1 -1
- package/mobile/dist/index.d.ts +1 -0
- package/mobile/dist/index.js +3 -1
- package/mobile/dist/index.js.map +1 -1
- package/mobile/dist/ui-kit/DialogManager/useDialogsList.js +3 -0
- package/mobile/dist/ui-kit/DialogManager/useDialogsList.js.map +1 -1
- package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js +11 -14
- package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
- package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
- package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.js +15 -0
- package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
- package/mobile/dist/ui-kit/PopupManager/PopupManager.js +3 -0
- package/mobile/dist/ui-kit/PopupManager/PopupManager.js.map +1 -1
- package/mobile/lib/EventBus/EventBus.d.ts +1 -8
- package/mobile/lib/EventBus/EventBus.js +1 -27
- package/mobile/lib/EventBus/EventBus.js.map +1 -1
- package/mobile/lib/EventBus/defaultEventBus.d.ts +0 -9
- package/mobile/lib/EventBus/defaultEventBus.js.map +1 -1
- package/mobile/lib/api/RetailAPI/updateRefreshToken.d.ts +1 -1
- package/mobile/lib/api/RetailAPI/updateRefreshToken.js +6 -10
- package/mobile/lib/api/RetailAPI/updateRefreshToken.js.map +1 -1
- package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +1 -1
- package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
- package/mobile/lib/components/ContentPage/ContentPage.js +2 -0
- package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/lib/components/CreditCardForm/CreditCardForm.js +4 -1
- package/mobile/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/mobile/lib/components/CreditForm/CreditForm.js +4 -1
- package/mobile/lib/components/CreditForm/CreditForm.js.map +1 -1
- package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
- package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/mobile/lib/components/Header/HeaderSecondaryMenu.js +1 -1
- package/mobile/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
- package/mobile/lib/components/OfficesAtmsMap/AtmsMap.js +1 -1
- package/mobile/lib/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
- package/mobile/lib/components/OfficesAtmsMap/OfficesMap.js +1 -1
- package/mobile/lib/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
- package/mobile/lib/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
- package/mobile/lib/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
- package/mobile/lib/hooks/useLocation.d.ts +4 -1
- package/mobile/lib/hooks/useLocation.js +15 -34
- package/mobile/lib/hooks/useLocation.js.map +1 -1
- package/mobile/lib/hooks/useNavigator.d.ts +8 -0
- package/mobile/lib/hooks/useNavigator.js +10 -0
- package/mobile/lib/hooks/useNavigator.js.map +1 -0
- package/mobile/lib/hooks/useRegions.js +3 -1
- package/mobile/lib/hooks/useRegions.js.map +1 -1
- package/mobile/lib/index.d.ts +1 -0
- package/mobile/lib/index.js +1 -0
- package/mobile/lib/index.js.map +1 -1
- package/mobile/lib/ui-kit/DialogManager/useDialogsList.js +3 -0
- package/mobile/lib/ui-kit/DialogManager/useDialogsList.js.map +1 -1
- package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js +13 -16
- package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
- package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
- package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.js +13 -0
- package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
- package/mobile/lib/ui-kit/PopupManager/PopupManager.js +3 -0
- package/mobile/lib/ui-kit/PopupManager/PopupManager.js.map +1 -1
- package/mobile/src/EventBus/EventBus.ts +1 -36
- package/mobile/src/EventBus/defaultEventBus.ts +0 -10
- package/mobile/src/api/RetailAPI/updateRefreshToken.ts +6 -12
- package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +1 -1
- package/mobile/src/components/ContentPage/ContentPage.tsx +2 -0
- package/mobile/src/components/CreditCardForm/CreditCardForm.tsx +6 -1
- package/mobile/src/components/CreditForm/CreditForm.tsx +6 -1
- package/mobile/src/components/ExchangeRateTile/ExchangeRateTile.tsx +1 -1
- package/mobile/src/components/Header/HeaderSecondaryMenu.tsx +1 -1
- package/mobile/src/components/OfficesAtmsMap/AtmsMap.tsx +1 -1
- package/mobile/src/components/OfficesAtmsMap/OfficesMap.tsx +1 -1
- package/mobile/src/components/StickyBottomMenu/BurgerMenuDialog.tsx +1 -1
- package/mobile/src/hooks/useLocation.ts +25 -47
- package/mobile/src/hooks/useNavigator.ts +15 -0
- package/mobile/src/hooks/useRegions.ts +4 -1
- package/mobile/src/index.ts +1 -0
- package/mobile/src/ui-kit/DialogManager/useDialogsList.ts +3 -0
- package/mobile/src/ui-kit/LocationDialog/LocationDialog.tsx +22 -28
- package/mobile/src/ui-kit/LocationDialog/SelectedLocation.tsx +27 -0
- package/mobile/src/ui-kit/PopupManager/PopupManager.tsx +3 -0
- package/package.json +5 -5
- package/src/EventBus/EventBus.ts +1 -36
- package/src/EventBus/defaultEventBus.ts +0 -10
- package/src/api/RetailAPI/updateRefreshToken.ts +6 -12
- package/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +1 -1
- package/src/components/ContentPage/ContentPage.tsx +2 -0
- package/src/components/CreditCardForm/CreditCardForm.tsx +6 -1
- package/src/components/CreditForm/CreditForm.tsx +6 -1
- package/src/components/ExchangeRateTile/ExchangeRateTile.tsx +1 -1
- package/src/components/Header/HeaderSecondaryMenu.tsx +1 -1
- package/src/components/OfficesAtmsMap/AtmsMap.tsx +1 -1
- package/src/components/OfficesAtmsMap/OfficesMap.tsx +1 -1
- package/src/components/StickyBottomMenu/BurgerMenuDialog.tsx +1 -1
- package/src/hooks/useLocation.ts +25 -47
- package/src/hooks/useNavigator.ts +15 -0
- package/src/hooks/useRegions.ts +4 -1
- package/src/index.ts +1 -0
- package/src/ui-kit/DialogManager/useDialogsList.ts +3 -0
- package/src/ui-kit/LocationDialog/LocationDialog.tsx +22 -28
- package/src/ui-kit/LocationDialog/SelectedLocation.tsx +27 -0
- package/src/ui-kit/PopupManager/PopupManager.tsx +3 -0
|
@@ -414,32 +414,53 @@
|
|
|
414
414
|
className,
|
|
415
415
|
].join(' ');
|
|
416
416
|
|
|
417
|
-
class EventBus {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
this.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
417
|
+
class EventBus {
|
|
418
|
+
watchers = new Set();
|
|
419
|
+
subscribersMap = {};
|
|
420
|
+
subjectsStateMap = {};
|
|
421
|
+
emitter = this;
|
|
422
|
+
observable = this;
|
|
423
|
+
watch(watcher) {
|
|
424
|
+
this.watchers.add(watcher);
|
|
425
|
+
return () => {
|
|
426
|
+
this.watchers.delete(watcher);
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
subscribe(type, listener) {
|
|
430
|
+
this.subscribersMap[type] ||= new Set();
|
|
431
|
+
this.subscribersMap[type]?.add(listener);
|
|
432
|
+
const initialEvent = this.subjectsStateMap[type];
|
|
433
|
+
initialEvent && listener(initialEvent);
|
|
434
|
+
return () => {
|
|
435
|
+
this.subscribersMap[type]?.delete(listener);
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
fire(type, event) {
|
|
439
|
+
const isSubjectDeclared = type in this.subjectsStateMap;
|
|
440
|
+
if (isSubjectDeclared) {
|
|
441
|
+
this.subject(type, event);
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
this.fireSubscribers(type, event);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
subject(type, event) {
|
|
448
|
+
if (this.subjectsStateMap[type] !== event) {
|
|
449
|
+
this.subjectsStateMap[type] = event ?? undefined;
|
|
450
|
+
this.fireSubscribers(type, event);
|
|
451
|
+
}
|
|
452
|
+
return () => {
|
|
453
|
+
delete this.subjectsStateMap[type];
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
fireSubscribers(type, event) {
|
|
457
|
+
for (const _ of this.subscribersMap[type] ?? []) {
|
|
458
|
+
_(event ?? null);
|
|
459
|
+
}
|
|
460
|
+
for (const _ of this.watchers) {
|
|
461
|
+
_({ type, event: event ?? null });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
443
464
|
}
|
|
444
465
|
|
|
445
466
|
const defaultEventBus = new EventBus();
|
|
@@ -725,26 +746,166 @@
|
|
|
725
746
|
const leftOrRightImage = (img, directionRight) => directionRight ? { rightImage: img } : { leftImage: img };
|
|
726
747
|
const renderTags = (tags) => (tags?.length ? jsx(Tags, { tags: tags }) : null);
|
|
727
748
|
|
|
749
|
+
class JSONBox {
|
|
750
|
+
_;
|
|
751
|
+
constructor(_) {
|
|
752
|
+
this._ = _;
|
|
753
|
+
}
|
|
754
|
+
of(_) {
|
|
755
|
+
return new this.constructor(_ instanceof JSONBox ? _._ : _);
|
|
756
|
+
}
|
|
757
|
+
filter(predicate) {
|
|
758
|
+
return this.from(this.entries().filter(predicate));
|
|
759
|
+
}
|
|
760
|
+
map(mapper) {
|
|
761
|
+
return this.from(this.entries().map(mapper));
|
|
762
|
+
}
|
|
763
|
+
flatMap(mapper) {
|
|
764
|
+
return this.from(this.entries().flatMap(mapper));
|
|
765
|
+
}
|
|
766
|
+
reduce(reducer, initial) {
|
|
767
|
+
return this.entries().reduce(reducer.bind(this), initial);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
const trueF = () => true;
|
|
772
|
+
const and = (a, b) => (...args) => a(...args) && b(...args);
|
|
773
|
+
|
|
774
|
+
const table = (...table) => (...input) => {
|
|
775
|
+
const [, unit] = assertNonEmpty$1(table.find(([predicate]) => predicate(...input)));
|
|
776
|
+
return unit(...input);
|
|
777
|
+
};
|
|
778
|
+
function assertNonEmpty$1(value) {
|
|
779
|
+
if (!value) {
|
|
780
|
+
throw new Error('Value should be fulfilled');
|
|
781
|
+
}
|
|
782
|
+
return value;
|
|
783
|
+
}
|
|
784
|
+
|
|
728
785
|
const isJSONArray = (_) => Boolean(_ && Array.isArray(_));
|
|
729
|
-
const isJSONRecord = (_) => Boolean(_ &&
|
|
730
|
-
|
|
786
|
+
const isJSONRecord = (_) => Boolean(_ && typeof _ === 'object' && !isJSONArray(_));
|
|
787
|
+
|
|
788
|
+
const identity$1 = (x) => x;
|
|
789
|
+
|
|
790
|
+
const t0 = (fn = identity$1) => ([_]) => fn(_);
|
|
791
|
+
const t1 = (fn = identity$1) => ([, _]) => fn(_);
|
|
731
792
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
793
|
+
function unbox(box) {
|
|
794
|
+
return box instanceof JSONBox ? box._ : box;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
class JSONArrayBox extends JSONBox {
|
|
798
|
+
from(entries) {
|
|
799
|
+
return this.of(entries.map(t1(unbox)));
|
|
735
800
|
}
|
|
736
|
-
|
|
737
|
-
return
|
|
801
|
+
entries() {
|
|
802
|
+
return (this._ ?? []).map((node, p) => [p, this.of(node)]);
|
|
738
803
|
}
|
|
739
|
-
|
|
740
|
-
return
|
|
804
|
+
size() {
|
|
805
|
+
return this._?.length ?? 0;
|
|
741
806
|
}
|
|
742
|
-
|
|
743
|
-
return
|
|
807
|
+
get(p) {
|
|
808
|
+
return this.of(typeof p === 'number' ? this._?.[p] : undefined);
|
|
809
|
+
}
|
|
810
|
+
set(p, child) {
|
|
811
|
+
return this.of(isJSONArray(this._)
|
|
812
|
+
? Array.from({ length: Math.max(this._.length, Number(p) + 1) }, (x, i) => (i === p ? child : this._[i]))
|
|
813
|
+
: Array.from({ length: Number(p) + 1 }, (x, i) => (i === p ? child : undefined)));
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
class JSONLeafBox extends JSONBox {
|
|
818
|
+
from() {
|
|
819
|
+
return this;
|
|
820
|
+
}
|
|
821
|
+
entries() {
|
|
822
|
+
return [];
|
|
823
|
+
}
|
|
824
|
+
size() {
|
|
825
|
+
return 0;
|
|
826
|
+
}
|
|
827
|
+
get(p) {
|
|
828
|
+
return this.of(p !== undefined ? undefined /* no childs */ : this._ /* self */);
|
|
829
|
+
}
|
|
830
|
+
set(p, child) {
|
|
831
|
+
return this.of(child);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
class JSONRecordBox extends JSONBox {
|
|
836
|
+
from(entries) {
|
|
837
|
+
return this.of(Object.fromEntries(entries.map(([p, box]) => [p, unbox(box)])));
|
|
838
|
+
}
|
|
839
|
+
entries() {
|
|
840
|
+
return Object.entries(this._ ?? {}).map(([p, node]) => [p, this.of(node)]);
|
|
841
|
+
}
|
|
842
|
+
size() {
|
|
843
|
+
return Object.keys(this._ ?? {}).length;
|
|
844
|
+
}
|
|
845
|
+
get(p) {
|
|
846
|
+
return this.of(typeof p === 'string' ? this._?.[p] : undefined);
|
|
847
|
+
}
|
|
848
|
+
set(p, child) {
|
|
849
|
+
return this.of({ ...this._, [p]: child });
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
class JSONBoxDefault extends JSONBox {
|
|
854
|
+
proto = table([p => isJSONArray(this._) || typeof p === 'number', () => JSONArrayBox.prototype], [p => isJSONRecord(this._) || typeof p === 'string', () => JSONRecordBox.prototype], [trueF, () => JSONLeafBox.prototype]);
|
|
855
|
+
from(entries) {
|
|
856
|
+
return this.proto(undefined).from.call(this, entries);
|
|
857
|
+
}
|
|
858
|
+
entries() {
|
|
859
|
+
return this.proto(undefined).entries.call(this);
|
|
860
|
+
}
|
|
861
|
+
size() {
|
|
862
|
+
return this.proto(undefined).size.call(this);
|
|
744
863
|
}
|
|
864
|
+
get(p) {
|
|
865
|
+
return this.proto(p).get.call(this, p);
|
|
866
|
+
}
|
|
867
|
+
set(p, child) {
|
|
868
|
+
return this.proto(p).set.call(this, p, child);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
const box = (_) => (_ instanceof JSONBox ? _ : new JSONBoxDefault(_));
|
|
873
|
+
|
|
874
|
+
const boxed = (fn) => {
|
|
875
|
+
const boxedFn = (node, ...args) => unbox(fn(box(node), ...args));
|
|
876
|
+
boxedFn.fn = fn;
|
|
877
|
+
return boxedFn;
|
|
745
878
|
};
|
|
746
879
|
|
|
747
|
-
const
|
|
880
|
+
const ROOT = [];
|
|
881
|
+
const endsWith = (suffix) => suffix
|
|
882
|
+
.map((predicate, i) => (path) => cmp(predicate)(path[i + path.length - suffix.length]))
|
|
883
|
+
.reduceRight(and, trueF);
|
|
884
|
+
const cmp = (a) => a instanceof Function ? a : (b) => a === b;
|
|
885
|
+
|
|
886
|
+
const reduce = (reducer) => (node, initial, path = ROOT) => box(node)
|
|
887
|
+
.entries()
|
|
888
|
+
.reduce((acc, [p, _]) => reduce(reducer)(_, acc, path.concat(p)), reducer(initial, [path, box(node)]));
|
|
889
|
+
|
|
890
|
+
const set = boxed((target, [path, node]) => {
|
|
891
|
+
const [p, ...tail] = path;
|
|
892
|
+
return target.set(p, tail.length ? set(target.get(p), [tail, node]) : node);
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
const fromEntries = boxed((initial, tree) => tree.reduce(set.fn, initial));
|
|
896
|
+
|
|
897
|
+
const leafs = (node) => reduce((acc, [path, _]) => (isLeaf(_) ? [...acc, [path, unbox(_)]] : acc))(node, []);
|
|
898
|
+
const isLeaf = (_) => _.size() === 0;
|
|
899
|
+
|
|
900
|
+
const map = (mapper, initial = {}) => (node) => fromEntries(initial, leafs(node).map(_ => mapper(_)));
|
|
901
|
+
|
|
902
|
+
const init = (list) => list.slice(0, -1);
|
|
903
|
+
|
|
904
|
+
boxed((target, path = ROOT) => path.reduce((_, p) => _.get(p), target));
|
|
905
|
+
|
|
906
|
+
const remove = boxed((target, [p, ...tail]) => tail.length ? target.set(p, remove(target.get(p), tail)) : target.filter(([i]) => i !== p));
|
|
907
|
+
|
|
908
|
+
const isJSONRefPath = endsWith(['$ref']);
|
|
748
909
|
|
|
749
910
|
const parseJPointer = (uri) => uri.includes('#')
|
|
750
911
|
? uri
|
|
@@ -754,46 +915,17 @@
|
|
|
754
915
|
: [];
|
|
755
916
|
|
|
756
917
|
const resolveJPointer = (json, uri) => parseJPointer(uri).reduce(selectNodeByKey, json);
|
|
757
|
-
const selectNodeByKey = (json, key) =>
|
|
758
|
-
if (!json || !key) {
|
|
759
|
-
return json;
|
|
760
|
-
}
|
|
761
|
-
if (isJSONRecord(json)) {
|
|
762
|
-
return json[key];
|
|
763
|
-
}
|
|
764
|
-
else if (isJSONArray(json)) {
|
|
765
|
-
return json[parseInt(key, 10)];
|
|
766
|
-
}
|
|
767
|
-
else {
|
|
768
|
-
return json;
|
|
769
|
-
}
|
|
770
|
-
};
|
|
918
|
+
const selectNodeByKey = table([isJSONArray, (json, key) => json[parseInt(key, 10)]], [isJSONRecord, (json, key) => json[key]], [trueF, identity$1]);
|
|
771
919
|
|
|
772
|
-
const resolveRef = (json, resolver) =>
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
array: list => list.map(_ => resolveRef(_, resolver))
|
|
776
|
-
});
|
|
920
|
+
const resolveRef = (json, resolver) => map(([path, node]) => isJSONRefPath(path)
|
|
921
|
+
? [init(path), resolveJPointer(resolver(node), node)]
|
|
922
|
+
: [path, node])(json);
|
|
777
923
|
|
|
778
|
-
const
|
|
779
|
-
mapJSONNode(json, {
|
|
780
|
-
ref: json => visitor(json.$ref, path),
|
|
781
|
-
record: record => {
|
|
782
|
-
for (const key in record)
|
|
783
|
-
visitRef(record[key], visitor, [...path, key]);
|
|
784
|
-
},
|
|
785
|
-
array: list => {
|
|
786
|
-
for (let i = 0; i < list.length; i++)
|
|
787
|
-
visitRef(list[i], visitor, [...path, i]);
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
};
|
|
924
|
+
const refEntries = (json) => leafs(json).filter(t0(isJSONRefPath));
|
|
791
925
|
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return refs;
|
|
796
|
-
};
|
|
926
|
+
const unique$1 = (list) => [...new Set(list)];
|
|
927
|
+
|
|
928
|
+
const collectRef = (json) => unique$1(refEntries(json).map(([, _]) => _));
|
|
797
929
|
|
|
798
930
|
async function fetchJSON(url, options) {
|
|
799
931
|
try {
|
|
@@ -3156,10 +3288,10 @@
|
|
|
3156
3288
|
const LegalFormField = JSX(({ field, input }) => (jsx(InputControl, { label: "\u041E\u041F\u0424", placeholder: "\u041E\u041E\u041E, \u041F\u0410\u041E \u0438 \u0434\u0440.", ...getValidation(field('legalForm'), validatorObj.legalForm, input?.required), ...input })));
|
|
3157
3289
|
|
|
3158
3290
|
const OUT_SERVICE_BASE_URL = `${API_BASE_URI}/outservice`;
|
|
3159
|
-
const EMPTY_REGIONS = [];
|
|
3291
|
+
const EMPTY_REGIONS$1 = [];
|
|
3160
3292
|
async function getOutServiceRegions() {
|
|
3161
3293
|
const data = await fetchJSON(`${OUT_SERVICE_BASE_URL}/outserviceregions`);
|
|
3162
|
-
return data && Array.isArray(data) ? data : EMPTY_REGIONS;
|
|
3294
|
+
return data && Array.isArray(data) ? data : EMPTY_REGIONS$1;
|
|
3163
3295
|
}
|
|
3164
3296
|
|
|
3165
3297
|
const LocalitiesField = JSX(({ field, input }) => {
|
|
@@ -3292,9 +3424,11 @@
|
|
|
3292
3424
|
const arrayToOptions = (array) => (array ?? []).map((_) => ({ key: _, value: _ }));
|
|
3293
3425
|
|
|
3294
3426
|
const REGIONS_URL = `${API_BASE_URI}/regions`;
|
|
3427
|
+
const EMPTY_REGIONS = [];
|
|
3428
|
+
// TODO Почему url можно менять? Разве смысл не в инкапсуляции api url. Тоже под рефакторинг попадает
|
|
3295
3429
|
function useRegions(url = REGIONS_URL) {
|
|
3296
3430
|
const { data } = useAsyncData(url, fetchJSONUnsafe);
|
|
3297
|
-
return Array.isArray(data) ? data :
|
|
3431
|
+
return Array.isArray(data) ? data : EMPTY_REGIONS;
|
|
3298
3432
|
}
|
|
3299
3433
|
|
|
3300
3434
|
const RegionField = JSX(({ field, input, url }) => {
|
|
@@ -6010,7 +6144,7 @@
|
|
|
6010
6144
|
: [cellsNode, []];
|
|
6011
6145
|
const [isVisible, setIsVisible] = useState(false);
|
|
6012
6146
|
useEffect(() => defaultEventBus.subscribe('fold', (event) => {
|
|
6013
|
-
if (options?.parent !== undefined && event.parent === options?.parent) {
|
|
6147
|
+
if (event && options?.parent !== undefined && event.parent === options?.parent) {
|
|
6014
6148
|
setIsVisible(event.isUnfolded);
|
|
6015
6149
|
}
|
|
6016
6150
|
}), [options?.parent]);
|
|
@@ -6024,14 +6158,13 @@
|
|
|
6024
6158
|
}
|
|
6025
6159
|
}, type: "button", ...(isUnfolded ? getAspectsAttributes(data) : {}), children: [jsx("div", { children: isUnfolded ? 'Скрыть' : 'Подробнее о тарифе' }), jsx(Icon, { className: "text-primary-text", name: isUnfolded ? 'ArrowUpIcon' : 'ArrowDownIcon', width: "16", height: "16" })] }));
|
|
6026
6160
|
|
|
6027
|
-
const PORTAL_NATURAL_URL = '/';
|
|
6028
6161
|
const UPDATING_INTERVAL = 60000 * 4;
|
|
6029
|
-
const updateRefreshToken = () => {
|
|
6162
|
+
const updateRefreshToken = (failCallback) => {
|
|
6030
6163
|
const refreshToken = globalThis.sessionStorage?.getItem('refreshToken');
|
|
6031
6164
|
const accessToken = globalThis.sessionStorage?.getItem('accessToken');
|
|
6032
6165
|
const taskId = globalThis.localStorage.getItem('taskId');
|
|
6033
6166
|
if (!accessToken || !refreshToken || !taskId) {
|
|
6034
|
-
|
|
6167
|
+
failCallback();
|
|
6035
6168
|
return () => null;
|
|
6036
6169
|
}
|
|
6037
6170
|
const updateTokenRequest = async () => {
|
|
@@ -6041,8 +6174,10 @@
|
|
|
6041
6174
|
// eslint-disable-next-line camelcase
|
|
6042
6175
|
access_token: accessToken,
|
|
6043
6176
|
});
|
|
6044
|
-
if (res) {
|
|
6045
|
-
|
|
6177
|
+
if (res?.status == 401) {
|
|
6178
|
+
failCallback();
|
|
6179
|
+
}
|
|
6180
|
+
if (res?.ok) {
|
|
6046
6181
|
const data = await res.json();
|
|
6047
6182
|
globalThis.sessionStorage.setItem('refreshToken', data.refresh_token);
|
|
6048
6183
|
globalThis.sessionStorage.setItem('accessToken', data.access_token);
|
|
@@ -6052,10 +6187,15 @@
|
|
|
6052
6187
|
const timer = setInterval(updateTokenRequest, UPDATING_INTERVAL);
|
|
6053
6188
|
return () => clearInterval(timer);
|
|
6054
6189
|
};
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6190
|
+
|
|
6191
|
+
function useNavigator() {
|
|
6192
|
+
return useNavigator._impl();
|
|
6193
|
+
}
|
|
6194
|
+
useNavigator._impl = () => ({
|
|
6195
|
+
assign: (url) => globalThis.location.assign(url),
|
|
6196
|
+
});
|
|
6197
|
+
useNavigator.setup = (impl) => {
|
|
6198
|
+
useNavigator._impl = impl;
|
|
6059
6199
|
};
|
|
6060
6200
|
|
|
6061
6201
|
const ProgressBar = JSX(({ step = 10, description, showPercentage = true }) => (jsxs("div", { children: [jsx("div", { className: "h-4 w-full bg-gray relative", children: jsx("div", { className: "h-4 bg-green", style: { width: `${step}%` } }) }), jsxs("div", { className: "relative", children: [showPercentage ? jsxs("div", { className: "absolute left-2/4 text-green", children: [step, "%"] }) : null, description ? jsx("div", { className: "text-right mr-4 text-gray", children: description }) : null] })] })));
|
|
@@ -6921,6 +7061,7 @@
|
|
|
6921
7061
|
],
|
|
6922
7062
|
];
|
|
6923
7063
|
|
|
7064
|
+
const PORTAL_NATURAL_URL$1 = '/';
|
|
6924
7065
|
const WIZARD_STEPS$1 = 6;
|
|
6925
7066
|
const WIZARD_TITLES$1 = [
|
|
6926
7067
|
'Параметры карты',
|
|
@@ -6934,7 +7075,8 @@
|
|
|
6934
7075
|
const [step, setStep] = useState(0);
|
|
6935
7076
|
const formContainerRef = useRef(null);
|
|
6936
7077
|
const scrollToTop = useCallback(() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }), [formContainerRef]);
|
|
6937
|
-
|
|
7078
|
+
const navigator = useNavigator();
|
|
7079
|
+
useEffect(() => updateRefreshToken(() => navigator.assign(PORTAL_NATURAL_URL$1)), []);
|
|
6938
7080
|
const handleNextStep = useCallback(() => {
|
|
6939
7081
|
setStep((_) => Math.min(_ + 1, WIZARD_STEPS$1));
|
|
6940
7082
|
scrollToTop();
|
|
@@ -7707,6 +7849,7 @@
|
|
|
7707
7849
|
],
|
|
7708
7850
|
];
|
|
7709
7851
|
|
|
7852
|
+
const PORTAL_NATURAL_URL = '/';
|
|
7710
7853
|
const WIZARD_STEPS = 5;
|
|
7711
7854
|
const WIZARD_TITLES = [
|
|
7712
7855
|
'',
|
|
@@ -7720,7 +7863,8 @@
|
|
|
7720
7863
|
const [step, setStep] = useState(0);
|
|
7721
7864
|
const formContainerRef = useRef(null);
|
|
7722
7865
|
const scrollToTop = useCallback(() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }), [formContainerRef]);
|
|
7723
|
-
|
|
7866
|
+
const navigator = useNavigator();
|
|
7867
|
+
useEffect(() => updateRefreshToken(() => navigator.assign(PORTAL_NATURAL_URL)), []);
|
|
7724
7868
|
const handleNextStep = useCallback(() => {
|
|
7725
7869
|
setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
|
|
7726
7870
|
scrollToTop();
|
|
@@ -7914,47 +8058,166 @@
|
|
|
7914
8058
|
};
|
|
7915
8059
|
const ErrorBlock = JSX(({ className = '', title, description, error, button, ...rest }) => (jsxs(BlockWrapper, { className: style('flex flex-col justify-center items-center', className), defaultPadding: style('p-6xl'), version: "transparent", ...rest, children: [jsx("div", { className: "flex justify-center", children: renderErrorContent(error) }), jsx(Headline, { title: title, description: description, headlineVersion: "XL", isEmbedded: true, className: "mb-2xl last:mb-0" }), button?.text ? (jsx(LinkButton, { version: button?.version, text: button?.text, ...button })) : null] })));
|
|
7916
8060
|
|
|
7917
|
-
|
|
7918
|
-
const [
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
8061
|
+
function copy(source, target) {
|
|
8062
|
+
for (const [k, v] of source.entries()) {
|
|
8063
|
+
if (v !== null && v !== undefined) {
|
|
8064
|
+
target.setItem(k, v);
|
|
8065
|
+
}
|
|
8066
|
+
else {
|
|
8067
|
+
target.removeItem(k);
|
|
8068
|
+
}
|
|
8069
|
+
}
|
|
8070
|
+
}
|
|
8071
|
+
|
|
8072
|
+
function replicate(primary, secondary) {
|
|
8073
|
+
copy(primary, secondary);
|
|
8074
|
+
copy(secondary, primary);
|
|
8075
|
+
return primary.bus.watch(({ type, event }) => {
|
|
8076
|
+
if (event !== null && event !== undefined) {
|
|
8077
|
+
secondary.setItem(type, event);
|
|
8078
|
+
}
|
|
8079
|
+
else {
|
|
8080
|
+
secondary.removeItem(type);
|
|
8081
|
+
}
|
|
8082
|
+
});
|
|
8083
|
+
}
|
|
8084
|
+
|
|
8085
|
+
class StorageAdapter {
|
|
8086
|
+
storage;
|
|
8087
|
+
bus;
|
|
8088
|
+
get size() {
|
|
8089
|
+
return this.storage?.length ?? 0;
|
|
8090
|
+
}
|
|
8091
|
+
constructor(storage, bus = new EventBus()) {
|
|
8092
|
+
this.storage = storage;
|
|
8093
|
+
this.bus = bus;
|
|
8094
|
+
}
|
|
8095
|
+
hasItem(key) {
|
|
8096
|
+
return Boolean(this.storage?.getItem(String(key)));
|
|
8097
|
+
}
|
|
8098
|
+
getItem(key) {
|
|
8099
|
+
const _ = this.storage?.getItem(String(key)) ?? null;
|
|
8100
|
+
try {
|
|
8101
|
+
return JSON.parse(String(_));
|
|
8102
|
+
}
|
|
8103
|
+
catch (ex) {
|
|
8104
|
+
return null;
|
|
8105
|
+
}
|
|
8106
|
+
}
|
|
8107
|
+
entries() {
|
|
8108
|
+
return Array.from({ length: this.size }, (_, i) => {
|
|
8109
|
+
const k = String(this.storage?.key(i));
|
|
8110
|
+
return [k, this.getItem(k)];
|
|
8111
|
+
});
|
|
8112
|
+
}
|
|
8113
|
+
setItem(key, value) {
|
|
8114
|
+
if (value !== null) {
|
|
8115
|
+
this.storage?.setItem(String(key), JSON.stringify(value));
|
|
8116
|
+
}
|
|
8117
|
+
else {
|
|
8118
|
+
this.storage?.removeItem(String(key));
|
|
8119
|
+
}
|
|
8120
|
+
this.bus?.subject(key, value);
|
|
8121
|
+
}
|
|
8122
|
+
removeItem(key) {
|
|
8123
|
+
this.storage?.removeItem(String(key));
|
|
8124
|
+
this.bus?.subject(key, null);
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
|
|
8128
|
+
class Store {
|
|
8129
|
+
bus;
|
|
8130
|
+
store = new Map();
|
|
8131
|
+
get size() {
|
|
8132
|
+
return this.store.size;
|
|
8133
|
+
}
|
|
8134
|
+
constructor(bus = new EventBus()) {
|
|
8135
|
+
this.bus = bus;
|
|
8136
|
+
}
|
|
8137
|
+
hasItem(key) {
|
|
8138
|
+
return this.store.has(key);
|
|
8139
|
+
}
|
|
8140
|
+
getItem(key) {
|
|
8141
|
+
return this.store.get(key);
|
|
8142
|
+
}
|
|
8143
|
+
entries() {
|
|
8144
|
+
return this.store.entries();
|
|
8145
|
+
}
|
|
8146
|
+
setItem(key, value) {
|
|
8147
|
+
this.store.set(key, value);
|
|
8148
|
+
this.bus.subject(key, value);
|
|
8149
|
+
}
|
|
8150
|
+
removeItem(key) {
|
|
8151
|
+
this.store.delete(key);
|
|
8152
|
+
this.bus.subject(key, null);
|
|
8153
|
+
}
|
|
8154
|
+
}
|
|
8155
|
+
|
|
8156
|
+
function useRerender() {
|
|
8157
|
+
const [, setCount] = useState(0);
|
|
8158
|
+
return useCallback(() => setCount(_ => (_ + 1) % (1 << 16)), []);
|
|
8159
|
+
}
|
|
8160
|
+
|
|
8161
|
+
const DEFAULT_METHODS = {};
|
|
8162
|
+
/**
|
|
8163
|
+
* MobX like reactivity (simplified).
|
|
8164
|
+
* Can be used to migrate from Redux/MobX or something else
|
|
8165
|
+
*
|
|
8166
|
+
* @param store
|
|
8167
|
+
* @returns reactive proxy backed by store
|
|
8168
|
+
*/
|
|
8169
|
+
function useStore(store, methods = DEFAULT_METHODS) {
|
|
8170
|
+
const deps = useRef(null);
|
|
8171
|
+
const render = useRerender();
|
|
8172
|
+
useEffect(() => store.bus.watch(ev => {
|
|
8173
|
+
if (deps.current?.has(String(ev.type))) {
|
|
8174
|
+
render();
|
|
8175
|
+
}
|
|
8176
|
+
}), [store, render]);
|
|
8177
|
+
return useMemo(() => new Proxy(methods, {
|
|
8178
|
+
get(_, key) {
|
|
8179
|
+
deps.current ||= new Set();
|
|
8180
|
+
deps.current.add(key);
|
|
8181
|
+
return store.getItem(key);
|
|
8182
|
+
},
|
|
8183
|
+
has(_, key) {
|
|
8184
|
+
deps.current ||= new Set();
|
|
8185
|
+
deps.current.add(key);
|
|
8186
|
+
return store.hasItem(key);
|
|
8187
|
+
},
|
|
8188
|
+
set(_, key, value) {
|
|
8189
|
+
store.setItem(key, value);
|
|
8190
|
+
return true;
|
|
8191
|
+
},
|
|
8192
|
+
deleteProperty(_, key) {
|
|
8193
|
+
store.removeItem(key);
|
|
8194
|
+
return true;
|
|
8195
|
+
}
|
|
8196
|
+
}), [store]);
|
|
8197
|
+
}
|
|
8198
|
+
|
|
8199
|
+
const localStore = new Store(); // localStorage cache
|
|
8200
|
+
replicate(localStore, new StorageAdapter(globalThis?.localStorage));
|
|
8201
|
+
function useLocalStore(methods) {
|
|
8202
|
+
return useStore(localStore, methods);
|
|
8203
|
+
}
|
|
7923
8204
|
|
|
7924
8205
|
const REGION_URL = `${API_BASE_URI}/region`;
|
|
7925
|
-
const LOCATION_STORAGE_KEY = 'location';
|
|
7926
8206
|
function useLocation(defaultLocation = 'Москва') {
|
|
7927
|
-
const
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
const
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
}
|
|
7937
|
-
}, [
|
|
7938
|
-
|
|
8207
|
+
const locationStore = useLocalStore();
|
|
8208
|
+
return locationStore.location ?? { name: defaultLocation };
|
|
8209
|
+
}
|
|
8210
|
+
function useDefaultLocation(defaultLocation = 'Москва') {
|
|
8211
|
+
const locationStore = useLocalStore();
|
|
8212
|
+
const preselectLocation = useCallback(async () => {
|
|
8213
|
+
if (!locationStore.location) {
|
|
8214
|
+
const region = await fetchJSON(REGION_URL);
|
|
8215
|
+
locationStore.location = region ?? { name: defaultLocation };
|
|
8216
|
+
}
|
|
8217
|
+
}, [locationStore, defaultLocation]);
|
|
8218
|
+
useAsyncData(REGION_URL, preselectLocation);
|
|
8219
|
+
return locationStore;
|
|
7939
8220
|
}
|
|
7940
|
-
const hasStoredLocation = () => Boolean(globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY));
|
|
7941
|
-
const restoreLocation = () => {
|
|
7942
|
-
try {
|
|
7943
|
-
const data = globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY);
|
|
7944
|
-
return data && JSON.parse(data);
|
|
7945
|
-
}
|
|
7946
|
-
catch (ex) {
|
|
7947
|
-
return null;
|
|
7948
|
-
}
|
|
7949
|
-
};
|
|
7950
|
-
const storeLocation = (_) => {
|
|
7951
|
-
try {
|
|
7952
|
-
globalThis.localStorage?.setItem(LOCATION_STORAGE_KEY, JSON.stringify(_));
|
|
7953
|
-
}
|
|
7954
|
-
catch (ex) {
|
|
7955
|
-
// Do nothing
|
|
7956
|
-
}
|
|
7957
|
-
};
|
|
7958
8221
|
|
|
7959
8222
|
var Currency;
|
|
7960
8223
|
(function (Currency) {
|
|
@@ -8096,7 +8359,7 @@
|
|
|
8096
8359
|
}
|
|
8097
8360
|
|
|
8098
8361
|
const ExchangeRateTile = JSX(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
|
|
8099
|
-
const
|
|
8362
|
+
const currentLocation = useLocation();
|
|
8100
8363
|
const exchangeRates = useFetchExchangeRateData(currentLocation);
|
|
8101
8364
|
const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
|
|
8102
8365
|
const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
|
|
@@ -8583,7 +8846,7 @@
|
|
|
8583
8846
|
designDisabledPeople: (item) => Boolean(item.designDisabledPeople),
|
|
8584
8847
|
};
|
|
8585
8848
|
const AtmsMap = JSX(({ descriptionData, className }) => {
|
|
8586
|
-
const
|
|
8849
|
+
const currentLocation = useLocation();
|
|
8587
8850
|
const regionCode = currentLocation?.code ?? '000';
|
|
8588
8851
|
const { data: officesData, isLoad } = useAtms(regionCode);
|
|
8589
8852
|
return (jsx(OfficesAtmsMapLayout, { className: className, filterItems: filterItems, data: officesData, isLoad: isLoad, initFilterState: INITIAL_FILTRATION_STATE, renderCard: renderAtmCard, getBalloon: getAtmPoint, title: `Банкоматы филиала ${currentLocation?.name}`, descriptionData: descriptionData }));
|
|
@@ -8636,7 +8899,7 @@
|
|
|
8636
8899
|
};
|
|
8637
8900
|
|
|
8638
8901
|
const OfficesMap = JSX(({ className }) => {
|
|
8639
|
-
const
|
|
8902
|
+
const currentLocation = useLocation();
|
|
8640
8903
|
const regionCode = currentLocation?.code ?? '000';
|
|
8641
8904
|
const { data, isLoad } = useOffices(regionCode);
|
|
8642
8905
|
return (jsx(OfficesAtmsMapLayout, { className: className, data: data?.branches, isLoad: isLoad, remoteWorkplaces: data?.remoteWorkplaces, renderCard: renderOfficeCard, renderRemoteWorkplaceCard: renderRemoteWorkplaceCard, getBalloon: getOfficePoint, getBalloonRemoteWorkplaces: getRemoteWorkplacePoint, title: `Офисы филиала ${currentLocation?.name}` }));
|
|
@@ -8885,6 +9148,9 @@
|
|
|
8885
9148
|
pop();
|
|
8886
9149
|
}, [dialogs, onClose]);
|
|
8887
9150
|
useEffect(() => defaultEventBus.subscribe('dialog', (action) => {
|
|
9151
|
+
if (!action) {
|
|
9152
|
+
return;
|
|
9153
|
+
}
|
|
8888
9154
|
switch (action.type) {
|
|
8889
9155
|
case 'open':
|
|
8890
9156
|
push(action);
|
|
@@ -8993,27 +9259,33 @@
|
|
|
8993
9259
|
return (jsxs("form", { className: `font-sans relative ${className}`, children: [jsx("div", { className: "absolute rounded h-full flex items-center justify-center pl-m max-w-44 gap-s pointer-events-none", children: searchTerm ? null : (jsx("label", { htmlFor: "search-bar-input", className: `text-secondary-text `, children: "\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0444\u0438\u043B\u0438\u0430\u043B\u0430\u043C" })) }), jsx("input", { id: "search-bar-input", className: style(inputValidStyle, `h-12 pl-m w-full peer text-l text-black rounded-md box-border`), value: searchTerm, onChange: (e) => onSearch(e.target.value.toLowerCase()), type: "text", name: "location-search-bar-input" })] }));
|
|
8994
9260
|
});
|
|
8995
9261
|
|
|
8996
|
-
const
|
|
8997
|
-
|
|
8998
|
-
const [currentLocation, selectCurrentLocation] = useLocation(branches?.default);
|
|
9262
|
+
const SelectedLocation = JSX(({ defaultLocation }) => {
|
|
9263
|
+
const currentLocation = useLocation(defaultLocation);
|
|
8999
9264
|
const link = useLink();
|
|
9000
9265
|
const { href } = link({ href: `/branches/${currentLocation.slug}` });
|
|
9266
|
+
return currentLocation ? (jsx("div", { className: "mb-s", children: jsxs(Paragraph, { size: "text-l", color: "text-primary-text", children: ["\u0421\u0435\u0439\u0447\u0430\u0441 \u0432\u044B\u0431\u0440\u0430\u043D:", jsx(LinkWrapper, { href: href, className: "inline mx-2xs text-primary-main", children: currentLocation.name })] }) })) : null;
|
|
9267
|
+
});
|
|
9268
|
+
|
|
9269
|
+
const SEARCH_TERM_MIN_LENGTH = 3;
|
|
9270
|
+
const LocationDialog = JSX(({ foreignOffices, branches }) => {
|
|
9271
|
+
const locationStore = useDefaultLocation(branches?.default);
|
|
9001
9272
|
const [query, setQuery] = useState('');
|
|
9002
|
-
const
|
|
9003
|
-
const
|
|
9273
|
+
const rawRegions = useRegions();
|
|
9274
|
+
const regions = useMemo(() => cleanUpRegions(rawRegions).sort((a, b) => a.name.localeCompare(b.name)), [rawRegions]);
|
|
9275
|
+
const regionsGroupByLetter = useMemo(() => groupBy(regions, regionFirstLetter), [regions]);
|
|
9004
9276
|
const { close } = useDialogManager();
|
|
9005
|
-
const handleChangeLocation = useCallback((
|
|
9006
|
-
|
|
9277
|
+
const handleChangeLocation = useCallback((_) => {
|
|
9278
|
+
locationStore.location = _;
|
|
9007
9279
|
close();
|
|
9008
|
-
}, []);
|
|
9009
|
-
return (jsxs(Dialog, { className: "pb-20", head: jsxs("div", { children: [jsx(Text, { size: "text-h4", color: "text-primary-text", children: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B" }),
|
|
9280
|
+
}, [locationStore]);
|
|
9281
|
+
return (jsxs(Dialog, { className: "pb-20", head: jsxs("div", { children: [jsx(Text, { size: "text-h4", color: "text-primary-text", children: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0438\u043B\u0438\u0430\u043B" }), jsx(SelectedLocation, { defaultLocation: branches?.default }), jsx(SearchBar, { onSearch: setQuery, searchTerm: query })] }), children: [query && query.length >= SEARCH_TERM_MIN_LENGTH ? (jsx("div", { children: regions
|
|
9010
9282
|
.filter(({ name }) => name && jaroWinklerDistance(name.toLowerCase())(query.toLowerCase()) >= 0.8)
|
|
9011
9283
|
.map(renderRegion(branches?.dataSelect, handleChangeLocation)) })) : (jsx("div", { className: "columns-1 sm:columns-3 md:columns-4 lg:columns-5", children: Array.from(regionsGroupByLetter.entries()).map(renderRegionGroup(handleChangeLocation, branches?.dataSelect)) })), renderForeignOffices(foreignOffices)] }));
|
|
9012
9284
|
});
|
|
9013
|
-
const regionFirstLetter = (region) => region.name?.charAt(0)
|
|
9285
|
+
const regionFirstLetter = (region) => region.name?.charAt(0) ?? '';
|
|
9014
9286
|
const cleanUpRegions = (regions) => regions.map((region) => ({
|
|
9015
9287
|
...region,
|
|
9016
|
-
name: region.name?.replace(/республика|область|край'/gi, '').trim()
|
|
9288
|
+
name: region.name?.replace(/республика|область|край'/gi, '').trim() ?? '',
|
|
9017
9289
|
}));
|
|
9018
9290
|
|
|
9019
9291
|
const useLocationDialog = (props) => {
|
|
@@ -9026,7 +9298,7 @@
|
|
|
9026
9298
|
|
|
9027
9299
|
const BurgerMenuDialog = JSX(({ menuRef, menuItem, locationDialogProps, closeAll }) => {
|
|
9028
9300
|
const locationDialog = useLocationDialog(locationDialogProps || {});
|
|
9029
|
-
const
|
|
9301
|
+
const { name: location } = useLocation();
|
|
9030
9302
|
const menuDimensions = menuRef?.current?.getBoundingClientRect();
|
|
9031
9303
|
const basePath = getBasePath(env.SITE_URL);
|
|
9032
9304
|
const handleIframeLoad = () => {
|
|
@@ -9589,6 +9861,9 @@
|
|
|
9589
9861
|
setPopup(null);
|
|
9590
9862
|
}, []);
|
|
9591
9863
|
useEffect(() => defaultEventBus.subscribe('popup', (action) => {
|
|
9864
|
+
if (!action) {
|
|
9865
|
+
return;
|
|
9866
|
+
}
|
|
9592
9867
|
switch (action.type) {
|
|
9593
9868
|
case 'open':
|
|
9594
9869
|
case 'update':
|
|
@@ -9622,6 +9897,7 @@
|
|
|
9622
9897
|
const { slots, blocks, fallback, ...pageContent } = data;
|
|
9623
9898
|
const resolvedPageContent = useJSONRef(pageContent, fallback);
|
|
9624
9899
|
useClickHandler();
|
|
9900
|
+
useDefaultLocation();
|
|
9625
9901
|
const options = {
|
|
9626
9902
|
key: '',
|
|
9627
9903
|
page: { slots, blocks, fallback, ...resolvedPageContent },
|
|
@@ -9643,7 +9919,7 @@
|
|
|
9643
9919
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
9644
9920
|
});
|
|
9645
9921
|
|
|
9646
|
-
const packageVersion = "0.14.
|
|
9922
|
+
const packageVersion = "0.14.676";
|
|
9647
9923
|
|
|
9648
9924
|
exports.Blocks = Blocks;
|
|
9649
9925
|
exports.ContentPage = ContentPage;
|
|
@@ -9654,6 +9930,7 @@
|
|
|
9654
9930
|
exports.setup = setup;
|
|
9655
9931
|
exports.setupHooks = setupHooks;
|
|
9656
9932
|
exports.url = url;
|
|
9933
|
+
exports.useNavigator = useNavigator;
|
|
9657
9934
|
exports.useRouter = useRouter;
|
|
9658
9935
|
|
|
9659
9936
|
Object.defineProperty(exports, '__esModule', { value: true });
|