viewkitjs 0.23.0 → 0.24.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/package.json +1 -1
  3. package/views/dist/controls/grip/grip.d.ts +14 -0
  4. package/views/dist/controls/grip/grip.js +9 -0
  5. package/views/dist/controls/index.d.ts +6 -0
  6. package/views/dist/controls/index.js +6 -0
  7. package/views/dist/controls/internal/hold.d.ts +25 -0
  8. package/views/dist/controls/internal/hold.js +81 -0
  9. package/views/dist/controls/internal/icons.d.ts +8 -0
  10. package/views/dist/controls/internal/icons.js +65 -0
  11. package/views/dist/controls/internal/read-token.d.ts +6 -0
  12. package/views/dist/controls/internal/read-token.js +11 -0
  13. package/views/dist/controls/internal/reorder.d.ts +44 -0
  14. package/views/dist/controls/internal/reorder.js +83 -0
  15. package/views/dist/controls/list/tokens.d.ts +139 -0
  16. package/views/dist/controls/list/tokens.js +37 -0
  17. package/views/dist/controls/list.css +188 -0
  18. package/views/dist/controls/menu-list/keys.d.ts +7 -0
  19. package/views/dist/controls/menu-list/keys.js +29 -0
  20. package/views/dist/controls/menu-list/looks.d.ts +4 -0
  21. package/views/dist/controls/menu-list/looks.js +20 -0
  22. package/views/dist/controls/menu-list/menu-list.d.ts +196 -0
  23. package/views/dist/controls/menu-list/menu-list.js +346 -0
  24. package/views/dist/controls/menu-list/tokens.d.ts +187 -0
  25. package/views/dist/controls/menu-list/tokens.js +49 -0
  26. package/views/dist/controls/menu-list.css +259 -0
  27. package/views/dist/controls/sheet/bottom-sheet.js +3 -0
  28. package/views/dist/controls/sheet.css +3 -0
  29. package/views/dist/controls/tokens.js +4 -0
  30. package/views/dist/grid/chrome/grid-caret-keys.d.ts +7 -0
  31. package/views/dist/grid/chrome/grid-caret-keys.js +22 -0
  32. package/views/dist/grid/chrome/useGridFittedWidths.d.ts +3 -0
  33. package/views/dist/grid/chrome/useGridFittedWidths.js +16 -3
  34. package/views/dist/grid/chrome/useGridKeyboard.js +3 -0
  35. package/views/dist/looks/index.d.ts +1 -0
  36. package/views/dist/looks/index.js +1 -0
  37. package/views/dist/looks/looks.d.ts +10 -9
  38. package/views/dist/looks/pieces.js +2 -0
  39. package/views/dist/styles.css +443 -11
  40. package/views/dist/styles.unlayered.css +443 -11
  41. package/views/docs/controls/list.md +40 -0
  42. package/views/docs/controls/menu-list.md +52 -0
  43. package/views/docs/getting-started.md +1 -1
  44. package/views/docs/reference/controls.md +40 -0
  45. package/views/docs/reference/looks.md +3 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ Until 0.19.0 ViewKit shipped as three packages; their changes are in [fields/CHA
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.24.0] — 2026-11-26
9
+
10
+ viewkitjs/views/controls: the menu list, the list's stylesheet and the helpers they stand on (Icon, Grip, useHoldDrag, useReorder); the menu list's looks in viewkitjs/views/looks. A piece's looks may pick fewer options than it has (`PieceLooks<Id, Picked>`).
11
+
12
+ ### Fixed
13
+
14
+ - `viewkitjs/views/controls`: inside the bottom Sheet with its smooth corners (its default), a box that draws the smooth outline too (an Input, a Tag) keeps its own rounded bottom corners: the Sheet's square bottom and its foot no longer reach what it holds.
15
+ - `viewkitjs/views/controls`: the strip the Sheet lays under itself in the page goes on and fades on the Sheet's own spring, where a frame picks one.
16
+ - `viewkitjs/views/grid`: Home and End in a cell's editor move its caret to the start or the end of its line (⇧ extends the selection) on every platform. On a Mac they scrolled the whole grid to its top or its foot instead.
17
+ - `viewkitjs/views/grid`: a grid first drawn where it can't be seen (in a box `hidden` or `display: none` takes out of the page) keeps no width read there: a column with no width of its own is fitted once the grid is laid out, never narrower than its header.
18
+
8
19
  ## [0.23.0] — 2026-11-25
9
20
 
10
21
  viewkitjs/views/controls: the Option, the Tag, the Status and the Switch, their looks in viewkitjs/views/looks; CONTROL_ATOMS draws ViewKit's Tag, StatusBadge and CellMore atoms with them for an app that spreads it into its atoms.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewkitjs",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "ViewKit — typed fields, the grid and its editors, and a list's SQL for record lists, in one package: viewkitjs/fields, viewkitjs/views and viewkitjs/postgres. By Sheaf.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import { Button } from "../button/button.js";
3
+ import type { ButtonOwnLook } from "../button/own-look.js";
4
+ /** Its six dots. */
5
+ export declare const GRIP: string[];
6
+ /** Its look: md and round, no edge, faint, the grabbing hand, nothing under the pointer, its icon 14. */
7
+ export declare const GRIP_LOOK: ButtonOwnLook;
8
+ type GripProps = Omit<React.ComponentProps<typeof Button>, "kind" | "shape" | "size" | "look" | "icon" | "aria-label" | "children"> & {
9
+ /** What a press moves, to a screen reader: "Move Amount". */
10
+ label: string;
11
+ };
12
+ /** The grip: the Button a row is moved by, with useReorder's gripProps spread on it. */
13
+ export declare const Grip: React.ForwardRefExoticComponent<Omit<GripProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
14
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Button } from "../button/button.js";
4
+ const dot = (x, y) => `M${x} ${y}m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`;
5
+ export const GRIP = [dot(9, 5), dot(9, 12), dot(9, 19), dot(15, 5), dot(15, 12), dot(15, 19)];
6
+ export const GRIP_LOOK = { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none", icon: "14" };
7
+ export const Grip = React.forwardRef(function Grip({ label, ...props }, ref) {
8
+ return (_jsx(Button, { ref: ref, kind: "quiet", shape: "icon", size: "20x24", look: GRIP_LOOK, "aria-label": label, ...props, icon: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: GRIP.map((d) => _jsx("path", { d: d }, d)) }) }));
9
+ });
@@ -35,3 +35,9 @@ export { Switch, type SwitchProps } from "./switch/switch.js";
35
35
  export { CONTROL_ATOMS } from "./atoms.js";
36
36
  export { colourOf } from "./option/atom-tag.js";
37
37
  export { quartersOf, statusPlaceOf } from "./status/atom-status-badge.js";
38
+ export { Icon, iconPaths } from "./internal/icons.js";
39
+ export { GRIP, GRIP_LOOK, Grip } from "./grip/grip.js";
40
+ export { useHoldDrag, type HoldDragProps, type HoldReads } from "./internal/hold.js";
41
+ export { dragAt, gapOf, moved, useReorder, type ReorderDrag, type RowEdges } from "./internal/reorder.js";
42
+ export { rowFor, rowStarting } from "./menu-list/keys.js";
43
+ export { MenuList, MenuListPanelRows, MenuListRow, MenuListRows, MenuListShown, MenuScroll, menuListCloseOf, menuListRowsOf, sheetFormOf, tilesOf, useMenuListOption, useMenuListRows, type MenuChoice, type MenuEntry, type MenuListEntry, type MenuListPanelRowsProps, type MenuListProps, type MenuListTile, } from "./menu-list/menu-list.js";
@@ -29,3 +29,9 @@ export { Switch } from "./switch/switch.js";
29
29
  export { CONTROL_ATOMS } from "./atoms.js";
30
30
  export { colourOf } from "./option/atom-tag.js";
31
31
  export { quartersOf, statusPlaceOf } from "./status/atom-status-badge.js";
32
+ export { Icon, iconPaths } from "./internal/icons.js";
33
+ export { GRIP, GRIP_LOOK, Grip } from "./grip/grip.js";
34
+ export { useHoldDrag } from "./internal/hold.js";
35
+ export { dragAt, gapOf, moved, useReorder } from "./internal/reorder.js";
36
+ export { rowFor, rowStarting } from "./menu-list/keys.js";
37
+ export { MenuList, MenuListPanelRows, MenuListRow, MenuListRows, MenuListShown, MenuScroll, menuListCloseOf, menuListRowsOf, sheetFormOf, tilesOf, useMenuListOption, useMenuListRows, } from "./menu-list/menu-list.js";
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ import type { useReorder } from "./reorder.js";
3
+ /** What a row that is held, then dragged carries: the mark that it starts a drag (`data-drag-start`, where a list says no callout
4
+ * and a held row no scroll) and its pointer's handlers. */
5
+ export type HoldDragProps = {
6
+ "data-drag-start": "";
7
+ /** Base UI's Drawer leaves a touch that starts here to the browser and to the row: a held row's move never moves the Sheet. */
8
+ "data-base-ui-swipe-ignore": "";
9
+ onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
10
+ onPointerMove: (e: React.PointerEvent<HTMLElement>) => void;
11
+ onPointerUp: () => void;
12
+ onPointerCancel: () => void;
13
+ onClickCapture: (e: React.MouseEvent<HTMLElement>) => void;
14
+ onContextMenu: (e: React.MouseEvent<HTMLElement>) => void;
15
+ };
16
+ /** How a held row reads its hold delay, in ms, and the distance in px a finger may move before the press is a swipe. */
17
+ export type HoldReads = {
18
+ readonly delay: (row: HTMLElement) => number;
19
+ readonly swipe: (row: HTMLElement) => number;
20
+ };
21
+ /** A hold, then a drag, for the rows of the list `root` holds, moved by useReorder's `gripProps`: `drag(i)` gives the row at the
22
+ * i-th place among the rows that move its props. `reads` reads a row's hold delay and swipe distance off the row, as the
23
+ * stylesheet that draws it hands them. `on` says the list holds a row that moves: a list with none takes no touchmove
24
+ * listener, so nothing waits on it before scrolling. */
25
+ export declare function useHoldDrag(root: React.RefObject<HTMLElement | null>, gripProps: ReturnType<typeof useReorder>["gripProps"], reads: HoldReads, on?: boolean): (i: number) => HoldDragProps;
@@ -0,0 +1,81 @@
1
+ import * as React from "react";
2
+ function settled(h) {
3
+ window.clearTimeout(h.timer);
4
+ h.timer = undefined;
5
+ if (h.lifted || h.swiped)
6
+ h.swallow = true;
7
+ h.lifted = false;
8
+ h.swiped = false;
9
+ }
10
+ export function useHoldDrag(root, gripProps, reads, on = true) {
11
+ const hold = React.useRef({ timer: undefined, x0: 0, y0: 0, y: 0, id: -1, lifted: false, swiped: false, swallow: false });
12
+ React.useEffect(() => {
13
+ const el = root.current, h = hold.current;
14
+ if (!el || !on)
15
+ return;
16
+ const keep = (e) => { if (h.lifted)
17
+ e.preventDefault(); };
18
+ const up = (e) => { if (e.pointerId === h.id)
19
+ settled(h); };
20
+ const key = () => { h.swallow = false; };
21
+ el.addEventListener("touchmove", keep, { passive: false });
22
+ window.addEventListener("pointerup", up);
23
+ window.addEventListener("pointercancel", up);
24
+ window.addEventListener("keydown", key, true);
25
+ return () => {
26
+ el.removeEventListener("touchmove", keep);
27
+ window.removeEventListener("pointerup", up);
28
+ window.removeEventListener("pointercancel", up);
29
+ window.removeEventListener("keydown", key, true);
30
+ window.clearTimeout(h.timer);
31
+ h.timer = undefined;
32
+ h.lifted = false;
33
+ };
34
+ }, [root, on]);
35
+ return (i) => {
36
+ const g = gripProps(i), h = hold.current;
37
+ const wait = () => { window.clearTimeout(h.timer); h.timer = undefined; };
38
+ const end = () => { settled(h); g.onPointerUp(); };
39
+ return {
40
+ "data-drag-start": "", "data-base-ui-swipe-ignore": "",
41
+ onPointerDown: (e) => {
42
+ if (e.button !== 0)
43
+ return;
44
+ wait();
45
+ Object.assign(h, { x0: e.clientX, y0: e.clientY, y: e.clientY, id: e.pointerId, lifted: false, swiped: false, swallow: false });
46
+ const el = e.currentTarget;
47
+ h.timer = window.setTimeout(() => {
48
+ h.timer = undefined;
49
+ try {
50
+ g.onPointerDown({ button: 0, pointerId: h.id, clientY: h.y, currentTarget: el, preventDefault: () => { } });
51
+ h.lifted = true;
52
+ }
53
+ catch {
54
+ h.lifted = false;
55
+ }
56
+ }, reads.delay(el));
57
+ },
58
+ onPointerMove: (e) => {
59
+ if (h.lifted) {
60
+ g.onPointerMove(e);
61
+ return;
62
+ }
63
+ if (h.timer !== undefined && Math.hypot(e.clientX - h.x0, e.clientY - h.y0) > reads.swipe(e.currentTarget)) {
64
+ wait();
65
+ h.swiped = true;
66
+ }
67
+ if (h.timer !== undefined)
68
+ h.y = e.clientY;
69
+ },
70
+ onPointerUp: end,
71
+ onPointerCancel: end,
72
+ onClickCapture: (e) => { if (h.swallow) {
73
+ e.preventDefault();
74
+ e.stopPropagation();
75
+ h.swallow = false;
76
+ } },
77
+ onContextMenu: (e) => { if (h.timer !== undefined || h.lifted)
78
+ e.preventDefault(); },
79
+ };
80
+ };
81
+ }
@@ -0,0 +1,8 @@
1
+ declare const PATHS: Record<string, string[]>;
2
+ /** An icon's paths, for a control that draws one of its parts itself (the menu list's eye). */
3
+ export declare const iconPaths: (name: string) => string[];
4
+ export declare function Icon({ name, size }: {
5
+ name: keyof typeof PATHS | string;
6
+ size?: number;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const PATHS = {
3
+ plus: ["M12 5l0 14", "M5 12l14 0"],
4
+ down: ["M6 9l6 6l6 -6"],
5
+ trash: ["M4 7l16 0", "M10 11l0 6", "M14 11l0 6", "M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12", "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"],
6
+ dots: ["M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"],
7
+ x: ["M18 6l-12 12", "M6 6l12 12"],
8
+ filter: ["M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z"],
9
+ sort: ["M3 9l4 -4l4 4m-4 -4v14", "M21 15l-4 4l-4 -4m4 4v-14"],
10
+ columns: ["M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z", "M12 4v16"],
11
+ board: ["M4 4l6 0", "M14 4l6 0", "M4 8m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z", "M14 8m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z"],
12
+ underline: ["M7 5v5a5 5 0 0 0 10 0v-5", "M5 19h14"],
13
+ strike: ["M5 12l14 0", "M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5"],
14
+ "align-left": ["M4 6l16 0", "M4 12l10 0", "M4 18l14 0"],
15
+ "align-center": ["M4 6l16 0", "M8 12l8 0", "M6 18l12 0"],
16
+ "align-right": ["M4 6l16 0", "M10 12l10 0", "M6 18l14 0"],
17
+ search: ["M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0", "M21 21l-6 -6"],
18
+ open: ["M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6", "M11 13l9 -9", "M15 4h5v5"],
19
+ rename: ["M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4", "M13.5 6.5l4 4"],
20
+ link: ["M9 15l6 -6", "M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464", "M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"],
21
+ stage: ["M10 20.777a8.942 8.942 0 0 1 -2.48 -.969", "M14 3.223a9.003 9.003 0 0 1 0 17.554", "M4.579 17.093a8.961 8.961 0 0 1 -1.227 -2.592", "M3.124 10.5c.16 -.95 .468 -1.85 .9 -2.675l.169 -.305", "M6.907 4.579a8.954 8.954 0 0 1 3.093 -1.356"],
22
+ owner: ["M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0", "M9 10a3 3 0 1 0 6 0a3 3 0 1 0 -6 0", "M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855"],
23
+ star: ["M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873l-6.158 -3.245"],
24
+ copy: ["M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666", "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1"],
25
+ merge: ["M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M15 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0", "M7 8l0 8", "M7 8a4 4 0 0 0 4 4h4"],
26
+ none: ["M20.042 16.045a9 9 0 0 0 -12.087 -12.087m-2.318 1.677a9 9 0 1 0 12.725 12.73", "M3 3l18 18"],
27
+ export: ["M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2", "M7 11l5 5l5 -5", "M12 4l0 12"],
28
+ file: ["M14 3v4a1 1 0 0 0 1 1h4", "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"],
29
+ company: ["M3 21l18 0", "M9 8l1 0", "M9 12l1 0", "M9 16l1 0", "M14 8l1 0", "M14 12l1 0", "M14 16l1 0", "M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16"],
30
+ left: ["M15 6l-6 6l6 6"],
31
+ right: ["M9 6l6 6l-6 6"],
32
+ minus: ["M5 12l14 0"],
33
+ overview: ["M4 4h6v8h-6z", "M4 16h6v4h-6z", "M14 12h6v8h-6z", "M14 4h6v4h-6z"],
34
+ activity: ["M3 12h4l3 8l4 -16l3 8h4"],
35
+ deal: ["M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572", "M12 6l-3.293 3.293a1 1 0 0 0 0 1.414l.543 .543c.69 .69 1.81 .69 2.5 0l1 -1a3.182 3.182 0 0 1 4.5 0l2.25 2.25", "M12.5 15.5l2 2", "M15 13l2 2"],
36
+ people: ["M5 7a4 4 0 1 0 8 0a4 4 0 1 0 -8 0", "M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2", "M16 3.13a4 4 0 0 1 0 7.75", "M21 21v-2a4 4 0 0 0 -3 -3.85"],
37
+ mail: ["M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10z", "M3 7l9 6l9 -6"],
38
+ settings: ["M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065", "M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0"],
39
+ objects: ["M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0", "M4 6v6a8 3 0 0 0 16 0v-6", "M4 12v6a8 3 0 0 0 16 0v-6"],
40
+ fields: ["M13 5h8", "M13 9h5", "M13 15h8", "M13 19h5", "M3 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4", "M3 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4"],
41
+ eye: ["M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0", "M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"],
42
+ "eye-off": ["M10.585 10.587a2 2 0 0 0 2.829 2.828", "M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87", "M3 3l18 18"],
43
+ check: ["M5 12l5 5l10 -10"],
44
+ paperclip: ["M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5"],
45
+ at: ["M8 12a4 4 0 1 0 8 0a4 4 0 1 0 -8 0", "M16 12v1.5a2.5 2.5 0 0 0 5 0v-1.5a9 9 0 1 0 -5.5 8.28"],
46
+ bold: ["M7 5h6a3.5 3.5 0 0 1 0 7h-6z", "M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7"],
47
+ italic: ["M11 5l6 0", "M7 19l6 0", "M14 5l-4 14"],
48
+ list: ["M9 6l11 0", "M9 12l11 0", "M9 18l11 0", "M5 6l0 .01", "M5 12l0 .01", "M5 18l0 .01"],
49
+ pin: ["M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4", "M9 15l-4.5 4.5", "M14.5 4l5.5 5.5"],
50
+ bell: ["M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6", "M9 17v1a3 3 0 0 0 6 0v-1"],
51
+ "star-filled": ["M8.243 7.34l-6.38 .925l-.113 .023a1 1 0 0 0 -.44 1.684l4.622 4.499l-1.09 6.355l-.013 .11a1 1 0 0 0 1.464 .944l5.706 -3l5.693 3l.1 .046a1 1 0 0 0 1.352 -1.1l-1.091 -6.355l4.624 -4.5l.078 -.085a1 1 0 0 0 -.633 -1.62l-6.38 -.926l-2.852 -5.78a1 1 0 0 0 -1.794 0l-2.853 5.78z"],
52
+ "pin-filled": ["M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z"],
53
+ "bell-filled": ["M14.235 19c.865 0 1.322 1.024 .745 1.668a3.992 3.992 0 0 1 -2.98 1.332a3.992 3.992 0 0 1 -2.98 -1.332c-.552 -.616 -.158 -1.579 .634 -1.661l.11 -.006h4.471z", "M12 2c1.358 0 2.506 .903 2.875 2.141l.046 .171l.008 .043a8.013 8.013 0 0 1 4.024 6.069l.028 .287l.019 .289v2.931l.021 .136a3 3 0 0 0 1.143 1.847l.167 .117l.162 .099c.86 .487 .56 1.766 -.377 1.864l-.116 .006h-16c-1.028 0 -1.387 -1.364 -.493 -1.87a3 3 0 0 0 1.472 -2.063l.021 -.143l.001 -2.97a8 8 0 0 1 3.821 -6.454l.248 -.146l.01 -.043a3.003 3.003 0 0 1 2.562 -2.29l.182 -.017l.176 -.004z"],
54
+ undo: ["M9 14l-4 -4l4 -4", "M5 10h11a4 4 0 1 1 0 8h-1"],
55
+ redo: ["M15 14l4 -4l-4 -4", "M19 10h-11a4 4 0 1 0 0 8h1"],
56
+ "bring-in": ["M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v8", "M3 10h18", "M10 3v18", "M19 22v-6", "M22 19l-3 -3l-3 3"],
57
+ user: ["M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0", "M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"],
58
+ calendar: ["M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12z", "M16 3v4", "M8 3v4", "M4 11h16", "M11 15h1", "M12 15v3"],
59
+ logout: ["M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2", "M9 12h12l-3 -3", "M18 15l3 -3"],
60
+ };
61
+ export const iconPaths = (name) => PATHS[name] ?? [];
62
+ export function Icon({ name, size = 15 }) {
63
+ const filled = name.endsWith("-filled");
64
+ return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: filled ? "currentColor" : "none", stroke: filled ? "none" : "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: (PATHS[name] ?? []).map((d) => _jsx("path", { d: d }, d)) }));
65
+ }
@@ -0,0 +1,6 @@
1
+ /** A time in milliseconds ("500ms" is 500, "4s" 4000), 0 where nothing declares it. */
2
+ export declare function msOf(el: Element | null | undefined, prop: `--${string}`): number;
3
+ /** A length in px ("1px" is 1), 0 where nothing declares it. */
4
+ export declare function pxOf(el: Element | null | undefined, prop: `--${string}`): number;
5
+ /** Steps of the spacing name, in px (1.5 steps is 6px at the default 4px). */
6
+ export declare const spacingPx: (steps: number, el: Element | null | undefined) => number;
@@ -0,0 +1,11 @@
1
+ const read = (el, prop) => !el || typeof getComputedStyle === "undefined" ? "" : getComputedStyle(el).getPropertyValue(prop).trim();
2
+ export function msOf(el, prop) {
3
+ const v = read(el, prop), n = parseFloat(v);
4
+ if (Number.isNaN(n))
5
+ return 0;
6
+ return /\dms$/.test(v) ? n : /\ds$/.test(v) ? n * 1000 : n;
7
+ }
8
+ export function pxOf(el, prop) {
9
+ return parseFloat(read(el, prop)) || 0;
10
+ }
11
+ export const spacingPx = (steps, el) => pxOf(el, "--vk-spacing") * steps;
@@ -0,0 +1,44 @@
1
+ import * as React from "react";
2
+ /** A drag: the place the row was taken from, where the pointer started, a row's step (its height and the gap after it), the
3
+ * scale the row is drawn at, and how far it has moved, in its own pixels. */
4
+ export type ReorderDrag = {
5
+ from: number;
6
+ y: number;
7
+ step: number;
8
+ k: number;
9
+ dy: number;
10
+ };
11
+ /** A row's top and bottom on screen. */
12
+ export type RowEdges = {
13
+ top: number;
14
+ bottom: number;
15
+ };
16
+ /** The gap after a row, on screen: to the next row, or, for the last row, from the one before it; 0 for a row alone. `prev` and
17
+ * `next` are the neighbouring rows ([data-row]) only, never a line or a heading standing beside it. */
18
+ export declare function gapOf(row: RowEdges, prev: RowEdges | null, next: RowEdges | null): number;
19
+ /** A value moved from one place to another; a place outside the list moves nothing. */
20
+ export declare function moved<T>(list: T[], from: number, to: number): T[];
21
+ /** Where a dragged row is, in its own pixels: the pointer's move on screen over `k`, the scale the row is drawn at (as
22
+ * drawnAt reads it), and the place it has passed half a row into, within the list's `count`. */
23
+ export declare function dragAt(d: ReorderDrag, clientY: number, count: number): {
24
+ dy: number;
25
+ to: number;
26
+ };
27
+ /** The grips of a list of `count` rows: each move handed to `onMove`, and the focus back on `grip` (the grip's selector) at
28
+ * the row's new place after a move by the keys. `lift(i)` is the held row's place as it follows the pointer; `dragging` is
29
+ * the place it stands in now, while it is held. */
30
+ export declare function useReorder(o: {
31
+ count: number;
32
+ onMove(from: number, to: number): void;
33
+ grip: string;
34
+ }): {
35
+ gripProps: (i: number) => {
36
+ onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
37
+ onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
38
+ onPointerMove: (e: React.PointerEvent<HTMLElement>) => void;
39
+ onPointerUp: () => void;
40
+ onPointerCancel: () => void;
41
+ };
42
+ lift: (i: number) => React.CSSProperties | undefined;
43
+ dragging: number | null;
44
+ };
@@ -0,0 +1,83 @@
1
+ import * as React from "react";
2
+ import { drawnAt } from "./scroll.js";
3
+ export function gapOf(row, prev, next) {
4
+ return next ? next.top - row.bottom : prev ? row.top - prev.bottom : 0;
5
+ }
6
+ export function moved(list, from, to) {
7
+ if (from === to || from < 0 || to < 0 || from >= list.length || to >= list.length)
8
+ return list;
9
+ const out = [...list], [one] = out.splice(from, 1);
10
+ out.splice(to, 0, one);
11
+ return out;
12
+ }
13
+ export function dragAt(d, clientY, count) {
14
+ const dy = (clientY - d.y) / d.k;
15
+ return { dy, to: Math.max(0, Math.min(count - 1, d.from + Math.round(dy / d.step))) };
16
+ }
17
+ export function useReorder(o) {
18
+ const { count, onMove, grip } = o;
19
+ const [drag, setDragState] = React.useState(null);
20
+ const now = React.useRef(null);
21
+ const setDrag = (d) => { now.current = d; setDragState(d); };
22
+ React.useLayoutEffect(() => { if (drag && !drag.held.isConnected)
23
+ setDrag(null); });
24
+ const [follow, setFollow] = React.useState(null);
25
+ React.useLayoutEffect(() => { if (follow) {
26
+ follow.list?.querySelectorAll(grip)[follow.at]?.focus({ preventScroll: true });
27
+ setFollow(null);
28
+ } }, [follow, grip]);
29
+ const onKeyDown = (i) => (e) => {
30
+ const to = e.key === "ArrowUp" ? i - 1 : e.key === "ArrowDown" ? i + 1 : null;
31
+ if (to == null)
32
+ return;
33
+ e.preventDefault();
34
+ e.stopPropagation();
35
+ if (to < 0 || to >= count)
36
+ return;
37
+ onMove(i, to);
38
+ setFollow({ list: e.currentTarget.closest("[data-row]")?.parentElement ?? null, at: to });
39
+ };
40
+ const onPointerDown = (i) => (e) => {
41
+ if (e.button !== 0)
42
+ return;
43
+ e.preventDefault();
44
+ e.currentTarget.setPointerCapture(e.pointerId);
45
+ const row = e.currentTarget.closest("[data-row]"), k = row ? drawnAt(row) : 1;
46
+ const near = (el) => (el?.matches("[data-row]") ? el.getBoundingClientRect() : null);
47
+ const next = row ? near(row.nextElementSibling) : null;
48
+ const gap = row ? gapOf(row.getBoundingClientRect(), next ? null : near(row.previousElementSibling), next) / k : 0;
49
+ setDrag({ from: i, y: e.clientY, step: (row?.offsetHeight ?? 34) + gap, k, dy: 0, at: i, held: e.currentTarget, id: e.pointerId });
50
+ };
51
+ const pointAt = (clientY) => {
52
+ const d = now.current;
53
+ if (!d || !d.step)
54
+ return;
55
+ const { dy, to } = dragAt(d, clientY, count);
56
+ if (to === d.at && dy === d.dy)
57
+ return;
58
+ if (to !== d.at)
59
+ onMove(d.at, to);
60
+ setDrag({ ...d, dy, at: to });
61
+ };
62
+ const onPointerMove = (e) => pointAt(e.clientY);
63
+ const onPointerUp = () => { if (now.current)
64
+ setDrag(null); };
65
+ const live = React.useRef({ pointAt, onPointerUp });
66
+ React.useLayoutEffect(() => { live.current = { pointAt, onPointerUp }; });
67
+ const heldBy = drag ? drag.id : null;
68
+ React.useEffect(() => {
69
+ if (heldBy == null)
70
+ return;
71
+ const move = (e) => { if (e.pointerId === heldBy)
72
+ live.current.pointAt(e.clientY); };
73
+ const up = (e) => { if (e.pointerId === heldBy)
74
+ live.current.onPointerUp(); };
75
+ window.addEventListener("pointermove", move);
76
+ window.addEventListener("pointerup", up);
77
+ window.addEventListener("pointercancel", up);
78
+ return () => { window.removeEventListener("pointermove", move); window.removeEventListener("pointerup", up); window.removeEventListener("pointercancel", up); };
79
+ }, [heldBy]);
80
+ const lift = (i) => (drag && drag.at === i && drag.step ? { transform: `translateY(${drag.dy - (i - drag.from) * drag.step}px)` } : undefined);
81
+ const gripProps = (i) => ({ onKeyDown: onKeyDown(i), onPointerDown: onPointerDown(i), onPointerMove, onPointerUp, onPointerCancel: onPointerUp });
82
+ return { gripProps, lift, dragging: drag ? drag.at : null };
83
+ }
@@ -0,0 +1,139 @@
1
+ export declare const LIST_TOKENS: readonly [{
2
+ readonly name: "--vk-border";
3
+ readonly kind: "colour";
4
+ readonly outright: "--border";
5
+ }, {
6
+ readonly name: "--vk-border-subtle";
7
+ readonly kind: "colour";
8
+ readonly outright: "--border-subtle";
9
+ }, {
10
+ readonly name: "--vk-brand-subtler";
11
+ readonly kind: "colour";
12
+ readonly outright: "--background-brand-subtler";
13
+ }, {
14
+ readonly name: "--vk-brand-subtler-hovered";
15
+ readonly kind: "colour";
16
+ readonly outright: "--background-brand-subtler-hovered";
17
+ }, {
18
+ readonly name: "--vk-brand-subtlest";
19
+ readonly kind: "colour";
20
+ readonly outright: "--background-brand-subtlest";
21
+ }, {
22
+ readonly name: "--vk-fg";
23
+ readonly kind: "colour";
24
+ readonly outright: "--text";
25
+ }, {
26
+ readonly name: "--vk-fg-disabled";
27
+ readonly kind: "colour";
28
+ readonly outright: "--text-disabled";
29
+ }, {
30
+ readonly name: "--vk-fg-subtle";
31
+ readonly kind: "colour";
32
+ readonly outright: "--text-subtle";
33
+ }, {
34
+ readonly name: "--vk-overlay";
35
+ readonly kind: "colour";
36
+ readonly outright: "--surface-overlay";
37
+ }, {
38
+ readonly name: "--vk-overlay-hovered";
39
+ readonly kind: "colour";
40
+ readonly outright: "--surface-overlay-hovered";
41
+ }, {
42
+ readonly name: "--vk-overlay-pressed";
43
+ readonly kind: "colour";
44
+ readonly outright: "--surface-overlay-pressed";
45
+ }, {
46
+ readonly name: "--vk-overlay-selected";
47
+ readonly kind: "colour";
48
+ readonly outright: "--surface-overlay-selected";
49
+ }, {
50
+ readonly name: "--vk-shadow-lg";
51
+ readonly kind: "shadow";
52
+ readonly outright: "--shadow-lg";
53
+ }, {
54
+ readonly name: "--vk-shadow-md";
55
+ readonly kind: "shadow";
56
+ readonly outright: "--shadow-md";
57
+ }, {
58
+ readonly name: "--vk-shadow-sm";
59
+ readonly kind: "shadow";
60
+ readonly outright: "--shadow-sm";
61
+ }, {
62
+ readonly name: "--vk-shadow-xl";
63
+ readonly kind: "shadow";
64
+ readonly outright: "--shadow-xl";
65
+ }, {
66
+ readonly name: "--vk-shadow-xs";
67
+ readonly kind: "shadow";
68
+ readonly outright: "--shadow-xs";
69
+ }, {
70
+ readonly name: "--vk-border-width";
71
+ readonly kind: "size";
72
+ readonly outright: "--border-width";
73
+ }, {
74
+ readonly name: "--vk-font-size-sm";
75
+ readonly kind: "size";
76
+ readonly outright: "--text-sm";
77
+ }, {
78
+ readonly name: "--vk-font-size-xs";
79
+ readonly kind: "size";
80
+ readonly outright: "--text-xs";
81
+ }, {
82
+ readonly name: "--vk-font-weight-medium";
83
+ readonly kind: "size";
84
+ readonly outright: "--font-weight-medium";
85
+ }, {
86
+ readonly name: "--vk-layer-popup";
87
+ readonly kind: "size";
88
+ readonly outright: "--layer-popup";
89
+ }, {
90
+ readonly name: "--vk-line-height-sm";
91
+ readonly kind: "size";
92
+ readonly outright: "--text-sm--line-height";
93
+ }, {
94
+ readonly name: "--vk-line-height-xs";
95
+ readonly kind: "size";
96
+ readonly outright: "--text-xs--line-height";
97
+ }, {
98
+ readonly name: "--vk-radius-2xl";
99
+ readonly kind: "size";
100
+ readonly outright: "--radius-2xl";
101
+ }, {
102
+ readonly name: "--vk-radius-full";
103
+ readonly kind: "size";
104
+ readonly outright: "--radius-full";
105
+ }, {
106
+ readonly name: "--vk-radius-lg";
107
+ readonly kind: "size";
108
+ readonly outright: "--radius-lg";
109
+ }, {
110
+ readonly name: "--vk-radius-md";
111
+ readonly kind: "size";
112
+ readonly outright: "--radius-md";
113
+ }, {
114
+ readonly name: "--vk-radius-sm";
115
+ readonly kind: "size";
116
+ readonly outright: "--radius-sm";
117
+ }, {
118
+ readonly name: "--vk-radius-xl";
119
+ readonly kind: "size";
120
+ readonly outright: "--radius-xl";
121
+ }, {
122
+ readonly name: "--vk-radius-xs";
123
+ readonly kind: "size";
124
+ readonly outright: "--radius-xs";
125
+ }, {
126
+ readonly name: "--vk-spacing";
127
+ readonly kind: "size";
128
+ readonly outright: "--spacing";
129
+ }, {
130
+ readonly name: "--vk-duration-fast";
131
+ readonly kind: "motion";
132
+ readonly outright: "--duration-fast";
133
+ }, {
134
+ readonly name: "--vk-ease-out";
135
+ readonly kind: "motion";
136
+ readonly outright: "--ease-out";
137
+ }];
138
+ /** The list's own machinery: its options' values set on the frame, its rows' and panel's measures, and the lines between groups. */
139
+ export declare const LIST_PRIVATE: readonly ["--list-", "--divider-", "--dividers-"];
@@ -0,0 +1,37 @@
1
+ export const LIST_TOKENS = [
2
+ { name: "--vk-border", kind: "colour", outright: "--border" },
3
+ { name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
4
+ { name: "--vk-brand-subtler", kind: "colour", outright: "--background-brand-subtler" },
5
+ { name: "--vk-brand-subtler-hovered", kind: "colour", outright: "--background-brand-subtler-hovered" },
6
+ { name: "--vk-brand-subtlest", kind: "colour", outright: "--background-brand-subtlest" },
7
+ { name: "--vk-fg", kind: "colour", outright: "--text" },
8
+ { name: "--vk-fg-disabled", kind: "colour", outright: "--text-disabled" },
9
+ { name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
10
+ { name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
11
+ { name: "--vk-overlay-hovered", kind: "colour", outright: "--surface-overlay-hovered" },
12
+ { name: "--vk-overlay-pressed", kind: "colour", outright: "--surface-overlay-pressed" },
13
+ { name: "--vk-overlay-selected", kind: "colour", outright: "--surface-overlay-selected" },
14
+ { name: "--vk-shadow-lg", kind: "shadow", outright: "--shadow-lg" },
15
+ { name: "--vk-shadow-md", kind: "shadow", outright: "--shadow-md" },
16
+ { name: "--vk-shadow-sm", kind: "shadow", outright: "--shadow-sm" },
17
+ { name: "--vk-shadow-xl", kind: "shadow", outright: "--shadow-xl" },
18
+ { name: "--vk-shadow-xs", kind: "shadow", outright: "--shadow-xs" },
19
+ { name: "--vk-border-width", kind: "size", outright: "--border-width" },
20
+ { name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
21
+ { name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
22
+ { name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
23
+ { name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
24
+ { name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
25
+ { name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
26
+ { name: "--vk-radius-2xl", kind: "size", outright: "--radius-2xl" },
27
+ { name: "--vk-radius-full", kind: "size", outright: "--radius-full" },
28
+ { name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
29
+ { name: "--vk-radius-md", kind: "size", outright: "--radius-md" },
30
+ { name: "--vk-radius-sm", kind: "size", outright: "--radius-sm" },
31
+ { name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
32
+ { name: "--vk-radius-xs", kind: "size", outright: "--radius-xs" },
33
+ { name: "--vk-spacing", kind: "size", outright: "--spacing" },
34
+ { name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
35
+ { name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
36
+ ];
37
+ export const LIST_PRIVATE = ["--list-", "--divider-", "--dividers-"];