@ksp-gonogo/ui-kit 1.0.0-rc.34 → 1.0.0-rc.38

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.
@@ -1,7 +1,7 @@
1
1
  // src/gridUnits.ts
2
- var COL_WIDTH = 32;
3
- var ROW_HEIGHT = 25;
4
- var GRID_MARGIN = 8;
2
+ var COL_WIDTH = 21;
3
+ var ROW_HEIGHT = 13;
4
+ var GRID_MARGIN = 20;
5
5
  function gridToPixels(w, h) {
6
6
  return {
7
7
  pxW: w * COL_WIDTH + (w - 1) * GRID_MARGIN,
@@ -15,4 +15,4 @@ export {
15
15
  GRID_MARGIN,
16
16
  gridToPixels
17
17
  };
18
- //# sourceMappingURL=chunk-TPCENPJX.js.map
18
+ //# sourceMappingURL=chunk-5LJPQV5P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/gridUnits.ts"],"sourcesContent":["/**\n * The width of one dashboard grid column in CSS pixels, an approximation for\n * the dashboard's widest layout (36 columns across): on the dashboard a\n * column's real width is a fraction of the container. Use it to lay a widget\n * out outside the dashboard, such as in a test harness or a docs page. Used by\n * the docs and probe renderers that draw a widget at its dashboard size.\n *\n * @category Layout\n */\nexport const COL_WIDTH = 21;\n\n/**\n * The height of one dashboard grid row in CSS pixels. Useful for sizing a tile\n * the way the dashboard the operator sees does. Used by the dashboard grid.\n *\n * @category Layout\n */\nexport const ROW_HEIGHT = 13;\n\n/**\n * The gap between adjacent dashboard grid cells in CSS pixels. Useful for\n * sizing a tile the way the dashboard the operator sees does. Used by the\n * dashboard grid.\n *\n * @category Layout\n */\nexport const GRID_MARGIN = 20;\n\n/**\n * The pixel box of a `w` by `h` grid-unit tile, as `{ pxW, pxH }`. The margin\n * falls between cells, so `n` cells carry `n - 1` gaps and a single cell\n * carries none. Useful for drawing a widget at the size of its dashboard tile.\n * Used by {@link Panel} and by the probe that renders an Uplink's widget.\n *\n * @category Layout\n * @categoryDescription Layout\n * Arranging a widget's content: stacks, rows, clusters, grids, boxes, cards and\n * sections, the spacing scale they share, and the dashboard grid's cell sizes\n * for turning a tile's columns and rows into pixels.\n */\nexport function gridToPixels(\n w: number,\n h: number,\n): {\n pxW: number;\n pxH: number;\n} {\n return {\n pxW: w * COL_WIDTH + (w - 1) * GRID_MARGIN,\n pxH: h * ROW_HEIGHT + (h - 1) * GRID_MARGIN,\n };\n}\n"],"mappings":";AASO,IAAM,YAAY;AAQlB,IAAM,aAAa;AASnB,IAAM,cAAc;AAcpB,SAAS,aACd,GACA,GAIA;AACA,SAAO;AAAA,IACL,KAAK,IAAI,aAAa,IAAI,KAAK;AAAA,IAC/B,KAAK,IAAI,cAAc,IAAI,KAAK;AAAA,EAClC;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  gridToPixels
3
- } from "./chunk-TPCENPJX.js";
3
+ } from "./chunk-5LJPQV5P.js";
4
4
 
5
5
  // src/tone.ts
6
6
  var TONE_TEXT = {
@@ -3077,14 +3077,15 @@ var X = createLucideIcon("x", __iconNode43);
3077
3077
  // src/Icons.tsx
3078
3078
  import { forwardRef as forwardRef5 } from "react";
3079
3079
  import { jsx as jsx15 } from "react/jsx-runtime";
3080
+ var DEFAULT_SIZE = "var(--icon-size-control)";
3080
3081
  var ICON_DEFAULTS = {
3081
- size: "var(--icon-size-control)",
3082
3082
  strokeWidth: 1.8,
3083
3083
  "aria-hidden": true
3084
3084
  };
3085
3085
  function makeIcon(Component, extraDefaults) {
3086
3086
  const Wrapped = forwardRef5(
3087
- ({ label, ...props }, ref) => {
3087
+ ({ label, size = DEFAULT_SIZE, style, ...props }, ref) => {
3088
+ const sizing = typeof size === "number" ? { size, style } : { style: { width: size, height: size, ...style } };
3088
3089
  const naming = label ? { role: "img", "aria-label": label, "aria-hidden": false } : {};
3089
3090
  return /* @__PURE__ */ jsx15(
3090
3091
  Component,
@@ -3093,6 +3094,7 @@ function makeIcon(Component, extraDefaults) {
3093
3094
  ...extraDefaults,
3094
3095
  ...naming,
3095
3096
  ...props,
3097
+ ...sizing,
3096
3098
  ref
3097
3099
  }
3098
3100
  );
@@ -8393,9 +8395,119 @@ var LevelBars__Bar = styled24.span`
8393
8395
  border: 1px solid ${({ $fill }) => $fill ?? "var(--color-border-subtle)"};
8394
8396
  `;
8395
8397
 
8398
+ // src/Sparkline.tsx
8399
+ import { useId as useId7, useMemo as useMemo5 } from "react";
8400
+ import { jsx as jsx39, jsxs as jsxs18 } from "react/jsx-runtime";
8401
+ function makeScale(domainMin, domainMax, rangeMin, rangeMax) {
8402
+ const span = domainMax - domainMin;
8403
+ if (span === 0) {
8404
+ const mid = (rangeMin + rangeMax) / 2;
8405
+ return () => mid;
8406
+ }
8407
+ return (v) => rangeMin + (v - domainMin) / span * (rangeMax - rangeMin);
8408
+ }
8409
+ function buildPath(ts, vs, scaleX, scaleY) {
8410
+ return ts.map(
8411
+ (t, i) => `${i === 0 ? "M" : "L"}${scaleX(t).toFixed(2)},${scaleY(vs[i]).toFixed(2)}`
8412
+ ).join(" ");
8413
+ }
8414
+ function Sparkline({
8415
+ values,
8416
+ width,
8417
+ height,
8418
+ color = "var(--color-text-primary)",
8419
+ strokeWidth = 1.5,
8420
+ yDomain,
8421
+ showZeroBaseline = false,
8422
+ background = true,
8423
+ "aria-label": ariaLabel = "Trend sparkline"
8424
+ }) {
8425
+ const finite = useMemo5(
8426
+ () => values.filter((v) => Number.isFinite(v)),
8427
+ [values]
8428
+ );
8429
+ const fillId = `sparkline-fill-${useId7().replace(/:/g, "")}`;
8430
+ const domain = useMemo5(() => {
8431
+ if (yDomain) return yDomain;
8432
+ if (finite.length === 0) return [0, 1];
8433
+ let min = finite[0];
8434
+ let max = finite[0];
8435
+ for (const v of finite) {
8436
+ if (v < min) min = v;
8437
+ if (v > max) max = v;
8438
+ }
8439
+ if (min === max) {
8440
+ const pad2 = Math.abs(min) > 0 ? Math.abs(min) * 0.01 : 1;
8441
+ return [min - pad2, max + pad2];
8442
+ }
8443
+ return [min, max];
8444
+ }, [yDomain, finite]);
8445
+ if (width <= 0 || height <= 0 || finite.length < 2) {
8446
+ return /* @__PURE__ */ jsx39(
8447
+ "svg",
8448
+ {
8449
+ width: Math.max(0, width),
8450
+ height: Math.max(0, height),
8451
+ role: "img",
8452
+ "aria-label": ariaLabel,
8453
+ style: { display: "block" },
8454
+ children: /* @__PURE__ */ jsx39("title", { children: ariaLabel })
8455
+ }
8456
+ );
8457
+ }
8458
+ const padY = strokeWidth / 2;
8459
+ const xs = finite.map((_, i) => i);
8460
+ const scaleX = makeScale(0, finite.length - 1, 0, width);
8461
+ const scaleY = makeScale(domain[0], domain[1], height - padY, padY);
8462
+ const d = buildPath(xs, finite, scaleX, scaleY);
8463
+ const dFill = `${d} L ${width},${height} L 0,${height} Z`;
8464
+ const showBaseline = showZeroBaseline && domain[0] <= 0 && domain[1] >= 0;
8465
+ const zeroY = showBaseline ? scaleY(0) : null;
8466
+ return /* @__PURE__ */ jsxs18(
8467
+ "svg",
8468
+ {
8469
+ width,
8470
+ height,
8471
+ role: "img",
8472
+ "aria-label": ariaLabel,
8473
+ style: { display: "block" },
8474
+ children: [
8475
+ /* @__PURE__ */ jsx39("title", { children: ariaLabel }),
8476
+ background && /* @__PURE__ */ jsx39("defs", { children: /* @__PURE__ */ jsxs18("linearGradient", { id: fillId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
8477
+ /* @__PURE__ */ jsx39("stop", { offset: "0%", stopColor: color, stopOpacity: "0.25" }),
8478
+ /* @__PURE__ */ jsx39("stop", { offset: "100%", stopColor: color, stopOpacity: "0.02" })
8479
+ ] }) }),
8480
+ showBaseline && zeroY !== null && /* @__PURE__ */ jsx39(
8481
+ "line",
8482
+ {
8483
+ x1: 0,
8484
+ y1: zeroY,
8485
+ x2: width,
8486
+ y2: zeroY,
8487
+ stroke: "var(--color-border-subtle)",
8488
+ strokeWidth: 1
8489
+ }
8490
+ ),
8491
+ background && /* @__PURE__ */ jsx39("path", { d: dFill, fill: `url(#${fillId})`, stroke: "none" }),
8492
+ /* @__PURE__ */ jsx39(
8493
+ "path",
8494
+ {
8495
+ d,
8496
+ stroke: color,
8497
+ strokeWidth,
8498
+ fill: "none",
8499
+ strokeLinejoin: "round",
8500
+ strokeLinecap: "round"
8501
+ }
8502
+ )
8503
+ ]
8504
+ }
8505
+ );
8506
+ }
8507
+
8396
8508
  // src/ToggleButton.tsx
8397
8509
  import { forwardRef as forwardRef8 } from "react";
8398
- import { jsx as jsx39 } from "react/jsx-runtime";
8510
+ import { jsx as jsx40 } from "react/jsx-runtime";
8399
8511
  var ToggleButton = forwardRef8(
8400
8512
  function ToggleButton2({
8401
8513
  pressed = false,
@@ -8405,7 +8517,7 @@ var ToggleButton = forwardRef8(
8405
8517
  "aria-pressed": ariaPressed,
8406
8518
  ...rest
8407
8519
  }, ref) {
8408
- return /* @__PURE__ */ jsx39(
8520
+ return /* @__PURE__ */ jsx40(
8409
8521
  Button,
8410
8522
  {
8411
8523
  ref,
@@ -8460,7 +8572,7 @@ function fillFraction(pair) {
8460
8572
  }
8461
8573
 
8462
8574
  // src/TinyEssentials.tsx
8463
- import { Fragment as Fragment14, jsx as jsx40, jsxs as jsxs18 } from "react/jsx-runtime";
8575
+ import { Fragment as Fragment14, jsx as jsx41, jsxs as jsxs19 } from "react/jsx-runtime";
8464
8576
  function TinyEssentials({
8465
8577
  title,
8466
8578
  essentials,
@@ -8471,44 +8583,53 @@ function TinyEssentials({
8471
8583
  const { rowsRef, drawn } = useRowsThatFit(rest);
8472
8584
  const mayInterrupt = essentials.some((e) => e.urgent !== void 0);
8473
8585
  const heroNamedByTitle = hero !== void 0 && rest.length === 0 && hero.label.toUpperCase() === title.toUpperCase();
8474
- return /* @__PURE__ */ jsx40(
8586
+ return /* @__PURE__ */ jsx41(
8475
8587
  Panel,
8476
8588
  {
8477
8589
  panelTitle: title,
8478
8590
  fitToSize: true,
8479
8591
  hoverTitle: true,
8480
- sections: /* @__PURE__ */ jsxs18(Section, { full: true, children: [
8481
- /* @__PURE__ */ jsx40(LiveRegion, { visuallyHidden: true, children: spokenWords(essentials.filter((e) => e.urgent !== true)) }),
8482
- mayInterrupt && /* @__PURE__ */ jsx40(LiveRegion, { visuallyHidden: true, assertive: true, additionsOnly: true, children: urgentWords(essentials).map((said2) => /* @__PURE__ */ jsx40(Fragment13, { children: `${said2}. ` }, said2)) }),
8483
- hero !== void 0 && /* @__PURE__ */ jsxs18(TinyEssentials__Hero, { "data-tiny-essential": "", children: [
8484
- heroNamedByTitle ? /* @__PURE__ */ jsx40(VisuallyHidden, { as: "dt", children: hero.label }) : /* @__PURE__ */ jsx40(TinyEssentials__Label, { children: hero.label }),
8485
- hero.gauge === void 0 ? /* @__PURE__ */ jsx40(TinyEssentials__HeroFigure, { $tone: hero.tone ?? "neutral", children: /* @__PURE__ */ jsx40(EssentialFigure, { essential: hero }) }) : /* @__PURE__ */ jsxs18(TinyEssentials__GaugedFigure, { $tone: hero.tone ?? "neutral", children: [
8486
- /* @__PURE__ */ jsx40(TinyEssentials__FigureLine, { children: /* @__PURE__ */ jsx40(EssentialFigure, { essential: hero }) }),
8487
- /* @__PURE__ */ jsx40(CompactGauge, { essential: hero, gauge: hero.gauge })
8592
+ panelTrend: hero?.trend === void 0 ? void 0 : ({ w, h }) => /* @__PURE__ */ jsx41(
8593
+ Sparkline,
8594
+ {
8595
+ values: hero.trend ?? [],
8596
+ width: w,
8597
+ height: h,
8598
+ "aria-label": `${hero.label} trend`
8599
+ }
8600
+ ),
8601
+ sections: /* @__PURE__ */ jsxs19(Section, { full: true, children: [
8602
+ /* @__PURE__ */ jsx41(LiveRegion, { visuallyHidden: true, children: spokenWords(essentials.filter((e) => e.urgent !== true)) }),
8603
+ mayInterrupt && /* @__PURE__ */ jsx41(LiveRegion, { visuallyHidden: true, assertive: true, additionsOnly: true, children: urgentWords(essentials).map((said2) => /* @__PURE__ */ jsx41(Fragment13, { children: `${said2}. ` }, said2)) }),
8604
+ hero !== void 0 && /* @__PURE__ */ jsxs19(TinyEssentials__Hero, { "data-tiny-essential": "", children: [
8605
+ heroNamedByTitle ? /* @__PURE__ */ jsx41(VisuallyHidden, { as: "dt", children: hero.label }) : /* @__PURE__ */ jsx41(TinyEssentials__Label, { children: hero.label }),
8606
+ hero.gauge === void 0 ? /* @__PURE__ */ jsx41(TinyEssentials__HeroFigure, { $tone: hero.tone ?? "neutral", children: /* @__PURE__ */ jsx41(EssentialFigure, { essential: hero }) }) : /* @__PURE__ */ jsxs19(TinyEssentials__GaugedFigure, { $tone: hero.tone ?? "neutral", children: [
8607
+ /* @__PURE__ */ jsx41(TinyEssentials__FigureLine, { children: /* @__PURE__ */ jsx41(EssentialFigure, { essential: hero }) }),
8608
+ /* @__PURE__ */ jsx41(CompactGauge, { essential: hero, gauge: hero.gauge })
8488
8609
  ] })
8489
8610
  ] }),
8490
- rest.length > 0 && /* @__PURE__ */ jsxs18(TinyEssentials__Rows, { ref: rowsRef, $equal: equalRows, children: [
8491
- rest.slice(0, drawn).map((essential) => /* @__PURE__ */ jsxs18(
8611
+ rest.length > 0 && /* @__PURE__ */ jsxs19(TinyEssentials__Rows, { ref: rowsRef, $equal: equalRows, children: [
8612
+ rest.slice(0, drawn).map((essential) => /* @__PURE__ */ jsxs19(
8492
8613
  TinyEssentials__Row,
8493
8614
  {
8494
8615
  "data-tiny-essential": "",
8495
8616
  $equal: equalRows,
8496
8617
  children: [
8497
- /* @__PURE__ */ jsx40(TinyEssentials__Label, { children: essential.label }),
8498
- /* @__PURE__ */ jsx40(
8618
+ /* @__PURE__ */ jsx41(TinyEssentials__Label, { children: essential.label }),
8619
+ /* @__PURE__ */ jsx41(
8499
8620
  TinyEssentials__RowFigure,
8500
8621
  {
8501
8622
  $tone: essential.tone ?? "neutral",
8502
- children: /* @__PURE__ */ jsx40(EssentialFigure, { essential })
8623
+ children: /* @__PURE__ */ jsx41(EssentialFigure, { essential })
8503
8624
  }
8504
8625
  )
8505
8626
  ]
8506
8627
  },
8507
8628
  essential.label
8508
8629
  )),
8509
- rest.slice(drawn).map((essential) => /* @__PURE__ */ jsxs18(VisuallyHidden, { as: "div", children: [
8510
- /* @__PURE__ */ jsx40("dt", { children: essential.label }),
8511
- /* @__PURE__ */ jsx40("dd", { children: essential.control === void 0 ? /* @__PURE__ */ jsx40(EssentialFigure, { essential }) : essential.control.label })
8630
+ rest.slice(drawn).map((essential) => /* @__PURE__ */ jsxs19(VisuallyHidden, { as: "div", children: [
8631
+ /* @__PURE__ */ jsx41("dt", { children: essential.label }),
8632
+ /* @__PURE__ */ jsx41("dd", { children: essential.control === void 0 ? /* @__PURE__ */ jsx41(EssentialFigure, { essential }) : essential.control.label })
8512
8633
  ] }, essential.label))
8513
8634
  ] })
8514
8635
  ] })
@@ -8566,7 +8687,7 @@ function extentOf(content) {
8566
8687
  function EssentialFigure({ essential }) {
8567
8688
  const { control } = essential;
8568
8689
  if (control !== void 0) {
8569
- return /* @__PURE__ */ jsx40(Tooltip, { text: control.hint ?? control.title, children: /* @__PURE__ */ jsx40(
8690
+ return /* @__PURE__ */ jsx41(Tooltip, { text: control.hint ?? control.title, children: /* @__PURE__ */ jsx41(
8570
8691
  ToggleButton,
8571
8692
  {
8572
8693
  size: "sm",
@@ -8578,8 +8699,8 @@ function EssentialFigure({ essential }) {
8578
8699
  }
8579
8700
  ) });
8580
8701
  }
8581
- return /* @__PURE__ */ jsxs18(Fragment14, { children: [
8582
- essential.level !== void 0 && /* @__PURE__ */ jsx40(
8702
+ return /* @__PURE__ */ jsxs19(Fragment14, { children: [
8703
+ essential.level !== void 0 && /* @__PURE__ */ jsx41(
8583
8704
  LevelBars,
8584
8705
  {
8585
8706
  lit: essential.level.lit,
@@ -8588,7 +8709,7 @@ function EssentialFigure({ essential }) {
8588
8709
  label: essential.label
8589
8710
  }
8590
8711
  ),
8591
- essential.word !== void 0 ? essential.word : /* @__PURE__ */ jsx40(MarkedFigure, { essential })
8712
+ essential.word !== void 0 ? essential.word : /* @__PURE__ */ jsx41(MarkedFigure, { essential })
8592
8713
  ] });
8593
8714
  }
8594
8715
  function asZero(value3, shown) {
@@ -8604,9 +8725,9 @@ function MarkedFigure({ essential }) {
8604
8725
  const roundsToZero = finite && decimals !== void 0 && Math.abs(shown.valueOf()) < 0.5 * 10 ** -decimals;
8605
8726
  const plus = finite && (roundsToZero || !shown.isNegative()) ? "+" : "";
8606
8727
  const drawn = roundsToZero ? asZero(value3, shown) : value3;
8607
- const figure = /* @__PURE__ */ jsxs18(Fragment14, { children: [
8728
+ const figure = /* @__PURE__ */ jsxs19(Fragment14, { children: [
8608
8729
  plus,
8609
- /* @__PURE__ */ jsx40(
8730
+ /* @__PURE__ */ jsx41(
8610
8731
  Unit,
8611
8732
  {
8612
8733
  value: drawn,
@@ -8617,7 +8738,7 @@ function MarkedFigure({ essential }) {
8617
8738
  )
8618
8739
  ] });
8619
8740
  if (mark === void 0 || held || mark.kind === void 0) return figure;
8620
- return /* @__PURE__ */ jsx40(
8741
+ return /* @__PURE__ */ jsx41(
8621
8742
  HeldFigure,
8622
8743
  {
8623
8744
  kind: mark.kind,
@@ -8637,7 +8758,7 @@ function CompactGauge({
8637
8758
  capacity: gauge.max.minus(gauge.min)
8638
8759
  }) ?? 0;
8639
8760
  const share = shown == null ? null : at(shown);
8640
- return /* @__PURE__ */ jsxs18(
8761
+ return /* @__PURE__ */ jsxs19(
8641
8762
  TinyEssentials__Gauge,
8642
8763
  {
8643
8764
  "aria-hidden": "true",
@@ -8646,7 +8767,7 @@ function CompactGauge({
8646
8767
  viewBox: "0 0 100 1",
8647
8768
  preserveAspectRatio: "none",
8648
8769
  children: [
8649
- (gauge.bands ?? []).map((band) => /* @__PURE__ */ jsx40(
8770
+ (gauge.bands ?? []).map((band) => /* @__PURE__ */ jsx41(
8650
8771
  "rect",
8651
8772
  {
8652
8773
  x: at(band.from) * 100,
@@ -8658,7 +8779,7 @@ function CompactGauge({
8658
8779
  },
8659
8780
  `${at(band.from)}-${at(band.to)}`
8660
8781
  )),
8661
- share !== null && /* @__PURE__ */ jsx40(
8782
+ share !== null && /* @__PURE__ */ jsx41(
8662
8783
  "rect",
8663
8784
  {
8664
8785
  "data-tiny-gauge-fill": "",
@@ -8685,10 +8806,10 @@ function WidgetBody({
8685
8806
  ...props
8686
8807
  }) {
8687
8808
  if (def.tiny !== void 0 && showsTiny(def, props.w, props.h)) {
8688
- return /* @__PURE__ */ jsx40(TinyBody, { tiny: def.tiny, props });
8809
+ return /* @__PURE__ */ jsx41(TinyBody, { tiny: def.tiny, props });
8689
8810
  }
8690
8811
  const Widget = def.component;
8691
- return /* @__PURE__ */ jsx40(Widget, { ...props });
8812
+ return /* @__PURE__ */ jsx41(Widget, { ...props });
8692
8813
  }
8693
8814
  function showsTiny(def, w, h) {
8694
8815
  if (def.tiny === void 0 || w === void 0 || h === void 0) {
@@ -8702,7 +8823,7 @@ function gridFloor(def) {
8702
8823
  }
8703
8824
  function TinyBody({ tiny, props }) {
8704
8825
  const essentials = tiny.useEssentials(props);
8705
- return /* @__PURE__ */ jsx40(
8826
+ return /* @__PURE__ */ jsx41(
8706
8827
  TinyEssentials,
8707
8828
  {
8708
8829
  title: tiny.title,
@@ -9021,6 +9142,7 @@ export {
9021
9142
  FRAMEWORK_AUGMENT_SEGMENTS,
9022
9143
  Panel,
9023
9144
  LevelBars,
9145
+ Sparkline,
9024
9146
  ToggleButton,
9025
9147
  TINY_BELOW,
9026
9148
  getSizeBucket,
@@ -9094,4 +9216,4 @@ lucide-react/dist/esm/lucide-react.mjs:
9094
9216
  * See the LICENSE file in the root directory of this source tree.
9095
9217
  *)
9096
9218
  */
9097
- //# sourceMappingURL=chunk-7PFMJAPT.js.map
9219
+ //# sourceMappingURL=chunk-YPSVSCHQ.js.map