bernova 1.3.0 → 1.3.1
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/CHANGELOG.md +6 -0
- package/dist/src/lib/generateProvider/template/providerTemplate.js +163 -1
- package/dist/src/styles/default/default.css +9 -0
- package/dist/src/styles/default/default.min.css +0 -0
- package/dist/styles/default/default.css +9 -0
- package/dist/styles/default/default.min.css +0 -0
- package/dist/styles/default/default.min.min.css +0 -0
- package/package.json +1 -1
- package/src/styles/default/default.css +9 -0
- package/src/styles/default/default.min.css +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to Bernova will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.3.1] - 2026-01-21
|
|
9
|
+
|
|
10
|
+
### Patch
|
|
11
|
+
|
|
12
|
+
- **prevent minify provider**: Prevent minify providerTemplate.js file
|
|
13
|
+
|
|
8
14
|
## [1.3.0] - 2026-01-21
|
|
9
15
|
|
|
10
16
|
### New Features
|
|
@@ -1 +1,163 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
cssThemes,
|
|
3
|
+
cssClasses,
|
|
4
|
+
cssVars,
|
|
5
|
+
cssAvailableComponents,
|
|
6
|
+
cssGlobalStyles,
|
|
7
|
+
cssMediaQueries,
|
|
8
|
+
} from './stats/stats';
|
|
9
|
+
|
|
10
|
+
export class $_Provider_$ {
|
|
11
|
+
#currentTheme;
|
|
12
|
+
#themes;
|
|
13
|
+
#themesVariables;
|
|
14
|
+
#themesClassNames;
|
|
15
|
+
#themesComponents;
|
|
16
|
+
#themesGlobalStyles;
|
|
17
|
+
#themesMediaQueries;
|
|
18
|
+
#linkId;
|
|
19
|
+
#jsInCss;
|
|
20
|
+
/* Bernova provider methods */
|
|
21
|
+
#linkBuilder = (url, id) => {
|
|
22
|
+
if (typeof document === 'undefined') return;
|
|
23
|
+
let linkElement = document.getElementById(id);
|
|
24
|
+
if (!linkElement) {
|
|
25
|
+
linkElement = document.createElement('link');
|
|
26
|
+
linkElement.id = id;
|
|
27
|
+
linkElement.rel = 'stylesheet';
|
|
28
|
+
document.head.appendChild(linkElement);
|
|
29
|
+
}
|
|
30
|
+
const href = new URL(url, import.meta.url).href;
|
|
31
|
+
linkElement.href = href;
|
|
32
|
+
};
|
|
33
|
+
#handlerThemes = (data) => {
|
|
34
|
+
const { css, foreign } = data;
|
|
35
|
+
const beforeFiles = foreign?.before || [];
|
|
36
|
+
const afterFiles = foreign?.after || [];
|
|
37
|
+
//* set the lower priority foreign themes
|
|
38
|
+
beforeFiles.forEach((url, idx) => {
|
|
39
|
+
const id = `${this.#linkId}-foreign-before-${idx + 1}`;
|
|
40
|
+
this.#linkBuilder(url, id);
|
|
41
|
+
});
|
|
42
|
+
//* set main theme
|
|
43
|
+
this.#linkBuilder(css, this.#linkId);
|
|
44
|
+
//* set the higher priority foreign themes
|
|
45
|
+
afterFiles.forEach((url, idx) => {
|
|
46
|
+
const id = `${this.#linkId}-foreign-after-${idx + 1}`;
|
|
47
|
+
this.#linkBuilder(url, id);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
#cleanUpLinks = () => {
|
|
51
|
+
if (typeof document === 'undefined') return;
|
|
52
|
+
const links = document.querySelectorAll(`link[id^="${this.#linkId}"]`);
|
|
53
|
+
links.forEach((link) => link.remove());
|
|
54
|
+
};
|
|
55
|
+
/* Bernova provider methods */
|
|
56
|
+
|
|
57
|
+
constructor({ linkId, jsInCss } = {}) {
|
|
58
|
+
this.#themes = cssThemes;
|
|
59
|
+
this.#themesVariables = cssVars;
|
|
60
|
+
this.#themesClassNames = cssClasses;
|
|
61
|
+
this.#themesComponents = cssAvailableComponents;
|
|
62
|
+
this.#themesGlobalStyles = cssGlobalStyles;
|
|
63
|
+
this.#themesMediaQueries = cssMediaQueries;
|
|
64
|
+
this.#linkId = linkId || 'kb-styled-link';
|
|
65
|
+
this.#currentTheme = Object.keys(cssThemes)[0];
|
|
66
|
+
this.#jsInCss = !!jsInCss;
|
|
67
|
+
this.getComponentStyles = this.getComponentStyles.bind(this);
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
typeof window !== 'undefined' &&
|
|
71
|
+
typeof document !== 'undefined' &&
|
|
72
|
+
this.#jsInCss
|
|
73
|
+
) {
|
|
74
|
+
this.#cleanUpLinks();
|
|
75
|
+
this.#handlerThemes(this.#themes[this.#currentTheme]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// ? getters and setters
|
|
79
|
+
//* theme selected
|
|
80
|
+
get themeSelected() {
|
|
81
|
+
return this.#currentTheme;
|
|
82
|
+
}
|
|
83
|
+
set themeSelected(themeName) {
|
|
84
|
+
if (themeName in this.#themes) {
|
|
85
|
+
if (this.#jsInCss) {
|
|
86
|
+
this.#cleanUpLinks();
|
|
87
|
+
this.#handlerThemes(this.#themes[themeName]);
|
|
88
|
+
}
|
|
89
|
+
this.#currentTheme = themeName;
|
|
90
|
+
} else {
|
|
91
|
+
throw new Error(`${themeName} is not exists`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//* themes
|
|
95
|
+
get allThemesNames() {
|
|
96
|
+
return Object.keys(this.#themes);
|
|
97
|
+
}
|
|
98
|
+
get allThemes() {
|
|
99
|
+
return this.#themes;
|
|
100
|
+
}
|
|
101
|
+
//* variables
|
|
102
|
+
get variables() {
|
|
103
|
+
return this.#themesVariables[this.#currentTheme];
|
|
104
|
+
}
|
|
105
|
+
//* classNames
|
|
106
|
+
get classNames() {
|
|
107
|
+
return this.#themesClassNames[this.#currentTheme];
|
|
108
|
+
}
|
|
109
|
+
//* components
|
|
110
|
+
get components() {
|
|
111
|
+
return this.#themesComponents[this.#currentTheme];
|
|
112
|
+
}
|
|
113
|
+
//* global styles
|
|
114
|
+
get globalStyles() {
|
|
115
|
+
return this.#themesGlobalStyles[this.#currentTheme];
|
|
116
|
+
}
|
|
117
|
+
//* media queries
|
|
118
|
+
get mediaQueries() {
|
|
119
|
+
return this.#themesMediaQueries[this.#currentTheme];
|
|
120
|
+
}
|
|
121
|
+
//? methods
|
|
122
|
+
getComponentStyles({ variant, component, additionalClassNames }) {
|
|
123
|
+
const THEME = this.#themesClassNames[this.#currentTheme];
|
|
124
|
+
const upperComponent = component.toLocaleUpperCase();
|
|
125
|
+
const COMPONENT = THEME[upperComponent];
|
|
126
|
+
|
|
127
|
+
if (!COMPONENT) return {};
|
|
128
|
+
|
|
129
|
+
const structure = {};
|
|
130
|
+
const startV = '$_';
|
|
131
|
+
const componentVariant = (() => {
|
|
132
|
+
if (!!variant) {
|
|
133
|
+
const lowerVariant = variant.toLocaleLowerCase().replace(/-/g, '_');
|
|
134
|
+
return `${startV}${lowerVariant}`;
|
|
135
|
+
} else {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
})();
|
|
139
|
+
if (componentVariant && componentVariant in COMPONENT) {
|
|
140
|
+
const variantFragment = COMPONENT[componentVariant];
|
|
141
|
+
Object.entries(variantFragment).forEach(([key, value]) => {
|
|
142
|
+
if (!(key in structure)) {
|
|
143
|
+
structure[key] = value;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
Object.entries(COMPONENT).forEach(([key, value]) => {
|
|
148
|
+
if (key.startsWith(startV)) return;
|
|
149
|
+
if (!(key in structure)) {
|
|
150
|
+
structure[key] = value;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
if (!!additionalClassNames && Object.keys(additionalClassNames).length) {
|
|
154
|
+
Object.entries(additionalClassNames).forEach(([key, value]) => {
|
|
155
|
+
if (!(key in structure)) {
|
|
156
|
+
structure[key] = '';
|
|
157
|
+
}
|
|
158
|
+
structure[key] += ` ${value}`;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return structure;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
File without changes
|