@stats-organization/github-readme-stats-core 2.1.3 → 2.1.5
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/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +34 -1
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +18 -1
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +17 -1
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +36 -5
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +34 -1
- package/build/calculateRank.d.ts +12 -11
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +18 -18
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +0 -1
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +29 -21
- package/build/cards/stats.d.ts +4 -2
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +21 -9
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +39 -12
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +29 -9
- package/build/common/Card.d.ts +54 -60
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +88 -61
- package/build/common/I18n.d.ts +13 -14
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +13 -12
- package/build/common/color.d.ts +56 -32
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +87 -50
- package/build/common/config.d.ts +18 -2
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +17 -26
- package/build/common/constants.d.ts +2 -2
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +5 -3
- package/build/common/error.d.ts +36 -29
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +14 -10
- package/build/common/fmt.d.ts +14 -13
- package/build/common/fmt.d.ts.map +1 -1
- package/build/common/fmt.js +19 -15
- package/build/common/html.d.ts +2 -4
- package/build/common/html.d.ts.map +1 -1
- package/build/common/html.js +2 -6
- package/build/common/http.d.ts +13 -4
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +3 -4
- package/build/common/icons.d.ts +22 -21
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +4 -5
- package/build/common/languageColors.json +9 -1
- package/build/common/ops.d.ts +30 -29
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +32 -38
- package/build/common/render.d.ts +115 -111
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +138 -88
- package/build/common/retryer.d.ts +24 -13
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +22 -30
- package/build/fetchers/gist.d.ts +6 -21
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +30 -36
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +4 -7
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +3 -7
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +0 -1
- package/build/fetchers/types.d.ts +126 -0
- package/build/fetchers/types.d.ts.map +1 -0
- package/build/fetchers/types.js +1 -0
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +0 -1
- package/build/translations.d.ts +627 -24
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +7 -8
- package/package.json +4 -4
- package/src/_emoji-name-map.d.ts +10 -0
- package/src/api/gist.js +36 -2
- package/src/api/index.js +19 -2
- package/src/api/pin.js +18 -2
- package/src/api/top-langs.js +38 -6
- package/src/api/wakatime.js +36 -2
- package/src/{calculateRank.js → calculateRank.ts} +29 -19
- package/src/cards/gist.js +0 -2
- package/src/cards/repo.js +30 -22
- package/src/cards/stats.js +22 -10
- package/src/cards/top-languages.js +49 -13
- package/src/cards/wakatime.js +33 -10
- package/src/common/Card.ts +338 -0
- package/src/common/I18n.ts +49 -0
- package/src/common/color.ts +212 -0
- package/src/common/config.ts +83 -0
- package/src/common/constants.ts +10 -0
- package/src/common/{error.js → error.ts} +20 -14
- package/src/common/{fmt.js → fmt.ts} +27 -19
- package/src/common/{html.js → html.ts} +3 -8
- package/src/common/http.ts +31 -0
- package/src/common/{icons.js → icons.ts} +9 -7
- package/src/common/languageColors.json +9 -1
- package/src/common/{ops.js → ops.ts} +48 -52
- package/src/common/{render.js → render.ts} +208 -98
- package/src/common/retryer.ts +125 -0
- package/src/fetchers/gist.ts +136 -0
- package/src/fetchers/repo.js +4 -8
- package/src/fetchers/stats.js +3 -8
- package/src/fetchers/top-languages.js +0 -2
- package/src/fetchers/{types.d.ts → types.ts} +1 -1
- package/src/fetchers/wakatime.js +0 -2
- package/src/{translations.js → translations.ts} +14 -10
- package/src/common/Card.js +0 -275
- package/src/common/I18n.js +0 -42
- package/src/common/color.js +0 -145
- package/src/common/config.js +0 -78
- package/src/common/constants.js +0 -9
- package/src/common/http.js +0 -21
- package/src/common/retryer.js +0 -104
- package/src/fetchers/gist.js +0 -114
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { Card } from "../common/Card.js";
|
|
3
2
|
import { I18n } from "../common/I18n.js";
|
|
4
|
-
import { fallbackColor, getCardColors } from "../common/color.js";
|
|
3
|
+
import { fallbackColor, getCardColors, isPrefixedHexColor, } from "../common/color.js";
|
|
5
4
|
import { formatBytes } from "../common/fmt.js";
|
|
5
|
+
import { encodeHTML } from "../common/html.js";
|
|
6
6
|
import { chunkArray, clampValue, lowercaseTrim } from "../common/ops.js";
|
|
7
7
|
import { createProgressNode, flexLayout, measureText, } from "../common/render.js";
|
|
8
8
|
import { langCardLocales } from "../translations.js";
|
|
@@ -202,8 +202,8 @@ const createProgressTextNode = ({ width, color, progBarBgColor, name, size, tota
|
|
|
202
202
|
const displayValue = getDisplayValue(size, progress, statsFormat);
|
|
203
203
|
return `
|
|
204
204
|
<g class="stagger" style="animation-delay: ${staggerDelay}ms">
|
|
205
|
-
<text data-testid="lang-name" x="2" y="15" class="lang-name">${name}</text>
|
|
206
|
-
${hideValues ? "" : `<text x="${progressTextX}" y="34" class="lang-name">${displayValue}</text>`}
|
|
205
|
+
<text data-testid="lang-name" x="2" y="15" class="lang-name">${encodeHTML(name)}</text>
|
|
206
|
+
${hideValues ? "" : `<text x="${progressTextX}" y="34" class="lang-name">${encodeHTML(displayValue)}</text>`}
|
|
207
207
|
${createProgressNode({
|
|
208
208
|
x: 0,
|
|
209
209
|
y: 25,
|
|
@@ -233,11 +233,14 @@ const createCompactLangNode = ({ lang, totalSize, hideProgress, hideValues, stat
|
|
|
233
233
|
const displayValue = getDisplayValue(lang.size, percentages, statsFormat);
|
|
234
234
|
const staggerDelay = (index + 3) * 150;
|
|
235
235
|
const color = lang.color || "#858585";
|
|
236
|
+
if (!isPrefixedHexColor(color)) {
|
|
237
|
+
throw new Error(`Invalid language color: "${color}"`);
|
|
238
|
+
}
|
|
236
239
|
return `
|
|
237
240
|
<g class="stagger" style="animation-delay: ${staggerDelay}ms">
|
|
238
241
|
<circle cx="5" cy="6" r="5" fill="${color}" />
|
|
239
242
|
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
|
240
|
-
${lang.name} ${hideProgress || hideValues ? "" : displayValue}
|
|
243
|
+
${encodeHTML(lang.name)} ${hideProgress || hideValues ? "" : encodeHTML(displayValue)}
|
|
241
244
|
</text>
|
|
242
245
|
</g>
|
|
243
246
|
`;
|
|
@@ -355,6 +358,10 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress, stat
|
|
|
355
358
|
let progressOffset = 0;
|
|
356
359
|
const compactProgressBar = langs
|
|
357
360
|
.map((lang) => {
|
|
361
|
+
const langColor = lang.color || DEFAULT_LANG_COLOR;
|
|
362
|
+
if (!isPrefixedHexColor(langColor)) {
|
|
363
|
+
throw new Error(`Invalid language color: "${langColor}"`);
|
|
364
|
+
}
|
|
358
365
|
const percentage = parseFloat(((lang.size / totalLanguageSize) * offsetWidth).toFixed(2));
|
|
359
366
|
const progress = percentage < 10 ? percentage + 10 : percentage;
|
|
360
367
|
const output = `
|
|
@@ -365,7 +372,7 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress, stat
|
|
|
365
372
|
y="0"
|
|
366
373
|
width="${progress}"
|
|
367
374
|
height="8"
|
|
368
|
-
fill="${
|
|
375
|
+
fill="${langColor}"
|
|
369
376
|
/>
|
|
370
377
|
`;
|
|
371
378
|
progressOffset += percentage;
|
|
@@ -413,17 +420,21 @@ const renderDonutVerticalLayout = (langs, totalLanguageSize, statsFormat, hideVa
|
|
|
413
420
|
let startDelayCoefficient = 1;
|
|
414
421
|
// Generate each donut vertical chart part
|
|
415
422
|
for (const lang of langs) {
|
|
423
|
+
const langColor = lang.color || DEFAULT_LANG_COLOR;
|
|
424
|
+
if (!isPrefixedHexColor(langColor)) {
|
|
425
|
+
throw new Error(`Invalid language color: "${langColor}"`);
|
|
426
|
+
}
|
|
416
427
|
const percentage = (lang.size / totalLanguageSize) * 100;
|
|
417
428
|
const circleLength = totalCircleLength * (percentage / 100);
|
|
418
429
|
const delay = startDelayCoefficient * 100;
|
|
419
430
|
circles.push(`
|
|
420
431
|
<g class="stagger" style="animation-delay: ${delay}ms">
|
|
421
|
-
<circle
|
|
432
|
+
<circle
|
|
422
433
|
cx="150"
|
|
423
434
|
cy="100"
|
|
424
435
|
r="${radius}"
|
|
425
436
|
fill="transparent"
|
|
426
|
-
stroke="${
|
|
437
|
+
stroke="${langColor}"
|
|
427
438
|
stroke-width="25"
|
|
428
439
|
stroke-dasharray="${totalCircleLength}"
|
|
429
440
|
stroke-dashoffset="${indent}"
|
|
@@ -480,6 +491,10 @@ const renderPieLayout = (langs, totalLanguageSize, statsFormat, hideValues) => {
|
|
|
480
491
|
const paths = [];
|
|
481
492
|
// Generate each pie chart part
|
|
482
493
|
for (const lang of langs) {
|
|
494
|
+
const langColor = lang.color || DEFAULT_LANG_COLOR;
|
|
495
|
+
if (!isPrefixedHexColor(langColor)) {
|
|
496
|
+
throw new Error(`Invalid language color: "${langColor}"`);
|
|
497
|
+
}
|
|
483
498
|
if (langs.length === 1) {
|
|
484
499
|
paths.push(`
|
|
485
500
|
<circle
|
|
@@ -487,7 +502,7 @@ const renderPieLayout = (langs, totalLanguageSize, statsFormat, hideValues) => {
|
|
|
487
502
|
cy="${centerY}"
|
|
488
503
|
r="${radius}"
|
|
489
504
|
stroke="none"
|
|
490
|
-
fill="${
|
|
505
|
+
fill="${langColor}"
|
|
491
506
|
data-testid="lang-pie"
|
|
492
507
|
size="100"
|
|
493
508
|
/>
|
|
@@ -514,7 +529,7 @@ const renderPieLayout = (langs, totalLanguageSize, statsFormat, hideValues) => {
|
|
|
514
529
|
data-testid="lang-pie"
|
|
515
530
|
size="${percentage}"
|
|
516
531
|
d="M ${centerX} ${centerY} L ${startPoint.x} ${startPoint.y} A ${radius} ${radius} 0 ${largeArcFlag} 1 ${endPoint.x} ${endPoint.y} Z"
|
|
517
|
-
fill="${
|
|
532
|
+
fill="${langColor}"
|
|
518
533
|
/>
|
|
519
534
|
</g>
|
|
520
535
|
`);
|
|
@@ -583,11 +598,20 @@ const createDonutPaths = (cx, cy, radius, percentages) => {
|
|
|
583
598
|
* @returns {string} Donut layout card SVG object.
|
|
584
599
|
*/
|
|
585
600
|
const renderDonutLayout = (langs, width, totalLanguageSize, statsFormat, hideValues) => {
|
|
601
|
+
if (!Number.isFinite(width)) {
|
|
602
|
+
throw new Error(`Invalid width: "${width}"`);
|
|
603
|
+
}
|
|
586
604
|
const centerX = width / 3;
|
|
587
605
|
const centerY = width / 3;
|
|
588
606
|
const radius = centerX - 60;
|
|
589
607
|
const strokeWidth = 12;
|
|
590
|
-
const colors = langs.map((lang) =>
|
|
608
|
+
const colors = langs.map((lang) => {
|
|
609
|
+
const langColor = lang.color || DEFAULT_LANG_COLOR;
|
|
610
|
+
if (!isPrefixedHexColor(langColor)) {
|
|
611
|
+
throw new Error(`Invalid language color: "${langColor}"`);
|
|
612
|
+
}
|
|
613
|
+
return langColor;
|
|
614
|
+
});
|
|
591
615
|
const langsPercents = langs.map((lang) => parseFloat(((lang.size / totalLanguageSize) * 100).toFixed(2)));
|
|
592
616
|
const langPaths = createDonutPaths(centerX, centerY, radius, langsPercents);
|
|
593
617
|
const donutPaths = langs.length === 1
|
|
@@ -638,8 +662,11 @@ const renderDonutLayout = (langs, width, totalLanguageSize, statsFormat, hideVal
|
|
|
638
662
|
* @returns {string} No languages data SVG node string.
|
|
639
663
|
*/
|
|
640
664
|
const noLanguagesDataNode = ({ color, text, layout }) => {
|
|
665
|
+
if (!isPrefixedHexColor(color)) {
|
|
666
|
+
throw new Error(`Invalid text color: "${color}"`);
|
|
667
|
+
}
|
|
641
668
|
return `
|
|
642
|
-
<text x="${layout === "pie" || layout === "donut-vertical" ? CARD_PADDING : 0}" y="11" class="stat bold" fill="${color}">${text}</text>
|
|
669
|
+
<text x="${layout === "pie" || layout === "donut-vertical" ? CARD_PADDING : 0}" y="11" class="stat bold" fill="${color}">${encodeHTML(text)}</text>
|
|
643
670
|
`;
|
|
644
671
|
};
|
|
645
672
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/cards/wakatime.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/cards/wakatime.js"],"names":[],"mappings":";;;AAoPA;;;GAGG;AAEH;;;;;;GAMG;AACH,2CAJW,OAAO,CAAC,YAAY,CAAC,YACrB,OAAO,CAAC,eAAe,CAAC,GACtB,MAAM,CA6OlB"}
|
package/build/cards/wakatime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { Card } from "../common/Card.js";
|
|
3
2
|
import { I18n } from "../common/I18n.js";
|
|
4
|
-
import { getCardColors } from "../common/color.js";
|
|
3
|
+
import { getCardColors, isPrefixedHexColor } from "../common/color.js";
|
|
4
|
+
import { encodeHTML } from "../common/html.js";
|
|
5
5
|
import languageColors from "../common/languageColors.json" with { type: "json" };
|
|
6
6
|
import { clampValue, lowercaseTrim } from "../common/ops.js";
|
|
7
7
|
import { createProgressNode, flexLayout } from "../common/render.js";
|
|
@@ -23,8 +23,11 @@ const TOTAL_TEXT_WIDTH = 275;
|
|
|
23
23
|
* @returns {string} No coding activity SVG node string.
|
|
24
24
|
*/
|
|
25
25
|
const noCodingActivityNode = ({ color, text }) => {
|
|
26
|
+
if (!isPrefixedHexColor(color)) {
|
|
27
|
+
throw new Error(`Invalid text color: "${color}"`);
|
|
28
|
+
}
|
|
26
29
|
return `
|
|
27
|
-
<text x="25" y="11" class="stat bold" fill="${color}">${text}</text>
|
|
30
|
+
<text x="25" y="11" class="stat bold" fill="${color}">${encodeHTML(text)}</text>
|
|
28
31
|
`;
|
|
29
32
|
};
|
|
30
33
|
/**
|
|
@@ -54,6 +57,12 @@ const formatLanguageValue = ({ display_format, lang }) => {
|
|
|
54
57
|
* @returns {string} The compact layout language SVG node.
|
|
55
58
|
*/
|
|
56
59
|
const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
|
60
|
+
if (!Number.isFinite(x)) {
|
|
61
|
+
throw new Error(`Invalid x: "${x}"`);
|
|
62
|
+
}
|
|
63
|
+
if (!Number.isFinite(y)) {
|
|
64
|
+
throw new Error(`Invalid y: "${y}"`);
|
|
65
|
+
}
|
|
57
66
|
// @ts-ignore
|
|
58
67
|
const color = languageColors[lang.name] || "#858585";
|
|
59
68
|
const value = formatLanguageValue({ display_format, lang });
|
|
@@ -61,7 +70,7 @@ const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
|
|
61
70
|
<g transform="translate(${x}, ${y})">
|
|
62
71
|
<circle cx="5" cy="6" r="5" fill="${color}" />
|
|
63
72
|
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
|
64
|
-
${lang.name} - ${value}
|
|
73
|
+
${encodeHTML(lang.name)} - ${encodeHTML(value)}
|
|
65
74
|
</text>
|
|
66
75
|
</g>
|
|
67
76
|
`;
|
|
@@ -107,6 +116,12 @@ const createLanguageTextNode = ({ langs, y, display_format, card_width }) => {
|
|
|
107
116
|
* @returns {string} The text SVG node.
|
|
108
117
|
*/
|
|
109
118
|
const createTextNode = ({ id, label, value, index, percent, hideProgress, progressBarColor, progressBarBackgroundColor, progressBarWidth, }) => {
|
|
119
|
+
if (!Number.isFinite(index)) {
|
|
120
|
+
throw new Error(`Invalid index: "${index}"`);
|
|
121
|
+
}
|
|
122
|
+
if (!Number.isFinite(progressBarWidth)) {
|
|
123
|
+
throw new Error(`Invalid progressBarWidth: "${progressBarWidth}"`);
|
|
124
|
+
}
|
|
110
125
|
const staggerDelay = (index + 3) * 150;
|
|
111
126
|
const cardProgress = hideProgress
|
|
112
127
|
? null
|
|
@@ -123,12 +138,12 @@ const createTextNode = ({ id, label, value, index, percent, hideProgress, progre
|
|
|
123
138
|
});
|
|
124
139
|
return `
|
|
125
140
|
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
|
|
126
|
-
<text class="stat bold" y="12.5" data-testid="${id}">${label}:</text>
|
|
141
|
+
<text class="stat bold" y="12.5" data-testid="${encodeHTML(id)}">${encodeHTML(label)}:</text>
|
|
127
142
|
<text
|
|
128
143
|
class="stat"
|
|
129
144
|
x="${hideProgress ? HIDDEN_PROGRESSBAR_PADDING : PROGRESSBAR_PADDING + progressBarWidth}"
|
|
130
145
|
y="12.5"
|
|
131
|
-
>${value}</text>
|
|
146
|
+
>${encodeHTML(value)}</text>
|
|
132
147
|
${cardProgress}
|
|
133
148
|
</g>
|
|
134
149
|
`;
|
|
@@ -155,9 +170,12 @@ const recalculatePercentages = (languages) => {
|
|
|
155
170
|
* @param {string} colors.textColor The text color.
|
|
156
171
|
* @returns {string} Card CSS styles.
|
|
157
172
|
*/
|
|
158
|
-
const getStyles = ({
|
|
173
|
+
const getStyles = function ({
|
|
159
174
|
// eslint-disable-next-line no-unused-vars
|
|
160
|
-
titleColor, textColor, })
|
|
175
|
+
titleColor, textColor, }) {
|
|
176
|
+
if (!isPrefixedHexColor(textColor)) {
|
|
177
|
+
throw new Error(`Invalid text color: "${textColor}"`);
|
|
178
|
+
}
|
|
161
179
|
return `
|
|
162
180
|
.stat {
|
|
163
181
|
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${textColor};
|
|
@@ -303,7 +321,9 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
303
321
|
// @ts-ignore
|
|
304
322
|
progressBarColor: titleColor,
|
|
305
323
|
// @ts-ignore
|
|
306
|
-
progressBarBackgroundColor: textColor === titleColor
|
|
324
|
+
progressBarBackgroundColor: textColor === titleColor
|
|
325
|
+
? "#fff0" // transparent
|
|
326
|
+
: textColor,
|
|
307
327
|
hideProgress: hide_progress,
|
|
308
328
|
progressBarWidth: normalizedWidth - TOTAL_TEXT_WIDTH,
|
|
309
329
|
});
|
package/build/common/Card.d.ts
CHANGED
|
@@ -1,49 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @param {string=} args.colors.titleColor Card title color.
|
|
15
|
-
* @param {string=} args.colors.textColor Card text color.
|
|
16
|
-
* @param {string=} args.colors.iconColor Card icon color.
|
|
17
|
-
* @param {string|string[]=} args.colors.bgColor Card background color.
|
|
18
|
-
* @param {string=} args.colors.borderColor Card border color.
|
|
19
|
-
*/
|
|
20
|
-
constructor({ width, height, border_radius, colors, customTitle, defaultTitle, titlePrefixIcon, }: {
|
|
21
|
-
width?: number | undefined;
|
|
22
|
-
height?: number | undefined;
|
|
23
|
-
border_radius?: number | undefined;
|
|
24
|
-
customTitle?: string | undefined;
|
|
25
|
-
defaultTitle?: string | undefined;
|
|
26
|
-
titlePrefixIcon?: string | undefined;
|
|
27
|
-
colors?: {
|
|
28
|
-
titleColor?: string | undefined;
|
|
29
|
-
textColor?: string | undefined;
|
|
30
|
-
iconColor?: string | undefined;
|
|
31
|
-
bgColor?: (string | string[]) | undefined;
|
|
32
|
-
borderColor?: string | undefined;
|
|
33
|
-
} | undefined;
|
|
34
|
-
});
|
|
1
|
+
interface CardColors {
|
|
2
|
+
/** Card title color. */
|
|
3
|
+
titleColor?: string;
|
|
4
|
+
/** Card text color. */
|
|
5
|
+
textColor?: string;
|
|
6
|
+
/** Card icon color. */
|
|
7
|
+
iconColor?: string;
|
|
8
|
+
/** Card background color. */
|
|
9
|
+
bgColor?: string | Array<string>;
|
|
10
|
+
/** Card border color. */
|
|
11
|
+
borderColor?: string;
|
|
12
|
+
}
|
|
13
|
+
declare class Card {
|
|
35
14
|
width: number;
|
|
36
15
|
height: number;
|
|
37
16
|
hideBorder: boolean;
|
|
38
17
|
hideTitle: boolean;
|
|
39
18
|
border_radius: number;
|
|
40
|
-
colors:
|
|
41
|
-
titleColor?: string | undefined;
|
|
42
|
-
textColor?: string | undefined;
|
|
43
|
-
iconColor?: string | undefined;
|
|
44
|
-
bgColor?: (string | string[]) | undefined;
|
|
45
|
-
borderColor?: string | undefined;
|
|
46
|
-
};
|
|
19
|
+
colors: CardColors;
|
|
47
20
|
title: string;
|
|
48
21
|
css: string;
|
|
49
22
|
paddingX: number;
|
|
@@ -53,57 +26,78 @@ export class Card {
|
|
|
53
26
|
a11yTitle: string;
|
|
54
27
|
a11yDesc: string;
|
|
55
28
|
/**
|
|
56
|
-
*
|
|
29
|
+
* Creates a new card instance.
|
|
30
|
+
*
|
|
31
|
+
* The caller must ensure that the passed `titlePrefixIcon` is properly sanitized!
|
|
32
|
+
*
|
|
33
|
+
* @param props Card arguments.
|
|
34
|
+
* @param props.width Card width.
|
|
35
|
+
* @param props.height Card height.
|
|
36
|
+
* @param props.border_radius Card border radius.
|
|
37
|
+
* @param props.colors Card colors arguments.
|
|
38
|
+
* @param props.customTitle Card custom title.
|
|
39
|
+
* @param props.defaultTitle Card default title.
|
|
40
|
+
* @param props.titlePrefixIcon Sanitized card title prefix icon.
|
|
57
41
|
*/
|
|
42
|
+
constructor({ width, height, border_radius, colors, customTitle, defaultTitle, titlePrefixIcon, }: {
|
|
43
|
+
width?: number;
|
|
44
|
+
height?: number;
|
|
45
|
+
border_radius?: number;
|
|
46
|
+
colors?: CardColors;
|
|
47
|
+
customTitle?: string;
|
|
48
|
+
defaultTitle?: string;
|
|
49
|
+
titlePrefixIcon?: string;
|
|
50
|
+
});
|
|
58
51
|
disableAnimations(): void;
|
|
59
52
|
/**
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
62
|
-
* @param
|
|
63
|
-
* @returns {void}
|
|
53
|
+
* @param props The props object.
|
|
54
|
+
* @param props.title Accessibility title.
|
|
55
|
+
* @param props.desc Accessibility description.
|
|
64
56
|
*/
|
|
65
|
-
setAccessibilityLabel({ title, desc }: {
|
|
57
|
+
setAccessibilityLabel({ title, desc, }: {
|
|
66
58
|
title: string;
|
|
67
59
|
desc: string;
|
|
68
60
|
}): void;
|
|
69
61
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
62
|
+
* The caller must ensure that the passed `css` string is properly sanitized!
|
|
63
|
+
*
|
|
64
|
+
* @param value The sanitized CSS to add to the card.
|
|
72
65
|
*/
|
|
73
66
|
setCSS(value: string): void;
|
|
74
67
|
/**
|
|
75
|
-
* @param
|
|
76
|
-
* @returns {void}
|
|
68
|
+
* @param value Whether to hide the border or not.
|
|
77
69
|
*/
|
|
78
70
|
setHideBorder(value: boolean): void;
|
|
79
71
|
/**
|
|
80
|
-
* @param
|
|
81
|
-
* @returns {void}
|
|
72
|
+
* @param value Whether to hide the title or not.
|
|
82
73
|
*/
|
|
83
74
|
setHideTitle(value: boolean): void;
|
|
84
75
|
/**
|
|
85
|
-
* @param
|
|
86
|
-
* @returns {void}
|
|
76
|
+
* @param text The title to set.
|
|
87
77
|
*/
|
|
88
78
|
setTitle(text: string): void;
|
|
89
79
|
/**
|
|
90
|
-
* @returns
|
|
80
|
+
* @returns The rendered card title.
|
|
91
81
|
*/
|
|
92
82
|
renderTitle(): string;
|
|
93
83
|
/**
|
|
94
|
-
* @returns
|
|
84
|
+
* @returns The rendered card gradient.
|
|
95
85
|
*/
|
|
96
86
|
renderGradient(): string;
|
|
97
87
|
/**
|
|
98
88
|
* Retrieves css animations for a card.
|
|
99
89
|
*
|
|
100
|
-
* @returns
|
|
90
|
+
* @returns Animation css.
|
|
101
91
|
*/
|
|
102
92
|
getAnimations: () => string;
|
|
103
93
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
94
|
+
* The caller must ensure that the passed `body` string is properly sanitized!
|
|
95
|
+
*
|
|
96
|
+
* @param body The sanitized inner body of the card.
|
|
97
|
+
* @returns The rendered card.
|
|
106
98
|
*/
|
|
107
99
|
render(body: string): string;
|
|
108
100
|
}
|
|
101
|
+
export { Card };
|
|
102
|
+
export default Card;
|
|
109
103
|
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/common/Card.
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/common/Card.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAClB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,cAAM,IAAI;IACR,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;OAaG;gBACS,EACV,KAAW,EACX,MAAY,EACZ,aAAmB,EACnB,MAAW,EACX,WAAW,EACX,YAAiB,EACjB,eAAe,GAChB,EAAE;QACD,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B;IAuBD,iBAAiB,IAAI,IAAI;IAIzB;;;;OAIG;IACH,qBAAqB,CAAC,EACpB,KAAK,EACL,IAAI,GACL,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI;IAKR;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI3B;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAInC;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAUlC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI5B;;OAEG;IACH,WAAW,IAAI,MAAM;IAoCrB;;OAEG;IACH,cAAc,IAAI,MAAM;IA2BxB;;;;OAIG;IACH,aAAa,QAAO,MAAM,CAoBxB;IAEF;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CA0F7B;AAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,eAAe,IAAI,CAAC"}
|