@bitsandbricks/widgets 0.0.0-stage → 0.1.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -2
  3. package/dist/FitWidget.d.ts +12 -0
  4. package/dist/FitWidget.js +51 -0
  5. package/dist/TileCard.d.ts +35 -0
  6. package/dist/TileCard.js +39 -0
  7. package/dist/TimeChart.d.ts +14 -0
  8. package/dist/TimeChart.js +30 -0
  9. package/dist/WidgetBody.d.ts +4 -0
  10. package/dist/WidgetBody.js +37 -0
  11. package/dist/autoPage.d.ts +5 -0
  12. package/dist/autoPage.js +6 -0
  13. package/dist/drill.d.ts +3 -0
  14. package/dist/drill.js +4 -0
  15. package/dist/index.d.ts +22 -0
  16. package/dist/index.js +24 -0
  17. package/dist/kinds/Bars.d.ts +15 -0
  18. package/dist/kinds/Bars.js +41 -0
  19. package/dist/kinds/Columns.d.ts +19 -0
  20. package/dist/kinds/Columns.js +101 -0
  21. package/dist/kinds/Gauge.d.ts +11 -0
  22. package/dist/kinds/Gauge.js +29 -0
  23. package/dist/kinds/Graph.d.ts +36 -0
  24. package/dist/kinds/Graph.js +103 -0
  25. package/dist/kinds/Histogram.d.ts +12 -0
  26. package/dist/kinds/Histogram.js +26 -0
  27. package/dist/kinds/Pie.d.ts +12 -0
  28. package/dist/kinds/Pie.js +32 -0
  29. package/dist/kinds/Rows.d.ts +14 -0
  30. package/dist/kinds/Rows.js +81 -0
  31. package/dist/kinds/Stat.d.ts +14 -0
  32. package/dist/kinds/Stat.js +32 -0
  33. package/dist/kinds/combine.d.ts +39 -0
  34. package/dist/kinds/combine.js +161 -0
  35. package/dist/kinds/display.d.ts +64 -0
  36. package/dist/kinds/display.js +113 -0
  37. package/dist/kinds/shape.d.ts +168 -0
  38. package/dist/kinds/shape.js +296 -0
  39. package/dist/level.d.ts +18 -0
  40. package/dist/level.js +37 -0
  41. package/dist/levelReport.d.ts +15 -0
  42. package/dist/levelReport.js +2 -0
  43. package/dist/messages.d.ts +89 -0
  44. package/dist/messages.js +99 -0
  45. package/dist/styles.css +192 -0
  46. package/dist/time.d.ts +6 -0
  47. package/dist/time.js +6 -0
  48. package/dist/useBox.d.ts +5 -0
  49. package/dist/useBox.js +19 -0
  50. package/package.json +40 -3
@@ -0,0 +1,89 @@
1
+ export declare const en: {
2
+ "widgets.kind.of": string;
3
+ "widgets.kind.noData": string;
4
+ "widgets.kind.noRows": string;
5
+ "widgets.kind.maxAvg": string;
6
+ "widgets.kind.graphLabel": string;
7
+ "widgets.kind.top": string;
8
+ "widgets.kind.name": string;
9
+ "widgets.kind.value": string;
10
+ "widgets.kind.detail": string;
11
+ "widgets.kind.filter": string;
12
+ "widgets.kind.more": string;
13
+ "widgets.kind.rowsOf": string;
14
+ "widgets.kind.prev": string;
15
+ "widgets.kind.next": string;
16
+ "widgets.kind.detailsNamed": string;
17
+ "widgets.kind.other": string;
18
+ "widgets.kind.gaugeLabel": string;
19
+ "widgets.kind.pieLabel": string;
20
+ "widgets.kind.columnsLabel": string;
21
+ "widgets.kind.histogramLabel": string;
22
+ "widgets.kind.binTip": string;
23
+ "widgets.kind.values_one": string;
24
+ "widgets.kind.values_other": string;
25
+ "widgets.kind.trend.linear": string;
26
+ "widgets.kind.trend.average": string;
27
+ "widgets.kind.state": string;
28
+ "widgets.kind.changeHour": string;
29
+ "widgets.kind.changeSince": string;
30
+ "widgets.kind.changeStart": string;
31
+ "widgets.state.up": string;
32
+ "widgets.state.down": string;
33
+ "widgets.state.warn": string;
34
+ "widgets.state.unknown": string;
35
+ "widgets.calc.count": string;
36
+ "widgets.calc.sum": string;
37
+ "widgets.calc.avg": string;
38
+ "widgets.calc.min": string;
39
+ "widgets.calc.max": string;
40
+ "widgets.calc.first": string;
41
+ "widgets.calc.last": string;
42
+ "dashboard.cantDraw": string;
43
+ };
44
+ export declare const de: {
45
+ "widgets.kind.of": string;
46
+ "widgets.kind.noData": string;
47
+ "widgets.kind.noRows": string;
48
+ "widgets.kind.maxAvg": string;
49
+ "widgets.kind.graphLabel": string;
50
+ "widgets.kind.top": string;
51
+ "widgets.kind.name": string;
52
+ "widgets.kind.value": string;
53
+ "widgets.kind.detail": string;
54
+ "widgets.kind.filter": string;
55
+ "widgets.kind.more": string;
56
+ "widgets.kind.rowsOf": string;
57
+ "widgets.kind.prev": string;
58
+ "widgets.kind.next": string;
59
+ "widgets.kind.detailsNamed": string;
60
+ "widgets.kind.other": string;
61
+ "widgets.kind.gaugeLabel": string;
62
+ "widgets.kind.pieLabel": string;
63
+ "widgets.kind.columnsLabel": string;
64
+ "widgets.kind.histogramLabel": string;
65
+ "widgets.kind.binTip": string;
66
+ "widgets.kind.values_one": string;
67
+ "widgets.kind.values_other": string;
68
+ "widgets.kind.trend.linear": string;
69
+ "widgets.kind.trend.average": string;
70
+ "widgets.kind.state": string;
71
+ "widgets.kind.changeHour": string;
72
+ "widgets.kind.changeSince": string;
73
+ "widgets.kind.changeStart": string;
74
+ "widgets.state.up": string;
75
+ "widgets.state.down": string;
76
+ "widgets.state.warn": string;
77
+ "widgets.state.unknown": string;
78
+ "widgets.calc.count": string;
79
+ "widgets.calc.sum": string;
80
+ "widgets.calc.avg": string;
81
+ "widgets.calc.min": string;
82
+ "widgets.calc.max": string;
83
+ "widgets.calc.first": string;
84
+ "widgets.calc.last": string;
85
+ "dashboard.cantDraw": string;
86
+ };
87
+ /** Registers the widgets' texts once. Called by the components that use them, not on import, so
88
+ * bundlers that drop side-effect imports keep them. */
89
+ export declare function registerWidgetMessages(): void;
@@ -0,0 +1,99 @@
1
+ import { registerMessages } from '@bitsandbricks/ui';
2
+ // The widgets' texts (from Floorbit's widgets and dashboard texts). Registered with the ui
3
+ // package, so an app's own translate function still wins for any key it knows.
4
+ export const en = {
5
+ "widgets.kind.of": "of {{count}}",
6
+ "widgets.kind.noData": "No data yet.",
7
+ "widgets.kind.noRows": "Nothing here right now.",
8
+ "widgets.kind.maxAvg": "max {{max}} · avg {{avg}}",
9
+ "widgets.kind.graphLabel": "Graph: {{name}}",
10
+ "widgets.kind.top": "top {{value}}",
11
+ "widgets.kind.name": "Name",
12
+ "widgets.kind.value": "Value",
13
+ "widgets.kind.detail": "Detail",
14
+ "widgets.kind.filter": "Filter",
15
+ "widgets.kind.more": "+{{count}} more",
16
+ "widgets.kind.rowsOf": "{{from}}–{{to}} of {{count}}",
17
+ "widgets.kind.prev": "Previous page",
18
+ "widgets.kind.next": "Next page",
19
+ "widgets.kind.detailsNamed": "Details of {{name}}",
20
+ "widgets.kind.other": "Other",
21
+ "widgets.kind.gaugeLabel": "{{value}} of {{max}} ({{pct}} %)",
22
+ "widgets.kind.pieLabel": "Pie: {{parts}}",
23
+ "widgets.kind.columnsLabel": "Columns: {{name}}",
24
+ "widgets.kind.histogramLabel": "Histogram: {{name}}, {{count}} values",
25
+ "widgets.kind.binTip": "{{range}}: {{count}}",
26
+ "widgets.kind.values_one": "{{count}} value",
27
+ "widgets.kind.values_other": "{{count}} values",
28
+ "widgets.kind.trend.linear": "Trend",
29
+ "widgets.kind.trend.average": "Average",
30
+ "widgets.kind.state": "State",
31
+ "widgets.kind.changeHour": "vs an hour ago",
32
+ "widgets.kind.changeSince": "since {{time}}",
33
+ "widgets.kind.changeStart": "since the start",
34
+ "widgets.state.up": "Up",
35
+ "widgets.state.down": "Down",
36
+ "widgets.state.warn": "Warning",
37
+ "widgets.state.unknown": "Unknown",
38
+ "widgets.calc.count": "Count",
39
+ "widgets.calc.sum": "Sum",
40
+ "widgets.calc.avg": "Average",
41
+ "widgets.calc.min": "Min",
42
+ "widgets.calc.max": "Max",
43
+ "widgets.calc.first": "First",
44
+ "widgets.calc.last": "Last",
45
+ "dashboard.cantDraw": "This tile can't be drawn."
46
+ };
47
+ export const de = {
48
+ "widgets.kind.of": "von {{count}}",
49
+ "widgets.kind.noData": "Noch keine Daten.",
50
+ "widgets.kind.noRows": "Gerade nichts da.",
51
+ "widgets.kind.maxAvg": "max {{max}} · Ø {{avg}}",
52
+ "widgets.kind.graphLabel": "Diagramm: {{name}}",
53
+ "widgets.kind.top": "Spitze {{value}}",
54
+ "widgets.kind.name": "Name",
55
+ "widgets.kind.value": "Wert",
56
+ "widgets.kind.detail": "Detail",
57
+ "widgets.kind.filter": "Filtern",
58
+ "widgets.kind.more": "+{{count}} weitere",
59
+ "widgets.kind.rowsOf": "{{from}}–{{to}} von {{count}}",
60
+ "widgets.kind.prev": "Vorherige Seite",
61
+ "widgets.kind.next": "Nächste Seite",
62
+ "widgets.kind.detailsNamed": "Details zu {{name}}",
63
+ "widgets.kind.other": "Andere",
64
+ "widgets.kind.gaugeLabel": "{{value}} von {{max}} ({{pct}} %)",
65
+ "widgets.kind.pieLabel": "Kreis: {{parts}}",
66
+ "widgets.kind.columnsLabel": "Säulen: {{name}}",
67
+ "widgets.kind.histogramLabel": "Histogramm: {{name}}, {{count}} Werte",
68
+ "widgets.kind.binTip": "{{range}}: {{count}}",
69
+ "widgets.kind.values_one": "{{count}} Wert",
70
+ "widgets.kind.values_other": "{{count}} Werte",
71
+ "widgets.kind.trend.linear": "Trend",
72
+ "widgets.kind.trend.average": "Durchschnitt",
73
+ "widgets.kind.state": "Status",
74
+ "widgets.kind.changeHour": "zu vor einer Stunde",
75
+ "widgets.kind.changeSince": "seit {{time}}",
76
+ "widgets.kind.changeStart": "seit Beginn",
77
+ "widgets.state.up": "Läuft",
78
+ "widgets.state.down": "Ausgefallen",
79
+ "widgets.state.warn": "Warnung",
80
+ "widgets.state.unknown": "Unbekannt",
81
+ "widgets.calc.count": "Anzahl",
82
+ "widgets.calc.sum": "Summe",
83
+ "widgets.calc.avg": "Durchschnitt",
84
+ "widgets.calc.min": "Min.",
85
+ "widgets.calc.max": "Max.",
86
+ "widgets.calc.first": "Erster",
87
+ "widgets.calc.last": "Letzter",
88
+ "dashboard.cantDraw": "Diese Kachel lässt sich nicht anzeigen."
89
+ };
90
+ let done = false;
91
+ /** Registers the widgets' texts once. Called by the components that use them, not on import, so
92
+ * bundlers that drop side-effect imports keep them. */
93
+ export function registerWidgetMessages() {
94
+ if (done)
95
+ return;
96
+ done = true;
97
+ registerMessages('en', en);
98
+ registerMessages('de', de);
99
+ }
@@ -0,0 +1,192 @@
1
+ /* Widgets that fit their box (FitWidget, issue #924). Nothing scrolls inside; sizes follow the
2
+ box through container units, so a wall screen and a laptop both read well. */
3
+ .bnb-pane-fit { overflow: hidden; padding: 0 12px 10px; display: flex; }
4
+ .bnb-pane-actions { display: flex; gap: 2px; flex: none; align-self: center; }
5
+
6
+ .bnb-w { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 4px; }
7
+ .bnb-w-area { flex: 1; min-height: 0; min-width: 0; position: relative; overflow: hidden; container-type: size; display: flex; }
8
+ .bnb-w-area > * { flex: 1; min-width: 0; }
9
+ .bnb-w-sub { flex: none; height: 16px; line-height: 16px; font-size: 12px; color: var(--bnb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
10
+ .bnb-w-empty { margin: auto; color: var(--bnb-muted); font-size: 14px; text-align: center; }
11
+
12
+ /* The pane's number size (issue #960): the big number of a stat, gauge or pie, smaller or larger. */
13
+ .bnb-w-text-s { --bnb-w-text: 0.7; }
14
+ .bnb-w-text-l { --bnb-w-text: 1.4; }
15
+
16
+ /* Stat */
17
+ .bnb-w-stat { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-height: 0; }
18
+ /* A figure inside list and graph widgets. */
19
+ .bnb-w-stat-main { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
20
+ .bnb-w-stat-value { font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
21
+ font-size: calc(clamp(22px, min(26cqh, 18cqw), 120px) * var(--bnb-w-text, 1)); }
22
+ .bnb-w-stat-unit { color: var(--bnb-muted); font-weight: 500; font-size: calc(clamp(12px, min(9cqh, 6cqw), 32px) * var(--bnb-w-text, 1)); }
23
+ /* The stat widget is the shared StatTile (#1154) at size fit: the pane is the card, so no box of its
24
+ own, and the figure grows with the pane. The tone colours the figure instead of an edge. */
25
+ .bnb-stat-fit { background: none; border: 0; border-radius: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
26
+ .bnb-stat-fit dd:not(.bnb-stat-more) { margin: 0; line-height: 1; white-space: nowrap; overflow: hidden; display: flex; align-items: baseline; gap: 6px;
27
+ font-size: calc(clamp(22px, min(26cqh, 18cqw), 120px) * var(--bnb-w-text, 1)); }
28
+ .bnb-stat-fit .bnb-stat-unit { font-size: calc(clamp(12px, min(9cqh, 6cqw), 32px) * var(--bnb-w-text, 1)); }
29
+ .bnb-stat-fit.is-ok dd:not(.bnb-stat-more) { color: var(--bnb-ok); }
30
+ .bnb-stat-fit.is-warn dd:not(.bnb-stat-more) { color: var(--bnb-warn); }
31
+ .bnb-stat-fit.is-err dd:not(.bnb-stat-more) { color: var(--bnb-err); }
32
+ .bnb-stat-fit dd.bnb-stat-more { display: flex; flex-direction: column; gap: 6px; color: var(--bnb-muted);
33
+ font-size: clamp(12px, min(7cqh, 5cqw), 22px); }
34
+ .bnb-stat-fit dd.bnb-stat-more span:not(.bnb-w-counts):not(.bnb-stat-spark) { display: inline; font-size: inherit; }
35
+ .bnb-stat-fit .bnb-w-counts { font-size: inherit; }
36
+ .bnb-stat-fit .bnb-stat-change { white-space: nowrap; overflow: hidden; }
37
+ .bnb-stat-fit .bnb-stat-change b { font-weight: 600; color: var(--bnb-fg); }
38
+ .bnb-stat-fit .bnb-stat-change.bnb-tone-up b, .bnb-stat-fit .bnb-stat-change.bnb-tone-down b { color: inherit; }
39
+ .bnb-stat-fit .bnb-stat-spark { display: block; height: clamp(16px, 25cqh, 60px); margin-top: 0; }
40
+ .bnb-w-counts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--bnb-muted); font-size: clamp(12px, 6cqh, 18px);
41
+ font-variant-numeric: tabular-nums; }
42
+ .bnb-w-counts .bnb-dot { vertical-align: 0; }
43
+
44
+ /* Rows: status, list, table */
45
+ .bnb-w-rows { display: flex; flex-direction: column; min-height: 0; }
46
+ .bnb-w-filter { flex: none; margin-bottom: 6px; }
47
+ .bnb-w-rows .bnb-dt-pager { margin-top: auto; }
48
+ .bnb-w-rows .bnb-dt-scroll { flex: none; }
49
+ .bnb-w-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
50
+ .bnb-w-table th, .bnb-w-table td { height: 28px; padding: 0 8px 0 0; text-align: left; white-space: nowrap; overflow: hidden;
51
+ text-overflow: ellipsis; border-bottom: 1px solid color-mix(in srgb, var(--bnb-line) 60%, transparent); }
52
+ .bnb-w-table th { color: var(--bnb-muted); font-weight: 600; font-size: 12px; }
53
+ .bnb-w-table tr:last-child td { border-bottom: 0; }
54
+ .bnb-w-table .bnb-dot { margin-right: 8px; vertical-align: 0; }
55
+ .bnb-w-plain td.bnb-w-side { text-align: right; color: var(--bnb-muted); font-family: var(--bnb-font-mono); width: 45%; }
56
+ .bnb-w-plain td.bnb-w-side[class*='bnb-tone-'] { color: inherit; }
57
+ .bnb-w-sort { font: inherit; color: inherit; }
58
+ .bnb-w-sort:hover { color: var(--bnb-fg); }
59
+ .bnb-w-more { flex: none; height: 28px; display: flex; align-items: center; font-size: 13px; color: var(--bnb-accent); }
60
+ .bnb-w-pick { font: inherit; color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
61
+ .bnb-w-pick:hover { color: var(--bnb-accent); }
62
+ button.bnb-w-more:hover { text-decoration: underline; }
63
+ .bnb-w-pager { flex: none; height: 28px; display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 12px;
64
+ color: var(--bnb-muted); margin-top: auto; }
65
+ .bnb-w-pager span { margin-right: 6px; font-variant-numeric: tabular-nums; }
66
+
67
+ /* Graph */
68
+ .bnb-w-graph, .bnb-w-graph-s { display: flex; flex-direction: column; min-height: 0; }
69
+ .bnb-w-graph-s { justify-content: space-between; gap: 4px; }
70
+ .bnb-w-legend { flex: none; height: 20px; display: flex; gap: 14px; font-size: 12px; color: var(--bnb-muted); overflow: hidden; white-space: nowrap; }
71
+ .bnb-w-legend i, .bnb-w-tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
72
+ .bnb-w-legend b { color: var(--bnb-fg); margin-left: 6px; font-variant-numeric: tabular-nums; }
73
+ .bnb-w-legend em { font-style: normal; margin-left: 8px; }
74
+ .bnb-w-plot { position: relative; flex: 1; min-height: 0; touch-action: pan-y; }
75
+ .bnb-w-plot svg, .bnb-w-graph-s svg { display: block; overflow: visible; }
76
+ .bnb-w-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
77
+ .bnb-w-fill { fill: currentColor; fill-opacity: 0.12; stroke: none; }
78
+ .bnb-w-base { stroke: var(--bnb-line); }
79
+ .bnb-w-cross { stroke: var(--bnb-muted); stroke-dasharray: 3 3; }
80
+ .bnb-w-tip { position: absolute; top: 4px; z-index: 2; min-width: 150px; padding: 6px 8px; border-radius: 6px; font-size: 12px;
81
+ background: var(--bnb-surface); border: 1px solid var(--bnb-line); pointer-events: none; }
82
+ .bnb-w-tip > div { display: flex; align-items: center; white-space: nowrap; }
83
+ .bnb-w-tip b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
84
+ .bnb-w-tip-when { color: var(--bnb-muted); margin-bottom: 2px; }
85
+ .bnb-w-axis { flex: none; height: 18px; display: flex; justify-content: space-between; font-size: 11px; color: var(--bnb-faint); }
86
+
87
+ /* Make large: the same widget, at its large level, filling most of the screen. */
88
+
89
+ /* Gauge */
90
+ .bnb-w-gauge { display: flex; align-items: center; justify-content: center; min-height: 0; }
91
+ .bnb-w-gauge svg { overflow: visible; }
92
+ .bnb-w-gauge-track, .bnb-w-gauge-fill { fill: none; stroke-width: 9; stroke-linecap: round; }
93
+ .bnb-w-gauge-track { stroke: var(--bnb-line); }
94
+ .bnb-w-gauge-fill { stroke: currentColor; color: var(--bnb-accent); }
95
+ .bnb-w-gauge-fill[class*='bnb-tone-'] { color: unset; }
96
+ .bnb-w-gauge-fill.bnb-tone-ok { color: var(--bnb-ok); }
97
+ .bnb-w-gauge-fill.bnb-tone-warn { color: var(--bnb-warn); }
98
+ .bnb-w-gauge-fill.bnb-tone-err { color: var(--bnb-err); }
99
+ .bnb-w-gauge-value { text-anchor: middle; font-size: calc(20px * var(--bnb-w-text, 1)); font-weight: 700; fill: var(--bnb-fg); font-variant-numeric: tabular-nums; }
100
+ .bnb-w-gauge-unit { text-anchor: middle; font-size: 8px; fill: var(--bnb-muted); }
101
+ .bnb-w-gauge-end { text-anchor: middle; font-size: 7px; fill: var(--bnb-faint); }
102
+
103
+ /* Bars */
104
+ .bnb-w-bars { list-style: none; margin: 0; padding: 0; }
105
+ .bnb-w-bars li { display: grid; grid-template-columns: var(--label-w) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
106
+ .bnb-w-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
107
+ .bnb-w-bar-track { height: 10px; border-radius: 3px; overflow: hidden; }
108
+ .bnb-w-bar-track.gauge { background: var(--bnb-line); }
109
+ .bnb-w-bar-fill { display: block; height: 100%; border-radius: 3px; min-width: 2px; }
110
+ .bnb-w-bar-value { color: var(--bnb-muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 3ch; text-align: right; }
111
+
112
+ /* Pie */
113
+ .bnb-w-pie { display: flex; align-items: center; gap: 16px; min-height: 0; }
114
+ .bnb-w-pie.small { justify-content: center; }
115
+ .bnb-w-pie svg { flex: none; }
116
+ .bnb-w-slice { fill: none; stroke-width: 14; transition: stroke-width 0.1s; }
117
+ .bnb-w-slice.hot { stroke-width: 18; }
118
+ .bnb-w-pie-total { text-anchor: middle; font-size: calc(16px * var(--bnb-w-text, 1)); font-weight: 700; fill: var(--bnb-fg); font-variant-numeric: tabular-nums; }
119
+ .bnb-w-pie-sub { text-anchor: middle; font-size: 8px; fill: var(--bnb-muted); }
120
+ .bnb-w-pie-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 13px; }
121
+ .bnb-w-pie-legend li { display: flex; align-items: center; gap: 8px; height: 22px; padding: 0 6px; border-radius: 4px; }
122
+ .bnb-w-pie-legend li.hot { background: var(--bnb-line); }
123
+ .bnb-w-pie-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
124
+ .bnb-w-pie-legend span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
125
+ .bnb-w-pie-legend b { font-variant-numeric: tabular-nums; }
126
+ .bnb-w-pie-legend em { font-style: normal; color: var(--bnb-muted); min-width: 4ch; text-align: right; }
127
+
128
+ /* Columns: vertical bars */
129
+ .bnb-w-cols-wrap { display: flex; flex-direction: column; min-height: 0; }
130
+ .bnb-w-cols { display: flex; align-items: flex-end; gap: 6px; min-width: 0; }
131
+ .bnb-w-col { flex: 1 1 0; min-width: 22px; max-width: 72px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
132
+ .bnb-w-col-value { font-size: 11px; color: var(--bnb-muted); font-variant-numeric: tabular-nums; height: 14px; white-space: nowrap; }
133
+ .bnb-w-col-track { width: 100%; display: flex; align-items: flex-end; border-radius: 3px; overflow: hidden; }
134
+ .bnb-w-col-track.gauge { background: var(--bnb-line); }
135
+ .bnb-w-col-fill { display: block; width: 100%; border-radius: 3px; min-height: 2px; }
136
+ .bnb-w-col-label { font-size: 12px; height: 18px; line-height: 18px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
137
+ .bnb-w-col-more { align-self: center; white-space: nowrap; }
138
+ .bnb-w-col-hot { fill: var(--bnb-line); fill-opacity: 0.6; }
139
+ .bnb-w-fill.area { fill-opacity: 0.18; }
140
+ .bnb-w-fill.stacked { fill-opacity: 0.45; }
141
+ .bnb-w-trend { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-dasharray: 6 4; opacity: 0.9; }
142
+ /* A comparison line (yesterday at the same time): faint and dashed, behind the real lines in meaning. */
143
+ .bnb-w-ghost { fill: none; stroke: var(--bnb-muted); stroke-width: 1.5; stroke-dasharray: 2 4; opacity: 0.8; }
144
+ .bnb-w-ghost-key i { background: none; border-top: 2px dotted var(--bnb-muted); height: 0; }
145
+ /* What happened when: a thin line across the graph in its tone, named in the hover card. */
146
+ .bnb-w-tip-mark { font-size: 12px; }
147
+ /* Under a stat: its history as a sparkline, and how it moved (issue #960). */
148
+ .bnb-w-tip-trend { color: var(--bnb-muted); }
149
+ .bnb-w-hist { gap: 2px; }
150
+ .bnb-w-hist .bnb-w-col { max-width: none; }
151
+ .bnb-w-col.hot .bnb-w-col-fill { filter: brightness(1.25); }
152
+ .bnb-w-seg { display: block; width: 100%; }
153
+ .bnb-w-bar-track .bnb-w-seg { height: 100%; width: auto; }
154
+ .bnb-w-group { display: flex; align-items: flex-end; gap: 1px; width: 100%; height: 100%; }
155
+ .bnb-w-group > span { flex: 1; border-radius: 2px 2px 0 0; min-height: 2px; }
156
+ .bnb-w-hgroup { display: flex; flex-direction: column; justify-content: center; gap: 1px; height: 100%; }
157
+ .bnb-w-hgroup > span { display: block; height: 3px; border-radius: 2px; min-width: 2px; }
158
+ .bnb-w-seg-legend { flex: none; height: 20px; }
159
+ .bnb-w-stack { display: flex; flex-direction: column; background: none !important; overflow: hidden; }
160
+ .bnb-w-hstack { display: flex; background: none !important; overflow: hidden; }
161
+ .bnb-w-bar-track.grouped { height: 14px; }
162
+
163
+ /* A threshold on a graph (issue #960): a thin dashed line in its tone. */
164
+ .bnb-w-step { stroke: var(--bnb-faint); stroke-width: 1; stroke-dasharray: 2 3; }
165
+ .bnb-w-step.bnb-tone-ok { stroke: var(--bnb-ok); }
166
+ .bnb-w-step.bnb-tone-warn { stroke: var(--bnb-warn); }
167
+ .bnb-w-step.bnb-tone-err { stroke: var(--bnb-err); }
168
+ /* What happened (a switch down, an incident): a dotted line across the graph, in its tone. */
169
+ .bnb-w-mark { stroke: var(--bnb-muted); stroke-width: 1.5; stroke-dasharray: 2 3; }
170
+ .bnb-w-mark.bnb-tone-ok { stroke: var(--bnb-ok); }
171
+ .bnb-w-mark.bnb-tone-warn { stroke: var(--bnb-warn); }
172
+ .bnb-w-mark.bnb-tone-err { stroke: var(--bnb-err); }
173
+
174
+ /* State dots and tone text in widgets (from Floorbit's shell). */
175
+ .bnb-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--bnb-off); }
176
+ .bnb-dot.up { background: var(--bnb-ok); }
177
+ .bnb-dot.down { background: var(--bnb-err); }
178
+ /* A diamond, so warn doesn't rely on colour alone. */
179
+ .bnb-dot.warn { background: var(--bnb-warn); border-radius: 2px; transform: rotate(45deg) scale(0.85); }
180
+ .bnb-tone-ok { color: var(--bnb-ok); }
181
+ .bnb-tone-warn { color: var(--bnb-warn); }
182
+ .bnb-tone-err { color: var(--bnb-err); }
183
+ .bnb-tone-info { color: var(--bnb-info); }
184
+
185
+ /* Time chart. */
186
+ .bnb-time-chart { margin: 0; }
187
+ .bnb-time-chart svg { display: block; width: 100%; }
188
+ .bnb-time-chart .axis { stroke: var(--bnb-line); }
189
+ .bnb-time-chart .area { fill: color-mix(in srgb, var(--bnb-accent) 14%, transparent); }
190
+ .bnb-time-chart .line { fill: none; stroke: var(--bnb-accent); stroke-width: 1.5; }
191
+ .bnb-time-chart .dot { fill: var(--bnb-accent); }
192
+ .bnb-time-chart figcaption { display: flex; justify-content: space-between; font-size: var(--bnb-fs-xs); color: var(--bnb-muted); font-variant-numeric: tabular-nums; }
package/dist/time.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ type When = number | string | Date;
2
+ /** "14:05" from unix seconds, milliseconds, an ISO string or a Date. */
3
+ export declare const clock: (when: When, lang?: string) => string;
4
+ /** "Sat 14:05", for times that may be on another day. */
5
+ export declare const dayClock: (when: When, lang?: string) => string;
6
+ export {};
package/dist/time.js ADDED
@@ -0,0 +1,6 @@
1
+ const toDate = (when) => (typeof when === 'number' ? new Date(when < 1e12 ? when * 1000 : when) : new Date(when));
2
+ const fmt = (when, options, lang) => new Intl.DateTimeFormat(lang || undefined, options).format(toDate(when));
3
+ /** "14:05" from unix seconds, milliseconds, an ISO string or a Date. */
4
+ export const clock = (when, lang) => fmt(when, { hour: '2-digit', minute: '2-digit' }, lang);
5
+ /** "Sat 14:05", for times that may be on another day. */
6
+ export const dayClock = (when, lang) => fmt(when, { weekday: 'short', hour: '2-digit', minute: '2-digit' }, lang);
@@ -0,0 +1,5 @@
1
+ /** The size of an element, kept current as its box changes (a dashboard cell, a split, a modal). */
2
+ export declare function useBox<T extends HTMLElement>(): readonly [import("react").RefObject<T | null>, {
3
+ w: number;
4
+ h: number;
5
+ }];
package/dist/useBox.js ADDED
@@ -0,0 +1,19 @@
1
+ import { useLayoutEffect, useRef, useState } from 'react';
2
+ /** The size of an element, kept current as its box changes (a dashboard cell, a split, a modal). */
3
+ export function useBox() {
4
+ const ref = useRef(null);
5
+ const [box, setBox] = useState({ w: 0, h: 0 });
6
+ useLayoutEffect(() => {
7
+ const el = ref.current;
8
+ if (!el)
9
+ return;
10
+ const set = () => setBox((b) => (b.w === el.clientWidth && b.h === el.clientHeight ? b : { w: el.clientWidth, h: el.clientHeight }));
11
+ set();
12
+ if (typeof ResizeObserver === 'undefined')
13
+ return;
14
+ const ro = new ResizeObserver(set);
15
+ ro.observe(el);
16
+ return () => ro.disconnect();
17
+ }, []);
18
+ return [ref, box];
19
+ }
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@bitsandbricks/widgets",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "BitsAndBricks dashboard widgets: stat, gauge, graph, bars, pie, histogram, tables, from plugin data",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/bitsandbricks-ch/ui.git",
10
+ "directory": "packages/widgets"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public",
14
+ "registry": "https://registry.npmjs.org/"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./styles.css": "./dist/styles.css"
25
+ },
26
+ "sideEffects": [
27
+ "*.css"
28
+ ],
29
+ "dependencies": {
30
+ "@bitsandbricks/ui": "^0.1.0"
31
+ },
32
+ "peerDependencies": {
33
+ "@mantine/core": "^9.7.4",
34
+ "@mantine/hooks": "^9.7.4",
35
+ "@tabler/icons-react": "^3.40.0",
36
+ "react": "^19.0.0",
37
+ "react-dom": "^19.0.0"
38
+ },
39
+ "scripts": {
40
+ "build": "node ../../scripts/build-package.mjs",
41
+ "typecheck": "tsc --noEmit -p ."
42
+ }
6
43
  }