vasille-css 3.0.5 → 3.1.0
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/README.md +3 -4
- package/fake-types/index.d.ts +2 -13
- package/lib/index.js +1 -1
- package/package.json +11 -15
- package/lib-node/index.js +0 -100
package/README.md
CHANGED
|
@@ -103,12 +103,11 @@ All of these are supported:
|
|
|
103
103
|
* [x] Develop the `Vasille JSX` library.
|
|
104
104
|
* [x] `100%` Test Coverage for the JSX library.
|
|
105
105
|
* [x] Develop the `Vasille Babel Plugin`.
|
|
106
|
-
* [
|
|
106
|
+
* [x] `100%` Test Coverage fot babel plugin.
|
|
107
107
|
* [x] Add CSS support (define styles in components).
|
|
108
|
-
* [ ] Add custom `input` components with 2-way value binding.
|
|
109
108
|
* [ ] Add router.
|
|
110
|
-
* [ ]
|
|
111
|
-
* [ ] Develop
|
|
109
|
+
* [ ] Add SSR (server side rendering).
|
|
110
|
+
* [ ] Develop tools extension for debugging.
|
|
112
111
|
|
|
113
112
|
## Questions
|
|
114
113
|
|
package/fake-types/index.d.ts
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import type { PropertiesHyphenFallback } from "csstype";
|
|
2
|
-
|
|
3
1
|
export declare function setMobileMaxWidth(value: number): void;
|
|
4
2
|
export declare function setTabletMaxWidth(value: number): void;
|
|
5
3
|
export declare function setLaptopMaxWidth(value: number): void;
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
[
|
|
9
|
-
};
|
|
10
|
-
type PseudoSet = PropsSet & {
|
|
11
|
-
[k: `:${string}`]: PropsSet;
|
|
12
|
-
};
|
|
13
|
-
type MediaSet = PseudoSet & {
|
|
14
|
-
[k: `@${string}`]: PseudoSet;
|
|
15
|
-
};
|
|
16
|
-
export declare function webStyleSheet<T extends {
|
|
17
|
-
[k: string]: MediaSet;
|
|
5
|
+
export declare function styleSheet<T extends {
|
|
6
|
+
[className: string]: unknown;
|
|
18
7
|
}>(styles: T): {
|
|
19
8
|
[K in keyof T]: string;
|
|
20
9
|
};
|
package/lib/index.js
CHANGED
|
@@ -64,7 +64,7 @@ function insertRule(target, rule) {
|
|
|
64
64
|
sheet.insertRule(rule, sheet.cssRules.length);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
export function
|
|
67
|
+
export function styleSheet(styles) {
|
|
68
68
|
const result = {};
|
|
69
69
|
for (const key in styles) {
|
|
70
70
|
Object.defineProperty(result, key, {
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasille-css",
|
|
3
|
-
"version": "3.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "The first Developer eXperience orientated front-end framework (style library)",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./fake-types/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
|
+
"types": "./fake-types/index.d.ts",
|
|
8
9
|
"import": "./lib/index.js",
|
|
9
10
|
"browser": "./lib/index.js",
|
|
10
|
-
"node": "./lib
|
|
11
|
-
"require": "./lib-node/index.js"
|
|
11
|
+
"node": "./lib/index.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"prepack": "cp -f ../README.md ./README.md",
|
|
15
15
|
"prettier": "prettier src test --write",
|
|
16
16
|
"build": "tsc --build tsconfig.json",
|
|
17
|
-
"
|
|
17
|
+
"test-types": "tsc --noEmit ./fake-types/index.d.ts",
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"test-coverage": "jest --coverage"
|
|
20
20
|
},
|
|
@@ -34,17 +34,13 @@
|
|
|
34
34
|
"type": "git",
|
|
35
35
|
"url": "git+https://github.com/vasille-js/vasille-js.git"
|
|
36
36
|
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"csstype": "^3.1.3"
|
|
39
|
-
},
|
|
40
37
|
"devDependencies": {
|
|
41
|
-
"@types/jest": "^
|
|
38
|
+
"@types/jest": "^30.0.0",
|
|
42
39
|
"@types/jsdom": "^21.1.7",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"typescript": "^5.6.3"
|
|
40
|
+
"jest": "^30.0.5",
|
|
41
|
+
"jsdom": "^26.1.0",
|
|
42
|
+
"prettier": "^3.6.2",
|
|
43
|
+
"ts-jest": "^29.4.0",
|
|
44
|
+
"typescript": "^5.8.3"
|
|
49
45
|
}
|
|
50
46
|
}
|
package/lib-node/index.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setMobileMaxWidth = setMobileMaxWidth;
|
|
4
|
-
exports.setTabletMaxWidth = setTabletMaxWidth;
|
|
5
|
-
exports.setLaptopMaxWidth = setLaptopMaxWidth;
|
|
6
|
-
exports.setIndex = setIndex;
|
|
7
|
-
exports.webStyleSheet = webStyleSheet;
|
|
8
|
-
let common;
|
|
9
|
-
let mobile;
|
|
10
|
-
let tablet;
|
|
11
|
-
let desktop;
|
|
12
|
-
let dark;
|
|
13
|
-
let light;
|
|
14
|
-
let mobileMaxWidth = 440;
|
|
15
|
-
let tabletMaxWidth = 880;
|
|
16
|
-
let laptopMaxWidth = 1320;
|
|
17
|
-
let index = Math.floor(Math.random() * 10);
|
|
18
|
-
function setMobileMaxWidth(value) {
|
|
19
|
-
mobileMaxWidth = value;
|
|
20
|
-
}
|
|
21
|
-
function setTabletMaxWidth(value) {
|
|
22
|
-
tabletMaxWidth = value;
|
|
23
|
-
}
|
|
24
|
-
function setLaptopMaxWidth(value) {
|
|
25
|
-
laptopMaxWidth = value;
|
|
26
|
-
}
|
|
27
|
-
function setIndex(value) {
|
|
28
|
-
index = value;
|
|
29
|
-
}
|
|
30
|
-
function createStyleSheet(media) {
|
|
31
|
-
const style = document.createElement("style");
|
|
32
|
-
style.media = media;
|
|
33
|
-
document.head.append(style);
|
|
34
|
-
return style.sheet;
|
|
35
|
-
}
|
|
36
|
-
function insertRule(target, rule) {
|
|
37
|
-
let sheet;
|
|
38
|
-
switch (target) {
|
|
39
|
-
case 1:
|
|
40
|
-
if (!mobile) {
|
|
41
|
-
mobile = createStyleSheet(`(max-width:${mobileMaxWidth}px)`);
|
|
42
|
-
}
|
|
43
|
-
sheet = mobile;
|
|
44
|
-
break;
|
|
45
|
-
case 2:
|
|
46
|
-
if (!tablet) {
|
|
47
|
-
tablet = createStyleSheet(`(min-width:${mobileMaxWidth}px)and(max-width:${tabletMaxWidth}px)`);
|
|
48
|
-
}
|
|
49
|
-
sheet = tablet;
|
|
50
|
-
break;
|
|
51
|
-
case 3:
|
|
52
|
-
if (!desktop) {
|
|
53
|
-
desktop = createStyleSheet(`(min-width:${tabletMaxWidth}px)and(max-width:${laptopMaxWidth}px)`);
|
|
54
|
-
}
|
|
55
|
-
sheet = desktop;
|
|
56
|
-
break;
|
|
57
|
-
case 4:
|
|
58
|
-
if (!dark) {
|
|
59
|
-
dark = createStyleSheet("(prefers-color-scheme:dark)");
|
|
60
|
-
}
|
|
61
|
-
sheet = dark;
|
|
62
|
-
break;
|
|
63
|
-
case 5:
|
|
64
|
-
if (!light) {
|
|
65
|
-
light = createStyleSheet("(prefers-color-scheme:light)");
|
|
66
|
-
}
|
|
67
|
-
sheet = light;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
if (sheet) {
|
|
71
|
-
sheet.insertRule(rule, sheet.cssRules.length);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function webStyleSheet(styles) {
|
|
75
|
-
const result = {};
|
|
76
|
-
for (const key in styles) {
|
|
77
|
-
Object.defineProperty(result, key, {
|
|
78
|
-
get() {
|
|
79
|
-
const className = `v-${++index}`;
|
|
80
|
-
for (const item of styles[key]) {
|
|
81
|
-
if (item instanceof Array) {
|
|
82
|
-
const [target, rule] = item;
|
|
83
|
-
insertRule(target, rule.replace("{}", className));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
if (!common) {
|
|
87
|
-
common = createStyleSheet("");
|
|
88
|
-
}
|
|
89
|
-
common.insertRule(item.replace("{}", className), common.cssRules.length);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
styles[key].splice(0);
|
|
93
|
-
Object.defineProperty(result, key, { value: className });
|
|
94
|
-
return className;
|
|
95
|
-
},
|
|
96
|
-
configurable: true,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return result;
|
|
100
|
-
}
|