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 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{cssThemes as e,cssClasses as t,cssVars as s,cssAvailableComponents as i,cssGlobalStyles as n,cssMediaQueries as h}from"./stats/stats";export class $_Provider_${#e;#t;#s;#i;#n;#h;#r;#l;#m;#o=(e,t)=>{if("undefined"==typeof document)return;let s=document.getElementById(t);s||(s=document.createElement("link"),s.id=t,s.rel="stylesheet",document.head.appendChild(s));const i=new URL(e,import.meta.url).href;s.href=i};#a=e=>{const{css:t,foreign:s}=e,i=s?.before||[],n=s?.after||[];i.forEach((e,t)=>{const s=`${this.#l}-foreign-before-${t+1}`;this.#o(e,s)}),this.#o(t,this.#l),n.forEach((e,t)=>{const s=`${this.#l}-foreign-after-${t+1}`;this.#o(e,s)})};#c=()=>{"undefined"!=typeof document&&document.querySelectorAll(`link[id^="${this.#l}"]`).forEach(e=>e.remove())};constructor({linkId:r,jsInCss:l}={}){this.#t=e,this.#s=s,this.#i=t,this.#n=i,this.#h=n,this.#r=h,this.#l=r||"kb-styled-link",this.#e=Object.keys(e)[0],this.#m=!!l,this.getComponentStyles=this.getComponentStyles.bind(this),"undefined"!=typeof window&&"undefined"!=typeof document&&this.#m&&(this.#c(),this.#a(this.#t[this.#e]))}get themeSelected(){return this.#e}set themeSelected(e){if(!(e in this.#t))throw new Error(`${e} is not exists`);this.#m&&(this.#c(),this.#a(this.#t[e])),this.#e=e}get allThemesNames(){return Object.keys(this.#t)}get allThemes(){return this.#t}get variables(){return this.#s[this.#e]}get classNames(){return this.#i[this.#e]}get components(){return this.#n[this.#e]}get globalStyles(){return this.#h[this.#e]}get mediaQueries(){return this.#r[this.#e]}getComponentStyles({variant:e,component:t,additionalClassNames:s}){const i=this.#i[this.#e][t.toLocaleUpperCase()];if(!i)return{};const n={},h=!!e&&`$_${e.toLocaleLowerCase().replace(/-/g,"_")}`;if(h&&h in i){const e=i[h];Object.entries(e).forEach(([e,t])=>{e in n||(n[e]=t)})}return Object.entries(i).forEach(([e,t])=>{e.startsWith("$_")||e in n||(n[e]=t)}),s&&Object.keys(s).length&&Object.entries(s).forEach(([e,t])=>{e in n||(n[e]=""),n[e]+=` ${t}`}),n}}
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
+ }
@@ -0,0 +1,9 @@
1
+ /* === BERNOVA FOUNDATIONS === */
2
+ :root{
3
+ }
4
+
5
+ /* === END FOUNDATIONS === */
6
+
7
+ /* === BERNOVA COMPONENTS === */
8
+
9
+ /* === END COMPONENTS === */
File without changes
@@ -0,0 +1,9 @@
1
+ /* === BERNOVA FOUNDATIONS === */
2
+ :root{
3
+ }
4
+
5
+ /* === END FOUNDATIONS === */
6
+
7
+ /* === BERNOVA COMPONENTS === */
8
+
9
+ /* === END COMPONENTS === */
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bernova",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "The best way to write CSS with Javascript syntax",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -0,0 +1,9 @@
1
+ /* === BERNOVA FOUNDATIONS === */
2
+ :root{
3
+ }
4
+
5
+ /* === END FOUNDATIONS === */
6
+
7
+ /* === BERNOVA COMPONENTS === */
8
+
9
+ /* === END COMPONENTS === */
File without changes