@bigpixelrocket/uiok 0.2.2 → 0.2.3

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/dist/button/TextLink.d.ts +27 -0
  3. package/dist/button/TextLink.js +15 -0
  4. package/dist/button/button.css +48 -0
  5. package/dist/button/index.d.ts +2 -1
  6. package/dist/button/index.js +2 -1
  7. package/dist/dialog/ConfirmDialog.d.ts +7 -1
  8. package/dist/dialog/ConfirmDialog.js +9 -4
  9. package/dist/dialog/DialogLists.d.ts +8 -1
  10. package/dist/dialog/DialogLists.js +3 -2
  11. package/dist/field/field.css +110 -2
  12. package/dist/filter/filter.css +16 -0
  13. package/dist/grid/DataGrid.d.ts +10 -2
  14. package/dist/grid/DataGrid.js +47 -13
  15. package/dist/grid/DataGrid.logic.d.ts +16 -0
  16. package/dist/grid/DataGrid.logic.js +28 -0
  17. package/dist/grid/grid.css +128 -4
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +1 -0
  20. package/dist/labels/UiokLabels.d.ts +3 -0
  21. package/dist/labels/UiokLabels.js +3 -1
  22. package/dist/labels/index.d.ts +1 -0
  23. package/dist/labels/index.js +1 -0
  24. package/dist/labels/keys.js +2 -0
  25. package/dist/labels/paneTabs.d.ts +27 -0
  26. package/dist/labels/paneTabs.js +10 -0
  27. package/dist/labels/selectAll.d.ts +4 -1
  28. package/dist/labels/selectAll.js +1 -1
  29. package/dist/legend/KeyLegendStrip.d.ts +9 -1
  30. package/dist/legend/KeyLegendStrip.js +119 -5
  31. package/dist/legend/legend.css +52 -0
  32. package/dist/listing/Listing.d.ts +23 -5
  33. package/dist/listing/Listing.js +11 -8
  34. package/dist/listing/listing.css +106 -3
  35. package/dist/pane/PaneActions.d.ts +3 -1
  36. package/dist/pane/PaneActions.js +6 -5
  37. package/dist/pane/PaneTabs.d.ts +92 -0
  38. package/dist/pane/PaneTabs.js +326 -0
  39. package/dist/pane/PaneTabs.logic.d.ts +97 -0
  40. package/dist/pane/PaneTabs.logic.js +158 -0
  41. package/dist/pane/index.d.ts +5 -1
  42. package/dist/pane/index.js +5 -1
  43. package/dist/pane/panetabs.css +408 -0
  44. package/dist/pane/useTabDrag.d.ts +49 -0
  45. package/dist/pane/useTabDrag.js +306 -0
  46. package/dist/segmented/SegmentedChoice.d.ts +8 -1
  47. package/dist/segmented/SegmentedChoice.js +7 -4
  48. package/dist/styles.css +8 -0
  49. package/dist/surface/GroupSwatch.d.ts +22 -0
  50. package/dist/surface/GroupSwatch.js +15 -0
  51. package/dist/surface/Tag.d.ts +26 -0
  52. package/dist/surface/Tag.js +12 -0
  53. package/dist/surface/index.d.ts +7 -0
  54. package/dist/surface/index.js +7 -0
  55. package/dist/surface/surface.css +116 -1
  56. package/dist/themes/tokens.js +12 -1
  57. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -6,6 +6,41 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.3] - 2026-11-22
10
+
11
+ ### Added
12
+
13
+ - `PaneTabs` (`@bigpixelrocket/uiok/pane`), the tab strip a pane hangs from: pinned, following (italic), dirty, picked, and danger-toned tabs, a mark slot and a context before the name, a pin rule, New Tab, and the strip's empty end (a double-click opens a tab). Tabs behind the front one shrink to a floor, then fold into a "+N" count with a "Folded here" menu; pinned, front, and following tabs never fold. A press brings a tab to the front and may drag it (4px slop) within its side of the pin rule, carrying any picks; Escape puts every tab back and `onReorder` gets the full order. ⌘-click and ⇧-click pick tabs (`onPick`), a middle-click closes, a double-click keeps (`onKeep`).
14
+ - Pure helpers for a host's tab state and the strip's rules: `togglePick`, `pickRun`, `pickedTabs`, `gatherTabs`, `foldOrder`, `foldsNeeded`, `tabLabelFloor`, `draggedTabOrder`.
15
+ - The `paneTabs` label group (`PaneTabsLabels`, `DEFAULT_PANE_TABS_LABELS`).
16
+ - `.pane[data-tone='danger']`: a pane's frame and its front tab's outline in `--danger`, at rest, active, and in an inactive window.
17
+ - `GroupSwatch` and `Tag` (`@bigpixelrocket/uiok/surface`, a new area): a group's colour as a filled or hollow square, and a small worded tag in a neutral, accent, ready, warning, or danger tone.
18
+ - `DataGridProps.pinnedColumns`: leading columns stay in view while the grid scrolls sideways, with a hairline at the pin edge; a column reorder never crosses it.
19
+ - The grid cell class `cell-removed`: struck out on the danger wash, for a row a save will delete.
20
+ - Field looks: `.field.value-null`, the `.field-editor` frame round a foreign editor (hover, focus, invalid, read-only, changed), and `.field-columns` with `--field-columns` for a check group in columns.
21
+ - `ListingColumn.tip`, the `info` state tone, `StateMarkProps.tip`, `RowProps.level` (an indent for a tree or a plan), the row classes `row-changed`, `row-removed`, and `drop-target`, `.row-meta.value-null`, and `.pane-message.warning`.
22
+ - `KeyLegendStripProps.overflow`: `'more'` folds the places that do not fit into a "+N" chip whose list names each folded verb with its chord and runs the one chosen. `'drop'`, the default, keeps today's behaviour.
23
+ - `TextLink` (`@bigpixelrocket/uiok/button`): a link in words, with an optional glyph, the code face, a tooltip, and a chord.
24
+ - `ConfirmDialogProps.confirmDisabled`: holds the primary off and its key inert, for a typed-name confirmation.
25
+ - `DialogStatementsProps.count` (also through `ConfirmDialog` `statements`): a host's own count words in place of the line count, or none.
26
+ - `SegmentedChoiceProps.disabled`: holds the whole choice while it cannot change.
27
+ - `RowIconActionProps.shortcut`: the chord written after the words in its tooltip.
28
+ - The invalid filter field look (an `aria-invalid="true"` input draws a danger edge and focus ring), `.overline.keep-case`, and `.notice code` in the code face.
29
+ - The `Delete` key's name and ⌦ glyph in the `keys` labels.
30
+ - `docs/tokens.md`: italic also marks a tab whose place is not fixed yet (a following tab).
31
+
32
+ ### Changed
33
+
34
+ - Every single place in `KeyLegendStrip` has a tooltip naming its verb and chord, as a paired cap's does.
35
+ - Arrow, Home, and End moves in `DataGrid` scroll the cursor's column into view sideways.
36
+
37
+ ### Fixed
38
+
39
+ - `SelectAllBar`'s default count uses thousands separators ("1,000 of 20,000 selected").
40
+ - A chosen option in a `select.field` list box (`multiple` or `size`) is no longer painted away.
41
+ - A failed `.pane-empty[role=alert]` draws its glyph in `--danger`.
42
+ - A `.notice` inside `.pane-summary` is cut with an ellipsis instead of wrapping.
43
+
9
44
  ## [0.2.2] - 2026-11-20
10
45
 
11
46
  ### Added
@@ -165,7 +200,8 @@ The first published version. The package is published to npm as `@bigpixelrocket
165
200
  - `lucide-react` 1.31 or later within 1.x is a peer dependency.
166
201
  - Terminal (`@bigpixelrocket/uiok/terminal`, `docs/components/terminal.md`): `Terminal`, Ghostty's VT engine as WebAssembly drawn on a canvas, read-only without `onInput`, with a Copy and Paste menu whose chords come from `menuChords`, a visual bell, line-editing actions bound by `actionForKey`, and `TerminalScrollbackContext`. The package root does not export it, so an app without a terminal never loads its assets. Its words are the new `terminal` label group; the package now ships a `NOTICE` with the engine's, adapter's, and font's licences.
167
202
 
168
- [Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.2...HEAD
203
+ [Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.3...HEAD
204
+ [0.2.3]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.2...v0.2.3
169
205
  [0.2.2]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.1...v0.2.2
170
206
  [0.2.1]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.0...v0.2.1
171
207
  [0.2.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.4...v0.2.0
@@ -0,0 +1,27 @@
1
+ import type { LucideIcon } from 'lucide-react';
2
+ import type { ReactElement } from 'react';
3
+ /** Props for {@link TextLink}. */
4
+ export interface TextLinkProps {
5
+ /** The link's words, which are also its accessible name: "DROP DATABASE in the manual". */
6
+ readonly children: string;
7
+ /** What it opens: the host opens the manual page, the place, or the window. */
8
+ readonly onClick: () => void;
9
+ /** A glyph before the words (a book for a manual page), at the small icon size. */
10
+ readonly icon?: LucideIcon;
11
+ /** Sets the words in the code face, for a name or value inside a sentence. */
12
+ readonly code?: boolean;
13
+ /** The tooltip, when it says more than the words (the page's address). */
14
+ readonly tip?: string;
15
+ /** The chord that opens it, as text, written after the tooltip's words. */
16
+ readonly shortcut?: string;
17
+ }
18
+ /**
19
+ * A link in words: a button that reads as a link inside a sentence, a
20
+ * section, or a status line, for a manual page or a place a sentence names.
21
+ * It wears the accent's text colour and underlines under the pointer; it
22
+ * takes the keyboard's focus with the shared ring. It is a button because
23
+ * the host decides how to open what it names (an external browser, a tab),
24
+ * so it never navigates the page itself. Styled by `.text-link` in
25
+ * `@bigpixelrocket/uiok/styles.css`.
26
+ */
27
+ export declare function TextLink({ children, onClick, icon: Icon, code, tip, shortcut }: TextLinkProps): ReactElement;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ICON_SM } from '../icon/sizes.js';
3
+ import { tooltip } from '../tooltip/Tooltip.logic.js';
4
+ /**
5
+ * A link in words: a button that reads as a link inside a sentence, a
6
+ * section, or a status line, for a manual page or a place a sentence names.
7
+ * It wears the accent's text colour and underlines under the pointer; it
8
+ * takes the keyboard's focus with the shared ring. It is a button because
9
+ * the host decides how to open what it names (an external browser, a tab),
10
+ * so it never navigates the page itself. Styled by `.text-link` in
11
+ * `@bigpixelrocket/uiok/styles.css`.
12
+ */
13
+ export function TextLink({ children, onClick, icon: Icon, code = false, tip, shortcut }) {
14
+ return (_jsxs("button", { className: code ? 'text-link code' : 'text-link', onClick: onClick, type: "button", ...(tip === undefined && shortcut === undefined ? {} : tooltip(tip ?? children, shortcut)), children: [Icon === undefined ? null : _jsx(Icon, { "aria-hidden": true, size: ICON_SM }), _jsx("span", { className: "text-link-words", children: children })] }));
15
+ }
@@ -261,3 +261,51 @@
261
261
  .disclosure:is(:hover, :focus-visible):not(:disabled) {
262
262
  color: var(--text);
263
263
  }
264
+
265
+ /* ---- Text link (TextLink) ----
266
+
267
+ A link in words inside running text: no bezel and no ground, the
268
+ accent's text colour, the words underlined under the pointer and while
269
+ held, and the shared focus ring. Its size and face follow the text round
270
+ it; `.code` sets the words in the code face for a name or value. A glyph
271
+ before the words takes the same colour. */
272
+ .text-link {
273
+ display: inline-flex;
274
+ align-items: baseline;
275
+ gap: var(--space-2);
276
+ max-width: 100%;
277
+ margin: 0;
278
+ padding: 0;
279
+ border: none;
280
+ border-radius: var(--radius-xs);
281
+ background: none;
282
+ color: var(--accent-text);
283
+ font: inherit;
284
+ text-align: start;
285
+ cursor: default;
286
+ }
287
+
288
+ .text-link > svg {
289
+ flex: none;
290
+ align-self: center;
291
+ }
292
+
293
+ .text-link-words {
294
+ min-width: 0;
295
+ overflow: hidden;
296
+ text-overflow: ellipsis;
297
+ text-decoration-thickness: var(--line);
298
+ text-underline-offset: var(--space-1);
299
+ }
300
+
301
+ .text-link.code .text-link-words {
302
+ font-family: var(--font-mono);
303
+ }
304
+
305
+ .text-link:is(:hover, :active):not(:disabled) .text-link-words {
306
+ text-decoration-line: underline;
307
+ }
308
+
309
+ .text-link:disabled {
310
+ color: var(--text-dim);
311
+ }
@@ -1,3 +1,4 @@
1
- /** Buttons: the text `Button` in three tiers and its icon-only sibling `IconButton`. */
1
+ /** Buttons: the text `Button` in three tiers, its icon-only sibling `IconButton`, and `TextLink`, a link in words. */
2
2
  export { Button, type ButtonProps, type ButtonSize, type ButtonVariant } from './Button.js';
3
3
  export { IconButton, type IconButtonProps } from './IconButton.js';
4
+ export { TextLink, type TextLinkProps } from './TextLink.js';
@@ -1,3 +1,4 @@
1
- /** Buttons: the text `Button` in three tiers and its icon-only sibling `IconButton`. */
1
+ /** Buttons: the text `Button` in three tiers, its icon-only sibling `IconButton`, and `TextLink`, a link in words. */
2
2
  export { Button } from './Button.js';
3
3
  export { IconButton } from './IconButton.js';
4
+ export { TextLink } from './TextLink.js';
@@ -98,6 +98,12 @@ export interface ConfirmDialogProps {
98
98
  * deletes anything for good.
99
99
  */
100
100
  readonly forGood?: boolean;
101
+ /**
102
+ * Holds the confirm verb off: its slot is disabled and its key runs
103
+ * nothing, until the caller lets it go (a typed-name confirmation keeps it
104
+ * off until the name in its field matches).
105
+ */
106
+ readonly confirmDisabled?: boolean;
101
107
  /** The confirm verb, on Return (or ⌥⌘⌫ with `forGood`) and its slot. */
102
108
  readonly onConfirm: () => void;
103
109
  /** Escape, the leave slot, and a press outside. */
@@ -119,4 +125,4 @@ export interface ConfirmDialogProps {
119
125
  * describe it. Styled by the `.confirm-dialog` rules in
120
126
  * `@bigpixelrocket/uiok/styles.css`; reads the `dialog` labels.
121
127
  */
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;
128
+ export declare function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone, items, itemIcon, itemCount, groups, statements, facts, paths, children, className, forGood, confirmDisabled, onConfirm, onCancel }: ConfirmDialogProps): ReactElement;
@@ -21,7 +21,7 @@ const DELETE_IMMEDIATELY = { key: 'Backspace', meta: true, alt: true };
21
21
  * describe it. Styled by the `.confirm-dialog` rules in
22
22
  * `@bigpixelrocket/uiok/styles.css`; reads the `dialog` labels.
23
23
  */
24
- export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone = 'danger', items, itemIcon, itemCount, groups = [], statements, facts = [], paths, children, className, forGood = false, onConfirm, onCancel }) {
24
+ export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone = 'danger', items, itemIcon, itemCount, groups = [], statements, facts = [], paths, children, className, forGood = false, confirmDisabled = false, onConfirm, onCancel }) {
25
25
  const labels = useLabels().dialog;
26
26
  const labelId = useId();
27
27
  const messageId = useId();
@@ -37,12 +37,17 @@ export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon,
37
37
  const legend = {
38
38
  leave: { label: cancelLabel ?? labels.cancel },
39
39
  primary: forGood
40
- ? { label: confirmLabel, chord: DELETE_IMMEDIATELY, onRun: onConfirm }
41
- : { label: confirmLabel, onRun: onConfirm }
40
+ ? {
41
+ label: confirmLabel,
42
+ chord: DELETE_IMMEDIATELY,
43
+ onRun: onConfirm,
44
+ disabled: confirmDisabled
45
+ }
46
+ : { label: confirmLabel, onRun: onConfirm, disabled: confirmDisabled }
42
47
  };
43
48
  return (_jsxs(ModalDialog, { className: ['confirm-dialog', hasItems || hasStatements ? 'confirm-items' : null, className]
44
49
  .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] }));
50
+ .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, ...(statements.count === undefined ? {} : { count: statements.count }) })), facts.length > 0 && _jsx(DialogFacts, { facts: facts, id: factsId }), children] }));
46
51
  }
47
52
  /**
48
53
  * A path as an item: its last part is the name, the folder that holds it
@@ -141,6 +141,13 @@ export interface DialogStatementsProps {
141
141
  readonly lines: readonly string[];
142
142
  /** The block's id, for a dialog that names it in its description. */
143
143
  readonly id?: string;
144
+ /**
145
+ * What the heading says beside the label in place of the line count: a
146
+ * host's own count ("1–100 of 101") for a block that is one page of a
147
+ * longer batch, or `null` for none, when the label already says it.
148
+ * Omitted, the block counts its lines.
149
+ */
150
+ readonly count?: string | null;
144
151
  }
145
152
  /**
146
153
  * The statements a confirmation runs (a batch of SQL), shown in full so
@@ -154,4 +161,4 @@ export interface DialogStatementsProps {
154
161
  * statement. Styled by the `.dialog-statements` rules in
155
162
  * `@bigpixelrocket/uiok/styles.css`.
156
163
  */
157
- export declare function DialogStatements({ label, lines, id }: DialogStatementsProps): ReactElement;
164
+ export declare function DialogStatements({ label, lines, id, count }: DialogStatementsProps): ReactElement;
@@ -131,7 +131,8 @@ function breakable(text) {
131
131
  * statement. Styled by the `.dialog-statements` rules in
132
132
  * `@bigpixelrocket/uiok/styles.css`.
133
133
  */
134
- export function DialogStatements({ label, lines, id }) {
134
+ export function DialogStatements({ label, lines, id, count }) {
135
135
  const labelId = useId();
136
- return (_jsxs("div", { className: "dialog-statements-block", id: id, children: [_jsxs("div", { className: "dialog-items-head", children: [_jsx("span", { className: "dialog-label", id: labelId, children: label }), _jsx("span", { className: "dialog-items-count", children: lines.length.toLocaleString() })] }), _jsx("div", { className: "dialog-statements-frame", children: _jsx("div", { "aria-labelledby": labelId, className: "dialog-statements scroll-fade", role: "region", tabIndex: 0, children: _jsx("ol", { children: lines.map((line, index) => (_jsx("li", { className: "dialog-statement", children: _jsx("code", { dir: "ltr", children: line }) }, `${index}:${line}`))) }) }) })] }));
136
+ const shownCount = count === undefined ? lines.length.toLocaleString() : count;
137
+ return (_jsxs("div", { className: "dialog-statements-block", id: id, children: [_jsxs("div", { className: "dialog-items-head", children: [_jsx("span", { className: "dialog-label", id: labelId, children: label }), shownCount === null ? null : _jsx("span", { className: "dialog-items-count", children: shownCount })] }), _jsx("div", { className: "dialog-statements-frame", children: _jsx("div", { "aria-labelledby": labelId, className: "dialog-statements scroll-fade", role: "region", tabIndex: 0, children: _jsx("ol", { children: lines.map((line, index) => (_jsx("li", { className: "dialog-statement", children: _jsx("code", { dir: "ltr", children: line }) }, `${index}:${line}`))) }) }) })] }));
137
138
  }
@@ -18,6 +18,9 @@
18
18
  focus edge.
19
19
  - .switch on a checkbox with role="switch": a pill track and its knob.
20
20
  - .range on an input of type range: a thin trough, its filled part, a knob.
21
+ - .field-editor on a container: the field's well round an editor the
22
+ page brings (a code editor), with its hover, focus edge, invalid,
23
+ read-only, and changed looks.
21
24
  - .field-label, .field-note, .field-problem: the words around a field,
22
25
  in the interface face; .field-group stacks them, .field-choice puts a
23
26
  check or switch beside its words, .field-grid lays label and value
@@ -164,14 +167,16 @@
164
167
  inset 0 1px 0 var(--well-shade);
165
168
  }
166
169
 
167
- .field[data-tone] {
170
+ .field[data-tone],
171
+ .field-editor[data-tone] {
168
172
  --field-tone-bar: var(--line-strong);
169
173
  }
170
174
 
171
175
  /* Right to left the bar stands on the right, the leading edge. The rule
172
176
  reads the dir attribute, as the listing's do: bundlers' CSS minifiers
173
177
  rewrite the direction pseudo-class into a list of languages. */
174
- .field[data-tone]:where([dir='rtl'] *, [dir='rtl']) {
178
+ .field[data-tone]:where([dir='rtl'] *, [dir='rtl']),
179
+ .field-editor[data-tone]:where([dir='rtl'] *, [dir='rtl']) {
175
180
  --field-tone-bar: calc(-1 * var(--line-strong));
176
181
  }
177
182
 
@@ -286,6 +291,96 @@ select.field option {
286
291
  color: var(--text);
287
292
  }
288
293
 
294
+ /* A list box's chosen rows, which the rule above would paint away: the
295
+ selection's colours while the list holds the keys, the quiet fill when
296
+ it does not (as a listing's selection goes quiet), and the fill with
297
+ quiet words when the list is off. A gradient, since a browser keeps its
298
+ own colour for a chosen option's background-color. */
299
+ select.field:is([multiple], [size]:not([size='1'])) option:checked {
300
+ background: linear-gradient(var(--selected-bg), var(--selected-bg));
301
+ color: var(--on-selected);
302
+ }
303
+
304
+ select.field:is([multiple], [size]:not([size='1'])):not(:focus) option:checked {
305
+ background: linear-gradient(var(--fill), var(--fill));
306
+ color: var(--text);
307
+ }
308
+
309
+ select.field:is([multiple], [size]:not([size='1'])):disabled option:checked {
310
+ background: linear-gradient(var(--fill), var(--fill));
311
+ color: var(--text-on-surface);
312
+ }
313
+
314
+ /* A field that holds no value (SQL NULL): its placeholder in the missing
315
+ value's look, dim italic, as a grid's NULL cell. */
316
+ .field.value-null::placeholder {
317
+ color: var(--text-dim);
318
+ font-style: italic;
319
+ }
320
+
321
+ /* -- A field's frame round an editor -- */
322
+
323
+ /* An editor the page brings (a code editor) that stands in a form as a
324
+ field does takes the field's well on its container: the outline,
325
+ corners, ground, and well shade, the hover lift, the accent focus edge
326
+ while anything inside holds the keys, the danger outline when invalid,
327
+ and the accent outline and bar of a changed value (data-tone="accent").
328
+ Read-only (.read-only) recesses the ground and draws no focus edge: the
329
+ value is there to read and copy. The editor fills the frame, which
330
+ clips it to the corners. */
331
+ .field-editor {
332
+ box-sizing: border-box;
333
+ min-width: 0;
334
+ overflow: hidden;
335
+ border: var(--line) solid var(--control-border);
336
+ border-radius: var(--radius-md);
337
+ box-shadow: inset 0 1px 0 var(--well-shade);
338
+ background: var(--ground);
339
+ color: var(--text);
340
+ transition:
341
+ border-color var(--duration-fast),
342
+ outline-color var(--duration-fast);
343
+ }
344
+
345
+ .field-editor:hover:not(
346
+ :focus-within,
347
+ [aria-invalid='true'],
348
+ [data-tone],
349
+ .read-only,
350
+ [aria-disabled='true']
351
+ ) {
352
+ border-color: var(--text);
353
+ }
354
+
355
+ .field-editor:focus-within {
356
+ border-color: var(--accent);
357
+ outline: var(--line) solid var(--accent);
358
+ outline-offset: var(--focus-offset-flush);
359
+ }
360
+
361
+ .field-editor[aria-invalid='true'] {
362
+ border-color: var(--danger);
363
+ }
364
+
365
+ .field-editor[aria-invalid='true']:focus-within {
366
+ outline-color: var(--danger);
367
+ }
368
+
369
+ .field-editor[data-tone='accent']:not([aria-invalid='true']) {
370
+ border-color: var(--accent);
371
+ box-shadow:
372
+ inset var(--field-tone-bar) 0 0 0 var(--accent),
373
+ inset 0 1px 0 var(--well-shade);
374
+ }
375
+
376
+ .field-editor.read-only,
377
+ .field-editor.read-only:focus-within {
378
+ border-color: var(--border-strong);
379
+ outline: none;
380
+ box-shadow: none;
381
+ background: var(--surface-recessed);
382
+ }
383
+
289
384
  /* -- Checkbox and radio -- */
290
385
 
291
386
  /* The on fill and the mark drawn on it: the accent, or a tone's. A mixed
@@ -711,6 +806,19 @@ select.field option {
711
806
  var(--font-ui);
712
807
  }
713
808
 
809
+ /* A group whose choices stand in columns (a long list of short choices):
810
+ --field-columns columns of equal width, 2 unless the host sets it; the
811
+ legend and any note span them all. */
812
+ .field-columns {
813
+ display: grid;
814
+ grid-template-columns: repeat(var(--field-columns, 2), minmax(0, 1fr));
815
+ gap: var(--space-2) var(--space-6);
816
+ }
817
+
818
+ .field-columns > :is(legend, .field-note, .field-problem) {
819
+ grid-column: 1 / -1;
820
+ }
821
+
714
822
  /* A check, radio, or switch with its words beside it; the whole label is
715
823
  the target. The words wrap rather than run out of the column. */
716
824
  .field-choice {
@@ -92,3 +92,19 @@
92
92
  :where(.listing-root) :is(:focus-within, :has(> input:not(:placeholder-shown))) > .filter-icon {
93
93
  color: var(--accent);
94
94
  }
95
+
96
+ /* A query the field refuses (its input aria-invalid="true", with the
97
+ reason in a problem line or a tooltip the input names): the field's foot
98
+ and its focus edge turn to --danger, and so does its lit mark, in place
99
+ of the divider and the accent. */
100
+ :where(.listing-root) .filter-field:has(input[aria-invalid='true']) {
101
+ border-bottom-color: var(--danger);
102
+ }
103
+
104
+ :where(.listing-root) .filter-field:has(input[aria-invalid='true']):focus-within {
105
+ box-shadow: inset 0 calc(-1 * var(--line-strong)) 0 var(--danger);
106
+ }
107
+
108
+ :where(.listing-root) .filter-field:has(input[aria-invalid='true']) > .filter-icon {
109
+ color: var(--danger);
110
+ }
@@ -86,6 +86,13 @@ export interface DataGridProps {
86
86
  readonly rowLead?: (row: number) => ReactNode;
87
87
  /** The width of the lead's column, the same on every row, in pixels. */
88
88
  readonly leadWidth?: number;
89
+ /**
90
+ * How many leading columns stay in view while the grid scrolls sideways
91
+ * (a key, a name), after the row's lead, which stays with them; a hairline
92
+ * marks the pin edge, and a header dragged to a new place never crosses
93
+ * it. None when absent or 0.
94
+ */
95
+ readonly pinnedColumns?: number;
89
96
  /** A control at a row's end, after its cells (Stop on a list of running jobs). */
90
97
  readonly rowAction?: (row: number) => ReactNode;
91
98
  /** The width of the row's end column, in pixels; as wide as it asks when absent. */
@@ -155,7 +162,8 @@ export interface DataGridProps {
155
162
  * What a caller adds, each only where it passes its handler: headers that
156
163
  * sort (Shift adds a column to the sort, Option or Control takes it out),
157
164
  * that drag to a new place, that copy their name on a double-click, and
158
- * that mark their column on a click; controls at each row's start and end;
165
+ * that mark their column on a click; leading columns pinned in view while
166
+ * the rest scroll sideways (`pinnedColumns`); controls at each row's start and end;
159
167
  * rows that mark on a click or Space; the row under the pointer lit; and
160
168
  * inline edit: a click or a double-click on an editable cell (`editTrigger`),
161
169
  * or Return on the cursor cell when it holds no link, asks to edit it
@@ -163,4 +171,4 @@ export interface DataGridProps {
163
171
  * a double-click starting an edit, a link cell's single click waits a
164
172
  * moment, so a double-click edits it rather than following it.
165
173
  */
166
- export declare function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows, rowLead, leadWidth, rowAction, actionWidth, sort, sorts, onSort, onReorder, onHeaderDoubleClick, markedColumns, onMarkColumn, rowMarked, onMarkRow, pointer, maxHeight, editable, editTrigger, onEdit, editor, editorContainer, empty }: DataGridProps): ReactElement;
174
+ export declare function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows, rowLead, leadWidth, pinnedColumns, rowAction, actionWidth, sort, sorts, onSort, onReorder, onHeaderDoubleClick, markedColumns, onMarkColumn, rowMarked, onMarkRow, pointer, maxHeight, editable, editTrigger, onEdit, editor, editorContainer, empty }: DataGridProps): ReactElement;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useLayoutEffect, useReducer, useRef, useState } from 'react';
3
3
  import { ChevronDown, ChevronUp } from 'lucide-react';
4
4
  import { createPortal, flushSync } from 'react-dom';
5
- import { dropPlace, editorLeft, gridMove, initialWidth, movedCell, resizedWidth, visibleRows, windowHolds } from './DataGrid.logic.js';
5
+ import { dropPlace, editorLeft, gridMove, initialWidth, movedCell, pinnedDropPlace, resizedWidth, revealedScrollLeft, visibleRows, windowHolds } from './DataGrid.logic.js';
6
6
  import { ICON_SM } from '../icon/index.js';
7
7
  import { cutTooltip, describedTooltip } from '../tooltip/Tooltip.logic.js';
8
8
  /** Every row's height, so the grid can place any row without measuring it. */
@@ -45,7 +45,8 @@ const FADE_MIN_OVERFLOW = 12;
45
45
  * What a caller adds, each only where it passes its handler: headers that
46
46
  * sort (Shift adds a column to the sort, Option or Control takes it out),
47
47
  * that drag to a new place, that copy their name on a double-click, and
48
- * that mark their column on a click; controls at each row's start and end;
48
+ * that mark their column on a click; leading columns pinned in view while
49
+ * the rest scroll sideways (`pinnedColumns`); controls at each row's start and end;
49
50
  * rows that mark on a click or Space; the row under the pointer lit; and
50
51
  * inline edit: a click or a double-click on an editable cell (`editTrigger`),
51
52
  * or Return on the cursor cell when it holds no link, asks to edit it
@@ -53,7 +54,7 @@ const FADE_MIN_OVERFLOW = 12;
53
54
  * a double-click starting an edit, a link cell's single click waits a
54
55
  * moment, so a double-click edits it rather than following it.
55
56
  */
56
- export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows, rowLead, leadWidth = 0, rowAction, actionWidth, sort, sorts, onSort, onReorder, onHeaderDoubleClick, markedColumns, onMarkColumn, rowMarked, onMarkRow, pointer = false, maxHeight = 420, editable, editTrigger = 'double-click', onEdit, editor = null, editorContainer, empty }) {
57
+ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows, rowLead, leadWidth = 0, pinnedColumns = 0, rowAction, actionWidth, sort, sorts, onSort, onReorder, onHeaderDoubleClick, markedColumns, onMarkColumn, rowMarked, onMarkRow, pointer = false, maxHeight = 420, editable, editTrigger = 'double-click', onEdit, editor = null, editorContainer, empty }) {
57
58
  const id = useId();
58
59
  const viewport = useRef(null);
59
60
  /** The frame around the scrolling well, which an editor's layer keeps inside. */
@@ -111,6 +112,22 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
111
112
  .filter((part) => part !== null)
112
113
  .join(' ');
113
114
  const page = Math.max(1, Math.floor(viewportHeight / ROW_HEIGHT) - 1);
115
+ /** The columns pinned, never more than there are. */
116
+ const pinned = Math.max(0, Math.min(Math.floor(pinnedColumns), columns.length));
117
+ /** Where each column starts from the rows' start, the lead included, and where the last ends. */
118
+ const starts = columns.reduce((edges, column, index) => [...edges, (edges[index] ?? 0) + widthOf(column, index)], [rowLead === undefined ? 0 : leadWidth]);
119
+ /** How wide the part that stays in view is: the lead and the pinned columns. */
120
+ const pinnedWidth = pinned === 0 ? 0 : (starts[pinned] ?? 0);
121
+ /** A pinned column's or lead's class and sticky offset; nothing for one that scrolls. */
122
+ const pinning = (index) => {
123
+ if (pinned === 0 || (index !== 'lead' && index >= pinned))
124
+ return { className: '' };
125
+ return {
126
+ className: index === pinned - 1 ? 'pinned pin-edge' : 'pinned',
127
+ style: { insetInlineStart: index === 'lead' ? 0 : starts[index] }
128
+ };
129
+ };
130
+ const leadPin = pinning('lead');
114
131
  // A column that does not sort shows no mark, whatever the sort names, and is not counted.
115
132
  const marks = (sorts ?? (sort === null || sort === undefined ? [] : [{ ...sort, position: 1 }])).filter((mark) => columns[mark.column]?.sortable !== false);
116
133
  useLayoutEffect(() => {
@@ -232,11 +249,21 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
232
249
  : editorLeft(editorBox.left - 1, layer.getBoundingClientRect().width, editorBox.well, EDITOR_MARGIN);
233
250
  setEditorShift((held) => (held === next ? held : next));
234
251
  }, [editorBox, editor]);
235
- /** Scrolls a row into the viewport, below the header. */
236
- const reveal = (row) => {
252
+ /**
253
+ * Scrolls a cell into the viewport: its row below the header, its column
254
+ * past the pinned ones. The sideways scroll is measured from the rows'
255
+ * start: a right-to-left well's scrollLeft runs from 0 down, so it is
256
+ * read and written with its sign turned.
257
+ */
258
+ const reveal = (row, column) => {
237
259
  const element = viewport.current;
238
260
  if (element === null)
239
261
  return;
262
+ const sign = getComputedStyle(element).direction === 'rtl' ? -1 : 1;
263
+ const from = sign * element.scrollLeft;
264
+ const to = revealedScrollLeft(from, element.clientWidth, starts[column] ?? 0, starts[column + 1] ?? 0, pinnedWidth);
265
+ if (to !== from)
266
+ element.scrollLeft = sign * to;
240
267
  const top = row * ROW_HEIGHT;
241
268
  const shown = element.clientHeight - ROW_HEIGHT;
242
269
  if (top < element.scrollTop)
@@ -273,7 +300,7 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
273
300
  return;
274
301
  event.preventDefault();
275
302
  setCursor(next);
276
- reveal(next.row);
303
+ reveal(next.row, next.column);
277
304
  };
278
305
  const onResizeStart = (event, column) => {
279
306
  if (event.button !== 0)
@@ -315,7 +342,10 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
315
342
  moving = true;
316
343
  target.setPointerCapture(event.pointerId);
317
344
  }
318
- setDragging({ from: column, to: dropPlace(move.clientX, headingEdges(), column) });
345
+ setDragging({
346
+ from: column,
347
+ to: pinnedDropPlace(dropPlace(move.clientX, headingEdges(), column), column, pinned)
348
+ });
319
349
  };
320
350
  const onUp = (up) => {
321
351
  target.removeEventListener('pointermove', onMove);
@@ -325,7 +355,7 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
325
355
  return;
326
356
  dragged.current = true;
327
357
  setDragging(null);
328
- const place = dropPlace(up.clientX, headingEdges(), column);
358
+ const place = pinnedDropPlace(dropPlace(up.clientX, headingEdges(), column), column, pinned);
329
359
  if (place !== column)
330
360
  onReorder(column, place);
331
361
  };
@@ -351,8 +381,9 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
351
381
  const rows = [];
352
382
  for (let row = from; row < to; row += 1) {
353
383
  const marked = rowMarked?.(row) ?? false;
354
- rows.push(_jsxs("div", { "aria-rowindex": row + 2, "aria-selected": onMarkRow === undefined ? undefined : marked, className: marked ? 'data-grid-row marked' : 'data-grid-row', role: "row", style: { gridTemplateColumns: template, transform: `translateY(${row * ROW_HEIGHT}px)` }, children: [rowLead !== undefined && _jsx("div", { className: "data-grid-lead", children: rowLead(row) }), columns.map((column, index) => {
384
+ rows.push(_jsxs("div", { "aria-rowindex": row + 2, "aria-selected": onMarkRow === undefined ? undefined : marked, className: marked ? 'data-grid-row marked' : 'data-grid-row', role: "row", style: { gridTemplateColumns: template, transform: `translateY(${row * ROW_HEIGHT}px)` }, children: [rowLead !== undefined && (_jsx("div", { className: ['data-grid-lead', leadPin.className].filter(Boolean).join(' '), style: leadPin.style, children: rowLead(row) })), columns.map((column, index) => {
355
385
  const shown = cell(row, index);
386
+ const pin = pinning(index);
356
387
  const current = cursor?.row === row && cursor.column === index;
357
388
  const editing = editor !== null && editor.row === row && editor.column === index;
358
389
  const edits = canEdit(row, index);
@@ -362,6 +393,7 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
362
393
  current ? 'cursor' : '',
363
394
  markedColumns?.has(index) === true ? 'marked' : '',
364
395
  editing ? 'editing' : '',
396
+ pin.className,
365
397
  shown?.className ?? ''
366
398
  ]
367
399
  .filter(Boolean)
@@ -377,7 +409,7 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
377
409
  window.clearTimeout(pendingLink.current);
378
410
  pendingLink.current = null;
379
411
  onEdit?.(row, index);
380
- }, onPointerDown: () => setCursor({ row, column: index }), role: "gridcell", ...describedTooltip(shown?.tip ?? null), children: [shown?.content !== undefined ? (shown.content) : shown?.onOpen === undefined ? ((shown?.text ?? '')) : (_jsx("button", { className: "data-grid-link", onClick: (event) => {
412
+ }, onPointerDown: () => setCursor({ row, column: index }), role: "gridcell", style: pin.style, ...describedTooltip(shown?.tip ?? null), children: [shown?.content !== undefined ? (shown.content) : shown?.onOpen === undefined ? ((shown?.text ?? '')) : (_jsx("button", { className: "data-grid-link", onClick: (event) => {
381
413
  event.stopPropagation();
382
414
  const open = shown.onOpen;
383
415
  if (edits && editTrigger === 'double-click') {
@@ -416,8 +448,9 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
416
448
  // by the fade's width) never erases them.
417
449
  return (_jsx("div", { className: pointer ? 'data-grid pointer' : 'data-grid', ref: frame,
418
450
  // The frame's own height, border included; the well fills what is left.
419
- style: { maxHeight: maxHeight }, children: _jsxs("div", { "aria-activedescendant": cursor === null ? undefined : cellId(cursor.row, cursor.column), "aria-colcount": columns.length, "aria-label": label, "aria-multiselectable": onMarkRow === undefined ? undefined : true, "aria-rowcount": rowCount + 1, className: fades ? 'data-grid-scroll scroll-fade-x' : 'data-grid-scroll', onKeyDown: onKeyDown, ref: viewport, role: "grid", tabIndex: 0, children: [_jsxs("div", { "aria-rowindex": 1, className: "data-grid-header", ref: header, role: "row", style: { gridTemplateColumns: template }, children: [rowLead !== undefined && _jsx("div", { className: "data-grid-lead" }), columns.map((column, index) => {
451
+ style: { maxHeight: maxHeight }, children: _jsxs("div", { "aria-activedescendant": cursor === null ? undefined : cellId(cursor.row, cursor.column), "aria-colcount": columns.length, "aria-label": label, "aria-multiselectable": onMarkRow === undefined ? undefined : true, "aria-rowcount": rowCount + 1, className: fades ? 'data-grid-scroll scroll-fade-x' : 'data-grid-scroll', onKeyDown: onKeyDown, ref: viewport, role: "grid", tabIndex: 0, children: [_jsxs("div", { "aria-rowindex": 1, className: "data-grid-header", ref: header, role: "row", style: { gridTemplateColumns: template }, children: [rowLead !== undefined && (_jsx("div", { className: ['data-grid-lead', leadPin.className].filter(Boolean).join(' '), style: leadPin.style })), columns.map((column, index) => {
420
452
  const sortable = sortsBy(column);
453
+ const pin = pinning(index);
421
454
  const mark = marks.find((entry) => entry.column === index);
422
455
  return (_jsxs("div", { "aria-colindex": index + 1, "aria-sort": mark?.direction, className: [
423
456
  'data-grid-heading',
@@ -429,14 +462,15 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
429
462
  ? 'drop-before'
430
463
  : 'drop-after'
431
464
  : '',
432
- onReorder === undefined ? '' : 'draggable'
465
+ onReorder === undefined ? '' : 'draggable',
466
+ pin.className
433
467
  ]
434
468
  .filter(Boolean)
435
469
  .join(' '), onClick: (event) => {
436
470
  if (draggedClick(event))
437
471
  return;
438
472
  onMarkColumn?.(index);
439
- }, onDoubleClick: () => onHeaderDoubleClick?.(index), onPointerDown: (event) => onHeadingPointerDown(event, index), role: "columnheader", ...(column.tip === undefined
473
+ }, onDoubleClick: () => onHeaderDoubleClick?.(index), onPointerDown: (event) => onHeadingPointerDown(event, index), role: "columnheader", style: pin.style, ...(column.tip === undefined
440
474
  ? sortable
441
475
  ? {}
442
476
  : cutTooltip(column.label)
@@ -57,6 +57,22 @@ export declare function dropPlace(x: number, edges: readonly {
57
57
  readonly left: number;
58
58
  readonly right: number;
59
59
  }[], from: number): number;
60
+ /**
61
+ * Where a header dragged from `from` may land, given `place` under the
62
+ * pointer, in a grid whose first `pinned` columns stay in view: a pinned
63
+ * column stays among the pinned ones and any other among the rest, so a
64
+ * reorder never crosses the pin edge.
65
+ */
66
+ export declare function pinnedDropPlace(place: number, from: number, pinned: number): number;
67
+ /**
68
+ * Where a well scrolled sideways to `scrollLeft`, `width` pixels wide, scrolls
69
+ * to show a column spanning `left` to `right` (from the rows' start), when
70
+ * the first `pinned` pixels stay in view over whatever scrolls under them:
71
+ * the least scroll that shows the column whole past the pinned ones, its
72
+ * start first when it is wider than the room. A column inside the pinned
73
+ * part, or one already in view, leaves the scroll where it is.
74
+ */
75
+ export declare function revealedScrollLeft(scrollLeft: number, width: number, left: number, right: number, pinned?: number): number;
60
76
  /**
61
77
  * Where the inline editor's layer starts, in window pixels: over its cell
62
78
  * (`left`), unless a layer wider than the cell would cross the well's right