@bigpixelrocket/uiok 0.1.3 → 0.2.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/CHANGELOG.md +95 -1
- package/README.md +1 -1
- package/dist/activity/ActivityBar.d.ts +21 -8
- package/dist/activity/ActivityBar.js +15 -5
- package/dist/activity/activity.css +53 -6
- package/dist/button/Button.d.ts +10 -6
- package/dist/button/Button.js +6 -1
- package/dist/button/button.css +201 -33
- package/dist/charts/Line.logic.d.ts +6 -0
- package/dist/charts/Line.logic.js +9 -0
- package/dist/charts/LineChart.js +11 -4
- package/dist/charts/Pie.logic.d.ts +89 -1
- package/dist/charts/Pie.logic.js +272 -2
- package/dist/charts/PieChart.d.ts +2 -1
- package/dist/charts/PieChart.js +12 -5
- package/dist/charts/PieFill.d.ts +15 -0
- package/dist/charts/PieFill.js +33 -0
- package/dist/charts/ResultChart.d.ts +2 -2
- package/dist/charts/ResultChart.js +173 -47
- package/dist/charts/ResultChart.logic.d.ts +60 -4
- package/dist/charts/ResultChart.logic.js +105 -6
- package/dist/charts/Scatter.logic.d.ts +18 -4
- package/dist/charts/Scatter.logic.js +98 -22
- package/dist/charts/ScatterChart.js +19 -5
- package/dist/charts/charts.css +233 -116
- package/dist/charts/seriesColour.d.ts +2 -0
- package/dist/charts/seriesColour.js +1 -1
- package/dist/datetime/DateTimePicker.d.ts +12 -2
- package/dist/datetime/DateTimePicker.js +61 -16
- package/dist/datetime/DateTimePicker.logic.d.ts +29 -0
- package/dist/datetime/DateTimePicker.logic.js +25 -0
- package/dist/datetime/datetime.css +89 -49
- package/dist/dialog/ConfirmDialog.d.ts +69 -20
- package/dist/dialog/ConfirmDialog.js +39 -12
- package/dist/dialog/DialogLayer.d.ts +25 -0
- package/dist/dialog/DialogLayer.js +24 -0
- package/dist/dialog/DialogLegend.d.ts +2 -1
- package/dist/dialog/DialogLegend.js +10 -5
- package/dist/dialog/DialogLegend.logic.d.ts +15 -3
- package/dist/dialog/DialogLegend.logic.js +8 -4
- package/dist/dialog/DialogLists.d.ts +157 -0
- package/dist/dialog/DialogLists.js +137 -0
- package/dist/dialog/ModalDialog.d.ts +20 -15
- package/dist/dialog/ModalDialog.js +22 -7
- package/dist/dialog/dialog.css +570 -127
- package/dist/dialog/index.d.ts +7 -1
- package/dist/dialog/index.js +7 -1
- package/dist/field/Check.d.ts +15 -0
- package/dist/field/Check.js +23 -0
- package/dist/field/field.css +812 -0
- package/dist/field/index.d.ts +10 -0
- package/dist/field/index.js +10 -0
- package/dist/field/labelHelp.d.ts +33 -0
- package/dist/field/labelHelp.js +22 -0
- package/dist/filter/FilterIcon.js +2 -1
- package/dist/filter/filter.css +72 -20
- package/dist/grid/DataGrid.d.ts +8 -1
- package/dist/grid/DataGrid.js +115 -40
- package/dist/grid/DataGrid.logic.d.ts +15 -3
- package/dist/grid/DataGrid.logic.js +18 -5
- package/dist/grid/grid.css +481 -56
- package/dist/icon/Spinner.d.ts +16 -0
- package/dist/icon/Spinner.js +13 -0
- package/dist/icon/index.d.ts +5 -0
- package/dist/icon/index.js +5 -0
- package/dist/icon/sizes.d.ts +19 -0
- package/dist/icon/sizes.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/keychord/KeyChord.d.ts +12 -1
- package/dist/keychord/KeyChord.js +2 -2
- package/dist/keychord/index.d.ts +1 -1
- package/dist/keychord/keychord.css +87 -9
- package/dist/labels/dialog.d.ts +12 -1
- package/dist/labels/dialog.js +3 -1
- package/dist/labels/selectAll.d.ts +4 -4
- package/dist/labels/selectAll.js +1 -1
- package/dist/legend/KeyLegendStrip.js +1 -1
- package/dist/legend/legend.css +82 -57
- package/dist/listing/Listing.d.ts +17 -10
- package/dist/listing/Listing.js +33 -26
- package/dist/listing/listing.css +1665 -237
- package/dist/menu/menu.css +227 -67
- package/dist/menu/useBellBeat.js +2 -2
- package/dist/namecut/NameCut.d.ts +3 -1
- package/dist/namecut/NameCut.js +152 -5
- package/dist/namecut/NameCut.logic.d.ts +5 -3
- package/dist/namecut/NameCut.logic.js +20 -5
- package/dist/namecut/namecut.css +27 -7
- package/dist/pager/Pager.d.ts +12 -4
- package/dist/pager/Pager.js +21 -7
- package/dist/pager/pager.css +41 -30
- package/dist/palette/Palette.js +2 -1
- package/dist/palette/palette.css +121 -60
- package/dist/pane/PaneActions.d.ts +56 -14
- package/dist/pane/PaneActions.js +64 -16
- package/dist/pane/PaneFrame.d.ts +37 -5
- package/dist/pane/PaneFrame.js +246 -11
- package/dist/pane/index.d.ts +4 -2
- package/dist/pane/index.js +4 -2
- package/dist/pane/toolWords.d.ts +14 -0
- package/dist/pane/toolWords.js +26 -0
- package/dist/pane/useToolbarFit.d.ts +25 -0
- package/dist/pane/useToolbarFit.js +95 -0
- package/dist/run/RunHeader.d.ts +5 -3
- package/dist/run/RunHeader.js +11 -8
- package/dist/run/run.css +64 -79
- package/dist/segmented/SegmentedChoice.d.ts +18 -2
- package/dist/segmented/SegmentedChoice.js +18 -7
- package/dist/segmented/segmented.css +62 -22
- package/dist/selectall/SelectAllBar.d.ts +4 -3
- package/dist/selectall/SelectAllBar.js +4 -3
- package/dist/selectall/selectall.css +17 -12
- package/dist/shell/shell.css +1073 -0
- package/dist/styles.css +620 -22
- package/dist/surface/surface.css +154 -0
- package/dist/tabs/PageTabs.d.ts +10 -5
- package/dist/tabs/PageTabs.js +126 -37
- package/dist/tabs/tabs.css +131 -51
- package/dist/terminal/Terminal.js +3 -1
- package/dist/terminal/Terminal.logic.d.ts +5 -4
- package/dist/terminal/Terminal.logic.js +9 -4
- package/dist/terminal/TerminalMenu.d.ts +4 -1
- package/dist/terminal/TerminalMenu.js +12 -5
- package/dist/terminal/ghostty/contrast.logic.d.ts +45 -0
- package/dist/terminal/ghostty/contrast.logic.js +130 -0
- package/dist/terminal/ghostty/core.d.ts +6 -0
- package/dist/terminal/ghostty/renderer.d.ts +9 -2
- package/dist/terminal/ghostty/renderer.js +91 -14
- package/dist/terminal/ghostty/surface.d.ts +8 -0
- package/dist/terminal/ghostty/surface.js +27 -1
- package/dist/terminal/terminal.css +87 -61
- package/dist/text/text.css +16 -7
- package/dist/themes/catalog.js +4 -3
- package/dist/themes/themes.generated.css +1307 -264
- package/dist/themes/tokens.d.ts +69 -14
- package/dist/themes/tokens.js +920 -97
- package/dist/tokens.css +239 -0
- package/dist/tooltip/Tooltip.d.ts +6 -0
- package/dist/tooltip/Tooltip.js +48 -6
- package/dist/tooltip/Tooltip.logic.d.ts +89 -12
- package/dist/tooltip/Tooltip.logic.js +142 -20
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +1 -1
- package/dist/tooltip/tooltip.css +39 -9
- package/package.json +9 -3
|
@@ -40,24 +40,69 @@ const niceStep = (span, count) => {
|
|
|
40
40
|
const fraction = raw / power;
|
|
41
41
|
return (fraction < 1.5 ? 1 : fraction < 3 ? 2 : fraction < 7 ? 5 : 10) * power;
|
|
42
42
|
};
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Time steps a time axis may tick on, in milliseconds: round seconds,
|
|
45
|
+
* minutes, hours, days, weeks, months, and years, close enough together
|
|
46
|
+
* that some step always gives a few ticks.
|
|
47
|
+
*/
|
|
44
48
|
const TIME_STEPS = [
|
|
45
49
|
1000,
|
|
50
|
+
2000,
|
|
51
|
+
5000,
|
|
52
|
+
10_000,
|
|
53
|
+
15_000,
|
|
54
|
+
30_000,
|
|
46
55
|
60_000,
|
|
47
|
-
|
|
56
|
+
2 * 60_000,
|
|
57
|
+
5 * 60_000,
|
|
58
|
+
10 * 60_000,
|
|
59
|
+
15 * 60_000,
|
|
60
|
+
30 * 60_000,
|
|
48
61
|
3_600_000,
|
|
62
|
+
2 * 3_600_000,
|
|
63
|
+
3 * 3_600_000,
|
|
49
64
|
6 * 3_600_000,
|
|
65
|
+
12 * 3_600_000,
|
|
50
66
|
86_400_000,
|
|
67
|
+
2 * 86_400_000,
|
|
51
68
|
7 * 86_400_000,
|
|
69
|
+
14 * 86_400_000,
|
|
52
70
|
30 * 86_400_000,
|
|
71
|
+
91 * 86_400_000,
|
|
72
|
+
182 * 86_400_000,
|
|
53
73
|
365 * 86_400_000
|
|
54
74
|
];
|
|
75
|
+
/** The fewest ticks a number or time axis shows where its span allows. */
|
|
76
|
+
const FEWEST_TICKS = 3;
|
|
77
|
+
/** The ticks of a number or time axis over `domain` at about `count` of them. */
|
|
78
|
+
function stepTicks(domain, kind, count) {
|
|
79
|
+
const span = domain.max - domain.min;
|
|
80
|
+
const step = kind === 'time'
|
|
81
|
+
? (TIME_STEPS.find((candidate) => span / candidate <= count) ?? niceStep(span, count))
|
|
82
|
+
: niceStep(span, count);
|
|
83
|
+
const ticks = [];
|
|
84
|
+
const first = Math.ceil(domain.min / step);
|
|
85
|
+
// A step is at least two thirds of `span / count`, so at most 1.5 × count + 1 ticks fit;
|
|
86
|
+
// the bound only stops a step too fine to move a double.
|
|
87
|
+
for (let index = 0; index <= 3 * count + 2; index += 1) {
|
|
88
|
+
const at = (first + index) * step;
|
|
89
|
+
if (at > domain.max)
|
|
90
|
+
break;
|
|
91
|
+
// Round away the float error a multiple of the step carries.
|
|
92
|
+
const tick = Number(at.toPrecision(12));
|
|
93
|
+
if (tick !== ticks.at(-1))
|
|
94
|
+
ticks.push(tick);
|
|
95
|
+
}
|
|
96
|
+
return ticks;
|
|
97
|
+
}
|
|
55
98
|
/**
|
|
56
99
|
* The ticks of an axis over `domain`, about `count` of them: round numbers;
|
|
57
100
|
* round times; or each category in the domain, every few where there are
|
|
58
|
-
* more than `count`.
|
|
59
|
-
*
|
|
60
|
-
*
|
|
101
|
+
* more than `count`. A number or time axis shows at least three where a
|
|
102
|
+
* round step allows, however few `count` asks for, so its span can be read.
|
|
103
|
+
* Each tick is counted from the first, never added up, and a step finer
|
|
104
|
+
* than a double can tell apart at the domain's values (an integer past
|
|
105
|
+
* 2^53, a deep zoom) gives no repeats, so the ticks stay few.
|
|
61
106
|
*/
|
|
62
107
|
export function ticksOf(domain, kind, count = 5) {
|
|
63
108
|
const span = domain.max - domain.min;
|
|
@@ -72,31 +117,42 @@ export function ticksOf(domain, kind, count = 5) {
|
|
|
72
117
|
ticks.push(at);
|
|
73
118
|
return ticks;
|
|
74
119
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// the bound only stops a step too fine to move a double.
|
|
82
|
-
for (let index = 0; index <= 3 * count + 2; index += 1) {
|
|
83
|
-
const at = (first + index) * step;
|
|
84
|
-
if (at > domain.max)
|
|
85
|
-
break;
|
|
86
|
-
// Round away the float error a multiple of the step carries.
|
|
87
|
-
const tick = Number(at.toPrecision(12));
|
|
88
|
-
if (tick !== ticks.at(-1))
|
|
89
|
-
ticks.push(tick);
|
|
120
|
+
let ticks = stepTicks(domain, kind, count);
|
|
121
|
+
// Ask for one more at a time until a round step gives enough, a few tries at most.
|
|
122
|
+
for (let more = count + 1; ticks.length < FEWEST_TICKS && more <= count + 4; more += 1) {
|
|
123
|
+
const finer = stepTicks(domain, kind, more);
|
|
124
|
+
if (finer.length > ticks.length)
|
|
125
|
+
ticks = finer;
|
|
90
126
|
}
|
|
91
127
|
return ticks;
|
|
92
128
|
}
|
|
93
129
|
const pad = (value) => String(value).padStart(2, '0');
|
|
94
|
-
/**
|
|
130
|
+
/** Numbers from a million up are written short ("1.7936T"), at most this many digits long. */
|
|
131
|
+
const LONG_NUMBER = 1_000_000;
|
|
132
|
+
/**
|
|
133
|
+
* A number on an axis over `domain`: as it is below a million; from a
|
|
134
|
+
* million up in the short form ("2.5M", "1.7936T") with as many significant
|
|
135
|
+
* digits as a tenth of the span needs, so neighbouring ticks still differ.
|
|
136
|
+
*/
|
|
137
|
+
function numberLabel(value, domain) {
|
|
138
|
+
if (Math.abs(value) < LONG_NUMBER)
|
|
139
|
+
return String(value);
|
|
140
|
+
const step = (domain.max - domain.min) / 10;
|
|
141
|
+
const digits = Math.ceil(Math.log10(Math.abs(value))) - Math.floor(Math.log10(step || 1));
|
|
142
|
+
return new Intl.NumberFormat('en-US', {
|
|
143
|
+
notation: 'compact',
|
|
144
|
+
maximumSignificantDigits: Math.min(21, Math.max(2, digits))
|
|
145
|
+
}).format(value);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A tick's label: the number (from a million up in the short form,
|
|
149
|
+
* "1.7936T"), the date or the time of day in UTC, or the category.
|
|
150
|
+
*/
|
|
95
151
|
export function tickLabel(value, axis, domain) {
|
|
96
152
|
if (axis.kind === 'category')
|
|
97
153
|
return axis.categories?.[Math.round(value)] ?? '';
|
|
98
154
|
if (axis.kind === 'number')
|
|
99
|
-
return
|
|
155
|
+
return numberLabel(value, domain);
|
|
100
156
|
if (axis.timeOfDay === true) {
|
|
101
157
|
const seconds = Math.round(value / 1000);
|
|
102
158
|
const sign = seconds < 0 ? '-' : '';
|
|
@@ -109,6 +165,26 @@ export function tickLabel(value, axis, domain) {
|
|
|
109
165
|
? day
|
|
110
166
|
: `${day} ${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}`;
|
|
111
167
|
}
|
|
168
|
+
/** An offset from an axis's first tick, short and signed ("+100M", "+2.5K"). */
|
|
169
|
+
const offsetLabel = (offset) => `+${new Intl.NumberFormat('en-US', { notation: 'compact', maximumSignificantDigits: 3 }).format(offset)}`;
|
|
170
|
+
/**
|
|
171
|
+
* The labels of an axis's ticks, in order. A number axis whose ticks lie
|
|
172
|
+
* so close together for their size that their short forms would differ
|
|
173
|
+
* only past the fourth digit ("1.7936T", "1.7937T") labels the first tick
|
|
174
|
+
* in full and each other by how far past it it lies ("+100M"), so the
|
|
175
|
+
* steps read at a glance. Any other axis labels each tick on its own
|
|
176
|
+
* (`tickLabel`).
|
|
177
|
+
*/
|
|
178
|
+
export function tickLabels(ticks, axis, domain) {
|
|
179
|
+
const [first, second] = ticks;
|
|
180
|
+
if (axis.kind === 'number' && first !== undefined && second !== undefined) {
|
|
181
|
+
const largest = Math.max(...ticks.map((tick) => Math.abs(tick)));
|
|
182
|
+
if (largest >= LONG_NUMBER && second - first < largest / 1000) {
|
|
183
|
+
return ticks.map((tick, at) => at === 0 ? numberLabel(tick, domain) : offsetLabel(tick - first));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return ticks.map((tick) => tickLabel(tick, axis, domain));
|
|
187
|
+
}
|
|
112
188
|
/**
|
|
113
189
|
* The domains a rectangle dragged from one pixel to another zooms to, in a
|
|
114
190
|
* plot of `width` by `height` (y grows upward), or null for a rectangle too
|
|
@@ -2,10 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { RotateCcw } from 'lucide-react';
|
|
3
3
|
import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
4
4
|
import { Button } from '../button/Button.js';
|
|
5
|
+
import { ICON_SM } from '../icon/index.js';
|
|
5
6
|
import { useLabels } from '../labels/UiokProvider.js';
|
|
6
7
|
import { createValueStore } from '../store/ValueStore.js';
|
|
7
8
|
import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
8
|
-
import { domainOf, scaled,
|
|
9
|
+
import { domainOf, scaled, tickLabels, ticksOf, zoomedTo } from './Scatter.logic.js';
|
|
9
10
|
/** The room the axes' ticks and titles take around the plot. */
|
|
10
11
|
const MARGIN = { top: 10, right: 14, bottom: 40, left: 64 };
|
|
11
12
|
/** The size the chart starts at, before the frame reports its own. */
|
|
@@ -57,10 +58,15 @@ export function ScatterChart({ label, points, x, y, picked = null, onPick }) {
|
|
|
57
58
|
};
|
|
58
59
|
const px = (value) => scaled(value, domains.x, 0, width);
|
|
59
60
|
const py = (value) => scaled(value, domains.y, height, 0);
|
|
60
|
-
const
|
|
61
|
+
const inView = points.filter((point) => point.x >= domains.x.min &&
|
|
61
62
|
point.x <= domains.x.max &&
|
|
62
63
|
point.y >= domains.y.min &&
|
|
63
64
|
point.y <= domains.y.max);
|
|
65
|
+
// The picked point is drawn last, over its neighbours, so its ring shows whole.
|
|
66
|
+
const shown = [
|
|
67
|
+
...inView.filter((point) => point.id !== picked),
|
|
68
|
+
...inView.filter((point) => point.id === picked)
|
|
69
|
+
];
|
|
64
70
|
/** Where a pointer is in the plot, in its own pixels. */
|
|
65
71
|
const inPlot = (event) => {
|
|
66
72
|
const box = event.currentTarget.getBoundingClientRect();
|
|
@@ -75,7 +81,13 @@ export function ScatterChart({ label, points, x, y, picked = null, onPick }) {
|
|
|
75
81
|
onPick(id);
|
|
76
82
|
}
|
|
77
83
|
};
|
|
78
|
-
|
|
84
|
+
const xTicks = ticksOf(domains.x, x.kind, Math.max(2, Math.floor(width / 110)));
|
|
85
|
+
const yTicks = ticksOf(domains.y, y.kind, Math.max(2, Math.floor(height / 50)));
|
|
86
|
+
const xTickLabels = tickLabels(xTicks, x, domains.x);
|
|
87
|
+
const yTickLabels = tickLabels(yTicks, y, domains.y);
|
|
88
|
+
return (_jsxs("figure", { "aria-label": label, className: "scatter-chart", children: [_jsx("div", { className: "scatter-frame", ref: frame, children: _jsx("svg", { className: "scatter-svg", height: size.height, role: "group", "aria-label": label, width: size.width, children: _jsxs("g", { transform: `translate(${MARGIN.left} ${MARGIN.top})`, children: [points.length > 0 &&
|
|
89
|
+
xTicks.map((tick, at) => (_jsxs("g", { className: "scatter-tick", transform: `translate(${px(tick)} 0)`, children: [_jsx("line", { className: "scatter-grid", y1: 0, y2: height }), _jsx("text", { dy: "1.2em", textAnchor: "middle", y: height + 4, children: xTickLabels[at] })] }, `x${tick}`))), points.length > 0 &&
|
|
90
|
+
yTicks.map((tick, at) => (_jsxs("g", { className: "scatter-tick", transform: `translate(0 ${py(tick)})`, children: [_jsx("line", { className: "scatter-grid", x1: 0, x2: width }), _jsx("text", { dy: "0.32em", textAnchor: "end", x: -6, children: yTickLabels[at] })] }, `y${tick}`))), _jsx("path", { className: "scatter-axes", d: `M0 0V${height}H${width}` }), _jsx("rect", { className: "scatter-plot", "data-testid": "scatter-plot", height: height, onPointerDown: (event) => {
|
|
79
91
|
if (event.button !== 0)
|
|
80
92
|
return;
|
|
81
93
|
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
@@ -93,7 +105,9 @@ export function ScatterChart({ label, points, x, y, picked = null, onPick }) {
|
|
|
93
105
|
drag.set(null);
|
|
94
106
|
if (zoomed !== null)
|
|
95
107
|
setZoom(zoomed);
|
|
96
|
-
}, width: width }), _jsx(ScatterSelection, { drag: drag }), shown
|
|
108
|
+
}, width: width }), _jsx(ScatterSelection, { drag: drag }), shown
|
|
109
|
+
.filter((point) => point.id === picked)
|
|
110
|
+
.map((point) => (_jsx("circle", { className: "scatter-halo", cx: px(point.x), cy: py(point.y), r: 10 }, "halo"))), points.length === 0 && (_jsx("text", { className: "chart-empty-text", dominantBaseline: "middle", textAnchor: "middle", x: width / 2, y: height / 2, children: labels.noValue })), shown.map((point) => (_jsx("circle", { "aria-label": point.label, className: picked === point.id ? 'scatter-point lit' : 'scatter-point', cx: px(point.x), cy: py(point.y), onClick: () => onPick(point.id), onKeyDown: (event) => pickKey(event, point.id), r: picked === point.id ? 6 : 4, role: "button", tabIndex: 0, ...tooltip(point.label) }, point.id))), _jsx("text", { className: "scatter-title", textAnchor: "middle", x: width / 2, y: height + 34, children: x.title }), _jsx("text", { className: "scatter-title", textAnchor: "middle", transform: `translate(${-MARGIN.left + 12} ${height / 2}) rotate(-90)`, children: y.title })] }) }) }), _jsxs("figcaption", { className: "scatter-caption", children: [_jsx("span", { children: shown.length === points.length
|
|
97
111
|
? labels.points(points.length)
|
|
98
|
-
: labels.pointsShown(shown.length, points.length) }), _jsxs(Button, { disabled: zoom === null, onClick: () => setZoom(null), size: "small", children: [_jsx(RotateCcw, { "aria-hidden": true, size:
|
|
112
|
+
: labels.pointsShown(shown.length, points.length) }), _jsxs(Button, { disabled: zoom === null, onClick: () => setZoom(null), size: "small", children: [_jsx(RotateCcw, { "aria-hidden": true, size: ICON_SM }), labels.resetZoom] })] })] }));
|
|
99
113
|
}
|