@bigpixelrocket/uiok 0.2.0 → 0.2.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 CHANGED
@@ -6,6 +6,12 @@ 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.1] - 2026-11-16
10
+
11
+ ### Added
12
+
13
+ - `DataGridColumn` `sortable`: `false` keeps a column's heading a plain label in a grid that sorts, for values with no order such as a JSON document or a geometric point. It draws no sort button or mark, keeps no room for the mark in its first width, has no `aria-sort`, and a click on it never asks `onSort`; it still marks, resizes, and drags as any heading does. Other columns sort as before.
14
+
9
15
  ## [0.2.0] - 2026-11-13
10
16
 
11
17
  ### Added
@@ -146,7 +152,8 @@ The first published version. The package is published to npm as `@bigpixelrocket
146
152
  - `lucide-react` 1.31 or later within 1.x is a peer dependency.
147
153
  - 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.
148
154
 
149
- [Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.0...HEAD
155
+ [Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.1...HEAD
156
+ [0.2.1]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.0...v0.2.1
150
157
  [0.2.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.4...v0.2.0
151
158
  [0.1.4]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.3...v0.1.4
152
159
  [0.1.3]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.2...v0.1.3
@@ -9,6 +9,13 @@ export interface DataGridColumn {
9
9
  readonly align?: 'right';
10
10
  /** Names the column across reorders, so its width follows it; its index when absent. */
11
11
  readonly id?: string;
12
+ /**
13
+ * False keeps the header a plain label while the grid sorts (a value with
14
+ * no order, such as a JSON document or a point): no sort control, no room
15
+ * for the sort mark, no `aria-sort`, and a click on it never asks
16
+ * `onSort`. Sortable when absent or true.
17
+ */
18
+ readonly sortable?: boolean;
12
19
  }
13
20
  /** The column a grid is sorted by, and which way. */
14
21
  export interface DataGridSort {
@@ -87,7 +94,10 @@ export interface DataGridProps {
87
94
  readonly sort?: DataGridSort | null;
88
95
  /** The columns the rows are sorted by, in order, each header numbered while there are several. */
89
96
  readonly sorts?: readonly DataGridSortMark[];
90
- /** Makes each header a control that asks to sort by its column; the caller orders the rows. */
97
+ /**
98
+ * Makes each header a control that asks to sort by its column, except a
99
+ * column with `sortable: false`; the caller orders the rows.
100
+ */
91
101
  readonly onSort?: (column: number, click: DataGridSortClick) => void;
92
102
  /** Lets a header be dragged to another column's place; the caller reorders `columns`. */
93
103
  readonly onReorder?: (from: number, to: number) => void;
@@ -87,12 +87,16 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
87
87
  window.clearTimeout(pendingLink.current);
88
88
  }, []);
89
89
  const keyOf = (column, index) => column.id ?? String(index);
90
+ /** Whether a column's header is a sort control: the grid sorts and the column allows it. */
91
+ const sortsBy = (column) => onSort !== undefined && column.sortable !== false;
92
+ /** The room a column's heading keeps beside its label for the sort mark. */
93
+ const labelRoom = (column) => (sortsBy(column) ? SORT_MARK_ROOM : 0);
90
94
  const [widths, setWidths] = useState(() => new Map(columns.map((column, index) => [
91
95
  keyOf(column, index),
92
- initialWidth(column.label, Array.from({ length: Math.min(rowCount, 20) }, (_, row) => cell(row, index)?.text ?? ''), CHAR_WIDTH, onSort === undefined ? 0 : SORT_MARK_ROOM)
96
+ initialWidth(column.label, Array.from({ length: Math.min(rowCount, 20) }, (_, row) => cell(row, index)?.text ?? ''), CHAR_WIDTH, labelRoom(column))
93
97
  ])));
94
98
  const widthOf = (column, index) => widths.get(keyOf(column, index)) ??
95
- initialWidth(column.label, [], CHAR_WIDTH, onSort === undefined ? 0 : SORT_MARK_ROOM);
99
+ initialWidth(column.label, [], CHAR_WIDTH, labelRoom(column));
96
100
  // The rows drawn last while they still cover where the grid stands, a fresh window otherwise.
97
101
  const held = committed.current;
98
102
  const { from, to } = held !== null &&
@@ -107,7 +111,8 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
107
111
  .filter((part) => part !== null)
108
112
  .join(' ');
109
113
  const page = Math.max(1, Math.floor(viewportHeight / ROW_HEIGHT) - 1);
110
- const marks = sorts ?? (sort === null || sort === undefined ? [] : [{ ...sort, position: 1 }]);
114
+ // A column that does not sort shows no mark, whatever the sort names, and is not counted.
115
+ const marks = (sorts ?? (sort === null || sort === undefined ? [] : [{ ...sort, position: 1 }])).filter((mark) => columns[mark.column]?.sortable !== false);
111
116
  useLayoutEffect(() => {
112
117
  const element = viewport.current;
113
118
  if (element === null || typeof ResizeObserver === 'undefined')
@@ -412,6 +417,7 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
412
417
  return (_jsx("div", { className: pointer ? 'data-grid pointer' : 'data-grid', ref: frame,
413
418
  // The frame's own height, border included; the well fills what is left.
414
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) => {
420
+ const sortable = sortsBy(column);
415
421
  const mark = marks.find((entry) => entry.column === index);
416
422
  return (_jsxs("div", { "aria-colindex": index + 1, "aria-sort": mark?.direction, className: [
417
423
  'data-grid-heading',
@@ -431,10 +437,10 @@ export function DataGrid({ label, columns, rowCount, cell, copyText, onNeedRows,
431
437
  return;
432
438
  onMarkColumn?.(index);
433
439
  }, onDoubleClick: () => onHeaderDoubleClick?.(index), onPointerDown: (event) => onHeadingPointerDown(event, index), role: "columnheader", ...(column.tip === undefined
434
- ? onSort === undefined
435
- ? cutTooltip(column.label)
436
- : {}
437
- : describedTooltip(column.tip)), children: [onSort === undefined ? (_jsx("span", { className: "data-grid-label", children: column.label })) : (_jsxs("button", { className: "data-grid-label data-grid-sort", onClick: (event) => {
440
+ ? sortable
441
+ ? {}
442
+ : cutTooltip(column.label)
443
+ : describedTooltip(column.tip)), children: [onSort === undefined || !sortable ? (_jsx("span", { className: "data-grid-label", children: column.label })) : (_jsxs("button", { className: "data-grid-label data-grid-sort", onClick: (event) => {
438
444
  event.stopPropagation();
439
445
  // A double-click's second click (`detail` 2) leaves the sort its first made.
440
446
  if (draggedClick(event) || event.detail > 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigpixelrocket/uiok",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A React UI library with a retro look: themeable design tokens and accessible components.",
5
5
  "keywords": [
6
6
  "react",