@ojiepermana/angular-theme 22.0.32 → 22.0.34

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.
@@ -1,7 +1,7 @@
1
1
  import { isPlatformBrowser } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
3
  import { inject, PLATFORM_ID, signal, Service, computed, DestroyRef } from '@angular/core';
4
- import { LAYOUT_SURFACE_STORAGE_KEY, isUiLayoutSurface, LAYOUT_TYPE_STORAGE_KEY, isUiLayoutType, LAYOUT_WIDTH_STORAGE_KEY, isUiLayoutWidth, LAYOUT_APPEARANCE_STORAGE_KEY, LAYOUT_STYLE_STORAGE_KEY, LAYOUT_DEFAULT_SURFACE, LAYOUT_DEFAULT_TYPE, LAYOUT_DEFAULT_STYLE, LAYOUT_DEFAULT_WIDTH, isUiLayoutStyle } from '@ojiepermana/angular-theme/layout/types';
4
+ import { LAYOUT_SURFACE_STORAGE_KEY, isUiLayoutSurface, LAYOUT_TYPE_STORAGE_KEY, isUiLayoutType, LAYOUT_WIDTH_STORAGE_KEY, isUiLayoutWidth, LAYOUT_APPEARANCE_STORAGE_KEY, LAYOUT_DEFAULT_SURFACE, LAYOUT_DEFAULT_TYPE, LAYOUT_DEFAULT_APPEARANCE, LAYOUT_DEFAULT_WIDTH, isUiLayoutAppearance } from '@ojiepermana/angular-theme/layout/types';
5
5
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
6
  import { Router, NavigationStart, NavigationEnd, NavigationCancel, NavigationError, NavigationSkipped } from '@angular/router';
7
7
  import { HttpContextToken } from '@angular/common/http';
@@ -13,13 +13,13 @@ class LayoutService {
13
13
  ...(ngDevMode ? [{ debugName: "surfaceState" }] : /* istanbul ignore next */ []));
14
14
  typeState = signal(this.getStoredType(), /* @ts-ignore */
15
15
  ...(ngDevMode ? [{ debugName: "typeState" }] : /* istanbul ignore next */ []));
16
- styleState = signal(this.getStoredStyle(), /* @ts-ignore */
17
- ...(ngDevMode ? [{ debugName: "styleState" }] : /* istanbul ignore next */ []));
16
+ appearanceState = signal(this.getStoredAppearance(), /* @ts-ignore */
17
+ ...(ngDevMode ? [{ debugName: "appearanceState" }] : /* istanbul ignore next */ []));
18
18
  widthState = signal(this.getStoredWidth(), /* @ts-ignore */
19
19
  ...(ngDevMode ? [{ debugName: "widthState" }] : /* istanbul ignore next */ []));
20
20
  surface = this.surfaceState.asReadonly();
21
21
  type = this.typeState.asReadonly();
22
- appearance = this.styleState.asReadonly();
22
+ appearance = this.appearanceState.asReadonly();
23
23
  width = this.widthState.asReadonly();
24
24
  registerDefaults(defaults) {
25
25
  if (defaults.surface !== undefined) {
@@ -78,12 +78,11 @@ class LayoutService {
78
78
  this.writeStorage(LAYOUT_TYPE_STORAGE_KEY, type);
79
79
  }
80
80
  setAppearance(appearance, options = {}) {
81
- this.styleState.set(appearance);
81
+ this.appearanceState.set(appearance);
82
82
  if (options.persist === false) {
83
83
  return;
84
84
  }
85
85
  this.writeStorage(LAYOUT_APPEARANCE_STORAGE_KEY, appearance);
86
- this.removeStorage(LAYOUT_STYLE_STORAGE_KEY);
87
86
  }
88
87
  setWidth(width, options = {}) {
89
88
  this.widthState.set(width);
@@ -102,10 +101,7 @@ class LayoutService {
102
101
  }
103
102
  getStoredAppearance() {
104
103
  const value = this.readStoredAppearance();
105
- return value ?? LAYOUT_DEFAULT_STYLE;
106
- }
107
- getStoredStyle() {
108
- return this.getStoredAppearance();
104
+ return value ?? LAYOUT_DEFAULT_APPEARANCE;
109
105
  }
110
106
  getStoredWidth() {
111
107
  const value = this.readStorage(LAYOUT_WIDTH_STORAGE_KEY);
@@ -123,18 +119,6 @@ class LayoutService {
123
119
  return null;
124
120
  }
125
121
  }
126
- removeStorage(key) {
127
- const storage = this.getStorage();
128
- if (!storage) {
129
- return;
130
- }
131
- try {
132
- storage.removeItem(key);
133
- }
134
- catch {
135
- return;
136
- }
137
- }
138
122
  writeStorage(key, value) {
139
123
  const storage = this.getStorage();
140
124
  if (!storage) {
@@ -160,11 +144,7 @@ class LayoutService {
160
144
  }
161
145
  readStoredAppearance() {
162
146
  const appearance = this.readStorage(LAYOUT_APPEARANCE_STORAGE_KEY);
163
- if (isUiLayoutStyle(appearance)) {
164
- return appearance;
165
- }
166
- const legacyStyle = this.readStorage(LAYOUT_STYLE_STORAGE_KEY);
167
- return isUiLayoutStyle(legacyStyle) ? legacyStyle : null;
147
+ return isUiLayoutAppearance(appearance) ? appearance : null;
168
148
  }
169
149
  getStoredAppearanceOrDefault(fallback) {
170
150
  return this.readStoredAppearance() ?? fallback;
@@ -1,15 +1,14 @@
1
1
  const LAYOUT_TYPES = ['vertical', 'horizontal', 'empty', 'fluid'];
2
2
  const LAYOUT_SURFACES = ['flat', 'grid', 'honeycome', 'line-vertical', 'line-horizontal'];
3
- const LAYOUT_STYLES = ['flat', 'border-rail'];
3
+ const LAYOUT_APPEARANCES = ['flat', 'border-rail'];
4
4
  const LAYOUT_WIDTHS = ['full', 'wide', 'container', 'fluid'];
5
5
  const LAYOUT_DEFAULT_SURFACE = 'flat';
6
6
  const LAYOUT_DEFAULT_TYPE = 'vertical';
7
- const LAYOUT_DEFAULT_STYLE = 'flat';
7
+ const LAYOUT_DEFAULT_APPEARANCE = 'flat';
8
8
  const LAYOUT_DEFAULT_WIDTH = 'full';
9
9
  const LAYOUT_SURFACE_STORAGE_KEY = 'layout-surface';
10
10
  const LAYOUT_APPEARANCE_STORAGE_KEY = 'layout-appearance';
11
11
  const LAYOUT_TYPE_STORAGE_KEY = 'layout-type';
12
- const LAYOUT_STYLE_STORAGE_KEY = 'layout-style';
13
12
  const LAYOUT_WIDTH_STORAGE_KEY = 'layout-width';
14
13
  function isUiLayoutSurface(value) {
15
14
  return value !== null && LAYOUT_SURFACES.includes(value);
@@ -17,8 +16,8 @@ function isUiLayoutSurface(value) {
17
16
  function isUiLayoutType(value) {
18
17
  return value !== null && LAYOUT_TYPES.includes(value);
19
18
  }
20
- function isUiLayoutStyle(value) {
21
- return value !== null && LAYOUT_STYLES.includes(value);
19
+ function isUiLayoutAppearance(value) {
20
+ return value !== null && LAYOUT_APPEARANCES.includes(value);
22
21
  }
23
22
  function isUiLayoutWidth(value) {
24
23
  return value !== null && LAYOUT_WIDTHS.includes(value);
@@ -28,4 +27,4 @@ function isUiLayoutWidth(value) {
28
27
  * Generated bundle index. Do not edit.
29
28
  */
30
29
 
31
- export { LAYOUT_APPEARANCE_STORAGE_KEY, LAYOUT_DEFAULT_STYLE, LAYOUT_DEFAULT_SURFACE, LAYOUT_DEFAULT_TYPE, LAYOUT_DEFAULT_WIDTH, LAYOUT_STYLES, LAYOUT_STYLE_STORAGE_KEY, LAYOUT_SURFACES, LAYOUT_SURFACE_STORAGE_KEY, LAYOUT_TYPES, LAYOUT_TYPE_STORAGE_KEY, LAYOUT_WIDTHS, LAYOUT_WIDTH_STORAGE_KEY, isUiLayoutStyle, isUiLayoutSurface, isUiLayoutType, isUiLayoutWidth };
30
+ export { LAYOUT_APPEARANCES, LAYOUT_APPEARANCE_STORAGE_KEY, LAYOUT_DEFAULT_APPEARANCE, LAYOUT_DEFAULT_SURFACE, LAYOUT_DEFAULT_TYPE, LAYOUT_DEFAULT_WIDTH, LAYOUT_SURFACES, LAYOUT_SURFACE_STORAGE_KEY, LAYOUT_TYPES, LAYOUT_TYPE_STORAGE_KEY, LAYOUT_WIDTHS, LAYOUT_WIDTH_STORAGE_KEY, isUiLayoutAppearance, isUiLayoutSurface, isUiLayoutType, isUiLayoutWidth };