@watt-ui/react 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.
- package/LICENSE +21 -0
- package/NOTICE +43 -0
- package/README.md +48 -2
- package/dist/chart/data.d.ts +13 -0
- package/dist/chart/data.d.ts.map +1 -0
- package/dist/chart/data.js +92 -0
- package/dist/chart/data.js.map +1 -0
- package/dist/chart/engine.d.ts +2 -0
- package/dist/chart/engine.d.ts.map +1 -0
- package/dist/chart/engine.js +16 -0
- package/dist/chart/engine.js.map +1 -0
- package/dist/chart/options.d.ts +18 -0
- package/dist/chart/options.d.ts.map +1 -0
- package/dist/chart/options.js +136 -0
- package/dist/chart/options.js.map +1 -0
- package/dist/components/alarm-feed.d.ts +18 -0
- package/dist/components/alarm-feed.d.ts.map +1 -0
- package/dist/components/alarm-feed.js +45 -0
- package/dist/components/alarm-feed.js.map +1 -0
- package/dist/components/asset-tree.d.ts +33 -0
- package/dist/components/asset-tree.d.ts.map +1 -0
- package/dist/components/asset-tree.js +149 -0
- package/dist/components/asset-tree.js.map +1 -0
- package/dist/components/battery-soc.d.ts +11 -0
- package/dist/components/battery-soc.d.ts.map +1 -0
- package/dist/components/battery-soc.js +34 -0
- package/dist/components/battery-soc.js.map +1 -0
- package/dist/components/data-freshness.d.ts +26 -0
- package/dist/components/data-freshness.d.ts.map +1 -0
- package/dist/components/data-freshness.js +45 -0
- package/dist/components/data-freshness.js.map +1 -0
- package/dist/components/energy-flow.d.ts +39 -0
- package/dist/components/energy-flow.d.ts.map +1 -0
- package/dist/components/energy-flow.js +176 -0
- package/dist/components/energy-flow.js.map +1 -0
- package/dist/components/flow-geometry.d.ts +24 -0
- package/dist/components/flow-geometry.d.ts.map +1 -0
- package/dist/components/flow-geometry.js +57 -0
- package/dist/components/flow-geometry.js.map +1 -0
- package/dist/components/power-metric.d.ts +14 -0
- package/dist/components/power-metric.d.ts.map +1 -0
- package/dist/components/power-metric.js +25 -0
- package/dist/components/power-metric.js.map +1 -0
- package/dist/components/status-indicator.d.ts +10 -0
- package/dist/components/status-indicator.d.ts.map +1 -0
- package/dist/components/status-indicator.js +15 -0
- package/dist/components/status-indicator.js.map +1 -0
- package/dist/components/telemetry-chart.d.ts +50 -0
- package/dist/components/telemetry-chart.d.ts.map +1 -0
- package/dist/components/telemetry-chart.js +256 -0
- package/dist/components/telemetry-chart.js.map +1 -0
- package/dist/domain.d.ts +6 -0
- package/dist/domain.d.ts.map +1 -0
- package/dist/domain.js +43 -0
- package/dist/domain.js.map +1 -0
- package/dist/icons/index.d.ts +7 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/icons/index.js +38 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +6 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +45 -0
- package/dist/internal.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +32 -0
- package/dist/server.js.map +1 -0
- package/dist/styles.css +130 -0
- package/dist/theme/shadcn.css +14 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +118 -4
- package/src/chart/data.ts +103 -0
- package/src/chart/engine.ts +19 -0
- package/src/chart/options.ts +178 -0
- package/src/components/alarm-feed.tsx +126 -0
- package/src/components/asset-tree.tsx +258 -0
- package/src/components/battery-soc.tsx +84 -0
- package/src/components/data-freshness.tsx +109 -0
- package/src/components/energy-flow.tsx +364 -0
- package/src/components/flow-geometry.ts +82 -0
- package/src/components/power-metric.tsx +71 -0
- package/src/components/status-indicator.tsx +31 -0
- package/src/components/telemetry-chart.tsx +476 -0
- package/src/domain.ts +64 -0
- package/src/icons/index.tsx +49 -0
- package/src/index.ts +37 -0
- package/src/internal.tsx +57 -0
- package/src/server.ts +47 -0
- package/src/styles.css +130 -0
- package/src/theme/shadcn.css +14 -0
- package/src/types.ts +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Watt UI contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
The following Lucide icons are derived from the Feather project:
|
|
20
|
+
|
|
21
|
+
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
|
|
22
|
+
|
|
23
|
+
The MIT License (MIT) (for the icons listed above)
|
|
24
|
+
|
|
25
|
+
Copyright (c) 2013-present Cole Bemis
|
|
26
|
+
|
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
29
|
+
in the Software without restriction, including without limitation the rights
|
|
30
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
32
|
+
furnished to do so, subject to the following conditions:
|
|
33
|
+
|
|
34
|
+
The above copyright notice and this permission notice shall be included in all
|
|
35
|
+
copies or substantial portions of the Software.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Watt UI
|
|
2
|
+
React components for energy & power dashboards. React 18/19, Tailwind CSS v4, TypeScript, MIT.
|
|
3
|
+
[Component playground](https://watt-ui.pages.dev) · [Icon gallery](https://watt-ui.pages.dev/icons)
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
## Install
|
|
6
|
+
```sh
|
|
7
|
+
npm install @watt-ui/react react react-dom tailwindcss
|
|
8
|
+
```
|
|
9
|
+
In your Tailwind v4 CSS entry (configure Tailwind's Vite/PostCSS integration in your app):
|
|
10
|
+
```css
|
|
11
|
+
@import "tailwindcss";
|
|
12
|
+
@import "@watt-ui/react/styles.css";
|
|
13
|
+
/* Source scanning is registered by styles.css, relative to the installed package. */
|
|
14
|
+
/* If your build strips @source, explicitly register the package here: */
|
|
15
|
+
/* @source "../node_modules/@watt-ui/react/dist"; */
|
|
16
|
+
/* Optional, after defining your shadcn variables: */
|
|
17
|
+
/* @import "@watt-ui/react/theme/shadcn.css"; */
|
|
18
|
+
```
|
|
19
|
+
Use `.dark` or `data-theme="dark"` on a shared ancestor. Watt does not reset global styles.
|
|
20
|
+
|
|
21
|
+
## Compose
|
|
22
|
+
```tsx
|
|
23
|
+
'use client'; // Next.js App Router: put compound component usage in a client module.
|
|
24
|
+
import { PowerMetric } from '@watt-ui/react';
|
|
25
|
+
<PowerMetric.Root density="compact">
|
|
26
|
+
<PowerMetric.Label>PV generation</PowerMetric.Label>
|
|
27
|
+
<PowerMetric.Value value={482.6} />
|
|
28
|
+
<PowerMetric.Unit>kW</PowerMetric.Unit>
|
|
29
|
+
</PowerMetric.Root>
|
|
30
|
+
```
|
|
31
|
+
Exports: `PowerMetric`, `StatusIndicator`, `DataFreshness`, `BatterySOC`, `TelemetryChart`, `EnergyFlow`, `AlarmFeed`, `AssetTree`. Import individual families from `@watt-ui/react/power-metric` etc. Icons live in `@watt-ui/react/icons`.
|
|
32
|
+
The 12 use cases live in the Playground, including solar yield, inverter status, charge/discharge and energy balance as composition recipes. `demo/recipes.tsx` contains their working source.
|
|
33
|
+
|
|
34
|
+
## Contracts
|
|
35
|
+
- Content and translation belong to children/render functions. DOM parts support refs and `asChild`; Canvas and virtualized list wrappers keep their required DOM structure.
|
|
36
|
+
- Measurements, units, quality, equipment status, direction and business calculations come from your app. There is no automatic stale detection, transport, integration or conversion. Invalid SOC (outside 0–100) displays an empty track without a false numeric reading.
|
|
37
|
+
- Charts require sorted timestamps: ISO 8601 with timezone or Unix milliseconds. Use explicit `null` for gaps. Series IDs must be unique; each axis has one unit, with at most two axes. Inputs are immutable snapshots; keep references stable when unchanged.
|
|
38
|
+
- `TelemetryChart.Root` takes `series`, `timeZone`, optional `range/onRangeChange`, `sampling`, `options`, `events`, `onReady`, `onError`. It composes `Canvas`, `Legend`, `Tooltip`, `Description`. Sampling preserves explicit gaps and spikes; tooltip inspection looks up original samples. Heavy alternating-null input can exceed the display-point budget to preserve gaps.
|
|
39
|
+
- Explicit Watt fields own axes, series, zoom, legend and tooltip; other ECharts options pass through. Data quality is inspection metadata; use `null` yourself to omit a point. Arrow/Home/End inspect original samples. Inside zoom uses Ctrl+wheel; range synchronization belongs to your app.
|
|
40
|
+
- SSR emits a deterministic chart shell. Optional server-only `renderTelemetrySVG({series,timeZone,width,height})` from `@watt-ui/react/server` generates trusted `previewSvg` for `Canvas`. Canvas replaces it after its first render; this is not SVG hydration. Do not pass untrusted HTML as `previewSvg`.
|
|
41
|
+
- `EnergyFlow.Root` measures your CSS layout after mount; nodes SSR-render, edges appear after measurement. Connect Node IDs or explicit Port IDs with Edge source/target. Layout changes caused by CSS transforms need a resize or class/style mutation; graph editing and automatic graph layout are not included. Labels are your content; add an accessible diagram description. Missing endpoints remain unrendered until registered.
|
|
42
|
+
- Flow animation: `particles/dash/pulse/none`, nonnegative speed (0 pauses), particleSize/count (maximum 100), strokeWidth, color and `straight/step/bezier`. Root defaults can be overridden per Edge. Reduced Motion retains static arrows.
|
|
43
|
+
- `AssetTree.Root` takes immutable `items`, a row render function, `expandedIds/onExpandedChange`, `selectedIds/onSelectionChange`, optional defaults and `onActivate`. Give it an `aria-label`. Virtual rows use a fixed `rowHeight` (36 compact / 48 comfortable); keep content within that height. No built-in fetching, editing or drag/drop.
|
|
44
|
+
- `AlarmFeed.Root` renders supplied order and exposes a row function; optional virtualization uses `height/rowHeight`. Your app owns acknowledgement, filtering, sorting and actions. Live announcements are opt-in through your wrapper's ARIA props.
|
|
45
|
+
|
|
46
|
+
## Develop and verify
|
|
47
|
+
`npm run dev` opens the single-component Playground. `npm run typecheck`, `npm test`, `npm run test:browser`, `npm run check:package` verify types, behavior, accessibility and packed React 18/Vite + React 19/Next consumers. `node scripts/benchmark.mjs` measures 4×100k desktop, 4×10k throttled mobile simulation, and 1m stress input against the running Playground; results include initial rendering, update p95, frame times and heap usage. Set `WATT_BENCH_URL` to a production preview for release measurements. Physical mobile results must be verified separately.
|
|
48
|
+
|
|
49
|
+
Measured 2026-10-23, production build, Apple M2 Pro / macOS arm64 / Chromium 156: desktop 4×100k at 1Hz + pointer inspection averaged 60.01fps (update p95 40.4ms); 390px / 4× CPU-throttled 4×10k averaged 57.80fps (92.6ms); 1×1m stress averaged 59.22fps (74.5ms). Initial chart rendering: 139/333/163ms after fixture generation. Desktop and mobile-simulation windows ran 60s after 10s warmup; stress ran 15s. GC heap before→after: 85.4→84.9MB, 14.8→16.5MB, 200.8→198.2MB. These are bounded synthetic browser measurements, not physical-phone or indefinite-memory guarantees.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TelemetrySeries, TimeRange, TimeSeriesPoint } from "../types.js";
|
|
2
|
+
export type ChartPoint = [number, number | null];
|
|
3
|
+
export interface PreparedSeries extends Omit<TelemetrySeries, "points"> {
|
|
4
|
+
points: ChartPoint[];
|
|
5
|
+
sourcePoints: readonly TimeSeriesPoint[];
|
|
6
|
+
}
|
|
7
|
+
export declare function prepareSeries(series: readonly TelemetrySeries[]): PreparedSeries[];
|
|
8
|
+
/** Display-only min/max sampling: every explicit null remains a line break. */
|
|
9
|
+
export declare function samplePoints(points: ChartPoint[], limit: number, range?: TimeRange): ChartPoint[];
|
|
10
|
+
export declare function lowerBound(points: ChartPoint[], time: number): number;
|
|
11
|
+
export declare function nearestIndex(points: ChartPoint[], time: number): number;
|
|
12
|
+
export declare function nearestPoint(points: ChartPoint[], time: number): ChartPoint | undefined;
|
|
13
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/chart/data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC/E,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AACjD,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC;IACrE,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,YAAY,EAAE,SAAS,eAAe,EAAE,CAAC;CAC1C;AACD,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,eAAe,EAAE,GACjC,cAAc,EAAE,CA4BlB;AACD,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,MAAM,EAAE,UAAU,EAAE,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,SAAS,GAChB,UAAU,EAAE,CA+Bd;AACD,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CASrE;AACD,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAWvE;AACD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,UAAU,EAAE,EACpB,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAExB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { parseTimestamp } from "../domain.js";
|
|
2
|
+
export function prepareSeries(series) {
|
|
3
|
+
const ids = new Set();
|
|
4
|
+
const units = new Map();
|
|
5
|
+
return series.map((s) => {
|
|
6
|
+
if (!s.id || ids.has(s.id))
|
|
7
|
+
throw new Error("Chart series IDs must be nonempty and unique");
|
|
8
|
+
ids.add(s.id);
|
|
9
|
+
const axis = s.axis ?? 0;
|
|
10
|
+
if (axis !== 0 && axis !== 1)
|
|
11
|
+
throw new Error("Charts support at most two Y axes");
|
|
12
|
+
if (units.has(axis) && units.get(axis) !== s.unit)
|
|
13
|
+
throw new Error("Series on one Y axis must use the same unit");
|
|
14
|
+
units.set(axis, s.unit);
|
|
15
|
+
let last = -Infinity;
|
|
16
|
+
const points = s.points.map((p) => {
|
|
17
|
+
const time = parseTimestamp(p.timestamp);
|
|
18
|
+
if (time === null || time < last)
|
|
19
|
+
throw new Error("Chart timestamps must be valid ISO instants or epoch milliseconds, sorted ascending");
|
|
20
|
+
last = time;
|
|
21
|
+
return [
|
|
22
|
+
time,
|
|
23
|
+
p.value !== null && Number.isFinite(p.value) ? p.value : null,
|
|
24
|
+
];
|
|
25
|
+
});
|
|
26
|
+
return { ...s, points, sourcePoints: s.points };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Display-only min/max sampling: every explicit null remains a line break. */
|
|
30
|
+
export function samplePoints(points, limit, range) {
|
|
31
|
+
let start = range ? lowerBound(points, range[0]) : 0;
|
|
32
|
+
let end = range ? lowerBound(points, range[1]) + 1 : points.length;
|
|
33
|
+
start = Math.max(0, start - (range ? 1 : 0));
|
|
34
|
+
end = Math.min(points.length, end);
|
|
35
|
+
if (end - start <= limit)
|
|
36
|
+
return points.slice(start, end);
|
|
37
|
+
const result = [];
|
|
38
|
+
const bucket = Math.max(1, Math.ceil((end - start) / Math.max(1, limit / 2)));
|
|
39
|
+
result.push(points[start]);
|
|
40
|
+
for (let i = start; i < end;) {
|
|
41
|
+
if (points[i][1] === null) {
|
|
42
|
+
result.push(points[i]);
|
|
43
|
+
i++;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const stop = Math.min(end, i + bucket);
|
|
47
|
+
let min = i, max = i, j = i;
|
|
48
|
+
while (j < stop && points[j][1] !== null) {
|
|
49
|
+
if (points[j][1] < points[min][1])
|
|
50
|
+
min = j;
|
|
51
|
+
if (points[j][1] > points[max][1])
|
|
52
|
+
max = j;
|
|
53
|
+
j++;
|
|
54
|
+
}
|
|
55
|
+
if (min < max)
|
|
56
|
+
result.push(points[min], points[max]);
|
|
57
|
+
else if (max < min)
|
|
58
|
+
result.push(points[max], points[min]);
|
|
59
|
+
else
|
|
60
|
+
result.push(points[min]);
|
|
61
|
+
i = j;
|
|
62
|
+
}
|
|
63
|
+
if (end > start)
|
|
64
|
+
result.push(points[end - 1]);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
export function lowerBound(points, time) {
|
|
68
|
+
let lo = 0, hi = points.length;
|
|
69
|
+
while (lo < hi) {
|
|
70
|
+
const mid = (lo + hi) >>> 1;
|
|
71
|
+
if (points[mid][0] < time)
|
|
72
|
+
lo = mid + 1;
|
|
73
|
+
else
|
|
74
|
+
hi = mid;
|
|
75
|
+
}
|
|
76
|
+
return lo;
|
|
77
|
+
}
|
|
78
|
+
export function nearestIndex(points, time) {
|
|
79
|
+
const index = lowerBound(points, time);
|
|
80
|
+
const right = points[index], left = points[index - 1];
|
|
81
|
+
return !right
|
|
82
|
+
? points.length - 1
|
|
83
|
+
: !left
|
|
84
|
+
? index
|
|
85
|
+
: time - left[0] <= right[0] - time
|
|
86
|
+
? index - 1
|
|
87
|
+
: index;
|
|
88
|
+
}
|
|
89
|
+
export function nearestPoint(points, time) {
|
|
90
|
+
return points[nearestIndex(points, time)];
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/chart/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAO9C,MAAM,UAAU,aAAa,CAC3B,MAAkC;IAElC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IACxC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACtB,IAAI,CAAC,CAAC,CAAC,EA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,MAAM,CAAC,MAAM,CAAC;IACrB,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;QACf,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,MAAM,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,GAAG,IAAI;YAAE,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;;YACpC,EAAE,GAAG,GAAG,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,MAAoB,EAAE,IAAY;IAC7D,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,EACzB,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK;QACX,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QACnB,CAAC,CAAC,CAAC,IAAI;YACL,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;gBACjC,CAAC,CAAC,KAAK,GAAG,CAAC;gBACX,CAAC,CAAC,KAAK,CAAC;AAChB,CAAC;AACD,MAAM,UAAU,YAAY,CAC1B,MAAoB,EACpB,IAAY;IAEZ,OAAO,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/chart/engine.ts"],"names":[],"mappings":"AAQA,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,kCAU9C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { init, use } from "echarts/core";
|
|
2
|
+
import { LineChart } from "echarts/charts";
|
|
3
|
+
import { GridComponent, TooltipComponent, DataZoomComponent, } from "echarts/components";
|
|
4
|
+
import { CanvasRenderer } from "echarts/renderers";
|
|
5
|
+
export function initCanvas(element) {
|
|
6
|
+
// Registration belongs to the called function so bundlers cannot discard it as an unused module side effect.
|
|
7
|
+
use([
|
|
8
|
+
LineChart,
|
|
9
|
+
GridComponent,
|
|
10
|
+
TooltipComponent,
|
|
11
|
+
DataZoomComponent,
|
|
12
|
+
CanvasRenderer,
|
|
13
|
+
]);
|
|
14
|
+
return init(element, undefined, { renderer: "canvas" });
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/chart/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,MAAM,UAAU,UAAU,CAAC,OAAoB;IAC7C,6GAA6G;IAC7G,GAAG,CAAC;QACF,SAAS;QACT,aAAa;QACb,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACf,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EChartsCoreOption } from "echarts/core";
|
|
2
|
+
import type { PreparedSeries } from "./data.js";
|
|
3
|
+
import type { TimeRange } from "../types.js";
|
|
4
|
+
export interface ChartConfig {
|
|
5
|
+
series: PreparedSeries[];
|
|
6
|
+
range?: TimeRange;
|
|
7
|
+
sampling?: "minmax" | "none";
|
|
8
|
+
timeZone: string;
|
|
9
|
+
locale?: string;
|
|
10
|
+
options?: EChartsCoreOption;
|
|
11
|
+
}
|
|
12
|
+
export declare function hasManagedConflict(config: ChartConfig): boolean;
|
|
13
|
+
export declare function chartOption(config: ChartConfig, width?: number, colors?: {
|
|
14
|
+
text: string;
|
|
15
|
+
border: string;
|
|
16
|
+
accent: string;
|
|
17
|
+
}): EChartsCoreOption;
|
|
18
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/chart/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAYD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAoC/D;AACD,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,KAAK,SAAM,EACX,MAAM;;;;CAA4D,GACjE,iBAAiB,CAiHnB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { samplePoints } from "./data.js";
|
|
2
|
+
const record = (value) => value && typeof value === "object" && !Array.isArray(value)
|
|
3
|
+
? value
|
|
4
|
+
: {};
|
|
5
|
+
const at = (value, index = 0) => record(Array.isArray(value) ? value[index] : index === 0 ? value : undefined);
|
|
6
|
+
function seriesOption(value, id, index) {
|
|
7
|
+
return Array.isArray(value)
|
|
8
|
+
? record(value.find((v) => record(v).id === id) ?? value[index])
|
|
9
|
+
: at(value, index);
|
|
10
|
+
}
|
|
11
|
+
export function hasManagedConflict(config) {
|
|
12
|
+
const o = config.options;
|
|
13
|
+
if (!o)
|
|
14
|
+
return false;
|
|
15
|
+
const x = at(o.xAxis), zoom = at(o.dataZoom), tooltip = at(o.tooltip);
|
|
16
|
+
if ((x.type !== undefined && x.type !== "time") ||
|
|
17
|
+
(config.range &&
|
|
18
|
+
((x.min !== undefined && x.min !== config.range[0]) ||
|
|
19
|
+
(x.max !== undefined && x.max !== config.range[1]) ||
|
|
20
|
+
(zoom.startValue !== undefined &&
|
|
21
|
+
zoom.startValue !== config.range[0]) ||
|
|
22
|
+
(zoom.endValue !== undefined && zoom.endValue !== config.range[1]))))
|
|
23
|
+
return true;
|
|
24
|
+
if (at(o.legend).show === true ||
|
|
25
|
+
tooltip.showContent === true ||
|
|
26
|
+
(tooltip.trigger !== undefined && tooltip.trigger !== "axis"))
|
|
27
|
+
return true;
|
|
28
|
+
return config.series.some((s, index) => {
|
|
29
|
+
const custom = seriesOption(o.series, s.id, index), y = at(o.yAxis, s.axis ?? 0);
|
|
30
|
+
return ("data" in custom ||
|
|
31
|
+
(custom.type !== undefined && custom.type !== "line") ||
|
|
32
|
+
custom.connectNulls === true ||
|
|
33
|
+
(custom.yAxisIndex !== undefined &&
|
|
34
|
+
custom.yAxisIndex !== (s.axis ?? 0)) ||
|
|
35
|
+
(custom.name !== undefined && custom.name !== s.label) ||
|
|
36
|
+
(y.type !== undefined && y.type !== "value") ||
|
|
37
|
+
(y.name !== undefined && y.name !== s.unit));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function chartOption(config, width = 800, colors = { text: "#667085", border: "#e7e9ee", accent: "#355dff" }) {
|
|
41
|
+
const { series, range, sampling = "minmax", timeZone, locale, options, } = config;
|
|
42
|
+
if (range &&
|
|
43
|
+
(!range.every((value) => Number.isFinite(value) && Math.abs(value) <= 8.64e15) ||
|
|
44
|
+
range[0] >= range[1]))
|
|
45
|
+
throw new Error("Chart range must contain two increasing epoch milliseconds");
|
|
46
|
+
const timeFormat = new Intl.DateTimeFormat(locale ?? "en-GB", {
|
|
47
|
+
timeZone,
|
|
48
|
+
hour: "2-digit",
|
|
49
|
+
minute: "2-digit",
|
|
50
|
+
});
|
|
51
|
+
const maxAxis = series.some((s) => s.axis === 1) ? 1 : 0;
|
|
52
|
+
const passthrough = { ...options };
|
|
53
|
+
delete passthrough.legend;
|
|
54
|
+
const x = at(options?.xAxis), zoom = at(options?.dataZoom);
|
|
55
|
+
return {
|
|
56
|
+
animation: false,
|
|
57
|
+
...passthrough,
|
|
58
|
+
grid: {
|
|
59
|
+
left: 64,
|
|
60
|
+
right: maxAxis ? 64 : 20,
|
|
61
|
+
top: 30,
|
|
62
|
+
bottom: 44,
|
|
63
|
+
...at(options?.grid),
|
|
64
|
+
},
|
|
65
|
+
tooltip: {
|
|
66
|
+
...at(options?.tooltip),
|
|
67
|
+
trigger: "axis",
|
|
68
|
+
showContent: false,
|
|
69
|
+
animation: false,
|
|
70
|
+
},
|
|
71
|
+
xAxis: {
|
|
72
|
+
axisLine: { lineStyle: { color: colors.border } },
|
|
73
|
+
splitLine: { show: false },
|
|
74
|
+
axisPointer: { show: true, label: { show: false } },
|
|
75
|
+
...x,
|
|
76
|
+
type: "time",
|
|
77
|
+
...(range ? { min: range[0], max: range[1] } : {}),
|
|
78
|
+
axisLabel: {
|
|
79
|
+
color: colors.text,
|
|
80
|
+
formatter: (time) => timeFormat.format(time),
|
|
81
|
+
...record(x.axisLabel),
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
yAxis: Array.from({ length: maxAxis + 1 }, (_, axis) => {
|
|
85
|
+
const custom = at(options?.yAxis, axis);
|
|
86
|
+
return {
|
|
87
|
+
nameTextStyle: { color: colors.text },
|
|
88
|
+
splitLine: { lineStyle: { color: colors.border } },
|
|
89
|
+
scale: true,
|
|
90
|
+
...custom,
|
|
91
|
+
type: "value",
|
|
92
|
+
name: series.find((s) => (s.axis ?? 0) === axis)?.unit ?? "",
|
|
93
|
+
axisLabel: { color: colors.text, ...record(custom.axisLabel) },
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
96
|
+
dataZoom: [
|
|
97
|
+
{
|
|
98
|
+
zoomOnMouseWheel: "ctrl",
|
|
99
|
+
moveOnMouseMove: true,
|
|
100
|
+
preventDefaultMouseMove: false,
|
|
101
|
+
...zoom,
|
|
102
|
+
type: "inside",
|
|
103
|
+
xAxisIndex: 0,
|
|
104
|
+
filterMode: "none",
|
|
105
|
+
...(range ? { startValue: range[0], endValue: range[1] } : {}),
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
series: series.map((s, index) => {
|
|
109
|
+
const custom = seriesOption(options?.series, s.id, index);
|
|
110
|
+
const line = record(custom.lineStyle), item = record(custom.itemStyle);
|
|
111
|
+
const color = s.color ?? line.color ?? (index ? "#12a594" : colors.accent);
|
|
112
|
+
return {
|
|
113
|
+
showSymbol: false,
|
|
114
|
+
clip: true,
|
|
115
|
+
...custom,
|
|
116
|
+
id: s.id,
|
|
117
|
+
name: s.label,
|
|
118
|
+
type: "line",
|
|
119
|
+
yAxisIndex: s.axis ?? 0,
|
|
120
|
+
connectNulls: false,
|
|
121
|
+
sampling: "none",
|
|
122
|
+
lineStyle: { width: 2, ...line, color },
|
|
123
|
+
itemStyle: { ...item, color: s.color ?? item.color ?? color },
|
|
124
|
+
areaStyle: s.area === undefined
|
|
125
|
+
? custom.areaStyle
|
|
126
|
+
: s.area
|
|
127
|
+
? { opacity: 0.08, ...record(custom.areaStyle) }
|
|
128
|
+
: undefined,
|
|
129
|
+
data: sampling === "none"
|
|
130
|
+
? s.points
|
|
131
|
+
: samplePoints(s.points, Math.max(100, width * 2), range),
|
|
132
|
+
};
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL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AAM,CAAC,SAAS,CAAC,EAAE;wBAChD,CAAC,CAAC,SAAS;gBACjB,IAAI,EACF,QAAQ,KAAK,MAAM;oBACjB,CAAC,CAAC,CAAC,CAAC,MAAM;oBACV,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC;aAC9D,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RefAttributes, ReactElement } from "react";
|
|
2
|
+
import type { AlarmEvent, Density } from "../types.js";
|
|
3
|
+
export interface AlarmFeedProps<T extends AlarmEvent = AlarmEvent> extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
4
|
+
items: readonly T[];
|
|
5
|
+
children: (item: T, index: number) => React.ReactNode;
|
|
6
|
+
density?: Density;
|
|
7
|
+
virtualized?: boolean;
|
|
8
|
+
rowHeight?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
empty?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare const AlarmFeed: {
|
|
13
|
+
Root: <T extends AlarmEvent = AlarmEvent>(props: AlarmFeedProps<T> & RefAttributes<HTMLDivElement>) => ReactElement;
|
|
14
|
+
Severity: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLSpanElement> & RefAttributes<HTMLSpanElement>>;
|
|
15
|
+
Message: import("react").ForwardRefExoticComponent<import("../types.js").PartProps & RefAttributes<HTMLElement>>;
|
|
16
|
+
Description: import("react").ForwardRefExoticComponent<import("../types.js").PartProps & RefAttributes<HTMLElement>>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=alarm-feed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-feed.d.ts","sourceRoot":"","sources":["../../src/components/alarm-feed.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAKvE,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACvD,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,IAAI,CAC7E,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,UAAU,CACX;IACC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACzB;AA+FD,eAAO,MAAM,SAAS;UACM,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAC1D,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,KACrD,YAAY;;;;CAQlB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
6
|
+
import { useRef } from "react";
|
|
7
|
+
import { cx, part } from "../internal.js";
|
|
8
|
+
function Root({ items, children, density = "comfortable", virtualized = false, rowHeight = 80, height = 400, empty, className, style, ...props }, forwardedRef) {
|
|
9
|
+
const host = useRef(null);
|
|
10
|
+
const hostRef = useComposedRefs(host, forwardedRef);
|
|
11
|
+
const virtualizer = useVirtualizer({
|
|
12
|
+
count: items.length,
|
|
13
|
+
initialRect: { width: 0, height: virtualized ? height : 0 },
|
|
14
|
+
getScrollElement: () => host.current,
|
|
15
|
+
estimateSize: () => rowHeight,
|
|
16
|
+
overscan: 4,
|
|
17
|
+
enabled: virtualized,
|
|
18
|
+
getItemKey: (index) => items[index].id,
|
|
19
|
+
});
|
|
20
|
+
const rows = virtualized
|
|
21
|
+
? virtualizer.getVirtualItems()
|
|
22
|
+
: items.map((item, index) => ({ key: item.id, index, start: 0 }));
|
|
23
|
+
return (_jsx("div", { ...props, ref: hostRef, tabIndex: props.tabIndex ?? (virtualized ? 0 : undefined), "data-slot": "alarm-feed", "data-density": density, className: cx("watt-root overflow-auto", className), style: { ...(virtualized ? { height } : {}), ...style }, children: !items.length ? (empty) : (_jsx("div", { role: "list", style: virtualized
|
|
24
|
+
? { height: virtualizer.getTotalSize(), position: "relative" }
|
|
25
|
+
: undefined, children: rows.map((row) => {
|
|
26
|
+
const item = items[row.index];
|
|
27
|
+
return (_jsx("div", { role: "listitem", "data-index": row.index, ref: virtualized ? virtualizer.measureElement : undefined, "aria-posinset": row.index + 1, "aria-setsize": items.length, "data-slot": "alarm-feed-item", "data-severity": item.severity, "data-state": item.status, className: cx("border-b border-[var(--watt-border)] last:border-0", density === "compact" ? "py-2.5" : "py-4"), style: virtualized
|
|
28
|
+
? {
|
|
29
|
+
position: "absolute",
|
|
30
|
+
top: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
width: "100%",
|
|
33
|
+
transform: `translateY(${row.start}px)`,
|
|
34
|
+
}
|
|
35
|
+
: undefined, children: children(item, row.index) }, row.key));
|
|
36
|
+
}) })) }));
|
|
37
|
+
}
|
|
38
|
+
const Severity = forwardRef((props, ref) => (_jsx("span", { ...props, ref: ref, "data-slot": "alarm-feed-severity" })));
|
|
39
|
+
export const AlarmFeed = {
|
|
40
|
+
Root: forwardRef(Root),
|
|
41
|
+
Severity,
|
|
42
|
+
Message: part("alarm-feed-message", "font-medium", "span"),
|
|
43
|
+
Description: part("alarm-feed-description", "text-sm text-[var(--watt-muted)]", "span"),
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=alarm-feed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-feed.js","sourceRoot":"","sources":["../../src/components/alarm-feed.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAc1C,SAAS,IAAI,CACX,EACE,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,aAAa,EACvB,WAAW,GAAG,KAAK,EACnB,SAAS,GAAG,EAAE,EACd,MAAM,GAAG,GAAG,EACZ,KAAK,EACL,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACU,EACpB,YAA0C;IAE1C,MAAM,IAAI,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,cAAc,CAAC;QACjC,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QAC3D,gBAAgB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO;QACpC,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;QAC7B,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,WAAW;QACpB,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,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,CAAC,MAAM,eAChB,iBAAiB,mBACZ,IAAI,CAAC,QAAQ,gBAChB,IAAI,CAAC,MAAM,EACvB,SAAS,EAAE,EAAE,CACX,oDAAoD,EACpD,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAC1C,EACD,KAAK,EACH,WAAW;wBACT,CAAC,CAAC;4BACE,QAAQ,EAAE,UAAU;4BACpB,GAAG,EAAE,CAAC;4BACN,IAAI,EAAE,CAAC;4BACP,KAAK,EAAE,MAAM;4BACb,SAAS,EAAE,cAAc,GAAG,CAAC,KAAK,KAAK;yBACxC;wBACH,CAAC,CAAC,SAAS,YAGd,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAxBrB,GAAG,CAAC,GAAG,CAyBR,CACP,CAAC;YACJ,CAAC,CAAC,GACE,CACP,GACG,CACP,CAAC;AACJ,CAAC;AACD,MAAM,QAAQ,GAAG,UAAU,CAGzB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAChB,kBAAU,KAAK,EAAE,GAAG,EAAE,GAAG,eAAY,qBAAqB,GAAG,CAC9D,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,UAAU,CAAC,IAAI,CAEJ;IACjB,QAAQ;IACR,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,aAAa,EAAE,MAAM,CAAC;IAC1D,WAAW,EAAE,IAAI,CACf,wBAAwB,EACxB,kCAAkC,EAClC,MAAM,CACP;CACF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RefAttributes, ReactElement } from "react";
|
|
2
|
+
import type { Density, PlantAsset } from "../types.js";
|
|
3
|
+
export interface AssetTreeRow<T> {
|
|
4
|
+
item: T;
|
|
5
|
+
level: number;
|
|
6
|
+
expanded: boolean;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
focused: boolean;
|
|
9
|
+
hasChildren: boolean;
|
|
10
|
+
toggleExpanded: () => void;
|
|
11
|
+
}
|
|
12
|
+
export type AssetTreeItem<T extends PlantAsset> = T | (T extends {
|
|
13
|
+
children?: readonly (infer C extends PlantAsset)[];
|
|
14
|
+
} ? C extends T ? never : AssetTreeItem<C> : never);
|
|
15
|
+
export interface AssetTreeProps<T extends PlantAsset = PlantAsset> extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
16
|
+
items: readonly T[];
|
|
17
|
+
children: (row: AssetTreeRow<AssetTreeItem<T>>) => React.ReactNode;
|
|
18
|
+
expandedIds?: string[];
|
|
19
|
+
defaultExpandedIds?: string[];
|
|
20
|
+
onExpandedChange?: (ids: string[]) => void;
|
|
21
|
+
selectedIds?: string[];
|
|
22
|
+
defaultSelectedIds?: string[];
|
|
23
|
+
onSelectionChange?: (ids: string[]) => void;
|
|
24
|
+
onActivate?: (item: AssetTreeItem<T>) => void;
|
|
25
|
+
density?: Density;
|
|
26
|
+
height?: number;
|
|
27
|
+
rowHeight?: number;
|
|
28
|
+
empty?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export declare const AssetTree: {
|
|
31
|
+
Root: <T extends PlantAsset = PlantAsset>(props: AssetTreeProps<T> & RefAttributes<HTMLDivElement>) => ReactElement;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=asset-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-tree.d.ts","sourceRoot":"","sources":["../../src/components/asset-tree.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAgB,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvD,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,O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