@bigpixelrocket/uiok 0.1.4 → 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 +88 -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 +3 -3
package/dist/button/button.css
CHANGED
|
@@ -4,92 +4,260 @@
|
|
|
4
4
|
are drawn: they carry their own font, size, and box model, so no
|
|
5
5
|
surrounding stylesheet restyles them, and a consumer never overrides them
|
|
6
6
|
(a layout class may set width or alignment only). Tiers: primary for a
|
|
7
|
-
view's one main action, tonal for a row's routine positive action,
|
|
8
|
-
for
|
|
9
|
-
|
|
7
|
+
view's one main action, tonal for a row's routine positive action, danger
|
|
8
|
+
for a button that destroys something, neutral for the rest. A neutral
|
|
9
|
+
button and an icon button are outlined in
|
|
10
|
+
--control-border, the 3:1 line every control a pointer acts on shares.
|
|
11
|
+
Fills carry the glass edge (a lit top edge) at rest; hover deepens a fill
|
|
12
|
+
to its own hover token and lays a frosted wash on an outline; a press
|
|
13
|
+
sinks the face to a pressed tone one step past hover. Every control with
|
|
14
|
+
the frosted hover takes --transition-control, so the change eases the
|
|
15
|
+
same everywhere. */
|
|
10
16
|
.button,
|
|
11
17
|
.icon-button {
|
|
12
18
|
display: inline-flex;
|
|
13
19
|
flex: none;
|
|
14
20
|
align-items: center;
|
|
15
21
|
justify-content: center;
|
|
16
|
-
gap:
|
|
22
|
+
gap: var(--space-3);
|
|
17
23
|
box-sizing: border-box;
|
|
18
|
-
height:
|
|
24
|
+
height: var(--control-height);
|
|
19
25
|
margin: 0;
|
|
20
|
-
border:
|
|
21
|
-
border-radius:
|
|
26
|
+
border: var(--line) solid var(--control-border);
|
|
27
|
+
border-radius: var(--radius-md);
|
|
22
28
|
background: transparent;
|
|
23
29
|
color: var(--text);
|
|
24
|
-
cursor:
|
|
30
|
+
cursor: default;
|
|
25
31
|
font-family: var(--font-ui);
|
|
26
|
-
font-size:
|
|
27
|
-
font-weight:
|
|
32
|
+
font-size: var(--font-size-body);
|
|
33
|
+
font-weight: var(--font-weight-strong);
|
|
28
34
|
line-height: 1;
|
|
29
35
|
white-space: nowrap;
|
|
30
|
-
transition:
|
|
31
|
-
background-color 120ms,
|
|
32
|
-
border-color 120ms,
|
|
33
|
-
box-shadow 120ms,
|
|
34
|
-
color 120ms,
|
|
35
|
-
filter 120ms;
|
|
36
|
+
transition: var(--transition-control);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
.button {
|
|
39
|
-
padding: 0
|
|
40
|
+
padding: 0 var(--space-6);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
.button-small {
|
|
43
|
-
height:
|
|
44
|
-
padding: 0
|
|
45
|
-
font-size:
|
|
44
|
+
height: var(--control-height-sm);
|
|
45
|
+
padding: 0 var(--space-4);
|
|
46
|
+
font-size: var(--font-size-small);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* The 20px push button, for a row or a strip where 24px would touch the
|
|
50
|
+
rules: the 4px corner every 20px control has, caption words at medium
|
|
51
|
+
weight, and the tighter glyph gap. These are the strip action's values
|
|
52
|
+
(.pane-strip-link in listing.css), so the library has one 20px push
|
|
53
|
+
button look; a test holds the two rules equal. Its pointer target grows
|
|
54
|
+
to --hit-target in the block axis only, so buttons side by side keep
|
|
55
|
+
their own targets; the default focus ring stays. */
|
|
56
|
+
.button-xs {
|
|
57
|
+
position: relative;
|
|
58
|
+
gap: var(--space-2);
|
|
59
|
+
height: var(--control-height-xs);
|
|
60
|
+
padding: 0 var(--space-3);
|
|
61
|
+
border-radius: var(--radius-sm);
|
|
62
|
+
font-size: var(--font-size-caption);
|
|
63
|
+
font-weight: var(--font-weight-medium);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.button-xs::after {
|
|
67
|
+
position: absolute;
|
|
68
|
+
inset-block: min(0px, calc((100% - var(--hit-target)) / 2));
|
|
69
|
+
inset-inline: 0;
|
|
70
|
+
content: '';
|
|
46
71
|
}
|
|
47
72
|
|
|
48
73
|
.icon-button {
|
|
49
|
-
width:
|
|
74
|
+
width: var(--control-height);
|
|
50
75
|
padding: 0;
|
|
51
76
|
color: var(--text-dim);
|
|
52
77
|
}
|
|
53
78
|
|
|
54
79
|
.icon-button-small {
|
|
55
|
-
width:
|
|
56
|
-
height:
|
|
80
|
+
width: var(--control-height-sm);
|
|
81
|
+
height: var(--control-height-sm);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* A glyph takes the size of the control it sits in, whatever size its
|
|
85
|
+
caller passed: 14px in a regular control, 12px in a small or xs one. */
|
|
86
|
+
:is(.button, .icon-button) > svg {
|
|
87
|
+
flex: none;
|
|
88
|
+
width: var(--icon-md);
|
|
89
|
+
height: var(--icon-md);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:is(.button-small, .button-xs, .icon-button-small) > svg {
|
|
93
|
+
width: var(--icon-sm);
|
|
94
|
+
height: var(--icon-sm);
|
|
57
95
|
}
|
|
58
96
|
|
|
59
97
|
.button-primary {
|
|
60
98
|
border-color: var(--primary);
|
|
61
99
|
background: var(--primary);
|
|
100
|
+
box-shadow: inset 0 1px 0 var(--glass-edge);
|
|
62
101
|
color: var(--on-primary);
|
|
63
102
|
}
|
|
64
103
|
|
|
65
104
|
.button-tonal {
|
|
66
105
|
border-color: var(--tonal-border);
|
|
67
106
|
background: var(--tonal);
|
|
107
|
+
box-shadow: inset 0 1px 0 var(--glass-edge);
|
|
68
108
|
color: var(--on-tonal);
|
|
69
109
|
}
|
|
70
110
|
|
|
71
|
-
.button-primary:hover:enabled:not([aria-disabled='true']) {
|
|
111
|
+
.button-primary:hover:enabled:not([aria-disabled='true'], [aria-pressed='true']) {
|
|
112
|
+
background: var(--primary-hover);
|
|
72
113
|
box-shadow: var(--hover-lit);
|
|
73
|
-
filter: brightness(1.08);
|
|
74
114
|
}
|
|
75
115
|
|
|
76
|
-
.button-tonal:hover:enabled:not([aria-disabled='true']) {
|
|
116
|
+
.button-tonal:hover:enabled:not([aria-disabled='true'], [aria-pressed='true']) {
|
|
117
|
+
background: var(--tonal-hover);
|
|
77
118
|
box-shadow: var(--hover-lit);
|
|
78
|
-
filter: brightness(var(--tonal-hover-brightness));
|
|
79
119
|
}
|
|
80
120
|
|
|
81
|
-
:is(.button-neutral, .icon-button):hover:enabled:not(
|
|
121
|
+
:is(.button-neutral, .icon-button):hover:enabled:not(
|
|
122
|
+
[aria-disabled='true'],
|
|
123
|
+
[aria-pressed='true']
|
|
124
|
+
) {
|
|
82
125
|
background: var(--hover-wash);
|
|
83
126
|
box-shadow: var(--hover-frost);
|
|
84
127
|
color: var(--text);
|
|
85
128
|
}
|
|
86
129
|
|
|
87
|
-
|
|
130
|
+
/* A danger button is outlined, not filled: a --danger outline (4.5:1 on a
|
|
131
|
+
panel, so it clears the 3:1 an outline needs) and --danger-text words at
|
|
132
|
+
rest, the danger wash under the pointer, the stronger danger
|
|
133
|
+
wash while held. Red is kept for what destroys, so a view never shows a
|
|
134
|
+
solid red button beside its primary action. */
|
|
135
|
+
.button-danger {
|
|
136
|
+
border-color: var(--danger);
|
|
137
|
+
color: var(--danger-text);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.button-danger:hover:enabled:not([aria-disabled='true'], [aria-pressed='true']) {
|
|
141
|
+
background: var(--danger-wash);
|
|
142
|
+
box-shadow: var(--hover-frost);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* A press sinks the face. A fill steps past its hover tone to its pressed
|
|
146
|
+
tone (further from its words, so the label keeps its contrast) under the
|
|
147
|
+
pressed shadow; an outline takes the pressed wash, darker than the hover
|
|
148
|
+
wash. Pressed never reads as hovered, nor as the pointer having left. */
|
|
149
|
+
:is(.button-primary, .button-tonal):active:enabled:not(
|
|
150
|
+
[aria-disabled='true'],
|
|
151
|
+
[aria-pressed='true']
|
|
152
|
+
) {
|
|
153
|
+
box-shadow: var(--shadow-pressed);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.button-primary:active:enabled:not([aria-disabled='true'], [aria-pressed='true']) {
|
|
157
|
+
background: var(--primary-pressed);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.button-tonal:active:enabled:not([aria-disabled='true'], [aria-pressed='true']) {
|
|
161
|
+
background: var(--tonal-pressed);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* An outline keeps the inner hairline its hover drew, under the pressed
|
|
165
|
+
shadow, as the base sheet's shared press does: where a theme's pressed
|
|
166
|
+
wash barely moves the face, the sunk top edge and the ring still tell a
|
|
167
|
+
press from hover. */
|
|
168
|
+
.button-danger:active:enabled:not([aria-disabled='true'], [aria-pressed='true']) {
|
|
169
|
+
background: var(--danger-wash-strong);
|
|
170
|
+
box-shadow:
|
|
171
|
+
var(--shadow-pressed),
|
|
172
|
+
inset 0 0 0 var(--line) var(--border-strong);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
:is(.button-neutral, .icon-button):active:enabled:not(
|
|
176
|
+
[aria-disabled='true'],
|
|
177
|
+
[aria-pressed='true']
|
|
178
|
+
) {
|
|
179
|
+
background: var(--pressed-wash);
|
|
180
|
+
box-shadow:
|
|
181
|
+
var(--shadow-pressed),
|
|
182
|
+
inset 0 0 0 var(--line) var(--border-strong);
|
|
183
|
+
color: var(--text);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* A neutral Button or an IconButton that is on (aria-pressed="true", a
|
|
187
|
+
toggle) draws one ring, not two: its own outline takes the current
|
|
188
|
+
item's ring in place of the base sheet's inset ring, so the grey
|
|
189
|
+
outline and the accent ring never stand side by side. Held, it sinks
|
|
190
|
+
inside that one outline. */
|
|
191
|
+
:is(.button-neutral, .icon-button)[aria-pressed='true'] {
|
|
192
|
+
border-color: var(--current-ring);
|
|
193
|
+
box-shadow: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
:is(.button-neutral, .icon-button)[aria-pressed='true']:active:enabled:not([aria-disabled='true']) {
|
|
88
197
|
box-shadow: var(--shadow-pressed);
|
|
89
|
-
filter: brightness(0.94);
|
|
90
198
|
}
|
|
91
199
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
200
|
+
/* A primary, tonal, or danger button that cannot act drops its tier and is
|
|
201
|
+
drawn as a disabled neutral button: a faded tinted fill or a faded red
|
|
202
|
+
line would leave it murky. The base rule fades it like every other
|
|
203
|
+
disabled control. */
|
|
204
|
+
:is(.button-primary, .button-tonal, .button-danger):is(:disabled, [aria-disabled='true']) {
|
|
205
|
+
border-color: var(--control-border);
|
|
206
|
+
background: transparent;
|
|
207
|
+
box-shadow: none;
|
|
208
|
+
color: var(--text);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* ---- Disclosure ----
|
|
212
|
+
|
|
213
|
+
A section a user shows or hides (Extra options, Advanced options): a
|
|
214
|
+
disclosure chevron and a plain label, as a desktop window draws one,
|
|
215
|
+
never a bezelled push button. On a native button with aria-expanded;
|
|
216
|
+
the chevron is the icon family's (lucide ChevronRight, the glyph trees
|
|
217
|
+
and folds use), pointing to the label's end while closed and down while
|
|
218
|
+
open, and turns at once. At rest the words are dim, open or closed (the
|
|
219
|
+
chevron alone says open); under the pointer and with the keyboard focus
|
|
220
|
+
they are in the text colour, open or closed.
|
|
221
|
+
While held it takes the base sheet's shared press (the pressed wash and
|
|
222
|
+
hairline) on a face that reaches back over its own padding, so the words
|
|
223
|
+
keep their edge; the same corner rounds the base sheet's focus ring. */
|
|
224
|
+
.disclosure {
|
|
225
|
+
display: inline-flex;
|
|
226
|
+
align-items: center;
|
|
227
|
+
gap: var(--space-3);
|
|
228
|
+
box-sizing: border-box;
|
|
229
|
+
min-height: var(--control-height-sm);
|
|
230
|
+
margin: 0;
|
|
231
|
+
margin-inline: calc(-1 * var(--space-2));
|
|
232
|
+
padding: 0 var(--space-2);
|
|
233
|
+
border: 0;
|
|
234
|
+
border-radius: var(--radius-sm);
|
|
235
|
+
background: none;
|
|
236
|
+
color: var(--text-dim);
|
|
237
|
+
font: var(--font-weight-medium) var(--font-size-small) / var(--line-height-compact) var(--font-ui);
|
|
238
|
+
text-align: start;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.disclosure::before {
|
|
242
|
+
flex: none;
|
|
243
|
+
width: var(--icon-sm);
|
|
244
|
+
height: var(--icon-sm);
|
|
245
|
+
background: currentColor;
|
|
246
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E")
|
|
247
|
+
center / contain no-repeat;
|
|
248
|
+
content: '';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/* Mirrored right to left, read from the dir attribute (minifiers rewrite
|
|
252
|
+
the direction pseudo-class into a list of languages). */
|
|
253
|
+
.disclosure:where([dir='rtl'] *, [dir='rtl'])::before {
|
|
254
|
+
transform: scaleX(-1);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.disclosure[aria-expanded='true']::before {
|
|
258
|
+
transform: rotate(90deg);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.disclosure:is(:hover, :focus-visible):not(:disabled) {
|
|
262
|
+
color: var(--text);
|
|
95
263
|
}
|
|
@@ -16,6 +16,12 @@ export declare function valueDomain(values: readonly (number | null)[]): Domain;
|
|
|
16
16
|
* value a dot-sized stroke so it still shows.
|
|
17
17
|
*/
|
|
18
18
|
export declare function linePath(points: readonly LinePoint[], x: (at: number) => number, y: (value: number) => number): string;
|
|
19
|
+
/**
|
|
20
|
+
* The points a line cannot show: a value with no value beside it on either
|
|
21
|
+
* side (the series' only point, or one between two gaps), which a path
|
|
22
|
+
* draws as a speck. The chart marks each with a dot at rest.
|
|
23
|
+
*/
|
|
24
|
+
export declare function lonePoints(points: readonly LinePoint[]): LinePoint[];
|
|
19
25
|
/** The moment among `moments` (in order) nearest `at`; null when there is none. */
|
|
20
26
|
export declare function nearestMoment(moments: readonly number[], at: number): number | null;
|
|
21
27
|
/** A time label's position, kept inside the plot and clear of its neighbours. */
|
|
@@ -42,6 +42,15 @@ export function linePath(points, x, y) {
|
|
|
42
42
|
}
|
|
43
43
|
return parts.join(' ');
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The points a line cannot show: a value with no value beside it on either
|
|
47
|
+
* side (the series' only point, or one between two gaps), which a path
|
|
48
|
+
* draws as a speck. The chart marks each with a dot at rest.
|
|
49
|
+
*/
|
|
50
|
+
export function lonePoints(points) {
|
|
51
|
+
const has = (point) => point !== undefined && point.value !== null && Number.isFinite(point.value);
|
|
52
|
+
return points.filter((point, index) => has(point) && !has(points[index - 1]) && !has(points[index + 1]));
|
|
53
|
+
}
|
|
45
54
|
/** The moment among `moments` (in order) nearest `at`; null when there is none. */
|
|
46
55
|
export function nearestMoment(moments, at) {
|
|
47
56
|
let best = null;
|
package/dist/charts/LineChart.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
3
|
import { useLabels } from '../labels/UiokProvider.js';
|
|
4
|
-
import { linePath, nearestMoment, timeTickLabels, valueDomain } from './Line.logic.js';
|
|
4
|
+
import { linePath, lonePoints, nearestMoment, timeTickLabels, valueDomain } from './Line.logic.js';
|
|
5
5
|
import { scaled, ticksOf, unscaled } from './Scatter.logic.js';
|
|
6
6
|
import { seriesColour } from './seriesColour.js';
|
|
7
7
|
/** The room the axes' ticks take around the plot. */
|
|
@@ -50,6 +50,9 @@ export function LineChart({ label, series, from, to, format, timeText, onSelect
|
|
|
50
50
|
const timeTicks = ticksOf(time, 'time', Math.max(2, Math.floor(plotWidth / 90)));
|
|
51
51
|
const timeLabels = timeTickLabels(timeTicks, timeText, px, plotWidth, widthOf);
|
|
52
52
|
const labelKey = JSON.stringify([...timeTicks.map(timeText), ...valueTicks.map(format)]);
|
|
53
|
+
// A value to draw: one that is not missing, inside the time axis.
|
|
54
|
+
const drawable = series.some((entry) => entry.points.some((point) => point.value !== null && point.at >= time.min && point.at <= time.max));
|
|
55
|
+
// Measured again when the plot mounts, since the empty state draws no labels.
|
|
53
56
|
useLayoutEffect(() => {
|
|
54
57
|
const measured = {};
|
|
55
58
|
for (const label of svg.current?.querySelectorAll('.line-measure text') ?? []) {
|
|
@@ -60,7 +63,7 @@ export function LineChart({ label, series, from, to, format, timeText, onSelect
|
|
|
60
63
|
measured[label.textContent ?? ''] = Math.ceil(width);
|
|
61
64
|
}
|
|
62
65
|
setLabelWidths((known) => Object.entries(measured).some(([text, width]) => known[text] !== width) ? measured : known);
|
|
63
|
-
}, [labelKey]);
|
|
66
|
+
}, [labelKey, drawable]);
|
|
64
67
|
const moments = [
|
|
65
68
|
...new Set(series.flatMap((entry) => entry.points.map((point) => point.at)))
|
|
66
69
|
].sort((a, b) => a - b);
|
|
@@ -71,7 +74,11 @@ export function LineChart({ label, series, from, to, format, timeText, onSelect
|
|
|
71
74
|
return unscaled(x, time, 0, plotWidth);
|
|
72
75
|
};
|
|
73
76
|
const shown = hover === null ? null : nearestMoment(moments, hover);
|
|
74
|
-
return (_jsxs("figure", { "aria-label": label, className: "line-chart", children: [_jsxs("div", { className: "line-frame", ref: frame, children: [_jsxs("svg", { "aria-hidden": true, className: "line-svg", height: height, ref: svg, width: width, children: [_jsx("g", { className: "line-tick line-measure", visibility: "hidden", children: [...new Set([...timeTicks.map(timeText), ...valueTicks.map(format)])].map((text) => (_jsx("text", { children: text }, text))) }), _jsxs("g", { transform: `translate(${left} ${MARGIN.top})`, children: [timeTicks.map((tick) => (_jsx("line", { className: "line-grid", x1: px(tick), x2: px(tick), y1: 0, y2: plotHeight }, `grid${tick}`))), timeLabels.map((tick) => (_jsx("g", { className: "line-tick", children: _jsx("text", { dy: "1.1em", textAnchor: "start", x: tick.left, y: plotHeight + 4, children: tick.text }) }, `x${tick.at}`))), valueTicks.map((tick) => (_jsxs("g", { className: "line-tick", transform: `translate(0 ${py(tick)})`, children: [_jsx("line", { className: "line-grid", x1: 0, x2: plotWidth }), _jsx("text", { dy: "0.32em", textAnchor: "end", x: -6, children: format(tick) })] }, `y${tick}`))), _jsx("
|
|
77
|
+
return (_jsxs("figure", { "aria-label": label, className: "line-chart", children: [_jsxs("div", { className: "line-frame", ref: frame, children: [!drawable ? (_jsx("div", { className: "chart-empty", style: { height }, children: labels.noValue })) : (_jsxs("svg", { "aria-hidden": true, className: "line-svg", height: height, ref: svg, width: width, children: [_jsx("g", { className: "line-tick line-measure", visibility: "hidden", children: [...new Set([...timeTicks.map(timeText), ...valueTicks.map(format)])].map((text) => (_jsx("text", { children: text }, text))) }), _jsxs("g", { transform: `translate(${left} ${MARGIN.top})`, children: [timeTicks.map((tick) => (_jsx("line", { className: "line-grid", x1: px(tick), x2: px(tick), y1: 0, y2: plotHeight }, `grid${tick}`))), timeLabels.map((tick) => (_jsx("g", { className: "line-tick", children: _jsx("text", { dy: "1.1em", textAnchor: "start", x: tick.left, y: plotHeight + 4, children: tick.text }) }, `x${tick.at}`))), valueTicks.map((tick) => (_jsxs("g", { className: "line-tick", transform: `translate(0 ${py(tick)})`, children: [_jsx("line", { className: "line-grid", x1: 0, x2: plotWidth }), _jsx("text", { dy: "0.32em", textAnchor: "end", x: -6, children: format(tick) })] }, `y${tick}`))), _jsx("path", { className: "line-axes", d: `M0 0V${plotHeight}H${plotWidth}` }), series.map((entry, index) => (_jsx("path", { className: "line-series", d: linePath(entry.points.filter((point) => point.at >= time.min && point.at <= time.max), px, py), stroke: seriesColour(index) }, `${index}:${entry.label}`))), series.map((entry, index) => lonePoints(entry.points.filter((point) => point.at >= time.min && point.at <= time.max)).map((point) => (_jsx("circle", { className: "line-dot", cx: px(point.at), cy: py(point.value ?? 0), fill: seriesColour(index), r: 3 }, `lone${index}:${entry.label}:${point.at}`)))), shown !== null && (_jsx("line", { className: "line-guide", x1: px(shown), x2: px(shown), y1: 0, y2: plotHeight })), shown !== null &&
|
|
78
|
+
series.map((entry, index) => {
|
|
79
|
+
const value = entry.points.find((point) => point.at === shown)?.value ?? null;
|
|
80
|
+
return value === null ? null : (_jsx("circle", { className: "line-dot", cx: px(shown), cy: py(value), fill: seriesColour(index), r: 3 }, `dot${index}:${entry.label}`));
|
|
81
|
+
}), drag !== null && (_jsx("rect", { className: "line-selection", height: plotHeight, width: Math.abs(px(drag.to) - px(drag.from)), x: Math.min(px(drag.from), px(drag.to)) })), _jsx("rect", { className: onSelect === undefined ? 'line-plot' : 'line-plot selectable', "data-testid": "line-plot", height: plotHeight, onPointerDown: (event) => {
|
|
75
82
|
if (onSelect === undefined || event.button !== 0)
|
|
76
83
|
return;
|
|
77
84
|
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
@@ -91,7 +98,7 @@ export function LineChart({ label, series, from, to, format, timeText, onSelect
|
|
|
91
98
|
if (onSelect !== undefined && Math.abs(px(end) - px(drag.from)) >= 2) {
|
|
92
99
|
onSelect(Math.min(drag.from, end), Math.max(drag.from, end));
|
|
93
100
|
}
|
|
94
|
-
}, width: plotWidth })] })] }), shown !== null && (_jsxs("div", { className: "line-readout", role: "status", style: px(shown) > plotWidth / 2
|
|
101
|
+
}, width: plotWidth })] })] })), shown !== null && (_jsxs("div", { className: "line-readout", role: "status", style: px(shown) > plotWidth / 2
|
|
95
102
|
? { right: width - left - px(shown) + 8 }
|
|
96
103
|
: { left: left + px(shown) + 8 }, children: [_jsx("strong", { children: labels.time(timeText(shown)) }), series.map((entry, index) => {
|
|
97
104
|
const value = entry.points.find((point) => point.at === shown)?.value ?? null;
|
|
@@ -3,10 +3,15 @@ export interface PieSlice {
|
|
|
3
3
|
readonly label: string;
|
|
4
4
|
readonly value: number;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* A slice as drawn: its share of the whole, its path in a circle of radius
|
|
8
|
+
* `r` at the origin, and the turn (from twelve o'clock, clockwise) at its
|
|
9
|
+
* middle, where a tag naming it points.
|
|
10
|
+
*/
|
|
7
11
|
export interface PieArc extends PieSlice {
|
|
8
12
|
readonly share: number;
|
|
9
13
|
readonly path: string;
|
|
14
|
+
readonly middle: number;
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* The arcs of `slices`, clockwise from twelve o'clock in the order given;
|
|
@@ -14,3 +19,86 @@ export interface PieArc extends PieSlice {
|
|
|
14
19
|
* circle.
|
|
15
20
|
*/
|
|
16
21
|
export declare function pieArcs(slices: readonly PieSlice[], r: number): PieArc[];
|
|
22
|
+
/** A slice's tag outside the pie: a leader from the rim to `x`, `y`, and its number at `textX`, `textY`. */
|
|
23
|
+
export interface PieTag {
|
|
24
|
+
/** The leader's start, on the rim at the slice's middle. */
|
|
25
|
+
readonly fromX: number;
|
|
26
|
+
readonly fromY: number;
|
|
27
|
+
/** The leader's end. */
|
|
28
|
+
readonly x: number;
|
|
29
|
+
readonly y: number;
|
|
30
|
+
/** Which way the tag's text runs from its anchor. */
|
|
31
|
+
readonly anchor: 'start' | 'middle' | 'end';
|
|
32
|
+
/** The number's anchor point (drawn with a middle baseline). */
|
|
33
|
+
readonly textX: number;
|
|
34
|
+
readonly textY: number;
|
|
35
|
+
/** The number drawn. */
|
|
36
|
+
readonly text: string;
|
|
37
|
+
}
|
|
38
|
+
/** How far out a tag stands from the rim, on its first ring and on its second. */
|
|
39
|
+
export declare const PIE_TAG_REACH = 8;
|
|
40
|
+
/**
|
|
41
|
+
* The least room between two tags' numbers side by side: more than a
|
|
42
|
+
* figure's width, so "12" beside "1" never reads as "121".
|
|
43
|
+
*/
|
|
44
|
+
export declare const PIE_TAG_CLEAR = 8;
|
|
45
|
+
/** The least room between two tags' numbers one above the other, where lines keep them apart. */
|
|
46
|
+
export declare const PIE_TAG_CLEAR_ABOVE = 3;
|
|
47
|
+
/** A box by its edges. */
|
|
48
|
+
export interface PieTagBox {
|
|
49
|
+
readonly left: number;
|
|
50
|
+
readonly right: number;
|
|
51
|
+
readonly top: number;
|
|
52
|
+
readonly bottom: number;
|
|
53
|
+
}
|
|
54
|
+
/** The box `tag`'s number takes as drawn. */
|
|
55
|
+
export declare function pieTagBox(tag: PieTag): PieTagBox;
|
|
56
|
+
/**
|
|
57
|
+
* Where each slice's number goes when colours alone cannot tell slices apart
|
|
58
|
+
* (more slices than series colours): just outside the rim at the slice's
|
|
59
|
+
* middle, on a short leader. Each number's box keeps clear of every other
|
|
60
|
+
* number (`PIE_TAG_CLEAR` side by side) and leader, round the circle too, so the last tag and
|
|
61
|
+
* the first keep apart. Where tags crowd, they spread apart along their ring,
|
|
62
|
+
* keeping their order, so leaders never cross; where one ring cannot hold a
|
|
63
|
+
* run of thin slices, every other tag of the run steps out to a second ring.
|
|
64
|
+
* A leader is straight and never cuts into the pie, which bounds how far a
|
|
65
|
+
* tag may spread from its slice. A tag that still finds no clear place is
|
|
66
|
+
* `null` and its slice is left to the legend. `texts` holds each arc's
|
|
67
|
+
* number. A chart draws the pie `pieTagRoom` smaller to make the room.
|
|
68
|
+
*/
|
|
69
|
+
export declare function pieTags(arcs: readonly PieArc[], r: number, texts?: readonly string[]): (PieTag | null)[];
|
|
70
|
+
/** How much smaller a pie draws to make room for its tags outside the rim, both rings and the numbers on them. */
|
|
71
|
+
export declare const pieTagRoom: number;
|
|
72
|
+
/**
|
|
73
|
+
* How a slice's fill is drawn over its series colour: `solid`, `hatch`
|
|
74
|
+
* (stripes of the chart's surface across the hue, one way), or `cross`
|
|
75
|
+
* (stripes both ways).
|
|
76
|
+
*/
|
|
77
|
+
export type SliceHatch = 'solid' | 'hatch' | 'cross';
|
|
78
|
+
/** A slice's fill: which series colour (0 to 7, `--chart-1` to `--chart-8`) and how it is drawn. */
|
|
79
|
+
export interface SliceFill {
|
|
80
|
+
readonly hue: number;
|
|
81
|
+
readonly hatch: SliceHatch;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* How many slices have fills of their own: each of the eight series colours
|
|
85
|
+
* solid, then hatched, then crosshatched. A chart's legend lists no more.
|
|
86
|
+
*/
|
|
87
|
+
export declare const DISTINCT_SLICE_FILLS: number;
|
|
88
|
+
/**
|
|
89
|
+
* The fill of the slice at `at` (from zero) in the order given: the series
|
|
90
|
+
* colours in turn, solid for the first eight, hatched for the next eight,
|
|
91
|
+
* crosshatched for the eight after, so the first 24 slices and their legend
|
|
92
|
+
* swatches never share a fill, and two neighbours never share a colour.
|
|
93
|
+
*/
|
|
94
|
+
export declare const sliceFill: (at: number) => SliceFill;
|
|
95
|
+
/**
|
|
96
|
+
* The fills of the slices drawn, in arc order, given the place in the data
|
|
97
|
+
* of each (`places`, rising; a slice of nothing is not drawn, so places may
|
|
98
|
+
* skip). Each slice takes `sliceFill` of its place, so a slice keeps the
|
|
99
|
+
* fill its legend entry shows. Past the 24 fills, where the cycle starts
|
|
100
|
+
* over, a slice that would match the slice before it, or (the last) the
|
|
101
|
+
* first slice it meets round the circle, steps to the next way of drawing
|
|
102
|
+
* its colour, so no two neighbouring slices ever share a fill.
|
|
103
|
+
*/
|
|
104
|
+
export declare function pieFills(places: readonly number[]): SliceFill[];
|