@gravity-ui/chartkit 0.7.2

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 (79) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/LICENSE +21 -0
  3. package/README.md +64 -0
  4. package/build/components/ChartKit.css +4 -0
  5. package/build/components/ChartKit.d.ts +19 -0
  6. package/build/components/ChartKit.js +42 -0
  7. package/build/components/ErrorBoundary/ErrorBoundary.d.ts +18 -0
  8. package/build/components/ErrorBoundary/ErrorBoundary.js +27 -0
  9. package/build/components/ErrorView/ErrorView.d.ts +7 -0
  10. package/build/components/ErrorView/ErrorView.js +6 -0
  11. package/build/components/Loader/Loader.css +7 -0
  12. package/build/components/Loader/Loader.d.ts +6 -0
  13. package/build/components/Loader/Loader.js +9 -0
  14. package/build/constants/common.d.ts +1 -0
  15. package/build/constants/common.js +2 -0
  16. package/build/constants/index.d.ts +1 -0
  17. package/build/constants/index.js +1 -0
  18. package/build/i18n/index.d.ts +7 -0
  19. package/build/i18n/index.js +10 -0
  20. package/build/i18n/keysets/en.json +11 -0
  21. package/build/i18n/keysets/ru.json +11 -0
  22. package/build/index.d.ts +5 -0
  23. package/build/index.js +4 -0
  24. package/build/libs/chartkit-error/__tests__/chartkit-error.d.ts +1 -0
  25. package/build/libs/chartkit-error/__tests__/chartkit-error.js +27 -0
  26. package/build/libs/chartkit-error/chartkit-error.d.ts +16 -0
  27. package/build/libs/chartkit-error/chartkit-error.js +19 -0
  28. package/build/libs/index.d.ts +3 -0
  29. package/build/libs/index.js +2 -0
  30. package/build/libs/settings/__tests__/settings.test.d.ts +1 -0
  31. package/build/libs/settings/__tests__/settings.test.js +7 -0
  32. package/build/libs/settings/settings.d.ts +16 -0
  33. package/build/libs/settings/settings.js +43 -0
  34. package/build/plugins/index.d.ts +4 -0
  35. package/build/plugins/index.js +2 -0
  36. package/build/plugins/indicator/__stories__/Indicator.stories.d.ts +4 -0
  37. package/build/plugins/indicator/__stories__/Indicator.stories.js +45 -0
  38. package/build/plugins/indicator/index.d.ts +2 -0
  39. package/build/plugins/indicator/index.js +5 -0
  40. package/build/plugins/indicator/renderer/IndicatorItem.d.ts +6 -0
  41. package/build/plugins/indicator/renderer/IndicatorItem.js +15 -0
  42. package/build/plugins/indicator/renderer/IndicatorWidget.css +62 -0
  43. package/build/plugins/indicator/renderer/IndicatorWidget.d.ts +6 -0
  44. package/build/plugins/indicator/renderer/IndicatorWidget.js +28 -0
  45. package/build/plugins/indicator/types.d.ts +21 -0
  46. package/build/plugins/indicator/types.js +1 -0
  47. package/build/plugins/yagr/__stories__/Yagr.stories.d.ts +4 -0
  48. package/build/plugins/yagr/__stories__/Yagr.stories.js +21 -0
  49. package/build/plugins/yagr/__stories__/mocks/line10.d.ts +2 -0
  50. package/build/plugins/yagr/__stories__/mocks/line10.js +66 -0
  51. package/build/plugins/yagr/index.d.ts +2 -0
  52. package/build/plugins/yagr/index.js +5 -0
  53. package/build/plugins/yagr/renderer/YagrWidget.css +4 -0
  54. package/build/plugins/yagr/renderer/YagrWidget.d.ts +7 -0
  55. package/build/plugins/yagr/renderer/YagrWidget.js +196 -0
  56. package/build/plugins/yagr/renderer/polyfills.d.ts +1 -0
  57. package/build/plugins/yagr/renderer/polyfills.js +17 -0
  58. package/build/plugins/yagr/renderer/synchronizeTooltipTablesCellsWidth.d.ts +1 -0
  59. package/build/plugins/yagr/renderer/synchronizeTooltipTablesCellsWidth.js +43 -0
  60. package/build/plugins/yagr/renderer/tooltip/helpers/escapeHTML.d.ts +1 -0
  61. package/build/plugins/yagr/renderer/tooltip/helpers/escapeHTML.js +5 -0
  62. package/build/plugins/yagr/renderer/tooltip/tooltip.css +368 -0
  63. package/build/plugins/yagr/renderer/tooltip/tooltip.d.ts +141 -0
  64. package/build/plugins/yagr/renderer/tooltip/tooltip.js +229 -0
  65. package/build/plugins/yagr/types.d.ts +21 -0
  66. package/build/plugins/yagr/types.js +1 -0
  67. package/build/types/index.d.ts +33 -0
  68. package/build/types/index.js +1 -0
  69. package/build/types/widget.d.ts +13 -0
  70. package/build/types/widget.js +1 -0
  71. package/build/utils/__tests__/common.test.d.ts +1 -0
  72. package/build/utils/__tests__/common.test.js +9 -0
  73. package/build/utils/common.d.ts +1 -0
  74. package/build/utils/common.js +8 -0
  75. package/build/utils/index.d.ts +2 -0
  76. package/build/utils/index.js +2 -0
  77. package/build/utils/react.d.ts +1 -0
  78. package/build/utils/react.js +4 -0
  79. package/package.json +93 -0
@@ -0,0 +1,368 @@
1
+ .chartkit-highcharts-tooltip-container_type_timeline {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
5
+
6
+ .chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-header td:last-child {
7
+ padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
8
+ }
9
+
10
+ .chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-footer td:last-child {
11
+ padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
12
+ }
13
+
14
+ .chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-row td:last-child {
15
+ padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
16
+ }
17
+
18
+ .chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-rows__summ-tr td:last-child {
19
+ padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
20
+ }
21
+
22
+ ._tooltip {
23
+ border-radius: 5px;
24
+ background: var(--yc-color-infographics-tooltip-bg);
25
+ background-color: var(--yc-color-infographics-tooltip-bg);
26
+ color: var(--yc-color-text-primary);
27
+ font-size: 12px;
28
+ overflow: hidden;
29
+ box-sizing: border-box;
30
+ box-shadow: 0px 2px 12px rgba(0, 0, 0, 0.15);
31
+ }
32
+
33
+ ._tooltip_split-tooltip {
34
+ border: none;
35
+ border-radius: 0;
36
+ box-shadow: none;
37
+ padding-bottom: 12px;
38
+ }
39
+
40
+ ._tooltip_split-tooltip table {
41
+ table-layout: fixed;
42
+ }
43
+
44
+ ._tooltip_split-tooltip ._tooltip-rows__table tbody {
45
+ display: table-row-group;
46
+ }
47
+
48
+ @supports (padding: max(0px)) {
49
+ ._tooltip_split-tooltip {
50
+ padding-bottom: max(12px, env(safe-area-inset-bottom));
51
+ }
52
+ }
53
+ ._tooltip table {
54
+ width: 100%;
55
+ }
56
+
57
+ ._tooltip table td {
58
+ box-sizing: border-box;
59
+ }
60
+
61
+ ._tooltip table td:last-child {
62
+ text-align: right;
63
+ }
64
+
65
+ ._tooltip-fake-row {
66
+ height: 5px;
67
+ }
68
+
69
+ ._tooltip-fake-row-heightless {
70
+ height: 0;
71
+ }
72
+
73
+ ._tooltip-fake-row-heightless td {
74
+ padding: 0;
75
+ }
76
+
77
+ ._tooltip-fake-row td:first-child {
78
+ width: 28px;
79
+ }
80
+
81
+ ._tooltip-row {
82
+ width: 100%;
83
+ }
84
+
85
+ ._tooltip-row td:first-child {
86
+ padding-left: 14px;
87
+ }
88
+
89
+ ._tooltip-row td:last-child {
90
+ padding-right: 18px;
91
+ }
92
+
93
+ ._tooltip-row td {
94
+ padding: 2px 4px;
95
+ }
96
+
97
+ ._tooltip-row td._tooltip-rows__value-td, ._tooltip-row td._tooltip-rows__diff-td {
98
+ padding-bottom: 1px;
99
+ }
100
+
101
+ ._tooltip-selected-row {
102
+ font-weight: 600;
103
+ }
104
+
105
+ ._tooltip-comment-row td:last-child {
106
+ padding-right: 18px;
107
+ }
108
+
109
+ ._tooltip-right__td {
110
+ padding-right: 14px;
111
+ }
112
+
113
+ ._tooltip-right__td_with-split-tooltip {
114
+ border: none;
115
+ }
116
+
117
+ ._tooltip-date {
118
+ padding: 10px 14px 4px;
119
+ max-width: 450px;
120
+ overflow: hidden;
121
+ text-overflow: ellipsis;
122
+ white-space: nowrap;
123
+ font-size: 13px;
124
+ font-weight: bold;
125
+ }
126
+
127
+ ._tooltip-date-dayofweek {
128
+ display: inline-block;
129
+ }
130
+
131
+ ._tooltip-date-dayofweek_weekend {
132
+ color: #ff0000;
133
+ }
134
+
135
+ ._tooltip-rows__table {
136
+ border-spacing: 0;
137
+ width: 10px;
138
+ }
139
+
140
+ ._tooltip-rows__table-footer {
141
+ display: table;
142
+ width: 100%;
143
+ }
144
+
145
+ ._tooltip-rows__table thead {
146
+ display: table;
147
+ width: 100%;
148
+ }
149
+
150
+ ._tooltip-rows__table thead._tooltip-header tr:not(._tooltip-fake-row):first-child td {
151
+ padding-top: 6px;
152
+ padding-bottom: 6px;
153
+ border-bottom: 1px solid var(--yc-color-line-generic);
154
+ }
155
+
156
+ ._tooltip-rows__table tbody {
157
+ display: block;
158
+ overflow-y: auto;
159
+ overflow-x: hidden;
160
+ }
161
+
162
+ ._tooltip-rows__table tbody._tooltip-footer {
163
+ width: 100%;
164
+ display: table;
165
+ }
166
+
167
+ ._tooltip-rows__table tbody._tooltip-list {
168
+ overflow-x: hidden;
169
+ }
170
+
171
+ ._tooltip-rows__table tbody._tooltip-list ._tooltip-row-dark-bg {
172
+ background-color: var(--yc-color-base-generic);
173
+ }
174
+
175
+ ._tooltip-rows__table tbody ._hidden-rows-sum._hidden-rows-sum-dark-bg {
176
+ background-color: var(--yc-color-base-generic);
177
+ }
178
+
179
+ ._tooltip-rows__table tbody ._hidden-rows-sum td {
180
+ padding-top: 2px;
181
+ padding-bottom: 2px;
182
+ }
183
+
184
+ ._tooltip-rows__table tbody td._hidden-rows-number {
185
+ text-align: left;
186
+ padding-right: 20px;
187
+ }
188
+
189
+ ._tooltip-rows__table tbody td._hidden-rows-value {
190
+ font-family: "Consolas", "Menlo", "Ubuntu Mono", monospace;
191
+ word-spacing: -3px;
192
+ }
193
+
194
+ ._tooltip-rows__bubble-div {
195
+ display: inline-block;
196
+ width: 12px;
197
+ height: 6px;
198
+ margin-left: 1px;
199
+ margin-bottom: 1px;
200
+ border-radius: 1px;
201
+ }
202
+
203
+ ._tooltip-rows__shape-div {
204
+ width: 38px;
205
+ display: flex;
206
+ align-items: center;
207
+ height: 100%;
208
+ }
209
+
210
+ ._tooltip-rows__shape-td {
211
+ height: 20px;
212
+ }
213
+
214
+ ._tooltip-rows__percent-td {
215
+ font-family: "Consolas", "Menlo", "Ubuntu Mono", monospace;
216
+ word-spacing: -3px;
217
+ padding-left: 12px;
218
+ white-space: nowrap;
219
+ }
220
+
221
+ ._tooltip-rows__diff-td {
222
+ font-family: "Consolas", "Menlo", "Ubuntu Mono", monospace;
223
+ word-spacing: -3px;
224
+ padding-left: 3px;
225
+ padding-right: 3px;
226
+ white-space: nowrap;
227
+ }
228
+
229
+ ._tooltip-rows__comment-left-td {
230
+ position: relative;
231
+ }
232
+
233
+ ._tooltip-rows__comment-left-div {
234
+ left: 2px;
235
+ position: absolute;
236
+ top: -7px;
237
+ bottom: 6px;
238
+ width: 10px;
239
+ }
240
+
241
+ ._tooltip-rows__comment-div {
242
+ position: relative;
243
+ padding-left: 14px;
244
+ text-align: left;
245
+ font-size: 10px;
246
+ width: auto;
247
+ white-space: normal;
248
+ letter-spacing: 0.2px;
249
+ font-weight: normal;
250
+ line-height: 1.3;
251
+ color: #aaaaaa;
252
+ }
253
+
254
+ ._tooltip-rows__bubble-td {
255
+ width: 28px;
256
+ }
257
+
258
+ ._tooltip-rows__value-td {
259
+ font-family: "Consolas", "Menlo", "Ubuntu Mono", monospace;
260
+ word-spacing: -3px;
261
+ white-space: nowrap;
262
+ padding-left: 12px;
263
+ }
264
+
265
+ ._tooltip-rows__value-td_selected {
266
+ text-decoration: underline;
267
+ }
268
+
269
+ ._tooltip-rows__name-td {
270
+ text-align: left;
271
+ white-space: nowrap;
272
+ padding-left: 10px;
273
+ max-width: 400px;
274
+ overflow: hidden;
275
+ text-overflow: ellipsis;
276
+ }
277
+
278
+ ._tooltip-rows__name-td_selected {
279
+ text-decoration: underline;
280
+ }
281
+
282
+ ._tooltip-rows__summ-td {
283
+ padding: 6px 0 6px 3px;
284
+ color: var(--yc-color-text-complementary);
285
+ font-size: 12px;
286
+ border-top: 1px solid var(--yc-color-line-generic);
287
+ }
288
+
289
+ ._tooltip-rows__summ-td-value {
290
+ font-family: "Consolas", "Menlo", "Ubuntu Mono", monospace;
291
+ word-spacing: -3px;
292
+ }
293
+
294
+ ._tooltip-rows__summ-td:first-child {
295
+ padding-left: 15px;
296
+ text-align: left;
297
+ }
298
+
299
+ ._tooltip-rows__summ-td:last-child {
300
+ padding-right: 18px;
301
+ text-align: right;
302
+ }
303
+
304
+ ._tooltip-left__td {
305
+ vertical-align: top;
306
+ }
307
+
308
+ ._tooltip-right__td {
309
+ vertical-align: top;
310
+ opacity: 0.9;
311
+ border-left: 1px solid var(--yc-color-line-generic);
312
+ white-space: normal;
313
+ font-size: 8pt;
314
+ position: relative;
315
+ min-width: 120px;
316
+ max-width: 150px;
317
+ padding-left: 10px;
318
+ }
319
+
320
+ ._tooltip-right__holiday-div {
321
+ padding-bottom: 5px;
322
+ display: flex;
323
+ align-items: center;
324
+ text-align: left;
325
+ }
326
+
327
+ ._tooltip-right__holiday-emoji {
328
+ font-size: 20px;
329
+ }
330
+
331
+ ._tooltip-right__holiday-region {
332
+ color: #ffffff;
333
+ letter-spacing: 1px;
334
+ display: inline-block;
335
+ padding-left: 5px;
336
+ }
337
+
338
+ ._tooltip-right__traf-div {
339
+ text-align: left;
340
+ border-top: 3px solid;
341
+ padding-top: 3px;
342
+ font-size: 10px;
343
+ line-height: 1.3;
344
+ white-space: pre-line;
345
+ padding-bottom: 10px;
346
+ margin-top: 9px;
347
+ word-break: break-word;
348
+ }
349
+
350
+ ._tooltip-right__traf-div_for-split-tooltip {
351
+ color: var(--yc-color-text-secondary);
352
+ padding-left: 8px;
353
+ border-top: none;
354
+ border-left: 2px solid;
355
+ margin-left: 6px;
356
+ margin-top: 0;
357
+ padding-top: 0;
358
+ padding-bottom: 0;
359
+ margin-bottom: 5px;
360
+ }
361
+
362
+ ._tooltip-right__traf-div:not(:first-child) {
363
+ margin-top: 7px;
364
+ }
365
+
366
+ ._tooltip-right__margin-bot {
367
+ margin-bottom: 7px;
368
+ }
@@ -0,0 +1,141 @@
1
+ import './tooltip.css';
2
+ export declare const SERIES_NAME_DATA_ATTRIBUTE = "data-series-name";
3
+ export declare const SERIES_IDX_DATA_ATTRIBUTE = "data-series-idx";
4
+ export declare const TOOLTIP_CONTAINER_CLASS_NAME = "_tooltip";
5
+ export declare const TOOLTIP_ROW_NAME_CLASS_NANE = "_tooltip-rows__name-td";
6
+ export declare const TOOLTIP_ROW_CLASS_NAME = "_tooltip-row";
7
+ export declare const TOOLTIP_HEADER_CLASS_NAME = "_tooltip-header";
8
+ export declare const TOOLTIP_LIST_CLASS_NAME = "_tooltip-list";
9
+ export declare const TOOLTIP_FOOTER_CLASS_NAME = "_tooltip-footer";
10
+ declare type Tooltip = any;
11
+ export interface TooltipData {
12
+ /**
13
+ * Массив строк выводящихся в тултипе (см. TooltipLine)
14
+ */
15
+ lines: Array<TooltipLine>;
16
+ /**
17
+ * массив комментариев (задаются в диалоге комментариев)
18
+ */
19
+ xComments?: Array<{
20
+ /**
21
+ * текст комментария
22
+ */
23
+ text: string;
24
+ /**
25
+ * цвет отображающийся над комментарием
26
+ */
27
+ color: string;
28
+ }>;
29
+ /**
30
+ * текст комментария (задаётся через manageTooltipConfig)
31
+ */
32
+ commentDateText?: string;
33
+ /**
34
+ * флаг, указывающий что нужно всегда дублировать активную строку выводя её поверх основного списка (дефолтное
35
+ * поведение - активная строка выводится поверх основного списка только если "не поместилась" в тултип)
36
+ */
37
+ activeRowAlwaysFirstInTooltip?: boolean;
38
+ /**
39
+ * флаг, указыващий что чарт отображается в режиме split tooltip
40
+ */
41
+ splitTooltip?: boolean;
42
+ /**
43
+ * текст хедера тултипа
44
+ */
45
+ tooltipHeader?: string;
46
+ /**
47
+ * флаг, указывающий, что в тултипе выводится колонка с названием строки
48
+ */
49
+ shared?: boolean;
50
+ /**
51
+ * флаг, указывающий, что в тултипе выводится колонка с процентным значением
52
+ */
53
+ withPercent?: boolean;
54
+ /**
55
+ * флаг, указывающий, что в тултипе выводится колонка с diff-ом
56
+ */
57
+ useCompareFrom?: boolean;
58
+ /**
59
+ * флаг, указывающий, что в тултипе выводится блок с информацией о праздничном дне
60
+ */
61
+ holiday?: boolean;
62
+ /**
63
+ * название праздничного дня
64
+ */
65
+ holidayText?: string;
66
+ /**
67
+ * регион для которого актуален праздничный день
68
+ */
69
+ region?: string;
70
+ /**
71
+ * сумма значений выводящихся в тултипе строк
72
+ */
73
+ sum?: number | string;
74
+ /**
75
+ * количество скрытых строк "не поместившихся" в тултип
76
+ */
77
+ hiddenRowsNumber: number;
78
+ /**
79
+ * сумма значений скрытых ("не поместившихся" в тултип) строк
80
+ */
81
+ hiddenRowsSum?: number | string;
82
+ }
83
+ export interface TooltipLine {
84
+ /**
85
+ * цвет выводящийся в соответсвующей ячейке
86
+ */
87
+ seriesColor: string;
88
+ /**
89
+ * название измерения выводящееся в соответсвующей ячейке
90
+ */
91
+ seriesName: string;
92
+ /**
93
+ * индекс линии
94
+ */
95
+ seriesIdx?: number;
96
+ /**
97
+ * флаг, указывающий, должно ли отображаться название строки
98
+ */
99
+ hideSeriesName?: boolean;
100
+ /**
101
+ * процентное значение выводящееся в соответвующей ячейке
102
+ */
103
+ percentValue?: number | string;
104
+ /**
105
+ * значение diff-а выводящееся в соответвующей ячейке
106
+ */
107
+ diff?: string;
108
+ /**
109
+ * отформатированное числовое значение для текущего измерения выводящееся в соответствующей ячейке
110
+ */
111
+ value: string;
112
+ /**
113
+ * Комментарий к строке (отображается под соответствующей строкой), задаётся через manageTooltipConfig
114
+ */
115
+ commentText?: string;
116
+ /**
117
+ * Комментарий к строке (отображается под соответствующей строкой), задаётся через диалог комментариев
118
+ */
119
+ xyCommentText?: string;
120
+ /**
121
+ * флаг, указывающий, что данная строка активна
122
+ */
123
+ selectedSeries?: boolean;
124
+ /**
125
+ * кастомный рендер соответсвующей строки (строка с текстом либо html разметкой)
126
+ */
127
+ customRender?: string;
128
+ /**
129
+ * объект, где ключи - индексы ячеек, контент которых должен быть заменён, значения - функции возвращающие
130
+ * строку (с текстом либо html разметкой) которая будет вставлена в ячейку на соответствующем индексе
131
+ */
132
+ replaceCellAt?: Record<number, (line: TooltipLine) => string>;
133
+ /**
134
+ * объект, где ключи - индексы на которые будут вставлены новые ячейки (ячейка ранее располагавшаяся на этом
135
+ * индексе и последующие за ней будут сдвинуты), значения - функции возвращающие строку (с текстом либо html
136
+ * разметкой) которая будет вставлена в добавившуюся ячейку
137
+ */
138
+ insertCellAt?: Record<number, (line: TooltipLine) => string>;
139
+ }
140
+ export declare const formatTooltip: (data: TooltipData, tooltip: Tooltip) => string;
141
+ export {};