@removify/tailwind-preset 0.2.0 → 0.2.1

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.
@@ -340,28 +340,62 @@ var boxShadow = {
340
340
  };
341
341
 
342
342
  // src/theme/index.ts
343
- function buildTheme(options = {}) {
343
+ function buildTheme(object, option = {}) {
344
+ const {
345
+ enabled = true,
346
+ prefix = ""
347
+ } = option;
348
+ if (!enabled) {
349
+ return null;
350
+ }
351
+ if (prefix) {
352
+ Object.entries(object).map(([k, v]) => [`${prefix}${k}`, v]);
353
+ }
354
+ return object;
355
+ }
356
+ function factory(options = {}) {
344
357
  const theme = {};
345
- if (options.colors !== false) {
346
- theme.colors = colors;
358
+ if (options.colors?.enabled !== false) {
359
+ const _colors = buildTheme(colors, options.colors);
360
+ if (_colors != null) {
361
+ theme.colors = _colors;
362
+ }
347
363
  }
348
- if (options.boxShadow !== false) {
349
- theme.boxShadow = boxShadow;
364
+ if (options.boxShadow?.enabled !== false) {
365
+ const _boxShadow = buildTheme(boxShadow, options.boxShadow);
366
+ if (_boxShadow != null) {
367
+ theme.boxShadow = _boxShadow;
368
+ }
350
369
  }
351
- if (options.fontSize !== false) {
352
- theme.fontSize = fontSize;
370
+ if (options.fontSize?.enabled !== false) {
371
+ const _fontSize = buildTheme(fontSize, options.fontSize);
372
+ if (_fontSize != null) {
373
+ theme.fontSize = _fontSize;
374
+ }
353
375
  }
354
- if (options.fontFamily !== false) {
355
- theme.fontFamily = customFontFamily;
376
+ if (options.fontFamily?.enabled !== false) {
377
+ const _fontFamily = buildTheme(customFontFamily, options.fontFamily);
378
+ if (_fontFamily != null) {
379
+ theme.fontFamily = _fontFamily;
380
+ }
356
381
  }
357
- if (options.animation !== false) {
358
- theme.animation = animation;
382
+ if (options.animation?.enabled !== false) {
383
+ const _animation = buildTheme(animation, options.animation);
384
+ if (_animation != null) {
385
+ theme.animation = _animation;
386
+ }
359
387
  }
360
- if (options.keyframes !== false) {
361
- theme.keyframes = keyframes;
388
+ if (options.keyframes?.enabled !== false) {
389
+ const _keyframes = buildTheme(keyframes, options.keyframes);
390
+ if (_keyframes != null) {
391
+ theme.keyframes = _keyframes;
392
+ }
362
393
  }
363
- if (options.screens !== false) {
364
- theme.screens = screens;
394
+ if (options.screens?.enabled !== false) {
395
+ const _screens = buildTheme(screens, options.screens);
396
+ if (_screens != null) {
397
+ theme.screens = _screens;
398
+ }
365
399
  }
366
400
  return theme;
367
401
  }
@@ -390,6 +424,7 @@ export {
390
424
  screens,
391
425
  boxShadow,
392
426
  buildTheme,
427
+ factory,
393
428
  defaultTheme,
394
429
  unocssTheme
395
430
  };
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  colors
3
- } from "../chunk-QZWKJNXG.js";
3
+ } from "../chunk-I5TUIFQV.js";
4
4
 
5
5
  // src/cli/index.ts
6
6
  import process from "process";
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ __export(src_exports, {
38
38
  colorsNames: () => colorsNames,
39
39
  default: () => src_default,
40
40
  defaultTheme: () => defaultTheme,
41
+ factory: () => factory,
41
42
  fontFamily: () => customFontFamily,
42
43
  fontSize: () => fontSize,
43
44
  keyframes: () => keyframes,
@@ -393,28 +394,62 @@ var boxShadow = {
393
394
  };
394
395
 
395
396
  // src/theme/index.ts
396
- function buildTheme(options = {}) {
397
+ function buildTheme(object, option = {}) {
398
+ const {
399
+ enabled = true,
400
+ prefix = ""
401
+ } = option;
402
+ if (!enabled) {
403
+ return null;
404
+ }
405
+ if (prefix) {
406
+ Object.entries(object).map(([k, v]) => [`${prefix}${k}`, v]);
407
+ }
408
+ return object;
409
+ }
410
+ function factory(options = {}) {
397
411
  const theme = {};
398
- if (options.colors !== false) {
399
- theme.colors = colors;
412
+ if (options.colors?.enabled !== false) {
413
+ const _colors = buildTheme(colors, options.colors);
414
+ if (_colors != null) {
415
+ theme.colors = _colors;
416
+ }
400
417
  }
401
- if (options.boxShadow !== false) {
402
- theme.boxShadow = boxShadow;
418
+ if (options.boxShadow?.enabled !== false) {
419
+ const _boxShadow = buildTheme(boxShadow, options.boxShadow);
420
+ if (_boxShadow != null) {
421
+ theme.boxShadow = _boxShadow;
422
+ }
403
423
  }
404
- if (options.fontSize !== false) {
405
- theme.fontSize = fontSize;
424
+ if (options.fontSize?.enabled !== false) {
425
+ const _fontSize = buildTheme(fontSize, options.fontSize);
426
+ if (_fontSize != null) {
427
+ theme.fontSize = _fontSize;
428
+ }
406
429
  }
407
- if (options.fontFamily !== false) {
408
- theme.fontFamily = customFontFamily;
430
+ if (options.fontFamily?.enabled !== false) {
431
+ const _fontFamily = buildTheme(customFontFamily, options.fontFamily);
432
+ if (_fontFamily != null) {
433
+ theme.fontFamily = _fontFamily;
434
+ }
409
435
  }
410
- if (options.animation !== false) {
411
- theme.animation = animation2;
436
+ if (options.animation?.enabled !== false) {
437
+ const _animation = buildTheme(animation2, options.animation);
438
+ if (_animation != null) {
439
+ theme.animation = _animation;
440
+ }
412
441
  }
413
- if (options.keyframes !== false) {
414
- theme.keyframes = keyframes;
442
+ if (options.keyframes?.enabled !== false) {
443
+ const _keyframes = buildTheme(keyframes, options.keyframes);
444
+ if (_keyframes != null) {
445
+ theme.keyframes = _keyframes;
446
+ }
415
447
  }
416
- if (options.screens !== false) {
417
- theme.screens = screens;
448
+ if (options.screens?.enabled !== false) {
449
+ const _screens = buildTheme(screens, options.screens);
450
+ if (_screens != null) {
451
+ theme.screens = _screens;
452
+ }
418
453
  }
419
454
  return theme;
420
455
  }
@@ -453,13 +488,13 @@ var colorsNames = [
453
488
  function buildPreset(extend = true, buildOptions = {}) {
454
489
  if (extend === false) {
455
490
  return {
456
- theme: buildTheme(buildOptions),
491
+ theme: factory(buildOptions),
457
492
  plugins
458
493
  };
459
494
  }
460
495
  return {
461
496
  theme: {
462
- extend: buildTheme(buildOptions)
497
+ extend: factory(buildOptions)
463
498
  },
464
499
  plugins
465
500
  };
@@ -474,6 +509,7 @@ var src_default = buildPreset();
474
509
  colors,
475
510
  colorsNames,
476
511
  defaultTheme,
512
+ factory,
477
513
  fontFamily,
478
514
  fontSize,
479
515
  keyframes,
package/dist/index.d.cts CHANGED
@@ -24,15 +24,15 @@ type Colors = DefaultColors & MainColors & Record<ColorsNames, {
24
24
  }>;
25
25
  type ColorString = `${ColorsNames}-${ColorsVariations}` | keyof DefaultColors | keyof MainColors;
26
26
 
27
- interface BuildThemeOptions {
28
- colors?: boolean;
29
- boxShadow?: boolean;
30
- fontSize?: boolean;
31
- fontFamily?: boolean;
32
- animation?: boolean;
33
- keyframes?: boolean;
34
- screens?: boolean;
27
+ declare const configuredThemes: readonly ["colors", "boxShadow", "fontSize", "fontFamily", "animation", "keyframes", "screens"];
28
+ type ConfiguredThemes = typeof configuredThemes[number];
29
+ interface ThemeOptions {
30
+ enabled?: boolean;
31
+ prefix?: string;
35
32
  }
33
+ type BuildThemeOptions = {
34
+ [k in ConfiguredThemes]?: ThemeOptions;
35
+ };
36
36
 
37
37
  /**
38
38
  * Converts the given string from camel-case to kebab-case.
@@ -442,7 +442,10 @@ declare const boxShadow: {
442
442
  'elevation-5': "0 12px 24px 0 rgba(0, 0, 0, 0.10)";
443
443
  };
444
444
 
445
- declare function buildTheme(options?: BuildThemeOptions): Config['theme'];
445
+ declare function buildTheme<T extends object>(object: T, option?: ThemeOptions): null | T | {
446
+ [K in keyof T as `${string}${string & K}`]: T[K];
447
+ };
448
+ declare function factory(options?: BuildThemeOptions): Config['theme'];
446
449
  declare const defaultTheme: Config['theme'];
447
450
  declare const unocssTheme: {
448
451
  colors: {
@@ -639,4 +642,4 @@ declare const unocssTheme: {
639
642
  declare function buildPreset(extend?: boolean, buildOptions?: BuildThemeOptions): Partial<Config>;
640
643
  declare const _default: Partial<tailwindcss_types_config.Config>;
641
644
 
642
- export { type BuildThemeOptions, type ColorString, type Colors, type ColorsNames, type FontSizes, type Screens, type ScreensNumber, type Shadows, type UnocssFontSizes, animation, boxShadow, buildPreset, buildTheme, colors, colorsNames, _default as default, defaultTheme, customFontFamily as fontFamily, fontSize, isDetailFont, keyframes, screenSizes, screens, screensNumber, unocssTheme };
645
+ export { type BuildThemeOptions, type ColorString, type Colors, type ColorsNames, type ConfiguredThemes, type FontSizes, type Screens, type ScreensNumber, type Shadows, type ThemeOptions, type UnocssFontSizes, animation, boxShadow, buildPreset, buildTheme, colors, colorsNames, configuredThemes, _default as default, defaultTheme, factory, customFontFamily as fontFamily, fontSize, isDetailFont, keyframes, screenSizes, screens, screensNumber, unocssTheme };
package/dist/index.d.ts CHANGED
@@ -24,15 +24,15 @@ type Colors = DefaultColors & MainColors & Record<ColorsNames, {
24
24
  }>;
25
25
  type ColorString = `${ColorsNames}-${ColorsVariations}` | keyof DefaultColors | keyof MainColors;
26
26
 
27
- interface BuildThemeOptions {
28
- colors?: boolean;
29
- boxShadow?: boolean;
30
- fontSize?: boolean;
31
- fontFamily?: boolean;
32
- animation?: boolean;
33
- keyframes?: boolean;
34
- screens?: boolean;
27
+ declare const configuredThemes: readonly ["colors", "boxShadow", "fontSize", "fontFamily", "animation", "keyframes", "screens"];
28
+ type ConfiguredThemes = typeof configuredThemes[number];
29
+ interface ThemeOptions {
30
+ enabled?: boolean;
31
+ prefix?: string;
35
32
  }
33
+ type BuildThemeOptions = {
34
+ [k in ConfiguredThemes]?: ThemeOptions;
35
+ };
36
36
 
37
37
  /**
38
38
  * Converts the given string from camel-case to kebab-case.
@@ -442,7 +442,10 @@ declare const boxShadow: {
442
442
  'elevation-5': "0 12px 24px 0 rgba(0, 0, 0, 0.10)";
443
443
  };
444
444
 
445
- declare function buildTheme(options?: BuildThemeOptions): Config['theme'];
445
+ declare function buildTheme<T extends object>(object: T, option?: ThemeOptions): null | T | {
446
+ [K in keyof T as `${string}${string & K}`]: T[K];
447
+ };
448
+ declare function factory(options?: BuildThemeOptions): Config['theme'];
446
449
  declare const defaultTheme: Config['theme'];
447
450
  declare const unocssTheme: {
448
451
  colors: {
@@ -639,4 +642,4 @@ declare const unocssTheme: {
639
642
  declare function buildPreset(extend?: boolean, buildOptions?: BuildThemeOptions): Partial<Config>;
640
643
  declare const _default: Partial<tailwindcss_types_config.Config>;
641
644
 
642
- export { type BuildThemeOptions, type ColorString, type Colors, type ColorsNames, type FontSizes, type Screens, type ScreensNumber, type Shadows, type UnocssFontSizes, animation, boxShadow, buildPreset, buildTheme, colors, colorsNames, _default as default, defaultTheme, customFontFamily as fontFamily, fontSize, isDetailFont, keyframes, screenSizes, screens, screensNumber, unocssTheme };
645
+ export { type BuildThemeOptions, type ColorString, type Colors, type ColorsNames, type ConfiguredThemes, type FontSizes, type Screens, type ScreensNumber, type Shadows, type ThemeOptions, type UnocssFontSizes, animation, boxShadow, buildPreset, buildTheme, colors, colorsNames, configuredThemes, _default as default, defaultTheme, factory, customFontFamily as fontFamily, fontSize, isDetailFont, keyframes, screenSizes, screens, screensNumber, unocssTheme };
package/dist/index.js CHANGED
@@ -5,12 +5,13 @@ import {
5
5
  colors,
6
6
  customFontFamily,
7
7
  defaultTheme,
8
+ factory,
8
9
  fontSize,
9
10
  keyframes,
10
11
  screens,
11
12
  screensNumber,
12
13
  unocssTheme
13
- } from "./chunk-QZWKJNXG.js";
14
+ } from "./chunk-I5TUIFQV.js";
14
15
 
15
16
  // src/plugins/index.ts
16
17
  import animation2 from "tailwindcss-animate";
@@ -36,13 +37,13 @@ var colorsNames = [
36
37
  function buildPreset(extend = true, buildOptions = {}) {
37
38
  if (extend === false) {
38
39
  return {
39
- theme: buildTheme(buildOptions),
40
+ theme: factory(buildOptions),
40
41
  plugins
41
42
  };
42
43
  }
43
44
  return {
44
45
  theme: {
45
- extend: buildTheme(buildOptions)
46
+ extend: factory(buildOptions)
46
47
  },
47
48
  plugins
48
49
  };
@@ -57,6 +58,7 @@ export {
57
58
  colorsNames,
58
59
  src_default as default,
59
60
  defaultTheme,
61
+ factory,
60
62
  customFontFamily as fontFamily,
61
63
  fontSize,
62
64
  keyframes,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@removify/tailwind-preset",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "description": "Tailwind CSS preset for Removify",
6
6
  "keywords": [
7
7
  "tailwind"
@@ -47,7 +47,7 @@
47
47
  "tsx": "^4.19.1",
48
48
  "typescript": "^5.6.2",
49
49
  "vitest": "^2.1.1",
50
- "@removify/tailwind-preset": "0.2.0"
50
+ "@removify/tailwind-preset": "0.2.1"
51
51
  },
52
52
  "lint-staged": {
53
53
  "**/*.{js,ts,vue,html}": [