@alfalab/core-components-typography 4.0.0 → 4.1.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.
Files changed (109) hide show
  1. package/colors.css +20 -20
  2. package/colors.module-69def6bf.js +6 -0
  3. package/common.module-59cc11ca.js +6 -0
  4. package/component.js +6 -2
  5. package/cssm/component.js +5 -0
  6. package/cssm/hooks/index.d.ts +1 -0
  7. package/cssm/hooks/index.js +14 -0
  8. package/cssm/hooks/use-skeleton.module.css +19 -0
  9. package/cssm/hooks/useSkeleton.d.ts +12 -0
  10. package/cssm/hooks/useSkeleton.js +59 -0
  11. package/cssm/index.js +5 -0
  12. package/cssm/text/component.d.ts +9 -1
  13. package/cssm/text/component.js +23 -7
  14. package/cssm/text/index.js +5 -0
  15. package/cssm/title/component.d.ts +19 -2
  16. package/cssm/title/component.js +16 -2
  17. package/cssm/title/index.js +5 -0
  18. package/cssm/title-mobile/component.js +5 -0
  19. package/cssm/title-mobile/index.js +5 -0
  20. package/cssm/title-responsive/component.js +5 -0
  21. package/cssm/title-responsive/index.js +5 -0
  22. package/cssm/types.d.ts +12 -1
  23. package/esm/colors.css +20 -20
  24. package/esm/colors.module-64858915.js +4 -0
  25. package/esm/common.module-a0a4a875.js +4 -0
  26. package/esm/component.js +6 -2
  27. package/esm/hooks/index.d.ts +1 -0
  28. package/esm/hooks/index.js +5 -0
  29. package/esm/hooks/use-skeleton.css +20 -0
  30. package/esm/hooks/useSkeleton.d.ts +12 -0
  31. package/esm/hooks/useSkeleton.js +52 -0
  32. package/esm/index.js +6 -2
  33. package/esm/text/component.d.ts +9 -1
  34. package/esm/text/component.js +23 -9
  35. package/esm/text/index.css +18 -18
  36. package/esm/text/index.js +5 -1
  37. package/esm/title/common.css +5 -5
  38. package/esm/title/component.d.ts +19 -2
  39. package/esm/title/component.js +15 -3
  40. package/esm/title/index.css +19 -19
  41. package/esm/title/index.js +7 -3
  42. package/esm/title-mobile/component.js +7 -3
  43. package/esm/title-mobile/index.css +11 -11
  44. package/esm/title-mobile/index.js +6 -2
  45. package/esm/title-responsive/component.js +7 -3
  46. package/esm/title-responsive/index.css +31 -31
  47. package/esm/title-responsive/index.js +6 -2
  48. package/esm/types.d.ts +12 -1
  49. package/hooks/index.d.ts +1 -0
  50. package/hooks/index.js +13 -0
  51. package/hooks/use-skeleton.css +20 -0
  52. package/hooks/useSkeleton.d.ts +12 -0
  53. package/hooks/useSkeleton.js +60 -0
  54. package/index.js +6 -2
  55. package/modern/colors.css +20 -20
  56. package/modern/colors.module-58e8caae.js +4 -0
  57. package/modern/common.module-3d6095da.js +4 -0
  58. package/modern/component.js +6 -2
  59. package/modern/hooks/index.d.ts +1 -0
  60. package/modern/hooks/index.js +4 -0
  61. package/modern/hooks/use-skeleton.css +20 -0
  62. package/modern/hooks/useSkeleton.d.ts +12 -0
  63. package/modern/hooks/useSkeleton.js +51 -0
  64. package/modern/index.js +6 -2
  65. package/modern/text/component.d.ts +9 -1
  66. package/modern/text/component.js +24 -8
  67. package/modern/text/index.css +18 -18
  68. package/modern/text/index.js +5 -1
  69. package/modern/title/common.css +5 -5
  70. package/modern/title/component.d.ts +19 -2
  71. package/modern/title/component.js +16 -2
  72. package/modern/title/index.css +19 -19
  73. package/modern/title/index.js +7 -3
  74. package/modern/title-mobile/component.js +7 -3
  75. package/modern/title-mobile/index.css +11 -11
  76. package/modern/title-mobile/index.js +6 -2
  77. package/modern/title-responsive/component.js +7 -3
  78. package/modern/title-responsive/index.css +31 -31
  79. package/modern/title-responsive/index.js +6 -2
  80. package/modern/types.d.ts +12 -1
  81. package/package.json +4 -1
  82. package/src/hooks/index.ts +1 -0
  83. package/src/hooks/use-skeleton.module.css +5 -0
  84. package/src/hooks/useSkeleton.tsx +78 -0
  85. package/src/text/component.tsx +51 -22
  86. package/src/title/component.tsx +46 -18
  87. package/src/types.ts +14 -0
  88. package/text/component.d.ts +9 -1
  89. package/text/component.js +24 -9
  90. package/text/index.css +18 -18
  91. package/text/index.js +5 -1
  92. package/title/common.css +5 -5
  93. package/title/component.d.ts +19 -2
  94. package/title/component.js +16 -3
  95. package/title/index.css +19 -19
  96. package/title/index.js +7 -3
  97. package/title-mobile/component.js +7 -3
  98. package/title-mobile/index.css +11 -11
  99. package/title-mobile/index.js +6 -2
  100. package/title-responsive/component.js +7 -3
  101. package/title-responsive/index.css +31 -31
  102. package/title-responsive/index.js +6 -2
  103. package/types.d.ts +12 -1
  104. package/colors.module-1c06b16d.js +0 -6
  105. package/common.module-00fb3f71.js +0 -6
  106. package/esm/colors.module-d9f55bc3.js +0 -4
  107. package/esm/common.module-39c4c6a5.js +0 -4
  108. package/modern/colors.module-d0f9b310.js +0 -4
  109. package/modern/common.module-47d6bc91.js +0 -4
@@ -1,11 +1,15 @@
1
1
  import { __assign } from 'tslib';
2
2
  import React from 'react';
3
3
  import { Title } from '../title/component.js';
4
- import { c as commonStyles } from '../common.module-39c4c6a5.js';
4
+ import { c as commonStyles } from '../common.module-a0a4a875.js';
5
+ import 'react-merge-refs';
5
6
  import 'classnames';
6
- import '../colors.module-d9f55bc3.js';
7
+ import '../hooks/useSkeleton.js';
8
+ import '@alfalab/core-components-skeleton/esm';
9
+ import '@alfalab/hooks';
10
+ import '../colors.module-64858915.js';
7
11
 
8
- var styles = {"styrene-xlarge":"typography__styrene-xlarge_z4yoi","styrene-large":"typography__styrene-large_z4yoi","styrene-medium":"typography__styrene-medium_z4yoi","styrene-small":"typography__styrene-small_z4yoi","styrene-xsmall":"typography__styrene-xsmall_z4yoi","system-xlarge":"typography__system-xlarge_z4yoi","system-large":"typography__system-large_z4yoi","system-medium":"typography__system-medium_z4yoi","system-small":"typography__system-small_z4yoi","system-xsmall":"typography__system-xsmall_z4yoi","margins-xlarge":"typography__margins-xlarge_z4yoi","margins-large":"typography__margins-large_z4yoi","margins-medium":"typography__margins-medium_z4yoi","margins-small":"typography__margins-small_z4yoi","margins-xsmall":"typography__margins-xsmall_z4yoi"};
12
+ var styles = {"styrene-xlarge":"typography__styrene-xlarge_1h9yc","styrene-large":"typography__styrene-large_1h9yc","styrene-medium":"typography__styrene-medium_1h9yc","styrene-small":"typography__styrene-small_1h9yc","styrene-xsmall":"typography__styrene-xsmall_1h9yc","system-xlarge":"typography__system-xlarge_1h9yc","system-large":"typography__system-large_1h9yc","system-medium":"typography__system-medium_1h9yc","system-small":"typography__system-small_1h9yc","system-xsmall":"typography__system-xsmall_1h9yc","margins-xlarge":"typography__margins-xlarge_1h9yc","margins-large":"typography__margins-large_1h9yc","margins-medium":"typography__margins-medium_1h9yc","margins-small":"typography__margins-small_1h9yc","margins-xsmall":"typography__margins-xsmall_1h9yc"};
9
13
  require('./index.css')
10
14
 
11
15
  var TitleResponsive = function (props) { return (
@@ -1,4 +1,4 @@
1
- /* hash: 1av2i */
1
+ /* hash: s5eu3 */
2
2
  :root {
3
3
  } /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
4
4
  } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -20,68 +20,68 @@
20
20
  --font-family-styrene: 'Styrene UI', system-ui, -apple-system, 'Segoe UI', Roboto,
21
21
  'Helvetica Neue', Helvetica, sans-serif;
22
22
  } :root {
23
- } /* TODO: поменять медиа-запросы на миксины */ .typography__styrene-xlarge_z4yoi {
23
+ } /* TODO: поменять медиа-запросы на миксины */ .typography__styrene-xlarge_1h9yc {
24
24
  font-size: 34px;
25
25
  line-height: 40px;
26
26
  font-weight: 500;
27
27
  font-feature-settings: 'ss01';
28
28
  font-family: var(--font-family-styrene);
29
- } .typography__styrene-large_z4yoi {
29
+ } .typography__styrene-large_1h9yc {
30
30
  font-size: 30px;
31
31
  line-height: 36px;
32
32
  font-weight: 500;
33
33
  font-feature-settings: 'ss01';
34
34
  font-family: var(--font-family-styrene);
35
- } .typography__styrene-medium_z4yoi {
35
+ } .typography__styrene-medium_1h9yc {
36
36
  font-size: 26px;
37
37
  line-height: 32px;
38
38
  font-weight: 500;
39
39
  font-feature-settings: 'ss01';
40
40
  font-family: var(--font-family-styrene);
41
- } .typography__styrene-small_z4yoi {
41
+ } .typography__styrene-small_1h9yc {
42
42
  font-size: 20px;
43
43
  line-height: 28px;
44
44
  font-weight: 500;
45
45
  font-feature-settings: 'ss01';
46
46
  font-family: var(--font-family-styrene);
47
- } .typography__styrene-xsmall_z4yoi {
47
+ } .typography__styrene-xsmall_1h9yc {
48
48
  font-size: 16px;
49
49
  line-height: 20px;
50
50
  font-weight: 500;
51
51
  font-feature-settings: 'ss01';
52
52
  font-family: var(--font-family-styrene);
53
- } .typography__system-xlarge_z4yoi {
53
+ } .typography__system-xlarge_1h9yc {
54
54
  font-size: 34px;
55
55
  line-height: 40px;
56
56
  font-weight: 600;
57
- } .typography__system-large_z4yoi {
57
+ } .typography__system-large_1h9yc {
58
58
  font-size: 30px;
59
59
  line-height: 36px;
60
60
  font-weight: 600;
61
- } .typography__system-medium_z4yoi {
61
+ } .typography__system-medium_1h9yc {
62
62
  font-size: 26px;
63
63
  line-height: 32px;
64
64
  font-weight: 600;
65
- } .typography__system-small_z4yoi {
65
+ } .typography__system-small_1h9yc {
66
66
  font-size: 20px;
67
67
  line-height: 28px;
68
68
  font-weight: 600;
69
- } .typography__system-xsmall_z4yoi {
69
+ } .typography__system-xsmall_1h9yc {
70
70
  font-size: 16px;
71
71
  line-height: 20px;
72
72
  font-weight: 600;
73
- } .typography__margins-xlarge_z4yoi {
73
+ } .typography__margins-xlarge_1h9yc {
74
74
  margin: 0 0 var(--gap-xl);
75
- } .typography__margins-large_z4yoi {
75
+ } .typography__margins-large_1h9yc {
76
76
  margin: var(--gap-3xl) 0 var(--gap-m);
77
- } .typography__margins-medium_z4yoi {
77
+ } .typography__margins-medium_1h9yc {
78
78
  margin: var(--gap-3xl) 0 var(--gap-m);
79
- } .typography__margins-small_z4yoi {
79
+ } .typography__margins-small_1h9yc {
80
80
  margin: var(--gap-3xl) 0 var(--gap-m);
81
- } .typography__margins-xsmall_z4yoi {
81
+ } .typography__margins-xsmall_1h9yc {
82
82
  margin: var(--gap-3xl) 0 var(--gap-m);
83
83
  } @media screen and (min-width: 1024px) {
84
- .typography__styrene-xlarge_z4yoi {
84
+ .typography__styrene-xlarge_1h9yc {
85
85
  font-size: 48px;
86
86
  line-height: 64px;
87
87
  font-weight: 500;
@@ -89,7 +89,7 @@
89
89
  font-family: var(--font-family-styrene);
90
90
  }
91
91
 
92
- .typography__styrene-large_z4yoi {
92
+ .typography__styrene-large_1h9yc {
93
93
  font-size: 40px;
94
94
  line-height: 48px;
95
95
  font-weight: 500;
@@ -97,7 +97,7 @@
97
97
  font-family: var(--font-family-styrene);
98
98
  }
99
99
 
100
- .typography__styrene-medium_z4yoi {
100
+ .typography__styrene-medium_1h9yc {
101
101
  font-size: 32px;
102
102
  line-height: 40px;
103
103
  font-weight: 500;
@@ -105,7 +105,7 @@
105
105
  font-family: var(--font-family-styrene);
106
106
  }
107
107
 
108
- .typography__styrene-small_z4yoi {
108
+ .typography__styrene-small_1h9yc {
109
109
  font-size: 24px;
110
110
  line-height: 32px;
111
111
  font-weight: 500;
@@ -113,7 +113,7 @@
113
113
  font-family: var(--font-family-styrene);
114
114
  }
115
115
 
116
- .typography__styrene-xsmall_z4yoi {
116
+ .typography__styrene-xsmall_1h9yc {
117
117
  font-size: 20px;
118
118
  line-height: 24px;
119
119
  font-weight: 500;
@@ -121,53 +121,53 @@
121
121
  font-family: var(--font-family-styrene);
122
122
  }
123
123
 
124
- .typography__system-xlarge_z4yoi {
124
+ .typography__system-xlarge_1h9yc {
125
125
  font-size: 48px;
126
126
  line-height: 52px;
127
127
  font-weight: 700;
128
128
  }
129
129
 
130
- .typography__system-large_z4yoi {
130
+ .typography__system-large_1h9yc {
131
131
  font-size: 40px;
132
132
  line-height: 48px;
133
133
  font-weight: 700;
134
134
  }
135
135
 
136
- .typography__system-medium_z4yoi {
136
+ .typography__system-medium_1h9yc {
137
137
  font-size: 30px;
138
138
  line-height: 36px;
139
139
  font-weight: 700;
140
140
  }
141
141
 
142
- .typography__system-small_z4yoi {
142
+ .typography__system-small_1h9yc {
143
143
  font-size: 22px;
144
144
  line-height: 26px;
145
145
  font-weight: 700;
146
146
  }
147
147
 
148
- .typography__system-xsmall_z4yoi {
148
+ .typography__system-xsmall_1h9yc {
149
149
  font-size: 18px;
150
150
  line-height: 22px;
151
151
  font-weight: 700;
152
152
  }
153
153
 
154
- .typography__margins-xlarge_z4yoi {
154
+ .typography__margins-xlarge_1h9yc {
155
155
  margin: 0 0 var(--gap-xl);
156
156
  }
157
157
 
158
- .typography__margins-large_z4yoi {
158
+ .typography__margins-large_1h9yc {
159
159
  margin: var(--gap-4xl) 0 var(--gap-xl);
160
160
  }
161
161
 
162
- .typography__margins-medium_z4yoi {
162
+ .typography__margins-medium_1h9yc {
163
163
  margin: var(--gap-4xl) 0 var(--gap-xl);
164
164
  }
165
165
 
166
- .typography__margins-small_z4yoi {
166
+ .typography__margins-small_1h9yc {
167
167
  margin: var(--gap-3xl) 0 var(--gap-m);
168
168
  }
169
169
 
170
- .typography__margins-xsmall_z4yoi {
170
+ .typography__margins-xsmall_1h9yc {
171
171
  margin: var(--gap-3xl) 0 var(--gap-m);
172
172
  }
173
173
  }
@@ -2,6 +2,10 @@ export { TitleResponsive } from './component.js';
2
2
  import 'tslib';
3
3
  import 'react';
4
4
  import '../title/component.js';
5
+ import 'react-merge-refs';
5
6
  import 'classnames';
6
- import '../colors.module-d9f55bc3.js';
7
- import '../common.module-39c4c6a5.js';
7
+ import '../hooks/useSkeleton.js';
8
+ import '@alfalab/core-components-skeleton/esm';
9
+ import '@alfalab/hooks';
10
+ import '../colors.module-64858915.js';
11
+ import '../common.module-a0a4a875.js';
package/esm/types.d.ts CHANGED
@@ -1,2 +1,13 @@
1
1
  type TextElementType = HTMLParagraphElement | HTMLSpanElement | HTMLDivElement;
2
- export { TextElementType };
2
+ type WidthUnit = number | string;
3
+ type TextSkeletonProps = {
4
+ /**
5
+ * Кол-во строк текста
6
+ */
7
+ rows?: number;
8
+ /**
9
+ * Ширина строки
10
+ */
11
+ width?: WidthUnit | WidthUnit[];
12
+ };
13
+ export { TextElementType, TextSkeletonProps };
@@ -0,0 +1 @@
1
+ export * from "./useSkeleton";
package/hooks/index.js ADDED
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var hooks_useSkeleton = require('./useSkeleton.js');
6
+ require('tslib');
7
+ require('react');
8
+ require('@alfalab/core-components-skeleton');
9
+ require('@alfalab/hooks');
10
+
11
+
12
+
13
+ exports.useSkeleton = hooks_useSkeleton.useSkeleton;
@@ -0,0 +1,20 @@
1
+ /* hash: svslz */
2
+ :root {
3
+ } /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
4
+ } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
5
+ } :root {
6
+ } :root {
7
+
8
+ /* Hard */
9
+
10
+ /* Up */
11
+
12
+ /* Hard up */
13
+ } :root {
14
+ --border-radius-pill: 99px;
15
+ } :root {
16
+ } :root {
17
+ } :root {
18
+ } .typography__skeletonText_ywqd3.typography__skeletonText_ywqd3 {
19
+ border-radius: var(--border-radius-pill);
20
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { TextSkeletonProps } from "../types";
4
+ type SkeletonProps = {
5
+ wrapperClassName?: string;
6
+ dataTestId?: string;
7
+ };
8
+ declare function useSkeleton(showSkeleton?: boolean, skeletonProps?: TextSkeletonProps): {
9
+ renderSkeleton: (props: SkeletonProps) => React.JSX.Element | null;
10
+ textRef: React.RefObject<HTMLElement>;
11
+ };
12
+ export { useSkeleton };
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+ var coreComponentsSkeleton = require('@alfalab/core-components-skeleton');
8
+ var hooks = require('@alfalab/hooks');
9
+
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
13
+
14
+ var styles = {"skeletonText":"typography__skeletonText_ywqd3"};
15
+ require('./use-skeleton.css')
16
+
17
+ function useSkeleton(showSkeleton, skeletonProps) {
18
+ var _a = React.useState(), skeletonParams = _a[0], setSkeletonParams = _a[1];
19
+ var textRef = React.useRef(null);
20
+ hooks.useLayoutEffect_SAFE_FOR_SSR(function () {
21
+ if (showSkeleton && textRef.current) {
22
+ var style = getComputedStyle(textRef.current);
23
+ var textHeight = textRef.current.offsetHeight;
24
+ var fontSize = parseInt(style.fontSize, 10);
25
+ var lineHeight = parseInt(style.lineHeight, 10);
26
+ var padding = (lineHeight - fontSize) % 2 === 0
27
+ ? (lineHeight - fontSize) / 2
28
+ : (lineHeight - fontSize - 1) / 2;
29
+ var rows = (skeletonProps === null || skeletonProps === void 0 ? void 0 : skeletonProps.rows)
30
+ ? skeletonProps === null || skeletonProps === void 0 ? void 0 : skeletonProps.rows
31
+ : Math.ceil(textHeight / lineHeight);
32
+ setSkeletonParams({
33
+ height: lineHeight - padding * 2,
34
+ padding: "".concat(padding, "px 0"),
35
+ rows: rows,
36
+ });
37
+ }
38
+ else {
39
+ setSkeletonParams(undefined);
40
+ }
41
+ }, [showSkeleton, skeletonProps === null || skeletonProps === void 0 ? void 0 : skeletonProps.rows]);
42
+ var renderSkeleton = function (props) {
43
+ if (showSkeleton && skeletonParams) {
44
+ return (React__default.default.createElement("div", { className: props.wrapperClassName, "data-test-id": props.dataTestId }, tslib.__spreadArray([], Array(skeletonParams.rows), true).map(function (_, idx) {
45
+ var width = Array.isArray(skeletonProps === null || skeletonProps === void 0 ? void 0 : skeletonProps.width)
46
+ ? skeletonProps === null || skeletonProps === void 0 ? void 0 : skeletonProps.width[idx]
47
+ : skeletonProps === null || skeletonProps === void 0 ? void 0 : skeletonProps.width;
48
+ return (
49
+ // eslint-disable-next-line react/no-array-index-key
50
+ React__default.default.createElement("div", { key: idx, style: { width: width, padding: skeletonParams.padding } },
51
+ React__default.default.createElement(coreComponentsSkeleton.Skeleton, { visible: true, className: styles.skeletonText },
52
+ React__default.default.createElement("div", { style: { height: skeletonParams.height } }))));
53
+ })));
54
+ }
55
+ return null;
56
+ };
57
+ return { renderSkeleton: renderSkeleton, textRef: textRef };
58
+ }
59
+
60
+ exports.useSkeleton = useSkeleton;
package/index.js CHANGED
@@ -7,11 +7,15 @@ var presets = require('./presets.js');
7
7
  require('./text/component.js');
8
8
  require('tslib');
9
9
  require('react');
10
+ require('react-merge-refs');
10
11
  require('classnames');
11
- require('./colors.module-1c06b16d.js');
12
+ require('./hooks/useSkeleton.js');
13
+ require('@alfalab/core-components-skeleton');
14
+ require('@alfalab/hooks');
15
+ require('./colors.module-69def6bf.js');
12
16
  require('./title/index.js');
13
17
  require('./title/component.js');
14
- require('./common.module-00fb3f71.js');
18
+ require('./common.module-59cc11ca.js');
15
19
  require('./title-mobile/component.js');
16
20
  require('./title-responsive/component.js');
17
21
 
package/modern/colors.css CHANGED
@@ -1,4 +1,4 @@
1
- /* hash: xlwka */
1
+ /* hash: qj5ei */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-accent: #ef3124;
@@ -33,42 +33,42 @@
33
33
  } :root {
34
34
  } :root {
35
35
  } :root {
36
- } /* colors */ .typography__tertiary_j1wcp {
36
+ } /* colors */ .typography__tertiary_13nf8 {
37
37
  color: var(--color-light-text-tertiary);
38
- } .typography__disabled_j1wcp {
38
+ } .typography__disabled_13nf8 {
39
39
  color: var(--color-light-text-disabled);
40
- } .typography__accent_j1wcp {
40
+ } .typography__accent_13nf8 {
41
41
  color: var(--color-light-text-accent);
42
- } .typography__primary_j1wcp {
42
+ } .typography__primary_13nf8 {
43
43
  color: var(--color-light-text-primary);
44
- } .typography__attention_j1wcp {
44
+ } .typography__attention_13nf8 {
45
45
  color: var(--color-light-text-attention);
46
- } .typography__positive_j1wcp {
46
+ } .typography__positive_13nf8 {
47
47
  color: var(--color-light-text-positive);
48
- } .typography__secondary_j1wcp {
48
+ } .typography__secondary_13nf8 {
49
49
  color: var(--color-light-text-secondary);
50
- } .typography__tertiary-inverted_j1wcp {
50
+ } .typography__tertiary-inverted_13nf8 {
51
51
  color: var(--color-light-text-tertiary-inverted);
52
- } .typography__primary-inverted_j1wcp {
52
+ } .typography__primary-inverted_13nf8 {
53
53
  color: var(--color-light-text-primary-inverted);
54
- } .typography__secondary-inverted_j1wcp {
54
+ } .typography__secondary-inverted_13nf8 {
55
55
  color: var(--color-light-text-secondary-inverted);
56
- } .typography__link_j1wcp {
56
+ } .typography__link_13nf8 {
57
57
  color: var(--color-light-text-link);
58
- } .typography__negative_j1wcp {
58
+ } .typography__negative_13nf8 {
59
59
  color: var(--color-light-text-negative);
60
- } .typography__static-primary-light_j1wcp {
60
+ } .typography__static-primary-light_13nf8 {
61
61
  color: var(--color-static-text-primary-light);
62
- } .typography__static-secondary-light_j1wcp {
62
+ } .typography__static-secondary-light_13nf8 {
63
63
  color: var(--color-static-text-secondary-light);
64
- } .typography__static-tertiary-light_j1wcp {
64
+ } .typography__static-tertiary-light_13nf8 {
65
65
  color: var(--color-static-text-tertiary-light);
66
- } .typography__static-primary-dark_j1wcp {
66
+ } .typography__static-primary-dark_13nf8 {
67
67
  color: var(--color-static-text-primary-dark);
68
- } .typography__static-secondary-dark_j1wcp {
68
+ } .typography__static-secondary-dark_13nf8 {
69
69
  color: var(--color-static-text-secondary-dark);
70
- } .typography__static-tertiary-dark_j1wcp {
70
+ } .typography__static-tertiary-dark_13nf8 {
71
71
  color: var(--color-static-text-tertiary-dark);
72
- } .typography__static-accent_j1wcp {
72
+ } .typography__static-accent_13nf8 {
73
73
  color: var(--color-static-text-accent);
74
74
  }
@@ -0,0 +1,4 @@
1
+ const colors = {"tertiary":"typography__tertiary_13nf8","disabled":"typography__disabled_13nf8","accent":"typography__accent_13nf8","primary":"typography__primary_13nf8","attention":"typography__attention_13nf8","positive":"typography__positive_13nf8","secondary":"typography__secondary_13nf8","tertiary-inverted":"typography__tertiary-inverted_13nf8","primary-inverted":"typography__primary-inverted_13nf8","secondary-inverted":"typography__secondary-inverted_13nf8","link":"typography__link_13nf8","negative":"typography__negative_13nf8","static-primary-light":"typography__static-primary-light_13nf8","static-secondary-light":"typography__static-secondary-light_13nf8","static-tertiary-light":"typography__static-tertiary-light_13nf8","static-primary-dark":"typography__static-primary-dark_13nf8","static-secondary-dark":"typography__static-secondary-dark_13nf8","static-tertiary-dark":"typography__static-tertiary-dark_13nf8","static-accent":"typography__static-accent_13nf8"};
2
+ require('./colors.css')
3
+
4
+ export { colors as c };
@@ -0,0 +1,4 @@
1
+ const commonStyles = {"component":"typography__component_wh2dw","bold":"typography__bold_wh2dw","medium":"typography__medium_wh2dw","regular":"typography__regular_wh2dw"};
2
+ require('./title/common.css')
3
+
4
+ export { commonStyles as c };
@@ -3,10 +3,14 @@ import { Title } from './title/index.js';
3
3
  import { TitleMobile } from './title-mobile/component.js';
4
4
  import { TitleResponsive } from './title-responsive/component.js';
5
5
  import 'react';
6
+ import 'react-merge-refs';
6
7
  import 'classnames';
7
- import './colors.module-d0f9b310.js';
8
+ import './hooks/useSkeleton.js';
9
+ import '@alfalab/core-components-skeleton/modern';
10
+ import '@alfalab/hooks';
11
+ import './colors.module-58e8caae.js';
8
12
  import './title/component.js';
9
- import './common.module-47d6bc91.js';
13
+ import './common.module-3d6095da.js';
10
14
 
11
15
  const Typography = {
12
16
  Title,
@@ -0,0 +1 @@
1
+ export * from "./useSkeleton";
@@ -0,0 +1,4 @@
1
+ export { useSkeleton } from './useSkeleton.js';
2
+ import 'react';
3
+ import '@alfalab/core-components-skeleton/modern';
4
+ import '@alfalab/hooks';
@@ -0,0 +1,20 @@
1
+ /* hash: svslz */
2
+ :root {
3
+ } /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
4
+ } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
5
+ } :root {
6
+ } :root {
7
+
8
+ /* Hard */
9
+
10
+ /* Up */
11
+
12
+ /* Hard up */
13
+ } :root {
14
+ --border-radius-pill: 99px;
15
+ } :root {
16
+ } :root {
17
+ } :root {
18
+ } .typography__skeletonText_ywqd3.typography__skeletonText_ywqd3 {
19
+ border-radius: var(--border-radius-pill);
20
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { TextSkeletonProps } from "../types";
4
+ type SkeletonProps = {
5
+ wrapperClassName?: string;
6
+ dataTestId?: string;
7
+ };
8
+ declare function useSkeleton(showSkeleton?: boolean, skeletonProps?: TextSkeletonProps): {
9
+ renderSkeleton: (props: SkeletonProps) => React.JSX.Element | null;
10
+ textRef: React.RefObject<HTMLElement>;
11
+ };
12
+ export { useSkeleton };
@@ -0,0 +1,51 @@
1
+ import React, { useState, useRef } from 'react';
2
+ import { Skeleton } from '@alfalab/core-components-skeleton/modern';
3
+ import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
4
+
5
+ const styles = {"skeletonText":"typography__skeletonText_ywqd3"};
6
+ require('./use-skeleton.css')
7
+
8
+ function useSkeleton(showSkeleton, skeletonProps) {
9
+ const [skeletonParams, setSkeletonParams] = useState();
10
+ const textRef = useRef(null);
11
+ useLayoutEffect_SAFE_FOR_SSR(() => {
12
+ if (showSkeleton && textRef.current) {
13
+ const style = getComputedStyle(textRef.current);
14
+ const textHeight = textRef.current.offsetHeight;
15
+ const fontSize = parseInt(style.fontSize, 10);
16
+ const lineHeight = parseInt(style.lineHeight, 10);
17
+ const padding = (lineHeight - fontSize) % 2 === 0
18
+ ? (lineHeight - fontSize) / 2
19
+ : (lineHeight - fontSize - 1) / 2;
20
+ const rows = skeletonProps?.rows
21
+ ? skeletonProps?.rows
22
+ : Math.ceil(textHeight / lineHeight);
23
+ setSkeletonParams({
24
+ height: lineHeight - padding * 2,
25
+ padding: `${padding}px 0`,
26
+ rows,
27
+ });
28
+ }
29
+ else {
30
+ setSkeletonParams(undefined);
31
+ }
32
+ }, [showSkeleton, skeletonProps?.rows]);
33
+ const renderSkeleton = (props) => {
34
+ if (showSkeleton && skeletonParams) {
35
+ return (React.createElement("div", { className: props.wrapperClassName, "data-test-id": props.dataTestId }, [...Array(skeletonParams.rows)].map((_, idx) => {
36
+ const width = Array.isArray(skeletonProps?.width)
37
+ ? skeletonProps?.width[idx]
38
+ : skeletonProps?.width;
39
+ return (
40
+ // eslint-disable-next-line react/no-array-index-key
41
+ React.createElement("div", { key: idx, style: { width, padding: skeletonParams.padding } },
42
+ React.createElement(Skeleton, { visible: true, className: styles.skeletonText },
43
+ React.createElement("div", { style: { height: skeletonParams.height } }))));
44
+ })));
45
+ }
46
+ return null;
47
+ };
48
+ return { renderSkeleton, textRef };
49
+ }
50
+
51
+ export { useSkeleton };
package/modern/index.js CHANGED
@@ -2,10 +2,14 @@ export { Typography } from './component.js';
2
2
  export { typographyPresets } from './presets.js';
3
3
  import './text/component.js';
4
4
  import 'react';
5
+ import 'react-merge-refs';
5
6
  import 'classnames';
6
- import './colors.module-d0f9b310.js';
7
+ import './hooks/useSkeleton.js';
8
+ import '@alfalab/core-components-skeleton/modern';
9
+ import '@alfalab/hooks';
10
+ import './colors.module-58e8caae.js';
7
11
  import './title/index.js';
8
12
  import './title/component.js';
9
- import './common.module-47d6bc91.js';
13
+ import './common.module-3d6095da.js';
10
14
  import './title-mobile/component.js';
11
15
  import './title-responsive/component.js';
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import { HTMLAttributes } from "react";
4
4
  import { Color } from "../colors";
5
- import { TextElementType } from "../types";
5
+ import { TextElementType, TextSkeletonProps } from "../types";
6
6
  type NativeProps = HTMLAttributes<HTMLSpanElement>;
7
7
  type TextBaseProps = {
8
8
  /**
@@ -45,6 +45,14 @@ type TextBaseProps = {
45
45
  * Количество строк (не поддерживает IE)
46
46
  */
47
47
  rowLimit?: 1 | 2 | 3;
48
+ /**
49
+ * Показать скелетон
50
+ */
51
+ showSkeleton?: boolean;
52
+ /**
53
+ * Пропы для скелетона
54
+ */
55
+ skeletonProps?: TextSkeletonProps;
48
56
  };
49
57
  type TextPTagProps = Omit<TextBaseProps, 'tag' | 'defaultMargins'> & {
50
58
  tag?: 'p';