@seanyeh77/ui 0.48.3 → 0.50.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/dist/bundle.js +18 -18
- package/dist/components/CodeView/CodeView.js +6 -5
- package/dist/components/CodeView/CodeView.js.map +1 -1
- package/dist/components/ConsoleLayout/ConsoleLayout.d.ts +11 -5
- package/dist/components/ConsoleLayout/ConsoleLayout.js +73 -10
- package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
- package/dist/components/DataTable/DataTable.js +2 -2
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.js +2 -2
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/FloorPlan/FloorPlan.d.ts +65 -0
- package/dist/components/FloorPlan/FloorPlan.js +830 -0
- package/dist/components/FloorPlan/FloorPlan.js.map +1 -0
- package/dist/components/Markdown/Markdown.js +3 -3
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/SideNav/SideNav.js +2 -2
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.js +2 -2
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/ZoneMap/ZoneMap.d.ts +3 -0
- package/dist/components/ZoneMap/ZoneMap.js +6 -20
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
- package/dist/css/ConsoleLayout.css +43 -5
- package/dist/css/FloorPlan.css +273 -0
- package/dist/css/KpiCard.css +5 -4
- package/dist/css/ZoneMap.css +0 -97
- package/dist/css/base.css +99 -0
- package/dist/i18n.js +6 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/chart.js +2 -2
- package/dist/internal/chart.js.map +1 -1
- package/dist/internal/util.js +8 -1
- package/dist/internal/util.js.map +1 -1
- package/dist/internal/zone.js +48 -0
- package/dist/internal/zone.js.map +1 -0
- package/dist/styles.css +415 -106
- package/docs/ConsoleLayout.md +23 -7
- package/docs/DataColors.md +1 -1
- package/docs/FloorPlan.md +43 -0
- package/docs/ZoneMap.md +2 -2
- package/docs/agents.md +5 -5
- package/docs/components.json +4 -0
- package/docs/data.md +2 -1
- package/docs/monitoring.md +9 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { announce } from '../../announce';\nimport { DRAG_MIN, nextPreset } from '../../internal/clickSteps';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys, stepped\n * through preset widths with a click (narrowest, default, 1.5 times the default) and reset with a double-click or Enter. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press. `moved` turns a press\n // into a drag once the pointer has gone DRAG_MIN px; released before that it was a click.\n const dragging = React.useRef<{ x: number; moved: boolean } | null>(null);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = { x: e.clientX, moved: false };\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n const d = dragging.current;\n if (!d || !root.current) return;\n if (!d.moved && Math.abs(e.clientX - d.x) < DRAG_MIN) return;\n d.moved = true;\n const r = root.current.getBoundingClientRect();\n set(r.right - e.clientX - HANDLE / 2, false);\n };\n // A click without dragging (WCAG 2.5.7): the next preset width of the panel, announced.\n const presets = [minB, defaultB, defaultB * 1.5];\n const onUp = (e: React.PointerEvent<HTMLDivElement>, cancel = false) => {\n const d = dragging.current;\n if (!d) return;\n dragging.current = null;\n setDrag(false);\n if (!d.moved && !cancel) {\n const next = Math.round(Math.min(maxB, Math.max(minB, nextPreset(shown, presets))));\n set(next);\n announce(tr('面板 {n} px', { n: next }));\n }\n try {\n if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n aria-description={tr('拖曳或按 ← → 調整;按一下切換預設寬度,按兩下或 Enter 還原')}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={(e) => onUp(e, true)}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AA6BA,MAAM,SAAS;;AAEf,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAEb,MAAM,QAAQ,QAA2C;CACvD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,IAAI,OAAO,OAAO,aAAa,QAAQ,cAAc,GAAG,CAAC;EAC/D,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;CAC3C,QAAQ;EACN,OAAO;CACT;AACF;AACA,MAAM,SAAS,KAAyB,MAAc;CACpD,IAAI,CAAC,KAAK;CACV,IAAI;EACF,OAAO,aAAa,QAAQ,cAAc,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC;CACtE,QAAQ,CAER;AACF;;;AAIA,SAAgB,UAAU,EAAE,GAAG,GAAG,WAAW,KAAK,OAAO,KAAK,OAAO,KAAK,YAAY,OAAO,UAAU,aAA6B;CAClI,QAAQ,WAAW,MAAM,aAAa,aAAa,SAAS,sBAAsB,KAAK,4BAA4B,KAAK,mCAAmC;CAC3J,MAAM,OAAO,MAAM,OAAuB,IAAI;CAC9C,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,CAAC;CAG1C,MAAM,CAAC,MAAM,WAAW,MAAM,gBAAgB,OAAO,WAAW,cAAc,OAA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c,UAAA;GAAO,CAAA;GACnC,UAAU,OACT,oBAAC,OAAD;IACE,MAAK;IACL,UAAU;IACV,oBAAiB;IACjB,cAAY,SAAS,GAAG,QAAQ;IAChC,iBAAe;IACf,iBAAe;IACf,iBAAe;IACf,iBAAe,KAAK,IAAI,MAAM,QAAQ,SAAS,IAAI;IACnD,kBAAgB,GAAG,yBAAyB;KAAE,GAAG;KAAQ,GAAG;IAAM,CAAC;IACnE,oBAAkB,GAAG,qCAAqC;IAC1D,WAAU;IACV,WAAW;IACX,eAAe;IACf,eAAe;IACf,aAAa;IACb,kBAAkB,MAAM,KAAK,GAAG,IAAI;IACpC,qBAAqB,IAAI,QAAQ;IAGjC,UAAA,qBAAC,QAAD;KAAM,WAAU;KAAgB,eAAY;KAA5C,UAAA;MACE,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;KACA;;GACH,CAAA;GAEP,oBAAC,OAAD;IAAS;IAAI,WAAU;IACpB,UAAA;GACE,CAAA;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cssZoom, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { announce } from '../../announce';\nimport { DRAG_MIN, nextPreset } from '../../internal/clickSteps';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys, stepped\n * through preset widths with a click (narrowest, default, 1.5 times the default) and reset with a double-click or Enter. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press. `moved` turns a press\n // into a drag once the pointer has gone DRAG_MIN px; released before that it was a click.\n const dragging = React.useRef<{ x: number; moved: boolean } | null>(null);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = { x: e.clientX, moved: false };\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n const d = dragging.current;\n if (!d || !root.current) return;\n if (!d.moved && Math.abs(e.clientX - d.x) < DRAG_MIN) return;\n d.moved = true;\n const r = root.current.getBoundingClientRect();\n set((r.right - e.clientX) / cssZoom(root.current) - HANDLE / 2, false);\n };\n // A click without dragging (WCAG 2.5.7): the next preset width of the panel, announced.\n const presets = [minB, defaultB, defaultB * 1.5];\n const onUp = (e: React.PointerEvent<HTMLDivElement>, cancel = false) => {\n const d = dragging.current;\n if (!d) return;\n dragging.current = null;\n setDrag(false);\n if (!d.moved && !cancel) {\n const next = Math.round(Math.min(maxB, Math.max(minB, nextPreset(shown, presets))));\n set(next);\n announce(tr('面板 {n} px', { n: next }));\n }\n try {\n if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n aria-description={tr('拖曳或按 ← → 調整;按一下切換預設寬度,按兩下或 Enter 還原')}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={(e) => onUp(e, true)}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AA6BA,MAAM,SAAS;;AAEf,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAEb,MAAM,QAAQ,QAA2C;CACvD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,IAAI,OAAO,OAAO,aAAa,QAAQ,cAAc,GAAG,CAAC;EAC/D,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;CAC3C,QAAQ;EACN,OAAO;CACT;AACF;AACA,MAAM,SAAS,KA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the root element. */
|
|
57
57
|
className?: string;
|
|
58
58
|
}
|
|
59
|
+
/** A floor plan of zones as rectangles on a grid, each filled by its value (heat scale) with its name, state, figure
|
|
60
|
+
* and one detail line. Zones are buttons: Tab moves between them, Enter or Space selects. The selected zone has an
|
|
61
|
+
* ink outline outside it; a zone needing attention has a 4 px warning or danger border and 「⚠」 in its state. */
|
|
59
62
|
export declare function ZoneMap({ zones, label, columns, rowHeight, fill, className, ...p }: ZoneMapProps): React.JSX.Element;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { devWarn } from "../../internal/dev.js";
|
|
3
3
|
import { cx } from "../../internal/util.js";
|
|
4
|
-
import { format } from "../../format.js";
|
|
5
4
|
import { tr } from "../../i18n.js";
|
|
6
|
-
import {
|
|
5
|
+
import { heatRange, noData, zoneText } from "../../internal/zone.js";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
// src/components/ZoneMap/ZoneMap.tsx
|
|
9
8
|
/** A floor plan of zones as rectangles on a grid, each filled by its value (heat scale) with its name, state, figure
|
|
10
9
|
* and one detail line. Zones are buttons: Tab moves between them, Enter or Space selects. The selected zone has an
|
|
11
10
|
* ink outline outside it; a zone needing attention has a 4 px warning or danger border and 「⚠」 in its state. */
|
|
12
|
-
const DATA_TOKEN = /^(heat-[1-7]|diverge-(neg|pos)(-strong)?|diverge-zero|chart-[1-4])$/;
|
|
13
11
|
function ZoneMap({ zones, label, columns = 4, rowHeight = 120, fill = false, className, ...p }) {
|
|
14
12
|
devWarn(p.selectedId !== void 0 || p.onSelect !== void 0, "ZoneMap", "selectedId and onSelect are renamed value and onChange (id, zone); pass those instead.");
|
|
15
13
|
const selectedId = p.value !== void 0 ? p.value : p.selectedId;
|
|
16
14
|
const pick = (z) => p.onChange ? p.onChange(z.id, z) : p.onSelect?.(z);
|
|
17
|
-
const
|
|
18
|
-
const lo = p.min ?? (values.length ? Math.min(...values) : 0);
|
|
19
|
-
const hiRaw = p.max ?? (values.length ? Math.max(...values) : 1);
|
|
20
|
-
const [min, max] = hiRaw > lo ? [lo, hiRaw] : [lo - 1, lo + 1];
|
|
15
|
+
const [min, max] = heatRange(zones, p.min, p.max);
|
|
21
16
|
return /* @__PURE__ */ jsx("div", {
|
|
22
17
|
className: cx("ui-zonemap", fill && "is-fill", className),
|
|
23
18
|
role: "group",
|
|
@@ -31,7 +26,7 @@ function ZoneMap({ zones, label, columns = 4, rowHeight = 120, fill = false, cla
|
|
|
31
26
|
gridRow: `${z.area.row} / span ${z.area.rows ?? 1}`,
|
|
32
27
|
gridColumn: `${z.area.col} / span ${z.area.cols ?? 1}`
|
|
33
28
|
} : void 0;
|
|
34
|
-
if (z
|
|
29
|
+
if (noData(z)) return /* @__PURE__ */ jsxs("div", {
|
|
35
30
|
className: "ui-zone is-empty",
|
|
36
31
|
style: place,
|
|
37
32
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -42,11 +37,7 @@ function ZoneMap({ zones, label, columns = 4, rowHeight = 120, fill = false, cla
|
|
|
42
37
|
children: tr("沒有資料")
|
|
43
38
|
})]
|
|
44
39
|
}, z.id);
|
|
45
|
-
const tone = z
|
|
46
|
-
const fill = z.fill ?? (z.value != null ? heatToken(z.value, min, max) : "surface-sub");
|
|
47
|
-
const bg = /^[a-z][a-z0-9-]*$/.test(fill) ? `var(--${fill})` : fill;
|
|
48
|
-
const state = (tone === "normal" ? "" : "⚠ ") + (z.state ?? (z.forecast ? tr("預測") : tr("正常")));
|
|
49
|
-
const figure = z.value != null ? format.number(z.value, z.decimals ?? 1) : "—";
|
|
40
|
+
const { tone, fill, bg, color, state, figure, label: name } = zoneText(z, min, max);
|
|
50
41
|
const on = selectedId === z.id;
|
|
51
42
|
return /* @__PURE__ */ jsxs("button", {
|
|
52
43
|
type: "button",
|
|
@@ -55,15 +46,10 @@ function ZoneMap({ zones, label, columns = 4, rowHeight = 120, fill = false, cla
|
|
|
55
46
|
style: {
|
|
56
47
|
...place,
|
|
57
48
|
background: bg,
|
|
58
|
-
color
|
|
49
|
+
color
|
|
59
50
|
},
|
|
60
51
|
"aria-pressed": on,
|
|
61
|
-
"aria-label":
|
|
62
|
-
z.name,
|
|
63
|
-
figure + (z.unit ? " " + z.unit : ""),
|
|
64
|
-
state.replace("⚠ ", ""),
|
|
65
|
-
z.detail
|
|
66
|
-
].filter(Boolean).join(tr(",")),
|
|
52
|
+
"aria-label": name,
|
|
67
53
|
onClick: () => pick(z),
|
|
68
54
|
children: [
|
|
69
55
|
/* @__PURE__ */ jsxs("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoneMap.js","names":[],"sources":["../../../src/components/ZoneMap/ZoneMap.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { devWarn } from '../../internal/dev';\nimport { cx } from '../../internal/util';\nimport {
|
|
1
|
+
{"version":3,"file":"ZoneMap.js","names":[],"sources":["../../../src/components/ZoneMap/ZoneMap.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { devWarn } from '../../internal/dev';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\nimport { heatRange, noData, zoneText } from '../../internal/zone';\n\nexport interface Zone {\n /** Unique id: value and onChange use it. */\n id: string;\n /** 「A 區」. */\n name: string;\n /** The main figure; null or undefined: no data (a dashed outline, not selectable). */\n value?: number | null;\n /** After the figure, smaller: '°C'. */\n unit?: string;\n /** Decimals of the figure. Default 1. */\n decimals?: number;\n /** The fill: a token name such as 'heat-5' or a color. Default: from the value on the heat scale (min, max). */\n fill?: string;\n /** `warning` or `danger`: a 4 px border in that color, and 「⚠」 before the state. Default normal. */\n tone?: 'normal' | 'warning' | 'danger';\n /** The state in words, e.g. 「正常」「注意」「超過上限」. Default 「正常」, or 「預測」 for a forecast. */\n state?: string;\n /** A forecast, not a measurement: the forecast stripes over the fill. */\n forecast?: boolean;\n /** One line of secondary information, e.g. 「進氣 26.1 °C」. */\n detail?: string;\n /** Where it sits on the grid (1-based); default: the next free cell. */\n area?: { row: number; col: number; rows?: number; cols?: number };\n}\n\nexport interface ZoneMapProps {\n /** The zones, in order (placed by `area` or flowing into the grid). */\n zones: Zone[];\n /** What the map shows, for screen readers, e.g. 「設施分區」. */\n label: string;\n /** Columns of the grid. Default 4. Where a zone would be narrower than 150 px (phones), fewer columns are used and\n * `area` placements are dropped, so zones flow in order. */\n columns?: number;\n /** Height of one grid row in px. Default 120. With `fill`, the least height of a row. */\n rowHeight?: number;\n /** Rows grow to fill the height the map is given (in ConsoleLayout's main view, or any flex column), never below\n * `rowHeight`. */\n fill?: boolean;\n /** Bottom of the heat scale for zones without a fill. Default: the smallest value among the zones. */\n min?: number;\n /** Top of the heat scale for zones without a fill. Default: the largest value among the zones. */\n max?: number;\n /** The selected zone's id (controlled); null for none. */\n value?: string | null;\n /** A zone was picked (click, Enter or Space): its id, and the zone. */\n onChange?: (id: string, zone: Zone) => void;\n /** @deprecated use value. */\n selectedId?: string | null;\n /** @deprecated use onChange (it gets the id first, the zone second). */\n onSelect?: (zone: Zone) => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** A floor plan of zones as rectangles on a grid, each filled by its value (heat scale) with its name, state, figure\n * and one detail line. Zones are buttons: Tab moves between them, Enter or Space selects. The selected zone has an\n * ink outline outside it; a zone needing attention has a 4 px warning or danger border and 「⚠」 in its state. */\nexport function ZoneMap({ zones, label, columns = 4, rowHeight = 120, fill = false, className, ...p }: ZoneMapProps) {\n devWarn(\n p.selectedId !== undefined || p.onSelect !== undefined,\n 'ZoneMap',\n 'selectedId and onSelect are renamed value and onChange (id, zone); pass those instead.',\n );\n const selectedId = p.value !== undefined ? p.value : p.selectedId;\n const pick = (z: Zone) => (p.onChange ? p.onChange(z.id, z) : p.onSelect?.(z));\n // The heat scale spans the zones' own values unless min and max are given: a map of humidity or load reads as well as\n // one of temperatures.\n const [min, max] = heatRange(zones, p.min, p.max);\n return (\n <div\n className={cx('ui-zonemap', fill && 'is-fill', className)}\n role=\"group\"\n aria-label={label}\n style={{ '--zone-cols': columns, gridAutoRows: fill ? `minmax(${rowHeight}px, 1fr)` : rowHeight + 'px' } as React.CSSProperties}\n >\n {zones.map((z) => {\n const place = z.area ? { gridRow: `${z.area.row} / span ${z.area.rows ?? 1}`, gridColumn: `${z.area.col} / span ${z.area.cols ?? 1}` } : undefined;\n if (noData(z))\n return (\n <div key={z.id} className=\"ui-zone is-empty\" style={place}>\n <span className=\"ui-zone-name\">{z.name}</span>\n <span className=\"ui-zone-detail\">{tr('沒有資料')}</span>\n </div>\n );\n const { tone, fill, bg, color, state, figure, label: name } = zoneText(z, min, max);\n const on = selectedId === z.id;\n return (\n <button\n key={z.id}\n type=\"button\"\n className={cx('ui-zone', 'is-' + tone, z.forecast && 'ui-forecast', on && 'is-selected')}\n data-fill={fill}\n // Text on the data tokens comes from CSS (it follows the theme); other fills are measured here.\n style={{ ...place, background: bg, color }}\n aria-pressed={on}\n aria-label={name}\n onClick={() => pick(z)}\n >\n <span className=\"ui-zone-head\">\n <span className=\"ui-zone-name\">{z.name}</span>\n <span className=\"ui-zone-state\">{state}</span>\n </span>\n <span className=\"ui-zone-value\">\n {figure}\n {/* The space before the unit sits in the unit's text font (a Geist Mono space at h2 size is about 20 px wide)\n and does not break: the shown text is 「23.1 °C」, the same as the button's name (WCAG 2.5.3). */}\n {z.unit ? <span className=\"ui-zone-unit\">{'\\u00a0' + z.unit}</span> : null}\n </span>\n {z.detail ? <span className=\"ui-zone-detail\">{z.detail}</span> : null}\n </button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AA+DA,SAAgB,QAAQ,EAAE,OAAO,OAAO,UAAU,GAAG,YAAY,KAAK,OAAO,OAAO,WAAW,GAAG,KAAmB;CACnH,QACE,EAAE,eAAe,KAAA,KAAa,EAAE,aAAa,KAAA,GAC7C,WACA,wFACF;CACA,MAAM,aAAa,EAAE,UAAU,KAAA,IAAY,EAAE,QAAQ,EAAE;CACvD,MAAM,QAAQ,MAAa,EAAE,WAAW,EAAE,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AA,CACzC;;KACN,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACG,QAGA,EAAE,OAAO,oBAAC,QAAD;OAAM,WAAU;OAAgB,UAAA,SAAW,EAAE;MAAW,CAAA,IAAI,IAClE;;KACL,EAAE,SAAS,oBAAC,QAAD;MAAM,WAAU;MAAkB,UAAA,EAAE;KAAa,CAAA,IAAI;IAC3D;GArBD,GAAA,EAAE,EAqBD;EAEZ,CAAC;CACE,CAAA;AAET"}
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
.ui-console-top {
|
|
30
30
|
grid-column: 1 / -1;
|
|
31
31
|
display: flex;
|
|
32
|
+
/* Never wider than the layout: what does not fit goes to a second line (the main view gives up the height). */
|
|
33
|
+
flex-wrap: wrap;
|
|
34
|
+
row-gap: var(--space-2);
|
|
32
35
|
align-items: center;
|
|
33
36
|
justify-content: space-between;
|
|
34
37
|
gap: var(--space-4);
|
|
@@ -47,6 +50,11 @@
|
|
|
47
50
|
gap: var(--space-3);
|
|
48
51
|
min-width: 0;
|
|
49
52
|
}
|
|
53
|
+
.ui-console-end {
|
|
54
|
+
flex-wrap: wrap;
|
|
55
|
+
justify-content: flex-end;
|
|
56
|
+
margin-left: auto;
|
|
57
|
+
}
|
|
50
58
|
.ui-console-title {
|
|
51
59
|
margin: 0;
|
|
52
60
|
font-size: inherit;
|
|
@@ -60,7 +68,9 @@
|
|
|
60
68
|
}
|
|
61
69
|
.ui-console-kpis {
|
|
62
70
|
display: flex;
|
|
71
|
+
flex-wrap: wrap;
|
|
63
72
|
align-items: stretch;
|
|
73
|
+
max-width: 100%;
|
|
64
74
|
}
|
|
65
75
|
.ui-console-content {
|
|
66
76
|
display: contents;
|
|
@@ -74,6 +84,9 @@
|
|
|
74
84
|
flex-direction: column;
|
|
75
85
|
}
|
|
76
86
|
.ui-console-main > * {
|
|
87
|
+
/* Scroll containers are positioned, so visually hidden text inside them is clipped with them instead of making the
|
|
88
|
+
page scroll. */
|
|
89
|
+
position: relative;
|
|
77
90
|
flex: 1 1 auto;
|
|
78
91
|
min-height: 0;
|
|
79
92
|
overflow: auto;
|
|
@@ -82,6 +95,7 @@
|
|
|
82
95
|
flex-direction: column;
|
|
83
96
|
}
|
|
84
97
|
.ui-console-side {
|
|
98
|
+
position: relative;
|
|
85
99
|
grid-column: 2;
|
|
86
100
|
grid-row: 2 / 4;
|
|
87
101
|
min-height: 0;
|
|
@@ -94,9 +108,22 @@
|
|
|
94
108
|
padding: 12px;
|
|
95
109
|
}
|
|
96
110
|
.ui-console-side > * {
|
|
111
|
+
/* Side cards keep their own height; the panel scrolls when they do not fit. */
|
|
97
112
|
flex: none;
|
|
98
113
|
}
|
|
114
|
+
/* An extra card that does not fit: laid out at the panel's width, out of sight and at no height, so it is measured
|
|
115
|
+
again when the panel grows. */
|
|
116
|
+
.ui-console-extra.is-out {
|
|
117
|
+
position: absolute;
|
|
118
|
+
top: 0;
|
|
119
|
+
left: 12px;
|
|
120
|
+
right: 12px;
|
|
121
|
+
height: 0;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
visibility: hidden;
|
|
124
|
+
}
|
|
99
125
|
.ui-console-bottom {
|
|
126
|
+
position: relative;
|
|
100
127
|
grid-column: 1;
|
|
101
128
|
grid-row: 3;
|
|
102
129
|
min-width: 0;
|
|
@@ -104,7 +131,9 @@
|
|
|
104
131
|
display: flex;
|
|
105
132
|
flex-direction: column;
|
|
106
133
|
}
|
|
107
|
-
/*
|
|
134
|
+
/* Stacked (narrower than stackedBelow, 1100 px by default): one scrolling column. The top bar keeps the title, status,
|
|
135
|
+
clock and full screen on its first line and puts every KPI on the next ones; the main view; the side cards side by
|
|
136
|
+
side where there is room; the bottom row; the extra cards the same way as the side cards. */
|
|
108
137
|
.ui-console.is-stacked {
|
|
109
138
|
height: auto;
|
|
110
139
|
min-height: 100dvh;
|
|
@@ -116,19 +145,28 @@
|
|
|
116
145
|
height: auto;
|
|
117
146
|
}
|
|
118
147
|
.ui-console.is-stacked .ui-console-top {
|
|
119
|
-
flex-wrap: wrap;
|
|
120
148
|
padding: var(--space-3) var(--space-4);
|
|
121
149
|
}
|
|
150
|
+
.ui-console.is-stacked .ui-console-start {
|
|
151
|
+
margin-right: auto;
|
|
152
|
+
}
|
|
122
153
|
.ui-console.is-stacked .ui-console-end {
|
|
123
|
-
|
|
124
|
-
row-gap: var(--space-2);
|
|
154
|
+
display: contents;
|
|
125
155
|
}
|
|
126
156
|
.ui-console.is-stacked .ui-console-kpis {
|
|
127
157
|
order: 1;
|
|
158
|
+
display: grid;
|
|
159
|
+
grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr));
|
|
160
|
+
gap: var(--space-2) var(--space-4);
|
|
128
161
|
width: 100%;
|
|
129
|
-
overflow-x: auto;
|
|
130
162
|
}
|
|
131
163
|
.ui-console.is-stacked .ui-console-main {
|
|
132
164
|
min-height: 320px;
|
|
133
165
|
}
|
|
166
|
+
.ui-console-cards {
|
|
167
|
+
display: grid;
|
|
168
|
+
grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
|
|
169
|
+
align-items: start;
|
|
170
|
+
gap: 12px;
|
|
171
|
+
}
|
|
134
172
|
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
@layer theme, base, ui, components, utilities;
|
|
2
|
+
@layer ui.tokens, ui.components;
|
|
3
|
+
@import './IconButton.css';
|
|
4
|
+
@layer ui.components {
|
|
5
|
+
/* FloorPlan: zones with any outline in an SVG, labels as HTML on top (the same size at every zoom). Fills, the 4 px
|
|
6
|
+
attention border, the forecast stripes, the selection outline (ink, 2 px, 4 px outside) and the label type follow
|
|
7
|
+
ZoneMap. */
|
|
8
|
+
.ui-floorplan {
|
|
9
|
+
/* The containing block of the visually hidden hint: without it the hint escapes a scrolling card and makes the page
|
|
10
|
+
scroll. */
|
|
11
|
+
position: relative;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: var(--space-3);
|
|
15
|
+
min-width: 0;
|
|
16
|
+
}
|
|
17
|
+
.ui-floorplan.is-fill {
|
|
18
|
+
flex: 1 1 auto;
|
|
19
|
+
min-height: 0;
|
|
20
|
+
}
|
|
21
|
+
.ui-fp-box {
|
|
22
|
+
position: relative;
|
|
23
|
+
width: 100%;
|
|
24
|
+
min-height: 240px;
|
|
25
|
+
max-height: 640px;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
border-radius: var(--radius-md);
|
|
28
|
+
}
|
|
29
|
+
.ui-floorplan.is-fill .ui-fp-box {
|
|
30
|
+
flex: 1 1 auto;
|
|
31
|
+
max-height: none;
|
|
32
|
+
}
|
|
33
|
+
.ui-fp-svg {
|
|
34
|
+
position: absolute;
|
|
35
|
+
inset: 0;
|
|
36
|
+
display: block;
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
touch-action: none;
|
|
40
|
+
-webkit-user-select: none;
|
|
41
|
+
user-select: none;
|
|
42
|
+
}
|
|
43
|
+
.ui-fp-shell {
|
|
44
|
+
fill: var(--surface-sub);
|
|
45
|
+
stroke: var(--line-strong);
|
|
46
|
+
stroke-width: 1.5px;
|
|
47
|
+
vector-effect: non-scaling-stroke;
|
|
48
|
+
}
|
|
49
|
+
.ui-fp-zone {
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
outline: none;
|
|
52
|
+
}
|
|
53
|
+
.ui-fp-fill {
|
|
54
|
+
stroke: var(--surface);
|
|
55
|
+
stroke-width: 1.5px;
|
|
56
|
+
stroke-linejoin: round;
|
|
57
|
+
vector-effect: non-scaling-stroke;
|
|
58
|
+
}
|
|
59
|
+
.ui-fp-zone.is-warning .ui-fp-tone {
|
|
60
|
+
stroke: var(--warning);
|
|
61
|
+
}
|
|
62
|
+
.ui-fp-zone.is-danger .ui-fp-tone {
|
|
63
|
+
stroke: var(--danger);
|
|
64
|
+
}
|
|
65
|
+
.ui-fp-stripe {
|
|
66
|
+
fill: var(--forecast-stripe);
|
|
67
|
+
}
|
|
68
|
+
.ui-fp-empty {
|
|
69
|
+
fill: transparent;
|
|
70
|
+
stroke: var(--line-strong);
|
|
71
|
+
stroke-width: 1px;
|
|
72
|
+
stroke-dasharray: 4 3;
|
|
73
|
+
vector-effect: non-scaling-stroke;
|
|
74
|
+
}
|
|
75
|
+
.ui-fp-edge {
|
|
76
|
+
fill: none;
|
|
77
|
+
stroke: var(--ink-muted);
|
|
78
|
+
stroke-width: 1.5px;
|
|
79
|
+
stroke-dasharray: 5 4;
|
|
80
|
+
vector-effect: non-scaling-stroke;
|
|
81
|
+
pointer-events: none;
|
|
82
|
+
}
|
|
83
|
+
.ui-fp-group {
|
|
84
|
+
fill: var(--ink-muted);
|
|
85
|
+
pointer-events: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Labels: centred on the zone's label point, sized by FloorPlan (width and height set inline). */
|
|
89
|
+
.ui-fp-labels {
|
|
90
|
+
position: absolute;
|
|
91
|
+
inset: 0;
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
}
|
|
94
|
+
.ui-fp-labels > * {
|
|
95
|
+
position: absolute;
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
}
|
|
100
|
+
.ui-fp-label {
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
color: var(--ink);
|
|
106
|
+
text-align: center;
|
|
107
|
+
}
|
|
108
|
+
.ui-fp-name {
|
|
109
|
+
max-width: 100%;
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
text-overflow: ellipsis;
|
|
112
|
+
font-size: var(--text-body);
|
|
113
|
+
font-weight: 600;
|
|
114
|
+
line-height: 22px;
|
|
115
|
+
}
|
|
116
|
+
.ui-fp-value {
|
|
117
|
+
font-family: var(--font-mono);
|
|
118
|
+
font-size: var(--text-h3);
|
|
119
|
+
font-weight: 700;
|
|
120
|
+
line-height: 32px;
|
|
121
|
+
font-variant-numeric: tabular-nums;
|
|
122
|
+
}
|
|
123
|
+
.ui-fp-unit {
|
|
124
|
+
font-family: var(--font-sans);
|
|
125
|
+
font-size: var(--text-body);
|
|
126
|
+
font-weight: 500;
|
|
127
|
+
}
|
|
128
|
+
.ui-fp-state {
|
|
129
|
+
font-size: var(--text-small);
|
|
130
|
+
font-weight: 600;
|
|
131
|
+
line-height: 20px;
|
|
132
|
+
}
|
|
133
|
+
.ui-fp-label.is-muted .ui-fp-name {
|
|
134
|
+
font-size: var(--text-small);
|
|
135
|
+
line-height: 20px;
|
|
136
|
+
}
|
|
137
|
+
.ui-fp-label.is-muted .ui-fp-value {
|
|
138
|
+
font-size: var(--text-body);
|
|
139
|
+
line-height: 22px;
|
|
140
|
+
}
|
|
141
|
+
.ui-fp-label.is-muted .ui-fp-unit {
|
|
142
|
+
font-size: var(--text-small);
|
|
143
|
+
}
|
|
144
|
+
.ui-fp-label.is-empty .ui-fp-state {
|
|
145
|
+
color: var(--ink-muted);
|
|
146
|
+
font-weight: 400;
|
|
147
|
+
}
|
|
148
|
+
/* One line on a pill of its own ground: slender zones, and zones too small for the full label. */
|
|
149
|
+
.ui-fp-pill {
|
|
150
|
+
padding: 0 8px;
|
|
151
|
+
border: 1px solid var(--line-strong);
|
|
152
|
+
border-radius: var(--radius-full);
|
|
153
|
+
background: var(--surface);
|
|
154
|
+
color: var(--ink);
|
|
155
|
+
font-size: var(--text-small);
|
|
156
|
+
font-weight: 600;
|
|
157
|
+
line-height: 22px;
|
|
158
|
+
text-align: center;
|
|
159
|
+
}
|
|
160
|
+
.ui-fp-pill.is-empty {
|
|
161
|
+
color: var(--ink-muted);
|
|
162
|
+
}
|
|
163
|
+
.ui-fp-num {
|
|
164
|
+
font-family: var(--font-mono);
|
|
165
|
+
font-variant-numeric: tabular-nums;
|
|
166
|
+
}
|
|
167
|
+
.ui-fp-group-name {
|
|
168
|
+
padding: 0 6px;
|
|
169
|
+
border-radius: var(--radius-xs);
|
|
170
|
+
background: var(--surface);
|
|
171
|
+
color: var(--ink-muted);
|
|
172
|
+
font-size: var(--text-small);
|
|
173
|
+
font-weight: 600;
|
|
174
|
+
line-height: 22px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* Tooltip: the look of Tooltip, beside the pointer (or the label point, for keyboard focus). */
|
|
178
|
+
.ui-fp-tip {
|
|
179
|
+
position: absolute;
|
|
180
|
+
z-index: var(--z-raised);
|
|
181
|
+
display: flex;
|
|
182
|
+
flex-direction: column;
|
|
183
|
+
max-width: 240px;
|
|
184
|
+
padding: 6px 10px;
|
|
185
|
+
border-radius: var(--radius-chip);
|
|
186
|
+
background: var(--ink);
|
|
187
|
+
color: var(--bg);
|
|
188
|
+
font-size: var(--text-small);
|
|
189
|
+
line-height: 20px;
|
|
190
|
+
pointer-events: none;
|
|
191
|
+
}
|
|
192
|
+
.ui-fp-tip-name {
|
|
193
|
+
font-weight: 600;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.ui-fp-controls {
|
|
197
|
+
position: absolute;
|
|
198
|
+
right: var(--space-2);
|
|
199
|
+
bottom: var(--space-2);
|
|
200
|
+
display: flex;
|
|
201
|
+
gap: var(--space-1);
|
|
202
|
+
}
|
|
203
|
+
.ui-fp-controls > * {
|
|
204
|
+
background: var(--surface);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* Legend: the heat scale with its ends, the watch and limit marks, and a note when there are muted zones. */
|
|
208
|
+
.ui-fp-legend {
|
|
209
|
+
display: flex;
|
|
210
|
+
flex-wrap: wrap;
|
|
211
|
+
align-items: center;
|
|
212
|
+
gap: var(--space-2) var(--space-4);
|
|
213
|
+
color: var(--ink-muted);
|
|
214
|
+
font-size: var(--text-small);
|
|
215
|
+
line-height: 20px;
|
|
216
|
+
}
|
|
217
|
+
.ui-fp-scale {
|
|
218
|
+
display: inline-flex;
|
|
219
|
+
align-items: center;
|
|
220
|
+
gap: var(--space-2);
|
|
221
|
+
}
|
|
222
|
+
.ui-fp-bar {
|
|
223
|
+
position: relative;
|
|
224
|
+
display: inline-flex;
|
|
225
|
+
width: 168px;
|
|
226
|
+
height: 12px;
|
|
227
|
+
border-radius: var(--radius-xs);
|
|
228
|
+
}
|
|
229
|
+
.ui-fp-bar > span:not(.ui-fp-tick) {
|
|
230
|
+
flex: 1;
|
|
231
|
+
}
|
|
232
|
+
.ui-fp-bar > span:first-child {
|
|
233
|
+
border-radius: var(--radius-xs) 0 0 var(--radius-xs);
|
|
234
|
+
}
|
|
235
|
+
.ui-fp-bar > span:nth-child(7) {
|
|
236
|
+
border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
|
|
237
|
+
}
|
|
238
|
+
.ui-fp-tick {
|
|
239
|
+
position: absolute;
|
|
240
|
+
top: -4px;
|
|
241
|
+
width: 2px;
|
|
242
|
+
height: 20px;
|
|
243
|
+
margin-left: -1px;
|
|
244
|
+
}
|
|
245
|
+
.ui-fp-tick.is-warning,
|
|
246
|
+
.ui-fp-key.is-warning::before {
|
|
247
|
+
background: var(--warning);
|
|
248
|
+
}
|
|
249
|
+
.ui-fp-tick.is-danger,
|
|
250
|
+
.ui-fp-key.is-danger::before {
|
|
251
|
+
background: var(--danger);
|
|
252
|
+
}
|
|
253
|
+
.ui-fp-key {
|
|
254
|
+
display: inline-flex;
|
|
255
|
+
align-items: center;
|
|
256
|
+
gap: 6px;
|
|
257
|
+
}
|
|
258
|
+
.ui-fp-key::before {
|
|
259
|
+
content: '';
|
|
260
|
+
width: 2px;
|
|
261
|
+
height: 14px;
|
|
262
|
+
}
|
|
263
|
+
.ui-fp-key.is-muted::before {
|
|
264
|
+
width: 14px;
|
|
265
|
+
border-radius: 3px;
|
|
266
|
+
background: color-mix(in srgb, var(--heat-4) 40%, var(--surface));
|
|
267
|
+
box-shadow: inset 0 0 0 1px var(--line);
|
|
268
|
+
}
|
|
269
|
+
.ui-fp-pill .ui-fp-unit {
|
|
270
|
+
font-size: inherit;
|
|
271
|
+
font-weight: inherit;
|
|
272
|
+
}
|
|
273
|
+
}
|
package/dist/css/KpiCard.css
CHANGED
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
as its content. */
|
|
115
115
|
.ui-console-kpis > .ui-kpi {
|
|
116
116
|
flex: 1 1 0;
|
|
117
|
+
/* At least as wide as its content; the row wraps (the top bar's next line) when they do not all fit. */
|
|
117
118
|
min-width: max-content;
|
|
118
119
|
padding: 6px var(--space-4);
|
|
119
120
|
border-radius: 0;
|
|
@@ -124,11 +125,11 @@
|
|
|
124
125
|
.ui-console-kpis > .ui-kpi:last-child {
|
|
125
126
|
border-right: 1px solid var(--line);
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
+
/* Stacked, the KPIs are a grid under the title line: no lines between them, each starting at its column's edge. */
|
|
129
|
+
.ui-console.is-stacked .ui-console-kpis > .ui-kpi {
|
|
130
|
+
min-width: 0;
|
|
131
|
+
padding: 0;
|
|
128
132
|
border-left: 0;
|
|
129
|
-
padding-left: 0;
|
|
130
|
-
}
|
|
131
|
-
.ui-console.is-stacked .ui-console-kpis > .ui-kpi:last-child {
|
|
132
133
|
border-right: 0;
|
|
133
134
|
}
|
|
134
135
|
}
|