@rescui/typography 0.15.0 → 0.16.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.
@@ -25,7 +25,7 @@ export declare type LinkParams = {
25
25
  */
26
26
  external?: boolean;
27
27
  /**
28
- * @default hard
28
+ * @default null
29
29
  */
30
30
  hardness?: Hardness;
31
31
  /**
@@ -45,7 +45,14 @@ export declare type OrderedListParams = {
45
45
  export declare type UnorderedListParams = {
46
46
  offsetItems?: OffsetItems;
47
47
  };
48
- export declare function createTextCn(theme: Theme): {
48
+ export declare function createTextCn(theme?: Theme): {
49
+ (type: Texts, params?: TextsParams): string;
50
+ (type: Link, params?: LinkParams): string;
51
+ (type: OrderedList, params?: OrderedListParams): string;
52
+ (type: UnorderedList, params?: UnorderedListParams): string;
53
+ (type: Others): string;
54
+ };
55
+ export declare const textCn: {
49
56
  (type: Texts, params?: TextsParams): string;
50
57
  (type: Link, params?: LinkParams): string;
51
58
  (type: OrderedList, params?: OrderedListParams): string;
@@ -1,13 +1,12 @@
1
1
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
2
- import { useTheme } from '@rescui/ui-contexts';
3
- import bemCnFast from 'bem-cn-fast';
4
- var THEMED_TYPES = ['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', 'rs-text-1', 'rs-text-2', 'rs-text-3', 'rs-link'];
2
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
+ import { useThemeWithUndefined } from '@rescui/ui-contexts';
4
+ import cn from 'classnames';
5
+ 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'];
6
+ var TEXTS = ['rs-text-1', 'rs-text-2', 'rs-text-3'];
5
7
 
6
8
  function createTextCn(theme) {
7
- if (!theme) {
8
- throw new TypeError('theme argument is required');
9
- }
10
-
9
+ // eslint-disable-next-line complexity
11
10
  function textCn() {
12
11
  var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'rs-text-1';
13
12
 
@@ -31,22 +30,30 @@ function createTextCn(theme) {
31
30
  console.warn("'rs-digits' style is deprecated, please use 'rs-digits-1' instead");
32
31
  }
33
32
 
34
- return bemCnFast(type)({
35
- 'paragraph-offset-auto': paragraphOffsetAuto,
36
- hardness: hardness,
37
- external: external,
38
- mode: type === 'rs-link' && mode,
39
- theme: _includesInstanceProperty(THEMED_TYPES).call(THEMED_TYPES, type) && theme,
40
- alpha: alpha,
41
- 'offset-items': offsetItems
42
- });
33
+ if (_includesInstanceProperty(TEXT_BASES).call(TEXT_BASES, type)) {
34
+ return cn(type, theme && "rs-typography_theme_".concat(theme), hardness ? "rs-text_hardness_".concat(hardness) : _includesInstanceProperty(TEXTS).call(TEXTS, type) && "rs-text_hardness_average", paragraphOffsetAuto && 'rs-text_paragraph-offset-auto');
35
+ }
36
+
37
+ if (type === 'rs-link') {
38
+ return cn(type, "rs-link_mode_".concat(mode), hardness && "rs-link_hardness_".concat(hardness), external && "rs-link_external", theme && "rs-typography_theme_".concat(theme));
39
+ }
40
+
41
+ if (type === 'rs-ul' || type === 'rs-ol') {
42
+ var _context;
43
+
44
+ return cn(type, alpha && "rs-ol_alpha_".concat(alpha), offsetItems && _concatInstanceProperty(_context = "".concat(type, "_offset-items_")).call(_context, offsetItems));
45
+ }
46
+
47
+ return cn(type, theme && "rs-typography_theme_".concat(theme));
43
48
  }
44
49
 
45
50
  return textCn;
46
51
  }
47
52
 
53
+ var textCn = createTextCn();
54
+
48
55
  var useTextStyles = function useTextStyles() {
49
- return createTextCn(useTheme());
56
+ return createTextCn(useThemeWithUndefined());
50
57
  };
51
58
 
52
- export { createTextCn, useTextStyles };
59
+ export { createTextCn, textCn, useTextStyles };