dispersa 0.4.2 → 0.4.3

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.
@@ -57,14 +57,15 @@ type CssBuilderConfig = BuilderConfigBase & CssRendererOptions;
57
57
  * @example Basic CSS bundle with transforms
58
58
  * ```typescript
59
59
  * import { css } from 'dispersa'
60
- * import { nameKebabCase } from 'dispersa/transforms'
60
+ * import { colorToHex } from 'dispersa/transforms'
61
61
  *
62
+ * // nameKebabCase() is applied automatically before your transforms
62
63
  * const config = css({
63
64
  * name: 'css',
64
65
  * file: 'tokens.css',
65
66
  * preset: 'bundle',
66
67
  * selector: ':root',
67
- * transforms: [nameKebabCase()]
68
+ * transforms: [colorToHex()]
68
69
  * })
69
70
  * ```
70
71
  *
@@ -57,14 +57,15 @@ type CssBuilderConfig = BuilderConfigBase & CssRendererOptions;
57
57
  * @example Basic CSS bundle with transforms
58
58
  * ```typescript
59
59
  * import { css } from 'dispersa'
60
- * import { nameKebabCase } from 'dispersa/transforms'
60
+ * import { colorToHex } from 'dispersa/transforms'
61
61
  *
62
+ * // nameKebabCase() is applied automatically before your transforms
62
63
  * const config = css({
63
64
  * name: 'css',
64
65
  * file: 'tokens.css',
65
66
  * preset: 'bundle',
66
67
  * selector: ':root',
67
- * transforms: [nameKebabCase()]
68
+ * transforms: [colorToHex()]
68
69
  * })
69
70
  * ```
70
71
  *
package/dist/builders.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { kebabCase } from 'change-case';
1
2
  import { converter, formatHex8, formatHex } from 'culori';
2
3
  import prettier from 'prettier';
3
4
 
@@ -126,7 +127,7 @@ function indentStr(width, level) {
126
127
  function buildGeneratedFileHeader() {
127
128
  return [
128
129
  "// Generated by Dispersa - do not edit manually",
129
- "// https://github.com/timges/dispersa"
130
+ "// https://github.com/dispersa-core/dispersa"
130
131
  ].join("\n");
131
132
  }
132
133
  function toSafeIdentifier(name, keywords, capitalize) {
@@ -484,6 +485,17 @@ var init_json = __esm({
484
485
  init_utils();
485
486
  }
486
487
  });
488
+ function nameKebabCase() {
489
+ return {
490
+ transform: (token) => {
491
+ const name = kebabCase(token.path.join(" "));
492
+ return {
493
+ ...token,
494
+ name
495
+ };
496
+ }
497
+ };
498
+ }
487
499
  function isColorObject(value) {
488
500
  return typeof value === "object" && value !== null && "colorSpace" in value && "components" in value;
489
501
  }
@@ -3451,7 +3463,7 @@ function css(config) {
3451
3463
  file,
3452
3464
  renderer: cssRenderer(),
3453
3465
  options: { preset, ...rendererOptions },
3454
- transforms,
3466
+ transforms: [nameKebabCase(), ...transforms ?? []],
3455
3467
  filters,
3456
3468
  hooks
3457
3469
  };