intelica-library-components 1.1.92 → 1.1.94

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.
@@ -8283,19 +8283,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
8283
8283
  }] });
8284
8284
 
8285
8285
  class GlobalMenuService {
8286
+ ConfigService = inject(ConfigService);
8286
8287
  _isMenuVisible = signal(true, ...(ngDevMode ? [{ debugName: "_isMenuVisible" }] : []));
8287
8288
  _selectedProduct = signal({ product: "", icon: "", productId: "" }, ...(ngDevMode ? [{ debugName: "_selectedProduct" }] : []));
8288
8289
  isMenuVisible = this._isMenuVisible.asReadonly();
8289
8290
  selectedProduct = this._selectedProduct.asReadonly();
8290
8291
  eventMenu = "MenuBarEvent";
8291
8292
  eventProducts = "SelectedProductMenuEvent";
8293
+ COOKIE_PRODUCT = "intelica:selected-product";
8294
+ COOKIE_MENU = "intelica:menu-visible";
8295
+ initialized = false;
8292
8296
  initialize() {
8297
+ if (this.initialized)
8298
+ return;
8293
8299
  this.listenMenuEvents();
8300
+ this.hydrateFromCookies();
8301
+ this.initialized = true;
8302
+ }
8303
+ hydrateFromCookies() {
8304
+ const productCookie = getCookie(this.COOKIE_PRODUCT);
8305
+ if (productCookie) {
8306
+ try {
8307
+ const parsed = JSON.parse(productCookie);
8308
+ this._selectedProduct.set({
8309
+ product: parsed.product ?? "",
8310
+ icon: parsed.icon ?? "",
8311
+ productId: parsed.productId ?? "",
8312
+ });
8313
+ }
8314
+ catch { }
8315
+ }
8316
+ const menuCookie = getCookie(this.COOKIE_MENU);
8317
+ if (menuCookie !== undefined) {
8318
+ this._isMenuVisible.set(menuCookie === "true");
8319
+ }
8294
8320
  }
8295
8321
  setMenuVisibility(isVisible) {
8322
+ const cookieAttributesGeneral = GetCookieAttributes(this.ConfigService.environment?.environment ?? "");
8323
+ setCookie(this.COOKIE_MENU, String(isVisible), cookieAttributesGeneral); // 👈 NUEVO
8296
8324
  this.emitMenuEvent(isVisible);
8297
8325
  }
8298
8326
  setSelectedProduct(product) {
8327
+ const cookieAttributesGeneral = GetCookieAttributes(this.ConfigService.environment?.environment ?? "");
8328
+ setCookie(this.COOKIE_PRODUCT, JSON.stringify(product), cookieAttributesGeneral); // 👈 NUEVO
8299
8329
  this.emitSelectedProductEvent(product);
8300
8330
  }
8301
8331
  listenMenuEvents() {
@@ -8304,8 +8334,11 @@ class GlobalMenuService {
8304
8334
  }
8305
8335
  onMenuEvent = (event) => {
8306
8336
  const { menuIsVisible } = event.detail ?? {};
8307
- if (typeof menuIsVisible === "boolean")
8337
+ if (typeof menuIsVisible === "boolean") {
8308
8338
  this._isMenuVisible.set(menuIsVisible);
8339
+ const cookieAttributesGeneral = GetCookieAttributes(this.ConfigService.environment?.environment ?? "");
8340
+ setCookie(this.COOKIE_MENU, String(menuIsVisible), cookieAttributesGeneral); // 👈 NUEVO
8341
+ }
8309
8342
  };
8310
8343
  onSelectedProductEvent = (event) => {
8311
8344
  const detail = event.detail;
@@ -8313,7 +8346,10 @@ class GlobalMenuService {
8313
8346
  return;
8314
8347
  const { product, icon, productId: authClient } = detail;
8315
8348
  if (typeof product === "string" && typeof icon === "string" && typeof authClient === "string") {
8316
- this._selectedProduct.set({ product, icon, productId: authClient });
8349
+ const normalized = { product, icon, productId: authClient };
8350
+ this._selectedProduct.set(normalized);
8351
+ const cookieAttributesGeneral = GetCookieAttributes(this.ConfigService.environment?.environment ?? "");
8352
+ setCookie(this.COOKIE_PRODUCT, JSON.stringify(normalized), cookieAttributesGeneral); // 👈 NUEVO
8317
8353
  }
8318
8354
  };
8319
8355
  emitMenuEvent(isVisible) {