@tokenami/config 0.0.47 → 0.0.49
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 +12 -11
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +12 -11
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -215,7 +215,8 @@ var gridValueRegex = /^\d+/;
|
|
|
215
215
|
var GridValue = {
|
|
216
216
|
safeParse: (input) => validate(gridValueRegex, input)
|
|
217
217
|
};
|
|
218
|
-
var
|
|
218
|
+
var charClass = `A-Za-z0-9!#$%&()*+,./:;<=>?@[\\]^_{|}~`;
|
|
219
|
+
var tokenPropertyRegex = new RegExp(`(?<!var\\()--[${charClass}]([${charClass}-]+)?`);
|
|
219
220
|
var TokenProperty = {
|
|
220
221
|
safeParse: (input) => validate(tokenPropertyRegex, input)
|
|
221
222
|
};
|
|
@@ -241,13 +242,13 @@ var ArbitraryValue = {
|
|
|
241
242
|
safeParse: (input) => validate(arbitraryValueRegex, input)
|
|
242
243
|
};
|
|
243
244
|
function arbitraryValue(value) {
|
|
244
|
-
return `var(
|
|
245
|
+
return `var(---, ${value})`;
|
|
245
246
|
}
|
|
246
247
|
function validate(regex, input) {
|
|
247
248
|
try {
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
return { success: true, output:
|
|
249
|
+
const [match] = String(input).match(regex) || [];
|
|
250
|
+
if (match) {
|
|
251
|
+
return { success: true, output: match };
|
|
251
252
|
} else {
|
|
252
253
|
return { success: false };
|
|
253
254
|
}
|
|
@@ -255,17 +256,17 @@ function validate(regex, input) {
|
|
|
255
256
|
return { success: false };
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
function getTokenPropertyName(
|
|
259
|
-
|
|
259
|
+
function getTokenPropertyName(property) {
|
|
260
|
+
const propertyPrefix = tokenProperty("");
|
|
261
|
+
return property.replace(propertyPrefix, "");
|
|
260
262
|
}
|
|
261
|
-
function getTokenPropertySplit(
|
|
262
|
-
const name = getTokenPropertyName(
|
|
263
|
+
function getTokenPropertySplit(property) {
|
|
264
|
+
const name = getTokenPropertyName(property);
|
|
263
265
|
const [alias, ...variants] = name.split("_").reverse();
|
|
264
266
|
return { alias, variants: variants.reverse() };
|
|
265
267
|
}
|
|
266
268
|
function getTokenPropertyParts(tokenProperty2, config) {
|
|
267
269
|
var _a, _b, _c;
|
|
268
|
-
const name = getTokenPropertyName(tokenProperty2);
|
|
269
270
|
const { alias, variants } = getTokenPropertySplit(tokenProperty2);
|
|
270
271
|
const [firstVariant, secondVariant] = variants;
|
|
271
272
|
const firstSelector = ((_a = config.selectors) == null ? void 0 : _a[firstVariant]) && firstVariant;
|
|
@@ -275,7 +276,7 @@ function getTokenPropertyParts(tokenProperty2, config) {
|
|
|
275
276
|
const validVariant = [responsive, selector].filter(Boolean).join("_");
|
|
276
277
|
if (firstVariant && variantProperty(validVariant, alias) !== tokenProperty2)
|
|
277
278
|
return null;
|
|
278
|
-
return {
|
|
279
|
+
return { alias, responsive, selector, variant: validVariant };
|
|
279
280
|
}
|
|
280
281
|
function getTokenValueParts(tokenValue2) {
|
|
281
282
|
const [, property, themeKey, token] = tokenValue2.split(tokenValueRegex);
|
package/dist/index.d.cts
CHANGED
|
@@ -240,13 +240,12 @@ type Validated<T> = {
|
|
|
240
240
|
} | {
|
|
241
241
|
success: false;
|
|
242
242
|
};
|
|
243
|
-
declare function getTokenPropertyName(
|
|
244
|
-
declare function getTokenPropertySplit(
|
|
243
|
+
declare function getTokenPropertyName(property: TokenProperty): string;
|
|
244
|
+
declare function getTokenPropertySplit(property: TokenProperty): {
|
|
245
245
|
alias: string;
|
|
246
246
|
variants: string[];
|
|
247
247
|
};
|
|
248
248
|
type PropertyParts = {
|
|
249
|
-
name: string;
|
|
250
249
|
alias: string;
|
|
251
250
|
responsive?: string;
|
|
252
251
|
selector?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -240,13 +240,12 @@ type Validated<T> = {
|
|
|
240
240
|
} | {
|
|
241
241
|
success: false;
|
|
242
242
|
};
|
|
243
|
-
declare function getTokenPropertyName(
|
|
244
|
-
declare function getTokenPropertySplit(
|
|
243
|
+
declare function getTokenPropertyName(property: TokenProperty): string;
|
|
244
|
+
declare function getTokenPropertySplit(property: TokenProperty): {
|
|
245
245
|
alias: string;
|
|
246
246
|
variants: string[];
|
|
247
247
|
};
|
|
248
248
|
type PropertyParts = {
|
|
249
|
-
name: string;
|
|
250
249
|
alias: string;
|
|
251
250
|
responsive?: string;
|
|
252
251
|
selector?: string;
|
package/dist/index.js
CHANGED
|
@@ -171,7 +171,8 @@ var gridValueRegex = /^\d+/;
|
|
|
171
171
|
var GridValue = {
|
|
172
172
|
safeParse: (input) => validate(gridValueRegex, input)
|
|
173
173
|
};
|
|
174
|
-
var
|
|
174
|
+
var charClass = `A-Za-z0-9!#$%&()*+,./:;<=>?@[\\]^_{|}~`;
|
|
175
|
+
var tokenPropertyRegex = new RegExp(`(?<!var\\()--[${charClass}]([${charClass}-]+)?`);
|
|
175
176
|
var TokenProperty = {
|
|
176
177
|
safeParse: (input) => validate(tokenPropertyRegex, input)
|
|
177
178
|
};
|
|
@@ -197,13 +198,13 @@ var ArbitraryValue = {
|
|
|
197
198
|
safeParse: (input) => validate(arbitraryValueRegex, input)
|
|
198
199
|
};
|
|
199
200
|
function arbitraryValue(value) {
|
|
200
|
-
return `var(
|
|
201
|
+
return `var(---, ${value})`;
|
|
201
202
|
}
|
|
202
203
|
function validate(regex, input) {
|
|
203
204
|
try {
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
return { success: true, output:
|
|
205
|
+
const [match] = String(input).match(regex) || [];
|
|
206
|
+
if (match) {
|
|
207
|
+
return { success: true, output: match };
|
|
207
208
|
} else {
|
|
208
209
|
return { success: false };
|
|
209
210
|
}
|
|
@@ -211,17 +212,17 @@ function validate(regex, input) {
|
|
|
211
212
|
return { success: false };
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
|
-
function getTokenPropertyName(
|
|
215
|
-
|
|
215
|
+
function getTokenPropertyName(property) {
|
|
216
|
+
const propertyPrefix = tokenProperty("");
|
|
217
|
+
return property.replace(propertyPrefix, "");
|
|
216
218
|
}
|
|
217
|
-
function getTokenPropertySplit(
|
|
218
|
-
const name = getTokenPropertyName(
|
|
219
|
+
function getTokenPropertySplit(property) {
|
|
220
|
+
const name = getTokenPropertyName(property);
|
|
219
221
|
const [alias, ...variants] = name.split("_").reverse();
|
|
220
222
|
return { alias, variants: variants.reverse() };
|
|
221
223
|
}
|
|
222
224
|
function getTokenPropertyParts(tokenProperty2, config) {
|
|
223
225
|
var _a, _b, _c;
|
|
224
|
-
const name = getTokenPropertyName(tokenProperty2);
|
|
225
226
|
const { alias, variants } = getTokenPropertySplit(tokenProperty2);
|
|
226
227
|
const [firstVariant, secondVariant] = variants;
|
|
227
228
|
const firstSelector = ((_a = config.selectors) == null ? void 0 : _a[firstVariant]) && firstVariant;
|
|
@@ -231,7 +232,7 @@ function getTokenPropertyParts(tokenProperty2, config) {
|
|
|
231
232
|
const validVariant = [responsive, selector].filter(Boolean).join("_");
|
|
232
233
|
if (firstVariant && variantProperty(validVariant, alias) !== tokenProperty2)
|
|
233
234
|
return null;
|
|
234
|
-
return {
|
|
235
|
+
return { alias, responsive, selector, variant: validVariant };
|
|
235
236
|
}
|
|
236
237
|
function getTokenValueParts(tokenValue2) {
|
|
237
238
|
const [, property, themeKey, token] = tokenValue2.split(tokenValueRegex);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenami/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"tsup": "^7.0.0",
|
|
34
34
|
"typescript": "^5.1.3"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "943a0df4a2e05a0493f06df960ab0aee8b190a89"
|
|
37
37
|
}
|