@bigpixelrocket/uiok 0.0.0-stage → 0.1.1
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 +42 -0
- package/LICENSE +21 -0
- package/NOTICE +569 -0
- package/README.md +44 -2
- package/dist/VisuallyHidden.d.ts +13 -0
- package/dist/VisuallyHidden.js +13 -0
- package/dist/activity/ActivityBar.d.ts +29 -0
- package/dist/activity/ActivityBar.js +21 -0
- package/dist/activity/activity.css +43 -0
- package/dist/activity/index.d.ts +2 -0
- package/dist/activity/index.js +2 -0
- package/dist/button/Button.d.ts +26 -0
- package/dist/button/Button.js +14 -0
- package/dist/button/IconButton.d.ts +18 -0
- package/dist/button/IconButton.js +14 -0
- package/dist/button/button.css +95 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.js +3 -0
- package/dist/charts/Drawing.d.ts +27 -0
- package/dist/charts/Drawing.js +117 -0
- package/dist/charts/Drawing.logic.d.ts +2 -0
- package/dist/charts/Drawing.logic.js +22 -0
- package/dist/charts/Line.logic.d.ts +33 -0
- package/dist/charts/Line.logic.js +72 -0
- package/dist/charts/LineChart.d.ts +34 -0
- package/dist/charts/LineChart.js +100 -0
- package/dist/charts/Pie.logic.d.ts +16 -0
- package/dist/charts/Pie.logic.js +28 -0
- package/dist/charts/PieChart.d.ts +20 -0
- package/dist/charts/PieChart.js +16 -0
- package/dist/charts/ResultChart.d.ts +47 -0
- package/dist/charts/ResultChart.js +175 -0
- package/dist/charts/ResultChart.logic.d.ts +42 -0
- package/dist/charts/ResultChart.logic.js +165 -0
- package/dist/charts/Scatter.logic.d.ts +55 -0
- package/dist/charts/Scatter.logic.js +134 -0
- package/dist/charts/ScatterChart.d.ts +36 -0
- package/dist/charts/ScatterChart.js +99 -0
- package/dist/charts/charts.css +310 -0
- package/dist/charts/index.d.ts +14 -0
- package/dist/charts/index.js +11 -0
- package/dist/charts/seriesColour.d.ts +2 -0
- package/dist/charts/seriesColour.js +8 -0
- package/dist/clock/index.d.ts +2 -0
- package/dist/clock/index.js +2 -0
- package/dist/clock/useClock.d.ts +14 -0
- package/dist/clock/useClock.js +57 -0
- package/dist/datetime/DateTimePicker.d.ts +50 -0
- package/dist/datetime/DateTimePicker.js +98 -0
- package/dist/datetime/DateTimePicker.logic.d.ts +59 -0
- package/dist/datetime/DateTimePicker.logic.js +103 -0
- package/dist/datetime/datetime.css +115 -0
- package/dist/datetime/index.d.ts +7 -0
- package/dist/datetime/index.js +7 -0
- package/dist/dialog/ConfirmDialog.d.ts +73 -0
- package/dist/dialog/ConfirmDialog.js +30 -0
- package/dist/dialog/DialogLegend.d.ts +21 -0
- package/dist/dialog/DialogLegend.js +28 -0
- package/dist/dialog/DialogLegend.logic.d.ts +145 -0
- package/dist/dialog/DialogLegend.logic.js +71 -0
- package/dist/dialog/ModalDialog.d.ts +101 -0
- package/dist/dialog/ModalDialog.js +184 -0
- package/dist/dialog/dialog.css +283 -0
- package/dist/dialog/index.d.ts +8 -0
- package/dist/dialog/index.js +8 -0
- package/dist/filter/FilterEscape.d.ts +16 -0
- package/dist/filter/FilterEscape.js +15 -0
- package/dist/filter/FilterIcon.d.ts +8 -0
- package/dist/filter/FilterIcon.js +11 -0
- package/dist/filter/filter.css +42 -0
- package/dist/filter/index.d.ts +3 -0
- package/dist/filter/index.js +3 -0
- package/dist/grid/DataGrid.d.ts +149 -0
- package/dist/grid/DataGrid.js +373 -0
- package/dist/grid/DataGrid.logic.d.ts +57 -0
- package/dist/grid/DataGrid.logic.js +121 -0
- package/dist/grid/grid.css +206 -0
- package/dist/grid/index.d.ts +7 -0
- package/dist/grid/index.js +7 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/keyboard/BrowserKeys.d.ts +15 -0
- package/dist/keyboard/BrowserKeys.js +28 -0
- package/dist/keyboard/KeyChord.logic.d.ts +25 -0
- package/dist/keyboard/KeyChord.logic.js +50 -0
- package/dist/keyboard/Keyboard.logic.d.ts +84 -0
- package/dist/keyboard/Keyboard.logic.js +137 -0
- package/dist/keyboard/OverlayWatch.d.ts +28 -0
- package/dist/keyboard/OverlayWatch.js +119 -0
- package/dist/keyboard/PageSelectAll.d.ts +14 -0
- package/dist/keyboard/PageSelectAll.js +22 -0
- package/dist/keyboard/index.d.ts +9 -0
- package/dist/keyboard/index.js +9 -0
- package/dist/keychord/KeyChord.d.ts +16 -0
- package/dist/keychord/KeyChord.js +55 -0
- package/dist/keychord/index.d.ts +2 -0
- package/dist/keychord/index.js +2 -0
- package/dist/keychord/keychord.css +41 -0
- package/dist/labels/UiokLabels.d.ts +41 -0
- package/dist/labels/UiokLabels.js +31 -0
- package/dist/labels/UiokProvider.d.ts +44 -0
- package/dist/labels/UiokProvider.js +54 -0
- package/dist/labels/charts.d.ts +34 -0
- package/dist/labels/charts.js +15 -0
- package/dist/labels/dateTime.d.ts +32 -0
- package/dist/labels/dateTime.js +14 -0
- package/dist/labels/dialog.d.ts +18 -0
- package/dist/labels/dialog.js +6 -0
- package/dist/labels/index.d.ts +13 -0
- package/dist/labels/index.js +13 -0
- package/dist/labels/keys.d.ts +28 -0
- package/dist/labels/keys.js +53 -0
- package/dist/labels/legend.d.ts +21 -0
- package/dist/labels/legend.js +7 -0
- package/dist/labels/listing.d.ts +16 -0
- package/dist/labels/listing.js +8 -0
- package/dist/labels/pager.d.ts +32 -0
- package/dist/labels/pager.js +20 -0
- package/dist/labels/palette.d.ts +17 -0
- package/dist/labels/palette.js +6 -0
- package/dist/labels/selectAll.d.ts +15 -0
- package/dist/labels/selectAll.js +6 -0
- package/dist/labels/terminal.d.ts +25 -0
- package/dist/labels/terminal.js +9 -0
- package/dist/legend/KeyLegend.logic.d.ts +84 -0
- package/dist/legend/KeyLegend.logic.js +109 -0
- package/dist/legend/KeyLegendStrip.d.ts +36 -0
- package/dist/legend/KeyLegendStrip.js +82 -0
- package/dist/legend/index.d.ts +3 -0
- package/dist/legend/index.js +3 -0
- package/dist/legend/legend.css +148 -0
- package/dist/listing/CurrentDot.d.ts +15 -0
- package/dist/listing/CurrentDot.js +13 -0
- package/dist/listing/Listing.d.ts +230 -0
- package/dist/listing/Listing.js +265 -0
- package/dist/listing/PathParts.logic.d.ts +17 -0
- package/dist/listing/PathParts.logic.js +18 -0
- package/dist/listing/index.d.ts +10 -0
- package/dist/listing/index.js +10 -0
- package/dist/listing/listing.css +867 -0
- package/dist/menu/MenuQuery.logic.d.ts +69 -0
- package/dist/menu/MenuQuery.logic.js +75 -0
- package/dist/menu/fuzzyMatch.d.ts +31 -0
- package/dist/menu/fuzzyMatch.js +296 -0
- package/dist/menu/index.d.ts +9 -0
- package/dist/menu/index.js +9 -0
- package/dist/menu/menu.css +203 -0
- package/dist/menu/useBellBeat.d.ts +8 -0
- package/dist/menu/useBellBeat.js +26 -0
- package/dist/namecut/NameCut.d.ts +22 -0
- package/dist/namecut/NameCut.js +28 -0
- package/dist/namecut/NameCut.logic.d.ts +51 -0
- package/dist/namecut/NameCut.logic.js +120 -0
- package/dist/namecut/index.d.ts +3 -0
- package/dist/namecut/index.js +3 -0
- package/dist/namecut/namecut.css +67 -0
- package/dist/pager/Pager.d.ts +37 -0
- package/dist/pager/Pager.js +38 -0
- package/dist/pager/Pager.logic.d.ts +13 -0
- package/dist/pager/Pager.logic.js +63 -0
- package/dist/pager/index.d.ts +7 -0
- package/dist/pager/index.js +7 -0
- package/dist/pager/pager.css +62 -0
- package/dist/palette/Palette.d.ts +79 -0
- package/dist/palette/Palette.js +60 -0
- package/dist/palette/index.d.ts +6 -0
- package/dist/palette/index.js +6 -0
- package/dist/palette/palette.css +159 -0
- package/dist/pane/PaneActions.d.ts +104 -0
- package/dist/pane/PaneActions.js +62 -0
- package/dist/pane/PaneFrame.d.ts +51 -0
- package/dist/pane/PaneFrame.js +28 -0
- package/dist/pane/PaneKeys.d.ts +41 -0
- package/dist/pane/PaneKeys.js +104 -0
- package/dist/pane/PaneKeys.logic.d.ts +95 -0
- package/dist/pane/PaneKeys.logic.js +109 -0
- package/dist/pane/index.d.ts +11 -0
- package/dist/pane/index.js +11 -0
- package/dist/pane/usePaneKeys.d.ts +141 -0
- package/dist/pane/usePaneKeys.js +313 -0
- package/dist/run/RunHeader.d.ts +50 -0
- package/dist/run/RunHeader.js +31 -0
- package/dist/run/RunProgress.logic.d.ts +29 -0
- package/dist/run/RunProgress.logic.js +34 -0
- package/dist/run/index.d.ts +3 -0
- package/dist/run/index.js +3 -0
- package/dist/run/run.css +190 -0
- package/dist/segmented/SegmentedChoice.d.ts +22 -0
- package/dist/segmented/SegmentedChoice.js +31 -0
- package/dist/segmented/index.d.ts +2 -0
- package/dist/segmented/index.js +2 -0
- package/dist/segmented/segmented.css +49 -0
- package/dist/selectall/CheckRange.logic.d.ts +8 -0
- package/dist/selectall/CheckRange.logic.js +23 -0
- package/dist/selectall/SelectAllBar.d.ts +25 -0
- package/dist/selectall/SelectAllBar.js +24 -0
- package/dist/selectall/index.d.ts +7 -0
- package/dist/selectall/index.js +7 -0
- package/dist/selectall/selectall.css +31 -0
- package/dist/store/KeepUnchanged.logic.d.ts +19 -0
- package/dist/store/KeepUnchanged.logic.js +33 -0
- package/dist/store/SameProps.d.ts +15 -0
- package/dist/store/SameProps.js +46 -0
- package/dist/store/ValueStore.d.ts +17 -0
- package/dist/store/ValueStore.js +23 -0
- package/dist/store/index.d.ts +8 -0
- package/dist/store/index.js +8 -0
- package/dist/store/useStableHandlers.d.ts +13 -0
- package/dist/store/useStableHandlers.js +22 -0
- package/dist/styles.css +85 -0
- package/dist/tabs/PageTabs.d.ts +38 -0
- package/dist/tabs/PageTabs.js +33 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/tabs.css +64 -0
- package/dist/terminal/Terminal.d.ts +104 -0
- package/dist/terminal/Terminal.js +309 -0
- package/dist/terminal/Terminal.logic.d.ts +66 -0
- package/dist/terminal/Terminal.logic.js +156 -0
- package/dist/terminal/TerminalMenu.d.ts +36 -0
- package/dist/terminal/TerminalMenu.js +87 -0
- package/dist/terminal/TerminalMenu.logic.d.ts +78 -0
- package/dist/terminal/TerminalMenu.logic.js +68 -0
- package/dist/terminal/TerminalScrollback.d.ts +10 -0
- package/dist/terminal/TerminalScrollback.js +11 -0
- package/dist/terminal/ghostty/LICENSE +21 -0
- package/dist/terminal/ghostty/core.d.ts +315 -0
- package/dist/terminal/ghostty/core.js +1189 -0
- package/dist/terminal/ghostty/fallbackColors.d.ts +12 -0
- package/dist/terminal/ghostty/fallbackColors.js +23 -0
- package/dist/terminal/ghostty/fonts/LICENSE +21 -0
- package/dist/terminal/ghostty/fonts/SymbolsNerdFontMono-Regular.woff2 +0 -0
- package/dist/terminal/ghostty/keyCodes.logic.d.ts +20 -0
- package/dist/terminal/ghostty/keyCodes.logic.js +249 -0
- package/dist/terminal/ghostty/links.logic.d.ts +39 -0
- package/dist/terminal/ghostty/links.logic.js +84 -0
- package/dist/terminal/ghostty/renderer.d.ts +98 -0
- package/dist/terminal/ghostty/renderer.js +481 -0
- package/dist/terminal/ghostty/runtime.d.ts +126 -0
- package/dist/terminal/ghostty/runtime.js +346 -0
- package/dist/terminal/ghostty/spriteGlyphs.logic.d.ts +64 -0
- package/dist/terminal/ghostty/spriteGlyphs.logic.js +546 -0
- package/dist/terminal/ghostty/surface.d.ts +285 -0
- package/dist/terminal/ghostty/surface.js +1565 -0
- package/dist/terminal/ghostty/surface.logic.d.ts +181 -0
- package/dist/terminal/ghostty/surface.logic.js +392 -0
- package/dist/terminal/ghostty/vendor/LICENSE +21 -0
- package/dist/terminal/ghostty/vendor/ghostty-effects.wasm +0 -0
- package/dist/terminal/ghostty/vendor/ghostty-vt.wasm +0 -0
- package/dist/terminal/index.d.ts +12 -0
- package/dist/terminal/index.js +12 -0
- package/dist/terminal/terminal.css +169 -0
- package/dist/text/MarkedText.d.ts +14 -0
- package/dist/text/MarkedText.js +11 -0
- package/dist/text/highlightSegments.d.ts +13 -0
- package/dist/text/highlightSegments.js +29 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +3 -0
- package/dist/text/text.css +11 -0
- package/dist/themes/attributes.d.ts +21 -0
- package/dist/themes/attributes.js +41 -0
- package/dist/themes/catalog.d.ts +125 -0
- package/dist/themes/catalog.js +940 -0
- package/dist/themes/color.d.ts +29 -0
- package/dist/themes/color.js +52 -0
- package/dist/themes/ids.d.ts +139 -0
- package/dist/themes/ids.js +59 -0
- package/dist/themes/index.d.ts +12 -0
- package/dist/themes/index.js +12 -0
- package/dist/themes/themes.generated.css +1830 -0
- package/dist/themes/tokens.d.ts +189 -0
- package/dist/themes/tokens.js +462 -0
- package/dist/tooltip/Tooltip.d.ts +21 -0
- package/dist/tooltip/Tooltip.js +105 -0
- package/dist/tooltip/Tooltip.logic.d.ts +49 -0
- package/dist/tooltip/Tooltip.logic.js +50 -0
- package/dist/tooltip/index.d.ts +3 -0
- package/dist/tooltip/index.js +3 -0
- package/dist/tooltip/tooltip.css +45 -0
- package/package.json +91 -4
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
import { type KeyboardEvent, type ReactElement, type ReactNode } from 'react';
|
|
3
|
+
import { type DialogLegendModel } from './DialogLegend.logic.js';
|
|
4
|
+
/**
|
|
5
|
+
* The colour a dialog wears on its title strip's rule and icon: the accent
|
|
6
|
+
* by default, the danger colour for a destructive question (which also
|
|
7
|
+
* lights its primary in it), the warning colour for a warning question.
|
|
8
|
+
*/
|
|
9
|
+
export type DialogTone = 'accent' | 'danger' | 'warning';
|
|
10
|
+
/**
|
|
11
|
+
* Keeps Tab inside `container`: Tab moves to its next control and Shift-Tab
|
|
12
|
+
* to its previous one, wrapping at either end, so keyboard focus cannot
|
|
13
|
+
* escape to what lies behind a modal surface. A control that refuses the
|
|
14
|
+
* focus (hidden by a stylesheet, inert) is passed over for the one after it
|
|
15
|
+
* in the same direction, each tried at most once, so Tab never stalls on
|
|
16
|
+
* it. With nothing tabbable inside, Tab stays put. Any other key passes
|
|
17
|
+
* through. For a modal surface that is not a `ModalDialog` (a palette),
|
|
18
|
+
* called from its keydown handler.
|
|
19
|
+
*/
|
|
20
|
+
export declare const containTab: (event: KeyboardEvent<HTMLElement>, container: HTMLElement) => void;
|
|
21
|
+
/** Props for {@link ModalDialog}; content renders below the title strip. */
|
|
22
|
+
export interface ModalDialogProps {
|
|
23
|
+
/**
|
|
24
|
+
* What the dialog does: words, or a line that names a file cut so the
|
|
25
|
+
* name keeps its end, so a long name's extension and the words after it
|
|
26
|
+
* stay in the strip. A string title is also its own tooltip.
|
|
27
|
+
*/
|
|
28
|
+
readonly title: ReactNode;
|
|
29
|
+
/** Heading element id, unique per dialog, wired to `aria-labelledby`. */
|
|
30
|
+
readonly labelId: string;
|
|
31
|
+
/**
|
|
32
|
+
* The id of the body element that says what the dialog is about, wired to
|
|
33
|
+
* `aria-describedby`, so a screen reader reads it with the title (a
|
|
34
|
+
* confirmation's message); none when the title says it all.
|
|
35
|
+
*/
|
|
36
|
+
readonly describedBy?: string;
|
|
37
|
+
/** Extra class on the dialog box for dialog-specific layout (its width). */
|
|
38
|
+
readonly className?: string;
|
|
39
|
+
/** The verb's icon at the start of the title strip, drawn in the tone's colour. */
|
|
40
|
+
readonly icon?: LucideIcon;
|
|
41
|
+
/** The title strip's colour; `accent` unless given. */
|
|
42
|
+
readonly tone?: DialogTone;
|
|
43
|
+
/**
|
|
44
|
+
* The strip's context, pushed to its right edge and cut short with an
|
|
45
|
+
* ellipsis: where the dialog acts (`~/Developer/app`, with the home
|
|
46
|
+
* folder as `~`), or the item it asks about. Left out when the dialog has
|
|
47
|
+
* nothing to say there. A string context is also its own tooltip.
|
|
48
|
+
*/
|
|
49
|
+
readonly titleAside?: ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Frost the window behind the dialog. Off by default: a dialog that asks
|
|
52
|
+
* about what is on screen (renaming a file, adding a record) is part of
|
|
53
|
+
* that context, so the page behind it must stay readable while it asks.
|
|
54
|
+
* Only a self-contained overlay (a shortcuts list, settings) turns it on.
|
|
55
|
+
*/
|
|
56
|
+
readonly frosted?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Keep the box's top edge where it opened, centred, so a body that grows
|
|
59
|
+
* while it is open (a table of pending changes) extends it downward
|
|
60
|
+
* instead of moving what is above it under the pointer; a window resize
|
|
61
|
+
* centres it again. Off by default: every other dialog stays centred as
|
|
62
|
+
* its body changes.
|
|
63
|
+
*/
|
|
64
|
+
readonly pinTop?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The key legend footer, drawn last and bound to its keys while the
|
|
67
|
+
* dialog is open. A dialog without one draws its own last row.
|
|
68
|
+
*/
|
|
69
|
+
readonly legend?: DialogLegendModel;
|
|
70
|
+
/** Escape, and the esc slot: the dialog's way out. */
|
|
71
|
+
readonly onCancel: () => void;
|
|
72
|
+
/**
|
|
73
|
+
* A press outside the box, where it does something other than Escape: a
|
|
74
|
+
* dialog whose Escape asks before it ends work (a progress dialog's
|
|
75
|
+
* Cancel) puts itself away on an outside press instead. Left out, an
|
|
76
|
+
* outside press runs `onCancel`.
|
|
77
|
+
*/
|
|
78
|
+
readonly onOutsidePress?: () => void;
|
|
79
|
+
/** The body, between the title strip and the legend. */
|
|
80
|
+
readonly children: ReactNode;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The modal frame every dialog shares: the backdrop over the whole window
|
|
84
|
+
* that swallows clicks and cancels on an outside press (or runs
|
|
85
|
+
* `onOutsidePress`), Escape-cancels (with or without an esc slot drawn, so
|
|
86
|
+
* a dialog whose primary already does what Escape would still leaves on
|
|
87
|
+
* it), dialog ARIA semantics, Tab focus containment, the title strip (icon,
|
|
88
|
+
* title, context), and the key legend footer with its keys. The backdrop is
|
|
89
|
+
* clear unless `frosted` is set, so the page stays in view behind the
|
|
90
|
+
* dialog. Its `aria-modal="true"` is the overlay contract's modal cue
|
|
91
|
+
* (`MODAL_SELECTOR`), which an app shell reads to mute its own chords while
|
|
92
|
+
* the dialog is open. The dialog itself takes focus when it opens with
|
|
93
|
+
* nothing inside focused, so its keys work before any control is chosen.
|
|
94
|
+
* With `pinTop` the box keeps the top edge it opened at. Dialogs supply
|
|
95
|
+
* only their content and verbs.
|
|
96
|
+
*
|
|
97
|
+
* Styled by the `.dialog-backdrop` and `.dialog` rules in `@bigpixelrocket/uiok/styles.css`
|
|
98
|
+
* (`docs/components/dialog.md`); a caller sets only a dialog's size and its
|
|
99
|
+
* body's layout, through `className`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function ModalDialog({ title, labelId, describedBy, className, icon: Icon, tone, titleAside, frosted, pinTop, legend, onCancel, onOutsidePress, children }: ModalDialogProps): ReactElement;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
import { isKeyKept } from '../keyboard/BrowserKeys.js';
|
|
4
|
+
import { isTextEditingTarget } from '../keyboard/Keyboard.logic.js';
|
|
5
|
+
import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
6
|
+
import { DialogLegend } from './DialogLegend.js';
|
|
7
|
+
import { legendKeyAction } from './DialogLegend.logic.js';
|
|
8
|
+
/** Whether a key comes from a text field holding text, which keeps its deletion chords. */
|
|
9
|
+
const isFilledField = (target) => {
|
|
10
|
+
if (!isTextEditingTarget(target)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement
|
|
14
|
+
? target.value !== ''
|
|
15
|
+
: target.textContent !== '';
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The controls Tab visits inside a dialog, in order. Disabled controls
|
|
19
|
+
* (`:disabled`, so those inside a disabled fieldset too) and hidden inputs
|
|
20
|
+
* take no focus, so they must not anchor the cycle, and neither does
|
|
21
|
+
* anything taken out of the Tab order (the legend's slots); focusable scroll
|
|
22
|
+
* regions (a long path list) join it so they stay reachable.
|
|
23
|
+
*/
|
|
24
|
+
const tabbableIn = (dialog) => [
|
|
25
|
+
...dialog.querySelectorAll(':is(button, input:not([type="hidden"]), select, textarea, a[href], [tabindex="0"]):not(:disabled):not([tabindex="-1"])')
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Keeps Tab inside `container`: Tab moves to its next control and Shift-Tab
|
|
29
|
+
* to its previous one, wrapping at either end, so keyboard focus cannot
|
|
30
|
+
* escape to what lies behind a modal surface. A control that refuses the
|
|
31
|
+
* focus (hidden by a stylesheet, inert) is passed over for the one after it
|
|
32
|
+
* in the same direction, each tried at most once, so Tab never stalls on
|
|
33
|
+
* it. With nothing tabbable inside, Tab stays put. Any other key passes
|
|
34
|
+
* through. For a modal surface that is not a `ModalDialog` (a palette),
|
|
35
|
+
* called from its keydown handler.
|
|
36
|
+
*/
|
|
37
|
+
export const containTab = (event, container) => {
|
|
38
|
+
if (event.key !== 'Tab') {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { ownerDocument } = event.currentTarget;
|
|
42
|
+
const active = ownerDocument.activeElement;
|
|
43
|
+
const focusable = tabbableIn(container);
|
|
44
|
+
// With nothing tabbable (a progress dialog before its log has a line),
|
|
45
|
+
// Tab stays put; letting it through would reach the page behind.
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
if (focusable.length === 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const count = focusable.length;
|
|
51
|
+
const index = focusable.indexOf(active);
|
|
52
|
+
const delta = event.shiftKey ? -1 : 1;
|
|
53
|
+
// From the container itself, Tab enters at the first control and Shift-Tab at the last.
|
|
54
|
+
const first = index === -1 ? (event.shiftKey ? count - 1 : 0) : index + delta;
|
|
55
|
+
// The browser's own move is prevented, so a candidate that ignores focus()
|
|
56
|
+
// would hold Tab where it is; try the next one until the focus moves.
|
|
57
|
+
for (let step = 0; step < count; step += 1) {
|
|
58
|
+
focusable[(((first + step * delta) % count) + count) % count]?.focus();
|
|
59
|
+
if (ownerDocument.activeElement !== active) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Lets a dialog rendered inside another (a confirmation portalled from its
|
|
66
|
+
* body) tell the enclosing one that it holds the focus: claim when it
|
|
67
|
+
* mounts, release when it unmounts. Child effects run first, so an inner
|
|
68
|
+
* dialog mounted in the same commit claims before the enclosing dialog's
|
|
69
|
+
* own mount effect would take the focus back. A dialog opened later on top,
|
|
70
|
+
* nested or not, is unaffected: the enclosing dialog has already mounted.
|
|
71
|
+
*/
|
|
72
|
+
const NestedFocusContext = createContext(null);
|
|
73
|
+
/**
|
|
74
|
+
* The modal frame every dialog shares: the backdrop over the whole window
|
|
75
|
+
* that swallows clicks and cancels on an outside press (or runs
|
|
76
|
+
* `onOutsidePress`), Escape-cancels (with or without an esc slot drawn, so
|
|
77
|
+
* a dialog whose primary already does what Escape would still leaves on
|
|
78
|
+
* it), dialog ARIA semantics, Tab focus containment, the title strip (icon,
|
|
79
|
+
* title, context), and the key legend footer with its keys. The backdrop is
|
|
80
|
+
* clear unless `frosted` is set, so the page stays in view behind the
|
|
81
|
+
* dialog. Its `aria-modal="true"` is the overlay contract's modal cue
|
|
82
|
+
* (`MODAL_SELECTOR`), which an app shell reads to mute its own chords while
|
|
83
|
+
* the dialog is open. The dialog itself takes focus when it opens with
|
|
84
|
+
* nothing inside focused, so its keys work before any control is chosen.
|
|
85
|
+
* With `pinTop` the box keeps the top edge it opened at. Dialogs supply
|
|
86
|
+
* only their content and verbs.
|
|
87
|
+
*
|
|
88
|
+
* Styled by the `.dialog-backdrop` and `.dialog` rules in `@bigpixelrocket/uiok/styles.css`
|
|
89
|
+
* (`docs/components/dialog.md`); a caller sets only a dialog's size and its
|
|
90
|
+
* body's layout, through `className`.
|
|
91
|
+
*/
|
|
92
|
+
export function ModalDialog({ title, labelId, describedBy, className, icon: Icon, tone = 'accent', titleAside, frosted = false, pinTop = false, legend, onCancel, onOutsidePress = onCancel, children }) {
|
|
93
|
+
const dialogRef = useRef(null);
|
|
94
|
+
const claimEnclosingFocus = useContext(NestedFocusContext);
|
|
95
|
+
// How many dialogs nested inside this one hold the focus; a count, since
|
|
96
|
+
// StrictMode mounts, cleans up, and mounts each effect again.
|
|
97
|
+
const nestedFocusClaims = useRef(0);
|
|
98
|
+
const claimNestedFocus = useCallback((claim) => {
|
|
99
|
+
nestedFocusClaims.current += claim ? 1 : -1;
|
|
100
|
+
}, []);
|
|
101
|
+
// The top edge the centred box opened at, in the backdrop; null while centred.
|
|
102
|
+
const [pinnedTop, setPinnedTop] = useState(null);
|
|
103
|
+
// Read where the centring put the box before it paints, then hold it
|
|
104
|
+
// there. The offset ignores the settle animation's transform.
|
|
105
|
+
useLayoutEffect(() => {
|
|
106
|
+
const dialog = dialogRef.current;
|
|
107
|
+
if (pinTop && pinnedTop === null && dialog) {
|
|
108
|
+
setPinnedTop(Math.max(0, dialog.offsetTop));
|
|
109
|
+
}
|
|
110
|
+
}, [pinTop, pinnedTop]);
|
|
111
|
+
const pinned = pinTop ? pinnedTop : null;
|
|
112
|
+
// A resized window centres the box again, and the effect above pins it there.
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!pinTop) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const recentre = () => setPinnedTop(null);
|
|
118
|
+
window.addEventListener('resize', recentre);
|
|
119
|
+
return () => window.removeEventListener('resize', recentre);
|
|
120
|
+
}, [pinTop]);
|
|
121
|
+
// A control that asked for focus as it mounted (a name field) keeps it, as
|
|
122
|
+
// does a dialog nested inside this one that mounted with it; otherwise the
|
|
123
|
+
// dialog holds it, so Return and Escape reach it.
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const dialog = dialogRef.current;
|
|
126
|
+
if (dialog &&
|
|
127
|
+
nestedFocusClaims.current === 0 &&
|
|
128
|
+
!dialog.contains(dialog.ownerDocument.activeElement)) {
|
|
129
|
+
dialog.focus({ preventScroll: true });
|
|
130
|
+
}
|
|
131
|
+
if (!claimEnclosingFocus) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
claimEnclosingFocus(true);
|
|
135
|
+
return () => claimEnclosingFocus(false);
|
|
136
|
+
}, [claimEnclosingFocus]);
|
|
137
|
+
// Modal focus containment: Tab cycles inside the dialog so keyboard focus
|
|
138
|
+
// cannot escape to the page behind the backdrop.
|
|
139
|
+
const containFocus = (event) => {
|
|
140
|
+
if (dialogRef.current) {
|
|
141
|
+
containTab(event, dialogRef.current);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
return (_jsx("div", { className: frosted ? 'dialog-backdrop frosted' : 'dialog-backdrop', onMouseDown: onOutsidePress, children: _jsxs("div", { "aria-describedby": describedBy, "aria-labelledby": labelId, "aria-modal": "true", className: className ? `dialog ${className}` : 'dialog', "data-pinned": pinned !== null || undefined, "data-tone": tone, onKeyDown: (event) => {
|
|
145
|
+
// React bubbles events through portals, so a dialog portalled from
|
|
146
|
+
// inside this one (a confirmation) must not cancel or trap here.
|
|
147
|
+
if (!event.currentTarget.contains(event.target)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
// An input method's keys belong to its composition.
|
|
151
|
+
const composing = event.nativeEvent.isComposing || event.key === 'Process';
|
|
152
|
+
if (event.key === 'Escape' && !composing) {
|
|
153
|
+
onCancel();
|
|
154
|
+
}
|
|
155
|
+
const action = legend &&
|
|
156
|
+
legendKeyAction(legend, {
|
|
157
|
+
key: event.key,
|
|
158
|
+
altKey: event.altKey,
|
|
159
|
+
ctrlKey: event.ctrlKey,
|
|
160
|
+
metaKey: event.metaKey,
|
|
161
|
+
shiftKey: event.shiftKey,
|
|
162
|
+
repeat: event.repeat,
|
|
163
|
+
composing,
|
|
164
|
+
// The browser-key guard's cancel of a document key (⌘R) keeps nothing.
|
|
165
|
+
handled: isKeyKept(event.nativeEvent),
|
|
166
|
+
// Only focusable elements take keys, so anything but the dialog
|
|
167
|
+
// itself is a control in the body.
|
|
168
|
+
fromControl: event.target !== event.currentTarget,
|
|
169
|
+
// A pop-up menu opens on Return on macOS, as a button presses.
|
|
170
|
+
fromReturnControl: event.target instanceof HTMLButtonElement ||
|
|
171
|
+
event.target instanceof HTMLSelectElement ||
|
|
172
|
+
isTextEditingTarget(event.target),
|
|
173
|
+
fromFilledField: isFilledField(event.target)
|
|
174
|
+
});
|
|
175
|
+
if (action) {
|
|
176
|
+
// Return must not also press the focused button or submit a field.
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
if (action.kind === 'run') {
|
|
179
|
+
action.run();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
containFocus(event);
|
|
183
|
+
}, onMouseDown: (event) => event.stopPropagation(), ref: dialogRef, role: "dialog", style: pinned === null ? undefined : { ['--dialog-top']: `${pinned}px` }, tabIndex: -1, children: [_jsxs("div", { className: "dialog-heading", children: [Icon && _jsx(Icon, { "aria-hidden": true, className: "dialog-icon" }), _jsx("h2", { id: labelId, ...(typeof title === 'string' ? tooltip(title) : {}), children: title }), titleAside ? (_jsx("span", { className: "dialog-context", ...(typeof titleAside === 'string' ? tooltip(titleAside) : {}), children: titleAside })) : null] }), _jsx(NestedFocusContext, { value: claimNestedFocus, children: children }), legend && _jsx(DialogLegend, { legend: legend, onLeave: onCancel })] }) }));
|
|
184
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/* ---- Modal dialogs (ModalDialog) ----
|
|
2
|
+
|
|
3
|
+
The backdrop covers the whole window: fixed to the viewport, not to the
|
|
4
|
+
page, so nothing outside the dialog can be reached until it closes, the
|
|
5
|
+
way a native sheet blocks its window. It paints nothing: a dialog is part
|
|
6
|
+
of the context it asks about (the file being renamed, the record being
|
|
7
|
+
added), so the page stays readable behind it. Only the box itself lifts. */
|
|
8
|
+
.dialog-backdrop {
|
|
9
|
+
position: fixed;
|
|
10
|
+
inset: 0;
|
|
11
|
+
/* Above any docked panel (--z-panel) so the panel cannot steal clicks. */
|
|
12
|
+
z-index: var(--z-dialog);
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* The frosted wash, for overlays that replace the page rather than ask
|
|
19
|
+
about it (a shortcuts list, settings): the window ground at half strength
|
|
20
|
+
over a heavy blur, so each theme keeps its own tone and the page ghosts
|
|
21
|
+
through. */
|
|
22
|
+
.dialog-backdrop.frosted {
|
|
23
|
+
background: color-mix(in srgb, var(--bg) 50%, transparent);
|
|
24
|
+
-webkit-backdrop-filter: blur(36px) saturate(180%);
|
|
25
|
+
backdrop-filter: blur(36px) saturate(180%);
|
|
26
|
+
animation: dialog-wash-in 160ms ease-out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.dialog {
|
|
30
|
+
/* The tone (ModalDialog's `tone`): the title strip's rule, and in a
|
|
31
|
+
destructive dialog the lit primary; the icon wears the same colour, with
|
|
32
|
+
the primary colour for the accent. */
|
|
33
|
+
--dialog-tone: var(--accent);
|
|
34
|
+
--dialog-icon: var(--primary);
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
width: 360px;
|
|
37
|
+
background: var(--surface);
|
|
38
|
+
border: 1px solid var(--border-strong);
|
|
39
|
+
border-radius: 8px;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
/* Children are inset 12px; the title strip and the legend reach across
|
|
42
|
+
the box and the legend closes it at the bottom. */
|
|
43
|
+
padding: 0 12px 12px;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
gap: 12px;
|
|
47
|
+
box-shadow: var(--shadow-dialog);
|
|
48
|
+
animation: dialog-settle 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.dialog[data-tone='danger'] {
|
|
52
|
+
--dialog-tone: var(--danger);
|
|
53
|
+
--dialog-icon: var(--danger);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dialog[data-tone='warning'] {
|
|
57
|
+
--dialog-tone: var(--warning);
|
|
58
|
+
--dialog-icon: var(--warning);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* A dialog that grows while it is open (ModalDialog's `pinTop`) keeps the
|
|
62
|
+
top edge it opened at, centred, and grows downward. */
|
|
63
|
+
.dialog[data-pinned] {
|
|
64
|
+
align-self: flex-start;
|
|
65
|
+
margin-top: var(--dialog-top);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* The dialog holds the focus only so its keys work; it is not a control. */
|
|
69
|
+
.dialog:focus {
|
|
70
|
+
outline: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* The wash fades in and the dialog settles from a few pixels above; a cut to
|
|
74
|
+
a blurred window reads as a glitch. */
|
|
75
|
+
@keyframes dialog-wash-in {
|
|
76
|
+
from {
|
|
77
|
+
opacity: 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@keyframes dialog-settle {
|
|
82
|
+
from {
|
|
83
|
+
opacity: 0;
|
|
84
|
+
transform: translateY(-6px) scale(0.985);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@media (prefers-reduced-motion: reduce) {
|
|
89
|
+
.dialog-backdrop.frosted,
|
|
90
|
+
.dialog {
|
|
91
|
+
animation: none;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* The title strip: crust, ruled in the tone, with the verb's icon, the
|
|
96
|
+
title, and where the dialog acts pushed to the right edge. */
|
|
97
|
+
.dialog > .dialog-heading {
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
display: flex;
|
|
100
|
+
flex: none;
|
|
101
|
+
align-items: center;
|
|
102
|
+
gap: 8px;
|
|
103
|
+
height: 34px;
|
|
104
|
+
margin: 0 -12px;
|
|
105
|
+
padding: 0 12px 0 10px;
|
|
106
|
+
border-bottom: 1px solid var(--dialog-tone);
|
|
107
|
+
/* The box's own corner inside its border, so the crust keeps the curve
|
|
108
|
+
in a dialog that lets a popup hang past its edge. */
|
|
109
|
+
border-radius: 7px 7px 0 0;
|
|
110
|
+
background: var(--surface-header);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.dialog-icon {
|
|
114
|
+
flex: none;
|
|
115
|
+
width: 15px;
|
|
116
|
+
height: 15px;
|
|
117
|
+
stroke-width: 2;
|
|
118
|
+
color: var(--dialog-icon);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.dialog h2 {
|
|
122
|
+
flex: 0 1 auto;
|
|
123
|
+
min-width: 0;
|
|
124
|
+
margin: 0;
|
|
125
|
+
overflow: hidden;
|
|
126
|
+
font-size: 12px;
|
|
127
|
+
font-weight: 600;
|
|
128
|
+
text-overflow: ellipsis;
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.dialog-context {
|
|
133
|
+
flex: 1 1 0;
|
|
134
|
+
min-width: 0;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
color: var(--row-meta-text);
|
|
137
|
+
font-size: 12px;
|
|
138
|
+
font-weight: normal;
|
|
139
|
+
text-align: right;
|
|
140
|
+
text-overflow: ellipsis;
|
|
141
|
+
white-space: nowrap;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* ---- Dialog key legend (DialogLegend) ----
|
|
145
|
+
|
|
146
|
+
A hairline over the body surface, the secondary slots from the left edge,
|
|
147
|
+
the primary alone at the right edge. A slot is its key cap and its verb,
|
|
148
|
+
with no border or fill of its own and no focus ring: its key is the
|
|
149
|
+
keyboard's way to it. Its holder runs the hairline out to its own edges:
|
|
150
|
+
the dialog frame here, a palette in its own sheet. */
|
|
151
|
+
.dialog-legend {
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-wrap: wrap;
|
|
155
|
+
flex: none;
|
|
156
|
+
align-items: center;
|
|
157
|
+
gap: 2px;
|
|
158
|
+
min-height: 34px;
|
|
159
|
+
padding: 0 6px;
|
|
160
|
+
border-top: 1px solid var(--border);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.dialog > .dialog-legend {
|
|
164
|
+
margin: 0 -12px -12px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.legend-slot {
|
|
168
|
+
display: inline-flex;
|
|
169
|
+
flex: none;
|
|
170
|
+
align-items: center;
|
|
171
|
+
gap: 6px;
|
|
172
|
+
box-sizing: border-box;
|
|
173
|
+
min-height: 24px;
|
|
174
|
+
max-width: 100%;
|
|
175
|
+
margin: 0;
|
|
176
|
+
padding: 0 7px 0 4px;
|
|
177
|
+
border: none;
|
|
178
|
+
border-radius: 5px;
|
|
179
|
+
background: transparent;
|
|
180
|
+
color: var(--text);
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
font: inherit;
|
|
183
|
+
font-size: 12px;
|
|
184
|
+
white-space: normal;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.legend-slot:hover:enabled {
|
|
188
|
+
background: var(--hover-wash);
|
|
189
|
+
box-shadow: var(--hover-frost);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.dialog-legend .legend-slot:focus-visible {
|
|
193
|
+
outline: none;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.legend-slot-key {
|
|
197
|
+
display: inline-flex;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* A slot's chord drawn as one plain key cap. */
|
|
201
|
+
.legend-slot .keychord {
|
|
202
|
+
box-sizing: border-box;
|
|
203
|
+
height: 18px;
|
|
204
|
+
min-width: 20px;
|
|
205
|
+
justify-content: center;
|
|
206
|
+
padding: 0 4px;
|
|
207
|
+
border: 1px solid var(--border-strong);
|
|
208
|
+
border-radius: 4px;
|
|
209
|
+
color: var(--text);
|
|
210
|
+
background: var(--bg-panel);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.legend-primary {
|
|
214
|
+
margin-left: auto;
|
|
215
|
+
font-weight: 600;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* The verb Return runs is lit like a held key; a destructive one in the
|
|
219
|
+
danger colour, verb and all. */
|
|
220
|
+
.legend-primary .keychord {
|
|
221
|
+
border-color: var(--accent);
|
|
222
|
+
background: var(--accent);
|
|
223
|
+
color: var(--on-accent);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.dialog[data-tone='danger'] .legend-primary {
|
|
227
|
+
color: var(--danger);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.dialog[data-tone='danger'] .legend-primary .keychord {
|
|
231
|
+
border-color: var(--danger);
|
|
232
|
+
background: var(--danger);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* ---- Confirmation dialog (ConfirmDialog) ----
|
|
236
|
+
|
|
237
|
+
The dialog carries its own type, reset margins, and border-box sizing,
|
|
238
|
+
because a caller may portal it to the body, outside every page root; it
|
|
239
|
+
must render identically wherever it is drawn. */
|
|
240
|
+
.confirm-dialog {
|
|
241
|
+
color: var(--text);
|
|
242
|
+
font-family: var(--font-mono);
|
|
243
|
+
font-size: 13px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.confirm-dialog,
|
|
247
|
+
.confirm-dialog * {
|
|
248
|
+
box-sizing: border-box;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.confirm-dialog h2,
|
|
252
|
+
.confirm-dialog p,
|
|
253
|
+
.confirm-dialog ul {
|
|
254
|
+
margin: 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.dialog-message {
|
|
258
|
+
color: var(--text-dim);
|
|
259
|
+
overflow-wrap: break-word;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* A name the message sets apart (the item a delete asks about) reads in the text colour. */
|
|
263
|
+
.dialog-message strong {
|
|
264
|
+
color: var(--text);
|
|
265
|
+
font-weight: 600;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* A batch lists every affected path; long selections scroll. */
|
|
269
|
+
.dialog-paths {
|
|
270
|
+
margin: 8px 0 0;
|
|
271
|
+
padding: 6px 8px;
|
|
272
|
+
max-height: 160px;
|
|
273
|
+
overflow: auto;
|
|
274
|
+
list-style: none;
|
|
275
|
+
border: 1px solid var(--border);
|
|
276
|
+
border-radius: 4px;
|
|
277
|
+
font-size: 12px;
|
|
278
|
+
color: var(--text-dim);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.dialog-paths li {
|
|
282
|
+
overflow-wrap: anywhere;
|
|
283
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dialogs: the `ModalDialog` frame, its `DialogLegend` key legend footer and
|
|
3
|
+
* the rules for which slot a key runs, and the one `ConfirmDialog`.
|
|
4
|
+
*/
|
|
5
|
+
export { ConfirmDialog, type ConfirmDialogProps, type ConfirmTone } from './ConfirmDialog.js';
|
|
6
|
+
export { DialogLegend, type DialogLegendProps } from './DialogLegend.js';
|
|
7
|
+
export { filterLeaveLabel, legendKeyAction, legendSignature, type DialogLegendModel, type DialogLegendVerb, type LegendKeyAction, type LegendKeyStroke, type LegendPrimary, type LegendSecondary } from './DialogLegend.logic.js';
|
|
8
|
+
export { containTab, ModalDialog, type DialogTone, type ModalDialogProps } from './ModalDialog.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dialogs: the `ModalDialog` frame, its `DialogLegend` key legend footer and
|
|
3
|
+
* the rules for which slot a key runs, and the one `ConfirmDialog`.
|
|
4
|
+
*/
|
|
5
|
+
export { ConfirmDialog } from './ConfirmDialog.js';
|
|
6
|
+
export { DialogLegend } from './DialogLegend.js';
|
|
7
|
+
export { filterLeaveLabel, legendKeyAction, legendSignature } from './DialogLegend.logic.js';
|
|
8
|
+
export { containTab, ModalDialog } from './ModalDialog.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/** Props for {@link FilterEscape}. */
|
|
3
|
+
export interface FilterEscapeProps {
|
|
4
|
+
/** What a press does, in words ("Clear filter"): the key cap itself only says "esc". */
|
|
5
|
+
readonly label: string;
|
|
6
|
+
/** Does what Escape does in the field: clear a typed query, or leave. */
|
|
7
|
+
readonly onEscape: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The Escape key of a filter field, printed at its far end and pressable:
|
|
11
|
+
* the pointer's way to do what Escape does there, such as clear a typed
|
|
12
|
+
* query before the field closes. It takes no focus, so the field keeps the
|
|
13
|
+
* keys; where the focus goes once the field has closed is the caller's to
|
|
14
|
+
* say. Its label is its accessible name and its tooltip.
|
|
15
|
+
*/
|
|
16
|
+
export declare function FilterEscape({ label, onEscape }: FilterEscapeProps): ReactElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { KeyChord } from '../keychord/KeyChord.js';
|
|
3
|
+
import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
4
|
+
/** A press on a field's own controls must not take the focus from its input. */
|
|
5
|
+
const keepFocus = (event) => event.preventDefault();
|
|
6
|
+
/**
|
|
7
|
+
* The Escape key of a filter field, printed at its far end and pressable:
|
|
8
|
+
* the pointer's way to do what Escape does there, such as clear a typed
|
|
9
|
+
* query before the field closes. It takes no focus, so the field keeps the
|
|
10
|
+
* keys; where the focus goes once the field has closed is the caller's to
|
|
11
|
+
* say. Its label is its accessible name and its tooltip.
|
|
12
|
+
*/
|
|
13
|
+
export function FilterEscape({ label, onEscape }) {
|
|
14
|
+
return (_jsx("button", { "aria-label": label, className: "filter-escape", onClick: onEscape, onMouseDown: keepFocus, tabIndex: -1, type: "button", ...tooltip(label), children: _jsx(KeyChord, { chord: { key: 'Escape' } }) }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The mark at the start of a filter field, the same over a listing, in a
|
|
4
|
+
* menu, and in a palette. It is as wide as the icon column of the rows the
|
|
5
|
+
* field narrows, so the query starts on the same edge as their names.
|
|
6
|
+
* Decorative: the field's own label names it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function FilterIcon(): ReactElement;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ListFilter } from 'lucide-react';
|
|
3
|
+
/**
|
|
4
|
+
* The mark at the start of a filter field, the same over a listing, in a
|
|
5
|
+
* menu, and in a palette. It is as wide as the icon column of the rows the
|
|
6
|
+
* field narrows, so the query starts on the same edge as their names.
|
|
7
|
+
* Decorative: the field's own label names it.
|
|
8
|
+
*/
|
|
9
|
+
export function FilterIcon() {
|
|
10
|
+
return (_jsx("span", { "aria-hidden": true, className: "filter-icon", children: _jsx(ListFilter, { size: 13 }) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* ---- Filter field marks (FilterIcon, FilterEscape) ----
|
|
2
|
+
|
|
3
|
+
Drawn inside the listing scope (.listing-root), where a filter field sits
|
|
4
|
+
over the rows it narrows. */
|
|
5
|
+
|
|
6
|
+
/* The key that leaves a filter field (FilterEscape), drawn as a plain key
|
|
7
|
+
cap; the field's mark is .filter-icon. */
|
|
8
|
+
.listing-root .filter-escape {
|
|
9
|
+
flex: none;
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
margin-left: 8px;
|
|
12
|
+
padding: 0;
|
|
13
|
+
border: none;
|
|
14
|
+
border-radius: 4px;
|
|
15
|
+
background: none;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.listing-root .filter-escape .keychord {
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
height: 16px;
|
|
22
|
+
padding: 0 4px;
|
|
23
|
+
border: 1px solid var(--border-strong);
|
|
24
|
+
border-radius: 4px;
|
|
25
|
+
background: var(--bg-panel);
|
|
26
|
+
color: var(--text);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.listing-root .filter-escape:hover:enabled:not([aria-disabled='true']) .keychord {
|
|
30
|
+
border-color: color-mix(in srgb, var(--accent) 50%, var(--border-strong));
|
|
31
|
+
background: linear-gradient(var(--hover-wash), transparent) var(--bg-panel);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* A filter field's mark (FilterIcon), as wide as a row's icon column so the
|
|
35
|
+
query starts over the names. */
|
|
36
|
+
:where(.listing-root) .filter-icon {
|
|
37
|
+
flex: none;
|
|
38
|
+
display: inline-flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
width: 20px;
|
|
41
|
+
color: var(--accent);
|
|
42
|
+
}
|