vasille-css 3.0.5 → 3.2.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/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  * [Installation](#installation)
12
12
  * [How to use Vasille](#how-to-use-vasille)
13
13
  * [How SAFE is Vasille](#how-safe-is-vasille)
14
- * [How SIMPLE is Vasille](#how-simple-is-vasille)
14
+ * [How INTUITIVE is Vasille](#how-intuitive-is-vasille)
15
15
  * [How POWERFUL is Vasille](#how-powerful-is-vasille)
16
16
  * [Road Map](#road-map)
17
17
 
@@ -44,6 +44,7 @@ $ npx degit vasille-js/example-javascript my-project
44
44
 
45
45
  ### Full documentation:
46
46
  * [Learn `Vasille` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v3/doc/V3-API.md)
47
+ * [Vasille Router Documentation](https://github.com/vasille-js/vasille-js/blob/v3/doc/Router-API.md)
47
48
 
48
49
  ### Examples
49
50
  * [TypeScript Example](https://github.com/vasille-js/example-typescript)
@@ -60,7 +61,7 @@ The safe of your application is ensured by
60
61
  * `strong typing` makes your javascript/typescript code safe as C++ code.
61
62
  All entities of `vasille` core library are strongly typed, including:
62
63
  * data fields & properties.
63
- * computed properties (function parameters & result).
64
+ * computed properties (function parameters and result).
64
65
  * methods.
65
66
  * events (defined handlers & event emit).
66
67
  * DOM events & DOM operation (attributing, styling, etc.).
@@ -68,7 +69,7 @@ All entities of `vasille` core library are strongly typed, including:
68
69
  * references to children.
69
70
  * No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
70
71
 
71
- ## How SIMPLE is Vasille
72
+ ## How INTUITIVE is Vasille
72
73
 
73
74
  There is the "Hello World":
74
75
  ```typescript jsx
@@ -103,12 +104,11 @@ All of these are supported:
103
104
  * [x] Develop the `Vasille JSX` library.
104
105
  * [x] `100%` Test Coverage for the JSX library.
105
106
  * [x] Develop the `Vasille Babel Plugin`.
106
- * [ ] `100%` Test Coverage fot babel plugin.
107
+ * [x] `100%` Test Coverage fot babel plugin.
107
108
  * [x] Add CSS support (define styles in components).
108
- * [ ] Add custom `input` components with 2-way value binding.
109
- * [ ] Add router.
110
- * [ ] Develop dev-tools extension for debugging.
111
- * [ ] Develop a lot of libraries for the framework.
109
+ * [x] Add router.
110
+ * [ ] Add SSR (server side rendering).
111
+ * [ ] Develop tools extension for debugging.
112
112
 
113
113
  ## Questions
114
114
 
package/lib/index.js CHANGED
@@ -30,41 +30,51 @@ function insertRule(target, rule) {
30
30
  let sheet;
31
31
  switch (target) {
32
32
  case 1:
33
+ /* istanbul ignore else */
33
34
  if (!mobile) {
34
35
  mobile = createStyleSheet(`(max-width:${mobileMaxWidth}px)`);
35
36
  }
36
37
  sheet = mobile;
37
38
  break;
38
39
  case 2:
40
+ /* istanbul ignore else */
39
41
  if (!tablet) {
40
42
  tablet = createStyleSheet(`(min-width:${mobileMaxWidth}px) and (max-width:${tabletMaxWidth}px)`);
41
43
  }
42
44
  sheet = tablet;
43
45
  break;
44
46
  case 3:
47
+ /* istanbul ignore else */
45
48
  if (!desktop) {
46
49
  desktop = createStyleSheet(`(min-width:${tabletMaxWidth}px) and (max-width:${laptopMaxWidth}px)`);
47
50
  }
48
51
  sheet = desktop;
49
52
  break;
50
53
  case 4:
54
+ /* istanbul ignore else */
51
55
  if (!dark) {
52
56
  dark = createStyleSheet("(prefers-color-scheme:dark)");
53
57
  }
54
58
  sheet = dark;
55
59
  break;
56
60
  case 5:
61
+ /* istanbul ignore else */
57
62
  if (!light) {
58
63
  light = createStyleSheet("(prefers-color-scheme:light)");
59
64
  }
60
65
  sheet = light;
61
66
  break;
62
67
  }
68
+ /* istanbul ignore else */
63
69
  if (sheet) {
64
70
  sheet.insertRule(rule, sheet.cssRules.length);
65
71
  }
66
72
  }
67
- export function webStyleSheet(styles) {
73
+ /**
74
+ * Inserts stylesheet to document
75
+ * @param styles CSS styles based on classes
76
+ */
77
+ export function styleSheet(styles) {
68
78
  const result = {};
69
79
  for (const key in styles) {
70
80
  Object.defineProperty(result, key, {
@@ -76,6 +86,7 @@ export function webStyleSheet(styles) {
76
86
  insertRule(target, rule.replace("{}", className));
77
87
  }
78
88
  else {
89
+ /* istanbul ignore else */
79
90
  if (!common) {
80
91
  common = createStyleSheet("");
81
92
  }
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "vasille-css",
3
- "version": "3.0.5",
4
- "description": "Add module CSS styles to Vasille Components",
3
+ "version": "3.2.1",
4
+ "description": "The first Developer eXperience Orientated front-end framework (style library)",
5
5
  "main": "./lib/index.js",
6
- "types": "./fake-types/index.d.ts",
6
+ "types": "./types/index.d.ts",
7
7
  "exports": {
8
+ "types": "./types/index.d.ts",
8
9
  "import": "./lib/index.js",
9
10
  "browser": "./lib/index.js",
10
- "node": "./lib-node/index.js",
11
- "require": "./lib-node/index.js"
11
+ "node": "./lib/index.js"
12
12
  },
13
+ "type": "module",
13
14
  "scripts": {
14
15
  "prepack": "cp -f ../README.md ./README.md",
15
16
  "prettier": "prettier src test --write",
16
17
  "build": "tsc --build tsconfig.json",
17
- "build-node": "tsc --build tsconfig-build-node.json",
18
+ "build-types": "tsc --build tsconfig-types.json",
18
19
  "test": "jest",
19
20
  "test-coverage": "jest --coverage"
20
21
  },
@@ -34,17 +35,13 @@
34
35
  "type": "git",
35
36
  "url": "git+https://github.com/vasille-js/vasille-js.git"
36
37
  },
37
- "peerDependencies": {
38
- "csstype": "^3.1.3"
39
- },
40
38
  "devDependencies": {
41
- "@types/jest": "^29.5.14",
39
+ "@types/jest": "^30.0.0",
42
40
  "@types/jsdom": "^21.1.7",
43
- "csstype": "^3.1.3",
44
- "jest": "^29.7.0",
45
- "jsdom": "^25.0.1",
46
- "prettier": "^3.3.3",
47
- "ts-jest": "^29.2.5",
48
- "typescript": "^5.6.3"
41
+ "jest": "^30.0.5",
42
+ "jsdom": "^26.1.0",
43
+ "prettier": "^3.6.2",
44
+ "ts-jest": "^29.4.0",
45
+ "typescript": "^5.8.3"
49
46
  }
50
47
  }
@@ -0,0 +1,13 @@
1
+ export declare function setMobileMaxWidth(value: number): void;
2
+ export declare function setTabletMaxWidth(value: number): void;
3
+ export declare function setLaptopMaxWidth(value: number): void;
4
+ export declare function setIndex(value: number): void;
5
+ /**
6
+ * Inserts stylesheet to document
7
+ * @param styles CSS styles based on classes
8
+ */
9
+ export declare function styleSheet<T extends {
10
+ [k: string]: (string | [number, string])[];
11
+ }>(styles: T): {
12
+ [K in keyof T]: string;
13
+ };
@@ -1,32 +0,0 @@
1
- import type { PropertiesHyphenFallback } from "csstype";
2
-
3
- export declare function setMobileMaxWidth(value: number): void;
4
- export declare function setTabletMaxWidth(value: number): void;
5
- export declare function setLaptopMaxWidth(value: number): void;
6
-
7
- type PropsSet = PropertiesHyphenFallback<number | number[], string> & {
8
- [k: `--${string}`]: string;
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;
18
- }>(styles: T): {
19
- [K in keyof T]: string;
20
- };
21
-
22
- // fake functions
23
- export declare function theme<T>(name: string, value: T): T;
24
- export declare function dark<T>($: T): T;
25
- // rules with target
26
- export declare function mobile<T>($: T): T;
27
- export declare function tablet<T>($: T): T;
28
- export declare function laptop<T>($: T): T;
29
- export declare function prefersDark<T>($: T): T;
30
- export declare function prefersLight<T>($: T): T;
31
-
32
- export {};
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
- }