@cboxdk/cbox-ui 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -7
- package/dist/charts.d.ts +53 -3
- package/dist/charts.js +142 -4
- package/dist/charts.js.map +1 -1
- package/dist/chunk-QJ4T7RR2.js +113 -0
- package/dist/chunk-QJ4T7RR2.js.map +1 -0
- package/dist/engine-J67R3KY5.js +10 -0
- package/dist/engine-J67R3KY5.js.map +1 -0
- package/dist/index.d.ts +31 -7
- package/dist/index.js +87 -39
- package/dist/index.js.map +1 -1
- package/dist/scale-CYX7qlwJ.d.ts +55 -0
- package/package.json +1 -1
- package/tailwind.preset.js +4 -0
- package/tokens/cbox.css +17 -0
- package/tokens/shell.css +16 -8
- package/dist/chunk-OFTNLF7H.js +0 -55
- package/dist/chunk-OFTNLF7H.js.map +0 -1
- package/dist/engine-4DRZ3POZ.js +0 -10
- package/dist/engine-4DRZ3POZ.js.map +0 -1
- package/dist/scale-BaaY5qJs.d.ts +0 -24
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic under the Cbox charts (first written for Cbox Telemetry): round value
|
|
3
|
+
* ticks from zero, and time ticks on whole minutes, hours or days.
|
|
4
|
+
*/
|
|
5
|
+
/** 0 and round steps up to at least `max`: 0, 250, 500, 750, 1000. */
|
|
6
|
+
declare function niceTicks(max: number, count?: number): number[];
|
|
7
|
+
/** Ticks (milliseconds) on whole minutes, hours or days, about one per 84 px of plot. */
|
|
8
|
+
declare function timeTicks(from: number, to: number, width: number): number[];
|
|
9
|
+
/** A sample at `t` milliseconds since the epoch. */
|
|
10
|
+
type TimePoint = {
|
|
11
|
+
t: number;
|
|
12
|
+
value: number;
|
|
13
|
+
};
|
|
14
|
+
type SeriesDatum = {
|
|
15
|
+
value: [number, number | null];
|
|
16
|
+
symbolSize?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Runs of samples as ECharts line data: a null between runs keeps missing samples a gap
|
|
20
|
+
* (never interpolated or drawn as zero), and an isolated sample becomes a visible dot.
|
|
21
|
+
*/
|
|
22
|
+
declare function seriesData(segments: TimePoint[][]): SeriesDatum[];
|
|
23
|
+
/**
|
|
24
|
+
* Round ticks covering `min` to `max`, always through zero: `niceTicks(max)` when nothing is
|
|
25
|
+
* negative, mirrored when nothing is positive, else one round step across both sides.
|
|
26
|
+
*/
|
|
27
|
+
declare function niceRange(min: number, max: number, count?: number): number[];
|
|
28
|
+
/** The lowest and highest point the bars reach: per category, the stack's negative and positive sums when stacked. */
|
|
29
|
+
declare function barExtent(series: (number | null)[][], stacked: boolean): [number, number];
|
|
30
|
+
/**
|
|
31
|
+
* One waterfall step. A `total` (start, end) is drawn from zero to `value` and sets the running
|
|
32
|
+
* level; any other step is a signed change from the level the step before ended at.
|
|
33
|
+
*/
|
|
34
|
+
type WaterfallStep = {
|
|
35
|
+
key: string;
|
|
36
|
+
label: string;
|
|
37
|
+
value: number;
|
|
38
|
+
total?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Where each waterfall bar sits: an invisible `base`, a visible `height`, the level it ends at, and its kind. */
|
|
41
|
+
type WaterfallBar = {
|
|
42
|
+
base: number;
|
|
43
|
+
height: number;
|
|
44
|
+
end: number;
|
|
45
|
+
change: number;
|
|
46
|
+
kind: 'total' | 'up' | 'down';
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Waterfall steps as floating bars: each change starts where the step before ended. Drawn as a
|
|
50
|
+
* stacked base and rise, so the running level is expected to stay at or above zero (MRR,
|
|
51
|
+
* revenue, a balance); below zero a bar is drawn from zero.
|
|
52
|
+
*/
|
|
53
|
+
declare function waterfallBars(steps: WaterfallStep[]): WaterfallBar[];
|
|
54
|
+
|
|
55
|
+
export { type SeriesDatum as S, type TimePoint as T, type WaterfallStep as W, type WaterfallBar as a, barExtent as b, niceRange as c, niceTicks as n, seriesData as s, timeTicks as t, waterfallBars as w };
|
package/package.json
CHANGED
package/tailwind.preset.js
CHANGED
|
@@ -65,20 +65,24 @@ module.exports = {
|
|
|
65
65
|
DEFAULT: 'var(--success)',
|
|
66
66
|
foreground: 'var(--success-foreground)',
|
|
67
67
|
soft: 'var(--success-soft)',
|
|
68
|
+
text: 'var(--success-text)',
|
|
68
69
|
},
|
|
69
70
|
warning: {
|
|
70
71
|
DEFAULT: 'var(--warning)',
|
|
71
72
|
foreground: 'var(--warning-foreground)',
|
|
72
73
|
soft: 'var(--warning-soft)',
|
|
74
|
+
text: 'var(--warning-text)',
|
|
73
75
|
},
|
|
74
76
|
info: {
|
|
75
77
|
DEFAULT: 'var(--info)',
|
|
76
78
|
soft: 'var(--info-soft)',
|
|
79
|
+
text: 'var(--info-text)',
|
|
77
80
|
},
|
|
78
81
|
destructive: {
|
|
79
82
|
DEFAULT: 'var(--destructive)',
|
|
80
83
|
foreground: 'var(--destructive-foreground)',
|
|
81
84
|
soft: 'var(--destructive-soft)',
|
|
85
|
+
text: 'var(--destructive-text)',
|
|
82
86
|
},
|
|
83
87
|
border: 'var(--border)',
|
|
84
88
|
input: 'var(--input)',
|
package/tokens/cbox.css
CHANGED
|
@@ -41,6 +41,13 @@
|
|
|
41
41
|
--info: oklch(0.62 0.16 230);
|
|
42
42
|
--info-soft: oklch(0.62 0.16 230 / 0.12);
|
|
43
43
|
|
|
44
|
+
/* Tone text: words and icons in a tone on its soft tint, a card or the canvas. The fills
|
|
45
|
+
* above are too light for small text; these reach 4.5:1 (WCAG AA) on all three. */
|
|
46
|
+
--success-text: oklch(0.48 0.13 145);
|
|
47
|
+
--info-text: oklch(0.48 0.13 230);
|
|
48
|
+
--warning-text: oklch(0.48 0.11 65);
|
|
49
|
+
--destructive-text: oklch(0.50 0.19 25);
|
|
50
|
+
|
|
44
51
|
--destructive: oklch(0.58 0.21 25);
|
|
45
52
|
--destructive-foreground: oklch(0.99 0.003 247);
|
|
46
53
|
--destructive-soft: oklch(0.58 0.21 25 / 0.12);
|
|
@@ -108,6 +115,11 @@
|
|
|
108
115
|
--info: oklch(0.7 0.16 230);
|
|
109
116
|
--info-soft: oklch(0.7 0.16 230 / 0.16);
|
|
110
117
|
|
|
118
|
+
--success-text: oklch(0.74 0.16 145);
|
|
119
|
+
--info-text: oklch(0.7 0.16 230);
|
|
120
|
+
--warning-text: oklch(0.78 0.16 70);
|
|
121
|
+
--destructive-text: oklch(0.76 0.15 25);
|
|
122
|
+
|
|
111
123
|
--destructive: oklch(0.68 0.21 25);
|
|
112
124
|
--destructive-foreground: oklch(0.16 0.01 250);
|
|
113
125
|
--destructive-soft: oklch(0.68 0.21 25 / 0.16);
|
|
@@ -190,6 +202,11 @@
|
|
|
190
202
|
--color-destructive-foreground: var(--destructive-foreground);
|
|
191
203
|
--color-destructive-soft: var(--destructive-soft);
|
|
192
204
|
|
|
205
|
+
--color-success-text: var(--success-text);
|
|
206
|
+
--color-info-text: var(--info-text);
|
|
207
|
+
--color-warning-text: var(--warning-text);
|
|
208
|
+
--color-destructive-text: var(--destructive-text);
|
|
209
|
+
|
|
193
210
|
--color-border: var(--border);
|
|
194
211
|
--color-border-strong: var(--border-strong);
|
|
195
212
|
--color-input: var(--input);
|
package/tokens/shell.css
CHANGED
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
--cbx-font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
15
15
|
--cbx-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
16
16
|
--cbx-font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
|
|
17
|
+
/* The document scrolls, not a box inside the shell: Inertia resets the scroll on a new page and
|
|
18
|
+
* restores it on back and forward, and a full-page screenshot shows the whole page. The rail,
|
|
19
|
+
* the header, the subnav and docked Help stay in view with `position: sticky`. */
|
|
17
20
|
display: flex;
|
|
18
|
-
height: 100svh;
|
|
19
|
-
overflow: hidden;
|
|
21
|
+
min-height: 100svh;
|
|
20
22
|
font-family: var(--cbx-font-sans);
|
|
21
23
|
font-size: 14px;
|
|
22
24
|
line-height: 1.45;
|
|
@@ -53,7 +55,7 @@
|
|
|
53
55
|
.cbx-icon-button:hover { background: var(--secondary); color: var(--foreground); }
|
|
54
56
|
|
|
55
57
|
/* ── Rail (tier 1) ───────────────────────────────────────────────────────────── */
|
|
56
|
-
.cbx-rail-slot { position:
|
|
58
|
+
.cbx-rail-slot { position: sticky; top: 0; align-self: flex-start; height: 100svh; flex: 0 0 64px; width: 64px; z-index: 40; transition: flex-basis 300ms var(--cbx-ease), width 300ms var(--cbx-ease); }
|
|
57
59
|
.cbx-rail-slot[data-pinned='true'] { flex-basis: 222px; width: 222px; }
|
|
58
60
|
.cbx-rail { position: absolute; inset: 6px auto 6px 6px; width: 52px; display: flex; flex-direction: column; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--sidebar); color: var(--sidebar-foreground); overflow: hidden; transition: width 200ms var(--cbx-ease), box-shadow 200ms var(--cbx-ease); }
|
|
59
61
|
.cbx-rail[data-open='true'] { width: 210px; }
|
|
@@ -82,6 +84,12 @@
|
|
|
82
84
|
.cbx-rail-link.is-active .cbx-rail-label { color: var(--sidebar-foreground); font-weight: 600; }
|
|
83
85
|
.cbx-rail-label { opacity: 0; font-size: 13.5px; transition: opacity 150ms var(--cbx-ease); }
|
|
84
86
|
.cbx-rail[data-open='true'] .cbx-rail-label { opacity: 1; }
|
|
87
|
+
/* An area whose pages are all locked: a lock badge on the icon while collapsed, after the label when open. */
|
|
88
|
+
.cbx-rail-icon { position: relative; display: inline-flex; flex: none; }
|
|
89
|
+
.cbx-rail-lock { position: absolute; right: -5px; bottom: -4px; display: inline-flex; align-items: center; justify-content: center; width: 13px; height: 13px; border-radius: 999px; background: var(--sidebar, var(--background)); color: var(--muted-foreground); box-shadow: 0 0 0 1px var(--border); transition: opacity 150ms var(--cbx-ease); }
|
|
90
|
+
.cbx-rail[data-open='true'] .cbx-rail-lock { opacity: 0; }
|
|
91
|
+
.cbx-rail-lock-open { margin-left: auto; color: var(--muted-foreground); opacity: 0; transition: opacity 150ms var(--cbx-ease); }
|
|
92
|
+
.cbx-rail[data-open='true'] .cbx-rail-lock-open { opacity: 1; }
|
|
85
93
|
.cbx-rail-foot { flex: none; padding-top: 6px; border-top: 1px solid var(--border); }
|
|
86
94
|
.cbx-rail-account { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 3px; border-radius: 10px; white-space: nowrap; }
|
|
87
95
|
.cbx-rail-account:hover, .cbx-rail-account.is-open { background: var(--sidebar-accent); }
|
|
@@ -94,7 +102,7 @@
|
|
|
94
102
|
|
|
95
103
|
/* ── Column, header, banner ─────────────────────────────────────────────────── */
|
|
96
104
|
.cbx-shell-column { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; }
|
|
97
|
-
.cbx-header { position:
|
|
105
|
+
.cbx-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 56px; flex: none; padding: 0 16px 0 12px; background: var(--background); border-bottom: 1px solid var(--border); }
|
|
98
106
|
.cbx-context { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1 1 auto; }
|
|
99
107
|
.cbx-trigger { display: flex; align-items: center; gap: 8px; height: 32px; min-width: 0; max-width: 360px; padding: 0 6px 0 5px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--foreground); transition: background 150ms var(--cbx-ease); }
|
|
100
108
|
.cbx-trigger:hover, .cbx-trigger.is-open { background: var(--secondary); }
|
|
@@ -129,10 +137,10 @@
|
|
|
129
137
|
.cbx-banner-text { min-width: 0; }
|
|
130
138
|
.cbx-banner-action { margin-left: auto; font-weight: 600; text-decoration: underline; white-space: nowrap; }
|
|
131
139
|
.cbx-shell-body { display: flex; flex: 1; min-height: 0; }
|
|
132
|
-
.cbx-shell-main { flex: 1; min-width: 0;
|
|
140
|
+
.cbx-shell-main { flex: 1; min-width: 0; scroll-margin-top: 56px; }
|
|
133
141
|
|
|
134
142
|
/* ── Subnav (tier 2) ────────────────────────────────────────────────────────── */
|
|
135
|
-
.cbx-subnav { width: 210px; flex: none; overflow-y: auto; padding: 12px 8px; background: var(--background); border-right: 1px solid var(--border); overscroll-behavior: contain; }
|
|
143
|
+
.cbx-subnav { position: sticky; top: 56px; align-self: flex-start; height: calc(100svh - 56px); width: 210px; flex: none; overflow-y: auto; padding: 12px 8px; background: var(--background); border-right: 1px solid var(--border); overscroll-behavior: contain; }
|
|
136
144
|
.cbx-subnav[data-collapsed='true'] { width: 26px; padding: 0; }
|
|
137
145
|
.cbx-subnav-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; padding: 0 4px 0 12px; margin-bottom: 8px; font-size: 13px; }
|
|
138
146
|
.cbx-subnav-list { display: flex; flex-direction: column; gap: 4px; }
|
|
@@ -268,14 +276,14 @@ textarea.cbx-input { height: auto; padding: 10px 12px; resize: vertical; min-hei
|
|
|
268
276
|
.cbx-palette-foot .cbx-kbd + .cbx-kbd { margin-left: 2px; }
|
|
269
277
|
|
|
270
278
|
/* ── Help column (§7) ───────────────────────────────────────────────────────── */
|
|
271
|
-
.cbx-help { display: flex; flex-direction: column; flex: 0 0 360px; width: 360px; min-height: 0; background: var(--background); border-left: 1px solid var(--border); outline: none; }
|
|
279
|
+
.cbx-help { position: sticky; top: 0; align-self: flex-start; height: 100svh; display: flex; flex-direction: column; flex: 0 0 360px; width: 360px; min-height: 0; background: var(--background); border-left: 1px solid var(--border); outline: none; }
|
|
272
280
|
.cbx-help[hidden] { display: none; }
|
|
273
281
|
/* Help left open from an earlier visit only shows docked: below 1280px it waits for the person,
|
|
274
282
|
also on the server-rendered first paint, before the client knows the width. */
|
|
275
283
|
@media (max-width: 1279px) { .cbx-help[data-restored="true"] { display: none; } }
|
|
276
284
|
@media (min-width: 1440px) { .cbx-help { flex-basis: 400px; width: 400px; } }
|
|
277
285
|
@media (max-width: 1279px) {
|
|
278
|
-
.cbx-help { position: fixed; inset: 0; z-index: 65; width: auto; border-left: 0; animation: cbx-fade 150ms var(--cbx-ease); }
|
|
286
|
+
.cbx-help { position: fixed; inset: 0; z-index: 65; width: auto; height: auto; align-self: stretch; border-left: 0; animation: cbx-fade 150ms var(--cbx-ease); }
|
|
279
287
|
}
|
|
280
288
|
.cbx-help-head { display: flex; align-items: center; gap: 8px; height: 56px; flex: none; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); }
|
|
281
289
|
.cbx-help-mark { color: var(--primary); flex: none; }
|
package/dist/chunk-OFTNLF7H.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { twMerge } from 'tailwind-merge';
|
|
3
|
-
|
|
4
|
-
// src/utils/cn.ts
|
|
5
|
-
function cn(...inputs) {
|
|
6
|
-
return twMerge(clsx(inputs));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// src/charts/scale.ts
|
|
10
|
-
function niceTicks(max, count = 4) {
|
|
11
|
-
const top = max > 0 && Number.isFinite(max) ? max : 1;
|
|
12
|
-
const raw = top / count;
|
|
13
|
-
const power = 10 ** Math.floor(Math.log10(raw));
|
|
14
|
-
const fraction = raw / power;
|
|
15
|
-
const step = (fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10) * power;
|
|
16
|
-
const ticks = [];
|
|
17
|
-
for (let value = 0; value < top + step * 0.999; value += step) {
|
|
18
|
-
ticks.push(Number(value.toPrecision(12)));
|
|
19
|
-
}
|
|
20
|
-
if (ticks.length < 2) {
|
|
21
|
-
ticks.push(step);
|
|
22
|
-
}
|
|
23
|
-
return ticks;
|
|
24
|
-
}
|
|
25
|
-
var MINUTE = 6e4;
|
|
26
|
-
var STEPS = [1, 2, 5, 10, 15, 30, 60, 120, 180, 360, 720, 1440, 2880, 10080].map((minutes) => minutes * MINUTE);
|
|
27
|
-
function timeTicks(from, to, width) {
|
|
28
|
-
const most = Math.max(2, Math.floor(width / 84));
|
|
29
|
-
const step = STEPS.find((candidate) => (to - from) / candidate <= most) ?? 7 * 1440 * MINUTE;
|
|
30
|
-
const ticks = [];
|
|
31
|
-
for (let tick = Math.ceil(from / step) * step; tick <= to; tick += step) {
|
|
32
|
-
ticks.push(tick);
|
|
33
|
-
}
|
|
34
|
-
return ticks;
|
|
35
|
-
}
|
|
36
|
-
function seriesData(segments) {
|
|
37
|
-
const data = [];
|
|
38
|
-
segments.forEach((segment, index) => {
|
|
39
|
-
const first = segment[0];
|
|
40
|
-
if (!first) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (index > 0) {
|
|
44
|
-
data.push({ value: [first.t - 1, null] });
|
|
45
|
-
}
|
|
46
|
-
for (const point of segment) {
|
|
47
|
-
data.push(segment.length === 1 ? { value: [point.t, point.value], symbolSize: 5 } : { value: [point.t, point.value] });
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return data;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { cn, niceTicks, seriesData, timeTicks };
|
|
54
|
-
//# sourceMappingURL=chunk-OFTNLF7H.js.map
|
|
55
|
-
//# sourceMappingURL=chunk-OFTNLF7H.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/cn.ts","../src/charts/scale.ts"],"names":[],"mappings":";;;;AAGO,SAAS,MAAM,MAAA,EAA8B;AAChD,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC/B;;;ACCO,SAAS,SAAA,CAAU,GAAA,EAAa,KAAA,GAAQ,CAAA,EAAa;AACxD,EAAA,MAAM,MAAM,GAAA,GAAM,CAAA,IAAK,OAAO,QAAA,CAAS,GAAG,IAAI,GAAA,GAAM,CAAA;AACpD,EAAA,MAAM,MAAM,GAAA,GAAM,KAAA;AAClB,EAAA,MAAM,QAAQ,EAAA,IAAM,IAAA,CAAK,MAAM,IAAA,CAAK,KAAA,CAAM,GAAG,CAAC,CAAA;AAC9C,EAAA,MAAM,WAAW,GAAA,GAAM,KAAA;AACvB,EAAA,MAAM,IAAA,GAAA,CAAQ,QAAA,IAAY,CAAA,GAAI,CAAA,GAAI,QAAA,IAAY,CAAA,GAAI,CAAA,GAAI,QAAA,IAAY,GAAA,GAAM,GAAA,GAAM,QAAA,IAAY,CAAA,GAAI,IAAI,EAAA,IAAM,KAAA;AACxG,EAAA,MAAM,QAAkB,EAAC;AAEzB,EAAA,KAAA,IAAS,QAAQ,CAAA,EAAG,KAAA,GAAQ,MAAM,IAAA,GAAO,KAAA,EAAO,SAAS,IAAA,EAAM;AAC3D,IAAA,KAAA,CAAM,KAAK,MAAA,CAAO,KAAA,CAAM,WAAA,CAAY,EAAE,CAAC,CAAC,CAAA;AAAA,EAC5C;AAEA,EAAA,IAAI,KAAA,CAAM,SAAS,CAAA,EAAG;AAClB,IAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,EACnB;AAEA,EAAA,OAAO,KAAA;AACX;AAEA,IAAM,MAAA,GAAS,GAAA;AACf,IAAM,KAAA,GAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,GAAG,EAAA,EAAI,EAAA,EAAI,IAAI,EAAA,EAAI,GAAA,EAAK,KAAK,GAAA,EAAK,GAAA,EAAK,MAAM,IAAA,EAAM,KAAK,EAAE,GAAA,CAAI,CAAC,OAAA,KAAY,OAAA,GAAU,MAAM,CAAA;AAGzG,SAAS,SAAA,CAAU,IAAA,EAAc,EAAA,EAAY,KAAA,EAAyB;AACzE,EAAA,MAAM,IAAA,GAAO,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,KAAA,CAAM,KAAA,GAAQ,EAAE,CAAC,CAAA;AAC/C,EAAA,MAAM,IAAA,GAAO,KAAA,CAAM,IAAA,CAAK,CAAC,SAAA,KAAA,CAAe,EAAA,GAAK,IAAA,IAAQ,SAAA,IAAa,IAAI,CAAA,IAAK,CAAA,GAAI,IAAA,GAAO,MAAA;AACtF,EAAA,MAAM,QAAkB,EAAC;AAEzB,EAAA,KAAA,IAAS,IAAA,GAAO,IAAA,CAAK,IAAA,CAAK,IAAA,GAAO,IAAI,IAAI,IAAA,EAAM,IAAA,IAAQ,EAAA,EAAI,IAAA,IAAQ,IAAA,EAAM;AACrE,IAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,EACnB;AAEA,EAAA,OAAO,KAAA;AACX;AAWO,SAAS,WAAW,QAAA,EAAwC;AAC/D,EAAA,MAAM,OAAsB,EAAC;AAE7B,EAAA,QAAA,CAAS,OAAA,CAAQ,CAAC,OAAA,EAAS,KAAA,KAAU;AACjC,IAAA,MAAM,KAAA,GAAQ,QAAQ,CAAC,CAAA;AAEvB,IAAA,IAAI,CAAC,KAAA,EAAO;AACR,MAAA;AAAA,IACJ;AAEA,IAAA,IAAI,QAAQ,CAAA,EAAG;AACX,MAAA,IAAA,CAAK,IAAA,CAAK,EAAE,KAAA,EAAO,CAAC,MAAM,CAAA,GAAI,CAAA,EAAG,IAAI,CAAA,EAAG,CAAA;AAAA,IAC5C;AAEA,IAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AACzB,MAAA,IAAA,CAAK,IAAA,CAAK,QAAQ,MAAA,KAAW,CAAA,GAAI,EAAE,KAAA,EAAO,CAAC,KAAA,CAAM,CAAA,EAAG,KAAA,CAAM,KAAK,GAAG,UAAA,EAAY,CAAA,EAAE,GAAI,EAAE,KAAA,EAAO,CAAC,MAAM,CAAA,EAAG,KAAA,CAAM,KAAK,CAAA,EAAG,CAAA;AAAA,IACzH;AAAA,EACJ,CAAC,CAAA;AAED,EAAA,OAAO,IAAA;AACX","file":"chunk-OFTNLF7H.js","sourcesContent":["import clsx, { type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(inputs));\n}\n","/**\n * The arithmetic under the Cbox charts (first written for Cbox Telemetry): round value\n * ticks from zero, and time ticks on whole minutes, hours or days.\n */\n\n/** 0 and round steps up to at least `max`: 0, 250, 500, 750, 1000. */\nexport function niceTicks(max: number, count = 4): number[] {\n const top = max > 0 && Number.isFinite(max) ? max : 1;\n const raw = top / count;\n const power = 10 ** Math.floor(Math.log10(raw));\n const fraction = raw / power;\n const step = (fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10) * power;\n const ticks: number[] = [];\n\n for (let value = 0; value < top + step * 0.999; value += step) {\n ticks.push(Number(value.toPrecision(12)));\n }\n\n if (ticks.length < 2) {\n ticks.push(step);\n }\n\n return ticks;\n}\n\nconst MINUTE = 60_000;\nconst STEPS = [1, 2, 5, 10, 15, 30, 60, 120, 180, 360, 720, 1440, 2880, 10080].map((minutes) => minutes * MINUTE);\n\n/** Ticks (milliseconds) on whole minutes, hours or days, about one per 84 px of plot. */\nexport function timeTicks(from: number, to: number, width: number): number[] {\n const most = Math.max(2, Math.floor(width / 84));\n const step = STEPS.find((candidate) => (to - from) / candidate <= most) ?? 7 * 1440 * MINUTE;\n const ticks: number[] = [];\n\n for (let tick = Math.ceil(from / step) * step; tick <= to; tick += step) {\n ticks.push(tick);\n }\n\n return ticks;\n}\n\n/** A sample at `t` milliseconds since the epoch. */\nexport type TimePoint = { t: number; value: number };\n\nexport type SeriesDatum = { value: [number, number | null]; symbolSize?: number };\n\n/**\n * Runs of samples as ECharts line data: a null between runs keeps missing samples a gap\n * (never interpolated or drawn as zero), and an isolated sample becomes a visible dot.\n */\nexport function seriesData(segments: TimePoint[][]): SeriesDatum[] {\n const data: SeriesDatum[] = [];\n\n segments.forEach((segment, index) => {\n const first = segment[0];\n\n if (!first) {\n return;\n }\n\n if (index > 0) {\n data.push({ value: [first.t - 1, null] });\n }\n\n for (const point of segment) {\n data.push(segment.length === 1 ? { value: [point.t, point.value], symbolSize: 5 } : { value: [point.t, point.value] });\n }\n });\n\n return data;\n}\n"]}
|
package/dist/engine-4DRZ3POZ.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LineChart } from 'echarts/charts';
|
|
2
|
-
import { DataZoomComponent, GridComponent, TooltipComponent, MarkLineComponent, AriaComponent } from 'echarts/components';
|
|
3
|
-
import * as echarts from 'echarts/core';
|
|
4
|
-
export { echarts };
|
|
5
|
-
import { SVGRenderer } from 'echarts/renderers';
|
|
6
|
-
|
|
7
|
-
// src/charts/engine.ts
|
|
8
|
-
echarts.use([LineChart, DataZoomComponent, GridComponent, TooltipComponent, MarkLineComponent, AriaComponent, SVGRenderer]);
|
|
9
|
-
//# sourceMappingURL=engine-4DRZ3POZ.js.map
|
|
10
|
-
//# sourceMappingURL=engine-4DRZ3POZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/engine.ts"],"names":[],"mappings":";;;;;;;AAMQ,OAAA,CAAA,GAAA,CAAI,CAAC,WAAW,iBAAA,EAAmB,aAAA,EAAe,kBAAkB,iBAAA,EAAmB,aAAA,EAAe,WAAW,CAAC,CAAA","file":"engine-4DRZ3POZ.js","sourcesContent":["import { LineChart } from 'echarts/charts';\nimport { AriaComponent, DataZoomComponent, GridComponent, MarkLineComponent, TooltipComponent } from 'echarts/components';\nimport * as echarts from 'echarts/core';\nimport { SVGRenderer } from 'echarts/renderers';\n\n/** Only what the Cbox time chart uses; loaded on first mount so pages without charts never pay for it. */\necharts.use([LineChart, DataZoomComponent, GridComponent, TooltipComponent, MarkLineComponent, AriaComponent, SVGRenderer]);\n\nexport { echarts };\n"]}
|
package/dist/scale-BaaY5qJs.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The arithmetic under the Cbox charts (first written for Cbox Telemetry): round value
|
|
3
|
-
* ticks from zero, and time ticks on whole minutes, hours or days.
|
|
4
|
-
*/
|
|
5
|
-
/** 0 and round steps up to at least `max`: 0, 250, 500, 750, 1000. */
|
|
6
|
-
declare function niceTicks(max: number, count?: number): number[];
|
|
7
|
-
/** Ticks (milliseconds) on whole minutes, hours or days, about one per 84 px of plot. */
|
|
8
|
-
declare function timeTicks(from: number, to: number, width: number): number[];
|
|
9
|
-
/** A sample at `t` milliseconds since the epoch. */
|
|
10
|
-
type TimePoint = {
|
|
11
|
-
t: number;
|
|
12
|
-
value: number;
|
|
13
|
-
};
|
|
14
|
-
type SeriesDatum = {
|
|
15
|
-
value: [number, number | null];
|
|
16
|
-
symbolSize?: number;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Runs of samples as ECharts line data: a null between runs keeps missing samples a gap
|
|
20
|
-
* (never interpolated or drawn as zero), and an isolated sample becomes a visible dot.
|
|
21
|
-
*/
|
|
22
|
-
declare function seriesData(segments: TimePoint[][]): SeriesDatum[];
|
|
23
|
-
|
|
24
|
-
export { type SeriesDatum as S, type TimePoint as T, niceTicks as n, seriesData as s, timeTicks as t };
|