@cboxdk/cbox-ui 0.10.1 → 0.10.3
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 +17 -5
- 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 +11 -2
- package/dist/index.js +42 -17
- package/dist/index.js.map +1 -1
- package/dist/scale-CYX7qlwJ.d.ts +55 -0
- package/package.json +1 -1
- package/tokens/shell.css +6 -0
- 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/tokens/shell.css
CHANGED
|
@@ -82,6 +82,12 @@
|
|
|
82
82
|
.cbx-rail-link.is-active .cbx-rail-label { color: var(--sidebar-foreground); font-weight: 600; }
|
|
83
83
|
.cbx-rail-label { opacity: 0; font-size: 13.5px; transition: opacity 150ms var(--cbx-ease); }
|
|
84
84
|
.cbx-rail[data-open='true'] .cbx-rail-label { opacity: 1; }
|
|
85
|
+
/* An area whose pages are all locked: a lock badge on the icon while collapsed, after the label when open. */
|
|
86
|
+
.cbx-rail-icon { position: relative; display: inline-flex; flex: none; }
|
|
87
|
+
.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); }
|
|
88
|
+
.cbx-rail[data-open='true'] .cbx-rail-lock { opacity: 0; }
|
|
89
|
+
.cbx-rail-lock-open { margin-left: auto; color: var(--muted-foreground); opacity: 0; transition: opacity 150ms var(--cbx-ease); }
|
|
90
|
+
.cbx-rail[data-open='true'] .cbx-rail-lock-open { opacity: 1; }
|
|
85
91
|
.cbx-rail-foot { flex: none; padding-top: 6px; border-top: 1px solid var(--border); }
|
|
86
92
|
.cbx-rail-account { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 3px; border-radius: 10px; white-space: nowrap; }
|
|
87
93
|
.cbx-rail-account:hover, .cbx-rail-account.is-open { background: var(--sidebar-accent); }
|
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,I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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 };
|