@jirawatpyk/aura-react 5.33.0 → 5.35.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.
- package/README.md +16 -2
- package/dist/aura.bundle.js +831 -412
- package/dist/cjs/index.cjs +830 -411
- package/dist/esm/ActionBar.js +1 -0
- package/dist/esm/AppShell.js +16 -2
- package/dist/esm/BottomNav.js +26 -2
- package/dist/esm/StatusTile.js +53 -0
- package/dist/esm/autoTip.js +5 -0
- package/dist/esm/breakpoints.js +18 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/responsive.js +1 -15
- package/dist/esm/scrollHide.js +96 -0
- package/dist/esm/strings.js +5 -0
- package/dist/esm/strings.sv.js +5 -0
- package/dist/esm/strings.th.js +5 -0
- package/dist/esm/tiles.js +220 -0
- package/dist/index.d.cts +126 -36
- package/dist/index.d.ts +126 -36
- package/dist/locales/sv.cjs +5 -0
- package/dist/locales/sv.d.cts +7 -0
- package/dist/locales/sv.d.ts +7 -0
- package/dist/locales/th.cjs +5 -0
- package/dist/locales/th.d.cts +7 -0
- package/dist/locales/th.d.ts +7 -0
- package/dist/server/index.cjs +274 -27
- package/dist/server/index.d.cts +78 -0
- package/dist/server/index.d.ts +78 -0
- package/dist/server/index.js +274 -27
- package/dist/styles.css +86 -5
- package/dist/styles.layer.css +86 -5
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -39,8 +39,11 @@ __export(server_exports, {
|
|
|
39
39
|
Icon: () => Icon,
|
|
40
40
|
PageHeader: () => PageHeader,
|
|
41
41
|
STRINGS: () => STRINGS,
|
|
42
|
+
Sparkline: () => Sparkline,
|
|
42
43
|
Stat: () => ServerStat,
|
|
43
44
|
StatusPill: () => ServerStatusPill,
|
|
45
|
+
StatusTile: () => ServerStatusTile,
|
|
46
|
+
TileGrid: () => TileGrid,
|
|
44
47
|
brandScale: () => scale,
|
|
45
48
|
breakpoints: () => breakpoints,
|
|
46
49
|
buttonClass: () => buttonClass,
|
|
@@ -329,11 +332,16 @@ var th = {
|
|
|
329
332
|
pageN: function(p) {
|
|
330
333
|
return "\u0E2B\u0E19\u0E49\u0E32 " + p;
|
|
331
334
|
},
|
|
332
|
-
progressReserved: function(v,
|
|
333
|
-
return "\u0E43\u0E0A\u0E49\u0E41\u0E25\u0E49\u0E27 " + n(v) + " \u0E08\u0E32\u0E01 " + n(max) + " \u0E08\u0E2D\u0E07\u0E44\u0E27\u0E49 " + n(
|
|
335
|
+
progressReserved: function(v, r2, max) {
|
|
336
|
+
return "\u0E43\u0E0A\u0E49\u0E41\u0E25\u0E49\u0E27 " + n(v) + " \u0E08\u0E32\u0E01 " + n(max) + " \u0E08\u0E2D\u0E07\u0E44\u0E27\u0E49 " + n(r2);
|
|
334
337
|
},
|
|
335
338
|
breadcrumbMore: "\u0E41\u0E2A\u0E14\u0E07\u0E40\u0E2A\u0E49\u0E19\u0E17\u0E32\u0E07\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14",
|
|
336
339
|
stepError: "\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14",
|
|
340
|
+
statusDown: "\u0E25\u0E48\u0E21",
|
|
341
|
+
statusProblem: "\u0E21\u0E35\u0E1B\u0E31\u0E0D\u0E2B\u0E32",
|
|
342
|
+
statusMaintenance: "\u0E1B\u0E34\u0E14\u0E1B\u0E23\u0E31\u0E1A\u0E1B\u0E23\u0E38\u0E07",
|
|
343
|
+
statusOk: "\u0E1B\u0E01\u0E15\u0E34",
|
|
344
|
+
statusUnknown: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
|
|
337
345
|
accepts: function(list, max) {
|
|
338
346
|
return [list, max && "\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 " + max + " \u0E15\u0E48\u0E2D\u0E44\u0E1F\u0E25\u0E4C"].filter(Boolean).join(" \xB7 ");
|
|
339
347
|
}
|
|
@@ -460,11 +468,16 @@ var sv = {
|
|
|
460
468
|
pageN: function(p) {
|
|
461
469
|
return "Sida " + p;
|
|
462
470
|
},
|
|
463
|
-
progressReserved: function(v,
|
|
464
|
-
return nsv(v) + " av " + nsv(max) + " anv\xE4nda, " + nsv(
|
|
471
|
+
progressReserved: function(v, r2, max) {
|
|
472
|
+
return nsv(v) + " av " + nsv(max) + " anv\xE4nda, " + nsv(r2) + " reserverade";
|
|
465
473
|
},
|
|
466
474
|
breadcrumbMore: "Visa hela s\xF6kv\xE4gen",
|
|
467
475
|
stepError: "har fel",
|
|
476
|
+
statusDown: "Nere",
|
|
477
|
+
statusProblem: "Problem",
|
|
478
|
+
statusMaintenance: "Underh\xE5ll",
|
|
479
|
+
statusOk: "OK",
|
|
480
|
+
statusUnknown: "Ingen data",
|
|
468
481
|
accepts: function(list, max) {
|
|
469
482
|
return [list, max && "h\xF6gst " + max + " per fil"].filter(Boolean).join(", ");
|
|
470
483
|
}
|
|
@@ -592,11 +605,16 @@ var STRINGS = {
|
|
|
592
605
|
pageN: function(p) {
|
|
593
606
|
return "Page " + p;
|
|
594
607
|
},
|
|
595
|
-
progressReserved: function(v,
|
|
596
|
-
return n2(v) + " of " + n2(max) + " used, " + n2(
|
|
608
|
+
progressReserved: function(v, r2, max) {
|
|
609
|
+
return n2(v) + " of " + n2(max) + " used, " + n2(r2) + " reserved";
|
|
597
610
|
},
|
|
598
611
|
breadcrumbMore: "Show the full path",
|
|
599
612
|
stepError: "has errors",
|
|
613
|
+
statusDown: "Down",
|
|
614
|
+
statusProblem: "Problem",
|
|
615
|
+
statusMaintenance: "Maintenance",
|
|
616
|
+
statusOk: "OK",
|
|
617
|
+
statusUnknown: "No data",
|
|
600
618
|
accepts: function(list, max) {
|
|
601
619
|
return [list, max && "up to " + max + " each"].filter(Boolean).join(", ");
|
|
602
620
|
}
|
|
@@ -607,14 +625,14 @@ var STRINGS = {
|
|
|
607
625
|
|
|
608
626
|
// src/theme.ts
|
|
609
627
|
function hexToRgb(hex) {
|
|
610
|
-
let
|
|
611
|
-
if (
|
|
612
|
-
|
|
628
|
+
let h6 = String(hex).trim().replace("#", "");
|
|
629
|
+
if (h6.length === 3)
|
|
630
|
+
h6 = h6.split("").map(function(c) {
|
|
613
631
|
return c + c;
|
|
614
632
|
}).join("");
|
|
615
|
-
if (!/^[0-9a-f]{6}$/i.test(
|
|
633
|
+
if (!/^[0-9a-f]{6}$/i.test(h6)) throw new Error('createTheme: "' + hex + '" is not a #rgb or #rrggbb colour');
|
|
616
634
|
return [0, 2, 4].map(function(i) {
|
|
617
|
-
return parseInt(
|
|
635
|
+
return parseInt(h6.slice(i, i + 2), 16) / 255;
|
|
618
636
|
});
|
|
619
637
|
}
|
|
620
638
|
function rgbToHex(rgb) {
|
|
@@ -630,10 +648,10 @@ function delin(c) {
|
|
|
630
648
|
return c <= 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
|
631
649
|
}
|
|
632
650
|
function rgbToOklch(rgb) {
|
|
633
|
-
const
|
|
634
|
-
const l = Math.cbrt(0.4122214708 *
|
|
635
|
-
const m = Math.cbrt(0.2119034982 *
|
|
636
|
-
const s = Math.cbrt(0.0883024619 *
|
|
651
|
+
const r2 = lin(rgb[0]), g = lin(rgb[1]), b = lin(rgb[2]);
|
|
652
|
+
const l = Math.cbrt(0.4122214708 * r2 + 0.5363325363 * g + 0.0514459929 * b);
|
|
653
|
+
const m = Math.cbrt(0.2119034982 * r2 + 0.6806995451 * g + 0.1073969566 * b);
|
|
654
|
+
const s = Math.cbrt(0.0883024619 * r2 + 0.2817188376 * g + 0.6299787005 * b);
|
|
637
655
|
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
638
656
|
const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
639
657
|
const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
@@ -793,13 +811,13 @@ function createTheme(opts) {
|
|
|
793
811
|
D["card-shadow-creative"] = "8px 8px 0px " + shadowDark;
|
|
794
812
|
const checks = [];
|
|
795
813
|
function check(theme, fg, bg, target, fgHex, bgHex) {
|
|
796
|
-
const
|
|
814
|
+
const r2 = contrast(fgHex, bgHex);
|
|
797
815
|
checks.push({
|
|
798
816
|
theme,
|
|
799
817
|
pair: fg + " on " + bg,
|
|
800
|
-
ratio: Math.round(
|
|
818
|
+
ratio: Math.round(r2 * 100) / 100,
|
|
801
819
|
target,
|
|
802
|
-
pass:
|
|
820
|
+
pass: r2 >= target - 5e-3
|
|
803
821
|
});
|
|
804
822
|
}
|
|
805
823
|
[
|
|
@@ -919,6 +937,18 @@ function colorSchemeScript(options) {
|
|
|
919
937
|
|
|
920
938
|
// src/breakpoints.ts
|
|
921
939
|
var breakpoints = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
940
|
+
var ORDER = ["base", "sm", "md", "lg", "xl"];
|
|
941
|
+
function respVars(prefix, value, map2) {
|
|
942
|
+
const style = {};
|
|
943
|
+
if (value == null) return style;
|
|
944
|
+
if (typeof value !== "object") value = { base: value };
|
|
945
|
+
let byBp = value, cur;
|
|
946
|
+
ORDER.forEach(function(k) {
|
|
947
|
+
if (byBp[k] !== void 0) cur = map2 ? map2(byBp[k]) : byBp[k];
|
|
948
|
+
if (cur !== void 0) style["--" + prefix + "-" + k] = cur;
|
|
949
|
+
});
|
|
950
|
+
return style;
|
|
951
|
+
}
|
|
922
952
|
|
|
923
953
|
// src/display.tsx
|
|
924
954
|
var React3 = __toESM(require("react"), 1);
|
|
@@ -982,9 +1012,9 @@ function iconSvg(shapes, props, ref) {
|
|
|
982
1012
|
...a11y
|
|
983
1013
|
},
|
|
984
1014
|
shapes.map(function(s, i) {
|
|
985
|
-
const
|
|
986
|
-
for (const k in s[1])
|
|
987
|
-
return h(s[0],
|
|
1015
|
+
const attrs2 = { key: i };
|
|
1016
|
+
for (const k in s[1]) attrs2[k === "stroke-width" ? "strokeWidth" : k] = s[1][k];
|
|
1017
|
+
return h(s[0], attrs2);
|
|
988
1018
|
})
|
|
989
1019
|
);
|
|
990
1020
|
}
|
|
@@ -1116,6 +1146,14 @@ var IconTrendingDown = /* @__PURE__ */ defineIcon("trending-down", [
|
|
|
1116
1146
|
["path", { d: "M16 17h6v-6" }],
|
|
1117
1147
|
["path", { d: "m22 17-8.5-8.5-5 5L2 7" }]
|
|
1118
1148
|
]);
|
|
1149
|
+
var IconWrench = /* @__PURE__ */ defineIcon("wrench", [
|
|
1150
|
+
[
|
|
1151
|
+
"path",
|
|
1152
|
+
{
|
|
1153
|
+
d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z"
|
|
1154
|
+
}
|
|
1155
|
+
]
|
|
1156
|
+
]);
|
|
1119
1157
|
|
|
1120
1158
|
// src/display.tsx
|
|
1121
1159
|
var h2 = React3.createElement;
|
|
@@ -1356,14 +1394,14 @@ function ServerAvatar(props) {
|
|
|
1356
1394
|
var React4 = __toESM(require("react"), 1);
|
|
1357
1395
|
var h3 = React4.createElement;
|
|
1358
1396
|
var Container = React4.forwardRef(function Container2(props, ref) {
|
|
1359
|
-
const
|
|
1397
|
+
const attrs2 = {};
|
|
1360
1398
|
Object.keys(props).forEach(function(k) {
|
|
1361
1399
|
if (k === "id" || k === "lang" || k === "dir" || /^(aria|data)-/.test(k))
|
|
1362
|
-
|
|
1400
|
+
attrs2[k] = props[k];
|
|
1363
1401
|
});
|
|
1364
1402
|
return h3(
|
|
1365
1403
|
props.as || "div",
|
|
1366
|
-
Object.assign(
|
|
1404
|
+
Object.assign(attrs2, {
|
|
1367
1405
|
ref,
|
|
1368
1406
|
className: cx(
|
|
1369
1407
|
"aura-container",
|
|
@@ -1381,15 +1419,15 @@ var Container = React4.forwardRef(function Container2(props, ref) {
|
|
|
1381
1419
|
var React5 = __toESM(require("react"), 1);
|
|
1382
1420
|
var h4 = React5.createElement;
|
|
1383
1421
|
var PageHeader = React5.forwardRef(function PageHeader2(props, ref) {
|
|
1384
|
-
const
|
|
1422
|
+
const attrs2 = {};
|
|
1385
1423
|
Object.keys(props).forEach(function(k) {
|
|
1386
1424
|
if (k === "id" || k === "lang" || k === "dir" || k === "role" || /^(aria|data)-/.test(k))
|
|
1387
|
-
|
|
1425
|
+
attrs2[k] = props[k];
|
|
1388
1426
|
});
|
|
1389
1427
|
const level = props.headingLevel || 1;
|
|
1390
1428
|
return h4(
|
|
1391
1429
|
"div",
|
|
1392
|
-
Object.assign(
|
|
1430
|
+
Object.assign(attrs2, { ref, className: cx("aura-page-header", props.className), style: props.style }),
|
|
1393
1431
|
h4(
|
|
1394
1432
|
"div",
|
|
1395
1433
|
{ className: "aura-page-header__text" },
|
|
@@ -1401,3 +1439,212 @@ var PageHeader = React5.forwardRef(function PageHeader2(props, ref) {
|
|
|
1401
1439
|
props.actions != null && props.actions !== false ? h4("div", { className: "aura-page-header__actions" }, props.actions) : null
|
|
1402
1440
|
);
|
|
1403
1441
|
});
|
|
1442
|
+
|
|
1443
|
+
// src/tiles.tsx
|
|
1444
|
+
var React6 = __toESM(require("react"), 1);
|
|
1445
|
+
var h5 = React6.createElement;
|
|
1446
|
+
var STATUS_ICON = {
|
|
1447
|
+
down: IconCircleAlert,
|
|
1448
|
+
problem: IconTriangleAlert,
|
|
1449
|
+
maintenance: IconWrench,
|
|
1450
|
+
ok: IconCircleCheck,
|
|
1451
|
+
unknown: IconCircleDotDashed
|
|
1452
|
+
};
|
|
1453
|
+
var STATUS_TONE = {
|
|
1454
|
+
down: "danger",
|
|
1455
|
+
problem: "warning",
|
|
1456
|
+
maintenance: "accent",
|
|
1457
|
+
ok: "default",
|
|
1458
|
+
unknown: "default"
|
|
1459
|
+
};
|
|
1460
|
+
var STATUS_WORD = {
|
|
1461
|
+
down: "statusDown",
|
|
1462
|
+
problem: "statusProblem",
|
|
1463
|
+
maintenance: "statusMaintenance",
|
|
1464
|
+
ok: "statusOk",
|
|
1465
|
+
unknown: "statusUnknown"
|
|
1466
|
+
};
|
|
1467
|
+
function statusWord(status, t) {
|
|
1468
|
+
return String(t[STATUS_WORD[status]] || STATUS_WORD[status]);
|
|
1469
|
+
}
|
|
1470
|
+
function attrs(props) {
|
|
1471
|
+
const out = {};
|
|
1472
|
+
Object.keys(props).forEach(function(k) {
|
|
1473
|
+
if (k === "id" || k === "style" || k === "lang" || k === "dir" || /^(aria|data)-/.test(k))
|
|
1474
|
+
out[k] = props[k];
|
|
1475
|
+
});
|
|
1476
|
+
return out;
|
|
1477
|
+
}
|
|
1478
|
+
var comma = h5("span", { className: "aura-status-tile__sep" }, ",");
|
|
1479
|
+
function statusTileElement(props, ref, Link, t, titleRef) {
|
|
1480
|
+
const status = STATUS_ICON[props.status] ? props.status : "unknown";
|
|
1481
|
+
if (status !== props.status)
|
|
1482
|
+
devWarnOnce(
|
|
1483
|
+
"status-tile-status-" + String(props.status),
|
|
1484
|
+
'StatusTile status="' + String(props.status) + '" is not down, problem, maintenance, ok or unknown: it shows as unknown ("No data"). Map your value first.'
|
|
1485
|
+
);
|
|
1486
|
+
const valueTone = props.valueTone || STATUS_TONE[status];
|
|
1487
|
+
const word = props.statusLabel || statusWord(status, t);
|
|
1488
|
+
const markers = (props.markers || []).filter(Boolean);
|
|
1489
|
+
const has = function(v) {
|
|
1490
|
+
return v != null && v !== false && v !== "";
|
|
1491
|
+
};
|
|
1492
|
+
const hasValue = has(props.value), hasMeta = has(props.meta);
|
|
1493
|
+
const Tag = props.href ? Link : "div";
|
|
1494
|
+
return h5(
|
|
1495
|
+
Tag,
|
|
1496
|
+
Object.assign(attrs(props), {
|
|
1497
|
+
ref,
|
|
1498
|
+
href: props.href,
|
|
1499
|
+
className: cx("aura-status-tile", "aura-status-tile--" + status, props.href && "is-interactive", props.className)
|
|
1500
|
+
}),
|
|
1501
|
+
h5(
|
|
1502
|
+
"span",
|
|
1503
|
+
{ className: "aura-status-tile__head" },
|
|
1504
|
+
h5(Icon, { name: h5(STATUS_ICON[status]), size: 16, className: "aura-status-tile__icon" }),
|
|
1505
|
+
h5("span", { className: "aura-status-tile__title", ref: titleRef }, props.title, comma),
|
|
1506
|
+
h5("span", { className: "aura-sr-only" }, word + (hasValue || hasMeta || markers.length ? "," : "")),
|
|
1507
|
+
hasValue ? h5(
|
|
1508
|
+
"span",
|
|
1509
|
+
{ className: cx("aura-status-tile__value", "is-" + valueTone) },
|
|
1510
|
+
props.value,
|
|
1511
|
+
hasMeta || markers.length ? comma : null
|
|
1512
|
+
) : null
|
|
1513
|
+
),
|
|
1514
|
+
hasMeta || markers.length ? h5(
|
|
1515
|
+
"span",
|
|
1516
|
+
{ className: "aura-status-tile__foot" },
|
|
1517
|
+
hasMeta ? h5("span", { className: "aura-status-tile__meta" }, props.meta, markers.length ? comma : null) : null,
|
|
1518
|
+
markers.length ? h5(
|
|
1519
|
+
"span",
|
|
1520
|
+
{ className: "aura-status-tile__markers" },
|
|
1521
|
+
markers.map(function(m, i) {
|
|
1522
|
+
return h5(
|
|
1523
|
+
"span",
|
|
1524
|
+
{
|
|
1525
|
+
key: i,
|
|
1526
|
+
className: cx("aura-status-tile__marker", "is-" + (m.tone || "neutral")),
|
|
1527
|
+
"data-aura-tip": m.label
|
|
1528
|
+
},
|
|
1529
|
+
h5(Icon, { name: m.icon, size: 14 }),
|
|
1530
|
+
h5("span", { className: "aura-sr-only" }, m.label + (i < markers.length - 1 ? "," : ""))
|
|
1531
|
+
);
|
|
1532
|
+
})
|
|
1533
|
+
) : null
|
|
1534
|
+
) : null
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1537
|
+
function ServerStatusTile(props) {
|
|
1538
|
+
return statusTileElement(props, void 0, props.linkComponent || "a", STRINGS.en);
|
|
1539
|
+
}
|
|
1540
|
+
var TileGrid = React6.forwardRef(function TileGrid2(props, ref) {
|
|
1541
|
+
const style = Object.assign(
|
|
1542
|
+
{},
|
|
1543
|
+
respVars("aura-grid-cols", props.columns == null ? { base: 2, md: 3 } : props.columns),
|
|
1544
|
+
props.style
|
|
1545
|
+
);
|
|
1546
|
+
return h5(
|
|
1547
|
+
"ul",
|
|
1548
|
+
Object.assign(attrs(props), {
|
|
1549
|
+
ref,
|
|
1550
|
+
role: "list",
|
|
1551
|
+
className: cx("aura-grid-layout", "aura-tile-grid", props.className),
|
|
1552
|
+
style
|
|
1553
|
+
}),
|
|
1554
|
+
/* toArray drops null and booleans and keys each element; a Fragment's children are items too. */
|
|
1555
|
+
flat(props.children).map(function(c, i) {
|
|
1556
|
+
return h5("li", { key: React6.isValidElement(c) && c.key != null ? c.key : i }, c);
|
|
1557
|
+
})
|
|
1558
|
+
);
|
|
1559
|
+
});
|
|
1560
|
+
function flat(children) {
|
|
1561
|
+
const out = [];
|
|
1562
|
+
React6.Children.toArray(children).forEach(function(c) {
|
|
1563
|
+
if (React6.isValidElement(c) && c.type === React6.Fragment)
|
|
1564
|
+
flat(c.props.children).forEach(function(x) {
|
|
1565
|
+
out.push(React6.isValidElement(x) ? React6.cloneElement(x, { key: String(c.key) + "/" + String(x.key) }) : x);
|
|
1566
|
+
});
|
|
1567
|
+
else if (c !== "") out.push(c);
|
|
1568
|
+
});
|
|
1569
|
+
return out;
|
|
1570
|
+
}
|
|
1571
|
+
var SIZES2 = { sm: [80, 24], md: [120, 32] };
|
|
1572
|
+
var PAD = 2;
|
|
1573
|
+
function r(n3) {
|
|
1574
|
+
return Math.round(n3 * 100) / 100;
|
|
1575
|
+
}
|
|
1576
|
+
function num(v) {
|
|
1577
|
+
return typeof v === "number" && isFinite(v) ? v : null;
|
|
1578
|
+
}
|
|
1579
|
+
var Sparkline = React6.forwardRef(function Sparkline2(props, ref) {
|
|
1580
|
+
const wh = SIZES2[props.size || "sm"] || SIZES2.sm;
|
|
1581
|
+
const W = wh[0], H = wh[1];
|
|
1582
|
+
const data = (props.data || []).map(num);
|
|
1583
|
+
const n3 = data.length;
|
|
1584
|
+
const vals = data.filter(function(v) {
|
|
1585
|
+
return v != null;
|
|
1586
|
+
});
|
|
1587
|
+
let lo = num(props.min), hi = num(props.max);
|
|
1588
|
+
if (lo == null) lo = vals.length ? Math.min.apply(null, vals) : 0;
|
|
1589
|
+
if (hi == null) hi = vals.length ? Math.max.apply(null, vals) : 0;
|
|
1590
|
+
if (lo > hi) {
|
|
1591
|
+
const s = lo;
|
|
1592
|
+
lo = hi;
|
|
1593
|
+
hi = s;
|
|
1594
|
+
}
|
|
1595
|
+
const step = n3 > 1 ? (W - 2 * PAD) / (n3 - 1) : 0;
|
|
1596
|
+
const x = function(i) {
|
|
1597
|
+
return n3 > 1 ? PAD + i * step : W / 2;
|
|
1598
|
+
};
|
|
1599
|
+
const y = function(v) {
|
|
1600
|
+
if (hi === lo) return H / 2;
|
|
1601
|
+
const k = Math.max(0, Math.min(1, (v - lo) / (hi - lo)));
|
|
1602
|
+
return H - PAD - k * (H - 2 * PAD);
|
|
1603
|
+
};
|
|
1604
|
+
let d = "";
|
|
1605
|
+
const dots = [];
|
|
1606
|
+
data.forEach(function(v, i) {
|
|
1607
|
+
if (v == null) return;
|
|
1608
|
+
const prev = i > 0 && data[i - 1] != null, next = i < n3 - 1 && data[i + 1] != null;
|
|
1609
|
+
if (!prev && !next) dots.push(h5("circle", { key: "d" + i, cx: r(x(i)), cy: r(y(v)), r: 1.5 }));
|
|
1610
|
+
else d += (prev ? "L" : "M") + r(x(i)) + " " + r(y(v));
|
|
1611
|
+
});
|
|
1612
|
+
const mode = props.failures || "none";
|
|
1613
|
+
const fails = [];
|
|
1614
|
+
if (mode !== "none" && props.failed)
|
|
1615
|
+
data.forEach(function(_v, i) {
|
|
1616
|
+
if (!props.failed[i]) return;
|
|
1617
|
+
if (mode === "band") {
|
|
1618
|
+
const w = Math.max(2, step || W), left = Math.max(0, x(i) - w / 2), right = Math.min(W, x(i) + w / 2);
|
|
1619
|
+
fails.push(h5("rect", { key: "f" + i, x: r(left), y: 0, width: r(right - left), height: H }));
|
|
1620
|
+
} else
|
|
1621
|
+
fails.push(
|
|
1622
|
+
h5("rect", {
|
|
1623
|
+
key: "f" + i,
|
|
1624
|
+
x: r(Math.max(0, Math.min(W - 1.5, x(i) - 0.75))),
|
|
1625
|
+
y: H - 6,
|
|
1626
|
+
width: 1.5,
|
|
1627
|
+
height: 6
|
|
1628
|
+
})
|
|
1629
|
+
);
|
|
1630
|
+
});
|
|
1631
|
+
const named = !!props.label;
|
|
1632
|
+
return h5(
|
|
1633
|
+
"svg",
|
|
1634
|
+
Object.assign(attrs(props), {
|
|
1635
|
+
ref,
|
|
1636
|
+
className: cx("aura-sparkline", "is-" + (props.tone || "neutral"), props.className),
|
|
1637
|
+
width: W,
|
|
1638
|
+
height: H,
|
|
1639
|
+
viewBox: "0 0 " + W + " " + H,
|
|
1640
|
+
role: named ? "img" : void 0,
|
|
1641
|
+
"aria-label": named ? props.label : void 0,
|
|
1642
|
+
"aria-hidden": named ? void 0 : true,
|
|
1643
|
+
focusable: "false"
|
|
1644
|
+
}),
|
|
1645
|
+
fails.length && mode === "band" ? h5("g", { className: "aura-sparkline__band" }, fails) : null,
|
|
1646
|
+
d ? h5("path", { className: "aura-sparkline__line", d }) : null,
|
|
1647
|
+
dots.length ? h5("g", { className: "aura-sparkline__dots" }, dots) : null,
|
|
1648
|
+
fails.length && mode === "ticks" ? h5("g", { className: "aura-sparkline__ticks" }, fails) : null
|
|
1649
|
+
);
|
|
1650
|
+
});
|
package/dist/server/index.d.cts
CHANGED
|
@@ -112,6 +112,8 @@ export interface DateDisplayOptions {
|
|
|
112
112
|
export type DataAttributes = {
|
|
113
113
|
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
114
114
|
};
|
|
115
|
+
export type Breakpoint = "base" | "sm" | "md" | "lg" | "xl";
|
|
116
|
+
export type Responsive<T> = T | Partial<Record<Breakpoint, T>>;
|
|
115
117
|
export interface StatChange {
|
|
116
118
|
/** Shown as written, e.g. "+12%" or "−3". */
|
|
117
119
|
value: React$1.ReactNode;
|
|
@@ -199,6 +201,71 @@ export interface Theme {
|
|
|
199
201
|
/** CSS overriding the tokens. No selector: the whole page. A selector (".tenant-acme") scopes it. Load after aura.css. */
|
|
200
202
|
css(selector?: string): string;
|
|
201
203
|
}
|
|
204
|
+
/** A monitored thing's state on a StatusTile. */
|
|
205
|
+
export type StatusTileStatus = "down" | "problem" | "maintenance" | "ok" | "unknown";
|
|
206
|
+
/** A colour for a tile's value or a marker: `danger`, `warning`, `accent` (violet), `neutral` (grey) or `default`
|
|
207
|
+
* (the text colour). */
|
|
208
|
+
export type TileTone = "danger" | "warning" | "accent" | "neutral" | "default";
|
|
209
|
+
/** A small icon at the end of a StatusTile's second line ("SSL expires soon", "Muted"). */
|
|
210
|
+
export interface StatusTileMarker {
|
|
211
|
+
icon: IconInput;
|
|
212
|
+
/** What it means. Read with the tile's name and shown as a tip on hover (a mouse only: on a phone, say it on the
|
|
213
|
+
* detail page too). */
|
|
214
|
+
label: string;
|
|
215
|
+
/** Default `neutral`. */
|
|
216
|
+
tone?: TileTone | undefined;
|
|
217
|
+
}
|
|
218
|
+
export interface StatusTileProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "style" | "lang" | "dir">, React$1.AriaAttributes, DataAttributes {
|
|
219
|
+
/** down (red), problem (amber), maintenance (violet), ok (grey) or unknown (5.35: no data yet — a dashed circle on
|
|
220
|
+
* the plain surface). Each has its own icon too, so colour is never the only sign. */
|
|
221
|
+
status: StatusTileStatus;
|
|
222
|
+
/** The name. Wraps to two lines at most, then ends with "…"; a cut name shows in full in a tip on hover. */
|
|
223
|
+
title: React$1.ReactNode;
|
|
224
|
+
/** Top right, tabular figures: "12m", "99.98%", "240 ms". */
|
|
225
|
+
value?: React$1.ReactNode | undefined;
|
|
226
|
+
/** The value's colour. Default: the status's (down → danger, problem → warning, maintenance → accent, ok and
|
|
227
|
+
* unknown → default). */
|
|
228
|
+
valueTone?: TileTone | undefined;
|
|
229
|
+
/** A short second line: "since 09:41", "3 of 4 checks". */
|
|
230
|
+
meta?: React$1.ReactNode | undefined;
|
|
231
|
+
/** Small icons at the end of the second line, each with a label. */
|
|
232
|
+
markers?: ReadonlyArray<StatusTileMarker> | undefined;
|
|
233
|
+
/** Makes the whole tile a link. Its name is everything the tile says, in reading order. */
|
|
234
|
+
href?: string | undefined;
|
|
235
|
+
/** Your router's link (e.g. `next/link`); defaults to AuraProvider's `linkComponent`, then `<a>`. */
|
|
236
|
+
linkComponent?: React$1.ElementType | undefined;
|
|
237
|
+
/** The status word read out after the title. Default: the locale's (Down, Problem, Maintenance, OK, No data). */
|
|
238
|
+
statusLabel?: string | undefined;
|
|
239
|
+
className?: string | undefined;
|
|
240
|
+
}
|
|
241
|
+
export interface TileGridProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "style" | "lang" | "dir">, React$1.AriaAttributes, DataAttributes {
|
|
242
|
+
/** Equal columns, responsive like Grid. Default `{ base: 2, md: 3 }` (two on phones, three from 768px). */
|
|
243
|
+
columns?: Responsive<number> | undefined;
|
|
244
|
+
/** Each child (and each child of a Fragment) becomes one list item; the grid is a `ul` with an 8px gap. */
|
|
245
|
+
children?: React$1.ReactNode;
|
|
246
|
+
className?: string | undefined;
|
|
247
|
+
}
|
|
248
|
+
export interface SparklineProps extends Pick<React$1.SVGAttributes<SVGSVGElement>, "id" | "style">, DataAttributes {
|
|
249
|
+
/** The values, oldest first. `null` (or a value that isn't a finite number) is no point: the line breaks there. */
|
|
250
|
+
data: ReadonlyArray<number | null | undefined>;
|
|
251
|
+
/** Which points failed, by the same index as `data`. Shown only when `failures` isn't `none`. */
|
|
252
|
+
failed?: ReadonlyArray<boolean | null | undefined> | undefined;
|
|
253
|
+
/** How failed points show: `none` (default), `band` (a red band behind the point) or `ticks` (a red tick at the
|
|
254
|
+
* foot). */
|
|
255
|
+
failures?: "none" | "band" | "ticks" | undefined;
|
|
256
|
+
/** The line's colour. Default `neutral`. */
|
|
257
|
+
tone?: "neutral" | "accent" | "danger" | "warning" | "positive" | undefined;
|
|
258
|
+
/** `sm` 80×24 (default), `md` 120×32. */
|
|
259
|
+
size?: "sm" | "md" | undefined;
|
|
260
|
+
/** The scale's ends; default the data's own lowest and highest. Give tiles the same ones to compare them. Values
|
|
261
|
+
* beyond them are drawn at the edge. */
|
|
262
|
+
min?: number | undefined;
|
|
263
|
+
max?: number | undefined;
|
|
264
|
+
/** What the line says, for screen readers ("Response time, last 24 h: 180–420 ms, 2 failures"). Without it the
|
|
265
|
+
* sparkline is decoration and hidden from them. */
|
|
266
|
+
label?: string | undefined;
|
|
267
|
+
className?: string | undefined;
|
|
268
|
+
}
|
|
202
269
|
/** Options for formatDate: locale/calendar plus a preset or any Intl.DateTimeFormat options. */
|
|
203
270
|
export type FormatDateOptions = DateDisplayOptions & {
|
|
204
271
|
format?: "short" | "long" | "numeric" | Intl.DateTimeFormatOptions | undefined;
|
|
@@ -309,6 +376,13 @@ export interface AuraStrings {
|
|
|
309
376
|
breadcrumbMore: string;
|
|
310
377
|
/** A Stepper step with `status: 'error'` (5.18). */
|
|
311
378
|
stepError: string;
|
|
379
|
+
/** StatusTile's status words (5.34). */
|
|
380
|
+
statusDown: string;
|
|
381
|
+
statusProblem: string;
|
|
382
|
+
statusMaintenance: string;
|
|
383
|
+
statusOk: string;
|
|
384
|
+
/** StatusTile `unknown` (5.35). */
|
|
385
|
+
statusUnknown: string;
|
|
312
386
|
}
|
|
313
387
|
/** Built-in strings by locale. th and sv also ship as packs (`@jirawatpyk/aura-react/locales/th`, `/sv`, 5.9); in 6.0
|
|
314
388
|
* only en stays built in and a Thai or Swedish app passes its pack to AuraProvider `strings`. */
|
|
@@ -430,6 +504,9 @@ export interface PageHeaderProps extends Pick<React$1.HTMLAttributes<HTMLElement
|
|
|
430
504
|
style?: React$1.CSSProperties | undefined;
|
|
431
505
|
}
|
|
432
506
|
export declare const PageHeader: React$1.ForwardRefExoticComponent<PageHeaderProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
507
|
+
declare function ServerStatusTile(props: StatusTileProps): React$1.ReactElement;
|
|
508
|
+
export declare const TileGrid: React$1.ForwardRefExoticComponent<TileGridProps & React$1.RefAttributes<HTMLUListElement>>;
|
|
509
|
+
export declare const Sparkline: React$1.ForwardRefExoticComponent<SparklineProps & React$1.RefAttributes<SVGSVGElement>>;
|
|
433
510
|
|
|
434
511
|
export {
|
|
435
512
|
ServerAlert as Alert,
|
|
@@ -439,6 +516,7 @@ export {
|
|
|
439
516
|
ServerEmptyState as EmptyState,
|
|
440
517
|
ServerStat as Stat,
|
|
441
518
|
ServerStatusPill as StatusPill,
|
|
519
|
+
ServerStatusTile as StatusTile,
|
|
442
520
|
scale as brandScale,
|
|
443
521
|
toneFor as statusTone,
|
|
444
522
|
};
|
package/dist/server/index.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ export interface DateDisplayOptions {
|
|
|
112
112
|
export type DataAttributes = {
|
|
113
113
|
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
114
114
|
};
|
|
115
|
+
export type Breakpoint = "base" | "sm" | "md" | "lg" | "xl";
|
|
116
|
+
export type Responsive<T> = T | Partial<Record<Breakpoint, T>>;
|
|
115
117
|
export interface StatChange {
|
|
116
118
|
/** Shown as written, e.g. "+12%" or "−3". */
|
|
117
119
|
value: React$1.ReactNode;
|
|
@@ -199,6 +201,71 @@ export interface Theme {
|
|
|
199
201
|
/** CSS overriding the tokens. No selector: the whole page. A selector (".tenant-acme") scopes it. Load after aura.css. */
|
|
200
202
|
css(selector?: string): string;
|
|
201
203
|
}
|
|
204
|
+
/** A monitored thing's state on a StatusTile. */
|
|
205
|
+
export type StatusTileStatus = "down" | "problem" | "maintenance" | "ok" | "unknown";
|
|
206
|
+
/** A colour for a tile's value or a marker: `danger`, `warning`, `accent` (violet), `neutral` (grey) or `default`
|
|
207
|
+
* (the text colour). */
|
|
208
|
+
export type TileTone = "danger" | "warning" | "accent" | "neutral" | "default";
|
|
209
|
+
/** A small icon at the end of a StatusTile's second line ("SSL expires soon", "Muted"). */
|
|
210
|
+
export interface StatusTileMarker {
|
|
211
|
+
icon: IconInput;
|
|
212
|
+
/** What it means. Read with the tile's name and shown as a tip on hover (a mouse only: on a phone, say it on the
|
|
213
|
+
* detail page too). */
|
|
214
|
+
label: string;
|
|
215
|
+
/** Default `neutral`. */
|
|
216
|
+
tone?: TileTone | undefined;
|
|
217
|
+
}
|
|
218
|
+
export interface StatusTileProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "style" | "lang" | "dir">, React$1.AriaAttributes, DataAttributes {
|
|
219
|
+
/** down (red), problem (amber), maintenance (violet), ok (grey) or unknown (5.35: no data yet — a dashed circle on
|
|
220
|
+
* the plain surface). Each has its own icon too, so colour is never the only sign. */
|
|
221
|
+
status: StatusTileStatus;
|
|
222
|
+
/** The name. Wraps to two lines at most, then ends with "…"; a cut name shows in full in a tip on hover. */
|
|
223
|
+
title: React$1.ReactNode;
|
|
224
|
+
/** Top right, tabular figures: "12m", "99.98%", "240 ms". */
|
|
225
|
+
value?: React$1.ReactNode | undefined;
|
|
226
|
+
/** The value's colour. Default: the status's (down → danger, problem → warning, maintenance → accent, ok and
|
|
227
|
+
* unknown → default). */
|
|
228
|
+
valueTone?: TileTone | undefined;
|
|
229
|
+
/** A short second line: "since 09:41", "3 of 4 checks". */
|
|
230
|
+
meta?: React$1.ReactNode | undefined;
|
|
231
|
+
/** Small icons at the end of the second line, each with a label. */
|
|
232
|
+
markers?: ReadonlyArray<StatusTileMarker> | undefined;
|
|
233
|
+
/** Makes the whole tile a link. Its name is everything the tile says, in reading order. */
|
|
234
|
+
href?: string | undefined;
|
|
235
|
+
/** Your router's link (e.g. `next/link`); defaults to AuraProvider's `linkComponent`, then `<a>`. */
|
|
236
|
+
linkComponent?: React$1.ElementType | undefined;
|
|
237
|
+
/** The status word read out after the title. Default: the locale's (Down, Problem, Maintenance, OK, No data). */
|
|
238
|
+
statusLabel?: string | undefined;
|
|
239
|
+
className?: string | undefined;
|
|
240
|
+
}
|
|
241
|
+
export interface TileGridProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "style" | "lang" | "dir">, React$1.AriaAttributes, DataAttributes {
|
|
242
|
+
/** Equal columns, responsive like Grid. Default `{ base: 2, md: 3 }` (two on phones, three from 768px). */
|
|
243
|
+
columns?: Responsive<number> | undefined;
|
|
244
|
+
/** Each child (and each child of a Fragment) becomes one list item; the grid is a `ul` with an 8px gap. */
|
|
245
|
+
children?: React$1.ReactNode;
|
|
246
|
+
className?: string | undefined;
|
|
247
|
+
}
|
|
248
|
+
export interface SparklineProps extends Pick<React$1.SVGAttributes<SVGSVGElement>, "id" | "style">, DataAttributes {
|
|
249
|
+
/** The values, oldest first. `null` (or a value that isn't a finite number) is no point: the line breaks there. */
|
|
250
|
+
data: ReadonlyArray<number | null | undefined>;
|
|
251
|
+
/** Which points failed, by the same index as `data`. Shown only when `failures` isn't `none`. */
|
|
252
|
+
failed?: ReadonlyArray<boolean | null | undefined> | undefined;
|
|
253
|
+
/** How failed points show: `none` (default), `band` (a red band behind the point) or `ticks` (a red tick at the
|
|
254
|
+
* foot). */
|
|
255
|
+
failures?: "none" | "band" | "ticks" | undefined;
|
|
256
|
+
/** The line's colour. Default `neutral`. */
|
|
257
|
+
tone?: "neutral" | "accent" | "danger" | "warning" | "positive" | undefined;
|
|
258
|
+
/** `sm` 80×24 (default), `md` 120×32. */
|
|
259
|
+
size?: "sm" | "md" | undefined;
|
|
260
|
+
/** The scale's ends; default the data's own lowest and highest. Give tiles the same ones to compare them. Values
|
|
261
|
+
* beyond them are drawn at the edge. */
|
|
262
|
+
min?: number | undefined;
|
|
263
|
+
max?: number | undefined;
|
|
264
|
+
/** What the line says, for screen readers ("Response time, last 24 h: 180–420 ms, 2 failures"). Without it the
|
|
265
|
+
* sparkline is decoration and hidden from them. */
|
|
266
|
+
label?: string | undefined;
|
|
267
|
+
className?: string | undefined;
|
|
268
|
+
}
|
|
202
269
|
/** Options for formatDate: locale/calendar plus a preset or any Intl.DateTimeFormat options. */
|
|
203
270
|
export type FormatDateOptions = DateDisplayOptions & {
|
|
204
271
|
format?: "short" | "long" | "numeric" | Intl.DateTimeFormatOptions | undefined;
|
|
@@ -309,6 +376,13 @@ export interface AuraStrings {
|
|
|
309
376
|
breadcrumbMore: string;
|
|
310
377
|
/** A Stepper step with `status: 'error'` (5.18). */
|
|
311
378
|
stepError: string;
|
|
379
|
+
/** StatusTile's status words (5.34). */
|
|
380
|
+
statusDown: string;
|
|
381
|
+
statusProblem: string;
|
|
382
|
+
statusMaintenance: string;
|
|
383
|
+
statusOk: string;
|
|
384
|
+
/** StatusTile `unknown` (5.35). */
|
|
385
|
+
statusUnknown: string;
|
|
312
386
|
}
|
|
313
387
|
/** Built-in strings by locale. th and sv also ship as packs (`@jirawatpyk/aura-react/locales/th`, `/sv`, 5.9); in 6.0
|
|
314
388
|
* only en stays built in and a Thai or Swedish app passes its pack to AuraProvider `strings`. */
|
|
@@ -430,6 +504,9 @@ export interface PageHeaderProps extends Pick<React$1.HTMLAttributes<HTMLElement
|
|
|
430
504
|
style?: React$1.CSSProperties | undefined;
|
|
431
505
|
}
|
|
432
506
|
export declare const PageHeader: React$1.ForwardRefExoticComponent<PageHeaderProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
507
|
+
declare function ServerStatusTile(props: StatusTileProps): React$1.ReactElement;
|
|
508
|
+
export declare const TileGrid: React$1.ForwardRefExoticComponent<TileGridProps & React$1.RefAttributes<HTMLUListElement>>;
|
|
509
|
+
export declare const Sparkline: React$1.ForwardRefExoticComponent<SparklineProps & React$1.RefAttributes<SVGSVGElement>>;
|
|
433
510
|
|
|
434
511
|
export {
|
|
435
512
|
ServerAlert as Alert,
|
|
@@ -439,6 +516,7 @@ export {
|
|
|
439
516
|
ServerEmptyState as EmptyState,
|
|
440
517
|
ServerStat as Stat,
|
|
441
518
|
ServerStatusPill as StatusPill,
|
|
519
|
+
ServerStatusTile as StatusTile,
|
|
442
520
|
scale as brandScale,
|
|
443
521
|
toneFor as statusTone,
|
|
444
522
|
};
|