valtech-components 2.0.15 → 2.0.16
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/esm2022/lib/components/atoms/button/button.component.mjs +69 -0
- package/esm2022/lib/components/atoms/button/factory.mjs +217 -0
- package/esm2022/lib/components/atoms/button/types.mjs +2 -0
- package/esm2022/lib/components/types.mjs +29 -0
- package/esm2022/lib/services/download.service.mjs +63 -0
- package/esm2022/lib/services/lang-provider/components/lang-settings.mjs +13 -0
- package/esm2022/lib/services/lang-provider/components/theme-settings.mjs +15 -0
- package/esm2022/lib/services/lang-provider/content.mjs +8 -0
- package/esm2022/lib/services/lang-provider/lang-provider.service.mjs +39 -0
- package/esm2022/lib/services/lang-provider/types.mjs +14 -0
- package/esm2022/lib/services/local-storage.service.mjs +16 -0
- package/esm2022/lib/services/theme.service.mjs +97 -0
- package/esm2022/lib/services/types.mjs +3 -0
- package/esm2022/lib/shared/constants/storage.mjs +3 -0
- package/esm2022/lib/shared/utils/dom.mjs +17 -0
- package/esm2022/public-api.mjs +18 -0
- package/esm2022/valtech-components.mjs +5 -0
- package/fesm2022/valtech-components.mjs +565 -0
- package/fesm2022/valtech-components.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/atoms/button/button.component.d.ts +20 -0
- package/lib/components/atoms/button/factory.d.ts +71 -0
- package/lib/components/atoms/button/types.d.ts +22 -0
- package/lib/components/types.d.ts +78 -0
- package/lib/services/download.service.d.ts +8 -0
- package/lib/services/lang-provider/components/lang-settings.d.ts +3 -0
- package/lib/services/lang-provider/components/theme-settings.d.ts +3 -0
- package/lib/services/lang-provider/content.d.ts +6 -0
- package/lib/services/lang-provider/lang-provider.service.d.ts +17 -0
- package/lib/services/lang-provider/types.d.ts +15 -0
- package/lib/services/local-storage.service.d.ts +6 -0
- package/lib/services/theme.service.d.ts +27 -0
- package/{src/lib/services/types.ts → lib/services/types.d.ts} +1 -3
- package/lib/shared/constants/storage.d.ts +2 -0
- package/lib/shared/utils/dom.d.ts +3 -0
- package/package.json +14 -6
- package/{src/public-api.ts → public-api.d.ts} +0 -11
- package/ng-package.json +0 -9
- package/src/lib/components/atoms/button/button.component.scss +0 -5
- package/src/lib/components/atoms/button/button.component.ts +0 -54
- package/src/lib/components/atoms/button/factory.ts +0 -378
- package/src/lib/components/atoms/button/types.ts +0 -24
- package/src/lib/components/types.ts +0 -84
- package/src/lib/services/download.service.ts +0 -58
- package/src/lib/services/lang-provider/components/lang-settings.ts +0 -14
- package/src/lib/services/lang-provider/components/theme-settings.ts +0 -16
- package/src/lib/services/lang-provider/content.ts +0 -15
- package/src/lib/services/lang-provider/lang-provider.service.ts +0 -38
- package/src/lib/services/lang-provider/types.ts +0 -25
- package/src/lib/services/local-storage.service.ts +0 -18
- package/src/lib/services/theme.service.ts +0 -102
- package/src/lib/shared/constants/storage.ts +0 -2
- package/src/lib/shared/utils/dom.ts +0 -20
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { LocalStorageService } from './local-storage.service';
|
|
4
|
-
import { THEME } from '../shared/constants/storage';
|
|
5
|
-
|
|
6
|
-
export enum ThemeOption {
|
|
7
|
-
LIGHT = 'light',
|
|
8
|
-
DARK = 'dark',
|
|
9
|
-
AUTO = 'auto',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@Injectable({
|
|
13
|
-
providedIn: 'root',
|
|
14
|
-
})
|
|
15
|
-
export class ThemeService {
|
|
16
|
-
lightToggle = false;
|
|
17
|
-
darkToggle = false;
|
|
18
|
-
autoToggle = false;
|
|
19
|
-
currentOption = ThemeOption.AUTO;
|
|
20
|
-
themeOptions = ThemeOption;
|
|
21
|
-
prefersDark = false;
|
|
22
|
-
default = ThemeOption.AUTO;
|
|
23
|
-
theme: BehaviorSubject<ThemeOption>;
|
|
24
|
-
|
|
25
|
-
constructor() {
|
|
26
|
-
const current = LocalStorageService.get<ThemeOption>(THEME);
|
|
27
|
-
console.log('💡 ThemeConfig current::: ', current);
|
|
28
|
-
this.theme = new BehaviorSubject<ThemeOption>(current || this.default);
|
|
29
|
-
this.currentOption = this.Theme;
|
|
30
|
-
console.log('💡 ThemeConfig this.currentOption::: ', this.currentOption);
|
|
31
|
-
this.toggleUserPreference(this.currentOption);
|
|
32
|
-
|
|
33
|
-
const prefersDarkQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
34
|
-
this.prefersDark = prefersDarkQuery.matches;
|
|
35
|
-
this.handleAutoConfiguration();
|
|
36
|
-
|
|
37
|
-
prefersDarkQuery.addEventListener('change', (mediaQuery) => {
|
|
38
|
-
console.log('💡 ThemeConfig addEventListener change::: ', mediaQuery);
|
|
39
|
-
this.prefersDark = mediaQuery.matches;
|
|
40
|
-
this.handleAutoConfiguration();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private handleAutoConfiguration() {
|
|
45
|
-
if (this.prefersDark && this.currentOption === ThemeOption.AUTO) {
|
|
46
|
-
console.log('💡 ThemeConfig prefersDark::: ', this.prefersDark);
|
|
47
|
-
this.toggleUserPreference(ThemeOption.AUTO);
|
|
48
|
-
}
|
|
49
|
-
if (!this.prefersDark && this.currentOption === ThemeOption.AUTO) {
|
|
50
|
-
console.log('💡 ThemeConfig prefersDark::: ', this.prefersDark);
|
|
51
|
-
this.toggleUserPreference(ThemeOption.AUTO);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private handleDarkPreference() {
|
|
56
|
-
this.toggleTheme(ThemeOption.DARK, true);
|
|
57
|
-
this.toggleTheme(ThemeOption.LIGHT, false);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private handleLightPreference() {
|
|
61
|
-
this.toggleTheme(ThemeOption.LIGHT, true);
|
|
62
|
-
this.toggleTheme(ThemeOption.DARK, false);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get Theme(): ThemeOption {
|
|
66
|
-
return this.theme.value;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
set Theme(theme: ThemeOption) {
|
|
70
|
-
this.theme.next(theme);
|
|
71
|
-
LocalStorageService.set<ThemeOption>(THEME, theme);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
toggleTheme(name: string, shouldAdd: boolean) {
|
|
75
|
-
console.log('toggleTheme::: ', name, shouldAdd);
|
|
76
|
-
document.body.classList.toggle(name, shouldAdd);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
toggleUserPreference(option: ThemeOption) {
|
|
80
|
-
this.currentOption = option;
|
|
81
|
-
this.Theme = option;
|
|
82
|
-
this.lightToggle = option === ThemeOption.LIGHT;
|
|
83
|
-
this.darkToggle = option === ThemeOption.DARK;
|
|
84
|
-
this.autoToggle = option === ThemeOption.AUTO;
|
|
85
|
-
|
|
86
|
-
switch (option) {
|
|
87
|
-
case ThemeOption.LIGHT:
|
|
88
|
-
this.handleLightPreference();
|
|
89
|
-
break;
|
|
90
|
-
case ThemeOption.DARK:
|
|
91
|
-
this.handleDarkPreference();
|
|
92
|
-
break;
|
|
93
|
-
case ThemeOption.AUTO:
|
|
94
|
-
if (this.prefersDark) {
|
|
95
|
-
this.handleDarkPreference();
|
|
96
|
-
} else {
|
|
97
|
-
this.handleLightPreference();
|
|
98
|
-
}
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ElementRef } from "@angular/core";
|
|
2
|
-
|
|
3
|
-
export const goToTop = (id: string): void => {
|
|
4
|
-
const element = document.getElementById(id);
|
|
5
|
-
if (element) {
|
|
6
|
-
element.scrollIntoView({
|
|
7
|
-
block: 'start',
|
|
8
|
-
inline: 'nearest',
|
|
9
|
-
behavior: 'smooth',
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const isAtEnd = (elementRef: ElementRef): boolean => {
|
|
16
|
-
const formElement = elementRef.nativeElement;
|
|
17
|
-
const rect = formElement.getBoundingClientRect();
|
|
18
|
-
const windowHeight = window.innerHeight;
|
|
19
|
-
return rect.bottom <= windowHeight;
|
|
20
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/lib",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"inlineSources": true,
|
|
9
|
-
"types": []
|
|
10
|
-
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"**/*.spec.ts"
|
|
13
|
-
]
|
|
14
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
-
{
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"outDir": "../../out-tsc/spec",
|
|
6
|
-
"types": [
|
|
7
|
-
"jasmine"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
"include": [
|
|
11
|
-
"**/*.spec.ts",
|
|
12
|
-
"**/*.d.ts"
|
|
13
|
-
]
|
|
14
|
-
}
|