@edsis/ui 21.3.11 → 21.3.13
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.
|
@@ -8,7 +8,6 @@ const UI_THEME_OPTIONS = new InjectionToken('UI_THEME_OPTIONS');
|
|
|
8
8
|
const THEME_MODES = ['light', 'dark', 'system'];
|
|
9
9
|
const RESOLVED_THEME_MODES = ['light', 'dark'];
|
|
10
10
|
const THEME_SEASONS = ['base', 'imlek', 'ramadhan', 'ied', 'natal', 'new-year'];
|
|
11
|
-
const DEFAULT_THEME_BRAND = 'etos';
|
|
12
11
|
const DEFAULT_THEME_MODE = 'system';
|
|
13
12
|
const DEFAULT_THEME_SEASON = 'base';
|
|
14
13
|
const THEME_MODE_STORAGE_KEY = 'theme-mode';
|
|
@@ -25,10 +24,6 @@ function isThemeSeason(value) {
|
|
|
25
24
|
function normalizeThemeMode(value) {
|
|
26
25
|
return isThemeMode(value) ? value : DEFAULT_THEME_MODE;
|
|
27
26
|
}
|
|
28
|
-
function normalizeThemeBrand(value) {
|
|
29
|
-
const normalized = value?.trim();
|
|
30
|
-
return normalized ? normalized : DEFAULT_THEME_BRAND;
|
|
31
|
-
}
|
|
32
27
|
function normalizeThemeSeason(value) {
|
|
33
28
|
return isThemeSeason(value) ? value : DEFAULT_THEME_SEASON;
|
|
34
29
|
}
|
|
@@ -199,7 +194,6 @@ function provideUiTheme(options = {}) {
|
|
|
199
194
|
useValue: options,
|
|
200
195
|
},
|
|
201
196
|
provideEnvironmentInitializer(() => {
|
|
202
|
-
inject(DOCUMENT, { optional: true })?.documentElement.setAttribute('theme-brand', normalizeThemeBrand(options.brand));
|
|
203
197
|
if (options.icons?.materialSymbols !== false) {
|
|
204
198
|
inject(UiMaterialSymbolsService).ensureLoaded();
|
|
205
199
|
}
|
|
@@ -213,5 +207,5 @@ function provideUiTheme(options = {}) {
|
|
|
213
207
|
* Generated bundle index. Do not edit.
|
|
214
208
|
*/
|
|
215
209
|
|
|
216
|
-
export {
|
|
210
|
+
export { DEFAULT_THEME_MODE, DEFAULT_THEME_SEASON, RESOLVED_THEME_MODES, THEME_MODES, THEME_MODE_STORAGE_KEY, THEME_SEASONS, THEME_SEASON_STORAGE_KEY, ThemeModeService, ThemeSeasonService, UI_THEME_OPTIONS, isResolvedThemeMode, isThemeMode, isThemeSeason, normalizeThemeMode, normalizeThemeSeason, provideUiTheme };
|
|
217
211
|
//# sourceMappingURL=edsis-ui-theme.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edsis-ui-theme.mjs","sources":["../../../library/ui/theme/theme.config.ts","../../../library/ui/theme/theme.types.ts","../../../library/ui/theme/theme-mode.service.ts","../../../library/ui/theme/theme-season.service.ts","../../../library/ui/theme/theme.provider.ts","../../../library/ui/theme/edsis-ui-theme.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport type { ThemeBrand, ThemeMode, ThemeSeason } from './theme.types';\n\nexport interface UiThemeIconOptions {\n readonly materialSymbols?: boolean;\n}\n\nexport interface UiThemeOptions {\n readonly brand?: ThemeBrand;\n readonly mode?: ThemeMode;\n readonly season?: ThemeSeason;\n readonly icons?: UiThemeIconOptions;\n}\n\nexport const UI_THEME_OPTIONS = new InjectionToken<Readonly<UiThemeOptions>>('UI_THEME_OPTIONS');\n","export const THEME_MODES = ['light', 'dark', 'system'] as const;\nexport const RESOLVED_THEME_MODES = ['light', 'dark'] as const;\nexport const THEME_SEASONS = ['base', 'imlek', 'ramadhan', 'ied', 'natal', 'new-year'] as const;\n\nexport type ThemeBrand = string;\nexport type ThemeMode = (typeof THEME_MODES)[number];\nexport type ResolvedThemeMode = (typeof RESOLVED_THEME_MODES)[number];\nexport type ThemeSeason = (typeof THEME_SEASONS)[number];\n\nexport const DEFAULT_THEME_BRAND: ThemeBrand = 'etos';\nexport const DEFAULT_THEME_MODE: ThemeMode = 'system';\nexport const DEFAULT_THEME_SEASON: ThemeSeason = 'base';\n\nexport const THEME_MODE_STORAGE_KEY = 'theme-mode';\nexport const THEME_SEASON_STORAGE_KEY = 'theme-season';\n\nexport function isThemeMode(value: string | null | undefined): value is ThemeMode {\n return typeof value === 'string' && THEME_MODES.includes(value as ThemeMode);\n}\n\nexport function isResolvedThemeMode(value: string | null | undefined): value is ResolvedThemeMode {\n return typeof value === 'string' && RESOLVED_THEME_MODES.includes(value as ResolvedThemeMode);\n}\n\nexport function isThemeSeason(value: string | null | undefined): value is ThemeSeason {\n return typeof value === 'string' && THEME_SEASONS.includes(value as ThemeSeason);\n}\n\nexport function normalizeThemeMode(value: string | null | undefined): ThemeMode {\n return isThemeMode(value) ? value : DEFAULT_THEME_MODE;\n}\n\nexport function normalizeThemeBrand(value: string | null | undefined): ThemeBrand {\n const normalized = value?.trim();\n\n return normalized ? normalized : DEFAULT_THEME_BRAND;\n}\n\nexport function normalizeThemeSeason(value: string | null | undefined): ThemeSeason {\n return isThemeSeason(value) ? value : DEFAULT_THEME_SEASON;\n}\n","import { DOCUMENT } from '@angular/common';\nimport { DestroyRef, Injectable, computed, effect, inject, signal } from '@angular/core';\nimport { UI_THEME_OPTIONS } from './theme.config';\nimport {\n DEFAULT_THEME_MODE,\n THEME_MODE_STORAGE_KEY,\n type ResolvedThemeMode,\n type ThemeMode,\n normalizeThemeMode,\n} from './theme.types';\n\n@Injectable({ providedIn: 'root' })\nexport class ThemeModeService {\n private readonly documentRef = inject(DOCUMENT, { optional: true });\n private readonly destroyRef = inject(DestroyRef);\n private readonly options = inject(UI_THEME_OPTIONS, { optional: true });\n private readonly modeState = signal<ThemeMode>(DEFAULT_THEME_MODE);\n private readonly systemPrefersDark = signal(this.readSystemPreference());\n\n readonly mode = this.modeState.asReadonly();\n readonly resolvedMode = computed<ResolvedThemeMode>(() => {\n const mode = this.modeState();\n\n if (mode === 'system') {\n return this.systemPrefersDark() ? 'dark' : 'light';\n }\n\n return mode;\n });\n\n readonly isDark = computed(() => this.resolvedMode() === 'dark');\n\n constructor() {\n this.bindSystemPreferenceListener();\n this.ensureDefaults();\n\n effect(() => {\n const mode = this.modeState();\n const resolvedMode = this.resolvedMode();\n\n this.persistMode(mode);\n this.applyModeAttributes(resolvedMode);\n });\n }\n\n setMode(mode: ThemeMode): void {\n this.modeState.set(mode);\n }\n\n toggle(): void {\n this.setMode(this.isDark() ? 'light' : 'dark');\n }\n\n private ensureDefaults(): void {\n const defaultMode = normalizeThemeMode(this.options?.mode);\n const storedMode = this.readStorage(THEME_MODE_STORAGE_KEY) ?? defaultMode;\n\n this.modeState.set(normalizeThemeMode(storedMode));\n }\n\n private persistMode(mode: ThemeMode): void {\n this.writeStorage(THEME_MODE_STORAGE_KEY, mode);\n }\n\n private applyModeAttributes(mode: ResolvedThemeMode): void {\n const root = this.documentRef?.documentElement;\n\n if (!root) {\n return;\n }\n\n root.setAttribute('theme-mode', mode);\n root.dataset['mode'] = mode;\n }\n\n private readSystemPreference(): boolean {\n return this.mediaQueryList()?.matches ?? false;\n }\n\n private bindSystemPreferenceListener(): void {\n const mediaQueryList = this.mediaQueryList();\n\n if (!mediaQueryList) {\n return;\n }\n\n const onChange = (event: MediaQueryListEvent) => {\n this.systemPrefersDark.set(event.matches);\n };\n\n mediaQueryList.addEventListener('change', onChange);\n this.destroyRef.onDestroy(() => mediaQueryList.removeEventListener('change', onChange));\n }\n\n private mediaQueryList(): MediaQueryList | null {\n return this.documentRef?.defaultView?.matchMedia?.('(prefers-color-scheme: dark)') ?? null;\n }\n\n private storage(): Storage | null {\n try {\n return this.documentRef?.defaultView?.localStorage ?? null;\n } catch {\n return null;\n }\n }\n\n private readStorage(key: string): string | null {\n try {\n return this.storage()?.getItem(key) ?? null;\n } catch {\n return null;\n }\n }\n\n private writeStorage(key: string, value: string): void {\n try {\n this.storage()?.setItem(key, value);\n } catch {\n return;\n }\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport { Injectable, effect, inject, signal } from '@angular/core';\nimport { UI_THEME_OPTIONS } from './theme.config';\nimport { DEFAULT_THEME_SEASON, THEME_SEASON_STORAGE_KEY, type ThemeSeason, normalizeThemeSeason } from './theme.types';\n\n@Injectable({ providedIn: 'root' })\nexport class ThemeSeasonService {\n private readonly documentRef = inject(DOCUMENT, { optional: true });\n private readonly options = inject(UI_THEME_OPTIONS, { optional: true });\n private readonly seasonState = signal<ThemeSeason>(DEFAULT_THEME_SEASON);\n\n readonly season = this.seasonState.asReadonly();\n\n constructor() {\n this.ensureDefaults();\n\n effect(() => {\n const season = this.seasonState();\n\n this.persistSeason(season);\n this.applySeasonAttribute(season);\n });\n }\n\n setSeason(season: ThemeSeason): void {\n this.seasonState.set(season);\n }\n\n private ensureDefaults(): void {\n const defaultSeason = normalizeThemeSeason(this.options?.season);\n const storedSeason = this.readStorage(THEME_SEASON_STORAGE_KEY) ?? defaultSeason;\n\n this.seasonState.set(normalizeThemeSeason(storedSeason));\n }\n\n private persistSeason(season: ThemeSeason): void {\n this.writeStorage(THEME_SEASON_STORAGE_KEY, season);\n }\n\n private applySeasonAttribute(season: ThemeSeason): void {\n const root = this.documentRef?.documentElement;\n\n if (!root) {\n return;\n }\n\n root.setAttribute('theme-season', season);\n }\n\n private storage(): Storage | null {\n try {\n return this.documentRef?.defaultView?.localStorage ?? null;\n } catch {\n return null;\n }\n }\n\n private readStorage(key: string): string | null {\n try {\n return this.storage()?.getItem(key) ?? null;\n } catch {\n return null;\n }\n }\n\n private writeStorage(key: string, value: string): void {\n try {\n this.storage()?.setItem(key, value);\n } catch {\n return;\n }\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport {\n type EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n} from '@angular/core';\nimport { UiMaterialSymbolsService } from '@edsis/ui/icon';\nimport { UI_THEME_OPTIONS, type UiThemeOptions } from './theme.config';\nimport { ThemeModeService } from './theme-mode.service';\nimport { ThemeSeasonService } from './theme-season.service';\nimport { normalizeThemeBrand } from './theme.types';\n\nexport function provideUiTheme(options: UiThemeOptions = {}): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: UI_THEME_OPTIONS,\n useValue: options,\n },\n provideEnvironmentInitializer(() => {\n inject(DOCUMENT, { optional: true })?.documentElement.setAttribute(\n 'theme-brand',\n normalizeThemeBrand(options.brand),\n );\n\n if (options.icons?.materialSymbols !== false) {\n inject(UiMaterialSymbolsService).ensureLoaded();\n }\n\n inject(ThemeModeService);\n inject(ThemeSeasonService);\n }),\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAca,gBAAgB,GAAG,IAAI,cAAc,CAA2B,kBAAkB;;ACdxF,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ;MACxC,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM;AAC7C,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU;AAO9E,MAAM,mBAAmB,GAAe;AACxC,MAAM,kBAAkB,GAAc;AACtC,MAAM,oBAAoB,GAAgB;AAE1C,MAAM,sBAAsB,GAAG;AAC/B,MAAM,wBAAwB,GAAG;AAElC,SAAU,WAAW,CAAC,KAAgC,EAAA;IAC1D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAkB,CAAC;AAC9E;AAEM,SAAU,mBAAmB,CAAC,KAAgC,EAAA;IAClE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,oBAAoB,CAAC,QAAQ,CAAC,KAA0B,CAAC;AAC/F;AAEM,SAAU,aAAa,CAAC,KAAgC,EAAA;IAC5D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAoB,CAAC;AAClF;AAEM,SAAU,kBAAkB,CAAC,KAAgC,EAAA;AACjE,IAAA,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,kBAAkB;AACxD;AAEM,SAAU,mB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AAC,YAAY,CAChE,aAAa,EACb,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CACnC;YAED,IAAI,OAAO,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,EAAE;AAC5C,gBAAA,MAAM,CAAC,wBAAwB,CAAC,CAAC,YAAY,EAAE;YACjD;YAEA,MAAM,CAAC,gBAAgB,CAAC;YACxB,MAAM,CAAC,kBAAkB,CAAC;AAC5B,QAAA,CAAC,CAAC;AACH,KAAA,CAAC;AACJ;;ACjCA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"edsis-ui-theme.mjs","sources":["../../../library/ui/theme/theme.config.ts","../../../library/ui/theme/theme.types.ts","../../../library/ui/theme/theme-mode.service.ts","../../../library/ui/theme/theme-season.service.ts","../../../library/ui/theme/theme.provider.ts","../../../library/ui/theme/edsis-ui-theme.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport type { ThemeMode, ThemeSeason } from './theme.types';\n\nexport interface UiThemeIconOptions {\n readonly materialSymbols?: boolean;\n}\n\nexport interface UiThemeOptions {\n readonly mode?: ThemeMode;\n readonly season?: ThemeSeason;\n readonly icons?: UiThemeIconOptions;\n}\n\nexport const UI_THEME_OPTIONS = new InjectionToken<Readonly<UiThemeOptions>>('UI_THEME_OPTIONS');\n","export const THEME_MODES = ['light', 'dark', 'system'] as const;\nexport const RESOLVED_THEME_MODES = ['light', 'dark'] as const;\nexport const THEME_SEASONS = ['base', 'imlek', 'ramadhan', 'ied', 'natal', 'new-year'] as const;\n\nexport type ThemeMode = (typeof THEME_MODES)[number];\nexport type ResolvedThemeMode = (typeof RESOLVED_THEME_MODES)[number];\nexport type ThemeSeason = (typeof THEME_SEASONS)[number];\n\nexport const DEFAULT_THEME_MODE: ThemeMode = 'system';\nexport const DEFAULT_THEME_SEASON: ThemeSeason = 'base';\n\nexport const THEME_MODE_STORAGE_KEY = 'theme-mode';\nexport const THEME_SEASON_STORAGE_KEY = 'theme-season';\n\nexport function isThemeMode(value: string | null | undefined): value is ThemeMode {\n return typeof value === 'string' && THEME_MODES.includes(value as ThemeMode);\n}\n\nexport function isResolvedThemeMode(value: string | null | undefined): value is ResolvedThemeMode {\n return typeof value === 'string' && RESOLVED_THEME_MODES.includes(value as ResolvedThemeMode);\n}\n\nexport function isThemeSeason(value: string | null | undefined): value is ThemeSeason {\n return typeof value === 'string' && THEME_SEASONS.includes(value as ThemeSeason);\n}\n\nexport function normalizeThemeMode(value: string | null | undefined): ThemeMode {\n return isThemeMode(value) ? value : DEFAULT_THEME_MODE;\n}\n\nexport function normalizeThemeSeason(value: string | null | undefined): ThemeSeason {\n return isThemeSeason(value) ? value : DEFAULT_THEME_SEASON;\n}\n","import { DOCUMENT } from '@angular/common';\nimport { DestroyRef, Injectable, computed, effect, inject, signal } from '@angular/core';\nimport { UI_THEME_OPTIONS } from './theme.config';\nimport {\n DEFAULT_THEME_MODE,\n THEME_MODE_STORAGE_KEY,\n type ResolvedThemeMode,\n type ThemeMode,\n normalizeThemeMode,\n} from './theme.types';\n\n@Injectable({ providedIn: 'root' })\nexport class ThemeModeService {\n private readonly documentRef = inject(DOCUMENT, { optional: true });\n private readonly destroyRef = inject(DestroyRef);\n private readonly options = inject(UI_THEME_OPTIONS, { optional: true });\n private readonly modeState = signal<ThemeMode>(DEFAULT_THEME_MODE);\n private readonly systemPrefersDark = signal(this.readSystemPreference());\n\n readonly mode = this.modeState.asReadonly();\n readonly resolvedMode = computed<ResolvedThemeMode>(() => {\n const mode = this.modeState();\n\n if (mode === 'system') {\n return this.systemPrefersDark() ? 'dark' : 'light';\n }\n\n return mode;\n });\n\n readonly isDark = computed(() => this.resolvedMode() === 'dark');\n\n constructor() {\n this.bindSystemPreferenceListener();\n this.ensureDefaults();\n\n effect(() => {\n const mode = this.modeState();\n const resolvedMode = this.resolvedMode();\n\n this.persistMode(mode);\n this.applyModeAttributes(resolvedMode);\n });\n }\n\n setMode(mode: ThemeMode): void {\n this.modeState.set(mode);\n }\n\n toggle(): void {\n this.setMode(this.isDark() ? 'light' : 'dark');\n }\n\n private ensureDefaults(): void {\n const defaultMode = normalizeThemeMode(this.options?.mode);\n const storedMode = this.readStorage(THEME_MODE_STORAGE_KEY) ?? defaultMode;\n\n this.modeState.set(normalizeThemeMode(storedMode));\n }\n\n private persistMode(mode: ThemeMode): void {\n this.writeStorage(THEME_MODE_STORAGE_KEY, mode);\n }\n\n private applyModeAttributes(mode: ResolvedThemeMode): void {\n const root = this.documentRef?.documentElement;\n\n if (!root) {\n return;\n }\n\n root.setAttribute('theme-mode', mode);\n root.dataset['mode'] = mode;\n }\n\n private readSystemPreference(): boolean {\n return this.mediaQueryList()?.matches ?? false;\n }\n\n private bindSystemPreferenceListener(): void {\n const mediaQueryList = this.mediaQueryList();\n\n if (!mediaQueryList) {\n return;\n }\n\n const onChange = (event: MediaQueryListEvent) => {\n this.systemPrefersDark.set(event.matches);\n };\n\n mediaQueryList.addEventListener('change', onChange);\n this.destroyRef.onDestroy(() => mediaQueryList.removeEventListener('change', onChange));\n }\n\n private mediaQueryList(): MediaQueryList | null {\n return this.documentRef?.defaultView?.matchMedia?.('(prefers-color-scheme: dark)') ?? null;\n }\n\n private storage(): Storage | null {\n try {\n return this.documentRef?.defaultView?.localStorage ?? null;\n } catch {\n return null;\n }\n }\n\n private readStorage(key: string): string | null {\n try {\n return this.storage()?.getItem(key) ?? null;\n } catch {\n return null;\n }\n }\n\n private writeStorage(key: string, value: string): void {\n try {\n this.storage()?.setItem(key, value);\n } catch {\n return;\n }\n }\n}\n","import { DOCUMENT } from '@angular/common';\nimport { Injectable, effect, inject, signal } from '@angular/core';\nimport { UI_THEME_OPTIONS } from './theme.config';\nimport { DEFAULT_THEME_SEASON, THEME_SEASON_STORAGE_KEY, type ThemeSeason, normalizeThemeSeason } from './theme.types';\n\n@Injectable({ providedIn: 'root' })\nexport class ThemeSeasonService {\n private readonly documentRef = inject(DOCUMENT, { optional: true });\n private readonly options = inject(UI_THEME_OPTIONS, { optional: true });\n private readonly seasonState = signal<ThemeSeason>(DEFAULT_THEME_SEASON);\n\n readonly season = this.seasonState.asReadonly();\n\n constructor() {\n this.ensureDefaults();\n\n effect(() => {\n const season = this.seasonState();\n\n this.persistSeason(season);\n this.applySeasonAttribute(season);\n });\n }\n\n setSeason(season: ThemeSeason): void {\n this.seasonState.set(season);\n }\n\n private ensureDefaults(): void {\n const defaultSeason = normalizeThemeSeason(this.options?.season);\n const storedSeason = this.readStorage(THEME_SEASON_STORAGE_KEY) ?? defaultSeason;\n\n this.seasonState.set(normalizeThemeSeason(storedSeason));\n }\n\n private persistSeason(season: ThemeSeason): void {\n this.writeStorage(THEME_SEASON_STORAGE_KEY, season);\n }\n\n private applySeasonAttribute(season: ThemeSeason): void {\n const root = this.documentRef?.documentElement;\n\n if (!root) {\n return;\n }\n\n root.setAttribute('theme-season', season);\n }\n\n private storage(): Storage | null {\n try {\n return this.documentRef?.defaultView?.localStorage ?? null;\n } catch {\n return null;\n }\n }\n\n private readStorage(key: string): string | null {\n try {\n return this.storage()?.getItem(key) ?? null;\n } catch {\n return null;\n }\n }\n\n private writeStorage(key: string, value: string): void {\n try {\n this.storage()?.setItem(key, value);\n } catch {\n return;\n }\n }\n}\n","import {\n type EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n} from '@angular/core';\nimport { UiMaterialSymbolsService } from '@edsis/ui/icon';\nimport { UI_THEME_OPTIONS, type UiThemeOptions } from './theme.config';\nimport { ThemeModeService } from './theme-mode.service';\nimport { ThemeSeasonService } from './theme-season.service';\n\nexport function provideUiTheme(options: UiThemeOptions = {}): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: UI_THEME_OPTIONS,\n useValue: options,\n },\n provideEnvironmentInitializer(() => {\n if (options.icons?.materialSymbols !== false) {\n inject(UiMaterialSymbolsService).ensureLoaded();\n }\n\n inject(ThemeModeService);\n inject(ThemeSeasonService);\n }),\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\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,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;QACrC;AAAE,QAAA,MAAM;YACN;QACF;IACF;wGAjEW,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAlB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,kBAAkB,cADL,MAAM,EAAA,CAAA;;4FACnB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAD9B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACM5B,SAAU,cAAc,CAAC,OAAA,GAA0B,EAAE,EAAA;AACzD,IAAA,OAAO,wBAAwB,CAAC;AAC9B,QAAA;AACE,YAAA,OAAO,EAAE,gBAAgB;AACzB,YAAA,QAAQ,EAAE,OAAO;AAClB,SAAA;QACD,6BAA6B,CAAC,MAAK;YACjC,IAAI,OAAO,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,EAAE;AAC5C,gBAAA,MAAM,CAAC,wBAAwB,CAAC,CAAC,YAAY,EAAE;YACjD;YAEA,MAAM,CAAC,gBAAgB,CAAC;YACxB,MAAM,CAAC,kBAAkB,CAAC;AAC5B,QAAA,CAAC,CAAC;AACH,KAAA,CAAC;AACJ;;AC1BA;;AAEG;;;;"}
|
package/package.json
CHANGED
package/theme/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Theme
|
|
2
2
|
|
|
3
|
-
`@edsis/ui/theme` menyediakan provider untuk
|
|
3
|
+
`@edsis/ui/theme` menyediakan provider untuk mode, season, dan preload aset tema global.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { provideUiTheme } from '@edsis/ui/theme';
|
|
@@ -8,7 +8,6 @@ import { provideUiTheme } from '@edsis/ui/theme';
|
|
|
8
8
|
export const appConfig = {
|
|
9
9
|
providers: [
|
|
10
10
|
provideUiTheme({
|
|
11
|
-
brand: 'etos',
|
|
12
11
|
mode: 'light',
|
|
13
12
|
season: 'base',
|
|
14
13
|
}),
|
|
@@ -18,7 +17,6 @@ export const appConfig = {
|
|
|
18
17
|
|
|
19
18
|
## API Notes
|
|
20
19
|
|
|
21
|
-
- `brand` mengatur atribut `theme-brand` pada `documentElement`.
|
|
22
20
|
- `mode` mem-bootstrap `ThemeModeService` dan default mode yang disimpan di storage.
|
|
23
21
|
- `season` mem-bootstrap `ThemeSeasonService` dan default season yang disimpan di storage.
|
|
24
22
|
- `icons.materialSymbols` mengontrol preload stylesheet Material Symbols pada bootstrap aplikasi.
|
|
@@ -4,11 +4,9 @@ import { InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
|
4
4
|
declare const THEME_MODES: readonly ["light", "dark", "system"];
|
|
5
5
|
declare const RESOLVED_THEME_MODES: readonly ["light", "dark"];
|
|
6
6
|
declare const THEME_SEASONS: readonly ["base", "imlek", "ramadhan", "ied", "natal", "new-year"];
|
|
7
|
-
type ThemeBrand = string;
|
|
8
7
|
type ThemeMode = (typeof THEME_MODES)[number];
|
|
9
8
|
type ResolvedThemeMode = (typeof RESOLVED_THEME_MODES)[number];
|
|
10
9
|
type ThemeSeason = (typeof THEME_SEASONS)[number];
|
|
11
|
-
declare const DEFAULT_THEME_BRAND: ThemeBrand;
|
|
12
10
|
declare const DEFAULT_THEME_MODE: ThemeMode;
|
|
13
11
|
declare const DEFAULT_THEME_SEASON: ThemeSeason;
|
|
14
12
|
declare const THEME_MODE_STORAGE_KEY = "theme-mode";
|
|
@@ -17,14 +15,12 @@ declare function isThemeMode(value: string | null | undefined): value is ThemeMo
|
|
|
17
15
|
declare function isResolvedThemeMode(value: string | null | undefined): value is ResolvedThemeMode;
|
|
18
16
|
declare function isThemeSeason(value: string | null | undefined): value is ThemeSeason;
|
|
19
17
|
declare function normalizeThemeMode(value: string | null | undefined): ThemeMode;
|
|
20
|
-
declare function normalizeThemeBrand(value: string | null | undefined): ThemeBrand;
|
|
21
18
|
declare function normalizeThemeSeason(value: string | null | undefined): ThemeSeason;
|
|
22
19
|
|
|
23
20
|
interface UiThemeIconOptions {
|
|
24
21
|
readonly materialSymbols?: boolean;
|
|
25
22
|
}
|
|
26
23
|
interface UiThemeOptions {
|
|
27
|
-
readonly brand?: ThemeBrand;
|
|
28
24
|
readonly mode?: ThemeMode;
|
|
29
25
|
readonly season?: ThemeSeason;
|
|
30
26
|
readonly icons?: UiThemeIconOptions;
|
|
@@ -75,5 +71,5 @@ declare class ThemeSeasonService {
|
|
|
75
71
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<ThemeSeasonService>;
|
|
76
72
|
}
|
|
77
73
|
|
|
78
|
-
export {
|
|
79
|
-
export type { ResolvedThemeMode,
|
|
74
|
+
export { DEFAULT_THEME_MODE, DEFAULT_THEME_SEASON, RESOLVED_THEME_MODES, THEME_MODES, THEME_MODE_STORAGE_KEY, THEME_SEASONS, THEME_SEASON_STORAGE_KEY, ThemeModeService, ThemeSeasonService, UI_THEME_OPTIONS, isResolvedThemeMode, isThemeMode, isThemeSeason, normalizeThemeMode, normalizeThemeSeason, provideUiTheme };
|
|
75
|
+
export type { ResolvedThemeMode, ThemeMode, ThemeSeason, UiThemeIconOptions, UiThemeOptions };
|