next-style 2.0.0 → 2.0.2
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/dist/index.cjs +31 -0
- package/dist/index.d.cts +259 -0
- package/dist/index.d.ts +259 -5
- package/dist/index.js +31 -4
- package/dist/postcss-plugin/index.cjs +1 -0
- package/dist/postcss-plugin/index.d.cts +19 -0
- package/dist/postcss-plugin/index.d.ts +12 -21
- package/dist/postcss-plugin/index.js +1 -48
- package/package.json +27 -15
- package/dist/compiler/index.d.ts +0 -95
- package/dist/compiler/index.d.ts.map +0 -1
- package/dist/compiler/index.js +0 -229
- package/dist/index.d.ts.map +0 -1
- package/dist/postcss-plugin/index.d.ts.map +0 -1
- package/dist/runtime/index.d.ts +0 -104
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -62
- package/dist/utils/index.d.ts +0 -60
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -97
package/dist/utils/index.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a camelCase CSS property name to kebab-case.
|
|
3
|
-
*
|
|
4
|
-
* @param str - camelCase string, e.g. `"backgroundColor"`.
|
|
5
|
-
* @returns kebab-case string, e.g. `"background-color"`.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* camelToKebab('fontSize') // "font-size"
|
|
9
|
-
* camelToKebab('borderTopWidth') // "border-top-width"
|
|
10
|
-
*/
|
|
11
|
-
export declare function camelToKebab(str: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Generates a short, stable hash string from a style object or string.
|
|
14
|
-
* Used to produce unique class name suffixes (e.g. `"ns-1x2y3z"`).
|
|
15
|
-
*
|
|
16
|
-
* @param styles - Style object or pre-serialised string.
|
|
17
|
-
* @returns Base-36 hash string.
|
|
18
|
-
*/
|
|
19
|
-
export declare function generateClassHash(styles: any): string;
|
|
20
|
-
/**
|
|
21
|
-
* Shorthand breakpoint aliases mapped to their full `@media` query strings.
|
|
22
|
-
*
|
|
23
|
-
* | Key | Expands to |
|
|
24
|
-
* |--------|-------------------------------------|
|
|
25
|
-
* | `@sm` | `@media (min-width: 640px)` |
|
|
26
|
-
* | `@md` | `@media (min-width: 768px)` |
|
|
27
|
-
* | `@lg` | `@media (min-width: 1024px)` |
|
|
28
|
-
* | `@xl` | `@media (min-width: 1280px)` |
|
|
29
|
-
* | `@2xl` | `@media (min-width: 1536px)` |
|
|
30
|
-
*/
|
|
31
|
-
export declare const BREAKPOINTS: Record<string, string>;
|
|
32
|
-
/**
|
|
33
|
-
* Resolves a breakpoint shorthand to its full `@media` query string.
|
|
34
|
-
* Passes through unrecognised strings unchanged.
|
|
35
|
-
*
|
|
36
|
-
* @param query - Shorthand key (e.g. `"@md"`) or an arbitrary media query.
|
|
37
|
-
* @returns Full media query string (e.g. `"@media (min-width: 768px)"`).
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* normalizeMediaQuery('@md') // "@media (min-width: 768px)"
|
|
41
|
-
* normalizeMediaQuery('@media (max-width: 600px)') // "@media (max-width: 600px)"
|
|
42
|
-
*/
|
|
43
|
-
export declare function normalizeMediaQuery(query: string): string;
|
|
44
|
-
/**
|
|
45
|
-
* Returns `true` if the value is a valid CSS property value that can be
|
|
46
|
-
* serialised to a declaration (string, number, or nested object).
|
|
47
|
-
*
|
|
48
|
-
* @param _key - CSS property name (unused, reserved for future validation).
|
|
49
|
-
* @param value - Value to check.
|
|
50
|
-
*/
|
|
51
|
-
export declare function validateCSSProperty(_key: string, value: any): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Removes duplicate entries from a style map, keeping the first occurrence.
|
|
54
|
-
* Two entries are considered duplicates when their serialised values are identical.
|
|
55
|
-
*
|
|
56
|
-
* @param styles - Map of class name → style data.
|
|
57
|
-
* @returns New map with duplicates removed.
|
|
58
|
-
*/
|
|
59
|
-
export declare function deduplicateStyles(styles: Map<string, any>): Map<string, any>;
|
|
60
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,CASrD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAM9C,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAQrE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAW5E"}
|
package/dist/utils/index.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a camelCase CSS property name to kebab-case.
|
|
3
|
-
*
|
|
4
|
-
* @param str - camelCase string, e.g. `"backgroundColor"`.
|
|
5
|
-
* @returns kebab-case string, e.g. `"background-color"`.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* camelToKebab('fontSize') // "font-size"
|
|
9
|
-
* camelToKebab('borderTopWidth') // "border-top-width"
|
|
10
|
-
*/
|
|
11
|
-
export function camelToKebab(str) {
|
|
12
|
-
return str.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Generates a short, stable hash string from a style object or string.
|
|
16
|
-
* Used to produce unique class name suffixes (e.g. `"ns-1x2y3z"`).
|
|
17
|
-
*
|
|
18
|
-
* @param styles - Style object or pre-serialised string.
|
|
19
|
-
* @returns Base-36 hash string.
|
|
20
|
-
*/
|
|
21
|
-
export function generateClassHash(styles) {
|
|
22
|
-
const str = typeof styles === 'string' ? styles : JSON.stringify(styles);
|
|
23
|
-
let hash = 0;
|
|
24
|
-
for (let i = 0; i < str.length; i++) {
|
|
25
|
-
const char = str.charCodeAt(i);
|
|
26
|
-
hash = (hash << 5) - hash + char;
|
|
27
|
-
hash = hash & hash;
|
|
28
|
-
}
|
|
29
|
-
return Math.abs(hash).toString(36);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Shorthand breakpoint aliases mapped to their full `@media` query strings.
|
|
33
|
-
*
|
|
34
|
-
* | Key | Expands to |
|
|
35
|
-
* |--------|-------------------------------------|
|
|
36
|
-
* | `@sm` | `@media (min-width: 640px)` |
|
|
37
|
-
* | `@md` | `@media (min-width: 768px)` |
|
|
38
|
-
* | `@lg` | `@media (min-width: 1024px)` |
|
|
39
|
-
* | `@xl` | `@media (min-width: 1280px)` |
|
|
40
|
-
* | `@2xl` | `@media (min-width: 1536px)` |
|
|
41
|
-
*/
|
|
42
|
-
export const BREAKPOINTS = {
|
|
43
|
-
'@sm': '@media (min-width: 640px)',
|
|
44
|
-
'@md': '@media (min-width: 768px)',
|
|
45
|
-
'@lg': '@media (min-width: 1024px)',
|
|
46
|
-
'@xl': '@media (min-width: 1280px)',
|
|
47
|
-
'@2xl': '@media (min-width: 1536px)'
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Resolves a breakpoint shorthand to its full `@media` query string.
|
|
51
|
-
* Passes through unrecognised strings unchanged.
|
|
52
|
-
*
|
|
53
|
-
* @param query - Shorthand key (e.g. `"@md"`) or an arbitrary media query.
|
|
54
|
-
* @returns Full media query string (e.g. `"@media (min-width: 768px)"`).
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* normalizeMediaQuery('@md') // "@media (min-width: 768px)"
|
|
58
|
-
* normalizeMediaQuery('@media (max-width: 600px)') // "@media (max-width: 600px)"
|
|
59
|
-
*/
|
|
60
|
-
export function normalizeMediaQuery(query) {
|
|
61
|
-
return BREAKPOINTS[query] ?? query;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Returns `true` if the value is a valid CSS property value that can be
|
|
65
|
-
* serialised to a declaration (string, number, or nested object).
|
|
66
|
-
*
|
|
67
|
-
* @param _key - CSS property name (unused, reserved for future validation).
|
|
68
|
-
* @param value - Value to check.
|
|
69
|
-
*/
|
|
70
|
-
export function validateCSSProperty(_key, value) {
|
|
71
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Removes duplicate entries from a style map, keeping the first occurrence.
|
|
81
|
-
* Two entries are considered duplicates when their serialised values are identical.
|
|
82
|
-
*
|
|
83
|
-
* @param styles - Map of class name → style data.
|
|
84
|
-
* @returns New map with duplicates removed.
|
|
85
|
-
*/
|
|
86
|
-
export function deduplicateStyles(styles) {
|
|
87
|
-
const deduplicated = new Map();
|
|
88
|
-
const seen = new Set();
|
|
89
|
-
styles.forEach((value, key) => {
|
|
90
|
-
const serialized = JSON.stringify(value);
|
|
91
|
-
if (!seen.has(serialized)) {
|
|
92
|
-
seen.add(serialized);
|
|
93
|
-
deduplicated.set(key, value);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return deduplicated;
|
|
97
|
-
}
|