@jirawatpyk/aura-react 5.32.0 → 5.34.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 +17 -2
- package/dist/aura.bundle.js +710 -414
- package/dist/cjs/index.cjs +709 -413
- package/dist/esm/AppShell.js +33 -14
- package/dist/esm/PageHeader.js +1 -0
- 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/strings.js +4 -0
- package/dist/esm/strings.sv.js +4 -0
- package/dist/esm/strings.th.js +4 -0
- package/dist/esm/tiles.js +212 -0
- package/dist/index.d.cts +119 -36
- package/dist/index.d.ts +119 -36
- package/dist/locales/sv.cjs +4 -0
- package/dist/locales/sv.d.cts +5 -0
- package/dist/locales/sv.d.ts +5 -0
- package/dist/locales/th.cjs +4 -0
- package/dist/locales/th.d.cts +5 -0
- package/dist/locales/th.d.ts +5 -0
- package/dist/server/index.cjs +264 -27
- package/dist/server/index.d.cts +79 -0
- package/dist/server/index.d.ts +79 -0
- package/dist/server/index.js +264 -27
- package/dist/styles.css +103 -24
- package/dist/styles.layer.css +103 -24
- 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,15 @@ 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",
|
|
337
344
|
accepts: function(list, max) {
|
|
338
345
|
return [list, max && "\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 " + max + " \u0E15\u0E48\u0E2D\u0E44\u0E1F\u0E25\u0E4C"].filter(Boolean).join(" \xB7 ");
|
|
339
346
|
}
|
|
@@ -460,11 +467,15 @@ var sv = {
|
|
|
460
467
|
pageN: function(p) {
|
|
461
468
|
return "Sida " + p;
|
|
462
469
|
},
|
|
463
|
-
progressReserved: function(v,
|
|
464
|
-
return nsv(v) + " av " + nsv(max) + " anv\xE4nda, " + nsv(
|
|
470
|
+
progressReserved: function(v, r2, max) {
|
|
471
|
+
return nsv(v) + " av " + nsv(max) + " anv\xE4nda, " + nsv(r2) + " reserverade";
|
|
465
472
|
},
|
|
466
473
|
breadcrumbMore: "Visa hela s\xF6kv\xE4gen",
|
|
467
474
|
stepError: "har fel",
|
|
475
|
+
statusDown: "Nere",
|
|
476
|
+
statusProblem: "Problem",
|
|
477
|
+
statusMaintenance: "Underh\xE5ll",
|
|
478
|
+
statusOk: "OK",
|
|
468
479
|
accepts: function(list, max) {
|
|
469
480
|
return [list, max && "h\xF6gst " + max + " per fil"].filter(Boolean).join(", ");
|
|
470
481
|
}
|
|
@@ -592,11 +603,15 @@ var STRINGS = {
|
|
|
592
603
|
pageN: function(p) {
|
|
593
604
|
return "Page " + p;
|
|
594
605
|
},
|
|
595
|
-
progressReserved: function(v,
|
|
596
|
-
return n2(v) + " of " + n2(max) + " used, " + n2(
|
|
606
|
+
progressReserved: function(v, r2, max) {
|
|
607
|
+
return n2(v) + " of " + n2(max) + " used, " + n2(r2) + " reserved";
|
|
597
608
|
},
|
|
598
609
|
breadcrumbMore: "Show the full path",
|
|
599
610
|
stepError: "has errors",
|
|
611
|
+
statusDown: "Down",
|
|
612
|
+
statusProblem: "Problem",
|
|
613
|
+
statusMaintenance: "Maintenance",
|
|
614
|
+
statusOk: "OK",
|
|
600
615
|
accepts: function(list, max) {
|
|
601
616
|
return [list, max && "up to " + max + " each"].filter(Boolean).join(", ");
|
|
602
617
|
}
|
|
@@ -607,14 +622,14 @@ var STRINGS = {
|
|
|
607
622
|
|
|
608
623
|
// src/theme.ts
|
|
609
624
|
function hexToRgb(hex) {
|
|
610
|
-
let
|
|
611
|
-
if (
|
|
612
|
-
|
|
625
|
+
let h6 = String(hex).trim().replace("#", "");
|
|
626
|
+
if (h6.length === 3)
|
|
627
|
+
h6 = h6.split("").map(function(c) {
|
|
613
628
|
return c + c;
|
|
614
629
|
}).join("");
|
|
615
|
-
if (!/^[0-9a-f]{6}$/i.test(
|
|
630
|
+
if (!/^[0-9a-f]{6}$/i.test(h6)) throw new Error('createTheme: "' + hex + '" is not a #rgb or #rrggbb colour');
|
|
616
631
|
return [0, 2, 4].map(function(i) {
|
|
617
|
-
return parseInt(
|
|
632
|
+
return parseInt(h6.slice(i, i + 2), 16) / 255;
|
|
618
633
|
});
|
|
619
634
|
}
|
|
620
635
|
function rgbToHex(rgb) {
|
|
@@ -630,10 +645,10 @@ function delin(c) {
|
|
|
630
645
|
return c <= 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
|
|
631
646
|
}
|
|
632
647
|
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 *
|
|
648
|
+
const r2 = lin(rgb[0]), g = lin(rgb[1]), b = lin(rgb[2]);
|
|
649
|
+
const l = Math.cbrt(0.4122214708 * r2 + 0.5363325363 * g + 0.0514459929 * b);
|
|
650
|
+
const m = Math.cbrt(0.2119034982 * r2 + 0.6806995451 * g + 0.1073969566 * b);
|
|
651
|
+
const s = Math.cbrt(0.0883024619 * r2 + 0.2817188376 * g + 0.6299787005 * b);
|
|
637
652
|
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
638
653
|
const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
639
654
|
const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
@@ -793,13 +808,13 @@ function createTheme(opts) {
|
|
|
793
808
|
D["card-shadow-creative"] = "8px 8px 0px " + shadowDark;
|
|
794
809
|
const checks = [];
|
|
795
810
|
function check(theme, fg, bg, target, fgHex, bgHex) {
|
|
796
|
-
const
|
|
811
|
+
const r2 = contrast(fgHex, bgHex);
|
|
797
812
|
checks.push({
|
|
798
813
|
theme,
|
|
799
814
|
pair: fg + " on " + bg,
|
|
800
|
-
ratio: Math.round(
|
|
815
|
+
ratio: Math.round(r2 * 100) / 100,
|
|
801
816
|
target,
|
|
802
|
-
pass:
|
|
817
|
+
pass: r2 >= target - 5e-3
|
|
803
818
|
});
|
|
804
819
|
}
|
|
805
820
|
[
|
|
@@ -919,6 +934,18 @@ function colorSchemeScript(options) {
|
|
|
919
934
|
|
|
920
935
|
// src/breakpoints.ts
|
|
921
936
|
var breakpoints = { sm: 640, md: 768, lg: 1024, xl: 1280 };
|
|
937
|
+
var ORDER = ["base", "sm", "md", "lg", "xl"];
|
|
938
|
+
function respVars(prefix, value, map2) {
|
|
939
|
+
const style = {};
|
|
940
|
+
if (value == null) return style;
|
|
941
|
+
if (typeof value !== "object") value = { base: value };
|
|
942
|
+
let byBp = value, cur;
|
|
943
|
+
ORDER.forEach(function(k) {
|
|
944
|
+
if (byBp[k] !== void 0) cur = map2 ? map2(byBp[k]) : byBp[k];
|
|
945
|
+
if (cur !== void 0) style["--" + prefix + "-" + k] = cur;
|
|
946
|
+
});
|
|
947
|
+
return style;
|
|
948
|
+
}
|
|
922
949
|
|
|
923
950
|
// src/display.tsx
|
|
924
951
|
var React3 = __toESM(require("react"), 1);
|
|
@@ -982,9 +1009,9 @@ function iconSvg(shapes, props, ref) {
|
|
|
982
1009
|
...a11y
|
|
983
1010
|
},
|
|
984
1011
|
shapes.map(function(s, i) {
|
|
985
|
-
const
|
|
986
|
-
for (const k in s[1])
|
|
987
|
-
return h(s[0],
|
|
1012
|
+
const attrs2 = { key: i };
|
|
1013
|
+
for (const k in s[1]) attrs2[k === "stroke-width" ? "strokeWidth" : k] = s[1][k];
|
|
1014
|
+
return h(s[0], attrs2);
|
|
988
1015
|
})
|
|
989
1016
|
);
|
|
990
1017
|
}
|
|
@@ -1116,6 +1143,14 @@ var IconTrendingDown = /* @__PURE__ */ defineIcon("trending-down", [
|
|
|
1116
1143
|
["path", { d: "M16 17h6v-6" }],
|
|
1117
1144
|
["path", { d: "m22 17-8.5-8.5-5 5L2 7" }]
|
|
1118
1145
|
]);
|
|
1146
|
+
var IconWrench = /* @__PURE__ */ defineIcon("wrench", [
|
|
1147
|
+
[
|
|
1148
|
+
"path",
|
|
1149
|
+
{
|
|
1150
|
+
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"
|
|
1151
|
+
}
|
|
1152
|
+
]
|
|
1153
|
+
]);
|
|
1119
1154
|
|
|
1120
1155
|
// src/display.tsx
|
|
1121
1156
|
var h2 = React3.createElement;
|
|
@@ -1356,14 +1391,14 @@ function ServerAvatar(props) {
|
|
|
1356
1391
|
var React4 = __toESM(require("react"), 1);
|
|
1357
1392
|
var h3 = React4.createElement;
|
|
1358
1393
|
var Container = React4.forwardRef(function Container2(props, ref) {
|
|
1359
|
-
const
|
|
1394
|
+
const attrs2 = {};
|
|
1360
1395
|
Object.keys(props).forEach(function(k) {
|
|
1361
1396
|
if (k === "id" || k === "lang" || k === "dir" || /^(aria|data)-/.test(k))
|
|
1362
|
-
|
|
1397
|
+
attrs2[k] = props[k];
|
|
1363
1398
|
});
|
|
1364
1399
|
return h3(
|
|
1365
1400
|
props.as || "div",
|
|
1366
|
-
Object.assign(
|
|
1401
|
+
Object.assign(attrs2, {
|
|
1367
1402
|
ref,
|
|
1368
1403
|
className: cx(
|
|
1369
1404
|
"aura-container",
|
|
@@ -1381,18 +1416,19 @@ var Container = React4.forwardRef(function Container2(props, ref) {
|
|
|
1381
1416
|
var React5 = __toESM(require("react"), 1);
|
|
1382
1417
|
var h4 = React5.createElement;
|
|
1383
1418
|
var PageHeader = React5.forwardRef(function PageHeader2(props, ref) {
|
|
1384
|
-
const
|
|
1419
|
+
const attrs2 = {};
|
|
1385
1420
|
Object.keys(props).forEach(function(k) {
|
|
1386
1421
|
if (k === "id" || k === "lang" || k === "dir" || k === "role" || /^(aria|data)-/.test(k))
|
|
1387
|
-
|
|
1422
|
+
attrs2[k] = props[k];
|
|
1388
1423
|
});
|
|
1389
1424
|
const level = props.headingLevel || 1;
|
|
1390
1425
|
return h4(
|
|
1391
1426
|
"div",
|
|
1392
|
-
Object.assign(
|
|
1427
|
+
Object.assign(attrs2, { ref, className: cx("aura-page-header", props.className), style: props.style }),
|
|
1393
1428
|
h4(
|
|
1394
1429
|
"div",
|
|
1395
1430
|
{ className: "aura-page-header__text" },
|
|
1431
|
+
props.breadcrumb != null && props.breadcrumb !== false ? h4("div", { className: "aura-page-header__breadcrumb" }, props.breadcrumb) : null,
|
|
1396
1432
|
props.eyebrow != null && props.eyebrow !== false ? h4("p", { className: "aura-page-header__eyebrow" }, props.eyebrow) : null,
|
|
1397
1433
|
h4("h" + level, { className: "aura-page-header__title", id: props.titleId }, props.title),
|
|
1398
1434
|
props.meta != null && props.meta !== false ? h4("div", { className: "aura-page-header__meta" }, props.meta) : null
|
|
@@ -1400,3 +1436,204 @@ var PageHeader = React5.forwardRef(function PageHeader2(props, ref) {
|
|
|
1400
1436
|
props.actions != null && props.actions !== false ? h4("div", { className: "aura-page-header__actions" }, props.actions) : null
|
|
1401
1437
|
);
|
|
1402
1438
|
});
|
|
1439
|
+
|
|
1440
|
+
// src/tiles.tsx
|
|
1441
|
+
var React6 = __toESM(require("react"), 1);
|
|
1442
|
+
var h5 = React6.createElement;
|
|
1443
|
+
var STATUS_ICON = {
|
|
1444
|
+
down: IconCircleAlert,
|
|
1445
|
+
problem: IconTriangleAlert,
|
|
1446
|
+
maintenance: IconWrench,
|
|
1447
|
+
ok: IconCircleCheck
|
|
1448
|
+
};
|
|
1449
|
+
var STATUS_TONE = {
|
|
1450
|
+
down: "danger",
|
|
1451
|
+
problem: "warning",
|
|
1452
|
+
maintenance: "accent",
|
|
1453
|
+
ok: "default"
|
|
1454
|
+
};
|
|
1455
|
+
var STATUS_WORD = {
|
|
1456
|
+
down: "statusDown",
|
|
1457
|
+
problem: "statusProblem",
|
|
1458
|
+
maintenance: "statusMaintenance",
|
|
1459
|
+
ok: "statusOk"
|
|
1460
|
+
};
|
|
1461
|
+
function statusWord(status, t) {
|
|
1462
|
+
return String(t[STATUS_WORD[status]] || STATUS_WORD[status]);
|
|
1463
|
+
}
|
|
1464
|
+
function attrs(props) {
|
|
1465
|
+
const out = {};
|
|
1466
|
+
Object.keys(props).forEach(function(k) {
|
|
1467
|
+
if (k === "id" || k === "style" || k === "lang" || k === "dir" || /^(aria|data)-/.test(k))
|
|
1468
|
+
out[k] = props[k];
|
|
1469
|
+
});
|
|
1470
|
+
return out;
|
|
1471
|
+
}
|
|
1472
|
+
var comma = h5("span", { className: "aura-status-tile__sep" }, ",");
|
|
1473
|
+
function statusTileElement(props, ref, Link, t, titleRef) {
|
|
1474
|
+
const status = STATUS_ICON[props.status] ? props.status : "ok";
|
|
1475
|
+
const valueTone = props.valueTone || STATUS_TONE[status];
|
|
1476
|
+
const word = props.statusLabel || statusWord(status, t);
|
|
1477
|
+
const markers = (props.markers || []).filter(Boolean);
|
|
1478
|
+
const has = function(v) {
|
|
1479
|
+
return v != null && v !== false && v !== "";
|
|
1480
|
+
};
|
|
1481
|
+
const hasValue = has(props.value), hasMeta = has(props.meta);
|
|
1482
|
+
const Tag = props.href ? Link : "div";
|
|
1483
|
+
return h5(
|
|
1484
|
+
Tag,
|
|
1485
|
+
Object.assign(attrs(props), {
|
|
1486
|
+
ref,
|
|
1487
|
+
href: props.href,
|
|
1488
|
+
className: cx("aura-status-tile", "aura-status-tile--" + status, props.href && "is-interactive", props.className)
|
|
1489
|
+
}),
|
|
1490
|
+
h5(
|
|
1491
|
+
"span",
|
|
1492
|
+
{ className: "aura-status-tile__head" },
|
|
1493
|
+
h5(Icon, { name: h5(STATUS_ICON[status]), size: 16, className: "aura-status-tile__icon" }),
|
|
1494
|
+
h5("span", { className: "aura-status-tile__title", ref: titleRef }, props.title, comma),
|
|
1495
|
+
h5("span", { className: "aura-sr-only" }, word + (hasValue || hasMeta || markers.length ? "," : "")),
|
|
1496
|
+
hasValue ? h5(
|
|
1497
|
+
"span",
|
|
1498
|
+
{ className: cx("aura-status-tile__value", "is-" + valueTone) },
|
|
1499
|
+
props.value,
|
|
1500
|
+
hasMeta || markers.length ? comma : null
|
|
1501
|
+
) : null
|
|
1502
|
+
),
|
|
1503
|
+
hasMeta || markers.length ? h5(
|
|
1504
|
+
"span",
|
|
1505
|
+
{ className: "aura-status-tile__foot" },
|
|
1506
|
+
hasMeta ? h5("span", { className: "aura-status-tile__meta" }, props.meta, markers.length ? comma : null) : null,
|
|
1507
|
+
markers.length ? h5(
|
|
1508
|
+
"span",
|
|
1509
|
+
{ className: "aura-status-tile__markers" },
|
|
1510
|
+
markers.map(function(m, i) {
|
|
1511
|
+
return h5(
|
|
1512
|
+
"span",
|
|
1513
|
+
{
|
|
1514
|
+
key: i,
|
|
1515
|
+
className: cx("aura-status-tile__marker", "is-" + (m.tone || "neutral")),
|
|
1516
|
+
"data-aura-tip": m.label
|
|
1517
|
+
},
|
|
1518
|
+
h5(Icon, { name: m.icon, size: 14 }),
|
|
1519
|
+
h5("span", { className: "aura-sr-only" }, m.label + (i < markers.length - 1 ? "," : ""))
|
|
1520
|
+
);
|
|
1521
|
+
})
|
|
1522
|
+
) : null
|
|
1523
|
+
) : null
|
|
1524
|
+
);
|
|
1525
|
+
}
|
|
1526
|
+
function ServerStatusTile(props) {
|
|
1527
|
+
return statusTileElement(props, void 0, props.linkComponent || "a", STRINGS.en);
|
|
1528
|
+
}
|
|
1529
|
+
var TileGrid = React6.forwardRef(function TileGrid2(props, ref) {
|
|
1530
|
+
const style = Object.assign(
|
|
1531
|
+
{},
|
|
1532
|
+
respVars("aura-grid-cols", props.columns == null ? { base: 2, md: 3 } : props.columns),
|
|
1533
|
+
props.style
|
|
1534
|
+
);
|
|
1535
|
+
return h5(
|
|
1536
|
+
"ul",
|
|
1537
|
+
Object.assign(attrs(props), {
|
|
1538
|
+
ref,
|
|
1539
|
+
role: "list",
|
|
1540
|
+
className: cx("aura-grid-layout", "aura-tile-grid", props.className),
|
|
1541
|
+
style
|
|
1542
|
+
}),
|
|
1543
|
+
/* toArray drops null and booleans and keys each element; a Fragment's children are items too. */
|
|
1544
|
+
flat(props.children).map(function(c, i) {
|
|
1545
|
+
return h5("li", { key: React6.isValidElement(c) && c.key != null ? c.key : i }, c);
|
|
1546
|
+
})
|
|
1547
|
+
);
|
|
1548
|
+
});
|
|
1549
|
+
function flat(children) {
|
|
1550
|
+
const out = [];
|
|
1551
|
+
React6.Children.toArray(children).forEach(function(c) {
|
|
1552
|
+
if (React6.isValidElement(c) && c.type === React6.Fragment)
|
|
1553
|
+
flat(c.props.children).forEach(function(x) {
|
|
1554
|
+
out.push(React6.isValidElement(x) ? React6.cloneElement(x, { key: String(c.key) + "/" + String(x.key) }) : x);
|
|
1555
|
+
});
|
|
1556
|
+
else if (c !== "") out.push(c);
|
|
1557
|
+
});
|
|
1558
|
+
return out;
|
|
1559
|
+
}
|
|
1560
|
+
var SIZES2 = { sm: [80, 24], md: [120, 32] };
|
|
1561
|
+
var PAD = 2;
|
|
1562
|
+
function r(n3) {
|
|
1563
|
+
return Math.round(n3 * 100) / 100;
|
|
1564
|
+
}
|
|
1565
|
+
function num(v) {
|
|
1566
|
+
return typeof v === "number" && isFinite(v) ? v : null;
|
|
1567
|
+
}
|
|
1568
|
+
var Sparkline = React6.forwardRef(function Sparkline2(props, ref) {
|
|
1569
|
+
const wh = SIZES2[props.size || "sm"] || SIZES2.sm;
|
|
1570
|
+
const W = wh[0], H = wh[1];
|
|
1571
|
+
const data = (props.data || []).map(num);
|
|
1572
|
+
const n3 = data.length;
|
|
1573
|
+
const vals = data.filter(function(v) {
|
|
1574
|
+
return v != null;
|
|
1575
|
+
});
|
|
1576
|
+
let lo = num(props.min), hi = num(props.max);
|
|
1577
|
+
if (lo == null) lo = vals.length ? Math.min.apply(null, vals) : 0;
|
|
1578
|
+
if (hi == null) hi = vals.length ? Math.max.apply(null, vals) : 0;
|
|
1579
|
+
if (lo > hi) {
|
|
1580
|
+
const s = lo;
|
|
1581
|
+
lo = hi;
|
|
1582
|
+
hi = s;
|
|
1583
|
+
}
|
|
1584
|
+
const step = n3 > 1 ? (W - 2 * PAD) / (n3 - 1) : 0;
|
|
1585
|
+
const x = function(i) {
|
|
1586
|
+
return n3 > 1 ? PAD + i * step : W / 2;
|
|
1587
|
+
};
|
|
1588
|
+
const y = function(v) {
|
|
1589
|
+
if (hi === lo) return H / 2;
|
|
1590
|
+
const k = Math.max(0, Math.min(1, (v - lo) / (hi - lo)));
|
|
1591
|
+
return H - PAD - k * (H - 2 * PAD);
|
|
1592
|
+
};
|
|
1593
|
+
let d = "";
|
|
1594
|
+
const dots = [];
|
|
1595
|
+
data.forEach(function(v, i) {
|
|
1596
|
+
if (v == null) return;
|
|
1597
|
+
const prev = i > 0 && data[i - 1] != null, next = i < n3 - 1 && data[i + 1] != null;
|
|
1598
|
+
if (!prev && !next) dots.push(h5("circle", { key: "d" + i, cx: r(x(i)), cy: r(y(v)), r: 1.5 }));
|
|
1599
|
+
else d += (prev ? "L" : "M") + r(x(i)) + " " + r(y(v));
|
|
1600
|
+
});
|
|
1601
|
+
const mode = props.failures || "none";
|
|
1602
|
+
const fails = [];
|
|
1603
|
+
if (mode !== "none" && props.failed)
|
|
1604
|
+
data.forEach(function(_v, i) {
|
|
1605
|
+
if (!props.failed[i]) return;
|
|
1606
|
+
if (mode === "band") {
|
|
1607
|
+
const w = Math.max(2, step || W), left = Math.max(0, x(i) - w / 2), right = Math.min(W, x(i) + w / 2);
|
|
1608
|
+
fails.push(h5("rect", { key: "f" + i, x: r(left), y: 0, width: r(right - left), height: H }));
|
|
1609
|
+
} else
|
|
1610
|
+
fails.push(
|
|
1611
|
+
h5("rect", {
|
|
1612
|
+
key: "f" + i,
|
|
1613
|
+
x: r(Math.max(0, Math.min(W - 1.5, x(i) - 0.75))),
|
|
1614
|
+
y: H - 6,
|
|
1615
|
+
width: 1.5,
|
|
1616
|
+
height: 6
|
|
1617
|
+
})
|
|
1618
|
+
);
|
|
1619
|
+
});
|
|
1620
|
+
const named = !!props.label;
|
|
1621
|
+
return h5(
|
|
1622
|
+
"svg",
|
|
1623
|
+
Object.assign(attrs(props), {
|
|
1624
|
+
ref,
|
|
1625
|
+
className: cx("aura-sparkline", "is-" + (props.tone || "neutral"), props.className),
|
|
1626
|
+
width: W,
|
|
1627
|
+
height: H,
|
|
1628
|
+
viewBox: "0 0 " + W + " " + H,
|
|
1629
|
+
role: named ? "img" : void 0,
|
|
1630
|
+
"aria-label": named ? props.label : void 0,
|
|
1631
|
+
"aria-hidden": named ? void 0 : true,
|
|
1632
|
+
focusable: "false"
|
|
1633
|
+
}),
|
|
1634
|
+
fails.length && mode === "band" ? h5("g", { className: "aura-sparkline__band" }, fails) : null,
|
|
1635
|
+
d ? h5("path", { className: "aura-sparkline__line", d }) : null,
|
|
1636
|
+
dots.length ? h5("g", { className: "aura-sparkline__dots" }, dots) : null,
|
|
1637
|
+
fails.length && mode === "ticks" ? h5("g", { className: "aura-sparkline__ticks" }, fails) : null
|
|
1638
|
+
);
|
|
1639
|
+
});
|
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,70 @@ 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";
|
|
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) or ok (grey). Each has its own icon too, so colour is never the
|
|
220
|
+
* 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 → default). */
|
|
227
|
+
valueTone?: TileTone | undefined;
|
|
228
|
+
/** A short second line: "since 09:41", "3 of 4 checks". */
|
|
229
|
+
meta?: React$1.ReactNode | undefined;
|
|
230
|
+
/** Small icons at the end of the second line, each with a label. */
|
|
231
|
+
markers?: ReadonlyArray<StatusTileMarker> | undefined;
|
|
232
|
+
/** Makes the whole tile a link. Its name is everything the tile says, in reading order. */
|
|
233
|
+
href?: string | undefined;
|
|
234
|
+
/** Your router's link (e.g. `next/link`); defaults to AuraProvider's `linkComponent`, then `<a>`. */
|
|
235
|
+
linkComponent?: React$1.ElementType | undefined;
|
|
236
|
+
/** The status word read out after the title. Default: the locale's (Down, Problem, Maintenance, OK). */
|
|
237
|
+
statusLabel?: string | undefined;
|
|
238
|
+
className?: string | undefined;
|
|
239
|
+
}
|
|
240
|
+
export interface TileGridProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "style" | "lang" | "dir">, React$1.AriaAttributes, DataAttributes {
|
|
241
|
+
/** Equal columns, responsive like Grid. Default `{ base: 2, md: 3 }` (two on phones, three from 768px). */
|
|
242
|
+
columns?: Responsive<number> | undefined;
|
|
243
|
+
/** Each child (and each child of a Fragment) becomes one list item; the grid is a `ul` with an 8px gap. */
|
|
244
|
+
children?: React$1.ReactNode;
|
|
245
|
+
className?: string | undefined;
|
|
246
|
+
}
|
|
247
|
+
export interface SparklineProps extends Pick<React$1.SVGAttributes<SVGSVGElement>, "id" | "style">, DataAttributes {
|
|
248
|
+
/** The values, oldest first. `null` (or a value that isn't a finite number) is no point: the line breaks there. */
|
|
249
|
+
data: ReadonlyArray<number | null | undefined>;
|
|
250
|
+
/** Which points failed, by the same index as `data`. Shown only when `failures` isn't `none`. */
|
|
251
|
+
failed?: ReadonlyArray<boolean | null | undefined> | undefined;
|
|
252
|
+
/** How failed points show: `none` (default), `band` (a red band behind the point) or `ticks` (a red tick at the
|
|
253
|
+
* foot). */
|
|
254
|
+
failures?: "none" | "band" | "ticks" | undefined;
|
|
255
|
+
/** The line's colour. Default `neutral`. */
|
|
256
|
+
tone?: "neutral" | "accent" | "danger" | "warning" | "positive" | undefined;
|
|
257
|
+
/** `sm` 80×24 (default), `md` 120×32. */
|
|
258
|
+
size?: "sm" | "md" | undefined;
|
|
259
|
+
/** The scale's ends; default the data's own lowest and highest. Give tiles the same ones to compare them. Values
|
|
260
|
+
* beyond them are drawn at the edge. */
|
|
261
|
+
min?: number | undefined;
|
|
262
|
+
max?: number | undefined;
|
|
263
|
+
/** What the line says, for screen readers ("Response time, last 24 h: 180–420 ms, 2 failures"). Without it the
|
|
264
|
+
* sparkline is decoration and hidden from them. */
|
|
265
|
+
label?: string | undefined;
|
|
266
|
+
className?: string | undefined;
|
|
267
|
+
}
|
|
202
268
|
/** Options for formatDate: locale/calendar plus a preset or any Intl.DateTimeFormat options. */
|
|
203
269
|
export type FormatDateOptions = DateDisplayOptions & {
|
|
204
270
|
format?: "short" | "long" | "numeric" | Intl.DateTimeFormatOptions | undefined;
|
|
@@ -309,6 +375,11 @@ export interface AuraStrings {
|
|
|
309
375
|
breadcrumbMore: string;
|
|
310
376
|
/** A Stepper step with `status: 'error'` (5.18). */
|
|
311
377
|
stepError: string;
|
|
378
|
+
/** StatusTile's status words (5.34). */
|
|
379
|
+
statusDown: string;
|
|
380
|
+
statusProblem: string;
|
|
381
|
+
statusMaintenance: string;
|
|
382
|
+
statusOk: string;
|
|
312
383
|
}
|
|
313
384
|
/** Built-in strings by locale. th and sv also ship as packs (`@jirawatpyk/aura-react/locales/th`, `/sv`, 5.9); in 6.0
|
|
314
385
|
* only en stays built in and a Thai or Swedish app passes its pack to AuraProvider `strings`. */
|
|
@@ -412,6 +483,10 @@ export declare const Container: React$1.ForwardRefExoticComponent<ContainerProps
|
|
|
412
483
|
export interface PageHeaderProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "lang" | "dir" | "role">, React$1.AriaAttributes, DataAttributes {
|
|
413
484
|
/** Small mono line above the title — a section or breadcrumb-like context ("Monitor / Sites"). */
|
|
414
485
|
eyebrow?: React$1.ReactNode | undefined;
|
|
486
|
+
/** 5.33 (DxT Monitor #7): a `<Breadcrumb>` above the title, 4px from it like the eyebrow, in its own `div` (a `nav`
|
|
487
|
+
* can't sit in the eyebrow's `p`) and its own 13px sans. Detail pages show a breadcrumb or an eyebrow; with both,
|
|
488
|
+
* the breadcrumb comes first. */
|
|
489
|
+
breadcrumb?: React$1.ReactNode | undefined;
|
|
415
490
|
/** The page's heading. */
|
|
416
491
|
title: React$1.ReactNode;
|
|
417
492
|
/** A line under the title — counts, last update, owner. */
|
|
@@ -426,6 +501,9 @@ export interface PageHeaderProps extends Pick<React$1.HTMLAttributes<HTMLElement
|
|
|
426
501
|
style?: React$1.CSSProperties | undefined;
|
|
427
502
|
}
|
|
428
503
|
export declare const PageHeader: React$1.ForwardRefExoticComponent<PageHeaderProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
504
|
+
declare function ServerStatusTile(props: StatusTileProps): React$1.ReactElement;
|
|
505
|
+
export declare const TileGrid: React$1.ForwardRefExoticComponent<TileGridProps & React$1.RefAttributes<HTMLUListElement>>;
|
|
506
|
+
export declare const Sparkline: React$1.ForwardRefExoticComponent<SparklineProps & React$1.RefAttributes<SVGSVGElement>>;
|
|
429
507
|
|
|
430
508
|
export {
|
|
431
509
|
ServerAlert as Alert,
|
|
@@ -435,6 +513,7 @@ export {
|
|
|
435
513
|
ServerEmptyState as EmptyState,
|
|
436
514
|
ServerStat as Stat,
|
|
437
515
|
ServerStatusPill as StatusPill,
|
|
516
|
+
ServerStatusTile as StatusTile,
|
|
438
517
|
scale as brandScale,
|
|
439
518
|
toneFor as statusTone,
|
|
440
519
|
};
|
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,70 @@ 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";
|
|
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) or ok (grey). Each has its own icon too, so colour is never the
|
|
220
|
+
* 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 → default). */
|
|
227
|
+
valueTone?: TileTone | undefined;
|
|
228
|
+
/** A short second line: "since 09:41", "3 of 4 checks". */
|
|
229
|
+
meta?: React$1.ReactNode | undefined;
|
|
230
|
+
/** Small icons at the end of the second line, each with a label. */
|
|
231
|
+
markers?: ReadonlyArray<StatusTileMarker> | undefined;
|
|
232
|
+
/** Makes the whole tile a link. Its name is everything the tile says, in reading order. */
|
|
233
|
+
href?: string | undefined;
|
|
234
|
+
/** Your router's link (e.g. `next/link`); defaults to AuraProvider's `linkComponent`, then `<a>`. */
|
|
235
|
+
linkComponent?: React$1.ElementType | undefined;
|
|
236
|
+
/** The status word read out after the title. Default: the locale's (Down, Problem, Maintenance, OK). */
|
|
237
|
+
statusLabel?: string | undefined;
|
|
238
|
+
className?: string | undefined;
|
|
239
|
+
}
|
|
240
|
+
export interface TileGridProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "style" | "lang" | "dir">, React$1.AriaAttributes, DataAttributes {
|
|
241
|
+
/** Equal columns, responsive like Grid. Default `{ base: 2, md: 3 }` (two on phones, three from 768px). */
|
|
242
|
+
columns?: Responsive<number> | undefined;
|
|
243
|
+
/** Each child (and each child of a Fragment) becomes one list item; the grid is a `ul` with an 8px gap. */
|
|
244
|
+
children?: React$1.ReactNode;
|
|
245
|
+
className?: string | undefined;
|
|
246
|
+
}
|
|
247
|
+
export interface SparklineProps extends Pick<React$1.SVGAttributes<SVGSVGElement>, "id" | "style">, DataAttributes {
|
|
248
|
+
/** The values, oldest first. `null` (or a value that isn't a finite number) is no point: the line breaks there. */
|
|
249
|
+
data: ReadonlyArray<number | null | undefined>;
|
|
250
|
+
/** Which points failed, by the same index as `data`. Shown only when `failures` isn't `none`. */
|
|
251
|
+
failed?: ReadonlyArray<boolean | null | undefined> | undefined;
|
|
252
|
+
/** How failed points show: `none` (default), `band` (a red band behind the point) or `ticks` (a red tick at the
|
|
253
|
+
* foot). */
|
|
254
|
+
failures?: "none" | "band" | "ticks" | undefined;
|
|
255
|
+
/** The line's colour. Default `neutral`. */
|
|
256
|
+
tone?: "neutral" | "accent" | "danger" | "warning" | "positive" | undefined;
|
|
257
|
+
/** `sm` 80×24 (default), `md` 120×32. */
|
|
258
|
+
size?: "sm" | "md" | undefined;
|
|
259
|
+
/** The scale's ends; default the data's own lowest and highest. Give tiles the same ones to compare them. Values
|
|
260
|
+
* beyond them are drawn at the edge. */
|
|
261
|
+
min?: number | undefined;
|
|
262
|
+
max?: number | undefined;
|
|
263
|
+
/** What the line says, for screen readers ("Response time, last 24 h: 180–420 ms, 2 failures"). Without it the
|
|
264
|
+
* sparkline is decoration and hidden from them. */
|
|
265
|
+
label?: string | undefined;
|
|
266
|
+
className?: string | undefined;
|
|
267
|
+
}
|
|
202
268
|
/** Options for formatDate: locale/calendar plus a preset or any Intl.DateTimeFormat options. */
|
|
203
269
|
export type FormatDateOptions = DateDisplayOptions & {
|
|
204
270
|
format?: "short" | "long" | "numeric" | Intl.DateTimeFormatOptions | undefined;
|
|
@@ -309,6 +375,11 @@ export interface AuraStrings {
|
|
|
309
375
|
breadcrumbMore: string;
|
|
310
376
|
/** A Stepper step with `status: 'error'` (5.18). */
|
|
311
377
|
stepError: string;
|
|
378
|
+
/** StatusTile's status words (5.34). */
|
|
379
|
+
statusDown: string;
|
|
380
|
+
statusProblem: string;
|
|
381
|
+
statusMaintenance: string;
|
|
382
|
+
statusOk: string;
|
|
312
383
|
}
|
|
313
384
|
/** Built-in strings by locale. th and sv also ship as packs (`@jirawatpyk/aura-react/locales/th`, `/sv`, 5.9); in 6.0
|
|
314
385
|
* only en stays built in and a Thai or Swedish app passes its pack to AuraProvider `strings`. */
|
|
@@ -412,6 +483,10 @@ export declare const Container: React$1.ForwardRefExoticComponent<ContainerProps
|
|
|
412
483
|
export interface PageHeaderProps extends Pick<React$1.HTMLAttributes<HTMLElement>, "id" | "lang" | "dir" | "role">, React$1.AriaAttributes, DataAttributes {
|
|
413
484
|
/** Small mono line above the title — a section or breadcrumb-like context ("Monitor / Sites"). */
|
|
414
485
|
eyebrow?: React$1.ReactNode | undefined;
|
|
486
|
+
/** 5.33 (DxT Monitor #7): a `<Breadcrumb>` above the title, 4px from it like the eyebrow, in its own `div` (a `nav`
|
|
487
|
+
* can't sit in the eyebrow's `p`) and its own 13px sans. Detail pages show a breadcrumb or an eyebrow; with both,
|
|
488
|
+
* the breadcrumb comes first. */
|
|
489
|
+
breadcrumb?: React$1.ReactNode | undefined;
|
|
415
490
|
/** The page's heading. */
|
|
416
491
|
title: React$1.ReactNode;
|
|
417
492
|
/** A line under the title — counts, last update, owner. */
|
|
@@ -426,6 +501,9 @@ export interface PageHeaderProps extends Pick<React$1.HTMLAttributes<HTMLElement
|
|
|
426
501
|
style?: React$1.CSSProperties | undefined;
|
|
427
502
|
}
|
|
428
503
|
export declare const PageHeader: React$1.ForwardRefExoticComponent<PageHeaderProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
504
|
+
declare function ServerStatusTile(props: StatusTileProps): React$1.ReactElement;
|
|
505
|
+
export declare const TileGrid: React$1.ForwardRefExoticComponent<TileGridProps & React$1.RefAttributes<HTMLUListElement>>;
|
|
506
|
+
export declare const Sparkline: React$1.ForwardRefExoticComponent<SparklineProps & React$1.RefAttributes<SVGSVGElement>>;
|
|
429
507
|
|
|
430
508
|
export {
|
|
431
509
|
ServerAlert as Alert,
|
|
@@ -435,6 +513,7 @@ export {
|
|
|
435
513
|
ServerEmptyState as EmptyState,
|
|
436
514
|
ServerStat as Stat,
|
|
437
515
|
ServerStatusPill as StatusPill,
|
|
516
|
+
ServerStatusTile as StatusTile,
|
|
438
517
|
scale as brandScale,
|
|
439
518
|
toneFor as statusTone,
|
|
440
519
|
};
|