@removify/tailwind-preset 0.1.10 → 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.
@@ -252,7 +252,7 @@ function fontConfigKeysKebabCase(fontConfig) {
252
252
  }
253
253
 
254
254
  // src/theme/fontSize.ts
255
- var fontSizes = {
255
+ var fontSize = {
256
256
  "2xs": ["0.6875rem", "1rem"],
257
257
  "xs": ["0.75rem", "1rem"],
258
258
  "sm": ["0.875rem", "1.25rem"],
@@ -305,7 +305,7 @@ var fontSizes = {
305
305
  letterSpacing: "-0.0125rem"
306
306
  }]
307
307
  };
308
- var unocssFontSizes = fontConfigKeysKebabCase(fontSizes);
308
+ var unocssFontSizes = fontConfigKeysKebabCase(fontSize);
309
309
 
310
310
  // src/theme/screen.ts
311
311
  var screensNumber = {
@@ -330,7 +330,7 @@ var screens = {
330
330
  };
331
331
 
332
332
  // src/theme/shadows.ts
333
- var shadows = {
333
+ var boxShadow = {
334
334
  "elevation-0": "0 0 0 0 rgba(0, 0, 0, 0.10)",
335
335
  "elevation-1": "0 1px 2px 0 rgba(0, 0, 0, 0.10)",
336
336
  "elevation-2": "0 4px 8px 0 rgba(0, 0, 0, 0.10)",
@@ -340,10 +340,69 @@ var shadows = {
340
340
  };
341
341
 
342
342
  // src/theme/index.ts
343
- var theme = {
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 = {}) {
357
+ const theme = {};
358
+ if (options.colors?.enabled !== false) {
359
+ const _colors = buildTheme(colors, options.colors);
360
+ if (_colors != null) {
361
+ theme.colors = _colors;
362
+ }
363
+ }
364
+ if (options.boxShadow?.enabled !== false) {
365
+ const _boxShadow = buildTheme(boxShadow, options.boxShadow);
366
+ if (_boxShadow != null) {
367
+ theme.boxShadow = _boxShadow;
368
+ }
369
+ }
370
+ if (options.fontSize?.enabled !== false) {
371
+ const _fontSize = buildTheme(fontSize, options.fontSize);
372
+ if (_fontSize != null) {
373
+ theme.fontSize = _fontSize;
374
+ }
375
+ }
376
+ if (options.fontFamily?.enabled !== false) {
377
+ const _fontFamily = buildTheme(customFontFamily, options.fontFamily);
378
+ if (_fontFamily != null) {
379
+ theme.fontFamily = _fontFamily;
380
+ }
381
+ }
382
+ if (options.animation?.enabled !== false) {
383
+ const _animation = buildTheme(animation, options.animation);
384
+ if (_animation != null) {
385
+ theme.animation = _animation;
386
+ }
387
+ }
388
+ if (options.keyframes?.enabled !== false) {
389
+ const _keyframes = buildTheme(keyframes, options.keyframes);
390
+ if (_keyframes != null) {
391
+ theme.keyframes = _keyframes;
392
+ }
393
+ }
394
+ if (options.screens?.enabled !== false) {
395
+ const _screens = buildTheme(screens, options.screens);
396
+ if (_screens != null) {
397
+ theme.screens = _screens;
398
+ }
399
+ }
400
+ return theme;
401
+ }
402
+ var defaultTheme = {
344
403
  colors,
345
- boxShadow: shadows,
346
- fontSize: fontSizes,
404
+ boxShadow,
405
+ fontSize,
347
406
  fontFamily: customFontFamily,
348
407
  animation,
349
408
  keyframes,
@@ -351,7 +410,7 @@ var theme = {
351
410
  };
352
411
  var unocssTheme = {
353
412
  colors,
354
- boxShadow: shadows,
413
+ boxShadow,
355
414
  fontSize: unocssFontSizes
356
415
  };
357
416
 
@@ -360,10 +419,12 @@ export {
360
419
  keyframes,
361
420
  colors,
362
421
  customFontFamily,
363
- fontSizes,
422
+ fontSize,
364
423
  screensNumber,
365
424
  screens,
366
- shadows,
367
- theme,
425
+ boxShadow,
426
+ buildTheme,
427
+ factory,
428
+ defaultTheme,
368
429
  unocssTheme
369
430
  };
@@ -281,7 +281,7 @@ function fontConfigKeysKebabCase(fontConfig) {
281
281
  }
282
282
 
283
283
  // src/theme/fontSize.ts
284
- var fontSizes = {
284
+ var fontSize = {
285
285
  "2xs": ["0.6875rem", "1rem"],
286
286
  "xs": ["0.75rem", "1rem"],
287
287
  "sm": ["0.875rem", "1.25rem"],
@@ -334,7 +334,7 @@ var fontSizes = {
334
334
  letterSpacing: "-0.0125rem"
335
335
  }]
336
336
  };
337
- var unocssFontSizes = fontConfigKeysKebabCase(fontSizes);
337
+ var unocssFontSizes = fontConfigKeysKebabCase(fontSize);
338
338
 
339
339
  // src/theme/screen.ts
340
340
  var screensNumber = {
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  colors
3
- } from "../chunk-J5XGEDSE.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
@@ -31,17 +31,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  animation: () => animation2,
34
+ boxShadow: () => boxShadow,
35
+ buildPreset: () => buildPreset,
36
+ buildTheme: () => buildTheme,
34
37
  colors: () => colors,
35
38
  colorsNames: () => colorsNames,
36
- config: () => config,
37
39
  default: () => src_default,
40
+ defaultTheme: () => defaultTheme,
41
+ factory: () => factory,
38
42
  fontFamily: () => customFontFamily,
39
- fontSizes: () => fontSizes,
43
+ fontSize: () => fontSize,
40
44
  keyframes: () => keyframes,
41
45
  screens: () => screens,
42
46
  screensNumber: () => screensNumber,
43
- shadows: () => shadows,
44
- theme: () => theme,
45
47
  unocssTheme: () => unocssTheme
46
48
  });
47
49
  module.exports = __toCommonJS(src_exports);
@@ -304,7 +306,7 @@ function fontConfigKeysKebabCase(fontConfig) {
304
306
  }
305
307
 
306
308
  // src/theme/fontSize.ts
307
- var fontSizes = {
309
+ var fontSize = {
308
310
  "2xs": ["0.6875rem", "1rem"],
309
311
  "xs": ["0.75rem", "1rem"],
310
312
  "sm": ["0.875rem", "1.25rem"],
@@ -357,7 +359,7 @@ var fontSizes = {
357
359
  letterSpacing: "-0.0125rem"
358
360
  }]
359
361
  };
360
- var unocssFontSizes = fontConfigKeysKebabCase(fontSizes);
362
+ var unocssFontSizes = fontConfigKeysKebabCase(fontSize);
361
363
 
362
364
  // src/theme/screen.ts
363
365
  var screensNumber = {
@@ -382,7 +384,7 @@ var screens = {
382
384
  };
383
385
 
384
386
  // src/theme/shadows.ts
385
- var shadows = {
387
+ var boxShadow = {
386
388
  "elevation-0": "0 0 0 0 rgba(0, 0, 0, 0.10)",
387
389
  "elevation-1": "0 1px 2px 0 rgba(0, 0, 0, 0.10)",
388
390
  "elevation-2": "0 4px 8px 0 rgba(0, 0, 0, 0.10)",
@@ -392,10 +394,69 @@ var shadows = {
392
394
  };
393
395
 
394
396
  // src/theme/index.ts
395
- var theme = {
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 = {}) {
411
+ const theme = {};
412
+ if (options.colors?.enabled !== false) {
413
+ const _colors = buildTheme(colors, options.colors);
414
+ if (_colors != null) {
415
+ theme.colors = _colors;
416
+ }
417
+ }
418
+ if (options.boxShadow?.enabled !== false) {
419
+ const _boxShadow = buildTheme(boxShadow, options.boxShadow);
420
+ if (_boxShadow != null) {
421
+ theme.boxShadow = _boxShadow;
422
+ }
423
+ }
424
+ if (options.fontSize?.enabled !== false) {
425
+ const _fontSize = buildTheme(fontSize, options.fontSize);
426
+ if (_fontSize != null) {
427
+ theme.fontSize = _fontSize;
428
+ }
429
+ }
430
+ if (options.fontFamily?.enabled !== false) {
431
+ const _fontFamily = buildTheme(customFontFamily, options.fontFamily);
432
+ if (_fontFamily != null) {
433
+ theme.fontFamily = _fontFamily;
434
+ }
435
+ }
436
+ if (options.animation?.enabled !== false) {
437
+ const _animation = buildTheme(animation2, options.animation);
438
+ if (_animation != null) {
439
+ theme.animation = _animation;
440
+ }
441
+ }
442
+ if (options.keyframes?.enabled !== false) {
443
+ const _keyframes = buildTheme(keyframes, options.keyframes);
444
+ if (_keyframes != null) {
445
+ theme.keyframes = _keyframes;
446
+ }
447
+ }
448
+ if (options.screens?.enabled !== false) {
449
+ const _screens = buildTheme(screens, options.screens);
450
+ if (_screens != null) {
451
+ theme.screens = _screens;
452
+ }
453
+ }
454
+ return theme;
455
+ }
456
+ var defaultTheme = {
396
457
  colors,
397
- boxShadow: shadows,
398
- fontSize: fontSizes,
458
+ boxShadow,
459
+ fontSize,
399
460
  fontFamily: customFontFamily,
400
461
  animation: animation2,
401
462
  keyframes,
@@ -403,7 +464,7 @@ var theme = {
403
464
  };
404
465
  var unocssTheme = {
405
466
  colors,
406
- boxShadow: shadows,
467
+ boxShadow,
407
468
  fontSize: unocssFontSizes
408
469
  };
409
470
 
@@ -424,33 +485,35 @@ var colorsNames = [
424
485
  ];
425
486
 
426
487
  // src/index.ts
427
- function config(extend = true) {
488
+ function buildPreset(extend = true, buildOptions = {}) {
428
489
  if (extend === false) {
429
490
  return {
430
- theme,
491
+ theme: factory(buildOptions),
431
492
  plugins
432
493
  };
433
494
  }
434
495
  return {
435
496
  theme: {
436
- extend: theme
497
+ extend: factory(buildOptions)
437
498
  },
438
499
  plugins
439
500
  };
440
501
  }
441
- var src_default = config();
502
+ var src_default = buildPreset();
442
503
  // Annotate the CommonJS export names for ESM import in node:
443
504
  0 && (module.exports = {
444
505
  animation,
506
+ boxShadow,
507
+ buildPreset,
508
+ buildTheme,
445
509
  colors,
446
510
  colorsNames,
447
- config,
511
+ defaultTheme,
512
+ factory,
448
513
  fontFamily,
449
- fontSizes,
514
+ fontSize,
450
515
  keyframes,
451
516
  screens,
452
517
  screensNumber,
453
- shadows,
454
- theme,
455
518
  unocssTheme
456
519
  });
package/dist/index.d.cts CHANGED
@@ -3,6 +3,99 @@ import { Config } from 'tailwindcss';
3
3
 
4
4
  declare const colorsNames: readonly ["primary", "bateau", "secondary", "pompelmo", "green", "fuchsia", "indigo", "neutral", "orange", "red", "amber", "seafoam"];
5
5
 
6
+ type ColorsNames = typeof colorsNames[number];
7
+ type ColorsVariations = 'DEFAULT' | 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
8
+ interface MainColors {
9
+ black: string;
10
+ white: string;
11
+ inherit: 'inherit';
12
+ current: 'currentColor';
13
+ transparent: 'transparent';
14
+ }
15
+ interface DefaultColors {
16
+ danger: string;
17
+ warning: string;
18
+ success: string;
19
+ info: string;
20
+ special: string;
21
+ }
22
+ type Colors = DefaultColors & MainColors & Record<ColorsNames, {
23
+ [K in ColorsVariations]: string;
24
+ }>;
25
+ type ColorString = `${ColorsNames}-${ColorsVariations}` | keyof DefaultColors | keyof MainColors;
26
+
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;
32
+ }
33
+ type BuildThemeOptions = {
34
+ [k in ConfiguredThemes]?: ThemeOptions;
35
+ };
36
+
37
+ /**
38
+ * Converts the given string from camel-case to kebab-case.
39
+ * @template T The string to convert the case.
40
+ * @see https://gist.github.com/albertms10/09f14ef7ebdc3ce0e95683c728616253
41
+ * @example
42
+ * type Kebab = CamelToKebab<'exampleVarName'>;
43
+ * // 'example-var-name'
44
+ */
45
+ type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToKebab<U>}` : `${Uncapitalize<T>}-${CamelToKebab<U>}` : '';
46
+ type CamelToKebabKeys<T> = {
47
+ [K in keyof T as K extends string ? CamelToKebab<K> : K]: T[K];
48
+ };
49
+
50
+ /**
51
+ * tailwindcss font-size configuration
52
+ * @see https://tailwindcss.com/docs/font-size
53
+ *
54
+ * @note For unocss, the keys are kebab-case
55
+ * @see https://github.com/unocss/unocss/issues/3663#issuecomment-2024909371
56
+ */
57
+
58
+ interface FontSizeDetail {
59
+ lineHeight?: string;
60
+ letterSpacing?: string;
61
+ fontWeight?: number;
62
+ }
63
+ type FontValue = `${number}px` | `${number}rem`;
64
+ type FontAndLineHeight = [FontValue, FontValue];
65
+ type DetailFont = [
66
+ FontValue,
67
+ FontSizeDetail
68
+ ];
69
+ type UnocssDetailFont = [FontValue, CamelToKebabKeys<FontSizeDetail>];
70
+ type FontSize = FontAndLineHeight | FontValue | DetailFont;
71
+ type UnocssFontSize = FontValue | FontAndLineHeight | UnocssDetailFont;
72
+ type SizeKeys = `${number}xs` | 'xs' | 'sm' | 'base' | 'md' | 'lg' | 'xl' | `${number}xl`;
73
+ type HeadingKeys = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
74
+ type DisplayKeys = 'display1' | 'display2' | 'display3' | 'display4';
75
+ type FontSizeKeys = SizeKeys | HeadingKeys | DisplayKeys;
76
+ declare function isDetailFont(value: FontSize): value is DetailFont;
77
+ type FontSizes = {
78
+ [K in FontSizeKeys]?: FontSize;
79
+ };
80
+ type UnocssFontSizes = {
81
+ [K in FontSizeKeys]?: UnocssFontSize;
82
+ };
83
+
84
+ declare const screenSizes: readonly ["sm", "md", "lg", "xl", "2xl", "tablet", "laptop", "desktop"];
85
+ type Screens = Record<typeof screenSizes[number], `${number}px`>;
86
+ type ExtractNumber<T extends string> = T extends `${infer N extends number}px` ? N : never;
87
+ type ScreensNumber = {
88
+ [K in keyof Screens]: ExtractNumber<Screens[K]>;
89
+ };
90
+
91
+ type BorderSize = 0 | `${number}px`;
92
+ type RgbValue = number;
93
+ type Shadow = `${BorderSize} ${BorderSize} ${BorderSize} ${BorderSize} rgba(${RgbValue}, ${RgbValue}, ${RgbValue}, ${RgbValue})`;
94
+ type ShadowSize = 0 | 1 | 2 | 3 | 4 | 5;
95
+ type Shadows = {
96
+ [K in ShadowSize as `elevation-${K}`]?: Shadow;
97
+ };
98
+
6
99
  declare const animation: {
7
100
  'radix-accordion-down': string;
8
101
  'radix-accordion-up': string;
@@ -265,54 +358,7 @@ declare const customFontFamily: {
265
358
  sans: string[];
266
359
  };
267
360
 
268
- /**
269
- * Converts the given string from camel-case to kebab-case.
270
- * @template T The string to convert the case.
271
- * @see https://gist.github.com/albertms10/09f14ef7ebdc3ce0e95683c728616253
272
- * @example
273
- * type Kebab = CamelToKebab<'exampleVarName'>;
274
- * // 'example-var-name'
275
- */
276
- type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToKebab<U>}` : `${Uncapitalize<T>}-${CamelToKebab<U>}` : '';
277
- type CamelToKebabKeys<T> = {
278
- [K in keyof T as K extends string ? CamelToKebab<K> : K]: T[K];
279
- };
280
-
281
- /**
282
- * tailwindcss font-size configuration
283
- * @see https://tailwindcss.com/docs/font-size
284
- *
285
- * @note For unocss, the keys are kebab-case
286
- * @see https://github.com/unocss/unocss/issues/3663#issuecomment-2024909371
287
- */
288
-
289
- interface FontSizeDetail {
290
- lineHeight?: string;
291
- letterSpacing?: string;
292
- fontWeight?: number;
293
- }
294
- type FontValue = `${number}px` | `${number}rem`;
295
- type FontAndLineHeight = [FontValue, FontValue];
296
- type DetailFont = [
297
- FontValue,
298
- FontSizeDetail
299
- ];
300
- type UnocssDetailFont = [FontValue, CamelToKebabKeys<FontSizeDetail>];
301
- type FontSize = FontAndLineHeight | FontValue | DetailFont;
302
- type UnocssFontSize = FontValue | FontAndLineHeight | UnocssDetailFont;
303
- type SizeKeys = `${number}xs` | 'xs' | 'sm' | 'base' | 'md' | 'lg' | 'xl' | `${number}xl`;
304
- type HeadingKeys = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
305
- type DisplayKeys = 'display1' | 'display2' | 'display3' | 'display4';
306
- type FontSizeKeys = SizeKeys | HeadingKeys | DisplayKeys;
307
- declare function isDetailFont(value: FontSize): value is DetailFont;
308
- type FontSizes = {
309
- [K in FontSizeKeys]?: FontSize;
310
- };
311
- type UnocssFontSizes = {
312
- [K in FontSizeKeys]?: UnocssFontSize;
313
- };
314
-
315
- declare const fontSizes: {
361
+ declare const fontSize: {
316
362
  '2xs': ["0.6875rem", "1rem"];
317
363
  xs: ["0.75rem", "1rem"];
318
364
  sm: ["0.875rem", "1.25rem"];
@@ -387,7 +433,7 @@ declare const screens: {
387
433
  desktop: `${number}px`;
388
434
  };
389
435
 
390
- declare const shadows: {
436
+ declare const boxShadow: {
391
437
  'elevation-0': "0 0 0 0 rgba(0, 0, 0, 0.10)";
392
438
  'elevation-1': "0 1px 2px 0 rgba(0, 0, 0, 0.10)";
393
439
  'elevation-2': "0 4px 8px 0 rgba(0, 0, 0, 0.10)";
@@ -396,7 +442,11 @@ declare const shadows: {
396
442
  'elevation-5': "0 12px 24px 0 rgba(0, 0, 0, 0.10)";
397
443
  };
398
444
 
399
- declare const theme: 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'];
449
+ declare const defaultTheme: Config['theme'];
400
450
  declare const unocssTheme: {
401
451
  colors: {
402
452
  primary: {
@@ -589,43 +639,7 @@ declare const unocssTheme: {
589
639
  fontSize: UnocssFontSizes;
590
640
  };
591
641
 
592
- type ColorsNames = typeof colorsNames[number];
593
- type ColorsVariations = 'DEFAULT' | 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
594
- interface MainColors {
595
- black: string;
596
- white: string;
597
- inherit: 'inherit';
598
- current: 'currentColor';
599
- transparent: 'transparent';
600
- }
601
- interface DefaultColors {
602
- danger: string;
603
- warning: string;
604
- success: string;
605
- info: string;
606
- special: string;
607
- }
608
- type Colors = DefaultColors & MainColors & Record<ColorsNames, {
609
- [K in ColorsVariations]: string;
610
- }>;
611
- type ColorString = `${ColorsNames}-${ColorsVariations}` | keyof DefaultColors | keyof MainColors;
612
-
613
- declare const screenSizes: readonly ["sm", "md", "lg", "xl", "2xl", "tablet", "laptop", "desktop"];
614
- type Screens = Record<typeof screenSizes[number], `${number}px`>;
615
- type ExtractNumber<T extends string> = T extends `${infer N extends number}px` ? N : never;
616
- type ScreensNumber = {
617
- [K in keyof Screens]: ExtractNumber<Screens[K]>;
618
- };
619
-
620
- type BorderSize = 0 | `${number}px`;
621
- type RgbValue = number;
622
- type Shadow = `${BorderSize} ${BorderSize} ${BorderSize} ${BorderSize} rgba(${RgbValue}, ${RgbValue}, ${RgbValue}, ${RgbValue})`;
623
- type ShadowSize = 0 | 1 | 2 | 3 | 4 | 5;
624
- type Shadows = {
625
- [K in ShadowSize as `elevation-${K}`]?: Shadow;
626
- };
627
-
628
- declare function config(extend?: boolean): Partial<Config>;
642
+ declare function buildPreset(extend?: boolean, buildOptions?: BuildThemeOptions): Partial<Config>;
629
643
  declare const _default: Partial<tailwindcss_types_config.Config>;
630
644
 
631
- export { type ColorString, type Colors, type ColorsNames, type FontSizes, type Screens, type ScreensNumber, type Shadows, type UnocssFontSizes, animation, colors, colorsNames, config, _default as default, customFontFamily as fontFamily, fontSizes, isDetailFont, keyframes, screenSizes, screens, screensNumber, shadows, theme, 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
@@ -3,6 +3,99 @@ import { Config } from 'tailwindcss';
3
3
 
4
4
  declare const colorsNames: readonly ["primary", "bateau", "secondary", "pompelmo", "green", "fuchsia", "indigo", "neutral", "orange", "red", "amber", "seafoam"];
5
5
 
6
+ type ColorsNames = typeof colorsNames[number];
7
+ type ColorsVariations = 'DEFAULT' | 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
8
+ interface MainColors {
9
+ black: string;
10
+ white: string;
11
+ inherit: 'inherit';
12
+ current: 'currentColor';
13
+ transparent: 'transparent';
14
+ }
15
+ interface DefaultColors {
16
+ danger: string;
17
+ warning: string;
18
+ success: string;
19
+ info: string;
20
+ special: string;
21
+ }
22
+ type Colors = DefaultColors & MainColors & Record<ColorsNames, {
23
+ [K in ColorsVariations]: string;
24
+ }>;
25
+ type ColorString = `${ColorsNames}-${ColorsVariations}` | keyof DefaultColors | keyof MainColors;
26
+
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;
32
+ }
33
+ type BuildThemeOptions = {
34
+ [k in ConfiguredThemes]?: ThemeOptions;
35
+ };
36
+
37
+ /**
38
+ * Converts the given string from camel-case to kebab-case.
39
+ * @template T The string to convert the case.
40
+ * @see https://gist.github.com/albertms10/09f14ef7ebdc3ce0e95683c728616253
41
+ * @example
42
+ * type Kebab = CamelToKebab<'exampleVarName'>;
43
+ * // 'example-var-name'
44
+ */
45
+ type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToKebab<U>}` : `${Uncapitalize<T>}-${CamelToKebab<U>}` : '';
46
+ type CamelToKebabKeys<T> = {
47
+ [K in keyof T as K extends string ? CamelToKebab<K> : K]: T[K];
48
+ };
49
+
50
+ /**
51
+ * tailwindcss font-size configuration
52
+ * @see https://tailwindcss.com/docs/font-size
53
+ *
54
+ * @note For unocss, the keys are kebab-case
55
+ * @see https://github.com/unocss/unocss/issues/3663#issuecomment-2024909371
56
+ */
57
+
58
+ interface FontSizeDetail {
59
+ lineHeight?: string;
60
+ letterSpacing?: string;
61
+ fontWeight?: number;
62
+ }
63
+ type FontValue = `${number}px` | `${number}rem`;
64
+ type FontAndLineHeight = [FontValue, FontValue];
65
+ type DetailFont = [
66
+ FontValue,
67
+ FontSizeDetail
68
+ ];
69
+ type UnocssDetailFont = [FontValue, CamelToKebabKeys<FontSizeDetail>];
70
+ type FontSize = FontAndLineHeight | FontValue | DetailFont;
71
+ type UnocssFontSize = FontValue | FontAndLineHeight | UnocssDetailFont;
72
+ type SizeKeys = `${number}xs` | 'xs' | 'sm' | 'base' | 'md' | 'lg' | 'xl' | `${number}xl`;
73
+ type HeadingKeys = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
74
+ type DisplayKeys = 'display1' | 'display2' | 'display3' | 'display4';
75
+ type FontSizeKeys = SizeKeys | HeadingKeys | DisplayKeys;
76
+ declare function isDetailFont(value: FontSize): value is DetailFont;
77
+ type FontSizes = {
78
+ [K in FontSizeKeys]?: FontSize;
79
+ };
80
+ type UnocssFontSizes = {
81
+ [K in FontSizeKeys]?: UnocssFontSize;
82
+ };
83
+
84
+ declare const screenSizes: readonly ["sm", "md", "lg", "xl", "2xl", "tablet", "laptop", "desktop"];
85
+ type Screens = Record<typeof screenSizes[number], `${number}px`>;
86
+ type ExtractNumber<T extends string> = T extends `${infer N extends number}px` ? N : never;
87
+ type ScreensNumber = {
88
+ [K in keyof Screens]: ExtractNumber<Screens[K]>;
89
+ };
90
+
91
+ type BorderSize = 0 | `${number}px`;
92
+ type RgbValue = number;
93
+ type Shadow = `${BorderSize} ${BorderSize} ${BorderSize} ${BorderSize} rgba(${RgbValue}, ${RgbValue}, ${RgbValue}, ${RgbValue})`;
94
+ type ShadowSize = 0 | 1 | 2 | 3 | 4 | 5;
95
+ type Shadows = {
96
+ [K in ShadowSize as `elevation-${K}`]?: Shadow;
97
+ };
98
+
6
99
  declare const animation: {
7
100
  'radix-accordion-down': string;
8
101
  'radix-accordion-up': string;
@@ -265,54 +358,7 @@ declare const customFontFamily: {
265
358
  sans: string[];
266
359
  };
267
360
 
268
- /**
269
- * Converts the given string from camel-case to kebab-case.
270
- * @template T The string to convert the case.
271
- * @see https://gist.github.com/albertms10/09f14ef7ebdc3ce0e95683c728616253
272
- * @example
273
- * type Kebab = CamelToKebab<'exampleVarName'>;
274
- * // 'example-var-name'
275
- */
276
- type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToKebab<U>}` : `${Uncapitalize<T>}-${CamelToKebab<U>}` : '';
277
- type CamelToKebabKeys<T> = {
278
- [K in keyof T as K extends string ? CamelToKebab<K> : K]: T[K];
279
- };
280
-
281
- /**
282
- * tailwindcss font-size configuration
283
- * @see https://tailwindcss.com/docs/font-size
284
- *
285
- * @note For unocss, the keys are kebab-case
286
- * @see https://github.com/unocss/unocss/issues/3663#issuecomment-2024909371
287
- */
288
-
289
- interface FontSizeDetail {
290
- lineHeight?: string;
291
- letterSpacing?: string;
292
- fontWeight?: number;
293
- }
294
- type FontValue = `${number}px` | `${number}rem`;
295
- type FontAndLineHeight = [FontValue, FontValue];
296
- type DetailFont = [
297
- FontValue,
298
- FontSizeDetail
299
- ];
300
- type UnocssDetailFont = [FontValue, CamelToKebabKeys<FontSizeDetail>];
301
- type FontSize = FontAndLineHeight | FontValue | DetailFont;
302
- type UnocssFontSize = FontValue | FontAndLineHeight | UnocssDetailFont;
303
- type SizeKeys = `${number}xs` | 'xs' | 'sm' | 'base' | 'md' | 'lg' | 'xl' | `${number}xl`;
304
- type HeadingKeys = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
305
- type DisplayKeys = 'display1' | 'display2' | 'display3' | 'display4';
306
- type FontSizeKeys = SizeKeys | HeadingKeys | DisplayKeys;
307
- declare function isDetailFont(value: FontSize): value is DetailFont;
308
- type FontSizes = {
309
- [K in FontSizeKeys]?: FontSize;
310
- };
311
- type UnocssFontSizes = {
312
- [K in FontSizeKeys]?: UnocssFontSize;
313
- };
314
-
315
- declare const fontSizes: {
361
+ declare const fontSize: {
316
362
  '2xs': ["0.6875rem", "1rem"];
317
363
  xs: ["0.75rem", "1rem"];
318
364
  sm: ["0.875rem", "1.25rem"];
@@ -387,7 +433,7 @@ declare const screens: {
387
433
  desktop: `${number}px`;
388
434
  };
389
435
 
390
- declare const shadows: {
436
+ declare const boxShadow: {
391
437
  'elevation-0': "0 0 0 0 rgba(0, 0, 0, 0.10)";
392
438
  'elevation-1': "0 1px 2px 0 rgba(0, 0, 0, 0.10)";
393
439
  'elevation-2': "0 4px 8px 0 rgba(0, 0, 0, 0.10)";
@@ -396,7 +442,11 @@ declare const shadows: {
396
442
  'elevation-5': "0 12px 24px 0 rgba(0, 0, 0, 0.10)";
397
443
  };
398
444
 
399
- declare const theme: 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'];
449
+ declare const defaultTheme: Config['theme'];
400
450
  declare const unocssTheme: {
401
451
  colors: {
402
452
  primary: {
@@ -589,43 +639,7 @@ declare const unocssTheme: {
589
639
  fontSize: UnocssFontSizes;
590
640
  };
591
641
 
592
- type ColorsNames = typeof colorsNames[number];
593
- type ColorsVariations = 'DEFAULT' | 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
594
- interface MainColors {
595
- black: string;
596
- white: string;
597
- inherit: 'inherit';
598
- current: 'currentColor';
599
- transparent: 'transparent';
600
- }
601
- interface DefaultColors {
602
- danger: string;
603
- warning: string;
604
- success: string;
605
- info: string;
606
- special: string;
607
- }
608
- type Colors = DefaultColors & MainColors & Record<ColorsNames, {
609
- [K in ColorsVariations]: string;
610
- }>;
611
- type ColorString = `${ColorsNames}-${ColorsVariations}` | keyof DefaultColors | keyof MainColors;
612
-
613
- declare const screenSizes: readonly ["sm", "md", "lg", "xl", "2xl", "tablet", "laptop", "desktop"];
614
- type Screens = Record<typeof screenSizes[number], `${number}px`>;
615
- type ExtractNumber<T extends string> = T extends `${infer N extends number}px` ? N : never;
616
- type ScreensNumber = {
617
- [K in keyof Screens]: ExtractNumber<Screens[K]>;
618
- };
619
-
620
- type BorderSize = 0 | `${number}px`;
621
- type RgbValue = number;
622
- type Shadow = `${BorderSize} ${BorderSize} ${BorderSize} ${BorderSize} rgba(${RgbValue}, ${RgbValue}, ${RgbValue}, ${RgbValue})`;
623
- type ShadowSize = 0 | 1 | 2 | 3 | 4 | 5;
624
- type Shadows = {
625
- [K in ShadowSize as `elevation-${K}`]?: Shadow;
626
- };
627
-
628
- declare function config(extend?: boolean): Partial<Config>;
642
+ declare function buildPreset(extend?: boolean, buildOptions?: BuildThemeOptions): Partial<Config>;
629
643
  declare const _default: Partial<tailwindcss_types_config.Config>;
630
644
 
631
- export { type ColorString, type Colors, type ColorsNames, type FontSizes, type Screens, type ScreensNumber, type Shadows, type UnocssFontSizes, animation, colors, colorsNames, config, _default as default, customFontFamily as fontFamily, fontSizes, isDetailFont, keyframes, screenSizes, screens, screensNumber, shadows, theme, 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
@@ -1,15 +1,17 @@
1
1
  import {
2
2
  animation,
3
+ boxShadow,
4
+ buildTheme,
3
5
  colors,
4
6
  customFontFamily,
5
- fontSizes,
7
+ defaultTheme,
8
+ factory,
9
+ fontSize,
6
10
  keyframes,
7
11
  screens,
8
12
  screensNumber,
9
- shadows,
10
- theme,
11
13
  unocssTheme
12
- } from "./chunk-J5XGEDSE.js";
14
+ } from "./chunk-I5TUIFQV.js";
13
15
 
14
16
  // src/plugins/index.ts
15
17
  import animation2 from "tailwindcss-animate";
@@ -32,33 +34,35 @@ var colorsNames = [
32
34
  ];
33
35
 
34
36
  // src/index.ts
35
- function config(extend = true) {
37
+ function buildPreset(extend = true, buildOptions = {}) {
36
38
  if (extend === false) {
37
39
  return {
38
- theme,
40
+ theme: factory(buildOptions),
39
41
  plugins
40
42
  };
41
43
  }
42
44
  return {
43
45
  theme: {
44
- extend: theme
46
+ extend: factory(buildOptions)
45
47
  },
46
48
  plugins
47
49
  };
48
50
  }
49
- var src_default = config();
51
+ var src_default = buildPreset();
50
52
  export {
51
53
  animation,
54
+ boxShadow,
55
+ buildPreset,
56
+ buildTheme,
52
57
  colors,
53
58
  colorsNames,
54
- config,
55
59
  src_default as default,
60
+ defaultTheme,
61
+ factory,
56
62
  customFontFamily as fontFamily,
57
- fontSizes,
63
+ fontSize,
58
64
  keyframes,
59
65
  screens,
60
66
  screensNumber,
61
- shadows,
62
- theme,
63
67
  unocssTheme
64
68
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@removify/tailwind-preset",
3
3
  "type": "module",
4
- "version": "0.1.10",
4
+ "version": "0.2.1",
5
5
  "description": "Tailwind CSS preset for Removify",
6
6
  "keywords": [
7
7
  "tailwind"
@@ -33,8 +33,8 @@
33
33
  "devDependencies": {
34
34
  "@commitlint/cli": "^19.5.0",
35
35
  "@commitlint/config-conventional": "^19.5.0",
36
- "@removify/eslint-config": "^1.5.4",
37
- "@types/node": "^22.5.4",
36
+ "@removify/eslint-config": "^1.5.7",
37
+ "@types/node": "^22.5.5",
38
38
  "@types/yargs": "^17.0.33",
39
39
  "bumpp": "^9.5.2",
40
40
  "eslint": "^9.10.0",
@@ -42,12 +42,12 @@
42
42
  "lint-staged": "^15.2.10",
43
43
  "rimraf": "^6.0.1",
44
44
  "tailwind-config-viewer": "^2.0.4",
45
- "tailwindcss": "^3.4.11",
46
- "tsup": "^8.2.4",
47
- "tsx": "^4.19.0",
45
+ "tailwindcss": "^3.4.12",
46
+ "tsup": "^8.3.0",
47
+ "tsx": "^4.19.1",
48
48
  "typescript": "^5.6.2",
49
- "vitest": "^2.0.5",
50
- "@removify/tailwind-preset": "0.1.10"
49
+ "vitest": "^2.1.1",
50
+ "@removify/tailwind-preset": "0.2.1"
51
51
  },
52
52
  "lint-staged": {
53
53
  "**/*.{js,ts,vue,html}": [
package/readme.md CHANGED
@@ -21,11 +21,11 @@ npx @removify/tailwind-preset > src/style.css
21
21
  ```
22
22
 
23
23
  ```ts
24
+ import type { Config } from 'tailwindcss';
25
+
24
26
  // tailwind.config.{t,j}s
25
27
  import removify from '@removify/tailwind-preset';
26
28
 
27
- import type { Config } from 'tailwindcss';
28
-
29
29
  export default {
30
30
  content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
31
31
  presets: [removify],