@bigpixelrocket/uiok 0.4.0 → 0.6.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 +63 -1
- package/dist/button/TextLink.d.ts +26 -3
- package/dist/button/TextLink.js +5 -3
- package/dist/button/button.css +7 -0
- package/dist/dialog/ModalDialog.js +8 -2
- package/dist/dialog/SectionedDialog.d.ts +37 -0
- package/dist/dialog/SectionedDialog.js +157 -0
- package/dist/dialog/dialog.css +102 -0
- package/dist/dialog/index.d.ts +4 -2
- package/dist/dialog/index.js +4 -2
- package/dist/frame/AppRoot.d.ts +1 -1
- package/dist/frame/AppRoot.js +2 -1
- package/dist/frame/Dock.d.ts +1 -1
- package/dist/frame/Dock.js +2 -1
- package/dist/frame/FilterChips.d.ts +5 -2
- package/dist/frame/FilterChips.js +35 -2
- package/dist/frame/FilterChips.logic.d.ts +24 -0
- package/dist/frame/FilterChips.logic.js +34 -0
- package/dist/frame/PageParts.d.ts +4 -3
- package/dist/frame/PageParts.js +10 -3
- package/dist/frame/SideBySide.d.ts +32 -0
- package/dist/frame/SideBySide.js +50 -0
- package/dist/frame/Tree.d.ts +9 -3
- package/dist/frame/Tree.js +8 -5
- package/dist/frame/WindowFrame.d.ts +1 -1
- package/dist/frame/WindowFrame.js +3 -1
- package/dist/frame/frame.css +74 -5
- package/dist/frame/index.d.ts +4 -2
- package/dist/frame/index.js +4 -2
- package/dist/grid/grid.css +1 -0
- package/dist/icon/ProductMark.d.ts +57 -0
- package/dist/icon/ProductMark.js +26 -0
- package/dist/icon/icon.css +53 -0
- package/dist/icon/index.d.ts +3 -1
- package/dist/icon/index.js +3 -1
- package/dist/keyboard/Keyboard.logic.js +20 -3
- package/dist/keychord/KeyChord.d.ts +17 -1
- package/dist/keychord/KeyChord.js +16 -1
- package/dist/keychord/ShortcutIndex.d.ts +49 -0
- package/dist/keychord/ShortcutIndex.js +28 -0
- package/dist/keychord/index.d.ts +8 -2
- package/dist/keychord/index.js +8 -2
- package/dist/keychord/keychord.css +101 -0
- package/dist/labels/dialog.d.ts +2 -0
- package/dist/labels/dialog.js +2 -1
- package/dist/labels/keys.d.ts +5 -0
- package/dist/labels/keys.js +2 -1
- package/dist/labels/settings.d.ts +6 -0
- package/dist/labels/settings.js +1 -0
- package/dist/listing/Listing.d.ts +95 -7
- package/dist/listing/Listing.js +57 -13
- package/dist/listing/ListingScope.d.ts +7 -0
- package/dist/listing/ListingScope.js +8 -0
- package/dist/listing/PaneMessage.d.ts +7 -4
- package/dist/listing/PaneMessage.js +11 -4
- package/dist/listing/Timeline.d.ts +51 -0
- package/dist/listing/Timeline.js +28 -0
- package/dist/listing/index.d.ts +4 -2
- package/dist/listing/index.js +3 -1
- package/dist/listing/listing.css +268 -25
- package/dist/log/Ansi.logic.d.ts +27 -0
- package/dist/log/Ansi.logic.js +203 -0
- package/dist/log/LogWell.d.ts +11 -2
- package/dist/log/LogWell.js +15 -3
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.js +1 -0
- package/dist/log/log.css +80 -0
- package/dist/menu/Menu.d.ts +133 -0
- package/dist/menu/Menu.js +351 -0
- package/dist/menu/Menu.logic.d.ts +83 -0
- package/dist/menu/Menu.logic.js +92 -0
- package/dist/menu/index.d.ts +6 -1
- package/dist/menu/index.js +6 -1
- package/dist/menu/menu.css +57 -0
- package/dist/palette/Palette.d.ts +3 -2
- package/dist/palette/Palette.js +8 -4
- package/dist/palette/PaletteRows.d.ts +138 -0
- package/dist/palette/PaletteRows.js +76 -0
- package/dist/palette/index.d.ts +5 -2
- package/dist/palette/index.js +5 -2
- package/dist/pane/Pane.d.ts +42 -6
- package/dist/pane/Pane.js +92 -5
- package/dist/pane/PaneFrame.d.ts +22 -1
- package/dist/pane/PaneFrame.js +42 -5
- package/dist/pane/PaneKeys.d.ts +5 -1
- package/dist/pane/PaneKeys.js +28 -3
- package/dist/pane/PaneKeys.logic.d.ts +25 -0
- package/dist/pane/PaneKeys.logic.js +30 -0
- package/dist/pane/index.d.ts +2 -2
- package/dist/pane/index.js +1 -1
- package/dist/pane/usePaneKeys.d.ts +8 -1
- package/dist/pane/usePaneKeys.js +32 -12
- package/dist/shell/SettingsDialog.d.ts +20 -2
- package/dist/shell/SettingsDialog.js +13 -3
- package/dist/shell/index.d.ts +1 -1
- package/dist/styles.css +18 -3
- package/dist/surface/FactList.d.ts +54 -0
- package/dist/surface/FactList.js +33 -0
- package/dist/surface/FactTable.d.ts +44 -0
- package/dist/surface/FactTable.js +33 -0
- package/dist/surface/index.d.ts +7 -2
- package/dist/surface/index.js +7 -2
- package/dist/surface/surface.css +139 -2
- package/dist/tabs/PageTabs.d.ts +6 -0
- package/dist/tabs/PageTabs.js +1 -1
- package/dist/tabs/tabs.css +14 -0
- package/dist/terminal/TerminalBox.d.ts +30 -0
- package/dist/terminal/TerminalBox.js +17 -0
- package/dist/terminal/ghostty/core.d.ts +12 -4
- package/dist/terminal/ghostty/core.js +12 -4
- package/dist/terminal/index.d.ts +6 -2
- package/dist/terminal/index.js +6 -2
- package/dist/terminal/terminal.css +29 -0
- package/dist/text/Code.d.ts +15 -0
- package/dist/text/Code.js +12 -0
- package/dist/text/index.d.ts +6 -1
- package/dist/text/index.js +6 -1
- package/dist/text/text.css +21 -0
- package/dist/themes/themes.generated.css +20 -0
- package/dist/themes/tokens.d.ts +1 -0
- package/dist/themes/tokens.js +16 -2
- package/package.json +1 -1
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
2
3
|
import { ICON_SM } from '../icon/sizes.js';
|
|
4
|
+
import { sidewaysWheel } from './FilterChips.logic.js';
|
|
3
5
|
/**
|
|
4
6
|
* A pane's quick row of filters under its path bar (`pane-quick-row`), as a
|
|
5
7
|
* sidebar's Running and Updates: each a quiet button with its glyph, its
|
|
6
8
|
* word, and its count, pressed while on. A press toggles its filter and
|
|
7
|
-
* leaves the focus where it was.
|
|
9
|
+
* leaves the focus where it was. The row is one line: chips that do not
|
|
10
|
+
* fit scroll sideways under an edge fade (`.scroll-fade-x`), a mouse's
|
|
11
|
+
* vertical wheel scrolls it sideways while it can move that way
|
|
12
|
+
* (`sidewaysWheel`), and a chip the keys reach comes whole into view.
|
|
8
13
|
*/
|
|
9
14
|
export function FilterChips({ chips, on, onToggle, label }) {
|
|
10
|
-
|
|
15
|
+
const rowRef = useRef(null);
|
|
16
|
+
// A wheel listener React would make passive, so it can keep the page
|
|
17
|
+
// still while it turns the row; one it leaves alone scrolls the page.
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const row = rowRef.current;
|
|
20
|
+
if (row === null)
|
|
21
|
+
return undefined;
|
|
22
|
+
const onWheel = (event) => {
|
|
23
|
+
// Shift turns a wheel sideways and Control (or Command) zooms on their
|
|
24
|
+
// own; the row leaves both to the browser.
|
|
25
|
+
if (event.shiftKey || event.ctrlKey || event.metaKey)
|
|
26
|
+
return;
|
|
27
|
+
const delta = sidewaysWheel(event, row, getComputedStyle(row).direction === 'rtl');
|
|
28
|
+
if (delta === null)
|
|
29
|
+
return;
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
row.scrollLeft += delta;
|
|
32
|
+
};
|
|
33
|
+
row.addEventListener('wheel', onWheel, { passive: false });
|
|
34
|
+
return () => row.removeEventListener('wheel', onWheel);
|
|
35
|
+
}, []);
|
|
36
|
+
return (_jsx("div", { "aria-label": label, className: "pane-quick-row scroll-fade-x",
|
|
37
|
+
// A chip the keys reach comes whole into view, past the edge fade, at
|
|
38
|
+
// once: nothing here scrolls smoothly, so reduced motion has nothing to stop.
|
|
39
|
+
onFocus: (event) => {
|
|
40
|
+
if (event.target !== event.currentTarget) {
|
|
41
|
+
event.target.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });
|
|
42
|
+
}
|
|
43
|
+
}, ref: rowRef, role: "toolbar", children: chips.map((chip) => {
|
|
11
44
|
const Icon = chip.icon;
|
|
12
45
|
return (_jsxs("button", { "aria-pressed": on.includes(chip.id), className: "pane-quick-button quiet-track-item", onClick: () => onToggle(chip.id), onMouseDown: (event) => event.preventDefault(), type: "button", children: [Icon === undefined ? null : _jsx(Icon, { "aria-hidden": true, size: ICON_SM }), chip.label, chip.count === undefined || chip.count === null ? null : (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "pane-quick-count", children: chip.count })] }))] }, chip.id));
|
|
13
46
|
}) }));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A wheel event's deltas, as the DOM reports them. */
|
|
2
|
+
export interface WheelDeltas {
|
|
3
|
+
readonly deltaX: number;
|
|
4
|
+
readonly deltaY: number;
|
|
5
|
+
/** `WheelEvent.deltaMode`: 0 pixels, 1 lines, 2 pages. */
|
|
6
|
+
readonly deltaMode: number;
|
|
7
|
+
}
|
|
8
|
+
/** Where a sideways scroller stands: its `scrollLeft`, `scrollWidth`, and `clientWidth`. */
|
|
9
|
+
export interface SidewaysBox {
|
|
10
|
+
readonly scrollLeft: number;
|
|
11
|
+
readonly scrollWidth: number;
|
|
12
|
+
readonly clientWidth: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* How far a wheel moves a sideways line, as a change to its `scrollLeft`,
|
|
16
|
+
* or null to leave the event alone: when it is mostly sideways already (a
|
|
17
|
+
* trackpad, or Shift with a wheel, which the browser turns sideways
|
|
18
|
+
* itself), when the line has nothing hidden, and when the line already
|
|
19
|
+
* stands at the end the wheel points to, so the page under it scrolls as
|
|
20
|
+
* it would without the line. Down moves toward the line's end, which is
|
|
21
|
+
* its left in a right-to-left line (`rtl`), where `scrollLeft` runs from 0
|
|
22
|
+
* down to less than 0.
|
|
23
|
+
*/
|
|
24
|
+
export declare function sidewaysWheel(wheel: WheelDeltas, box: SidewaysBox, rtl?: boolean): number | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The quick row of filters is one line that scrolls sideways under the
|
|
3
|
+
* base sheet's inline edge fade, with no scrollbar drawn. A trackpad
|
|
4
|
+
* scrolls it sideways on its own; a plain mouse wheel sends only a
|
|
5
|
+
* vertical delta, which these rules turn onto the line.
|
|
6
|
+
*/
|
|
7
|
+
/** How far one wheel line moves the line, in pixels: a listing row's height (`--row-height`). */
|
|
8
|
+
const LINE_PIXELS = 24;
|
|
9
|
+
/**
|
|
10
|
+
* How far a wheel moves a sideways line, as a change to its `scrollLeft`,
|
|
11
|
+
* or null to leave the event alone: when it is mostly sideways already (a
|
|
12
|
+
* trackpad, or Shift with a wheel, which the browser turns sideways
|
|
13
|
+
* itself), when the line has nothing hidden, and when the line already
|
|
14
|
+
* stands at the end the wheel points to, so the page under it scrolls as
|
|
15
|
+
* it would without the line. Down moves toward the line's end, which is
|
|
16
|
+
* its left in a right-to-left line (`rtl`), where `scrollLeft` runs from 0
|
|
17
|
+
* down to less than 0.
|
|
18
|
+
*/
|
|
19
|
+
export function sidewaysWheel(wheel, box, rtl = false) {
|
|
20
|
+
if (wheel.deltaY === 0 || Math.abs(wheel.deltaX) >= Math.abs(wheel.deltaY))
|
|
21
|
+
return null;
|
|
22
|
+
const room = box.scrollWidth - box.clientWidth;
|
|
23
|
+
if (room <= 0)
|
|
24
|
+
return null;
|
|
25
|
+
const unit = wheel.deltaMode === 1 ? LINE_PIXELS : wheel.deltaMode === 2 ? box.clientWidth : 1;
|
|
26
|
+
const delta = wheel.deltaY * unit;
|
|
27
|
+
const along = rtl ? -box.scrollLeft : box.scrollLeft;
|
|
28
|
+
// Within half a pixel of an end counts as there: scroll positions are fractional at 2x.
|
|
29
|
+
const atStart = along <= 0.5;
|
|
30
|
+
const atEnd = along >= room - 0.5;
|
|
31
|
+
if ((delta < 0 && atStart) || (delta > 0 && atEnd))
|
|
32
|
+
return null;
|
|
33
|
+
return rtl ? -delta : delta;
|
|
34
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LucideIcon } from 'lucide-react';
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
3
3
|
/** Props of a part that only lays out what it holds. */
|
|
4
4
|
export interface PagePartProps {
|
|
5
5
|
readonly children: ReactNode;
|
|
@@ -34,8 +34,9 @@ export interface PageNoteProps {
|
|
|
34
34
|
readonly children: ReactNode;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* A loading or empty line in a page, where its rows would be
|
|
38
|
-
* spinner beside the words, from the rows'
|
|
37
|
+
* A loading or empty line in a page, where its rows would be, or a note
|
|
38
|
+
* after a listing: its glyph or spinner beside the words, from the rows'
|
|
39
|
+
* inset. Drawn outside every listing scope, it carries the scope itself.
|
|
39
40
|
*/
|
|
40
41
|
export declare function PageNote({ icon: Icon, busy, children }: PageNoteProps): ReactElement;
|
|
41
42
|
/** The one command that answers an empty list (Add service), under its `PageNote`. */
|
package/dist/frame/PageParts.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from 'react';
|
|
2
3
|
import { Button } from '../button/Button.js';
|
|
3
4
|
import { Spinner } from '../icon/Spinner.js';
|
|
4
5
|
import { ICON_MD, ICON_SM } from '../icon/sizes.js';
|
|
6
|
+
import { ListingScopeContext } from '../listing/ListingScope.js';
|
|
5
7
|
import { drawn } from './WindowFrame.js';
|
|
6
8
|
/** A page in the main pane (in its `PageSlot`): a column that fills the pane. */
|
|
7
9
|
export function PanePage({ children }) {
|
|
@@ -27,11 +29,16 @@ export function PageFilter({ children }) {
|
|
|
27
29
|
return _jsx("div", { className: "pane-page-filter", children: children });
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
|
-
* A loading or empty line in a page, where its rows would be
|
|
31
|
-
* spinner beside the words, from the rows'
|
|
32
|
+
* A loading or empty line in a page, where its rows would be, or a note
|
|
33
|
+
* after a listing: its glyph or spinner beside the words, from the rows'
|
|
34
|
+
* inset. Drawn outside every listing scope, it carries the scope itself.
|
|
32
35
|
*/
|
|
33
36
|
export function PageNote({ icon: Icon, busy = false, children }) {
|
|
34
|
-
|
|
37
|
+
const scoped = useContext(ListingScopeContext);
|
|
38
|
+
const note = (_jsxs("p", { className: "pane-message pane-page-note", role: busy ? 'status' : undefined, children: [busy ? (_jsx(Spinner, { size: ICON_MD })) : Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, size: ICON_MD })), _jsx("span", { children: children })] }));
|
|
39
|
+
// Outside every listing scope it carries the scope itself, as a listing
|
|
40
|
+
// does, so it keeps its look anywhere.
|
|
41
|
+
return scoped ? note : _jsx("div", { className: "listing-root", children: note });
|
|
35
42
|
}
|
|
36
43
|
/** The one command that answers an empty list (Add service), under its `PageNote`. */
|
|
37
44
|
export function EmptyAction({ children }) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
/** Props for {@link SideBySide}. */
|
|
3
|
+
export interface SideBySideProps {
|
|
4
|
+
/**
|
|
5
|
+
* The width in pixels, of the room the pair itself is given (its pane's
|
|
6
|
+
* page, never the window), from which the two stand side by side; in
|
|
7
|
+
* less, the second stands under the first.
|
|
8
|
+
*/
|
|
9
|
+
readonly from: number;
|
|
10
|
+
/** The first part, at the inline start side by side and on top stacked: a listing, a section. */
|
|
11
|
+
readonly first: ReactNode;
|
|
12
|
+
/** The first part's accessible name ("Settings"), which its group carries. */
|
|
13
|
+
readonly firstLabel: string;
|
|
14
|
+
/** The second part, beside the first or under it. */
|
|
15
|
+
readonly second: ReactNode;
|
|
16
|
+
/** The second part's accessible name ("Extensions"), which its group carries. */
|
|
17
|
+
readonly secondLabel: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Two of a page's listings or sections, side by side in equal columns while
|
|
21
|
+
* the room the pair is given is `from` pixels wide or more, one over the
|
|
22
|
+
* other in less, a hairline between them either way. Once side by side, it
|
|
23
|
+
* stacks only under `from` less a scrollbar's width, so a scrollbar the
|
|
24
|
+
* two columns bring cannot flip it back and forth. The room is the
|
|
25
|
+
* pair's own, measured as it resizes (`data-layout`: `side-by-side` or
|
|
26
|
+
* `stacked`), so a pane narrowed by its sidebar or a split stacks them
|
|
27
|
+
* though the window is wide. It is a layout alone: each part is a group
|
|
28
|
+
* named by its label, in the page's reading order (the first, then the
|
|
29
|
+
* second), and holds no cursor and answers no key; the rows inside follow
|
|
30
|
+
* whatever `RowCursorContext` is around them.
|
|
31
|
+
*/
|
|
32
|
+
export declare function SideBySide({ from, first, firstLabel, second, secondLabel }: SideBySideProps): ReactElement;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* How far under `from` a pair already side by side stays so, in pixels:
|
|
5
|
+
* wider than a classic scrollbar (15px on macOS, 17px on Windows). Two
|
|
6
|
+
* columns can be taller than one stack, so side by side a scrollbar may
|
|
7
|
+
* appear in the pane and narrow the pair under `from`; stacking then would
|
|
8
|
+
* take the scrollbar away and stand them side by side again, back and
|
|
9
|
+
* forth. Holding the layout through a scrollbar's width keeps it still.
|
|
10
|
+
*/
|
|
11
|
+
const SCROLLBAR_HOLD = 20;
|
|
12
|
+
/**
|
|
13
|
+
* Two of a page's listings or sections, side by side in equal columns while
|
|
14
|
+
* the room the pair is given is `from` pixels wide or more, one over the
|
|
15
|
+
* other in less, a hairline between them either way. Once side by side, it
|
|
16
|
+
* stacks only under `from` less a scrollbar's width, so a scrollbar the
|
|
17
|
+
* two columns bring cannot flip it back and forth. The room is the
|
|
18
|
+
* pair's own, measured as it resizes (`data-layout`: `side-by-side` or
|
|
19
|
+
* `stacked`), so a pane narrowed by its sidebar or a split stacks them
|
|
20
|
+
* though the window is wide. It is a layout alone: each part is a group
|
|
21
|
+
* named by its label, in the page's reading order (the first, then the
|
|
22
|
+
* second), and holds no cursor and answers no key; the rows inside follow
|
|
23
|
+
* whatever `RowCursorContext` is around them.
|
|
24
|
+
*/
|
|
25
|
+
export function SideBySide({ from, first, firstLabel, second, secondLabel }) {
|
|
26
|
+
const ref = useRef(null);
|
|
27
|
+
const [sideBySide, setSideBySide] = useState(false);
|
|
28
|
+
// Measured before the first paint, so the pair never draws in the other
|
|
29
|
+
// layout first. A threshold a prop gives cannot reach a container query,
|
|
30
|
+
// whose conditions read no custom property, so the width is read here.
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
const element = ref.current;
|
|
33
|
+
if (element === null)
|
|
34
|
+
return undefined;
|
|
35
|
+
// A width of 0 is a page not laid out (held behind another tab), which keeps its layout.
|
|
36
|
+
const measure = () => {
|
|
37
|
+
const width = element.clientWidth;
|
|
38
|
+
if (width > 0)
|
|
39
|
+
setSideBySide((now) => width >= (now ? from - SCROLLBAR_HOLD : from));
|
|
40
|
+
};
|
|
41
|
+
measure();
|
|
42
|
+
// Optional: jsdom has no ResizeObserver.
|
|
43
|
+
if (typeof ResizeObserver === 'undefined')
|
|
44
|
+
return undefined;
|
|
45
|
+
const observer = new ResizeObserver(measure);
|
|
46
|
+
observer.observe(element);
|
|
47
|
+
return () => observer.disconnect();
|
|
48
|
+
}, [from]);
|
|
49
|
+
return (_jsxs("div", { className: "side-by-side", "data-layout": sideBySide ? 'side-by-side' : 'stacked', ref: ref, children: [_jsx("div", { "aria-label": firstLabel, className: "side-by-side-part", role: "group", children: first }), _jsx("div", { "aria-label": secondLabel, className: "side-by-side-part", role: "group", children: second })] }));
|
|
50
|
+
}
|
package/dist/frame/Tree.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LucideIcon } from 'lucide-react';
|
|
2
2
|
import { type KeyboardEvent, type ReactElement, type ReactNode, type Ref } from 'react';
|
|
3
|
-
import type
|
|
3
|
+
import { type RegionHandlers } from '../pane/Pane.js';
|
|
4
4
|
/** Props for {@link TreePane}. */
|
|
5
5
|
export interface TreePaneProps extends RegionHandlers {
|
|
6
6
|
/** The width the host keeps, in pixels; none takes `--sidebar-width` (240px). */
|
|
@@ -73,6 +73,12 @@ export interface TreeRowProps {
|
|
|
73
73
|
readonly onOpen?: () => void;
|
|
74
74
|
/** The row itself takes the focus: in the Tab order while it is the cursor row. */
|
|
75
75
|
readonly focusable?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The row adds one under its parent ("Add runtime…"): an accent plus in
|
|
78
|
+
* the glyph's slot unless `glyph` gives another, and dim words that turn
|
|
79
|
+
* full under the pointer and on the cursor row, as a listing's add row.
|
|
80
|
+
*/
|
|
81
|
+
readonly add?: boolean;
|
|
76
82
|
}
|
|
77
83
|
/**
|
|
78
84
|
* One row of a sidebar's tree: the chevron's slot, the glyph, the name (cut
|
|
@@ -83,7 +89,7 @@ export interface TreeRowProps {
|
|
|
83
89
|
* the cursor there. Its controls leave the Tab order, since the tree's keys
|
|
84
90
|
* run them. The expansion and its keys stay the host's.
|
|
85
91
|
*/
|
|
86
|
-
export declare function TreeRow({ rowKey, level, kind, toggle, glyph, name, detail, trailing, tool, marked, onOpen, focusable }: TreeRowProps): ReactElement;
|
|
92
|
+
export declare function TreeRow({ rowKey, level, kind, toggle, glyph, name, detail, trailing, tool, marked, onOpen, focusable, add }: TreeRowProps): ReactElement;
|
|
87
93
|
/**
|
|
88
94
|
* What a tree's tool row is: a plain tool (a filter field, a pager, an Add
|
|
89
95
|
* action), a note under a node (past the chevron's slot), a heading over a
|
package/dist/frame/Tree.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Plus } from 'lucide-react';
|
|
2
3
|
import { createContext, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useSyncExternalStore } from 'react';
|
|
3
4
|
import { ICON_MD } from '../icon/sizes.js';
|
|
4
5
|
import { RowCursorContext } from '../listing/Listing.js';
|
|
6
|
+
import { regionHandlers } from '../pane/Pane.js';
|
|
5
7
|
import { InListingRowContext, InRowContext } from '../pane/PaneActions.js';
|
|
6
8
|
import { cutTooltip } from '../tooltip/Tooltip.logic.js';
|
|
7
9
|
import { useSharedRef } from './sharedRef.js';
|
|
@@ -17,7 +19,7 @@ const levelStyle = (level) => level > 0 ? { '--tree-level': level } : undefined;
|
|
|
17
19
|
* its path bar takes a line for each.
|
|
18
20
|
*/
|
|
19
21
|
export function TreePane({ width, active = false, label, ref, children, ...handlers }) {
|
|
20
|
-
return (_jsx("aside", { "aria-label": label, className: active ? 'pane tree-pane active' : 'pane tree-pane', ref: ref, style: width === undefined ? undefined : { width }, ...handlers, children: children }));
|
|
22
|
+
return (_jsx("aside", { "aria-label": label, className: active ? 'pane tree-pane active' : 'pane tree-pane', ref: ref, style: width === undefined ? undefined : { width }, ...regionHandlers(handlers), children: children }));
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* The tree's rows in the sidebar's scrolling list: the sidebar's home
|
|
@@ -76,7 +78,7 @@ export function TreeList({ label, ref, children, ...handlers }) {
|
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
}), [tree]);
|
|
79
|
-
return (_jsx("div", { "aria-label": label, className: "pane-list tree", "data-pane-home": "sidebar", ref: attach, role: "tree", tabIndex: -1, ...handlers, children: _jsx(TreeIdContext.Provider, { value: scope, children: children }) }));
|
|
81
|
+
return (_jsx("div", { "aria-label": label, className: "pane-list tree", "data-pane-home": "sidebar", ref: attach, role: "tree", tabIndex: -1, ...regionHandlers(handlers), children: _jsx(TreeIdContext.Provider, { value: scope, children: children }) }));
|
|
80
82
|
}
|
|
81
83
|
/**
|
|
82
84
|
* One row of a sidebar's tree: the chevron's slot, the glyph, the name (cut
|
|
@@ -87,7 +89,7 @@ export function TreeList({ label, ref, children, ...handlers }) {
|
|
|
87
89
|
* the cursor there. Its controls leave the Tab order, since the tree's keys
|
|
88
90
|
* run them. The expansion and its keys stay the host's.
|
|
89
91
|
*/
|
|
90
|
-
export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name, detail, trailing, tool, marked = false, onOpen, focusable = false }) {
|
|
92
|
+
export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name, detail, trailing, tool, marked = false, onOpen, focusable = false, add = false }) {
|
|
91
93
|
const cursor = useContext(RowCursorContext);
|
|
92
94
|
const tree = useContext(TreeIdContext);
|
|
93
95
|
const current = useSyncExternalStore(cursor.subscribe, () => cursor.current() === rowKey);
|
|
@@ -104,14 +106,15 @@ export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name,
|
|
|
104
106
|
kind === 'band' ? 'tree-band' : '',
|
|
105
107
|
kind === 'group' ? 'tree-group' : '',
|
|
106
108
|
current ? 'cursor' : '',
|
|
107
|
-
marked ? 'marked' : ''
|
|
109
|
+
marked ? 'marked' : '',
|
|
110
|
+
add ? 'pane-add' : ''
|
|
108
111
|
]
|
|
109
112
|
.filter(Boolean)
|
|
110
113
|
.join(' ');
|
|
111
114
|
return (_jsx(InListingRowContext.Provider, { value: true, children: _jsx(InRowContext.Provider, { value: true, children: _jsxs("div", { "aria-current": current ? 'true' : undefined, "aria-expanded": toggle === undefined ? undefined : toggle.open, "aria-level": level + 1, "aria-selected": marked, className: classes, "data-row-key": rowKey, id: tree === null ? undefined : rowId(tree.id, rowKey), onClick: onOpen, onFocus: () => cursor.point(rowKey), onPointerMove: () => {
|
|
112
115
|
if (!current)
|
|
113
116
|
cursor.point(rowKey);
|
|
114
|
-
}, role: "treeitem", style: levelStyle(level), tabIndex: focusable ? (current ? 0 : -1) : undefined, children: [toggle === undefined ? (_jsx("span", { "aria-hidden": true, className: "row-icon" })) : (_jsx(TreeToggle, { label: toggle.label, onToggle: toggle.onToggle, open: toggle.open })), _jsx("span", { "aria-hidden": true, className: "tree-glyph", children: glyph }), _jsxs("span", { className: "row-name tree-name", ...(typeof name === 'string' && detail === undefined ? cutTooltip(name) : {}), children: [name, detail === undefined ? null : (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "tree-detail", children: detail })] }))] }), _jsxs("span", { className: "row-meta align-right", children: [trailing, tool === undefined ? null : _jsx("span", { className: "tree-row-tool", children: tool })] })] }) }) }));
|
|
117
|
+
}, role: "treeitem", style: levelStyle(level), tabIndex: focusable ? (current ? 0 : -1) : undefined, children: [toggle === undefined ? (_jsx("span", { "aria-hidden": true, className: "row-icon" })) : (_jsx(TreeToggle, { label: toggle.label, onToggle: toggle.onToggle, open: toggle.open })), _jsx("span", { "aria-hidden": true, className: "tree-glyph", children: glyph === undefined && add ? _jsx(Plus, { size: ICON_MD }) : glyph }), _jsxs("span", { className: "row-name tree-name", ...(typeof name === 'string' && detail === undefined ? cutTooltip(name) : {}), children: [name, detail === undefined ? null : (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "tree-detail", children: detail })] }))] }), _jsxs("span", { className: "row-meta align-right", children: [trailing, tool === undefined ? null : _jsx("span", { className: "tree-row-tool", children: tool })] })] }) }) }));
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
117
120
|
* A row of a tree that is not a node, at its level's indent in the small
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode, Ref } from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type RegionHandlers } from '../pane/Pane.js';
|
|
3
3
|
/** Whether a slot was given something to draw: idiomatic `cond && <Part />` passes false for none. */
|
|
4
4
|
export declare const drawn: (node: ReactNode) => boolean;
|
|
5
5
|
/**
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ListingScopeContext } from '../listing/ListingScope.js';
|
|
3
|
+
import { regionHandlers } from '../pane/Pane.js';
|
|
2
4
|
/** Whether a slot was given something to draw: idiomatic `cond && <Part />` passes false for none. */
|
|
3
5
|
export const drawn = (node) => node !== null && node !== undefined && node !== false && node !== '';
|
|
4
6
|
/**
|
|
@@ -15,5 +17,5 @@ export const drawn = (node) => node !== null && node !== undefined && node !== f
|
|
|
15
17
|
export function WindowFrame({ brand, sidebar = null, resizer = null, sidebarWidth, main, tray = null, dock = null, legend = null, trailing = null, group }) {
|
|
16
18
|
const shown = drawn(sidebar);
|
|
17
19
|
const parts = (_jsxs(_Fragment, { children: [shown ? _jsx("div", { className: "window-frame-slot window-frame-sidebar", children: sidebar }) : null, shown ? resizer : null, _jsx("div", { className: "window-frame-slot window-frame-main", children: main }), drawn(tray) ? _jsx("div", { className: "window-frame-slot window-frame-tray", children: tray }) : null, drawn(dock) ? _jsx("div", { className: "window-frame-slot window-frame-dock", children: dock }) : null] }));
|
|
18
|
-
return (_jsxs("div", { className: "window-frame space-root listing-root", "data-sidebar": shown ? 'shown' : 'hidden', style: { '--window-band-width': `${sidebarWidth}px` }, children: [_jsxs("div", { className: "window-frame-band", children: [_jsx("div", { className: "window-frame-band-lead", children: brand }), _jsx("span", { "aria-hidden": true, className: "window-frame-band-rest" }), drawn(trailing) ? _jsx("div", { className: "shell-trailing", children: trailing }) : null] }), group === undefined ? (parts) : (_jsx("div", { className: "window-frame-group", ...group, children: parts })), drawn(legend) ? _jsx("div", { className: "window-frame-legend", children: legend }) : null] }));
|
|
20
|
+
return (_jsx(ListingScopeContext, { value: true, children: _jsxs("div", { className: "window-frame space-root listing-root", "data-sidebar": shown ? 'shown' : 'hidden', style: { '--window-band-width': `${sidebarWidth}px` }, children: [_jsxs("div", { className: "window-frame-band", children: [_jsx("div", { className: "window-frame-band-lead", children: brand }), _jsx("span", { "aria-hidden": true, className: "window-frame-band-rest" }), drawn(trailing) ? _jsx("div", { className: "shell-trailing", children: trailing }) : null] }), group === undefined ? (parts) : (_jsx("div", { className: "window-frame-group", ...regionHandlers(group), children: parts })), drawn(legend) ? _jsx("div", { className: "window-frame-legend", children: legend }) : null] }) }));
|
|
19
21
|
}
|
package/dist/frame/frame.css
CHANGED
|
@@ -341,7 +341,9 @@
|
|
|
341
341
|
--row-fill: var(--strip);
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
/* The disclosure chevron in a row's first column (`TreeToggle`)
|
|
344
|
+
/* The disclosure chevron in a row's first column (`TreeToggle`), in the
|
|
345
|
+
rows' dim icon tone (a row's words may be darker). One class, so the
|
|
346
|
+
cursor, mark, selection, and hover tones over a row's icon still win. */
|
|
345
347
|
.tree-chev {
|
|
346
348
|
display: inline-flex;
|
|
347
349
|
align-items: center;
|
|
@@ -350,7 +352,7 @@
|
|
|
350
352
|
border: 0;
|
|
351
353
|
border-radius: var(--radius-xs);
|
|
352
354
|
background: none;
|
|
353
|
-
color:
|
|
355
|
+
color: var(--text-dim);
|
|
354
356
|
}
|
|
355
357
|
|
|
356
358
|
.tree-chev:hover {
|
|
@@ -385,8 +387,10 @@
|
|
|
385
387
|
color: var(--row-meta-text);
|
|
386
388
|
}
|
|
387
389
|
|
|
388
|
-
/* On a cursor or marked row the quiet words take the surface's text
|
|
389
|
-
|
|
390
|
+
/* On a cursor or marked row the quiet words take the surface's text, and
|
|
391
|
+
the glyph too but on an add row, which keeps its accent plus. */
|
|
392
|
+
.row:is(.cursor, .marked):where(:not(.selected)) .tree-detail,
|
|
393
|
+
.row:is(.cursor, .marked):where(:not(.selected, .pane-add)) .tree-glyph,
|
|
390
394
|
.tree-tool.cursor,
|
|
391
395
|
.tree-tool.cursor .tree-note-glyph {
|
|
392
396
|
color: var(--text-on-surface);
|
|
@@ -462,6 +466,14 @@
|
|
|
462
466
|
);
|
|
463
467
|
}
|
|
464
468
|
|
|
469
|
+
/* A tree note that is also a listing's empty line (`.pane-message.empty`,
|
|
470
|
+
"No tables") keeps the tree's size and padding, which that two-class
|
|
471
|
+
rule would otherwise replace with the rows' size and no padding. */
|
|
472
|
+
.tree-tool.pane-message.empty {
|
|
473
|
+
padding-block: var(--space-1);
|
|
474
|
+
font-size: var(--font-size-small);
|
|
475
|
+
}
|
|
476
|
+
|
|
465
477
|
/* A heading over a group of rows further down the tree. */
|
|
466
478
|
.tree-tool.tree-heading {
|
|
467
479
|
margin-top: var(--space-3);
|
|
@@ -505,19 +517,46 @@
|
|
|
505
517
|
text-overflow: ellipsis;
|
|
506
518
|
}
|
|
507
519
|
|
|
520
|
+
/* Its row's underline shows the focus, so no field ring: two classes'
|
|
521
|
+
weight, past the base stylesheet's ring, which comes later. Forced
|
|
522
|
+
colours draw no shadow, so there the underline is gone and the ring
|
|
523
|
+
stays. */
|
|
524
|
+
@media (forced-colors: none) {
|
|
525
|
+
.tree-filter-input:focus-visible {
|
|
526
|
+
outline: 0;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
508
530
|
/* ---- A pane's quick row ---- */
|
|
509
531
|
|
|
510
532
|
/* A row of quiet buttons under a pane's path bar (FilterChips: the tree's
|
|
511
533
|
Running and Updates filters): each a word with its glyph and count, and
|
|
512
|
-
`aria-pressed="true"` while its filter is on.
|
|
534
|
+
`aria-pressed="true"` while its filter is on. It is one line: chips that
|
|
535
|
+
do not fit scroll sideways, with no scrollbar drawn, under the base
|
|
536
|
+
sheet's inline edge fade (.scroll-fade-x, on the element), which leaves
|
|
537
|
+
the rule under the row solid. The block padding is the room a chip's
|
|
538
|
+
focus ring needs inside the scroller. Nothing scrolls smoothly (a wheel
|
|
539
|
+
and a chip reached by the keys move it at once), so reduced motion has
|
|
540
|
+
nothing to stop. */
|
|
513
541
|
.pane-quick-row {
|
|
514
542
|
display: flex;
|
|
515
543
|
gap: var(--space-2);
|
|
516
544
|
padding: var(--space-2) var(--pane-row-inset);
|
|
517
545
|
border-bottom: var(--line) solid var(--border);
|
|
546
|
+
overflow-x: auto;
|
|
547
|
+
overflow-y: hidden;
|
|
548
|
+
scroll-behavior: auto;
|
|
549
|
+
/* A chip the keys bring into view stops clear of the edge fade and with
|
|
550
|
+
room for its focus ring. */
|
|
551
|
+
scroll-padding-inline: calc(
|
|
552
|
+
var(--scroll-fade-size, var(--space-6)) + var(--focus-ring-width) + var(--focus-offset)
|
|
553
|
+
);
|
|
554
|
+
scrollbar-width: none;
|
|
518
555
|
}
|
|
519
556
|
|
|
520
557
|
.pane-quick-button {
|
|
558
|
+
flex: none;
|
|
559
|
+
white-space: nowrap;
|
|
521
560
|
display: inline-flex;
|
|
522
561
|
align-items: center;
|
|
523
562
|
gap: var(--space-2);
|
|
@@ -759,6 +798,36 @@
|
|
|
759
798
|
margin: var(--space-4) var(--pane-row-inset) var(--space-2);
|
|
760
799
|
}
|
|
761
800
|
|
|
801
|
+
/* Two of a page's listings or sections (SideBySide): one over the other
|
|
802
|
+
until the pair's own room reaches its threshold, then in two equal
|
|
803
|
+
columns; the component measures the room and says which in
|
|
804
|
+
data-layout. A hairline parts them, under the first stacked and after
|
|
805
|
+
it side by side, where the first stretches to the taller one's height so
|
|
806
|
+
the line runs the pair's whole height. */
|
|
807
|
+
.side-by-side {
|
|
808
|
+
display: grid;
|
|
809
|
+
grid-template-columns: minmax(0, 1fr);
|
|
810
|
+
align-items: start;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.side-by-side[data-layout='side-by-side'] {
|
|
814
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
.side-by-side-part {
|
|
818
|
+
min-width: 0;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
.side-by-side-part:first-child {
|
|
822
|
+
border-block-end: var(--line) solid var(--border);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
.side-by-side[data-layout='side-by-side'] > .side-by-side-part:first-child {
|
|
826
|
+
align-self: stretch;
|
|
827
|
+
border-block-end: none;
|
|
828
|
+
border-inline-end: var(--line) solid var(--border);
|
|
829
|
+
}
|
|
830
|
+
|
|
762
831
|
/* A bar at a pane's foot, under its list: a select-all bar, a form's
|
|
763
832
|
actions. */
|
|
764
833
|
.pane-foot-bar {
|
package/dist/frame/index.d.ts
CHANGED
|
@@ -7,14 +7,16 @@
|
|
|
7
7
|
* and its `PaneWarning`, a pane status line's `StatusNotice`, the `Dock`
|
|
8
8
|
* with its log and input, the splitter between a list and the pane under
|
|
9
9
|
* it (`usePaneSplit`, `PaneSplitter`, `SplitDetail`), and a page's parts
|
|
10
|
-
* (`PageSlot`, `PanePage`, `Toolbar`, `PageNote`, `SectionHead`,
|
|
11
|
-
* rest). Their look is `frame.css` in
|
|
10
|
+
* (`PageSlot`, `PanePage`, `Toolbar`, `PageNote`, `SectionHead`,
|
|
11
|
+
* `SideBySide`, and the rest). Their look is `frame.css` in
|
|
12
|
+
* `@bigpixelrocket/uiok/styles.css`.
|
|
12
13
|
*/
|
|
13
14
|
export { AppRoot, PageSlot, SpacePanel, type AppRootProps, type PageSlotProps, type SpacePanelProps } from './AppRoot.js';
|
|
14
15
|
export { Dock, dockHeight, DockInput, DockLog, DockLogEntry, type DockInputProps, type DockLogEntryProps, type DockLogProps, type DockProps } from './Dock.js';
|
|
15
16
|
export { FilterChips, type FilterChip, type FilterChipsProps } from './FilterChips.js';
|
|
16
17
|
export { EmptyAction, FootBar, PageFilter, PageNote, PanePage, PaneWarning, SectionHead, ShowSidebarButton, Toolbar, ToolbarGap, ToolbarGrow, type PageNoteProps, type PagePartProps, type SectionHeadProps, type ShowSidebarButtonProps, type ToolbarProps } from './PageParts.js';
|
|
17
18
|
export { cutRowDepth, heldSplitHeight, PaneSplitter, SplitDetail, usePaneSplit, type PaneSplit, type PaneSplitterProps, type SplitDetailProps } from './PaneSplit.js';
|
|
19
|
+
export { SideBySide, type SideBySideProps } from './SideBySide.js';
|
|
18
20
|
export { draggedWidth, SidebarResizer, type SidebarResizerProps } from './SidebarResizer.js';
|
|
19
21
|
export { StatusNotice, type StatusNoticeProps, type StatusNoticeTone } from './StatusNotice.js';
|
|
20
22
|
export { SidebarEmpty, TreeFilterInput, TreeList, TreePane, TreeRow, TreeTool, type SidebarEmptyProps, type TreeFilterInputProps, type TreeListProps, type TreePaneProps, type TreeRowKind, type TreeRowProps, type TreeRowToggle, type TreeToolKind, type TreeToolProps } from './Tree.js';
|
package/dist/frame/index.js
CHANGED
|
@@ -7,14 +7,16 @@
|
|
|
7
7
|
* and its `PaneWarning`, a pane status line's `StatusNotice`, the `Dock`
|
|
8
8
|
* with its log and input, the splitter between a list and the pane under
|
|
9
9
|
* it (`usePaneSplit`, `PaneSplitter`, `SplitDetail`), and a page's parts
|
|
10
|
-
* (`PageSlot`, `PanePage`, `Toolbar`, `PageNote`, `SectionHead`,
|
|
11
|
-
* rest). Their look is `frame.css` in
|
|
10
|
+
* (`PageSlot`, `PanePage`, `Toolbar`, `PageNote`, `SectionHead`,
|
|
11
|
+
* `SideBySide`, and the rest). Their look is `frame.css` in
|
|
12
|
+
* `@bigpixelrocket/uiok/styles.css`.
|
|
12
13
|
*/
|
|
13
14
|
export { AppRoot, PageSlot, SpacePanel } from './AppRoot.js';
|
|
14
15
|
export { Dock, dockHeight, DockInput, DockLog, DockLogEntry } from './Dock.js';
|
|
15
16
|
export { FilterChips } from './FilterChips.js';
|
|
16
17
|
export { EmptyAction, FootBar, PageFilter, PageNote, PanePage, PaneWarning, SectionHead, ShowSidebarButton, Toolbar, ToolbarGap, ToolbarGrow } from './PageParts.js';
|
|
17
18
|
export { cutRowDepth, heldSplitHeight, PaneSplitter, SplitDetail, usePaneSplit } from './PaneSplit.js';
|
|
19
|
+
export { SideBySide } from './SideBySide.js';
|
|
18
20
|
export { draggedWidth, SidebarResizer } from './SidebarResizer.js';
|
|
19
21
|
export { StatusNotice } from './StatusNotice.js';
|
|
20
22
|
export { SidebarEmpty, TreeFilterInput, TreeList, TreePane, TreeRow, TreeTool } from './Tree.js';
|
package/dist/grid/grid.css
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* A product's brand mark as data: what the app knows about a product (a
|
|
5
|
+
* language, a database, a tool) and hands the library to draw. The library
|
|
6
|
+
* ships no marks and no brand colours of its own.
|
|
7
|
+
*/
|
|
8
|
+
export interface ProductMarkShape {
|
|
9
|
+
/** The product's name: the mark's tooltip, and its accessible name where it stands alone. */
|
|
10
|
+
readonly title: string;
|
|
11
|
+
/** The mark's path data, on a 24-unit square (`viewBox` changes the part shown). */
|
|
12
|
+
readonly path: string;
|
|
13
|
+
/**
|
|
14
|
+
* The brand's colour as a CSS colour (`#777bb4`), or `currentColor` for a
|
|
15
|
+
* mark published in plain black, which then follows the quiet icon tone.
|
|
16
|
+
* The theme decides how much of it shows (`--product-mark-mix`).
|
|
17
|
+
*/
|
|
18
|
+
readonly colour: string;
|
|
19
|
+
/**
|
|
20
|
+
* The part of the artwork to show, when a published mark pairs a symbol
|
|
21
|
+
* with a wordmark that would not read at glyph size; `0 0 24 24` when
|
|
22
|
+
* absent.
|
|
23
|
+
*/
|
|
24
|
+
readonly viewBox?: string;
|
|
25
|
+
/**
|
|
26
|
+
* An outline drawn round the shape in its own colour, in viewBox units,
|
|
27
|
+
* for a mark published in lines too fine to read at row size.
|
|
28
|
+
*/
|
|
29
|
+
readonly stroke?: number;
|
|
30
|
+
}
|
|
31
|
+
/** Props for {@link ProductMark}. */
|
|
32
|
+
export interface ProductMarkProps {
|
|
33
|
+
/** The product's mark; null or absent draws `fallback` instead. */
|
|
34
|
+
readonly mark?: ProductMarkShape | null;
|
|
35
|
+
/**
|
|
36
|
+
* The glyph drawn when there is no mark (a database's, a terminal's), in
|
|
37
|
+
* the quiet icon tone at the icon size.
|
|
38
|
+
*/
|
|
39
|
+
readonly fallback?: LucideIcon;
|
|
40
|
+
/**
|
|
41
|
+
* The mark's name for assistive technology, for a mark that stands alone;
|
|
42
|
+
* absent, the mark is decorative, since the name beside it says it.
|
|
43
|
+
*/
|
|
44
|
+
readonly label?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A product's mark beside its name (a row's icon, a crumb, a palette's
|
|
48
|
+
* option): the brand's path in the brand's colour, mixed toward the text
|
|
49
|
+
* tone as far as the theme asks (`--product-mark-mix`: none in a light
|
|
50
|
+
* theme, some in a dark one, where a dark brand colour would sink), at the
|
|
51
|
+
* icon size (`--icon-md`), with the product's name as its tooltip. With
|
|
52
|
+
* no mark it draws `fallback`, a lucide glyph in the quiet icon tone, or
|
|
53
|
+
* nothing. The app owns the marks and their colours and passes one in, so
|
|
54
|
+
* the library stays free of any product list. Draws `.product-mark`
|
|
55
|
+
* (`.glyph` for a fallback), with `--product-mark-colour`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function ProductMark({ mark, fallback: Fallback, label }: ProductMarkProps): ReactElement;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
3
|
+
import { ICON_MD } from './sizes.js';
|
|
4
|
+
/**
|
|
5
|
+
* A product's mark beside its name (a row's icon, a crumb, a palette's
|
|
6
|
+
* option): the brand's path in the brand's colour, mixed toward the text
|
|
7
|
+
* tone as far as the theme asks (`--product-mark-mix`: none in a light
|
|
8
|
+
* theme, some in a dark one, where a dark brand colour would sink), at the
|
|
9
|
+
* icon size (`--icon-md`), with the product's name as its tooltip. With
|
|
10
|
+
* no mark it draws `fallback`, a lucide glyph in the quiet icon tone, or
|
|
11
|
+
* nothing. The app owns the marks and their colours and passes one in, so
|
|
12
|
+
* the library stays free of any product list. Draws `.product-mark`
|
|
13
|
+
* (`.glyph` for a fallback), with `--product-mark-colour`.
|
|
14
|
+
*/
|
|
15
|
+
export function ProductMark({ mark = null, fallback: Fallback, label }) {
|
|
16
|
+
const naming = label === undefined
|
|
17
|
+
? { 'aria-hidden': true }
|
|
18
|
+
: { 'aria-label': label, role: 'img' };
|
|
19
|
+
if (mark === null) {
|
|
20
|
+
return (_jsx("span", { className: "product-mark glyph", ...naming, ...(label === undefined ? {} : tooltip(label)), children: Fallback === undefined ? null : _jsx(Fallback, { "aria-hidden": true, size: ICON_MD }) }));
|
|
21
|
+
}
|
|
22
|
+
return (_jsx("span", { className: "product-mark", style: {
|
|
23
|
+
'--product-mark-colour': mark.colour,
|
|
24
|
+
...(mark.stroke === undefined ? {} : { '--product-mark-stroke': mark.stroke })
|
|
25
|
+
}, ...naming, ...tooltip(label ?? mark.title), children: _jsx("svg", { "aria-hidden": true, viewBox: mark.viewBox ?? '0 0 24 24', children: _jsx("path", { className: mark.stroke === undefined ? undefined : 'product-mark-outline', d: mark.path }) }) }));
|
|
26
|
+
}
|