@bigpixelrocket/uiok 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +569 -0
  4. package/README.md +44 -2
  5. package/dist/VisuallyHidden.d.ts +13 -0
  6. package/dist/VisuallyHidden.js +13 -0
  7. package/dist/activity/ActivityBar.d.ts +29 -0
  8. package/dist/activity/ActivityBar.js +21 -0
  9. package/dist/activity/activity.css +43 -0
  10. package/dist/activity/index.d.ts +2 -0
  11. package/dist/activity/index.js +2 -0
  12. package/dist/button/Button.d.ts +26 -0
  13. package/dist/button/Button.js +14 -0
  14. package/dist/button/IconButton.d.ts +18 -0
  15. package/dist/button/IconButton.js +14 -0
  16. package/dist/button/button.css +95 -0
  17. package/dist/button/index.d.ts +3 -0
  18. package/dist/button/index.js +3 -0
  19. package/dist/charts/Drawing.d.ts +27 -0
  20. package/dist/charts/Drawing.js +117 -0
  21. package/dist/charts/Drawing.logic.d.ts +2 -0
  22. package/dist/charts/Drawing.logic.js +22 -0
  23. package/dist/charts/Line.logic.d.ts +33 -0
  24. package/dist/charts/Line.logic.js +72 -0
  25. package/dist/charts/LineChart.d.ts +34 -0
  26. package/dist/charts/LineChart.js +100 -0
  27. package/dist/charts/Pie.logic.d.ts +16 -0
  28. package/dist/charts/Pie.logic.js +28 -0
  29. package/dist/charts/PieChart.d.ts +20 -0
  30. package/dist/charts/PieChart.js +16 -0
  31. package/dist/charts/ResultChart.d.ts +47 -0
  32. package/dist/charts/ResultChart.js +175 -0
  33. package/dist/charts/ResultChart.logic.d.ts +42 -0
  34. package/dist/charts/ResultChart.logic.js +165 -0
  35. package/dist/charts/Scatter.logic.d.ts +55 -0
  36. package/dist/charts/Scatter.logic.js +134 -0
  37. package/dist/charts/ScatterChart.d.ts +36 -0
  38. package/dist/charts/ScatterChart.js +99 -0
  39. package/dist/charts/charts.css +310 -0
  40. package/dist/charts/index.d.ts +14 -0
  41. package/dist/charts/index.js +11 -0
  42. package/dist/charts/seriesColour.d.ts +2 -0
  43. package/dist/charts/seriesColour.js +8 -0
  44. package/dist/clock/index.d.ts +2 -0
  45. package/dist/clock/index.js +2 -0
  46. package/dist/clock/useClock.d.ts +14 -0
  47. package/dist/clock/useClock.js +57 -0
  48. package/dist/datetime/DateTimePicker.d.ts +50 -0
  49. package/dist/datetime/DateTimePicker.js +98 -0
  50. package/dist/datetime/DateTimePicker.logic.d.ts +59 -0
  51. package/dist/datetime/DateTimePicker.logic.js +103 -0
  52. package/dist/datetime/datetime.css +115 -0
  53. package/dist/datetime/index.d.ts +7 -0
  54. package/dist/datetime/index.js +7 -0
  55. package/dist/dialog/ConfirmDialog.d.ts +73 -0
  56. package/dist/dialog/ConfirmDialog.js +30 -0
  57. package/dist/dialog/DialogLegend.d.ts +21 -0
  58. package/dist/dialog/DialogLegend.js +28 -0
  59. package/dist/dialog/DialogLegend.logic.d.ts +145 -0
  60. package/dist/dialog/DialogLegend.logic.js +71 -0
  61. package/dist/dialog/ModalDialog.d.ts +101 -0
  62. package/dist/dialog/ModalDialog.js +184 -0
  63. package/dist/dialog/dialog.css +283 -0
  64. package/dist/dialog/index.d.ts +8 -0
  65. package/dist/dialog/index.js +8 -0
  66. package/dist/filter/FilterEscape.d.ts +16 -0
  67. package/dist/filter/FilterEscape.js +15 -0
  68. package/dist/filter/FilterIcon.d.ts +8 -0
  69. package/dist/filter/FilterIcon.js +11 -0
  70. package/dist/filter/filter.css +42 -0
  71. package/dist/filter/index.d.ts +3 -0
  72. package/dist/filter/index.js +3 -0
  73. package/dist/grid/DataGrid.d.ts +149 -0
  74. package/dist/grid/DataGrid.js +373 -0
  75. package/dist/grid/DataGrid.logic.d.ts +57 -0
  76. package/dist/grid/DataGrid.logic.js +121 -0
  77. package/dist/grid/grid.css +206 -0
  78. package/dist/grid/index.d.ts +7 -0
  79. package/dist/grid/index.js +7 -0
  80. package/dist/index.d.ts +32 -0
  81. package/dist/index.js +32 -0
  82. package/dist/keyboard/BrowserKeys.d.ts +15 -0
  83. package/dist/keyboard/BrowserKeys.js +28 -0
  84. package/dist/keyboard/KeyChord.logic.d.ts +25 -0
  85. package/dist/keyboard/KeyChord.logic.js +50 -0
  86. package/dist/keyboard/Keyboard.logic.d.ts +84 -0
  87. package/dist/keyboard/Keyboard.logic.js +137 -0
  88. package/dist/keyboard/OverlayWatch.d.ts +28 -0
  89. package/dist/keyboard/OverlayWatch.js +119 -0
  90. package/dist/keyboard/PageSelectAll.d.ts +14 -0
  91. package/dist/keyboard/PageSelectAll.js +22 -0
  92. package/dist/keyboard/index.d.ts +9 -0
  93. package/dist/keyboard/index.js +9 -0
  94. package/dist/keychord/KeyChord.d.ts +16 -0
  95. package/dist/keychord/KeyChord.js +55 -0
  96. package/dist/keychord/index.d.ts +2 -0
  97. package/dist/keychord/index.js +2 -0
  98. package/dist/keychord/keychord.css +41 -0
  99. package/dist/labels/UiokLabels.d.ts +41 -0
  100. package/dist/labels/UiokLabels.js +31 -0
  101. package/dist/labels/UiokProvider.d.ts +44 -0
  102. package/dist/labels/UiokProvider.js +54 -0
  103. package/dist/labels/charts.d.ts +34 -0
  104. package/dist/labels/charts.js +15 -0
  105. package/dist/labels/dateTime.d.ts +32 -0
  106. package/dist/labels/dateTime.js +14 -0
  107. package/dist/labels/dialog.d.ts +18 -0
  108. package/dist/labels/dialog.js +6 -0
  109. package/dist/labels/index.d.ts +13 -0
  110. package/dist/labels/index.js +13 -0
  111. package/dist/labels/keys.d.ts +28 -0
  112. package/dist/labels/keys.js +53 -0
  113. package/dist/labels/legend.d.ts +21 -0
  114. package/dist/labels/legend.js +7 -0
  115. package/dist/labels/listing.d.ts +16 -0
  116. package/dist/labels/listing.js +8 -0
  117. package/dist/labels/pager.d.ts +32 -0
  118. package/dist/labels/pager.js +20 -0
  119. package/dist/labels/palette.d.ts +17 -0
  120. package/dist/labels/palette.js +6 -0
  121. package/dist/labels/selectAll.d.ts +15 -0
  122. package/dist/labels/selectAll.js +6 -0
  123. package/dist/labels/terminal.d.ts +25 -0
  124. package/dist/labels/terminal.js +9 -0
  125. package/dist/legend/KeyLegend.logic.d.ts +84 -0
  126. package/dist/legend/KeyLegend.logic.js +109 -0
  127. package/dist/legend/KeyLegendStrip.d.ts +36 -0
  128. package/dist/legend/KeyLegendStrip.js +82 -0
  129. package/dist/legend/index.d.ts +3 -0
  130. package/dist/legend/index.js +3 -0
  131. package/dist/legend/legend.css +148 -0
  132. package/dist/listing/CurrentDot.d.ts +15 -0
  133. package/dist/listing/CurrentDot.js +13 -0
  134. package/dist/listing/Listing.d.ts +230 -0
  135. package/dist/listing/Listing.js +265 -0
  136. package/dist/listing/PathParts.logic.d.ts +17 -0
  137. package/dist/listing/PathParts.logic.js +18 -0
  138. package/dist/listing/index.d.ts +10 -0
  139. package/dist/listing/index.js +10 -0
  140. package/dist/listing/listing.css +867 -0
  141. package/dist/menu/MenuQuery.logic.d.ts +69 -0
  142. package/dist/menu/MenuQuery.logic.js +75 -0
  143. package/dist/menu/fuzzyMatch.d.ts +31 -0
  144. package/dist/menu/fuzzyMatch.js +296 -0
  145. package/dist/menu/index.d.ts +9 -0
  146. package/dist/menu/index.js +9 -0
  147. package/dist/menu/menu.css +203 -0
  148. package/dist/menu/useBellBeat.d.ts +8 -0
  149. package/dist/menu/useBellBeat.js +26 -0
  150. package/dist/namecut/NameCut.d.ts +22 -0
  151. package/dist/namecut/NameCut.js +28 -0
  152. package/dist/namecut/NameCut.logic.d.ts +51 -0
  153. package/dist/namecut/NameCut.logic.js +120 -0
  154. package/dist/namecut/index.d.ts +3 -0
  155. package/dist/namecut/index.js +3 -0
  156. package/dist/namecut/namecut.css +67 -0
  157. package/dist/pager/Pager.d.ts +37 -0
  158. package/dist/pager/Pager.js +38 -0
  159. package/dist/pager/Pager.logic.d.ts +13 -0
  160. package/dist/pager/Pager.logic.js +63 -0
  161. package/dist/pager/index.d.ts +7 -0
  162. package/dist/pager/index.js +7 -0
  163. package/dist/pager/pager.css +62 -0
  164. package/dist/palette/Palette.d.ts +79 -0
  165. package/dist/palette/Palette.js +60 -0
  166. package/dist/palette/index.d.ts +6 -0
  167. package/dist/palette/index.js +6 -0
  168. package/dist/palette/palette.css +159 -0
  169. package/dist/pane/PaneActions.d.ts +104 -0
  170. package/dist/pane/PaneActions.js +62 -0
  171. package/dist/pane/PaneFrame.d.ts +51 -0
  172. package/dist/pane/PaneFrame.js +28 -0
  173. package/dist/pane/PaneKeys.d.ts +41 -0
  174. package/dist/pane/PaneKeys.js +104 -0
  175. package/dist/pane/PaneKeys.logic.d.ts +95 -0
  176. package/dist/pane/PaneKeys.logic.js +109 -0
  177. package/dist/pane/index.d.ts +11 -0
  178. package/dist/pane/index.js +11 -0
  179. package/dist/pane/usePaneKeys.d.ts +141 -0
  180. package/dist/pane/usePaneKeys.js +313 -0
  181. package/dist/run/RunHeader.d.ts +50 -0
  182. package/dist/run/RunHeader.js +31 -0
  183. package/dist/run/RunProgress.logic.d.ts +29 -0
  184. package/dist/run/RunProgress.logic.js +34 -0
  185. package/dist/run/index.d.ts +3 -0
  186. package/dist/run/index.js +3 -0
  187. package/dist/run/run.css +190 -0
  188. package/dist/segmented/SegmentedChoice.d.ts +22 -0
  189. package/dist/segmented/SegmentedChoice.js +31 -0
  190. package/dist/segmented/index.d.ts +2 -0
  191. package/dist/segmented/index.js +2 -0
  192. package/dist/segmented/segmented.css +49 -0
  193. package/dist/selectall/CheckRange.logic.d.ts +8 -0
  194. package/dist/selectall/CheckRange.logic.js +23 -0
  195. package/dist/selectall/SelectAllBar.d.ts +25 -0
  196. package/dist/selectall/SelectAllBar.js +24 -0
  197. package/dist/selectall/index.d.ts +7 -0
  198. package/dist/selectall/index.js +7 -0
  199. package/dist/selectall/selectall.css +31 -0
  200. package/dist/store/KeepUnchanged.logic.d.ts +19 -0
  201. package/dist/store/KeepUnchanged.logic.js +33 -0
  202. package/dist/store/SameProps.d.ts +15 -0
  203. package/dist/store/SameProps.js +46 -0
  204. package/dist/store/ValueStore.d.ts +17 -0
  205. package/dist/store/ValueStore.js +23 -0
  206. package/dist/store/index.d.ts +8 -0
  207. package/dist/store/index.js +8 -0
  208. package/dist/store/useStableHandlers.d.ts +13 -0
  209. package/dist/store/useStableHandlers.js +22 -0
  210. package/dist/styles.css +85 -0
  211. package/dist/tabs/PageTabs.d.ts +38 -0
  212. package/dist/tabs/PageTabs.js +33 -0
  213. package/dist/tabs/index.d.ts +2 -0
  214. package/dist/tabs/index.js +2 -0
  215. package/dist/tabs/tabs.css +64 -0
  216. package/dist/terminal/Terminal.d.ts +104 -0
  217. package/dist/terminal/Terminal.js +309 -0
  218. package/dist/terminal/Terminal.logic.d.ts +66 -0
  219. package/dist/terminal/Terminal.logic.js +156 -0
  220. package/dist/terminal/TerminalMenu.d.ts +36 -0
  221. package/dist/terminal/TerminalMenu.js +87 -0
  222. package/dist/terminal/TerminalMenu.logic.d.ts +78 -0
  223. package/dist/terminal/TerminalMenu.logic.js +68 -0
  224. package/dist/terminal/TerminalScrollback.d.ts +10 -0
  225. package/dist/terminal/TerminalScrollback.js +11 -0
  226. package/dist/terminal/ghostty/LICENSE +21 -0
  227. package/dist/terminal/ghostty/core.d.ts +315 -0
  228. package/dist/terminal/ghostty/core.js +1189 -0
  229. package/dist/terminal/ghostty/fallbackColors.d.ts +12 -0
  230. package/dist/terminal/ghostty/fallbackColors.js +23 -0
  231. package/dist/terminal/ghostty/fonts/LICENSE +21 -0
  232. package/dist/terminal/ghostty/fonts/SymbolsNerdFontMono-Regular.woff2 +0 -0
  233. package/dist/terminal/ghostty/keyCodes.logic.d.ts +20 -0
  234. package/dist/terminal/ghostty/keyCodes.logic.js +249 -0
  235. package/dist/terminal/ghostty/links.logic.d.ts +39 -0
  236. package/dist/terminal/ghostty/links.logic.js +84 -0
  237. package/dist/terminal/ghostty/renderer.d.ts +98 -0
  238. package/dist/terminal/ghostty/renderer.js +481 -0
  239. package/dist/terminal/ghostty/runtime.d.ts +126 -0
  240. package/dist/terminal/ghostty/runtime.js +346 -0
  241. package/dist/terminal/ghostty/spriteGlyphs.logic.d.ts +64 -0
  242. package/dist/terminal/ghostty/spriteGlyphs.logic.js +546 -0
  243. package/dist/terminal/ghostty/surface.d.ts +285 -0
  244. package/dist/terminal/ghostty/surface.js +1565 -0
  245. package/dist/terminal/ghostty/surface.logic.d.ts +181 -0
  246. package/dist/terminal/ghostty/surface.logic.js +392 -0
  247. package/dist/terminal/ghostty/vendor/LICENSE +21 -0
  248. package/dist/terminal/ghostty/vendor/ghostty-effects.wasm +0 -0
  249. package/dist/terminal/ghostty/vendor/ghostty-vt.wasm +0 -0
  250. package/dist/terminal/index.d.ts +12 -0
  251. package/dist/terminal/index.js +12 -0
  252. package/dist/terminal/terminal.css +169 -0
  253. package/dist/text/MarkedText.d.ts +14 -0
  254. package/dist/text/MarkedText.js +11 -0
  255. package/dist/text/highlightSegments.d.ts +13 -0
  256. package/dist/text/highlightSegments.js +29 -0
  257. package/dist/text/index.d.ts +3 -0
  258. package/dist/text/index.js +3 -0
  259. package/dist/text/text.css +11 -0
  260. package/dist/themes/attributes.d.ts +21 -0
  261. package/dist/themes/attributes.js +41 -0
  262. package/dist/themes/catalog.d.ts +125 -0
  263. package/dist/themes/catalog.js +940 -0
  264. package/dist/themes/color.d.ts +29 -0
  265. package/dist/themes/color.js +52 -0
  266. package/dist/themes/ids.d.ts +139 -0
  267. package/dist/themes/ids.js +59 -0
  268. package/dist/themes/index.d.ts +12 -0
  269. package/dist/themes/index.js +12 -0
  270. package/dist/themes/themes.generated.css +1830 -0
  271. package/dist/themes/tokens.d.ts +189 -0
  272. package/dist/themes/tokens.js +462 -0
  273. package/dist/tooltip/Tooltip.d.ts +21 -0
  274. package/dist/tooltip/Tooltip.js +105 -0
  275. package/dist/tooltip/Tooltip.logic.d.ts +49 -0
  276. package/dist/tooltip/Tooltip.logic.js +50 -0
  277. package/dist/tooltip/index.d.ts +3 -0
  278. package/dist/tooltip/index.js +3 -0
  279. package/dist/tooltip/tooltip.css +45 -0
  280. package/package.json +91 -4
@@ -0,0 +1,121 @@
1
+ /*
2
+ * The pure parts of `DataGrid`: which rows a scrolled viewport shows and
3
+ * when a scroll draws them again, where the cursor cell goes for a key, and
4
+ * how wide a dragged column becomes.
5
+ */
6
+ /** How many rows a grid draws beyond each edge of its viewport. */
7
+ const OVERSCAN = 8;
8
+ /**
9
+ * The rows a viewport draws, `[from, to)`, with `overscan` rows beyond each
10
+ * edge. A grid scrolling one way draws as many rows in all, a quarter of
11
+ * them behind and the rest ahead, so it can keep the rows drawn for a few
12
+ * rows' scroll (`windowHolds`) with `overscan` still ahead.
13
+ */
14
+ export function visibleRows(scrollTop, viewportHeight, rowHeight, rowCount, overscan = OVERSCAN, direction = 0) {
15
+ const first = Math.floor(Math.max(0, scrollTop) / rowHeight);
16
+ const shown = Math.ceil(Math.max(0, viewportHeight) / rowHeight) + 1;
17
+ const behind = direction === 0 ? overscan : Math.floor(overscan / 2);
18
+ const ahead = 2 * overscan - behind;
19
+ return {
20
+ from: Math.max(0, first - (direction < 0 ? ahead : behind)),
21
+ to: Math.min(rowCount, first + shown + (direction < 0 ? behind : ahead))
22
+ };
23
+ }
24
+ /**
25
+ * Whether the rows drawn, `[from, to)`, still serve a viewport scrolled to
26
+ * `scrollTop` that last moved `direction`: they cover it with `overscan`
27
+ * rows to spare ahead of it (beyond both edges before any scroll), or reach
28
+ * that end of the grid, and none lies past its last row. A scroll inside
29
+ * them draws nothing again, and every screen painted has as many rows ahead
30
+ * as a grid drawn again on every scroll would.
31
+ */
32
+ export function windowHolds(drawn, scrollTop, viewportHeight, rowHeight, rowCount, direction, overscan = OVERSCAN) {
33
+ const shown = visibleRows(scrollTop, viewportHeight, rowHeight, rowCount, 0);
34
+ return (drawn.to <= rowCount &&
35
+ drawn.from <= Math.max(0, shown.from - (direction > 0 ? 0 : overscan)) &&
36
+ drawn.to >= Math.min(rowCount, shown.to + (direction < 0 ? 0 : overscan)));
37
+ }
38
+ /** The move a key asks of a grid's cursor, or null for a key it leaves alone. */
39
+ export function gridMove(key, meta) {
40
+ switch (key) {
41
+ case 'ArrowUp':
42
+ return meta ? 'start' : 'up';
43
+ case 'ArrowDown':
44
+ return meta ? 'end' : 'down';
45
+ case 'ArrowLeft':
46
+ return meta ? 'row-start' : 'left';
47
+ case 'ArrowRight':
48
+ return meta ? 'row-end' : 'right';
49
+ case 'PageUp':
50
+ return 'page-up';
51
+ case 'PageDown':
52
+ return 'page-down';
53
+ case 'Home':
54
+ return 'row-start';
55
+ case 'End':
56
+ return 'row-end';
57
+ default:
58
+ return null;
59
+ }
60
+ }
61
+ /**
62
+ * Where a move takes the cursor among `rows` by `columns` cells, stopping
63
+ * at every edge; a page moves `page` rows. No cursor yet starts on the
64
+ * first cell. Null when the grid has no cells.
65
+ */
66
+ export function movedCell(cursor, move, rows, columns, page) {
67
+ if (rows === 0 || columns === 0)
68
+ return null;
69
+ if (cursor === null)
70
+ return { row: 0, column: 0 };
71
+ const clampRow = (row) => Math.min(rows - 1, Math.max(0, row));
72
+ const clampColumn = (column) => Math.min(columns - 1, Math.max(0, column));
73
+ const step = Math.max(1, page);
74
+ switch (move) {
75
+ case 'up':
76
+ return { ...cursor, row: clampRow(cursor.row - 1) };
77
+ case 'down':
78
+ return { ...cursor, row: clampRow(cursor.row + 1) };
79
+ case 'left':
80
+ return { ...cursor, column: clampColumn(cursor.column - 1) };
81
+ case 'right':
82
+ return { ...cursor, column: clampColumn(cursor.column + 1) };
83
+ case 'page-up':
84
+ return { ...cursor, row: clampRow(cursor.row - step) };
85
+ case 'page-down':
86
+ return { ...cursor, row: clampRow(cursor.row + step) };
87
+ case 'row-start':
88
+ return { ...cursor, column: 0 };
89
+ case 'row-end':
90
+ return { ...cursor, column: columns - 1 };
91
+ case 'start':
92
+ return { ...cursor, row: 0 };
93
+ case 'end':
94
+ return { ...cursor, row: rows - 1 };
95
+ }
96
+ }
97
+ /** The narrowest a column can be dragged. */
98
+ export const MINIMUM_COLUMN_WIDTH = 40;
99
+ /** A column's width after its edge is dragged by `delta` pixels from `start`. */
100
+ export const resizedWidth = (start, delta) => Math.max(MINIMUM_COLUMN_WIDTH, Math.round(start + delta));
101
+ /**
102
+ * A column's first width from what it holds: its label and up to the first
103
+ * rows' texts, at `charWidth` pixels a character, between 60 and 360 pixels.
104
+ */
105
+ export function initialWidth(label, samples, charWidth) {
106
+ const longest = Math.max(label.length, ...samples.map((text) => Math.min(text.length, 60)));
107
+ return Math.min(360, Math.max(60, Math.round(longest * charWidth + 20)));
108
+ }
109
+ /**
110
+ * Where a header dragged from `from` lands with the pointer at `x`, among
111
+ * the header cells' edges: the column under the pointer, the first left of
112
+ * them all, the last right of them all.
113
+ */
114
+ export function dropPlace(x, edges, from) {
115
+ if (edges.length === 0)
116
+ return from;
117
+ const at = edges.findIndex((edge) => x >= edge.left && x < edge.right);
118
+ if (at >= 0)
119
+ return at;
120
+ return x < (edges[0]?.left ?? 0) ? 0 : edges.length - 1;
121
+ }
@@ -0,0 +1,206 @@
1
+ /* ---- Data grid (DataGrid) ----
2
+
3
+ Rows of one height on a scrolling well, under a header that stays put,
4
+ cells cut to their column with an ellipsis, the cursor cell ringed in the
5
+ accent. */
6
+ .data-grid {
7
+ position: relative;
8
+ width: max-content;
9
+ max-width: 100%;
10
+ overflow: auto;
11
+ border: 1px solid var(--border);
12
+ border-radius: 4px;
13
+ background: var(--ground);
14
+ color: var(--text);
15
+ font: 12px/22px var(--font-mono);
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ .data-grid:focus-visible {
20
+ outline: 2px solid var(--accent);
21
+ outline-offset: -2px;
22
+ }
23
+
24
+ .data-grid-header {
25
+ position: sticky;
26
+ top: 0;
27
+ z-index: 1;
28
+ display: grid;
29
+ width: max-content;
30
+ min-width: 100%;
31
+ background: var(--surface-header);
32
+ border-bottom: 1px solid var(--border);
33
+ }
34
+
35
+ .data-grid-heading {
36
+ position: relative;
37
+ min-width: 0;
38
+ padding: 0 8px;
39
+ overflow: hidden;
40
+ color: var(--text-dim);
41
+ font-weight: 600;
42
+ text-overflow: ellipsis;
43
+ white-space: nowrap;
44
+ }
45
+
46
+ .data-grid-sort {
47
+ display: inline-flex;
48
+ gap: 4px;
49
+ max-width: 100%;
50
+ padding: 0;
51
+ border: none;
52
+ background: none;
53
+ color: inherit;
54
+ font: inherit;
55
+ cursor: pointer;
56
+ }
57
+
58
+ .data-grid-sort:hover:enabled {
59
+ color: var(--text);
60
+ }
61
+
62
+ .data-grid-arrow {
63
+ font-size: 9px;
64
+ }
65
+
66
+ .data-grid-resize {
67
+ position: absolute;
68
+ top: 0;
69
+ right: 0;
70
+ width: 6px;
71
+ height: 100%;
72
+ border-right: 1px solid var(--border);
73
+ cursor: col-resize;
74
+ touch-action: none;
75
+ }
76
+
77
+ .data-grid-body {
78
+ position: relative;
79
+ }
80
+
81
+ .data-grid-row {
82
+ position: absolute;
83
+ top: 0;
84
+ left: 0;
85
+ display: grid;
86
+ width: max-content;
87
+ min-width: 100%;
88
+ height: 22px;
89
+ }
90
+
91
+ .data-grid-row:nth-child(even) {
92
+ background: color-mix(in srgb, var(--text) 3%, transparent);
93
+ }
94
+
95
+ .data-grid-cell {
96
+ min-width: 0;
97
+ padding: 0 8px;
98
+ overflow: hidden;
99
+ border-right: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
100
+ text-overflow: ellipsis;
101
+ white-space: nowrap;
102
+ cursor: default;
103
+ }
104
+
105
+ .data-grid-cell.align-right,
106
+ .data-grid-heading.align-right {
107
+ text-align: right;
108
+ }
109
+
110
+ .data-grid-cell.cursor {
111
+ background: var(--cursor-row-bg);
112
+ box-shadow: inset 0 0 0 1px var(--accent);
113
+ }
114
+
115
+ .data-grid-action {
116
+ display: flex;
117
+ align-items: center;
118
+ padding: 0 6px;
119
+ }
120
+
121
+ /* A row's controls before its cells: a checkbox and compact icon actions. */
122
+ .data-grid-lead {
123
+ display: flex;
124
+ align-items: center;
125
+ gap: 2px;
126
+ padding: 0 4px;
127
+ border-right: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
128
+ }
129
+
130
+ .data-grid-lead input[type='checkbox'] {
131
+ margin: 0 4px 0 2px;
132
+ }
133
+
134
+ /* A cell whose value opens something: a linked record, a download. */
135
+ .data-grid-link {
136
+ max-width: 100%;
137
+ padding: 0;
138
+ overflow: hidden;
139
+ border: none;
140
+ background: none;
141
+ color: var(--accent);
142
+ font: inherit;
143
+ text-decoration: underline;
144
+ text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
145
+ text-overflow: ellipsis;
146
+ white-space: nowrap;
147
+ cursor: pointer;
148
+ }
149
+
150
+ .data-grid-link:hover:enabled {
151
+ text-decoration-color: var(--accent);
152
+ }
153
+
154
+ /* The row under the pointer, a marked row, and a marked column. */
155
+ .data-grid.pointer .data-grid-row:hover {
156
+ background: var(--hover-wash);
157
+ }
158
+
159
+ .data-grid-row.marked,
160
+ .data-grid-row.marked:hover {
161
+ background: color-mix(in srgb, var(--accent) 14%, transparent);
162
+ }
163
+
164
+ .data-grid-cell.marked,
165
+ .data-grid-heading.marked {
166
+ background: color-mix(in srgb, var(--accent) 10%, transparent);
167
+ }
168
+
169
+ /* A header that drags to a new place, and where it lands. */
170
+ .data-grid-heading.draggable {
171
+ cursor: grab;
172
+ }
173
+
174
+ .data-grid-heading.dragging {
175
+ opacity: 0.5;
176
+ }
177
+
178
+ .data-grid-heading.drop-before {
179
+ box-shadow: inset 2px 0 0 var(--accent);
180
+ }
181
+
182
+ .data-grid-heading.drop-after {
183
+ box-shadow: inset -2px 0 0 var(--accent);
184
+ }
185
+
186
+ .data-grid-arrow small {
187
+ margin-left: 1px;
188
+ font-size: 9px;
189
+ }
190
+
191
+ /* Inline edit: the editor drawn over its cell in a layer of its own, so the
192
+ grid's scrolling box never cuts it, above a dialog the grid sits in and
193
+ under the tooltip; and a value edited but not saved yet (a cell whose
194
+ className holds cell-edited). */
195
+ .data-grid-editor {
196
+ position: fixed;
197
+ z-index: calc(var(--z-dialog) + 1);
198
+ box-sizing: border-box;
199
+ font: 12px/1.4 var(--font-ui);
200
+ white-space: normal;
201
+ cursor: auto;
202
+ }
203
+
204
+ .data-grid-cell.cell-edited {
205
+ background: color-mix(in srgb, var(--warning) 16%, transparent);
206
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `DataGrid`: a virtualised grid of rows with a cursor cell, sortable,
3
+ * resizable, and reorderable columns, row and column marks, and an inline
4
+ * editor layer; plus the pure rules it draws and moves by.
5
+ */
6
+ export { DataGrid, type DataGridCell, type DataGridColumn, type DataGridEditor, type DataGridProps, type DataGridSort, type DataGridSortClick, type DataGridSortMark } from './DataGrid.js';
7
+ export { dropPlace, gridMove, initialWidth, MINIMUM_COLUMN_WIDTH, movedCell, resizedWidth, visibleRows, windowHolds, type GridCell, type GridMove, type ScrollDirection } from './DataGrid.logic.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `DataGrid`: a virtualised grid of rows with a cursor cell, sortable,
3
+ * resizable, and reorderable columns, row and column marks, and an inline
4
+ * editor layer; plus the pure rules it draws and moves by.
5
+ */
6
+ export { DataGrid } from './DataGrid.js';
7
+ export { dropPlace, gridMove, initialWidth, MINIMUM_COLUMN_WIDTH, movedCell, resizedWidth, visibleRows, windowHolds } from './DataGrid.logic.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * UIOK's public API. Every export here is part of the package's contract and
3
+ * carries a docblock; `test/api.test.ts` fails on one that does not. Each
4
+ * area is also importable on its own as `@bigpixelrocket/uiok/<area>`.
5
+ */
6
+ export { VisuallyHidden, type VisuallyHiddenProps } from './VisuallyHidden.js';
7
+ export * from './activity/index.js';
8
+ export * from './button/index.js';
9
+ export * from './charts/index.js';
10
+ export * from './clock/index.js';
11
+ export * from './datetime/index.js';
12
+ export * from './dialog/index.js';
13
+ export * from './filter/index.js';
14
+ export * from './grid/index.js';
15
+ export * from './keyboard/index.js';
16
+ export * from './keychord/index.js';
17
+ export * from './labels/index.js';
18
+ export * from './legend/index.js';
19
+ export * from './listing/index.js';
20
+ export * from './menu/index.js';
21
+ export * from './namecut/index.js';
22
+ export * from './pager/index.js';
23
+ export * from './palette/index.js';
24
+ export * from './pane/index.js';
25
+ export * from './run/index.js';
26
+ export * from './segmented/index.js';
27
+ export * from './selectall/index.js';
28
+ export * from './store/index.js';
29
+ export * from './tabs/index.js';
30
+ export * from './text/index.js';
31
+ export * from './themes/index.js';
32
+ export * from './tooltip/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * UIOK's public API. Every export here is part of the package's contract and
3
+ * carries a docblock; `test/api.test.ts` fails on one that does not. Each
4
+ * area is also importable on its own as `@bigpixelrocket/uiok/<area>`.
5
+ */
6
+ export { VisuallyHidden } from './VisuallyHidden.js';
7
+ export * from './activity/index.js';
8
+ export * from './button/index.js';
9
+ export * from './charts/index.js';
10
+ export * from './clock/index.js';
11
+ export * from './datetime/index.js';
12
+ export * from './dialog/index.js';
13
+ export * from './filter/index.js';
14
+ export * from './grid/index.js';
15
+ export * from './keyboard/index.js';
16
+ export * from './keychord/index.js';
17
+ export * from './labels/index.js';
18
+ export * from './legend/index.js';
19
+ export * from './listing/index.js';
20
+ export * from './menu/index.js';
21
+ export * from './namecut/index.js';
22
+ export * from './pager/index.js';
23
+ export * from './palette/index.js';
24
+ export * from './pane/index.js';
25
+ export * from './run/index.js';
26
+ export * from './segmented/index.js';
27
+ export * from './selectall/index.js';
28
+ export * from './store/index.js';
29
+ export * from './tabs/index.js';
30
+ export * from './text/index.js';
31
+ export * from './themes/index.js';
32
+ export * from './tooltip/index.js';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Cancels a key's browser document behaviour and remembers that the cancel
3
+ * was only that, so a dialog legend bound to the same chord (⌘R) still runs
4
+ * its slot (`isKeyKept`). Propagation goes on, so a feature can still own
5
+ * the key. Part of UIOK's public keyboard contract: an app's window-level
6
+ * guard cancels through this, never through a bare `preventDefault`.
7
+ */
8
+ export declare function cancelBrowserDocumentKey(event: Event): void;
9
+ /**
10
+ * Whether a control has already kept a key: it is cancelled, and not only as
11
+ * a browser document key. A control that answers a chord the app's guard
12
+ * cancels too stops the key's propagation, since the cancel cannot tell the
13
+ * two apart. Part of UIOK's public keyboard contract.
14
+ */
15
+ export declare function isKeyKept(event: Event): boolean;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The keydowns an app cancelled only to keep the browser's document
3
+ * behaviour from them (`shouldSuppressBrowserDocumentKey`: ⌘R anywhere, ⌘[
4
+ * and ⌘→ outside a text field). The app cancels them in the window's capture
5
+ * phase, before any control hears them, so a cancelled key alone does not
6
+ * say a control kept it.
7
+ */
8
+ const browserDocumentCancels = new WeakSet();
9
+ /**
10
+ * Cancels a key's browser document behaviour and remembers that the cancel
11
+ * was only that, so a dialog legend bound to the same chord (⌘R) still runs
12
+ * its slot (`isKeyKept`). Propagation goes on, so a feature can still own
13
+ * the key. Part of UIOK's public keyboard contract: an app's window-level
14
+ * guard cancels through this, never through a bare `preventDefault`.
15
+ */
16
+ export function cancelBrowserDocumentKey(event) {
17
+ event.preventDefault();
18
+ browserDocumentCancels.add(event);
19
+ }
20
+ /**
21
+ * Whether a control has already kept a key: it is cancelled, and not only as
22
+ * a browser document key. A control that answers a chord the app's guard
23
+ * cancels too stops the key's propagation, since the cancel cannot tell the
24
+ * two apart. Part of UIOK's public keyboard contract.
25
+ */
26
+ export function isKeyKept(event) {
27
+ return event.defaultPrevented && !browserDocumentCancels.has(event);
28
+ }
@@ -0,0 +1,25 @@
1
+ import { type KeyLabels } from '../labels/keys.js';
2
+ import type { Chord } from './Keyboard.logic.js';
3
+ /** The modifiers a chord can hold, in the order macOS prints them. */
4
+ export declare const LAYER_MODIFIERS: readonly ["ctrl", "alt", "shift", "meta"];
5
+ /** A modifier a chord or a legend layer can hold. */
6
+ export type LayerModifier = (typeof LAYER_MODIFIERS)[number];
7
+ /** How a modifier is named in labels and accessible names: "Command". */
8
+ export declare function modifierName(modifier: LayerModifier, labels?: KeyLabels): string;
9
+ /** One key of a chord as a legend draws it: a modifier or the trailing key. */
10
+ export type ChordPart = LayerModifier | {
11
+ readonly key: string;
12
+ };
13
+ /** The chord's keys in the order macOS prints them: Control, Option, Shift, Command, then the key. */
14
+ export declare function chordParts(chord: Chord): readonly ChordPart[];
15
+ /**
16
+ * The chord in words, for assistive technology: "Shift Command N". A chord
17
+ * drawn for its modifiers alone (an empty key) speaks only the modifiers.
18
+ */
19
+ export declare function chordSpoken(chord: Chord, labels?: KeyLabels): string;
20
+ /**
21
+ * The chord as macOS menus print it ("⇧⌘G"), for a tooltip or a sentence
22
+ * that names a chord in text rather than drawing its key caps. The space
23
+ * bar, which has no glyph, is written by its name ("⌘Space").
24
+ */
25
+ export declare function chordGlyphs(chord: Chord, labels?: KeyLabels): string;
@@ -0,0 +1,50 @@
1
+ /*
2
+ * How a chord is drawn and spoken, shared by every surface that prints keys:
3
+ * key legends, menus, a settings pane, and a dialog's legend footer. The key
4
+ * caps themselves are `KeyChord`. Names and glyphs come from `KeyLabels`
5
+ * (macOS's English by default), so an app on another platform or in another
6
+ * language passes its own.
7
+ */
8
+ import { DEFAULT_KEY_LABELS } from '../labels/keys.js';
9
+ /** The modifiers a chord can hold, in the order macOS prints them. */
10
+ export const LAYER_MODIFIERS = ['ctrl', 'alt', 'shift', 'meta'];
11
+ /** How a modifier is named in labels and accessible names: "Command". */
12
+ export function modifierName(modifier, labels = DEFAULT_KEY_LABELS) {
13
+ return labels.modifiers[modifier];
14
+ }
15
+ /** The chord's keys in the order macOS prints them: Control, Option, Shift, Command, then the key. */
16
+ export function chordParts(chord) {
17
+ return [
18
+ ...(chord.ctrl ? ['ctrl'] : []),
19
+ ...(chord.alt ? ['alt'] : []),
20
+ ...(chord.shift ? ['shift'] : []),
21
+ ...(chord.meta ? ['meta'] : []),
22
+ { key: chord.key }
23
+ ];
24
+ }
25
+ /** A key's name in words ("Return", "Page Up"); a letter or a digit is its capital itself. */
26
+ const spokenKey = (key, labels) => labels.names[key] ?? key.toUpperCase();
27
+ /**
28
+ * The chord in words, for assistive technology: "Shift Command N". A chord
29
+ * drawn for its modifiers alone (an empty key) speaks only the modifiers.
30
+ */
31
+ export function chordSpoken(chord, labels = DEFAULT_KEY_LABELS) {
32
+ return chordParts(chord)
33
+ .filter((part) => typeof part !== 'object' || part.key !== '')
34
+ .map((part) => typeof part === 'object' ? spokenKey(part.key, labels) : modifierName(part, labels))
35
+ .join(' ');
36
+ }
37
+ /**
38
+ * The chord as macOS menus print it ("⇧⌘G"), for a tooltip or a sentence
39
+ * that names a chord in text rather than drawing its key caps. The space
40
+ * bar, which has no glyph, is written by its name ("⌘Space").
41
+ */
42
+ export function chordGlyphs(chord, labels = DEFAULT_KEY_LABELS) {
43
+ return chordParts(chord)
44
+ .map((part) => typeof part !== 'object'
45
+ ? labels.modifierGlyphs[part]
46
+ : part.key === ' '
47
+ ? spokenKey(' ', labels)
48
+ : (labels.keyGlyphs[part.key] ?? part.key.toUpperCase()))
49
+ .join('');
50
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * One key combination. `key` is `KeyboardEvent.key` for named keys
3
+ * (`ArrowUp`, `Backspace`, `Tab`), a lowercase letter, or a symbol; the
4
+ * modifiers are the ones the chord holds. Every surface that prints or
5
+ * matches a chord shares this shape, so an app's own chords and a
6
+ * component's can be listed side by side.
7
+ */
8
+ export interface Chord {
9
+ readonly key: string;
10
+ readonly ctrl?: boolean;
11
+ readonly meta?: boolean;
12
+ readonly alt?: boolean;
13
+ readonly shift?: boolean;
14
+ }
15
+ /** Modifier state needed to recognize one unmodified macOS Command shortcut. */
16
+ export interface CommandKeyStroke {
17
+ readonly key: string;
18
+ readonly altKey: boolean;
19
+ readonly ctrlKey: boolean;
20
+ readonly metaKey: boolean;
21
+ readonly shiftKey: boolean;
22
+ }
23
+ /**
24
+ * Any open modal dialog or palette, whoever drew it: the ARIA contract every
25
+ * modal surface shares (`isModalOpen`). Part of UIOK's public contract: a
26
+ * surface that holds the window's keys sets `aria-modal="true"`, and an app
27
+ * reads this selector to know one is open. Changing it is a breaking change.
28
+ */
29
+ export declare const MODAL_SELECTOR = "[aria-modal=\"true\"]";
30
+ /**
31
+ * Any open overlay Escape closes: every modal surface (`MODAL_SELECTOR`), and
32
+ * the overlays that leave the window's other keys alone, which carry
33
+ * `data-overlay` instead (a menu, a find bar, a picker popover, a folded
34
+ * list of verbs). While one is open, an app should let Escape close it and
35
+ * hold back a window-level close such as ⌘W (`isOverlayOpen`). Part of
36
+ * UIOK's public contract; changing it is a breaking change.
37
+ */
38
+ export declare const OVERLAY_SELECTOR = "[aria-modal=\"true\"], [data-overlay]";
39
+ /** Whether a key target is a control where native text selection is intentionally available. */
40
+ export declare function isTextEditingTarget(target: EventTarget | null): boolean;
41
+ /**
42
+ * Controls and explicitly focusable surfaces whose native key behavior must
43
+ * survive. An element marks itself (or an ancestor) `data-native-keyboard`
44
+ * to keep its native keys without being a control.
45
+ */
46
+ export declare function isNativeKeyboardTarget(target: EventTarget | null): boolean;
47
+ /**
48
+ * Whether a keydown should lose its browser document behaviour: reload,
49
+ * find, print, save, view source, history, select-all on the page, and page
50
+ * scrolling. Meant for a window-level capture listener that cancels the key
51
+ * through `cancelBrowserDocumentKey` without stopping propagation, so a
52
+ * feature can still own the same key.
53
+ *
54
+ * Text editing and native controls retain the keys that have meaningful
55
+ * focused-control behavior, and a modal dialog retains the page-scroll keys
56
+ * aimed into it: its key legend may bind bare keys (Space to pause) and
57
+ * cancels the key itself when a slot runs. A legend slot bound to a chord
58
+ * cancelled here (⌘R) still runs, because `isKeyKept` tells the two cancels
59
+ * apart.
60
+ */
61
+ export declare function shouldSuppressBrowserDocumentKey(key: CommandKeyStroke, target: EventTarget | null): boolean;
62
+ /**
63
+ * Whether a modal dialog is open anywhere under `root`. Different parts of
64
+ * an app each own their dialogs, so none reads another's state; the ARIA
65
+ * contract is what they share: any `aria-modal="true"` element holds the
66
+ * window's keys until it closes, the way a native sheet blocks the rest of
67
+ * its window. Over a whole document, ask `watchOverlays`, which answers the
68
+ * same without walking every element.
69
+ */
70
+ export declare function isModalOpen(root: {
71
+ readonly querySelector: (selectors: string) => Element | null;
72
+ }): boolean;
73
+ /**
74
+ * Whether any overlay Escape closes is open and in view under `root`, a
75
+ * modal one or one marked `data-overlay` (`OVERLAY_SELECTOR`). An app holds
76
+ * a window-level close such as ⌘W back while it is, so that key closes
77
+ * nothing behind a dialog, a palette, or a menu. An overlay inside a
78
+ * `hidden` ancestor does not count: a view out of sight may keep its menu
79
+ * mounted, and Escape cannot reach it from the view on screen. Over a whole
80
+ * document, ask `watchOverlays`.
81
+ */
82
+ export declare function isOverlayOpen(root: {
83
+ readonly querySelectorAll: (selectors: string) => Iterable<Element>;
84
+ }): boolean;