@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
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { CalendarDays, ChevronLeft, ChevronRight, Clock } from 'lucide-react';
|
|
3
|
-
import { useEffect, useId, useRef, useState } from 'react';
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
4
4
|
import { Button } from '../button/Button.js';
|
|
5
5
|
import { IconButton } from '../button/IconButton.js';
|
|
6
|
+
import { ICON_MD } from '../icon/index.js';
|
|
6
7
|
import { useLabels } from '../labels/UiokProvider.js';
|
|
7
8
|
import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
8
|
-
import { formatPicker, monthGrid, nowParts, parsePicker, stepMonth, utcDay, weekdayNames } from './DateTimePicker.logic.js';
|
|
9
|
+
import { formatPicker, monthGrid, nowParts, panelPlace, parsePicker, stepMonth, utcDay, weekdayNames } from './DateTimePicker.logic.js';
|
|
9
10
|
/** The fields of a time, each with its largest value. */
|
|
10
11
|
const TIME_FIELDS = [
|
|
11
12
|
{ part: 'hour', max: 23 },
|
|
@@ -13,9 +14,9 @@ const TIME_FIELDS = [
|
|
|
13
14
|
{ part: 'second', max: 59 }
|
|
14
15
|
];
|
|
15
16
|
/**
|
|
16
|
-
* The most fraction digits a
|
|
17
|
-
*
|
|
18
|
-
* `--date-picker-digits`).
|
|
17
|
+
* The most fraction digits a millisecond field holds; a longer fraction
|
|
18
|
+
* field (microseconds) is `.long`. Every fraction field sits on a row of its
|
|
19
|
+
* own, as wide as its digits (`--date-picker-digits`).
|
|
19
20
|
*/
|
|
20
21
|
const SHORT_FRACTION = 3;
|
|
21
22
|
/** A time field's label. */
|
|
@@ -32,15 +33,50 @@ const timeFieldLabel = (labels, part) => labels[part];
|
|
|
32
33
|
* `dateTime` labels' locale; the field words from the same group.
|
|
33
34
|
*
|
|
34
35
|
* The panel is an overlay (`data-overlay`), so a window key policy that
|
|
35
|
-
* watches overlays holds its own keys while it is open.
|
|
36
|
+
* watches overlays holds its own keys while it is open. It stays beside its
|
|
37
|
+
* button in the document, so Tab reaches it next and a dialog keeps it, but
|
|
38
|
+
* is placed in the window (`position: fixed`): under the button, or above
|
|
39
|
+
* it when the room below is short, and always inside the window, so no
|
|
40
|
+
* scrolling pane or dialog cuts it. Today is marked in the month grid.
|
|
36
41
|
*/
|
|
37
|
-
export function DateTimePicker({ kind, fraction = 0, value, onChange, firstDay = 1, label, hint, disabled = false, format = formatPicker, parse = parsePicker }) {
|
|
42
|
+
export function DateTimePicker({ kind, fraction = 0, value, onChange, firstDay = 1, label, hint, disabled = false, size = 'small', format = formatPicker, parse = parsePicker }) {
|
|
38
43
|
const labels = useLabels().dateTime;
|
|
39
44
|
const [open, setOpen] = useState(false);
|
|
40
45
|
const [shown, setShown] = useState(() => parse(value) ?? nowParts());
|
|
41
46
|
const box = useRef(null);
|
|
47
|
+
const panel = useRef(null);
|
|
48
|
+
/** Where the open panel sits in the window; null until it is measured. */
|
|
49
|
+
const [place, setPlace] = useState(null);
|
|
42
50
|
const titleId = useId();
|
|
43
51
|
const picked = parse(value);
|
|
52
|
+
const today = nowParts();
|
|
53
|
+
// The panel follows its button as the page, a pane, or the window moves,
|
|
54
|
+
// measured before it paints, so it never shows in the wrong place.
|
|
55
|
+
useLayoutEffect(() => {
|
|
56
|
+
if (!open)
|
|
57
|
+
return;
|
|
58
|
+
const measure = () => {
|
|
59
|
+
const anchor = box.current?.getBoundingClientRect();
|
|
60
|
+
const own = panel.current?.getBoundingClientRect();
|
|
61
|
+
if (anchor === undefined || own === undefined)
|
|
62
|
+
return;
|
|
63
|
+
const next = panelPlace(anchor, own, {
|
|
64
|
+
width: window.innerWidth,
|
|
65
|
+
height: window.innerHeight
|
|
66
|
+
});
|
|
67
|
+
setPlace((held) => held?.left === next.left && held.top === next.top
|
|
68
|
+
? held
|
|
69
|
+
: { left: next.left, top: next.top });
|
|
70
|
+
};
|
|
71
|
+
measure();
|
|
72
|
+
window.addEventListener('scroll', measure, true);
|
|
73
|
+
window.addEventListener('resize', measure);
|
|
74
|
+
return () => {
|
|
75
|
+
window.removeEventListener('scroll', measure, true);
|
|
76
|
+
window.removeEventListener('resize', measure);
|
|
77
|
+
setPlace(null);
|
|
78
|
+
};
|
|
79
|
+
}, [open, shown.year, shown.month]);
|
|
44
80
|
// A pointer outside the picker closes it.
|
|
45
81
|
useEffect(() => {
|
|
46
82
|
if (!open)
|
|
@@ -67,20 +103,24 @@ export function DateTimePicker({ kind, fraction = 0, value, onChange, firstDay =
|
|
|
67
103
|
return (_jsxs("div", { className: "date-picker", ref: box, children: [_jsx(IconButton, { "aria-expanded": open, "aria-label": label, disabled: disabled, onClick: () => {
|
|
68
104
|
setShown(parse(value) ?? nowParts());
|
|
69
105
|
setOpen(!open);
|
|
70
|
-
}, size:
|
|
106
|
+
}, size: size, ...tooltip(hint ?? label), children: kind === 'time' ? (_jsx(Clock, { "aria-hidden": true, size: ICON_MD })) : (_jsx(CalendarDays, { "aria-hidden": true, size: ICON_MD })) }), open && (_jsxs("div", { "aria-labelledby": titleId, className: "date-picker-panel", "data-overlay": true, onKeyDown: (event) => {
|
|
71
107
|
if (event.key === 'Escape') {
|
|
72
108
|
event.preventDefault();
|
|
73
109
|
event.stopPropagation();
|
|
74
110
|
close();
|
|
75
111
|
}
|
|
76
|
-
}, role: "dialog", children: [kind !== 'time' && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "date-picker-head", children: [_jsx(IconButton, { "aria-label": labels.previousMonth, onClick: () => setShown(stepMonth(shown, -1)), size: "small", children: _jsx(ChevronLeft, { "aria-hidden": true, size:
|
|
112
|
+
}, ref: panel, role: "dialog", style: place ?? { visibility: 'hidden' }, children: [kind !== 'time' && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "date-picker-head", children: [_jsx(IconButton, { "aria-label": labels.previousMonth, onClick: () => setShown(stepMonth(shown, -1)), size: "small", children: _jsx(ChevronLeft, { "aria-hidden": true, size: ICON_MD }) }), _jsx("strong", { id: titleId, children: monthName }), _jsx(IconButton, { "aria-label": labels.nextMonth, onClick: () => setShown(stepMonth(shown, 1)), size: "small", children: _jsx(ChevronRight, { "aria-hidden": true, size: ICON_MD }) })] }), _jsxs("div", { className: "date-picker-days", role: "grid", children: [_jsx("div", { className: "date-picker-week", role: "row", children: weekdayNames(firstDay, labels.locale).map((name) => (_jsx("span", { className: "date-picker-weekday", role: "columnheader", children: name }, name))) }), Array.from({ length: days.length / 7 }, (_, week) => (_jsx("div", { className: "date-picker-week", role: "row", children: days.slice(week * 7, week * 7 + 7).map((day) => {
|
|
77
113
|
const current = picked !== null &&
|
|
78
114
|
picked.year === day.year &&
|
|
79
115
|
picked.month === day.month &&
|
|
80
116
|
picked.day === day.day;
|
|
81
|
-
|
|
117
|
+
const isToday = today.year === day.year &&
|
|
118
|
+
today.month === day.month &&
|
|
119
|
+
today.day === day.day;
|
|
120
|
+
return (_jsx("button", { "aria-current": isToday ? 'date' : undefined, "aria-selected": current, className: [
|
|
82
121
|
'date-picker-day',
|
|
83
122
|
day.inMonth ? '' : 'outside',
|
|
123
|
+
isToday ? 'today' : '',
|
|
84
124
|
current ? 'current' : ''
|
|
85
125
|
]
|
|
86
126
|
.filter(Boolean)
|
|
@@ -89,18 +129,23 @@ export function DateTimePicker({ kind, fraction = 0, value, onChange, firstDay =
|
|
|
89
129
|
if (kind === 'date')
|
|
90
130
|
close();
|
|
91
131
|
}, role: "gridcell", type: "button", children: day.day }, `${day.month}-${day.day}`));
|
|
92
|
-
}) }, week)))] })] })), kind !== 'date' && (_jsxs("div", { className: "date-picker-time", id: kind === 'time' ? titleId : undefined, children: [TIME_FIELDS.map((field) => (_jsxs("label", { className: "date-picker-field", children: [timeFieldLabel(labels, field.part), _jsx("input", { className: "date-picker-input", inputMode: "numeric", max: field.max, min: 0, onChange: (event) => {
|
|
132
|
+
}) }, week)))] })] })), kind !== 'date' && (_jsxs("div", { className: "date-picker-time", id: kind === 'time' ? titleId : undefined, children: [TIME_FIELDS.map((field) => (_jsxs("label", { className: "date-picker-field", children: [timeFieldLabel(labels, field.part), _jsx("input", { className: "field field-sm date-picker-input", inputMode: "numeric", max: field.max, min: 0, onChange: (event) => {
|
|
93
133
|
const next = Math.min(field.max, Math.max(0, Number(event.currentTarget.value)));
|
|
94
134
|
if (Number.isFinite(next))
|
|
95
135
|
write({ ...base, [field.part]: next });
|
|
96
|
-
}, type: "number",
|
|
136
|
+
}, type: "number",
|
|
137
|
+
// Two digits, as the field's value writes them ("09").
|
|
138
|
+
value: String(base[field.part]).padStart(2, '0') })] }, field.part))), fraction > 0 && (_jsxs("label", { className: "date-picker-field", children: [fraction > 3 ? labels.microsecond : labels.millisecond, _jsx("input", { className: fraction > SHORT_FRACTION
|
|
139
|
+
? 'field field-sm date-picker-input long'
|
|
140
|
+
: 'field field-sm date-picker-input', inputMode: "numeric", onChange: (event) => write({
|
|
97
141
|
...base,
|
|
98
142
|
fraction: event.currentTarget.value.replace(/\D/gu, '').slice(0, fraction)
|
|
99
|
-
}),
|
|
100
|
-
|
|
101
|
-
|
|
143
|
+
}),
|
|
144
|
+
// A text field's own width is 20 characters unless sized;
|
|
145
|
+
// the stylesheet sets it from its digits.
|
|
146
|
+
size: Math.max(2, fraction), style: { '--date-picker-digits': Math.max(2, fraction) }, value: base.fraction.padEnd(fraction, '0').slice(0, fraction) })] }))] })), _jsxs("div", { className: "date-picker-foot", children: [_jsx(Button, { onClick: () => {
|
|
102
147
|
write(nowParts());
|
|
103
148
|
if (kind === 'date')
|
|
104
149
|
close();
|
|
105
|
-
}, size: "small", children: kind === 'date' ? labels.today : labels.now }), _jsx(Button, { onClick: close, size: "small",
|
|
150
|
+
}, size: "small", children: kind === 'date' ? labels.today : labels.now }), _jsx(Button, { onClick: close, size: "small", children: labels.done })] })] }))] }));
|
|
106
151
|
}
|
|
@@ -57,3 +57,32 @@ export declare function monthGrid(year: number, month: number, firstDay: number)
|
|
|
57
57
|
export declare function stepMonth(parts: PickerParts, by: number): PickerParts;
|
|
58
58
|
/** The weekday names from `firstDay` (1 Monday to 7 Sunday), short, in `locale`'s language. */
|
|
59
59
|
export declare function weekdayNames(firstDay: number, locale?: string): string[];
|
|
60
|
+
/** A box in window coordinates, as `getBoundingClientRect` gives it. */
|
|
61
|
+
export interface PanelBox {
|
|
62
|
+
readonly left: number;
|
|
63
|
+
readonly top: number;
|
|
64
|
+
readonly width: number;
|
|
65
|
+
readonly height: number;
|
|
66
|
+
}
|
|
67
|
+
/** How far the panel keeps from the window's edges, in pixels. */
|
|
68
|
+
export declare const PANEL_INSET = 8;
|
|
69
|
+
/** How far the panel stands off its button, in pixels (`--space-2`). */
|
|
70
|
+
export declare const PANEL_GAP = 4;
|
|
71
|
+
/**
|
|
72
|
+
* Where the picker's panel sits in the window (`view`), given its button
|
|
73
|
+
* and its own size: under the button, its left edge on the button's, unless the room
|
|
74
|
+
* below is short of the panel and the room above is larger, when it opens
|
|
75
|
+
* above. Either way it is moved back inside the window, `PANEL_INSET` from
|
|
76
|
+
* each edge, so no part of it (its Now and Done buttons) is ever cut.
|
|
77
|
+
*/
|
|
78
|
+
export declare function panelPlace(anchor: PanelBox, panel: {
|
|
79
|
+
readonly width: number;
|
|
80
|
+
readonly height: number;
|
|
81
|
+
}, view: {
|
|
82
|
+
readonly width: number;
|
|
83
|
+
readonly height: number;
|
|
84
|
+
}): {
|
|
85
|
+
readonly left: number;
|
|
86
|
+
readonly top: number;
|
|
87
|
+
readonly above: boolean;
|
|
88
|
+
};
|
|
@@ -101,3 +101,28 @@ export function weekdayNames(firstDay, locale) {
|
|
|
101
101
|
// 2024-01-01 was a Monday.
|
|
102
102
|
return Array.from({ length: 7 }, (_, index) => format.format(new Date(Date.UTC(2024, 0, firstDay + index))));
|
|
103
103
|
}
|
|
104
|
+
/** How far the panel keeps from the window's edges, in pixels. */
|
|
105
|
+
export const PANEL_INSET = 8;
|
|
106
|
+
/** How far the panel stands off its button, in pixels (`--space-2`). */
|
|
107
|
+
export const PANEL_GAP = 4;
|
|
108
|
+
/**
|
|
109
|
+
* Where the picker's panel sits in the window (`view`), given its button
|
|
110
|
+
* and its own size: under the button, its left edge on the button's, unless the room
|
|
111
|
+
* below is short of the panel and the room above is larger, when it opens
|
|
112
|
+
* above. Either way it is moved back inside the window, `PANEL_INSET` from
|
|
113
|
+
* each edge, so no part of it (its Now and Done buttons) is ever cut.
|
|
114
|
+
*/
|
|
115
|
+
export function panelPlace(anchor, panel, view) {
|
|
116
|
+
const below = view.height - (anchor.top + anchor.height + PANEL_GAP) - PANEL_INSET;
|
|
117
|
+
const overhead = anchor.top - PANEL_GAP - PANEL_INSET;
|
|
118
|
+
const above = panel.height > below && overhead > below;
|
|
119
|
+
const top = above
|
|
120
|
+
? anchor.top - PANEL_GAP - panel.height
|
|
121
|
+
: anchor.top + anchor.height + PANEL_GAP;
|
|
122
|
+
const clamp = (value, size, room) => Math.max(PANEL_INSET, Math.min(value, room - size - PANEL_INSET));
|
|
123
|
+
return {
|
|
124
|
+
left: clamp(anchor.left, panel.width, view.width),
|
|
125
|
+
top: clamp(top, panel.height, view.height),
|
|
126
|
+
above
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -1,123 +1,163 @@
|
|
|
1
1
|
/* ---- Date and time picker (DateTimePicker) ----
|
|
2
2
|
|
|
3
|
-
A button beside its field, and the panel it opens
|
|
3
|
+
A button beside its field, and the panel it opens. */
|
|
4
4
|
.date-picker {
|
|
5
5
|
position: relative;
|
|
6
6
|
display: inline-flex;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/* The panel stays beside its button in the document but is placed in the
|
|
10
|
+
window (DateTimePicker sets top and left, flipping above the button when
|
|
11
|
+
the room below is short). A fixed box is not cut by a scrolling ancestor's
|
|
12
|
+
overflow, so no pane or dialog clips it; it is a menu-level layer in the
|
|
13
|
+
stacking context it is drawn in, which in a dialog is the dialog's own. */
|
|
9
14
|
.date-picker-panel {
|
|
10
|
-
position:
|
|
11
|
-
top:
|
|
15
|
+
position: fixed;
|
|
16
|
+
top: 0;
|
|
12
17
|
left: 0;
|
|
13
|
-
z-index: var(--z-
|
|
18
|
+
z-index: var(--z-menu);
|
|
14
19
|
display: flex;
|
|
15
20
|
flex-direction: column;
|
|
16
|
-
gap:
|
|
21
|
+
gap: var(--space-4);
|
|
22
|
+
box-sizing: border-box;
|
|
17
23
|
width: max-content;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
border
|
|
24
|
+
max-width: calc(100vw - 2 * var(--space-4));
|
|
25
|
+
padding: var(--space-6);
|
|
26
|
+
border: var(--line) solid var(--border-strong);
|
|
27
|
+
border-radius: var(--radius-lg);
|
|
21
28
|
background: var(--surface);
|
|
22
29
|
color: var(--text);
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
/* The lit top edge every floating surface wears, then the popover's lift. */
|
|
31
|
+
box-shadow:
|
|
32
|
+
inset 0 var(--line) 0 var(--glass-edge),
|
|
33
|
+
var(--shadow-popover);
|
|
34
|
+
font: var(--font-size-small)/var(--line-height-prose) var(--font-ui);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* A scroller's fade (.scroll-fade and its kin, a listing's pane list) is a
|
|
38
|
+
mask, and a mask cuts every descendant to the scroller's box, a fixed one
|
|
39
|
+
included, so it would cut the panel at the scroller's edge. While a panel
|
|
40
|
+
is open inside one, the scroller drops its fade; the edges turn sharp for
|
|
41
|
+
that moment and the panel escapes whole. */
|
|
42
|
+
:is(.scroll-fade, .scroll-fade-end, .scroll-fade-x, .listing-root .pane-list):has(
|
|
43
|
+
.date-picker-panel
|
|
44
|
+
) {
|
|
45
|
+
mask-image: none;
|
|
25
46
|
}
|
|
26
47
|
|
|
27
48
|
.date-picker-head {
|
|
28
49
|
display: flex;
|
|
29
50
|
align-items: center;
|
|
30
51
|
justify-content: space-between;
|
|
31
|
-
gap:
|
|
52
|
+
gap: var(--space-4);
|
|
32
53
|
}
|
|
33
54
|
|
|
34
55
|
.date-picker-days {
|
|
35
56
|
display: flex;
|
|
36
57
|
flex-direction: column;
|
|
37
|
-
gap:
|
|
58
|
+
gap: var(--space-1);
|
|
38
59
|
}
|
|
39
60
|
|
|
40
61
|
.date-picker-week {
|
|
41
62
|
display: grid;
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
/* A day is as wide as a regular control, room for a weekday's short name,
|
|
64
|
+
whatever the time row below asks; a wider panel spreads the days rather
|
|
65
|
+
than stretch them. */
|
|
66
|
+
grid-template-columns: repeat(7, var(--control-height));
|
|
67
|
+
justify-content: space-between;
|
|
68
|
+
gap: var(--space-1);
|
|
44
69
|
}
|
|
45
70
|
|
|
46
71
|
.date-picker-weekday {
|
|
47
72
|
color: var(--text-dim);
|
|
48
|
-
font-size:
|
|
73
|
+
font-size: var(--font-size-caption);
|
|
49
74
|
text-align: center;
|
|
50
75
|
}
|
|
51
76
|
|
|
77
|
+
/* A day: a quiet control in the month's track (hover and pressed come from
|
|
78
|
+
the base stylesheet's track recipe). */
|
|
52
79
|
.date-picker-day {
|
|
53
|
-
height:
|
|
80
|
+
height: var(--control-height-sm);
|
|
54
81
|
padding: 0;
|
|
55
82
|
border: none;
|
|
56
|
-
border-radius:
|
|
83
|
+
border-radius: var(--radius-sm);
|
|
57
84
|
background: none;
|
|
58
85
|
color: inherit;
|
|
59
86
|
font: inherit;
|
|
60
87
|
font-variant-numeric: tabular-nums;
|
|
61
|
-
cursor:
|
|
88
|
+
cursor: default;
|
|
62
89
|
}
|
|
63
90
|
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
/* Days sit 2px apart: a ring outside would cross the next day. */
|
|
92
|
+
.date-picker-day:focus-visible {
|
|
93
|
+
outline-offset: var(--focus-offset-inset);
|
|
66
94
|
}
|
|
67
95
|
|
|
68
96
|
.date-picker-day.outside {
|
|
69
|
-
color: var(--
|
|
97
|
+
color: var(--text-dim);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Today: an outline and the strong weight, so it reads at a glance beside
|
|
101
|
+
the chosen day's fill, which wins when both fall on one day. */
|
|
102
|
+
.date-picker-day.today {
|
|
103
|
+
box-shadow: inset 0 0 0 var(--line) var(--control-border);
|
|
104
|
+
font-weight: var(--font-weight-strong);
|
|
70
105
|
}
|
|
71
106
|
|
|
72
107
|
.date-picker-day.current {
|
|
73
108
|
background: var(--accent);
|
|
109
|
+
box-shadow: none;
|
|
74
110
|
color: var(--on-accent);
|
|
75
111
|
}
|
|
76
112
|
|
|
113
|
+
/* Hour, minute, and second share one row that never wraps, in equal parts
|
|
114
|
+
of the panel's width. A fraction field takes a row of its own across all
|
|
115
|
+
three, so neither its label (whatever its length in a locale) nor its
|
|
116
|
+
digits set the columns: a picker with a fraction is as wide as one
|
|
117
|
+
without. */
|
|
77
118
|
.date-picker-time {
|
|
78
|
-
display:
|
|
79
|
-
|
|
80
|
-
gap:
|
|
119
|
+
display: grid;
|
|
120
|
+
grid-template-columns: repeat(3, minmax(6ch, 1fr));
|
|
121
|
+
gap: var(--space-4);
|
|
81
122
|
}
|
|
82
123
|
|
|
83
124
|
.date-picker-field {
|
|
84
125
|
display: flex;
|
|
85
126
|
flex-direction: column;
|
|
86
|
-
gap:
|
|
127
|
+
gap: var(--space-2);
|
|
128
|
+
min-width: 0;
|
|
87
129
|
color: var(--text-dim);
|
|
88
130
|
}
|
|
89
131
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
width: 7ch;
|
|
93
|
-
height: 24px;
|
|
94
|
-
padding: 0 8px;
|
|
95
|
-
border: 1px solid var(--border-strong);
|
|
96
|
-
border-radius: 6px;
|
|
97
|
-
background: var(--ground);
|
|
98
|
-
color: var(--text);
|
|
99
|
-
font: inherit;
|
|
100
|
-
transition:
|
|
101
|
-
border-color 120ms,
|
|
102
|
-
box-shadow 120ms;
|
|
132
|
+
.date-picker-field:nth-child(4) {
|
|
133
|
+
grid-column: 1 / -1;
|
|
103
134
|
}
|
|
104
135
|
|
|
105
|
-
/* A
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
136
|
+
/* A time field (the shared .field look, small): two digits centred. Scoped
|
|
137
|
+
under its label to outweigh the shared field's own min-width, which loads
|
|
138
|
+
after this sheet. */
|
|
139
|
+
.date-picker-field > .date-picker-input {
|
|
140
|
+
width: 100%;
|
|
141
|
+
/* Three digits and the field's inset, so the field never cuts its value,
|
|
142
|
+
and the room a number field's stepper takes at its end (none on a field
|
|
143
|
+
without one), so the digits keep their room beside it. */
|
|
144
|
+
min-width: calc(6ch + var(--field-stepper-width, 0px));
|
|
145
|
+
font-variant-numeric: tabular-nums;
|
|
146
|
+
text-align: center;
|
|
111
147
|
}
|
|
112
148
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
149
|
+
/* The fraction field is as wide as its --date-picker-digits, plus a ch for
|
|
150
|
+
the caret, its padding, and its border, so it fits whether the page sizes
|
|
151
|
+
boxes by content or border; it starts the row rather than stretch across
|
|
152
|
+
it, and never grows past the row. */
|
|
153
|
+
.date-picker-field:nth-child(4) > .date-picker-input {
|
|
154
|
+
align-self: flex-start;
|
|
155
|
+
width: calc((var(--date-picker-digits) + 1) * 1ch + 2 * var(--space-4) + 2px);
|
|
156
|
+
max-width: 100%;
|
|
117
157
|
}
|
|
118
158
|
|
|
119
159
|
.date-picker-foot {
|
|
120
160
|
display: flex;
|
|
121
161
|
justify-content: space-between;
|
|
122
|
-
gap:
|
|
162
|
+
gap: var(--space-4);
|
|
123
163
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LucideIcon } from 'lucide-react';
|
|
2
2
|
import { type ReactElement, type ReactNode } from 'react';
|
|
3
|
+
import { type DialogFact, type DialogItem, type DialogItemGroup, type DialogStatementsProps } from './DialogLists.js';
|
|
3
4
|
/**
|
|
4
5
|
* A confirmation's tone: `danger` for a destructive action, `warning` for a
|
|
5
6
|
* question whose yes is the safe choice but still ends work, `primary` for
|
|
@@ -8,10 +9,20 @@ import { type ReactElement, type ReactNode } from 'react';
|
|
|
8
9
|
export type ConfirmTone = 'danger' | 'warning' | 'primary';
|
|
9
10
|
/** Copy and callbacks for {@link ConfirmDialog}. */
|
|
10
11
|
export interface ConfirmDialogProps {
|
|
11
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* What will happen, in at most five words, on one line of the title
|
|
14
|
+
* strip ("Delete Now?"), with no count, name, or path the body shows;
|
|
15
|
+
* a title too long is cut with an ellipsis, never wrapped.
|
|
16
|
+
*/
|
|
12
17
|
readonly title: string;
|
|
13
|
-
/**
|
|
14
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The lead: one sentence that says what will happen and to how many
|
|
20
|
+
* things ("This removes 3 servers from the list."), and, where it matters,
|
|
21
|
+
* one more that says what will not happen or cannot be undone. Text, or
|
|
22
|
+
* with a word set apart in bold (`<strong>`). Leave it out (or pass `''`)
|
|
23
|
+
* only when the title says all there is: no empty paragraph is drawn.
|
|
24
|
+
*/
|
|
25
|
+
readonly message?: ReactNode;
|
|
15
26
|
/** The action's verb, the lit primary at the right edge. */
|
|
16
27
|
readonly confirmLabel: string;
|
|
17
28
|
/**
|
|
@@ -21,11 +32,6 @@ export interface ConfirmDialogProps {
|
|
|
21
32
|
readonly cancelLabel?: string;
|
|
22
33
|
/** The action's icon, the one its trigger or menu row wears (a trash can for Move to Trash). */
|
|
23
34
|
readonly icon: LucideIcon;
|
|
24
|
-
/**
|
|
25
|
-
* Where the action happens, on the title strip's right edge
|
|
26
|
-
* (`~/Downloads`, or a group's dot and name); none when nothing says it.
|
|
27
|
-
*/
|
|
28
|
-
readonly context?: ReactNode;
|
|
29
35
|
/**
|
|
30
36
|
* `danger` for destructive confirmations (the default): a red rule under
|
|
31
37
|
* the title and a red lit confirm. `warning` for a question whose yes is
|
|
@@ -34,7 +40,46 @@ export interface ConfirmDialogProps {
|
|
|
34
40
|
* changes nothing by itself, which keeps the accent.
|
|
35
41
|
*/
|
|
36
42
|
readonly tone?: ConfirmTone;
|
|
37
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The things the action acts on, as data: each item's name, an optional
|
|
45
|
+
* dim detail (a host, a folder, a size), and a glyph where it differs
|
|
46
|
+
* from `itemIcon`. The dialog draws them as one framed list under the
|
|
47
|
+
* lead, five rows in full and then "+N more" (`DialogItems`). One item is
|
|
48
|
+
* a list of one row: never a fact row.
|
|
49
|
+
*/
|
|
50
|
+
readonly items?: readonly DialogItem[];
|
|
51
|
+
/** The kind's glyph on every item row that names no other (a server, a file). */
|
|
52
|
+
readonly itemIcon?: LucideIcon;
|
|
53
|
+
/**
|
|
54
|
+
* How many things the action acts on in all, when `items` holds only the
|
|
55
|
+
* first few; `items.length` unless given.
|
|
56
|
+
*/
|
|
57
|
+
readonly itemCount?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Labelled lists, for a confirmation that names several kinds of things
|
|
60
|
+
* (a quit's running processes and open terminals): each its label and
|
|
61
|
+
* count above the same framed list. Drawn after `items`.
|
|
62
|
+
*/
|
|
63
|
+
readonly groups?: readonly DialogItemGroup[];
|
|
64
|
+
/**
|
|
65
|
+
* The statements the action runs (a batch of SQL), every one of them,
|
|
66
|
+
* under its own short label: `{ label: 'SQL', lines }`. Drawn whole,
|
|
67
|
+
* after the items and groups, in a framed block that scrolls on its own
|
|
68
|
+
* past about eight lines (`DialogStatements`); never sliced.
|
|
69
|
+
*/
|
|
70
|
+
readonly statements?: Omit<DialogStatementsProps, 'id'>;
|
|
71
|
+
/**
|
|
72
|
+
* Facts about the action itself, never the things it acts on: where it
|
|
73
|
+
* acts, what it costs ("Where", a folder). One-line rows of a label and a
|
|
74
|
+
* value (`DialogFacts`), under the items.
|
|
75
|
+
*/
|
|
76
|
+
readonly facts?: readonly DialogFact[];
|
|
77
|
+
/**
|
|
78
|
+
* Paths the action touches, drawn as `items`: each path's last part as
|
|
79
|
+
* the name and its folder as the detail, with `itemIcon`.
|
|
80
|
+
*
|
|
81
|
+
* @deprecated Pass `items` with the kind's glyph and detail.
|
|
82
|
+
*/
|
|
38
83
|
readonly paths?: readonly string[];
|
|
39
84
|
/**
|
|
40
85
|
* A choice the confirmation carries, drawn under the message (keep an
|
|
@@ -48,7 +93,7 @@ export interface ConfirmDialogProps {
|
|
|
48
93
|
/**
|
|
49
94
|
* True for a delete that cannot be undone (a volume with no Trash, a
|
|
50
95
|
* server, a database): the confirm verb stays at the right edge, lit, but
|
|
51
|
-
* moves off Return onto ⌥⌘⌫,
|
|
96
|
+
* moves off Return onto ⌥⌘⌫, the Delete Now chord, and
|
|
52
97
|
* Return does nothing, so a Return pressed out of habit after ⌘⌫ never
|
|
53
98
|
* deletes anything for good.
|
|
54
99
|
*/
|
|
@@ -60,14 +105,18 @@ export interface ConfirmDialogProps {
|
|
|
60
105
|
}
|
|
61
106
|
/**
|
|
62
107
|
* The one confirmation surface, for destructive, privileged, and
|
|
63
|
-
* side-effect-bearing actions
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* (`
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
108
|
+
* side-effect-bearing actions, with the same four parts whether it acts on
|
|
109
|
+
* one thing or a thousand: a one-line title naming the action, the lead
|
|
110
|
+
* sentence, the items as one framed list (`items`, then any labelled
|
|
111
|
+
* `groups`, five rows in full and then "+N more"), any statements it runs
|
|
112
|
+
* in full (`statements`), then the legend's esc
|
|
113
|
+
* Cancel (or the leave verb named) and the named action at the right edge,
|
|
114
|
+
* on Return, or on ⌥⌘⌫ with Return running nothing for a delete that cannot
|
|
115
|
+
* be undone (`forGood`). Facts about the action and a choice the caller
|
|
116
|
+
* draws sit under them. A dialog with items or statements is the medium
|
|
117
|
+
* width, whatever their number. Its description (`aria-describedby`) reads the
|
|
118
|
+
* lead, then the count, then the names; without a lead or items the facts
|
|
119
|
+
* describe it. Styled by the `.confirm-dialog` rules in
|
|
120
|
+
* `@bigpixelrocket/uiok/styles.css`; reads the `dialog` labels.
|
|
72
121
|
*/
|
|
73
|
-
export declare function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon,
|
|
122
|
+
export declare function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone, items, itemIcon, itemCount, groups, statements, facts, paths, children, className, forGood, onConfirm, onCancel }: ConfirmDialogProps): ReactElement;
|
|
@@ -1,30 +1,57 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from 'react';
|
|
3
3
|
import { useLabels } from '../labels/UiokProvider.js';
|
|
4
|
+
import { DialogFacts, DialogItems, DialogStatements } from './DialogLists.js';
|
|
4
5
|
import { ModalDialog } from './ModalDialog.js';
|
|
5
|
-
/** Finder's
|
|
6
|
+
/** The Delete Now chord (Finder's chord for a delete that skips the Trash), which confirms a delete that cannot be undone. */
|
|
6
7
|
const DELETE_IMMEDIATELY = { key: 'Backspace', meta: true, alt: true };
|
|
7
8
|
/**
|
|
8
9
|
* The one confirmation surface, for destructive, privileged, and
|
|
9
|
-
* side-effect-bearing actions
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (`
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* side-effect-bearing actions, with the same four parts whether it acts on
|
|
11
|
+
* one thing or a thousand: a one-line title naming the action, the lead
|
|
12
|
+
* sentence, the items as one framed list (`items`, then any labelled
|
|
13
|
+
* `groups`, five rows in full and then "+N more"), any statements it runs
|
|
14
|
+
* in full (`statements`), then the legend's esc
|
|
15
|
+
* Cancel (or the leave verb named) and the named action at the right edge,
|
|
16
|
+
* on Return, or on ⌥⌘⌫ with Return running nothing for a delete that cannot
|
|
17
|
+
* be undone (`forGood`). Facts about the action and a choice the caller
|
|
18
|
+
* draws sit under them. A dialog with items or statements is the medium
|
|
19
|
+
* width, whatever their number. Its description (`aria-describedby`) reads the
|
|
20
|
+
* lead, then the count, then the names; without a lead or items the facts
|
|
21
|
+
* describe it. Styled by the `.confirm-dialog` rules in
|
|
22
|
+
* `@bigpixelrocket/uiok/styles.css`; reads the `dialog` labels.
|
|
18
23
|
*/
|
|
19
|
-
export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon,
|
|
24
|
+
export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone = 'danger', items, itemIcon, itemCount, groups = [], statements, facts = [], paths, children, className, forGood = false, onConfirm, onCancel }) {
|
|
20
25
|
const labels = useLabels().dialog;
|
|
21
26
|
const labelId = useId();
|
|
22
27
|
const messageId = useId();
|
|
28
|
+
const itemsId = useId();
|
|
29
|
+
const factsId = useId();
|
|
30
|
+
// An empty message draws nothing, so the dialog is described by what it does draw.
|
|
31
|
+
const hasMessage = message !== undefined && message !== null && message !== false && message !== '';
|
|
32
|
+
const list = items ?? paths?.map(pathItem) ?? [];
|
|
33
|
+
const hasItems = list.length > 0 || groups.length > 0;
|
|
34
|
+
const hasStatements = statements !== undefined && statements.lines.length > 0;
|
|
35
|
+
const described = [hasMessage ? messageId : null, hasItems ? itemsId : null].filter((part) => part !== null);
|
|
36
|
+
const describedBy = described.length > 0 ? described.join(' ') : facts.length > 0 ? factsId : undefined;
|
|
23
37
|
const legend = {
|
|
24
38
|
leave: { label: cancelLabel ?? labels.cancel },
|
|
25
39
|
primary: forGood
|
|
26
40
|
? { label: confirmLabel, chord: DELETE_IMMEDIATELY, onRun: onConfirm }
|
|
27
41
|
: { label: confirmLabel, onRun: onConfirm }
|
|
28
42
|
};
|
|
29
|
-
return (_jsxs(ModalDialog, { className:
|
|
43
|
+
return (_jsxs(ModalDialog, { className: ['confirm-dialog', hasItems || hasStatements ? 'confirm-items' : null, className]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join(' '), describedBy: describedBy, icon: icon, labelId: labelId, legend: legend, onCancel: onCancel, title: title, tone: tone === 'primary' ? 'accent' : tone, children: [hasMessage && (_jsx("p", { className: "dialog-message", id: messageId, children: message })), hasItems && (_jsxs("div", { className: "confirm-items-lists", id: itemsId, children: [list.length > 0 && _jsx(DialogItems, { count: itemCount, icon: itemIcon, items: list }), groups.map((group) => (_jsx(DialogItems, { count: group.count, icon: group.icon, items: group.items, label: group.label }, group.label)))] })), hasStatements && _jsx(DialogStatements, { label: statements.label, lines: statements.lines }), facts.length > 0 && _jsx(DialogFacts, { facts: facts, id: factsId }), children] }));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A path as an item: its last part is the name, the folder that holds it
|
|
49
|
+
* the detail ("deploying.md" in "~/projects/site/docs").
|
|
50
|
+
*/
|
|
51
|
+
function pathItem(path) {
|
|
52
|
+
const trimmed = path.length > 1 ? path.replace(/\/+$/, '') : path;
|
|
53
|
+
const cut = trimmed.lastIndexOf('/');
|
|
54
|
+
return cut <= 0 || cut === trimmed.length - 1
|
|
55
|
+
? { name: path }
|
|
56
|
+
: { name: trimmed.slice(cut + 1), detail: trimmed.slice(0, cut) };
|
|
30
57
|
}
|