@rescui/typography 0.17.0 → 0.18.0

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.
@@ -3,8 +3,11 @@ export declare type Texts = 'rs-text-1' | 'rs-text-2' | 'rs-text-3';
3
3
  export declare type Link = 'rs-link';
4
4
  export declare type OrderedList = 'rs-ol';
5
5
  export declare type UnorderedList = 'rs-ul';
6
- export declare type Others = 'rs-super-hero' | 'rs-middle-hero' | 'rs-digits-1' | 'rs-digits-2' | 'rs-hero' | 'rs-subtitle-1' | 'rs-h1' | 'rs-subtitle-2' | 'rs-h2' | 'rs-h3' | 'rs-h4' | 'rs-h5' | 'rs-overline' | 'rs-pre' | 'rs-code' | 'rs-link' | 'rs-article';
7
- export declare type Type = Texts | Link | OrderedList | Others | UnorderedList;
6
+ export declare type Subtitles = 'rs-subtitle-1' | 'rs-subtitle-2';
7
+ export declare type Digits = 'rs-digits-1' | 'rs-digits-2';
8
+ export declare type SubtitlesAndDigits = Subtitles | Digits;
9
+ export declare type Others = 'rs-super-hero' | 'rs-middle-hero' | 'rs-hero' | 'rs-h1' | 'rs-h2' | 'rs-h3' | 'rs-h4' | 'rs-h5' | 'rs-overline' | 'rs-pre' | 'rs-code';
10
+ export declare type Type = Texts | Link | OrderedList | UnorderedList | SubtitlesAndDigits | Others;
8
11
  export declare type Hardness = 'average' | 'hard' | 'pale';
9
12
  export declare type TextsParams = {
10
13
  /**
@@ -16,6 +19,12 @@ export declare type TextsParams = {
16
19
  */
17
20
  hardness?: Hardness;
18
21
  };
22
+ export declare type SubtitlesAndDigitsParams = {
23
+ /**
24
+ * @default hard
25
+ */
26
+ hardness?: Hardness;
27
+ };
19
28
  export declare type Mode = 'classic' | 'rock' | 'clear' | 'standalone';
20
29
  export declare type LinkParams = {
21
30
  /**
@@ -43,24 +52,24 @@ export declare type OrderedListParams = {
43
52
  export declare type UnorderedListParams = {
44
53
  offsetItems?: OffsetItems;
45
54
  };
46
- export declare function createTextCn(theme?: Theme): {
47
- (type: Texts, params?: TextsParams): string;
48
- (type: Link, params?: LinkParams): string;
49
- (type: OrderedList, params?: OrderedListParams): string;
50
- (type: UnorderedList, params?: UnorderedListParams): string;
51
- (type: Others): string;
52
- };
53
- export declare const textCn: {
54
- (type: Texts, params?: TextsParams): string;
55
- (type: Link, params?: LinkParams): string;
56
- (type: OrderedList, params?: OrderedListParams): string;
57
- (type: UnorderedList, params?: UnorderedListParams): string;
58
- (type: Others): string;
59
- };
60
- export declare const useTextStyles: () => {
61
- (type: Texts, params?: TextsParams): string;
62
- (type: Link, params?: LinkParams): string;
63
- (type: OrderedList, params?: OrderedListParams): string;
64
- (type: UnorderedList, params?: UnorderedListParams): string;
65
- (type: Others): string;
55
+ declare type MapParams<Types extends string, Params extends Record<string, unknown>> = {
56
+ [T in Types]: Params;
66
57
  };
58
+ /**
59
+ * The example of the map content:
60
+ * ```
61
+ * {
62
+ * 'rs-text-1': TextsParams,
63
+ * 'rs-text-2': TextsParams,
64
+ * 'rs-text-3': TextsParams,
65
+ * 'rs-subtitle-1': SubtitlesAndDigitsParams,
66
+ * // ...
67
+ * }
68
+ * ```
69
+ */
70
+ export declare type TypeToParams = MapParams<Texts, TextsParams> & MapParams<SubtitlesAndDigits, SubtitlesAndDigitsParams> & MapParams<Link, LinkParams> & MapParams<OrderedList, OrderedListParams> & MapParams<UnorderedList, UnorderedListParams> & MapParams<Others, never>;
71
+ export declare function createTextCn(theme?: Theme): <T extends Texts | SubtitlesAndDigits | Others | "rs-link" | "rs-ol" | "rs-ul">(type: T, params?: TypeToParams[T]) => string;
72
+ export declare const textCn: <T extends Texts | SubtitlesAndDigits | Others | "rs-link" | "rs-ol" | "rs-ul">(type: T, params?: TypeToParams[T]) => string;
73
+ export declare const useTextStyles: () => <T extends Texts | SubtitlesAndDigits | Others | "rs-link" | "rs-ol" | "rs-ul">(type: T, params?: TypeToParams[T]) => string;
74
+ export declare const colorCn: (color: Hardness | 'base') => any;
75
+ export {};
@@ -4,7 +4,6 @@ import { useThemeWithUndefined } from '@rescui/ui-contexts';
4
4
  import cn from 'classnames';
5
5
  import styles from './index-moduled.p.module.css.js';
6
6
  var TEXT_BASES = ['rs-digits-1', 'rs-digits-2', 'rs-super-hero', 'rs-middle-hero', 'rs-hero', 'rs-subtitle-1', 'rs-subtitle-2', 'rs-h1', 'rs-h2', 'rs-h3', 'rs-h4', 'rs-h5', 'rs-overline', 'rs-text-1', 'rs-text-2', 'rs-text-3'];
7
- var TEXTS = ['rs-text-1', 'rs-text-2', 'rs-text-3'];
8
7
 
9
8
  function createTextCn(theme) {
10
9
  // eslint-disable-next-line complexity
@@ -32,7 +31,7 @@ function createTextCn(theme) {
32
31
  }
33
32
 
34
33
  if (_includesInstanceProperty(TEXT_BASES).call(TEXT_BASES, type)) {
35
- return cn(styles[type], theme && styles["rs-typography_theme_".concat(theme)], hardness ? styles["rs-text_hardness_".concat(hardness)] : _includesInstanceProperty(TEXTS).call(TEXTS, type) && styles["rs-text_hardness_average"], paragraphOffsetAuto && styles['rs-text_paragraph-offset-auto']);
34
+ return cn(styles[type], theme && styles["rs-typography_theme_".concat(theme)], styles["rs-text_hardness_".concat(hardness !== null && hardness !== void 0 ? hardness : 'auto')], paragraphOffsetAuto && styles['rs-text_paragraph-offset-auto']);
36
35
  }
37
36
 
38
37
  if (type === 'rs-link') {
@@ -57,4 +56,8 @@ var useTextStyles = function useTextStyles() {
57
56
  return createTextCn(useThemeWithUndefined());
58
57
  };
59
58
 
60
- export { createTextCn, textCn, useTextStyles };
59
+ var colorCn = function colorCn(color) {
60
+ return styles["rs-text_color_".concat(color)];
61
+ };
62
+
63
+ export { colorCn, createTextCn, textCn, useTextStyles };