@shival99/z-ui 2.2.5 → 2.3.0

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 (66) hide show
  1. package/assets/css/base.css +4 -0
  2. package/assets/css/overlay.css +82 -0
  3. package/assets/css/tailwind.css +1 -0
  4. package/assets/css/themes/hospital.css +28 -2
  5. package/fesm2022/shival99-z-ui-components-z-button-group.mjs +15 -13
  6. package/fesm2022/shival99-z-ui-components-z-button-group.mjs.map +1 -1
  7. package/fesm2022/shival99-z-ui-components-z-button.mjs +2 -2
  8. package/fesm2022/shival99-z-ui-components-z-button.mjs.map +1 -1
  9. package/fesm2022/shival99-z-ui-components-z-calendar.mjs +23 -17
  10. package/fesm2022/shival99-z-ui-components-z-calendar.mjs.map +1 -1
  11. package/fesm2022/shival99-z-ui-components-z-command.mjs +10 -24
  12. package/fesm2022/shival99-z-ui-components-z-command.mjs.map +1 -1
  13. package/fesm2022/shival99-z-ui-components-z-drawer.mjs +61 -70
  14. package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +1 -1
  15. package/fesm2022/shival99-z-ui-components-z-gallery.mjs +6 -8
  16. package/fesm2022/shival99-z-ui-components-z-gallery.mjs.map +1 -1
  17. package/fesm2022/shival99-z-ui-components-z-icon.mjs +227 -11
  18. package/fesm2022/shival99-z-ui-components-z-icon.mjs.map +1 -1
  19. package/fesm2022/shival99-z-ui-components-z-marquee.mjs +19 -4
  20. package/fesm2022/shival99-z-ui-components-z-marquee.mjs.map +1 -1
  21. package/fesm2022/shival99-z-ui-components-z-menu.mjs +7 -7
  22. package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -1
  23. package/fesm2022/shival99-z-ui-components-z-modal.mjs +45 -62
  24. package/fesm2022/shival99-z-ui-components-z-modal.mjs.map +1 -1
  25. package/fesm2022/shival99-z-ui-components-z-overlay.mjs +363 -0
  26. package/fesm2022/shival99-z-ui-components-z-overlay.mjs.map +1 -0
  27. package/fesm2022/shival99-z-ui-components-z-popover.mjs +94 -378
  28. package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -1
  29. package/fesm2022/shival99-z-ui-components-z-skeleton.mjs +14 -3
  30. package/fesm2022/shival99-z-ui-components-z-skeleton.mjs.map +1 -1
  31. package/fesm2022/shival99-z-ui-components-z-table.mjs +42 -16
  32. package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
  33. package/fesm2022/shival99-z-ui-components-z-tabs.mjs +85 -7
  34. package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +1 -1
  35. package/fesm2022/shival99-z-ui-components-z-toast.mjs +32 -25
  36. package/fesm2022/shival99-z-ui-components-z-toast.mjs.map +1 -1
  37. package/fesm2022/shival99-z-ui-components-z-tooltip.mjs +52 -222
  38. package/fesm2022/shival99-z-ui-components-z-tooltip.mjs.map +1 -1
  39. package/fesm2022/shival99-z-ui-providers.mjs +9 -2
  40. package/fesm2022/shival99-z-ui-providers.mjs.map +1 -1
  41. package/fesm2022/shival99-z-ui-services.mjs +203 -98
  42. package/fesm2022/shival99-z-ui-services.mjs.map +1 -1
  43. package/package.json +9 -1
  44. package/types/shival99-z-ui-components-z-autocomplete.d.ts +1 -1
  45. package/types/shival99-z-ui-components-z-button-group.d.ts +12 -11
  46. package/types/shival99-z-ui-components-z-button.d.ts +2 -1
  47. package/types/shival99-z-ui-components-z-calendar.d.ts +4 -4
  48. package/types/shival99-z-ui-components-z-command.d.ts +2 -4
  49. package/types/shival99-z-ui-components-z-drawer.d.ts +22 -16
  50. package/types/shival99-z-ui-components-z-editor.d.ts +1 -1
  51. package/types/shival99-z-ui-components-z-gallery.d.ts +3 -3
  52. package/types/shival99-z-ui-components-z-icon.d.ts +38 -6
  53. package/types/shival99-z-ui-components-z-marquee.d.ts +7 -1
  54. package/types/shival99-z-ui-components-z-modal.d.ts +53 -53
  55. package/types/shival99-z-ui-components-z-overlay.d.ts +145 -0
  56. package/types/shival99-z-ui-components-z-popover.d.ts +7 -15
  57. package/types/shival99-z-ui-components-z-qrcode.d.ts +1 -1
  58. package/types/shival99-z-ui-components-z-select.d.ts +1 -1
  59. package/types/shival99-z-ui-components-z-skeleton.d.ts +2 -0
  60. package/types/shival99-z-ui-components-z-table.d.ts +7 -3
  61. package/types/shival99-z-ui-components-z-tabs.d.ts +13 -3
  62. package/types/shival99-z-ui-components-z-toast.d.ts +7 -1
  63. package/types/shival99-z-ui-components-z-tooltip.d.ts +9 -7
  64. package/types/shival99-z-ui-components-z-upload.d.ts +3 -3
  65. package/types/shival99-z-ui-providers.d.ts +3 -1
  66. package/types/shival99-z-ui-services.d.ts +73 -37
@@ -4,8 +4,7 @@ import { zNormalize, zFormatNumExcel, zConvertColorToArgb } from '@shival99/z-ui
4
4
  import { __decorate, __param, __metadata } from 'tslib';
5
5
  import { isPlatformBrowser, DOCUMENT } from '@angular/common';
6
6
  import { Subject, takeUntil, fromEvent, filter, firstValueFrom, from, switchMap, of, catchError, throwError, tap, map, defer, BehaviorSubject } from 'rxjs';
7
- import { Overlay, OverlayRef, OverlayConfig } from '@angular/cdk/overlay';
8
- import { TemplatePortal, ComponentPortal } from '@angular/cdk/portal';
7
+ import { ZOverlayService } from '@shival99/z-ui/components/z-overlay';
9
8
  import * as ExcelJS from 'exceljs';
10
9
  import { saveAs } from 'file-saver';
11
10
  import * as XLSX from 'xlsx';
@@ -14,50 +13,107 @@ import { Router } from '@angular/router';
14
13
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
15
14
  import { TranslateService } from '@ngx-translate/core';
16
15
 
17
- const Z_CACHE_SCOPE_SEPARATOR = '::';
16
+ const Z_CACHE_SCOPE_SEPARATOR = '-';
18
17
  const Z_DB_SCOPE_SEPARATOR = '__';
19
- const Z_SCOPE_FALLBACK = 'global';
20
- const Z_RUNTIME_SCOPE = (() => {
18
+ const Z_STORAGE_SCOPE_FALLBACK = 'global';
19
+ const Z_CACHE_DEFAULT_PREFIX = 'z_';
20
+
21
+ const Z_LEGACY_CACHE_SCOPE_SEPARATOR = '::';
22
+ const Z_LEGACY_RUNTIME_SCOPE = (() => {
21
23
  if (typeof window === 'undefined') {
22
- return Z_SCOPE_FALLBACK;
24
+ return Z_STORAGE_SCOPE_FALLBACK;
23
25
  }
24
26
  const origin = zNormalize(window.location.origin);
25
27
  const baseHref = typeof document !== 'undefined' ? zNormalize(document.querySelector('base')?.getAttribute('href') ?? '') : '';
26
28
  if (!origin && !baseHref) {
27
- return Z_SCOPE_FALLBACK;
29
+ return Z_STORAGE_SCOPE_FALLBACK;
28
30
  }
29
31
  if (!origin) {
30
- return baseHref || Z_SCOPE_FALLBACK;
32
+ return baseHref || Z_STORAGE_SCOPE_FALLBACK;
31
33
  }
32
34
  if (!baseHref) {
33
35
  return origin;
34
36
  }
35
37
  return `${origin}__${baseHref}`;
36
38
  })();
37
- const Z_CACHE_SCOPE_SUFFIX = `${Z_CACHE_SCOPE_SEPARATOR}${Z_RUNTIME_SCOPE}`;
38
- const Z_DB_SCOPE_SUFFIX = `${Z_DB_SCOPE_SEPARATOR}${Z_RUNTIME_SCOPE}`;
39
- function zAppendScope(value, scopeSuffix) {
40
- const trimmed = value.trim();
41
- if (!trimmed || trimmed.endsWith(scopeSuffix)) {
42
- return value;
43
- }
44
- return `${trimmed}${scopeSuffix}`;
39
+ const Z_LEGACY_CACHE_SCOPE_SUFFIX = `${Z_LEGACY_CACHE_SCOPE_SEPARATOR}${Z_LEGACY_RUNTIME_SCOPE}`;
40
+ const Z_LEGACY_DB_SCOPE_SUFFIX = `${Z_DB_SCOPE_SEPARATOR}${Z_LEGACY_RUNTIME_SCOPE}`;
41
+ const Z_STORAGE_SCOPE_STATE = {};
42
+ function zNormalizeStorageAppName(appName) {
43
+ const normalized = (appName ?? '')
44
+ .trim()
45
+ .toLowerCase()
46
+ .replace(/[^a-z0-9]+/g, Z_CACHE_SCOPE_SEPARATOR)
47
+ .replace(/^-+|-+$/g, '');
48
+ return normalized || Z_STORAGE_SCOPE_FALLBACK;
49
+ }
50
+ function zConfigureStorageAppName(appName) {
51
+ Z_STORAGE_SCOPE_STATE.appName = appName === undefined ? undefined : zNormalizeStorageAppName(appName);
45
52
  }
46
- function zBuildScopedCacheKey(baseKey) {
47
- return zAppendScope(baseKey, Z_CACHE_SCOPE_SUFFIX);
53
+ function zGetStorageAppName() {
54
+ return Z_STORAGE_SCOPE_STATE.appName;
48
55
  }
49
- function zBuildScopedDbName(baseDbName) {
50
- return zAppendScope(baseDbName, Z_DB_SCOPE_SUFFIX);
56
+ function zBuildScopedCacheKey(baseKey, appName = zGetStorageAppName()) {
57
+ if (appName === undefined) {
58
+ return zBuildLegacyScopedCacheKey(baseKey);
59
+ }
60
+ const trimmedKey = baseKey.trim();
61
+ if (!trimmedKey) {
62
+ return baseKey;
63
+ }
64
+ const scopePrefix = `${zNormalizeStorageAppName(appName)}${Z_CACHE_SCOPE_SEPARATOR}`;
65
+ if (trimmedKey.startsWith(scopePrefix)) {
66
+ return trimmedKey;
67
+ }
68
+ return `${scopePrefix}${trimmedKey}`;
69
+ }
70
+ function zBuildScopedDbName(baseDbName, appName = zGetStorageAppName()) {
71
+ if (appName === undefined) {
72
+ return zBuildLegacyScopedDbName(baseDbName);
73
+ }
74
+ const trimmedName = baseDbName.trim();
75
+ if (!trimmedName) {
76
+ return baseDbName;
77
+ }
78
+ const scopeSuffix = `${Z_DB_SCOPE_SEPARATOR}${zNormalizeStorageAppName(appName)}`;
79
+ if (trimmedName.endsWith(scopeSuffix)) {
80
+ return trimmedName;
81
+ }
82
+ return `${trimmedName}${scopeSuffix}`;
51
83
  }
52
- function zStripScopedCacheKey(key) {
84
+ function zStripScopedCacheKey(key, appName = zGetStorageAppName()) {
85
+ if (appName === undefined) {
86
+ return zStripLegacyScopedCacheKey(key);
87
+ }
53
88
  const normalizedKey = key.trim();
54
89
  if (!normalizedKey) {
55
90
  return key;
56
91
  }
57
- if (!normalizedKey.endsWith(Z_CACHE_SCOPE_SUFFIX)) {
92
+ const scopePrefix = `${zNormalizeStorageAppName(appName)}${Z_CACHE_SCOPE_SEPARATOR}`;
93
+ if (!normalizedKey.startsWith(scopePrefix)) {
58
94
  return normalizedKey;
59
95
  }
60
- return normalizedKey.slice(0, normalizedKey.length - Z_CACHE_SCOPE_SUFFIX.length);
96
+ return normalizedKey.slice(scopePrefix.length);
97
+ }
98
+ function zBuildLegacyScopedCacheKey(baseKey) {
99
+ return zAppendLegacyScope(baseKey, Z_LEGACY_CACHE_SCOPE_SUFFIX);
100
+ }
101
+ function zBuildLegacyScopedDbName(baseDbName) {
102
+ return zAppendLegacyScope(baseDbName, Z_LEGACY_DB_SCOPE_SUFFIX);
103
+ }
104
+ function zStripLegacyScopedCacheKey(key) {
105
+ const normalizedKey = key.trim();
106
+ if (!normalizedKey || !normalizedKey.endsWith(Z_LEGACY_CACHE_SCOPE_SUFFIX)) {
107
+ return normalizedKey || key;
108
+ }
109
+ return normalizedKey.slice(0, normalizedKey.length - Z_LEGACY_CACHE_SCOPE_SUFFIX.length);
110
+ }
111
+ function zAppendLegacyScope(value, scopeSuffix) {
112
+ const trimmed = value.trim();
113
+ if (!trimmed || trimmed.endsWith(scopeSuffix)) {
114
+ return value;
115
+ }
116
+ return `${trimmed}${scopeSuffix}`;
61
117
  }
62
118
 
63
119
  /** Injection token for data passed to a dynamic component or template. */
@@ -126,14 +182,17 @@ let ZDynamicRef = class ZDynamicRef {
126
182
  this._destroy$.next();
127
183
  this._destroy$.complete();
128
184
  }
129
- /** Updates the overlay position using its configured strategy. */
185
+ /**
186
+ * @deprecated Không còn tác dụng — overlay tự do giờ luôn dùng vị trí toàn cục (global),
187
+ * tự canh giữa bằng CSS, không còn "chiến lược định vị" nào cần cập nhật lại. Giữ lại method
188
+ * rỗng để không phá vỡ code đang gọi nó.
189
+ */
130
190
  updatePosition() {
131
- this._overlayRef?.updatePosition();
191
+ // no-op — global overlay không có position strategy để cập nhật lại
132
192
  }
133
193
  /** Updates the overlay pane dimensions. */
134
194
  updateSize(width, height) {
135
- const sizeConfig = { width, height };
136
- this._overlayRef?.updateSize(sizeConfig);
195
+ this._overlayRef?.updateSize({ width, height });
137
196
  }
138
197
  /** @internal Used by the service after attaching a component portal. */
139
198
  attachComponentRef(componentRef) {
@@ -274,10 +333,11 @@ const Z_LANG_TO_LOCALE = {
274
333
  };
275
334
 
276
335
  class ZCacheService {
277
- static _prefix = 'z_';
336
+ static _prefix = Z_CACHE_DEFAULT_PREFIX;
278
337
  static _encrypt = true;
279
338
  static configure(config) {
280
- if (config.prefix) {
339
+ zConfigureStorageAppName(config.appName);
340
+ if (config.prefix !== undefined) {
281
341
  ZCacheService._prefix = config.prefix;
282
342
  }
283
343
  if (config.encrypt !== undefined) {
@@ -310,21 +370,31 @@ class ZCacheService {
310
370
  const prefixedKey = `${ZCacheService._prefix}${normalizedKey}`;
311
371
  return encrypt ? ZCacheService._encode(prefixedKey) : prefixedKey;
312
372
  }
373
+ static _toLegacyStorageKey(normalizedKey, encrypt) {
374
+ const prefixedKey = `z_${normalizedKey}`;
375
+ return encrypt ? ZCacheService._encode(prefixedKey) : prefixedKey;
376
+ }
313
377
  static _getFullKey(key, encrypt) {
314
378
  return ZCacheService._toStorageKey(ZCacheService._normalizeKey(key), encrypt);
315
379
  }
316
- static _getLegacyFullKey(key, encrypt) {
380
+ static _getLegacyFullKeys(key, encrypt) {
317
381
  const legacyNormalized = ZCacheService._normalizeLegacyKey(key);
318
382
  const scopedNormalized = ZCacheService._normalizeKey(key);
319
- if (legacyNormalized === scopedNormalized) {
320
- return null;
383
+ const legacyLogicalKeys = zGetStorageAppName() === undefined
384
+ ? [legacyNormalized]
385
+ : [zBuildLegacyScopedCacheKey(legacyNormalized), legacyNormalized];
386
+ if (legacyLogicalKeys.includes(scopedNormalized)) {
387
+ return [];
321
388
  }
322
- return ZCacheService._toStorageKey(legacyNormalized, encrypt);
389
+ const legacyKeys = legacyLogicalKeys.flatMap(logicalKey => [
390
+ ZCacheService._toStorageKey(logicalKey, encrypt),
391
+ ZCacheService._toLegacyStorageKey(logicalKey, encrypt),
392
+ ]);
393
+ return [...new Set(legacyKeys)];
323
394
  }
324
395
  static _getCandidateStorageKeys(key, encrypt) {
325
396
  const scopedKey = ZCacheService._getFullKey(key, encrypt);
326
- const legacyKey = ZCacheService._getLegacyFullKey(key, encrypt);
327
- return legacyKey ? [scopedKey, legacyKey] : [scopedKey];
397
+ return [scopedKey, ...ZCacheService._getLegacyFullKeys(key, encrypt)];
328
398
  }
329
399
  static _decodeStorageKey(storageKey) {
330
400
  const decoded = ZCacheService._decode(storageKey);
@@ -334,14 +404,14 @@ class ZCacheService {
334
404
  return decoded;
335
405
  }
336
406
  static _isManagedStorageKey(storageKey) {
337
- if (storageKey.startsWith(ZCacheService._prefix)) {
407
+ if (storageKey.startsWith(ZCacheService._prefix) || storageKey.startsWith('z_')) {
338
408
  return true;
339
409
  }
340
410
  const decoded = ZCacheService._decodeStorageKey(storageKey);
341
411
  if (!decoded) {
342
412
  return false;
343
413
  }
344
- return decoded.startsWith(ZCacheService._prefix);
414
+ return decoded.startsWith(ZCacheService._prefix) || decoded.startsWith('z_');
345
415
  }
346
416
  static _safeOperation(operation, fallback) {
347
417
  try {
@@ -377,12 +447,10 @@ class ZCacheService {
377
447
  static set(key, data, encrypt = ZCacheService._encrypt) {
378
448
  return ZCacheService._safeOperation(() => {
379
449
  const _key = ZCacheService._getFullKey(key, encrypt);
380
- const legacyKey = ZCacheService._getLegacyFullKey(key, encrypt);
450
+ const legacyKeys = ZCacheService._getLegacyFullKeys(key, encrypt);
381
451
  const _value = encrypt ? ZCacheService._encode(data) : JSON.stringify(data);
382
452
  localStorage.setItem(_key, _value);
383
- if (legacyKey) {
384
- localStorage.removeItem(legacyKey);
385
- }
453
+ legacyKeys.forEach(legacyKey => localStorage.removeItem(legacyKey));
386
454
  return true;
387
455
  }, false);
388
456
  }
@@ -460,11 +528,23 @@ class ZOverlayZIndexService {
460
528
  applyToOverlay(overlayRef) {
461
529
  const zIndex = this.next();
462
530
  overlayRef.hostElement.style.zIndex = `${zIndex}`;
531
+ // Lưu ý: với z-modal/z-drawer, dòng dưới đây không còn tác dụng thị giác — `.z-overlay-backdrop`
532
+ // trong overlay.css đã khoá z-index về 0 bằng !important (xem lịch sử fix bug backdrop đè modal).
533
+ // Vẫn giữ vì z-command/z-gallery-preview/z-dynamic.service dùng backdrop CDK riêng (.cdk-overlay-backdrop),
534
+ // không bị CSS đó ảnh hưởng — dòng này vẫn cần thiết cho các consumer đó.
463
535
  if (overlayRef.backdropElement) {
464
536
  overlayRef.backdropElement.style.zIndex = `${zIndex - 1}`;
465
537
  }
466
538
  return zIndex;
467
539
  }
540
+ /**
541
+ * @deprecated Thừa với overlay đã dùng native Popover API (`[popover]` + `showPopover()`):
542
+ * top layer đã tự xếp overlay hiện gần nhất lên trên cùng, hide+show lại chỉ là restack thủ
543
+ * công cho hành vi mà trình duyệt đã làm sẵn. CDK 22 cũng mặc định `usePopover: true` nên
544
+ * z-command/z-gallery-preview cũng đang gọi thừa. Chỉ còn có ý nghĩa làm fallback DOM-reorder
545
+ * (nhánh `else` trong `moveToTop`) cho trình duyệt KHÔNG hỗ trợ Popover API (Chrome <114,
546
+ * Firefox <125, Safari <17). Xoá khi dự án xác nhận không còn cần hỗ trợ nhóm trình duyệt đó.
547
+ */
468
548
  deferMoveToTop(overlayRef) {
469
549
  if (!isPlatformBrowser(this._platformId)) {
470
550
  return;
@@ -473,6 +553,7 @@ class ZOverlayZIndexService {
473
553
  this.moveToTop(overlayRef);
474
554
  });
475
555
  }
556
+ /** @deprecated Xem ghi chú tại {@link deferMoveToTop}. */
476
557
  moveToTop(overlayRef) {
477
558
  if (!isPlatformBrowser(this._platformId)) {
478
559
  return;
@@ -510,13 +591,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImpor
510
591
  }] });
511
592
 
512
593
  /**
513
- * Opens components and templates in a bare CDK overlay.
594
+ * Opens components and templates in a bare global overlay (no anchored positioning).
514
595
  *
515
- * @description The service supplies overlay lifecycle and positioning only. The
516
- * mounted content owns its complete layout, including close controls and styling.
596
+ * @description The service supplies overlay lifecycle only. The mounted content owns its
597
+ * complete layout, including close controls and styling.
517
598
  */
518
599
  class ZDynamicService {
519
- _overlay = inject(Overlay);
600
+ _overlayService = inject(ZOverlayService);
520
601
  _injector = inject(Injector);
521
602
  _platformId = inject(PLATFORM_ID);
522
603
  _zIndexService = inject(ZOverlayZIndexService);
@@ -524,7 +605,7 @@ class ZDynamicService {
524
605
  create(content, options = {}) {
525
606
  return this.open(content, options);
526
607
  }
527
- /** Opens a component or template in a free-form CDK overlay. */
608
+ /** Opens a component or template in a free-form global overlay. */
528
609
  open(content, options = {}) {
529
610
  const overlayRef = this._createOverlay(options);
530
611
  const dynamicRef = new ZDynamicRef(overlayRef, this._platformId);
@@ -543,18 +624,20 @@ class ZDynamicService {
543
624
  dynamicRef,
544
625
  data: options.data,
545
626
  };
546
- overlayRef.attach(new TemplatePortal(content, options.viewContainerRef, context));
627
+ overlayRef.attachTemplate(content, options.viewContainerRef, context);
547
628
  return dynamicRef;
548
629
  }
549
630
  const injector = Injector.create({
550
631
  parent: this._injector,
551
632
  providers: [
552
- { provide: OverlayRef, useValue: overlayRef },
553
633
  { provide: ZDynamicRef, useValue: dynamicRef },
554
634
  { provide: Z_DYNAMIC_DATA, useValue: options.data },
555
635
  ],
556
636
  });
557
- const componentRef = overlayRef.attach(new ComponentPortal(content, options.viewContainerRef, injector));
637
+ const componentRef = overlayRef.attach(content, {
638
+ injector,
639
+ viewContainerRef: options.viewContainerRef,
640
+ });
558
641
  componentRef.changeDetectorRef.detectChanges();
559
642
  dynamicRef.attachComponentRef(componentRef);
560
643
  return dynamicRef;
@@ -563,20 +646,20 @@ class ZDynamicService {
563
646
  if (!isPlatformBrowser(this._platformId)) {
564
647
  return undefined;
565
648
  }
566
- const config = new OverlayConfig({
649
+ return this._overlayService.createGlobal({
567
650
  hasBackdrop: options.hasBackdrop ?? true,
568
- backdropClass: options.backdropClass ?? 'cdk-overlay-dark-backdrop',
651
+ backdropClass: options.backdropClass ?? 'z-modal-backdrop-dark',
569
652
  panelClass: options.panelClass,
570
- positionStrategy: options.positionStrategy ?? this._overlay.position().global(),
571
- scrollStrategy: options.scrollStrategy ?? this._overlay.scrollStrategies.block(),
572
- width: options.width,
573
- height: options.height,
574
- minWidth: options.minWidth,
575
- maxWidth: options.maxWidth,
576
- minHeight: options.minHeight,
577
- maxHeight: options.maxHeight,
653
+ scrollLock: options.scrollLock ?? true,
654
+ size: {
655
+ width: options.width,
656
+ height: options.height,
657
+ minWidth: options.minWidth,
658
+ maxWidth: options.maxWidth,
659
+ minHeight: options.minHeight,
660
+ maxHeight: options.maxHeight,
661
+ },
578
662
  });
579
- return this._overlay.create(config);
580
663
  }
581
664
  _isTemplate(content) {
582
665
  return content instanceof TemplateRef;
@@ -1251,6 +1334,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImpor
1251
1334
  class ZIndexDbService {
1252
1335
  _db = null;
1253
1336
  _dbName;
1337
+ _appName;
1254
1338
  _legacyDbName = null;
1255
1339
  _version;
1256
1340
  _mode;
@@ -1261,9 +1345,16 @@ class ZIndexDbService {
1261
1345
  _encrypt = true;
1262
1346
  constructor(config = {}) {
1263
1347
  const baseDbName = config.dbName ?? Z_INDEXDB_DEFAULT_CONFIG.dbName;
1264
- const scopedDbName = zBuildScopedDbName(baseDbName);
1348
+ this._appName = config.appName ?? zGetStorageAppName();
1349
+ if (config.appName !== undefined) {
1350
+ zConfigureStorageAppName(config.appName);
1351
+ }
1352
+ const scopedDbName = this._appName === undefined
1353
+ ? zBuildLegacyScopedDbName(baseDbName)
1354
+ : zBuildScopedDbName(baseDbName, this._appName);
1265
1355
  this._dbName = scopedDbName;
1266
- this._legacyDbName = scopedDbName === baseDbName ? null : baseDbName;
1356
+ const legacyDbName = this._appName === undefined ? baseDbName : zBuildLegacyScopedDbName(baseDbName);
1357
+ this._legacyDbName = scopedDbName === legacyDbName ? null : legacyDbName;
1267
1358
  this._version = config.version ?? Z_INDEXDB_DEFAULT_CONFIG.version;
1268
1359
  this._mode = config.mode ?? Z_INDEXDB_DEFAULT_CONFIG.mode;
1269
1360
  this._defaultStoreName = config.defaultStore ?? Z_INDEXDB_DEFAULT_CONFIG.defaultStore;
@@ -1297,17 +1388,16 @@ class ZIndexDbService {
1297
1388
  return key.trim().toLowerCase();
1298
1389
  }
1299
1390
  _normalizeKey(key) {
1300
- return zBuildScopedCacheKey(this._normalizeLegacyKey(key));
1301
- }
1302
- _resolveLegacyNormalizedKey(key) {
1303
- const legacyKey = this._normalizeLegacyKey(key);
1304
- const scopedKey = this._normalizeKey(key);
1305
- return legacyKey === scopedKey ? null : legacyKey;
1391
+ const normalizedKey = this._normalizeLegacyKey(key);
1392
+ return this._appName === undefined
1393
+ ? zBuildLegacyScopedCacheKey(normalizedKey)
1394
+ : zBuildScopedCacheKey(normalizedKey, this._appName);
1306
1395
  }
1307
1396
  _buildStorageKeys(key, encrypt) {
1397
+ const normalizedKey = this._normalizeLegacyKey(key);
1308
1398
  const scopedKey = this._normalizeKey(key);
1309
- const legacyKey = this._resolveLegacyNormalizedKey(key);
1310
- const logicalKeys = legacyKey ? [scopedKey, legacyKey] : [scopedKey];
1399
+ const legacyLogicalKeys = this._appName === undefined ? [normalizedKey] : [zBuildLegacyScopedCacheKey(normalizedKey), normalizedKey];
1400
+ const logicalKeys = [...new Set([scopedKey, ...legacyLogicalKeys])];
1311
1401
  if (!encrypt) {
1312
1402
  return logicalKeys;
1313
1403
  }
@@ -1531,6 +1621,12 @@ class ZIndexDbService {
1531
1621
  }
1532
1622
  return this._db.objectStoreNames.contains(storeName);
1533
1623
  }
1624
+ _getDbOrThrow() {
1625
+ if (!this._db) {
1626
+ throw new Error('Database not initialized');
1627
+ }
1628
+ return this._db;
1629
+ }
1534
1630
  async get(key, options) {
1535
1631
  const storeConfig = this._getStoreConfig(options?.storeName);
1536
1632
  const shouldEncrypt = this._shouldEncrypt(storeConfig, options?.encrypt);
@@ -1552,34 +1648,44 @@ class ZIndexDbService {
1552
1648
  const storageKeys = this._buildStorageKeys(key, shouldEncrypt);
1553
1649
  return new Promise(resolve => {
1554
1650
  try {
1555
- const transaction = this._db.transaction([storeConfig.name], this._mode);
1651
+ const transaction = this._getDbOrThrow().transaction([storeConfig.name], this._mode);
1556
1652
  const store = transaction.objectStore(storeConfig.name);
1557
1653
  const request = store.get(storageKeys[0]);
1558
1654
  request.onsuccess = () => {
1559
1655
  const resolveData = (rawValue) => {
1560
1656
  try {
1561
- if (!rawValue) {
1562
- resolve(defaultValue);
1563
- return;
1657
+ if (rawValue === undefined) {
1658
+ return false;
1564
1659
  }
1565
1660
  const decrypted = shouldEncrypt ? this._decryptData(rawValue) : rawValue;
1661
+ if (decrypted === null) {
1662
+ return false;
1663
+ }
1566
1664
  resolve(decrypted ?? defaultValue);
1665
+ return true;
1567
1666
  }
1568
1667
  catch {
1569
- resolve(defaultValue);
1668
+ return false;
1570
1669
  }
1571
1670
  };
1572
- if (request.result) {
1573
- resolveData(request.result);
1671
+ if (resolveData(request.result)) {
1574
1672
  return;
1575
1673
  }
1576
- if (storageKeys.length < 2) {
1577
- resolve(defaultValue);
1578
- return;
1579
- }
1580
- const legacyRequest = store.get(storageKeys[1]);
1581
- legacyRequest.onsuccess = () => resolveData(legacyRequest.result);
1582
- legacyRequest.onerror = () => resolve(defaultValue);
1674
+ const readFallback = (index) => {
1675
+ if (index >= storageKeys.length) {
1676
+ resolve(defaultValue);
1677
+ return;
1678
+ }
1679
+ const fallbackRequest = store.get(storageKeys[index]);
1680
+ fallbackRequest.onsuccess = () => {
1681
+ if (resolveData(fallbackRequest.result)) {
1682
+ return;
1683
+ }
1684
+ readFallback(index + 1);
1685
+ };
1686
+ fallbackRequest.onerror = () => readFallback(index + 1);
1687
+ };
1688
+ readFallback(1);
1583
1689
  };
1584
1690
  request.onerror = () => resolve(defaultValue);
1585
1691
  transaction.onerror = () => resolve(defaultValue);
@@ -1612,12 +1718,10 @@ class ZIndexDbService {
1612
1718
  const _value = shouldEncrypt ? this._encryptData(value) : value;
1613
1719
  return new Promise((resolve, reject) => {
1614
1720
  try {
1615
- const transaction = this._db.transaction([storeConfig.name], 'readwrite');
1721
+ const transaction = this._getDbOrThrow().transaction([storeConfig.name], 'readwrite');
1616
1722
  const store = transaction.objectStore(storeConfig.name);
1617
1723
  const request = store.put(_value, _key);
1618
- if (storageKeys.length > 1) {
1619
- store.delete(storageKeys[1]);
1620
- }
1724
+ storageKeys.slice(1).forEach(item => store.delete(item));
1621
1725
  request.onerror = () => reject(request.error);
1622
1726
  transaction.oncomplete = () => resolve();
1623
1727
  transaction.onerror = () => reject(transaction.error);
@@ -1655,7 +1759,7 @@ class ZIndexDbService {
1655
1759
  const keys = Array.isArray(key) ? key : [key];
1656
1760
  return new Promise((resolve, reject) => {
1657
1761
  try {
1658
- const transaction = this._db.transaction([storeConfig.name], 'readwrite');
1762
+ const transaction = this._getDbOrThrow().transaction([storeConfig.name], 'readwrite');
1659
1763
  const store = transaction.objectStore(storeConfig.name);
1660
1764
  keys.forEach(k => {
1661
1765
  const plainKeys = this._buildStorageKeys(k, false);
@@ -1688,7 +1792,7 @@ class ZIndexDbService {
1688
1792
  }
1689
1793
  if (protectedKeys.length === 0) {
1690
1794
  return new Promise((resolve, reject) => {
1691
- const transaction = this._db.transaction([storeConfig.name], 'readwrite');
1795
+ const transaction = this._getDbOrThrow().transaction([storeConfig.name], 'readwrite');
1692
1796
  const store = transaction.objectStore(storeConfig.name);
1693
1797
  const request = store.clear();
1694
1798
  request.onsuccess = () => resolve();
@@ -1697,7 +1801,7 @@ class ZIndexDbService {
1697
1801
  }
1698
1802
  return new Promise((resolve, reject) => {
1699
1803
  try {
1700
- const transaction = this._db.transaction([storeConfig.name], 'readwrite');
1804
+ const transaction = this._getDbOrThrow().transaction([storeConfig.name], 'readwrite');
1701
1805
  const store = transaction.objectStore(storeConfig.name);
1702
1806
  const keyRequest = store.getAllKeys();
1703
1807
  const protectedSet = new Set();
@@ -1747,7 +1851,7 @@ class ZIndexDbService {
1747
1851
  }
1748
1852
  return new Promise(resolve => {
1749
1853
  try {
1750
- const transaction = this._db.transaction([storeConfig.name], this._mode);
1854
+ const transaction = this._getDbOrThrow().transaction([storeConfig.name], this._mode);
1751
1855
  const store = transaction.objectStore(storeConfig.name);
1752
1856
  const keysRequest = store.getAllKeys();
1753
1857
  const valuesRequest = store.getAll();
@@ -1761,7 +1865,10 @@ class ZIndexDbService {
1761
1865
  const _key = this._shouldEncrypt(storeConfig) ? this._decryptData(key) : key;
1762
1866
  const _value = this._shouldEncrypt(storeConfig) ? this._decryptData(values[index]) : values[index];
1763
1867
  if (_key && _value !== null) {
1764
- results[zStripScopedCacheKey(_key)] = _value;
1868
+ const scopedKey = this._appName === undefined
1869
+ ? zStripLegacyScopedCacheKey(_key)
1870
+ : zStripScopedCacheKey(_key, this._appName);
1871
+ results[zStripLegacyScopedCacheKey(scopedKey)] = _value;
1765
1872
  }
1766
1873
  }
1767
1874
  catch {
@@ -1802,16 +1909,14 @@ class ZIndexDbService {
1802
1909
  throw new Error(`Store "${storeConfig.name}" does not exist`);
1803
1910
  }
1804
1911
  return new Promise((resolve, reject) => {
1805
- const transaction = this._db.transaction([storeConfig.name], 'readwrite');
1912
+ const transaction = this._getDbOrThrow().transaction([storeConfig.name], 'readwrite');
1806
1913
  const store = transaction.objectStore(storeConfig.name);
1807
1914
  batch.forEach(([key, value]) => {
1808
1915
  const storageKeys = this._buildStorageKeys(key, shouldEncrypt);
1809
1916
  const _key = storageKeys[0];
1810
1917
  const _value = shouldEncrypt ? this._encryptData(value) : value;
1811
1918
  store.put(_value, _key);
1812
- if (storageKeys.length > 1) {
1813
- store.delete(storageKeys[1]);
1814
- }
1919
+ storageKeys.slice(1).forEach(item => store.delete(item));
1815
1920
  });
1816
1921
  transaction.oncomplete = () => resolve();
1817
1922
  transaction.onerror = () => reject(transaction.error);
@@ -2584,5 +2689,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImpor
2584
2689
  * Generated bundle index. Do not edit.
2585
2690
  */
2586
2691
 
2587
- export { ZCacheService, ZDynamicRef, ZDynamicService, ZExcelService, ZHttpAbstractService, ZIndexDbService, ZOverlayContainerService, ZOverlayZIndexService, ZSubjectService, ZThemeService, ZTranslateService, Z_DEFAULT_THEME, Z_DYNAMIC_DATA, Z_EXCEL_BORDER_THIN, Z_EXCEL_CHAR_WIDTH_MAP, Z_EXCEL_COLORS, Z_EXCEL_DEFAULT_CONFIG, Z_EXCEL_FONT_MULTIPLIERS, Z_EXCEL_WIDTH_LIMITS, Z_HTTP_DEFAULT_CONFIG, Z_INDEXDB_BATCH_SIZE, Z_INDEXDB_DEFAULT_CONFIG, Z_INDEXDB_MAX_VERSION, Z_LANG_CACHE_KEY, Z_LANG_TO_LOCALE, Z_THEME_CONFIG, Z_THEME_CSS_MAP, Z_THEME_PREFERENCES_CACHE_KEY, zBuildScopedCacheKey, zBuildScopedDbName, zStripScopedCacheKey };
2692
+ export { ZCacheService, ZDynamicRef, ZDynamicService, ZExcelService, ZHttpAbstractService, ZIndexDbService, ZOverlayContainerService, ZOverlayZIndexService, ZSubjectService, ZThemeService, ZTranslateService, Z_CACHE_DEFAULT_PREFIX, Z_CACHE_SCOPE_SEPARATOR, Z_DB_SCOPE_SEPARATOR, Z_DEFAULT_THEME, Z_DYNAMIC_DATA, Z_EXCEL_BORDER_THIN, Z_EXCEL_CHAR_WIDTH_MAP, Z_EXCEL_COLORS, Z_EXCEL_DEFAULT_CONFIG, Z_EXCEL_FONT_MULTIPLIERS, Z_EXCEL_WIDTH_LIMITS, Z_HTTP_DEFAULT_CONFIG, Z_INDEXDB_BATCH_SIZE, Z_INDEXDB_DEFAULT_CONFIG, Z_INDEXDB_MAX_VERSION, Z_LANG_CACHE_KEY, Z_LANG_TO_LOCALE, Z_STORAGE_SCOPE_FALLBACK, Z_THEME_CONFIG, Z_THEME_CSS_MAP, Z_THEME_PREFERENCES_CACHE_KEY, zBuildLegacyScopedCacheKey, zBuildLegacyScopedDbName, zBuildScopedCacheKey, zBuildScopedDbName, zConfigureStorageAppName, zGetStorageAppName, zNormalizeStorageAppName, zStripLegacyScopedCacheKey, zStripScopedCacheKey };
2588
2693
  //# sourceMappingURL=shival99-z-ui-services.mjs.map