wovvmap-webview-bridge 1.0.29 → 1.0.39
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/README.md +1563 -228
- package/dist/handlers/WebBridgeHandlers.d.ts +3 -15
- package/dist/handlers/WebBridgeHandlers.d.ts.map +1 -1
- package/dist/handlers/WebBridgeHandlers.js +94 -53
- package/dist/index.d.ts +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -3
- package/dist/types/types.d.ts +277 -316
- package/dist/types/types.d.ts.map +1 -1
- package/dist/web.d.ts +19 -3
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +19 -3
- package/dist/webviewBridge/BridgeService.d.ts +34 -17
- package/dist/webviewBridge/BridgeService.d.ts.map +1 -1
- package/dist/webviewBridge/BridgeService.js +227 -51
- package/dist/webviewBridge/WebViewBridgeRef.d.ts +3 -3
- package/dist/webviewBridge/WebViewBridgeRef.d.ts.map +1 -1
- package/dist/webviewBridge/WebViewBridgeRef.js +1 -1
- package/dist/webviewBridge/WebViewScreen.d.ts.map +1 -1
- package/dist/webviewBridge/services/DirectionBridgeService.d.ts +32 -0
- package/dist/webviewBridge/services/DirectionBridgeService.d.ts.map +1 -0
- package/dist/webviewBridge/services/DirectionBridgeService.js +72 -0
- package/dist/webviewBridge/services/FloorBridgeService.d.ts +4 -0
- package/dist/webviewBridge/services/FloorBridgeService.d.ts.map +1 -0
- package/dist/webviewBridge/services/FloorBridgeService.js +11 -0
- package/dist/webviewBridge/services/SelectionBridgeService.d.ts +10 -0
- package/dist/webviewBridge/services/SelectionBridgeService.d.ts.map +1 -0
- package/dist/webviewBridge/services/SelectionBridgeService.js +43 -0
- package/dist/webviewBridge/services/StepNavigationBridgeService.d.ts +7 -0
- package/dist/webviewBridge/services/StepNavigationBridgeService.d.ts.map +1 -0
- package/dist/webviewBridge/services/StepNavigationBridgeService.js +15 -0
- package/dist/webviewBridge/services/ViewerBridgeService.d.ts +8 -0
- package/dist/webviewBridge/services/ViewerBridgeService.d.ts.map +1 -0
- package/dist/webviewBridge/services/ViewerBridgeService.js +20 -0
- package/dist/webviewBridge/services/ZoomBridgeService.d.ts +5 -0
- package/dist/webviewBridge/services/ZoomBridgeService.d.ts.map +1 -0
- package/dist/webviewBridge/services/ZoomBridgeService.js +9 -0
- package/dist/webviewBridge/store/useAmenityStore.d.ts +20 -0
- package/dist/webviewBridge/store/useAmenityStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useAmenityStore.js +6 -0
- package/dist/webviewBridge/store/useBridgeStorage.d.ts +14 -0
- package/dist/webviewBridge/store/useBridgeStorage.d.ts.map +1 -0
- package/dist/webviewBridge/store/useBridgeStorage.js +13 -0
- package/dist/webviewBridge/store/useCategoryStore.d.ts +20 -0
- package/dist/webviewBridge/store/useCategoryStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useCategoryStore.js +6 -0
- package/dist/webviewBridge/store/useDirectionStore.d.ts +55 -0
- package/dist/webviewBridge/store/useDirectionStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useDirectionStore.js +35 -0
- package/dist/webviewBridge/store/useDirectionsRouteRequestStore.d.ts +14 -0
- package/dist/webviewBridge/store/useDirectionsRouteRequestStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useDirectionsRouteRequestStore.js +25 -0
- package/dist/webviewBridge/store/useFloorStore.d.ts +18 -0
- package/dist/webviewBridge/store/useFloorStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useFloorStore.js +8 -0
- package/dist/webviewBridge/store/useNavigationStore.d.ts +23 -0
- package/dist/webviewBridge/store/useNavigationStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useNavigationStore.js +18 -0
- package/dist/webviewBridge/store/useNodePointStore.d.ts +42 -0
- package/dist/webviewBridge/store/useNodePointStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useNodePointStore.js +19 -0
- package/dist/webviewBridge/store/useSelectionStore.d.ts +35 -0
- package/dist/webviewBridge/store/useSelectionStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useSelectionStore.js +32 -0
- package/dist/webviewBridge/store/useSubCategoryStore.d.ts +20 -0
- package/dist/webviewBridge/store/useSubCategoryStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useSubCategoryStore.js +6 -0
- package/dist/webviewBridge/store/useViewerStore.d.ts +35 -0
- package/dist/webviewBridge/store/useViewerStore.d.ts.map +1 -0
- package/dist/webviewBridge/store/useViewerStore.js +35 -0
- package/dist/webviewBridge/useBridgeStorage.d.ts +45 -0
- package/dist/webviewBridge/useBridgeStorage.d.ts.map +1 -0
- package/dist/webviewBridge/useBridgeStorage.js +43 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BridgeService } from "../BridgeService";
|
|
2
|
+
import { useFloorStore } from "../store/useFloorStore";
|
|
3
|
+
export class FloorBridgeService {
|
|
4
|
+
static changeFloor(floorIndex, animateCamera = true) {
|
|
5
|
+
const currentFloor = useFloorStore.getState().activeFloor;
|
|
6
|
+
if (floorIndex !== currentFloor) {
|
|
7
|
+
useFloorStore.getState().setActiveFloor(floorIndex);
|
|
8
|
+
BridgeService.changeFloor(floorIndex, animateCamera);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Amenity, Category, SubCategory } from "../../types/types";
|
|
2
|
+
export declare class SelectionBridgeService {
|
|
3
|
+
static selectCategory(category: Category): boolean;
|
|
4
|
+
static selectSubCategory(subCategory: SubCategory): boolean;
|
|
5
|
+
static selectAmenity(amenity: Amenity): boolean;
|
|
6
|
+
static toggleOffers(): boolean;
|
|
7
|
+
static clearSelection(): void;
|
|
8
|
+
static syncHighlightsWithState(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=SelectionBridgeService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionBridgeService.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/services/SelectionBridgeService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGxE,qBAAa,sBAAsB;WACnB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;WAW3C,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;WAUpD,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;WAUxC,YAAY,IAAI,OAAO;WAOvB,cAAc,IAAI,IAAI;WAKtB,uBAAuB,IAAI,IAAI;CAG9C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BridgeService } from "../BridgeService";
|
|
2
|
+
import { useSelectionStore } from "../store/useSelectionStore";
|
|
3
|
+
import { DirectionBridgeService } from "./DirectionBridgeService";
|
|
4
|
+
export class SelectionBridgeService {
|
|
5
|
+
static selectCategory(category) {
|
|
6
|
+
var _a;
|
|
7
|
+
const selectionStore = useSelectionStore.getState();
|
|
8
|
+
if (((_a = selectionStore.activeCategory) === null || _a === void 0 ? void 0 : _a.code.toString()) === category.code.toString()) {
|
|
9
|
+
BridgeService.clearActiveSelection();
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
BridgeService.setActiveSelection("Category", category.code.toString());
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
static selectSubCategory(subCategory) {
|
|
16
|
+
const selectionStore = useSelectionStore.getState();
|
|
17
|
+
const isAlreadySelected = selectionStore.activeSelection.id === subCategory.code.toString() &&
|
|
18
|
+
selectionStore.activeSelection.type === "SubCategory";
|
|
19
|
+
BridgeService.setActiveSelection("SubCategory", subCategory.code.toString());
|
|
20
|
+
return !isAlreadySelected;
|
|
21
|
+
}
|
|
22
|
+
static selectAmenity(amenity) {
|
|
23
|
+
if (!amenity.nodePointsKey || amenity.nodePointsKey.length === 0) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
DirectionBridgeService.setDestination(amenity.nodePointsKey.join("<->"), true, false);
|
|
27
|
+
BridgeService.setActiveSelection("Amenity", amenity.id.toString());
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
static toggleOffers() {
|
|
31
|
+
const selectionStore = useSelectionStore.getState();
|
|
32
|
+
const nextState = !selectionStore.isOfferSelected;
|
|
33
|
+
BridgeService.setOfferSelected(nextState);
|
|
34
|
+
return nextState;
|
|
35
|
+
}
|
|
36
|
+
static clearSelection() {
|
|
37
|
+
BridgeService.clearActiveSelection();
|
|
38
|
+
BridgeService.setOfferSelected(false);
|
|
39
|
+
}
|
|
40
|
+
static syncHighlightsWithState() {
|
|
41
|
+
// Highlighting is owned by the embedded viewer; host package services only send bridge commands.
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepNavigationBridgeService.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/services/StepNavigationBridgeService.ts"],"names":[],"mappings":"AAEA,qBAAa,2BAA2B;WACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;WAI7B,QAAQ,IAAI,IAAI;WAIhB,QAAQ,IAAI,IAAI;WAIhB,UAAU,IAAI,IAAI;CAGjC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BridgeService } from "../BridgeService";
|
|
2
|
+
export class StepNavigationBridgeService {
|
|
3
|
+
static goToStep(index) {
|
|
4
|
+
BridgeService.goToStep(index);
|
|
5
|
+
}
|
|
6
|
+
static nextStep() {
|
|
7
|
+
BridgeService.nextStep();
|
|
8
|
+
}
|
|
9
|
+
static prevStep() {
|
|
10
|
+
BridgeService.prevStep();
|
|
11
|
+
}
|
|
12
|
+
static finishStep() {
|
|
13
|
+
BridgeService.finishStep();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CameraView, TextType, ViewMode } from "../../types/types";
|
|
2
|
+
export declare class ViewerBridgeService {
|
|
3
|
+
static setViewMode(viewMode: ViewMode, animate?: boolean): void;
|
|
4
|
+
static setCameraView(cameraView: CameraView): void;
|
|
5
|
+
static setTextType(textType: TextType): void;
|
|
6
|
+
static setShow2DIcon(show2DIcon: boolean): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ViewerBridgeService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewerBridgeService.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/services/ViewerBridgeService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAExE,qBAAa,mBAAmB;WAChB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,OAAc,GAAG,IAAI;WAK9D,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;WAK3C,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;WAKrC,aAAa,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI;CAIvD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BridgeService } from "../BridgeService";
|
|
2
|
+
import { useViewerStore } from "../store/useViewerStore";
|
|
3
|
+
export class ViewerBridgeService {
|
|
4
|
+
static setViewMode(viewMode, animate = true) {
|
|
5
|
+
useViewerStore.getState().setViewMode(viewMode);
|
|
6
|
+
BridgeService.setViewMode(viewMode, animate);
|
|
7
|
+
}
|
|
8
|
+
static setCameraView(cameraView) {
|
|
9
|
+
useViewerStore.getState().setCameraView(cameraView);
|
|
10
|
+
BridgeService.setCameraView(cameraView);
|
|
11
|
+
}
|
|
12
|
+
static setTextType(textType) {
|
|
13
|
+
useViewerStore.getState().setTextType(textType);
|
|
14
|
+
BridgeService.setTextType(textType);
|
|
15
|
+
}
|
|
16
|
+
static setShow2DIcon(show2DIcon) {
|
|
17
|
+
useViewerStore.getState().setShow2DIcon(show2DIcon);
|
|
18
|
+
BridgeService.setShow2DIcon(show2DIcon);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoomBridgeService.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/services/ZoomBridgeService.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAiB;WACd,MAAM,IAAI,IAAI;WAId,OAAO,IAAI,IAAI;CAG9B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Amenity } from '../../types/types';
|
|
2
|
+
interface AmenityStore {
|
|
3
|
+
amenities: Record<string, Amenity>;
|
|
4
|
+
/**
|
|
5
|
+
* @description Sets the amenities collection into the store.
|
|
6
|
+
* @usecase Applies the full set of amenities after parsing map JSON or retrieving from cache.
|
|
7
|
+
*/
|
|
8
|
+
setAmenities: (amenities: Record<string, Amenity>) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useAmenityStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AmenityStore>, "subscribe"> & {
|
|
11
|
+
subscribe: {
|
|
12
|
+
(listener: (selectedState: AmenityStore, previousSelectedState: AmenityStore) => void): () => void;
|
|
13
|
+
<U>(selector: (state: AmenityStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
14
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
15
|
+
fireImmediately?: boolean;
|
|
16
|
+
} | undefined): () => void;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=useAmenityStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAmenityStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useAmenityStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,UAAU,YAAY;IAClB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;OAGG;IACH,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAC9D;AAED,eAAO,MAAM,eAAe;;;;;;;;EAK3B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface BridgeStorageState {
|
|
2
|
+
isMapLoaded: boolean;
|
|
3
|
+
isBridgeLoaded: boolean;
|
|
4
|
+
imageBaseUrl: string | null;
|
|
5
|
+
setIsMapLoaded: (loaded: boolean) => void;
|
|
6
|
+
setIsBridgeLoaded: (loaded: boolean) => void;
|
|
7
|
+
setImageBaseUrl: (url: string | null) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @description Zustand store for holding bridge states on the host application side.
|
|
11
|
+
* @usecase Exposes reactive states (like loaded state, floors, amenities) to the host UI.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useBridgeStorage: import("zustand").UseBoundStore<import("zustand").StoreApi<BridgeStorageState>>;
|
|
14
|
+
//# sourceMappingURL=useBridgeStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBridgeStorage.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useBridgeStorage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,iBAAiB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC/C;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,iFAU1B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
/**
|
|
3
|
+
* @description Zustand store for holding bridge states on the host application side.
|
|
4
|
+
* @usecase Exposes reactive states (like loaded state, floors, amenities) to the host UI.
|
|
5
|
+
*/
|
|
6
|
+
export const useBridgeStorage = create((set) => ({
|
|
7
|
+
isMapLoaded: false,
|
|
8
|
+
isBridgeLoaded: false,
|
|
9
|
+
imageBaseUrl: null,
|
|
10
|
+
setIsMapLoaded: (loaded) => set({ isMapLoaded: loaded }),
|
|
11
|
+
setIsBridgeLoaded: (loaded) => set({ isBridgeLoaded: loaded }),
|
|
12
|
+
setImageBaseUrl: (url) => set({ imageBaseUrl: url }),
|
|
13
|
+
}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Category } from '../../types/types';
|
|
2
|
+
interface CategoryStore {
|
|
3
|
+
categories: Record<string, Category>;
|
|
4
|
+
/**
|
|
5
|
+
* @description Sets the categories collection into the store.
|
|
6
|
+
* @usecase When map data is parsed or loaded from cache, this applies the full set of categories.
|
|
7
|
+
*/
|
|
8
|
+
setCategories: (categories: Record<string, Category>) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useCategoryStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<CategoryStore>, "subscribe"> & {
|
|
11
|
+
subscribe: {
|
|
12
|
+
(listener: (selectedState: CategoryStore, previousSelectedState: CategoryStore) => void): () => void;
|
|
13
|
+
<U>(selector: (state: CategoryStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
14
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
15
|
+
fireImmediately?: boolean;
|
|
16
|
+
} | undefined): () => void;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=useCategoryStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCategoryStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useCategoryStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,UAAU,aAAa;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC;;;OAGG;IACH,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC;CACjE;AAED,eAAO,MAAM,gBAAgB;;;;;;;;EAK5B,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DirectionBridgeState, RoutingPreferences } from "../../types/types";
|
|
2
|
+
/**
|
|
3
|
+
* DirectionStore
|
|
4
|
+
*
|
|
5
|
+
* Ye store direction / navigation ke liye required saari state manage karta hai:
|
|
6
|
+
*
|
|
7
|
+
* 1. Input Queries (user kya type kar raha hai)
|
|
8
|
+
* 2. Selected Points (actual selected store / node IDs)
|
|
9
|
+
* 3. Actions (update, swap, clear)
|
|
10
|
+
*/
|
|
11
|
+
interface DirectionStore {
|
|
12
|
+
/**
|
|
13
|
+
* 📍 SELECTED POINT STATE
|
|
14
|
+
* --------------------------------
|
|
15
|
+
* User ne jo final store / node select kiya hai uska ID
|
|
16
|
+
* (search result se select hone ke baad set hota hai)
|
|
17
|
+
*/
|
|
18
|
+
selectedOriginPointId: string | null;
|
|
19
|
+
selectedDestinationPointId: string | null;
|
|
20
|
+
pathfindingError: string | null;
|
|
21
|
+
setPathfindingError: (error: string | null) => void;
|
|
22
|
+
routingPreferences: RoutingPreferences;
|
|
23
|
+
setRoutingPreferences: (prefs: Partial<RoutingPreferences>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* 📌 SELECTION ACTIONS
|
|
26
|
+
* --------------------------------
|
|
27
|
+
* Jab user kisi search result / store par click kare
|
|
28
|
+
*/
|
|
29
|
+
setSelectedOriginPointId: (id: string | null) => void;
|
|
30
|
+
setSelectedDestinationPointId: (id: string | null) => void;
|
|
31
|
+
setDirectionState: (state: DirectionBridgeState) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Dono selected points reset karta hai
|
|
34
|
+
* (new search / reset flow ke liye)
|
|
35
|
+
*/
|
|
36
|
+
clearSelectedPoints: () => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* useDirectionStore
|
|
40
|
+
*
|
|
41
|
+
* Zustand store with subscribeWithSelector middleware
|
|
42
|
+
* - Efficient re-renders ke liye
|
|
43
|
+
* - Specific state change par subscribe karne ke liye
|
|
44
|
+
*/
|
|
45
|
+
export declare const useDirectionStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<DirectionStore>, "subscribe"> & {
|
|
46
|
+
subscribe: {
|
|
47
|
+
(listener: (selectedState: DirectionStore, previousSelectedState: DirectionStore) => void): () => void;
|
|
48
|
+
<U>(selector: (state: DirectionStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
49
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
50
|
+
fireImmediately?: boolean;
|
|
51
|
+
} | undefined): () => void;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=useDirectionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDirectionStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useDirectionStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAElF;;;;;;;;GAQG;AACH,UAAU,cAAc;IAGtB;;;;;OAKG;IACH,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAI1C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAEpD,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,qBAAqB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IAIpE;;;;OAIG;IACH,wBAAwB,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACtD,6BAA6B,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,iBAAiB,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAKzD;;;OAGG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;CAGjC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;EA4C7B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
3
|
+
/**
|
|
4
|
+
* useDirectionStore
|
|
5
|
+
*
|
|
6
|
+
* Zustand store with subscribeWithSelector middleware
|
|
7
|
+
* - Efficient re-renders ke liye
|
|
8
|
+
* - Specific state change par subscribe karne ke liye
|
|
9
|
+
*/
|
|
10
|
+
export const useDirectionStore = create()(subscribeWithSelector((set) => ({
|
|
11
|
+
// 📍 Initial selected points & groups
|
|
12
|
+
selectedOriginPointId: null,
|
|
13
|
+
selectedDestinationPointId: null,
|
|
14
|
+
pathfindingError: null,
|
|
15
|
+
setPathfindingError: (error) => set({ pathfindingError: error }),
|
|
16
|
+
routingPreferences: { elevator: true, escalator: false, stair: true },
|
|
17
|
+
setRoutingPreferences: (prefs) => set((state) => ({
|
|
18
|
+
routingPreferences: { ...state.routingPreferences, ...prefs }
|
|
19
|
+
})),
|
|
20
|
+
// 📌 Selection handlers
|
|
21
|
+
setSelectedOriginPointId: (id) => set({ selectedOriginPointId: id }),
|
|
22
|
+
setSelectedDestinationPointId: (id) => set({ selectedDestinationPointId: id }),
|
|
23
|
+
setDirectionState: (state) => set({
|
|
24
|
+
selectedOriginPointId: state.selectedOriginPointId,
|
|
25
|
+
selectedDestinationPointId: state.selectedDestinationPointId,
|
|
26
|
+
pathfindingError: state.pathfindingError,
|
|
27
|
+
routingPreferences: state.routingPreferences,
|
|
28
|
+
}),
|
|
29
|
+
// 🧹 Clear selection
|
|
30
|
+
clearSelectedPoints: () => set({
|
|
31
|
+
selectedOriginPointId: null,
|
|
32
|
+
selectedDestinationPointId: null,
|
|
33
|
+
pathfindingError: null,
|
|
34
|
+
}),
|
|
35
|
+
})));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DirectionsRouteResult } from "../../types/types";
|
|
2
|
+
export type DirectionsRouteRequestStatus = "idle" | "loading" | "success" | "error";
|
|
3
|
+
interface DirectionsRouteRequestStore {
|
|
4
|
+
status: DirectionsRouteRequestStatus;
|
|
5
|
+
result: DirectionsRouteResult | null;
|
|
6
|
+
error: string | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
startRequest: () => void;
|
|
9
|
+
resolveRequest: (result: DirectionsRouteResult) => void;
|
|
10
|
+
resetRequest: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const useDirectionsRouteRequestStore: import("zustand").UseBoundStore<import("zustand").StoreApi<DirectionsRouteRequestStore>>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=useDirectionsRouteRequestStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDirectionsRouteRequestStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useDirectionsRouteRequestStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,MAAM,4BAA4B,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpF,UAAU,2BAA2B;IACnC,MAAM,EAAE,4BAA4B,CAAC;IACrC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACrC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,cAAc,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACxD,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,eAAO,MAAM,8BAA8B,0FA6BxC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
export const useDirectionsRouteRequestStore = create()((set) => ({
|
|
3
|
+
status: "idle",
|
|
4
|
+
result: null,
|
|
5
|
+
error: null,
|
|
6
|
+
isLoading: false,
|
|
7
|
+
startRequest: () => set({
|
|
8
|
+
status: "loading",
|
|
9
|
+
result: null,
|
|
10
|
+
error: null,
|
|
11
|
+
isLoading: true,
|
|
12
|
+
}),
|
|
13
|
+
resolveRequest: (result) => set({
|
|
14
|
+
status: result.status,
|
|
15
|
+
result,
|
|
16
|
+
error: result.error,
|
|
17
|
+
isLoading: false,
|
|
18
|
+
}),
|
|
19
|
+
resetRequest: () => set({
|
|
20
|
+
status: "idle",
|
|
21
|
+
result: null,
|
|
22
|
+
error: null,
|
|
23
|
+
isLoading: false,
|
|
24
|
+
}),
|
|
25
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FloorImage } from '../../types/types';
|
|
2
|
+
interface FloorStore {
|
|
3
|
+
floors: FloorImage[];
|
|
4
|
+
activeFloor: number | null;
|
|
5
|
+
setFloors: (floors: FloorImage[]) => void;
|
|
6
|
+
setActiveFloor: (floor: number | null) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const useFloorStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<FloorStore>, "subscribe"> & {
|
|
9
|
+
subscribe: {
|
|
10
|
+
(listener: (selectedState: FloorStore, previousSelectedState: FloorStore) => void): () => void;
|
|
11
|
+
<U>(selector: (state: FloorStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
12
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
13
|
+
fireImmediately?: boolean;
|
|
14
|
+
} | undefined): () => void;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=useFloorStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFloorStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useFloorStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,UAAU,UAAU;IAChB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAC1C,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,aAAa;;;;;;;;EAQzB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { subscribeWithSelector } from 'zustand/middleware';
|
|
3
|
+
export const useFloorStore = create()(subscribeWithSelector((set) => ({
|
|
4
|
+
floors: [],
|
|
5
|
+
activeFloor: null,
|
|
6
|
+
setFloors: (floors) => set({ floors }),
|
|
7
|
+
setActiveFloor: (floor) => set({ activeFloor: floor }),
|
|
8
|
+
})));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NavigationBridgeState, NavigationResult, NodePoint, SimulationMode } from '../../types/types';
|
|
2
|
+
interface NavigationStore {
|
|
3
|
+
activePath: NodePoint[] | null;
|
|
4
|
+
navigationResult: NavigationResult | null;
|
|
5
|
+
simulationMode: SimulationMode;
|
|
6
|
+
currentStepIndex: number;
|
|
7
|
+
setNavigation: (path: NodePoint[], result: NavigationResult) => void;
|
|
8
|
+
clearNavigation: () => void;
|
|
9
|
+
setSimulationMode: (mode: SimulationMode) => void;
|
|
10
|
+
setCurrentStepIndex: (index: number) => void;
|
|
11
|
+
setNavigationState: (state: NavigationBridgeState) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const useNavigationStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<NavigationStore>, "subscribe"> & {
|
|
14
|
+
subscribe: {
|
|
15
|
+
(listener: (selectedState: NavigationStore, previousSelectedState: NavigationStore) => void): () => void;
|
|
16
|
+
<U>(selector: (state: NavigationStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
17
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
18
|
+
fireImmediately?: boolean;
|
|
19
|
+
} | undefined): () => void;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=useNavigationStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNavigationStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useNavigationStore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE5G,UAAU,eAAe;IACvB,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IAEzB,aAAa,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrE,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,iBAAiB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,kBAAkB,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAC5D;AAED,eAAO,MAAM,kBAAkB;;;;;;;;EAmB9B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { subscribeWithSelector } from 'zustand/middleware';
|
|
3
|
+
export const useNavigationStore = create()(subscribeWithSelector((set) => ({
|
|
4
|
+
activePath: null,
|
|
5
|
+
navigationResult: null,
|
|
6
|
+
simulationMode: 'none',
|
|
7
|
+
currentStepIndex: -1,
|
|
8
|
+
setNavigation: (path, result) => set({ activePath: path, navigationResult: result, currentStepIndex: -1 }),
|
|
9
|
+
clearNavigation: () => set({ activePath: null, navigationResult: null, simulationMode: 'none', currentStepIndex: -1 }),
|
|
10
|
+
setSimulationMode: (mode) => set({ simulationMode: mode }),
|
|
11
|
+
setCurrentStepIndex: (index) => set({ currentStepIndex: index }),
|
|
12
|
+
setNavigationState: (state) => set({
|
|
13
|
+
activePath: state.activePath,
|
|
14
|
+
navigationResult: state.navigationResult,
|
|
15
|
+
simulationMode: state.simulationMode,
|
|
16
|
+
currentStepIndex: state.currentStepIndex,
|
|
17
|
+
}),
|
|
18
|
+
})));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { NodePoint } from "../../web";
|
|
2
|
+
import type { OffersNodeMap } from "../../types/types";
|
|
3
|
+
/**
|
|
4
|
+
* NodePointStore
|
|
5
|
+
*
|
|
6
|
+
* Purpose:
|
|
7
|
+
* - Search ke liye available sabhi node points store karega
|
|
8
|
+
* - Ye data search/filter/suggestion me use hoga
|
|
9
|
+
*/
|
|
10
|
+
interface NodePointStore {
|
|
11
|
+
searchableNodePointMap: NodePoint[];
|
|
12
|
+
/**
|
|
13
|
+
* 📍 Grouped by locationName
|
|
14
|
+
* key: locationName
|
|
15
|
+
* value: NodePoint[]
|
|
16
|
+
*/
|
|
17
|
+
locationGroupedNodeMap: Record<string, string[]>;
|
|
18
|
+
keyNodeMap: Record<string, NodePoint>;
|
|
19
|
+
offersNodeMap: OffersNodeMap;
|
|
20
|
+
setSearchableNodePointMap: (points: NodePoint[]) => void;
|
|
21
|
+
setLocationGroupedNodeMap: (points: Record<string, string[]>) => void;
|
|
22
|
+
setKeyNodeMap: (points: Record<string, NodePoint>) => void;
|
|
23
|
+
setOffersNodeMap: (offersMap: OffersNodeMap) => void;
|
|
24
|
+
getNodePointByKey: (key: string) => NodePoint | undefined;
|
|
25
|
+
clearSearchableNodePoints: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* useNodePointStore
|
|
29
|
+
*
|
|
30
|
+
* Zustand store for managing node point search data
|
|
31
|
+
*/
|
|
32
|
+
export declare const useNodePointStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<NodePointStore>, "subscribe"> & {
|
|
33
|
+
subscribe: {
|
|
34
|
+
(listener: (selectedState: NodePointStore, previousSelectedState: NodePointStore) => void): () => void;
|
|
35
|
+
<U>(selector: (state: NodePointStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
36
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
37
|
+
fireImmediately?: boolean;
|
|
38
|
+
} | undefined): () => void;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=useNodePointStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNodePointStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useNodePointStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD;;;;;;GAMG;AACH,UAAU,cAAc;IAGpB,sBAAsB,EAAE,SAAS,EAAE,CAAC;IAEpC;;;;MAIE;IACF,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,aAAa,EAAE,aAAa,CAAC;IAE7B,yBAAyB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IACzD,yBAAyB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IACtE,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,IAAI,CAAC;IAC3D,gBAAgB,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAErD,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;IAG1D,yBAAyB,EAAE,MAAM,IAAI,CAAC;CACzC;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;EAmB7B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
3
|
+
/**
|
|
4
|
+
* useNodePointStore
|
|
5
|
+
*
|
|
6
|
+
* Zustand store for managing node point search data
|
|
7
|
+
*/
|
|
8
|
+
export const useNodePointStore = create()(subscribeWithSelector((set, get) => ({
|
|
9
|
+
searchableNodePointMap: [],
|
|
10
|
+
locationGroupedNodeMap: {},
|
|
11
|
+
keyNodeMap: {},
|
|
12
|
+
offersNodeMap: {},
|
|
13
|
+
setSearchableNodePointMap: (points) => set({ searchableNodePointMap: points }),
|
|
14
|
+
setLocationGroupedNodeMap: (points) => set({ locationGroupedNodeMap: points }),
|
|
15
|
+
setKeyNodeMap: (points) => set({ keyNodeMap: points }),
|
|
16
|
+
setOffersNodeMap: (offersMap) => set({ offersNodeMap: offersMap }),
|
|
17
|
+
getNodePointByKey: (key) => get().keyNodeMap[key],
|
|
18
|
+
clearSearchableNodePoints: () => set({ searchableNodePointMap: [] }),
|
|
19
|
+
})));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Category } from '../../types/types';
|
|
2
|
+
interface SelectionStore {
|
|
3
|
+
activeSelection: {
|
|
4
|
+
type: 'Category' | 'SubCategory' | 'Amenity' | null;
|
|
5
|
+
id: string | null;
|
|
6
|
+
};
|
|
7
|
+
activeCategory: Category | null;
|
|
8
|
+
isOfferSelected: boolean;
|
|
9
|
+
setActiveSelection: (type: 'Category' | 'SubCategory' | 'Amenity', id: string) => void;
|
|
10
|
+
clearActiveSelection: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* @description Sets the active selection status of offers.
|
|
13
|
+
* @usecase Used when the user clicks the offers action button to toggle or set the current offers visibility view.
|
|
14
|
+
*/
|
|
15
|
+
setOfferSelected: (selected: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* @description Restores a previously captured selection store state.
|
|
18
|
+
* @usecase Used by the KioskFlowHistoryService to restore the previous selection state during back navigation.
|
|
19
|
+
*/
|
|
20
|
+
restoreSelectionState: (activeSelection: {
|
|
21
|
+
type: 'Category' | 'SubCategory' | 'Amenity' | null;
|
|
22
|
+
id: string | null;
|
|
23
|
+
}, activeCategory: Category | null, isOfferSelected: boolean) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const useSelectionStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SelectionStore>, "subscribe"> & {
|
|
26
|
+
subscribe: {
|
|
27
|
+
(listener: (selectedState: SelectionStore, previousSelectedState: SelectionStore) => void): () => void;
|
|
28
|
+
<U>(selector: (state: SelectionStore) => U, listener: (selectedState: U, previousSelectedState: U) => void, options?: {
|
|
29
|
+
equalityFn?: ((a: U, b: U) => boolean) | undefined;
|
|
30
|
+
fireImmediately?: boolean;
|
|
31
|
+
} | undefined): () => void;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=useSelectionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelectionStore.d.ts","sourceRoot":"","sources":["../../../src/webviewBridge/store/useSelectionStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,UAAU,cAAc;IACpB,eAAe,EAAE;QACb,IAAI,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC;QACpD,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC;IACF,cAAc,EAAE,QAAQ,GAAG,IAAI,CAAC;IAChC,eAAe,EAAE,OAAO,CAAC;IAEzB,kBAAkB,EAAE,CAAC,IAAI,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvF,oBAAoB,EAAE,MAAM,IAAI,CAAC;IAEjC;;;OAGG;IACH,gBAAgB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAE9C;;;OAGG;IACH,qBAAqB,EAAE,CACnB,eAAe,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC;QAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAC3F,cAAc,EAAE,QAAQ,GAAG,IAAI,EAC/B,eAAe,EAAE,OAAO,KACvB,IAAI,CAAC;CACb;AAED,eAAO,MAAM,iBAAiB;;;;;;;;EAsC7B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { subscribeWithSelector } from 'zustand/middleware';
|
|
3
|
+
import { useSubCategoryStore } from './useSubCategoryStore';
|
|
4
|
+
import { useCategoryStore } from './useCategoryStore';
|
|
5
|
+
export const useSelectionStore = create()(subscribeWithSelector((set) => ({
|
|
6
|
+
activeSelection: { type: null, id: null },
|
|
7
|
+
activeCategory: null,
|
|
8
|
+
isOfferSelected: false,
|
|
9
|
+
setActiveSelection: (type, id) => set((state) => {
|
|
10
|
+
let category = state.activeCategory;
|
|
11
|
+
const categoryStore = useCategoryStore.getState();
|
|
12
|
+
if (type === 'Category') {
|
|
13
|
+
category = categoryStore.categories[id] || null;
|
|
14
|
+
}
|
|
15
|
+
else if (type === 'SubCategory') {
|
|
16
|
+
const subcategory = useSubCategoryStore.getState().subCategories[id];
|
|
17
|
+
if (subcategory && !state.activeCategory) {
|
|
18
|
+
category = categoryStore.categories[subcategory.categoryCode] || null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
category = null;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
activeSelection: { type, id },
|
|
26
|
+
activeCategory: category,
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
clearActiveSelection: () => set({ activeSelection: { type: null, id: null }, activeCategory: null }),
|
|
30
|
+
setOfferSelected: (selected) => set({ isOfferSelected: selected }),
|
|
31
|
+
restoreSelectionState: (activeSelection, activeCategory, isOfferSelected) => set({ activeSelection, activeCategory, isOfferSelected }),
|
|
32
|
+
})));
|