@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 CHANGED
@@ -215,7 +215,8 @@ var gridValueRegex = /^\d+/;
215
215
  var GridValue = {
216
216
  safeParse: (input) => validate(gridValueRegex, input)
217
217
  };
218
- var tokenPropertyRegex = /(?<!var\()--(\w([\w-]+)?)/;
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(---,${value})`;
245
+ return `var(---, ${value})`;
245
246
  }
246
247
  function validate(regex, input) {
247
248
  try {
248
- const inputString = String(input);
249
- if (regex.test(inputString)) {
250
- return { success: true, output: inputString };
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(tokenProperty2) {
259
- return tokenProperty2.replace(tokenPropertyRegex, "$1");
259
+ function getTokenPropertyName(property) {
260
+ const propertyPrefix = tokenProperty("");
261
+ return property.replace(propertyPrefix, "");
260
262
  }
261
- function getTokenPropertySplit(tokenProperty2) {
262
- const name = getTokenPropertyName(tokenProperty2);
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 { name, alias, responsive, selector, variant: validVariant };
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(tokenProperty: TokenProperty): string;
244
- declare function getTokenPropertySplit(tokenProperty: TokenProperty): {
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(tokenProperty: TokenProperty): string;
244
- declare function getTokenPropertySplit(tokenProperty: TokenProperty): {
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 tokenPropertyRegex = /(?<!var\()--(\w([\w-]+)?)/;
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(---,${value})`;
201
+ return `var(---, ${value})`;
201
202
  }
202
203
  function validate(regex, input) {
203
204
  try {
204
- const inputString = String(input);
205
- if (regex.test(inputString)) {
206
- return { success: true, output: inputString };
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(tokenProperty2) {
215
- return tokenProperty2.replace(tokenPropertyRegex, "$1");
215
+ function getTokenPropertyName(property) {
216
+ const propertyPrefix = tokenProperty("");
217
+ return property.replace(propertyPrefix, "");
216
218
  }
217
- function getTokenPropertySplit(tokenProperty2) {
218
- const name = getTokenPropertyName(tokenProperty2);
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 { name, alias, responsive, selector, variant: validVariant };
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.47",
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": "efcc98735098167cf277b2b6638779a0b7018e6b"
36
+ "gitHead": "943a0df4a2e05a0493f06df960ab0aee8b190a89"
37
37
  }