@tokenami/css 0.0.61 → 0.0.62
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 +18 -20
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -17
- package/package.json +8 -5
package/dist/index.cjs
CHANGED
|
@@ -54,31 +54,30 @@ function createCss(config, options) {
|
|
|
54
54
|
const cached = cache.get(cacheId);
|
|
55
55
|
if (cached)
|
|
56
56
|
return cached;
|
|
57
|
-
[baseStyles, ...overrides]
|
|
57
|
+
const allStyles = [baseStyles, ...overrides];
|
|
58
|
+
for (const originalStyles of allStyles) {
|
|
58
59
|
if (!originalStyles)
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
continue;
|
|
61
|
+
for (const [key, value] of Object.entries(originalStyles)) {
|
|
61
62
|
const tokenProperty2 = Tokenami__namespace.TokenProperty.safeParse(key);
|
|
62
63
|
if (!tokenProperty2.success) {
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
overriddenStyles[key] = value;
|
|
65
|
+
continue;
|
|
65
66
|
}
|
|
66
67
|
const parts = Tokenami__namespace.getTokenPropertySplit(tokenProperty2.output);
|
|
67
68
|
const cssProperties = Tokenami__namespace.getCSSPropertiesForAlias(parts.alias, config.aliases);
|
|
68
|
-
|
|
69
|
+
for (const cssProperty of cssProperties) {
|
|
69
70
|
const long = createLonghandProperty(tokenProperty2.output, cssProperty);
|
|
71
|
+
const isNumber = typeof value === "number" && value > 0;
|
|
70
72
|
const tokenPropertyLong = Tokenami__namespace.parseProperty(long, {
|
|
71
73
|
escapeSpecialChars: globalOptions == null ? void 0 : globalOptions.escapeSpecialChars
|
|
72
74
|
});
|
|
73
|
-
if (typeof value === "number" && value > 0) {
|
|
74
|
-
const gridVar = Tokenami__namespace.gridProperty();
|
|
75
|
-
value = `calc(var(${gridVar}) * ${value})`;
|
|
76
|
-
}
|
|
77
75
|
overrideLonghands(overriddenStyles, tokenPropertyLong);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
overriddenStyles[tokenPropertyLong] = value;
|
|
77
|
+
overriddenStyles[calcProperty(tokenPropertyLong)] = isNumber ? "/*on*/" : void 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
82
81
|
cache.set(cacheId, overriddenStyles);
|
|
83
82
|
return overriddenStyles;
|
|
84
83
|
};
|
|
@@ -120,11 +119,14 @@ function overrideLonghands(style, tokenProperty2) {
|
|
|
120
119
|
const longhands = Tokenami__namespace.mapShorthandToLonghands.get(parts.alias) || [];
|
|
121
120
|
longhands.forEach((longhand) => {
|
|
122
121
|
const tokenPropertyLong = createLonghandProperty(tokenProperty2, longhand);
|
|
123
|
-
if (style[tokenPropertyLong])
|
|
122
|
+
if (style[tokenPropertyLong]) {
|
|
124
123
|
delete style[tokenPropertyLong];
|
|
124
|
+
delete style[calcProperty(tokenPropertyLong)];
|
|
125
|
+
}
|
|
125
126
|
overrideLonghands(style, tokenPropertyLong);
|
|
126
127
|
});
|
|
127
128
|
}
|
|
129
|
+
var calcProperty = (property) => property + "__calc";
|
|
128
130
|
function createLonghandProperty(tokenProperty2, cssProperty) {
|
|
129
131
|
const parts = Tokenami__namespace.getTokenPropertySplit(tokenProperty2);
|
|
130
132
|
const aliasRegex = new RegExp(`${parts.alias}$`);
|
|
@@ -139,15 +141,11 @@ function convertToMediaStyles(bp, styles) {
|
|
|
139
141
|
});
|
|
140
142
|
return Object.fromEntries(updatedEntries);
|
|
141
143
|
}
|
|
142
|
-
var css = createCss(
|
|
144
|
+
var css = createCss({ include: [], theme: {} }, { escapeSpecialChars: true });
|
|
143
145
|
|
|
144
146
|
Object.defineProperty(exports, "createConfig", {
|
|
145
147
|
enumerable: true,
|
|
146
148
|
get: function () { return Tokenami.createConfig; }
|
|
147
149
|
});
|
|
148
|
-
Object.defineProperty(exports, "defaultConfig", {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
get: function () { return Tokenami.defaultConfig; }
|
|
151
|
-
});
|
|
152
150
|
exports.createCss = createCss;
|
|
153
151
|
exports.css = css;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TokenamiProperties, TokenamiFinalConfig } from '@tokenami/dev';
|
|
2
2
|
import * as Tokenami from '@tokenami/config';
|
|
3
|
-
export { Config, createConfig
|
|
3
|
+
export { Config, createConfig } from '@tokenami/config';
|
|
4
4
|
|
|
5
5
|
type TokenamiCSS = {
|
|
6
6
|
[_: symbol]: 'TokenamiCSS';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TokenamiProperties, TokenamiFinalConfig } from '@tokenami/dev';
|
|
2
2
|
import * as Tokenami from '@tokenami/config';
|
|
3
|
-
export { Config, createConfig
|
|
3
|
+
export { Config, createConfig } from '@tokenami/config';
|
|
4
4
|
|
|
5
5
|
type TokenamiCSS = {
|
|
6
6
|
[_: symbol]: 'TokenamiCSS';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Tokenami from '@tokenami/config';
|
|
2
|
-
export { createConfig
|
|
2
|
+
export { createConfig } from '@tokenami/config';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
5
|
var _TOKENAMI_CSS = Symbol.for("@tokenami/css");
|
|
@@ -33,31 +33,30 @@ function createCss(config, options) {
|
|
|
33
33
|
const cached = cache.get(cacheId);
|
|
34
34
|
if (cached)
|
|
35
35
|
return cached;
|
|
36
|
-
[baseStyles, ...overrides]
|
|
36
|
+
const allStyles = [baseStyles, ...overrides];
|
|
37
|
+
for (const originalStyles of allStyles) {
|
|
37
38
|
if (!originalStyles)
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
continue;
|
|
40
|
+
for (const [key, value] of Object.entries(originalStyles)) {
|
|
40
41
|
const tokenProperty2 = Tokenami.TokenProperty.safeParse(key);
|
|
41
42
|
if (!tokenProperty2.success) {
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
overriddenStyles[key] = value;
|
|
44
|
+
continue;
|
|
44
45
|
}
|
|
45
46
|
const parts = Tokenami.getTokenPropertySplit(tokenProperty2.output);
|
|
46
47
|
const cssProperties = Tokenami.getCSSPropertiesForAlias(parts.alias, config.aliases);
|
|
47
|
-
|
|
48
|
+
for (const cssProperty of cssProperties) {
|
|
48
49
|
const long = createLonghandProperty(tokenProperty2.output, cssProperty);
|
|
50
|
+
const isNumber = typeof value === "number" && value > 0;
|
|
49
51
|
const tokenPropertyLong = Tokenami.parseProperty(long, {
|
|
50
52
|
escapeSpecialChars: globalOptions == null ? void 0 : globalOptions.escapeSpecialChars
|
|
51
53
|
});
|
|
52
|
-
if (typeof value === "number" && value > 0) {
|
|
53
|
-
const gridVar = Tokenami.gridProperty();
|
|
54
|
-
value = `calc(var(${gridVar}) * ${value})`;
|
|
55
|
-
}
|
|
56
54
|
overrideLonghands(overriddenStyles, tokenPropertyLong);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
overriddenStyles[tokenPropertyLong] = value;
|
|
56
|
+
overriddenStyles[calcProperty(tokenPropertyLong)] = isNumber ? "/*on*/" : void 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
61
60
|
cache.set(cacheId, overriddenStyles);
|
|
62
61
|
return overriddenStyles;
|
|
63
62
|
};
|
|
@@ -99,11 +98,14 @@ function overrideLonghands(style, tokenProperty2) {
|
|
|
99
98
|
const longhands = Tokenami.mapShorthandToLonghands.get(parts.alias) || [];
|
|
100
99
|
longhands.forEach((longhand) => {
|
|
101
100
|
const tokenPropertyLong = createLonghandProperty(tokenProperty2, longhand);
|
|
102
|
-
if (style[tokenPropertyLong])
|
|
101
|
+
if (style[tokenPropertyLong]) {
|
|
103
102
|
delete style[tokenPropertyLong];
|
|
103
|
+
delete style[calcProperty(tokenPropertyLong)];
|
|
104
|
+
}
|
|
104
105
|
overrideLonghands(style, tokenPropertyLong);
|
|
105
106
|
});
|
|
106
107
|
}
|
|
108
|
+
var calcProperty = (property) => property + "__calc";
|
|
107
109
|
function createLonghandProperty(tokenProperty2, cssProperty) {
|
|
108
110
|
const parts = Tokenami.getTokenPropertySplit(tokenProperty2);
|
|
109
111
|
const aliasRegex = new RegExp(`${parts.alias}$`);
|
|
@@ -118,6 +120,6 @@ function convertToMediaStyles(bp, styles) {
|
|
|
118
120
|
});
|
|
119
121
|
return Object.fromEntries(updatedEntries);
|
|
120
122
|
}
|
|
121
|
-
var css = createCss(
|
|
123
|
+
var css = createCss({ include: [], theme: {} }, { escapeSpecialChars: true });
|
|
122
124
|
|
|
123
125
|
export { createCss, css };
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenami/css",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
-
"sideEffects": false,
|
|
10
9
|
"repository": "https://github.com/tokenami/tokenami",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
11
14
|
"exports": {
|
|
12
15
|
".": {
|
|
13
16
|
"import": {
|
|
@@ -32,10 +35,10 @@
|
|
|
32
35
|
"test:watch": "vitest"
|
|
33
36
|
},
|
|
34
37
|
"dependencies": {
|
|
35
|
-
"@tokenami/config": "0.0.
|
|
38
|
+
"@tokenami/config": "0.0.62"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
|
-
"@tokenami/dev": "0.0.
|
|
41
|
+
"@tokenami/dev": "0.0.62",
|
|
39
42
|
"tsup": "^7.0.0",
|
|
40
43
|
"typescript": "^5.1.3",
|
|
41
44
|
"vitest": "^0.34.6"
|
|
@@ -44,5 +47,5 @@
|
|
|
44
47
|
"@tokenami/dev": ">= 0",
|
|
45
48
|
"typescript": ">= 5"
|
|
46
49
|
},
|
|
47
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "37d807eab7137223f4667f293d20e0e8094b77d7"
|
|
48
51
|
}
|