@tokenami/css 0.0.20 → 0.0.22
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 +41 -212
- package/dist/index.d.cts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +41 -212
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -40,201 +40,40 @@ var import_config = require("@tokenami/config");
|
|
|
40
40
|
|
|
41
41
|
// src/css.ts
|
|
42
42
|
var Tokenami = __toESM(require("@tokenami/config"), 1);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"border-left": ["border-left-width", "border-left-style", "border-left-color"],
|
|
71
|
-
"border-color": [
|
|
72
|
-
"border-top-color",
|
|
73
|
-
"border-right-color",
|
|
74
|
-
"border-bottom-color",
|
|
75
|
-
"border-left-color"
|
|
76
|
-
],
|
|
77
|
-
"border-style": [
|
|
78
|
-
"border-top-style",
|
|
79
|
-
"border-right-style",
|
|
80
|
-
"border-bottom-style",
|
|
81
|
-
"border-left-style"
|
|
82
|
-
],
|
|
83
|
-
"border-width": [
|
|
84
|
-
"border-top-width",
|
|
85
|
-
"border-right-width",
|
|
86
|
-
"border-bottom-width",
|
|
87
|
-
"border-left-width"
|
|
88
|
-
],
|
|
89
|
-
"border-image": [
|
|
90
|
-
"border-image-source",
|
|
91
|
-
"border-image-slice",
|
|
92
|
-
"border-image-width",
|
|
93
|
-
"border-image-outset",
|
|
94
|
-
"border-image-repeat"
|
|
95
|
-
],
|
|
96
|
-
"border-radius": [
|
|
97
|
-
"border-top-left-radius",
|
|
98
|
-
"border-top-right-radius",
|
|
99
|
-
"border-bottom-right-radius",
|
|
100
|
-
"border-bottom-left-radius"
|
|
101
|
-
],
|
|
102
|
-
"border-block": ["border-block-width", "border-block-style", "border-block-color"],
|
|
103
|
-
"border-block-width": ["border-block-start-width", "border-block-end-width"],
|
|
104
|
-
"border-block-style": ["border-block-start-style", "border-block-end-style"],
|
|
105
|
-
"border-block-color": ["border-block-start-color", "border-block-end-color"],
|
|
106
|
-
"border-block-start": [
|
|
107
|
-
"border-block-start-width",
|
|
108
|
-
"border-block-start-style",
|
|
109
|
-
"border-block-start-color"
|
|
110
|
-
],
|
|
111
|
-
"border-block-end": [
|
|
112
|
-
"border-block-end-width",
|
|
113
|
-
"border-block-end-style",
|
|
114
|
-
"border-block-end-color"
|
|
115
|
-
],
|
|
116
|
-
"border-inline": ["border-inline-width", "border-inline-style", "border-inline-color"],
|
|
117
|
-
"border-inline-width": ["border-inline-start-width", "border-inline-end-width"],
|
|
118
|
-
"border-inline-style": ["border-inline-start-style", "border-inline-end-style"],
|
|
119
|
-
"border-inline-color": ["border-inline-start-color", "border-inline-end-color"],
|
|
120
|
-
"border-inline-start": [
|
|
121
|
-
"border-inline-start-width",
|
|
122
|
-
"border-inline-start-style",
|
|
123
|
-
"border-inline-start-color"
|
|
124
|
-
],
|
|
125
|
-
"border-inline-end": [
|
|
126
|
-
"border-inline-end-width",
|
|
127
|
-
"border-inline-end-style",
|
|
128
|
-
"border-inline-end-color"
|
|
129
|
-
],
|
|
130
|
-
"column-rule": ["column-rule-width", "column-rule-style", "column-rule-color"],
|
|
131
|
-
columns: ["column-width", "column-count"],
|
|
132
|
-
container: ["container-name", "container-type"],
|
|
133
|
-
"contain-intrinsic-size": ["contain-intrinsic-width", "contain-intrinsic-height"],
|
|
134
|
-
flex: ["flex-grow", "flex-shrink", "flex-basis"],
|
|
135
|
-
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
136
|
-
font: [
|
|
137
|
-
"font-style",
|
|
138
|
-
"font-variant",
|
|
139
|
-
"font-weight",
|
|
140
|
-
"font-stretch",
|
|
141
|
-
"font-size",
|
|
142
|
-
"line-height",
|
|
143
|
-
"font-family"
|
|
144
|
-
],
|
|
145
|
-
"font-variant": [
|
|
146
|
-
"font-variant-ligatures",
|
|
147
|
-
"font-variant-caps",
|
|
148
|
-
"font-variant-numeric",
|
|
149
|
-
"font-variant-east-asian"
|
|
150
|
-
],
|
|
151
|
-
gap: ["row-gap", "column-gap"],
|
|
152
|
-
grid: [
|
|
153
|
-
"grid-template-rows",
|
|
154
|
-
"grid-template-columns",
|
|
155
|
-
"grid-template-areas",
|
|
156
|
-
"grid-auto-rows",
|
|
157
|
-
"grid-auto-columns",
|
|
158
|
-
"grid-auto-flow"
|
|
159
|
-
],
|
|
160
|
-
"grid-area": ["grid-row-start", "grid-column-start", "grid-row-end", "grid-column-end"],
|
|
161
|
-
"grid-column": ["grid-column-start", "grid-column-end"],
|
|
162
|
-
"grid-row": ["grid-row-start", "grid-row-end"],
|
|
163
|
-
"grid-template": ["grid-template-rows", "grid-template-columns", "grid-template-areas"],
|
|
164
|
-
inset: ["top", "right", "bottom", "left"],
|
|
165
|
-
"list-style": ["list-style-type", "list-style-position", "list-style-image"],
|
|
166
|
-
"inset-block": ["inset-block-start", "inset-block-end"],
|
|
167
|
-
"inset-inline": ["inset-inline-start", "inset-inline-end"],
|
|
168
|
-
margin: ["margin-top", "margin-right", "margin-bottom", "margin-left"],
|
|
169
|
-
"margin-block": ["margin-block-start", "margin-block-end"],
|
|
170
|
-
"margin-inline": ["margin-inline-start", "margin-inline-end"],
|
|
171
|
-
mask: [
|
|
172
|
-
"mask-image",
|
|
173
|
-
"mask-mode",
|
|
174
|
-
"mask-position",
|
|
175
|
-
"mask-size",
|
|
176
|
-
"mask-repeat",
|
|
177
|
-
"mask-origin",
|
|
178
|
-
"mask-clip",
|
|
179
|
-
"mask-composite",
|
|
180
|
-
"mask-type"
|
|
181
|
-
],
|
|
182
|
-
"mask-border": [
|
|
183
|
-
"mask-border-mode",
|
|
184
|
-
"mask-border-outset",
|
|
185
|
-
"mask-border-repeat",
|
|
186
|
-
"mask-border-slice",
|
|
187
|
-
"mask-border-source",
|
|
188
|
-
"mask-border-width"
|
|
189
|
-
],
|
|
190
|
-
offset: ["offset-position", "offset-path", "offset-distance", "offset-anchor", "offset-rotate"],
|
|
191
|
-
outline: ["outline-color", "outline-style", "outline-width"],
|
|
192
|
-
overflow: ["overflow-x", "overflow-y"],
|
|
193
|
-
padding: ["padding-top", "padding-right", "padding-bottom", "padding-left"],
|
|
194
|
-
"padding-block": ["padding-block-start", "padding-block-end"],
|
|
195
|
-
"padding-inline": ["padding-inline-start", "padding-inline-end"],
|
|
196
|
-
"place-content": ["align-content", "justify-content"],
|
|
197
|
-
"place-items": ["align-items", "justify-items"],
|
|
198
|
-
"place-self": ["align-self", "justify-self"],
|
|
199
|
-
"scroll-margin": [
|
|
200
|
-
"scroll-margin-top",
|
|
201
|
-
"scroll-margin-right",
|
|
202
|
-
"scroll-margin-bottom",
|
|
203
|
-
"scroll-margin-left"
|
|
204
|
-
],
|
|
205
|
-
"scroll-margin-block": ["scroll-margin-block-start", "scroll-margin-block-end"],
|
|
206
|
-
"scroll-margin-inline": ["scroll-margin-inline-start", "scroll-margin-inline-end"],
|
|
207
|
-
"scroll-padding": [
|
|
208
|
-
"scroll-padding-top",
|
|
209
|
-
"scroll-padding-right",
|
|
210
|
-
"scroll-padding-bottom",
|
|
211
|
-
"scroll-padding-left"
|
|
212
|
-
],
|
|
213
|
-
"scroll-padding-block": ["scroll-padding-block-start", "scroll-padding-block-end"],
|
|
214
|
-
"scroll-padding-inline": ["scroll-padding-inline-start", "scroll-padding-inline-end"],
|
|
215
|
-
"scroll-timeline": ["scroll-timeline-name", "scroll-timeline-axis"],
|
|
216
|
-
"text-decoration": [
|
|
217
|
-
"text-decoration-line",
|
|
218
|
-
"text-decoration-style",
|
|
219
|
-
"text-decoration-color",
|
|
220
|
-
"text-decoration-thickness"
|
|
221
|
-
],
|
|
222
|
-
"text-emphasis": ["text-emphasis-style", "text-emphasis-color"],
|
|
223
|
-
transition: [
|
|
224
|
-
"transition-property",
|
|
225
|
-
"transition-duration",
|
|
226
|
-
"transition-timing-function",
|
|
227
|
-
"transition-delay"
|
|
228
|
-
]
|
|
43
|
+
var _LONGHANDS = Symbol();
|
|
44
|
+
var cache = {};
|
|
45
|
+
var css = (baseStyles, ...overrides) => {
|
|
46
|
+
const cacheId = JSON.stringify({ baseStyles, overrides });
|
|
47
|
+
const cached = cache[cacheId];
|
|
48
|
+
if (cached)
|
|
49
|
+
return cached;
|
|
50
|
+
let overriddenStyles = Object.assign({}, baseStyles);
|
|
51
|
+
overrides.forEach((overrideStyle) => {
|
|
52
|
+
if (!overrideStyle)
|
|
53
|
+
return;
|
|
54
|
+
for (let key in overrideStyle) {
|
|
55
|
+
const tokenProperty2 = key;
|
|
56
|
+
const property = Tokenami.getTokenPropertyName(tokenProperty2);
|
|
57
|
+
override(overriddenStyles, property);
|
|
58
|
+
}
|
|
59
|
+
Object.assign(overriddenStyles, overrideStyle);
|
|
60
|
+
});
|
|
61
|
+
Object.entries(overriddenStyles).forEach(([property, value]) => {
|
|
62
|
+
const tokenProperty2 = Tokenami.TokenProperty.safeParse(property);
|
|
63
|
+
if (tokenProperty2.success && typeof value === "number" && value > 0) {
|
|
64
|
+
const gridVar = Tokenami.gridProperty();
|
|
65
|
+
overriddenStyles[tokenProperty2.output] = `calc(var(${gridVar}) * ${value})`;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
cache[cacheId] = overriddenStyles;
|
|
69
|
+
return overriddenStyles;
|
|
229
70
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
function css(baseStyles, variantsConfig, options) {
|
|
234
|
-
const cache = {};
|
|
71
|
+
css[_LONGHANDS] = Tokenami.mapShorthandToLonghands;
|
|
72
|
+
css.compose = (baseStyles, variantsConfig, options) => {
|
|
73
|
+
const cache2 = {};
|
|
235
74
|
return function generate(variants, ...overrides) {
|
|
236
|
-
const cacheId = JSON.stringify({ variants, overrides });
|
|
237
|
-
const cached =
|
|
75
|
+
const cacheId = JSON.stringify({ baseStyles, variants, overrides });
|
|
76
|
+
const cached = cache2[cacheId];
|
|
238
77
|
if (cached)
|
|
239
78
|
return cached;
|
|
240
79
|
const variantStyles = variants ? Object.entries(variants).flatMap(([key, variant]) => {
|
|
@@ -242,35 +81,25 @@ function css(baseStyles, variantsConfig, options) {
|
|
|
242
81
|
if (!variant)
|
|
243
82
|
return [];
|
|
244
83
|
const [type, bp] = key.split("_").reverse();
|
|
245
|
-
const
|
|
84
|
+
const styles2 = (_a = variantsConfig == null ? void 0 : variantsConfig[type]) == null ? void 0 : _a[variant];
|
|
246
85
|
const responsive = options == null ? void 0 : options.responsive;
|
|
247
|
-
const updated = responsive && bp &&
|
|
86
|
+
const updated = responsive && bp && styles2 ? convertToMediaStyles(bp, styles2) : styles2;
|
|
248
87
|
return updated ? [updated] : [];
|
|
249
88
|
}) : [];
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (overrideStyle) {
|
|
254
|
-
for (let tokenProperty2 in overrideStyle) {
|
|
255
|
-
const property = Tokenami.getTokenPropertyName(tokenProperty2);
|
|
256
|
-
override(css2, property);
|
|
257
|
-
}
|
|
258
|
-
Object.assign(css2, overrideStyle);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
cache[cacheId] = css2;
|
|
262
|
-
return css2;
|
|
89
|
+
const styles = css(baseStyles, ...variantStyles, ...overrides);
|
|
90
|
+
cache2[cacheId] = styles;
|
|
91
|
+
return styles;
|
|
263
92
|
};
|
|
264
|
-
}
|
|
265
|
-
css[
|
|
93
|
+
};
|
|
94
|
+
css[_LONGHANDS] = Tokenami.mapShorthandToLonghands;
|
|
266
95
|
function createCss(config) {
|
|
267
96
|
if (!config.aliases)
|
|
268
97
|
return css;
|
|
269
|
-
css[
|
|
98
|
+
css[_LONGHANDS] = Object.assign({}, css[_LONGHANDS], config.aliases);
|
|
270
99
|
return css;
|
|
271
100
|
}
|
|
272
101
|
function override(style, property) {
|
|
273
|
-
const longhands = css[
|
|
102
|
+
const longhands = css[_LONGHANDS][property];
|
|
274
103
|
if (!longhands)
|
|
275
104
|
return;
|
|
276
105
|
for (let longhand of longhands) {
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import * as Tokenami from '@tokenami/config';
|
|
|
2
2
|
export { createConfig, defaultConfig } from '@tokenami/config';
|
|
3
3
|
import { TokenamiProperties, TokenamiFinalConfig } from '@tokenami/dev';
|
|
4
4
|
|
|
5
|
+
declare const _LONGHANDS: unique symbol;
|
|
5
6
|
type VariantsConfig = Record<string, Record<string, TokenamiProperties>>;
|
|
6
7
|
type VariantValue<T> = T extends 'true' | 'false' ? boolean : T;
|
|
7
8
|
type ReponsiveKey = Extract<keyof TokenamiFinalConfig['responsive'], string>;
|
|
@@ -15,12 +16,16 @@ type ResponsiveVariants<C> = {
|
|
|
15
16
|
[M in ResponsiveValue<V>]?: VariantValue<keyof C[V]>;
|
|
16
17
|
};
|
|
17
18
|
}[keyof C];
|
|
18
|
-
type SelectedVariants<V, R> = undefined extends V ? null : Variants$1<V> & (R extends true ? ResponsiveVariants<V> : {});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
type SelectedVariants<V, R> = null | (undefined extends V ? null : Variants$1<V> & (R extends true ? ResponsiveVariants<V> : {}));
|
|
20
|
+
interface CSS {
|
|
21
|
+
[_LONGHANDS]?: typeof Tokenami.mapShorthandToLonghands;
|
|
22
|
+
(baseStyles: TokenamiProperties, ...overrides: Override[]): {};
|
|
23
|
+
compose: <V extends VariantsConfig | undefined, R>(baseStyles: TokenamiProperties, variantsConfig?: V & VariantsConfig, options?: undefined extends V ? never : {
|
|
24
|
+
responsive: R & boolean;
|
|
25
|
+
}) => (variants?: SelectedVariants<V, R>, ...overrides: Override[]) => {};
|
|
26
|
+
}
|
|
27
|
+
declare const css: CSS;
|
|
28
|
+
declare function createCss(config: Tokenami.Config): CSS;
|
|
24
29
|
|
|
25
30
|
type Variants<T extends () => {}> = Parameters<T>[0] extends undefined | null ? {} : NonNullable<Parameters<T>[0]>;
|
|
26
31
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as Tokenami from '@tokenami/config';
|
|
|
2
2
|
export { createConfig, defaultConfig } from '@tokenami/config';
|
|
3
3
|
import { TokenamiProperties, TokenamiFinalConfig } from '@tokenami/dev';
|
|
4
4
|
|
|
5
|
+
declare const _LONGHANDS: unique symbol;
|
|
5
6
|
type VariantsConfig = Record<string, Record<string, TokenamiProperties>>;
|
|
6
7
|
type VariantValue<T> = T extends 'true' | 'false' ? boolean : T;
|
|
7
8
|
type ReponsiveKey = Extract<keyof TokenamiFinalConfig['responsive'], string>;
|
|
@@ -15,12 +16,16 @@ type ResponsiveVariants<C> = {
|
|
|
15
16
|
[M in ResponsiveValue<V>]?: VariantValue<keyof C[V]>;
|
|
16
17
|
};
|
|
17
18
|
}[keyof C];
|
|
18
|
-
type SelectedVariants<V, R> = undefined extends V ? null : Variants$1<V> & (R extends true ? ResponsiveVariants<V> : {});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
type SelectedVariants<V, R> = null | (undefined extends V ? null : Variants$1<V> & (R extends true ? ResponsiveVariants<V> : {}));
|
|
20
|
+
interface CSS {
|
|
21
|
+
[_LONGHANDS]?: typeof Tokenami.mapShorthandToLonghands;
|
|
22
|
+
(baseStyles: TokenamiProperties, ...overrides: Override[]): {};
|
|
23
|
+
compose: <V extends VariantsConfig | undefined, R>(baseStyles: TokenamiProperties, variantsConfig?: V & VariantsConfig, options?: undefined extends V ? never : {
|
|
24
|
+
responsive: R & boolean;
|
|
25
|
+
}) => (variants?: SelectedVariants<V, R>, ...overrides: Override[]) => {};
|
|
26
|
+
}
|
|
27
|
+
declare const css: CSS;
|
|
28
|
+
declare function createCss(config: Tokenami.Config): CSS;
|
|
24
29
|
|
|
25
30
|
type Variants<T extends () => {}> = Parameters<T>[0] extends undefined | null ? {} : NonNullable<Parameters<T>[0]>;
|
|
26
31
|
|
package/dist/index.js
CHANGED
|
@@ -3,201 +3,40 @@ import { createConfig, defaultConfig } from "@tokenami/config";
|
|
|
3
3
|
|
|
4
4
|
// src/css.ts
|
|
5
5
|
import * as Tokenami from "@tokenami/config";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"border-left": ["border-left-width", "border-left-style", "border-left-color"],
|
|
34
|
-
"border-color": [
|
|
35
|
-
"border-top-color",
|
|
36
|
-
"border-right-color",
|
|
37
|
-
"border-bottom-color",
|
|
38
|
-
"border-left-color"
|
|
39
|
-
],
|
|
40
|
-
"border-style": [
|
|
41
|
-
"border-top-style",
|
|
42
|
-
"border-right-style",
|
|
43
|
-
"border-bottom-style",
|
|
44
|
-
"border-left-style"
|
|
45
|
-
],
|
|
46
|
-
"border-width": [
|
|
47
|
-
"border-top-width",
|
|
48
|
-
"border-right-width",
|
|
49
|
-
"border-bottom-width",
|
|
50
|
-
"border-left-width"
|
|
51
|
-
],
|
|
52
|
-
"border-image": [
|
|
53
|
-
"border-image-source",
|
|
54
|
-
"border-image-slice",
|
|
55
|
-
"border-image-width",
|
|
56
|
-
"border-image-outset",
|
|
57
|
-
"border-image-repeat"
|
|
58
|
-
],
|
|
59
|
-
"border-radius": [
|
|
60
|
-
"border-top-left-radius",
|
|
61
|
-
"border-top-right-radius",
|
|
62
|
-
"border-bottom-right-radius",
|
|
63
|
-
"border-bottom-left-radius"
|
|
64
|
-
],
|
|
65
|
-
"border-block": ["border-block-width", "border-block-style", "border-block-color"],
|
|
66
|
-
"border-block-width": ["border-block-start-width", "border-block-end-width"],
|
|
67
|
-
"border-block-style": ["border-block-start-style", "border-block-end-style"],
|
|
68
|
-
"border-block-color": ["border-block-start-color", "border-block-end-color"],
|
|
69
|
-
"border-block-start": [
|
|
70
|
-
"border-block-start-width",
|
|
71
|
-
"border-block-start-style",
|
|
72
|
-
"border-block-start-color"
|
|
73
|
-
],
|
|
74
|
-
"border-block-end": [
|
|
75
|
-
"border-block-end-width",
|
|
76
|
-
"border-block-end-style",
|
|
77
|
-
"border-block-end-color"
|
|
78
|
-
],
|
|
79
|
-
"border-inline": ["border-inline-width", "border-inline-style", "border-inline-color"],
|
|
80
|
-
"border-inline-width": ["border-inline-start-width", "border-inline-end-width"],
|
|
81
|
-
"border-inline-style": ["border-inline-start-style", "border-inline-end-style"],
|
|
82
|
-
"border-inline-color": ["border-inline-start-color", "border-inline-end-color"],
|
|
83
|
-
"border-inline-start": [
|
|
84
|
-
"border-inline-start-width",
|
|
85
|
-
"border-inline-start-style",
|
|
86
|
-
"border-inline-start-color"
|
|
87
|
-
],
|
|
88
|
-
"border-inline-end": [
|
|
89
|
-
"border-inline-end-width",
|
|
90
|
-
"border-inline-end-style",
|
|
91
|
-
"border-inline-end-color"
|
|
92
|
-
],
|
|
93
|
-
"column-rule": ["column-rule-width", "column-rule-style", "column-rule-color"],
|
|
94
|
-
columns: ["column-width", "column-count"],
|
|
95
|
-
container: ["container-name", "container-type"],
|
|
96
|
-
"contain-intrinsic-size": ["contain-intrinsic-width", "contain-intrinsic-height"],
|
|
97
|
-
flex: ["flex-grow", "flex-shrink", "flex-basis"],
|
|
98
|
-
"flex-flow": ["flex-direction", "flex-wrap"],
|
|
99
|
-
font: [
|
|
100
|
-
"font-style",
|
|
101
|
-
"font-variant",
|
|
102
|
-
"font-weight",
|
|
103
|
-
"font-stretch",
|
|
104
|
-
"font-size",
|
|
105
|
-
"line-height",
|
|
106
|
-
"font-family"
|
|
107
|
-
],
|
|
108
|
-
"font-variant": [
|
|
109
|
-
"font-variant-ligatures",
|
|
110
|
-
"font-variant-caps",
|
|
111
|
-
"font-variant-numeric",
|
|
112
|
-
"font-variant-east-asian"
|
|
113
|
-
],
|
|
114
|
-
gap: ["row-gap", "column-gap"],
|
|
115
|
-
grid: [
|
|
116
|
-
"grid-template-rows",
|
|
117
|
-
"grid-template-columns",
|
|
118
|
-
"grid-template-areas",
|
|
119
|
-
"grid-auto-rows",
|
|
120
|
-
"grid-auto-columns",
|
|
121
|
-
"grid-auto-flow"
|
|
122
|
-
],
|
|
123
|
-
"grid-area": ["grid-row-start", "grid-column-start", "grid-row-end", "grid-column-end"],
|
|
124
|
-
"grid-column": ["grid-column-start", "grid-column-end"],
|
|
125
|
-
"grid-row": ["grid-row-start", "grid-row-end"],
|
|
126
|
-
"grid-template": ["grid-template-rows", "grid-template-columns", "grid-template-areas"],
|
|
127
|
-
inset: ["top", "right", "bottom", "left"],
|
|
128
|
-
"list-style": ["list-style-type", "list-style-position", "list-style-image"],
|
|
129
|
-
"inset-block": ["inset-block-start", "inset-block-end"],
|
|
130
|
-
"inset-inline": ["inset-inline-start", "inset-inline-end"],
|
|
131
|
-
margin: ["margin-top", "margin-right", "margin-bottom", "margin-left"],
|
|
132
|
-
"margin-block": ["margin-block-start", "margin-block-end"],
|
|
133
|
-
"margin-inline": ["margin-inline-start", "margin-inline-end"],
|
|
134
|
-
mask: [
|
|
135
|
-
"mask-image",
|
|
136
|
-
"mask-mode",
|
|
137
|
-
"mask-position",
|
|
138
|
-
"mask-size",
|
|
139
|
-
"mask-repeat",
|
|
140
|
-
"mask-origin",
|
|
141
|
-
"mask-clip",
|
|
142
|
-
"mask-composite",
|
|
143
|
-
"mask-type"
|
|
144
|
-
],
|
|
145
|
-
"mask-border": [
|
|
146
|
-
"mask-border-mode",
|
|
147
|
-
"mask-border-outset",
|
|
148
|
-
"mask-border-repeat",
|
|
149
|
-
"mask-border-slice",
|
|
150
|
-
"mask-border-source",
|
|
151
|
-
"mask-border-width"
|
|
152
|
-
],
|
|
153
|
-
offset: ["offset-position", "offset-path", "offset-distance", "offset-anchor", "offset-rotate"],
|
|
154
|
-
outline: ["outline-color", "outline-style", "outline-width"],
|
|
155
|
-
overflow: ["overflow-x", "overflow-y"],
|
|
156
|
-
padding: ["padding-top", "padding-right", "padding-bottom", "padding-left"],
|
|
157
|
-
"padding-block": ["padding-block-start", "padding-block-end"],
|
|
158
|
-
"padding-inline": ["padding-inline-start", "padding-inline-end"],
|
|
159
|
-
"place-content": ["align-content", "justify-content"],
|
|
160
|
-
"place-items": ["align-items", "justify-items"],
|
|
161
|
-
"place-self": ["align-self", "justify-self"],
|
|
162
|
-
"scroll-margin": [
|
|
163
|
-
"scroll-margin-top",
|
|
164
|
-
"scroll-margin-right",
|
|
165
|
-
"scroll-margin-bottom",
|
|
166
|
-
"scroll-margin-left"
|
|
167
|
-
],
|
|
168
|
-
"scroll-margin-block": ["scroll-margin-block-start", "scroll-margin-block-end"],
|
|
169
|
-
"scroll-margin-inline": ["scroll-margin-inline-start", "scroll-margin-inline-end"],
|
|
170
|
-
"scroll-padding": [
|
|
171
|
-
"scroll-padding-top",
|
|
172
|
-
"scroll-padding-right",
|
|
173
|
-
"scroll-padding-bottom",
|
|
174
|
-
"scroll-padding-left"
|
|
175
|
-
],
|
|
176
|
-
"scroll-padding-block": ["scroll-padding-block-start", "scroll-padding-block-end"],
|
|
177
|
-
"scroll-padding-inline": ["scroll-padding-inline-start", "scroll-padding-inline-end"],
|
|
178
|
-
"scroll-timeline": ["scroll-timeline-name", "scroll-timeline-axis"],
|
|
179
|
-
"text-decoration": [
|
|
180
|
-
"text-decoration-line",
|
|
181
|
-
"text-decoration-style",
|
|
182
|
-
"text-decoration-color",
|
|
183
|
-
"text-decoration-thickness"
|
|
184
|
-
],
|
|
185
|
-
"text-emphasis": ["text-emphasis-style", "text-emphasis-color"],
|
|
186
|
-
transition: [
|
|
187
|
-
"transition-property",
|
|
188
|
-
"transition-duration",
|
|
189
|
-
"transition-timing-function",
|
|
190
|
-
"transition-delay"
|
|
191
|
-
]
|
|
6
|
+
var _LONGHANDS = Symbol();
|
|
7
|
+
var cache = {};
|
|
8
|
+
var css = (baseStyles, ...overrides) => {
|
|
9
|
+
const cacheId = JSON.stringify({ baseStyles, overrides });
|
|
10
|
+
const cached = cache[cacheId];
|
|
11
|
+
if (cached)
|
|
12
|
+
return cached;
|
|
13
|
+
let overriddenStyles = Object.assign({}, baseStyles);
|
|
14
|
+
overrides.forEach((overrideStyle) => {
|
|
15
|
+
if (!overrideStyle)
|
|
16
|
+
return;
|
|
17
|
+
for (let key in overrideStyle) {
|
|
18
|
+
const tokenProperty2 = key;
|
|
19
|
+
const property = Tokenami.getTokenPropertyName(tokenProperty2);
|
|
20
|
+
override(overriddenStyles, property);
|
|
21
|
+
}
|
|
22
|
+
Object.assign(overriddenStyles, overrideStyle);
|
|
23
|
+
});
|
|
24
|
+
Object.entries(overriddenStyles).forEach(([property, value]) => {
|
|
25
|
+
const tokenProperty2 = Tokenami.TokenProperty.safeParse(property);
|
|
26
|
+
if (tokenProperty2.success && typeof value === "number" && value > 0) {
|
|
27
|
+
const gridVar = Tokenami.gridProperty();
|
|
28
|
+
overriddenStyles[tokenProperty2.output] = `calc(var(${gridVar}) * ${value})`;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
cache[cacheId] = overriddenStyles;
|
|
32
|
+
return overriddenStyles;
|
|
192
33
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
function css(baseStyles, variantsConfig, options) {
|
|
197
|
-
const cache = {};
|
|
34
|
+
css[_LONGHANDS] = Tokenami.mapShorthandToLonghands;
|
|
35
|
+
css.compose = (baseStyles, variantsConfig, options) => {
|
|
36
|
+
const cache2 = {};
|
|
198
37
|
return function generate(variants, ...overrides) {
|
|
199
|
-
const cacheId = JSON.stringify({ variants, overrides });
|
|
200
|
-
const cached =
|
|
38
|
+
const cacheId = JSON.stringify({ baseStyles, variants, overrides });
|
|
39
|
+
const cached = cache2[cacheId];
|
|
201
40
|
if (cached)
|
|
202
41
|
return cached;
|
|
203
42
|
const variantStyles = variants ? Object.entries(variants).flatMap(([key, variant]) => {
|
|
@@ -205,35 +44,25 @@ function css(baseStyles, variantsConfig, options) {
|
|
|
205
44
|
if (!variant)
|
|
206
45
|
return [];
|
|
207
46
|
const [type, bp] = key.split("_").reverse();
|
|
208
|
-
const
|
|
47
|
+
const styles2 = (_a = variantsConfig == null ? void 0 : variantsConfig[type]) == null ? void 0 : _a[variant];
|
|
209
48
|
const responsive = options == null ? void 0 : options.responsive;
|
|
210
|
-
const updated = responsive && bp &&
|
|
49
|
+
const updated = responsive && bp && styles2 ? convertToMediaStyles(bp, styles2) : styles2;
|
|
211
50
|
return updated ? [updated] : [];
|
|
212
51
|
}) : [];
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (overrideStyle) {
|
|
217
|
-
for (let tokenProperty2 in overrideStyle) {
|
|
218
|
-
const property = Tokenami.getTokenPropertyName(tokenProperty2);
|
|
219
|
-
override(css2, property);
|
|
220
|
-
}
|
|
221
|
-
Object.assign(css2, overrideStyle);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
cache[cacheId] = css2;
|
|
225
|
-
return css2;
|
|
52
|
+
const styles = css(baseStyles, ...variantStyles, ...overrides);
|
|
53
|
+
cache2[cacheId] = styles;
|
|
54
|
+
return styles;
|
|
226
55
|
};
|
|
227
|
-
}
|
|
228
|
-
css[
|
|
56
|
+
};
|
|
57
|
+
css[_LONGHANDS] = Tokenami.mapShorthandToLonghands;
|
|
229
58
|
function createCss(config) {
|
|
230
59
|
if (!config.aliases)
|
|
231
60
|
return css;
|
|
232
|
-
css[
|
|
61
|
+
css[_LONGHANDS] = Object.assign({}, css[_LONGHANDS], config.aliases);
|
|
233
62
|
return css;
|
|
234
63
|
}
|
|
235
64
|
function override(style, property) {
|
|
236
|
-
const longhands = css[
|
|
65
|
+
const longhands = css[_LONGHANDS][property];
|
|
237
66
|
if (!longhands)
|
|
238
67
|
return;
|
|
239
68
|
for (let longhand of longhands) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenami/css",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@tokenami/config": "0.0.
|
|
15
|
+
"@tokenami/config": "0.0.22"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"tsup": "^7.0.0",
|
|
19
19
|
"typescript": "^5.1.3",
|
|
20
20
|
"vitest": "^0.34.6",
|
|
21
|
-
"@tokenami/dev": "0.0.
|
|
21
|
+
"@tokenami/dev": "0.0.22"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"typescript": ">= 5",
|
|
25
|
-
"@tokenami/dev": "0.0.
|
|
25
|
+
"@tokenami/dev": "0.0.22"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsup",
|