@unocss/preset-typography 66.4.2 → 66.5.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.
package/dist/index.d.mts CHANGED
@@ -1,18 +1,38 @@
1
- import * as _unocss_core from '@unocss/core';
2
- import { CSSObject } from '@unocss/core';
3
- import { Theme } from '@unocss/preset-mini';
1
+ import { CSSObject, Arrayable, Preset } from '@unocss/core';
4
2
 
5
- /** @public */
6
3
  interface TypographyCompatibilityOptions {
7
- noColonWhere?: boolean
8
- noColonIs?: boolean
9
- noColonNot?: boolean
4
+ noColonWhere?: boolean;
5
+ noColonIs?: boolean;
6
+ noColonNot?: boolean;
10
7
  }
11
-
12
- /**
13
- * @public
14
- */
15
- interface TypographyOptions {
8
+ interface TypographyTheme {
9
+ colors?: Record<string, any>;
10
+ }
11
+ interface TypographyColorScheme {
12
+ 'body'?: Arrayable<string | number>;
13
+ 'headings'?: Arrayable<string | number>;
14
+ 'lead'?: Arrayable<string | number>;
15
+ 'links'?: Arrayable<string | number>;
16
+ 'bold'?: Arrayable<string | number>;
17
+ 'counters'?: Arrayable<string | number>;
18
+ 'bullets'?: Arrayable<string | number>;
19
+ 'hr'?: Arrayable<string | number>;
20
+ 'quotes'?: Arrayable<string | number>;
21
+ 'quote-borders'?: Arrayable<string | number>;
22
+ 'captions'?: Arrayable<string | number>;
23
+ 'kbd'?: Arrayable<string | number>;
24
+ 'kbd-shadows'?: Arrayable<string | number>;
25
+ 'code'?: Arrayable<string | number>;
26
+ 'pre-code'?: Arrayable<string | number>;
27
+ 'pre-bg'?: Arrayable<string | number>;
28
+ 'th-borders'?: Arrayable<string | number>;
29
+ 'td-borders'?: Arrayable<string | number>;
30
+ }
31
+ interface TypographyCSSObject extends Record<string, CSSObject | string | number> {
32
+ }
33
+ interface TypographySizeScheme extends Record<string, TypographyCSSObject> {
34
+ }
35
+ interface TypographyOptions<T extends TypographyTheme = TypographyTheme> {
16
36
  /**
17
37
  * The selector name to use the typographic utilities.
18
38
  * To undo the styles to the elements, use it like
@@ -28,7 +48,7 @@ interface TypographyOptions {
28
48
  *
29
49
  * @default undefined
30
50
  */
31
- cssExtend?: Record<string, CSSObject> | ((theme: Theme) => Record<string, CSSObject>);
51
+ cssExtend?: Record<string, CSSObject> | ((theme: T) => Record<string, CSSObject>);
32
52
  /**
33
53
  * Compatibility option. Notice that it will affect some features.
34
54
  * For more instructions, see
@@ -37,28 +57,86 @@ interface TypographyOptions {
37
57
  * @default undefined
38
58
  */
39
59
  compatibility?: TypographyCompatibilityOptions;
40
- /**
41
- * @deprecated use `selectorName` instead. It will be removed in 1.0.
42
- */
43
- className?: string;
44
60
  /**
45
61
  * Control whether prose's utilities should be marked with !important.
46
62
  *
47
63
  * @default false
48
64
  */
49
65
  important?: boolean | string;
66
+ /**
67
+ * Color scheme for typography elements.
68
+ *
69
+ * Each key represents a typographic element (e.g., 'body', 'headings', 'links').
70
+ *
71
+ * Type: [light, dark] => [color, invert-color]
72
+ *
73
+ * @default
74
+ *
75
+ * {
76
+ * 'body': [700, 300],
77
+ * 'headings': [900, 'white'],
78
+ * 'lead': [600, 400],
79
+ * 'links': [900, 'white'],
80
+ * 'bold': [900, 'white'],
81
+ * 'counters': [500, 400],
82
+ * 'bullets': [300, 600],
83
+ * 'hr': [200, 700],
84
+ * 'quotes': [900, 100],
85
+ * 'quote-borders': [200, 700],
86
+ * 'captions': [500, 400],
87
+ * 'kbd': [900, 'white'],
88
+ * 'kbd-shadows': [900, 'white'],
89
+ * 'code': [900, 'white'],
90
+ * 'pre-code': [200, 300],
91
+ * 'pre-bg': [800, 'rgb(0 0 0 / 50%)'],
92
+ * 'th-borders': [300, 600],
93
+ * 'td-borders': [200, 700],
94
+ * }
95
+ */
96
+ colorScheme?: TypographyColorScheme;
97
+ /**
98
+ * Size scheme for typography elements.
99
+ *
100
+ * Allows you to customize the CSS styles of various typographic elements.
101
+ * Similar to {@link cssExtend}, but it applies granular overlays to different sizes of text.
102
+ *
103
+ * Example:
104
+ *
105
+ * {
106
+ *
107
+ * 'sm': {@link TypographyCSSObject}
108
+ *
109
+ * 'base': {@link TypographyCSSObject}
110
+ *
111
+ * 'lg': {@link TypographyCSSObject}
112
+ *
113
+ * 'xl': {@link TypographyCSSObject}
114
+ *
115
+ * '2xl': {@link TypographyCSSObject}
116
+ *
117
+ * }
118
+ *
119
+ */
120
+ sizeScheme?: TypographySizeScheme;
121
+ /**
122
+ * Prefix for generated css vars.
123
+ *
124
+ * @default '--un-prose'
125
+ */
126
+ cssVarPrefix?: string;
50
127
  }
128
+
51
129
  /**
52
130
  * UnoCSS Preset for Typography
53
131
  *
54
132
  * ```js
55
133
  * // uno.config.ts
56
- * import { presetAttributify, presetUno, defineConfig, presetTypography } from 'unocss'
134
+ * import { presetAttributify, presetWind3/4, defineConfig, presetTypography } from 'unocss'
57
135
  *
58
136
  * export default defineConfig({
59
137
  * presets: [
138
+ * presetWind3/4(), // required!
60
139
  * presetAttributify(), // required if using attributify mode
61
- * presetUno(), // required
62
140
  * presetTypography()
63
141
  * ]
64
142
  * })
@@ -68,7 +146,7 @@ interface TypographyOptions {
68
146
  * @returns typography preset
69
147
  * @public
70
148
  */
71
- declare const presetTypography: _unocss_core.PresetFactory<Theme, TypographyOptions>;
149
+ declare const presetTypography: <Theme extends TypographyTheme = TypographyTheme>(options?: TypographyOptions<Theme> | undefined) => Preset<Theme>;
72
150
 
73
151
  export { presetTypography as default, presetTypography };
74
- export type { TypographyOptions };
152
+ export type { TypographyCSSObject, TypographyColorScheme, TypographyCompatibilityOptions, TypographyOptions, TypographySizeScheme, TypographyTheme };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,38 @@
1
- import * as _unocss_core from '@unocss/core';
2
- import { CSSObject } from '@unocss/core';
3
- import { Theme } from '@unocss/preset-mini';
1
+ import { CSSObject, Arrayable, Preset } from '@unocss/core';
4
2
 
5
- /** @public */
6
3
  interface TypographyCompatibilityOptions {
7
- noColonWhere?: boolean
8
- noColonIs?: boolean
9
- noColonNot?: boolean
4
+ noColonWhere?: boolean;
5
+ noColonIs?: boolean;
6
+ noColonNot?: boolean;
10
7
  }
11
-
12
- /**
13
- * @public
14
- */
15
- interface TypographyOptions {
8
+ interface TypographyTheme {
9
+ colors?: Record<string, any>;
10
+ }
11
+ interface TypographyColorScheme {
12
+ 'body'?: Arrayable<string | number>;
13
+ 'headings'?: Arrayable<string | number>;
14
+ 'lead'?: Arrayable<string | number>;
15
+ 'links'?: Arrayable<string | number>;
16
+ 'bold'?: Arrayable<string | number>;
17
+ 'counters'?: Arrayable<string | number>;
18
+ 'bullets'?: Arrayable<string | number>;
19
+ 'hr'?: Arrayable<string | number>;
20
+ 'quotes'?: Arrayable<string | number>;
21
+ 'quote-borders'?: Arrayable<string | number>;
22
+ 'captions'?: Arrayable<string | number>;
23
+ 'kbd'?: Arrayable<string | number>;
24
+ 'kbd-shadows'?: Arrayable<string | number>;
25
+ 'code'?: Arrayable<string | number>;
26
+ 'pre-code'?: Arrayable<string | number>;
27
+ 'pre-bg'?: Arrayable<string | number>;
28
+ 'th-borders'?: Arrayable<string | number>;
29
+ 'td-borders'?: Arrayable<string | number>;
30
+ }
31
+ interface TypographyCSSObject extends Record<string, CSSObject | string | number> {
32
+ }
33
+ interface TypographySizeScheme extends Record<string, TypographyCSSObject> {
34
+ }
35
+ interface TypographyOptions<T extends TypographyTheme = TypographyTheme> {
16
36
  /**
17
37
  * The selector name to use the typographic utilities.
18
38
  * To undo the styles to the elements, use it like
@@ -28,7 +48,7 @@ interface TypographyOptions {
28
48
  *
29
49
  * @default undefined
30
50
  */
31
- cssExtend?: Record<string, CSSObject> | ((theme: Theme) => Record<string, CSSObject>);
51
+ cssExtend?: Record<string, CSSObject> | ((theme: T) => Record<string, CSSObject>);
32
52
  /**
33
53
  * Compatibility option. Notice that it will affect some features.
34
54
  * For more instructions, see
@@ -37,28 +57,86 @@ interface TypographyOptions {
37
57
  * @default undefined
38
58
  */
39
59
  compatibility?: TypographyCompatibilityOptions;
40
- /**
41
- * @deprecated use `selectorName` instead. It will be removed in 1.0.
42
- */
43
- className?: string;
44
60
  /**
45
61
  * Control whether prose's utilities should be marked with !important.
46
62
  *
47
63
  * @default false
48
64
  */
49
65
  important?: boolean | string;
66
+ /**
67
+ * Color scheme for typography elements.
68
+ *
69
+ * Each key represents a typographic element (e.g., 'body', 'headings', 'links').
70
+ *
71
+ * Type: [light, dark] => [color, invert-color]
72
+ *
73
+ * @default
74
+ *
75
+ * {
76
+ * 'body': [700, 300],
77
+ * 'headings': [900, 'white'],
78
+ * 'lead': [600, 400],
79
+ * 'links': [900, 'white'],
80
+ * 'bold': [900, 'white'],
81
+ * 'counters': [500, 400],
82
+ * 'bullets': [300, 600],
83
+ * 'hr': [200, 700],
84
+ * 'quotes': [900, 100],
85
+ * 'quote-borders': [200, 700],
86
+ * 'captions': [500, 400],
87
+ * 'kbd': [900, 'white'],
88
+ * 'kbd-shadows': [900, 'white'],
89
+ * 'code': [900, 'white'],
90
+ * 'pre-code': [200, 300],
91
+ * 'pre-bg': [800, 'rgb(0 0 0 / 50%)'],
92
+ * 'th-borders': [300, 600],
93
+ * 'td-borders': [200, 700],
94
+ * }
95
+ */
96
+ colorScheme?: TypographyColorScheme;
97
+ /**
98
+ * Size scheme for typography elements.
99
+ *
100
+ * Allows you to customize the CSS styles of various typographic elements.
101
+ * Similar to {@link cssExtend}, but it applies granular overlays to different sizes of text.
102
+ *
103
+ * Example:
104
+ *
105
+ * {
106
+ *
107
+ * 'sm': {@link TypographyCSSObject}
108
+ *
109
+ * 'base': {@link TypographyCSSObject}
110
+ *
111
+ * 'lg': {@link TypographyCSSObject}
112
+ *
113
+ * 'xl': {@link TypographyCSSObject}
114
+ *
115
+ * '2xl': {@link TypographyCSSObject}
116
+ *
117
+ * }
118
+ *
119
+ */
120
+ sizeScheme?: TypographySizeScheme;
121
+ /**
122
+ * Prefix for generated css vars.
123
+ *
124
+ * @default '--un-prose'
125
+ */
126
+ cssVarPrefix?: string;
50
127
  }
128
+
51
129
  /**
52
130
  * UnoCSS Preset for Typography
53
131
  *
54
132
  * ```js
55
133
  * // uno.config.ts
56
- * import { presetAttributify, presetUno, defineConfig, presetTypography } from 'unocss'
134
+ * import { presetAttributify, presetWind3/4, defineConfig, presetTypography } from 'unocss'
57
135
  *
58
136
  * export default defineConfig({
59
137
  * presets: [
138
+ * presetWind3/4(), // required!
60
139
  * presetAttributify(), // required if using attributify mode
61
- * presetUno(), // required
62
140
  * presetTypography()
63
141
  * ]
64
142
  * })
@@ -68,7 +146,7 @@ interface TypographyOptions {
68
146
  * @returns typography preset
69
147
  * @public
70
148
  */
71
- declare const presetTypography: _unocss_core.PresetFactory<Theme, TypographyOptions>;
149
+ declare const presetTypography: <Theme extends TypographyTheme = TypographyTheme>(options?: TypographyOptions<Theme> | undefined) => Preset<Theme>;
72
150
 
73
151
  export { presetTypography as default, presetTypography };
74
- export type { TypographyOptions };
152
+ export type { TypographyCSSObject, TypographyColorScheme, TypographyCompatibilityOptions, TypographyOptions, TypographySizeScheme, TypographyTheme };