@crewlethq/ui 0.100.2 → 0.101.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 (51) hide show
  1. package/dist/AgentHandoffPanel/index.js +1 -1
  2. package/dist/AppShell/index.js +3 -3
  3. package/dist/ArtifactCard/index.js +3 -3
  4. package/dist/ContrastBadge/index.js +2 -2
  5. package/dist/ContrastHelp/index.js +3 -3
  6. package/dist/DataGrid/DataGrid.d.ts +127 -41
  7. package/dist/DataGrid/index.d.ts +1 -1
  8. package/dist/DataGrid/index.js +4 -2
  9. package/dist/DataGrid/parts.d.ts +163 -0
  10. package/dist/{DataGrid-SAHEL4SN.css → DataGrid-ERDIPEWV.css} +205 -16
  11. package/dist/DocTabsEditor/index.js +2 -2
  12. package/dist/LogoSlot/index.js +3 -3
  13. package/dist/OrgTable/OrgTable.d.ts +5 -20
  14. package/dist/OrgTable/index.js +10 -3
  15. package/dist/{OrgTable-XYHEFI5X.css → OrgTable-5NXRECVP.css} +29 -9
  16. package/dist/PeekRail/index.js +2 -2
  17. package/dist/RailList/index.js +3 -2
  18. package/dist/RelatedRow/index.js +3 -2
  19. package/dist/SetupWizard/index.js +1 -1
  20. package/dist/SlideFilmstrip/index.js +2 -2
  21. package/dist/TableCells/TableCells.d.ts +10 -2
  22. package/dist/TableCells/index.js +3 -2
  23. package/dist/Text/index.js +2 -1
  24. package/dist/TreeGrid/TreeGrid.d.ts +143 -12
  25. package/dist/TreeGrid/index.d.ts +1 -1
  26. package/dist/TreeGrid/index.js +15 -2
  27. package/dist/{TreeGrid-H3GHMKZX.css → TreeGrid-XZCH5WCC.css} +232 -2
  28. package/dist/{chunk-G44KKOMB.js → chunk-2LLMUJFB.js} +1 -1
  29. package/dist/{chunk-BK4KUIAZ.js → chunk-AP6JSZGT.js} +12 -4
  30. package/dist/chunk-FL5DTFF3.js +557 -0
  31. package/dist/{chunk-CL3FWLDO.js → chunk-HI47TXSW.js} +1 -1
  32. package/dist/{chunk-XQWWA2LG.js → chunk-IQO6YDEM.js} +19 -51
  33. package/dist/{chunk-HTCNTCBE.js → chunk-KMMRKMBQ.js} +1 -1
  34. package/dist/chunk-LIRXQOTR.js +892 -0
  35. package/dist/{chunk-CQIODINH.js → chunk-M2DHVN6T.js} +1 -1
  36. package/dist/chunk-WSIJDWUG.js +10 -0
  37. package/dist/{chunk-O5CEG7TQ.js → chunk-XLMURU75.js} +1 -6
  38. package/dist/generated/index.js +61 -61
  39. package/dist/index.js +61 -61
  40. package/dist/styles.css +469 -30
  41. package/dist/utils/titleIfCut.d.ts +18 -0
  42. package/package.json +3 -3
  43. package/dist/chunk-CCNAGB3F.js +0 -591
  44. package/dist/chunk-CTQZK5J3.js +0 -8
  45. package/dist/chunk-ERESJG6C.js +0 -353
  46. package/dist/{chunk-HEXH3HQJ.js → chunk-A5ISYHW7.js} +2 -2
  47. package/dist/{chunk-YPXXDYTR.js → chunk-AP6SM6BL.js} +1 -1
  48. package/dist/{chunk-GCKHZMWG.js → chunk-E23AXDKL.js} +1 -1
  49. package/dist/{chunk-HBHKMFAH.js → chunk-K2GVWTHA.js} +2 -2
  50. package/dist/{chunk-EW4ULFHK.js → chunk-WTJU7MAG.js} +1 -1
  51. package/dist/{chunk-BGRYFVSK.js → chunk-XHQ2JJCB.js} +1 -1
@@ -1,353 +0,0 @@
1
- import { useTreeState, treeExpandable, treeLevel, treePosInSet, treeSetSize, treeItemAction, treePrevious, treeNext, treeStep } from './chunk-MY374UUD.js';
2
- import { tableTrack } from './chunk-CTQZK5J3.js';
3
- import { LayerNodeBridge } from './chunk-X4HBZSXA.js';
4
- import { IconButton } from './chunk-WDLAAZFZ.js';
5
- import { LayerHost, LAYER_REPOSITION_EVENT } from './chunk-FIX72ZEC.js';
6
- import { focusables } from './chunk-TUEM2XIW.js';
7
- import { VisuallyHidden } from './chunk-UT6CW3C7.js';
8
- import { cx } from './chunk-ODEQTPFM.js';
9
- import './TreeGrid-H3GHMKZX.css';
10
- import { useRef, useState, useLayoutEffect, useEffect, useMemo, useCallback, useImperativeHandle } from 'react';
11
- import { ChevronRightGlyph } from '@crewlethq/icons/glyphs';
12
- import { jsx, jsxs } from 'react/jsx-runtime';
13
-
14
- var LABELS = {
15
- expand: (label) => `Expand ${label}`,
16
- collapse: (label) => `Collapse ${label}`
17
- };
18
- function controlIn(cell) {
19
- return focusables(cell).find((el) => !el.closest('[aria-hidden="true"]')) ?? null;
20
- }
21
- var TEXT_INPUTS = /* @__PURE__ */ new Set(["text", "search", "url", "email", "tel", "password", "number"]);
22
- function caretKey(target, key) {
23
- const lines = target instanceof HTMLTextAreaElement || target.isContentEditable;
24
- const field = lines || target instanceof HTMLInputElement && TEXT_INPUTS.has(target.type);
25
- if (!field) return false;
26
- if (key === "ArrowLeft" || key === "ArrowRight" || key === "Home" || key === "End") return true;
27
- return lines && (key === "ArrowUp" || key === "ArrowDown");
28
- }
29
- function TreeGrid({
30
- label,
31
- columns,
32
- rows: forest,
33
- renderCell,
34
- cellHasControl,
35
- onRowKey,
36
- onRowKeyDown,
37
- hasRowMenu,
38
- addRow,
39
- selectedId = null,
40
- onSelect,
41
- readOnly,
42
- defaultExpanded,
43
- expanded: held,
44
- onExpandedChange,
45
- headless = false,
46
- layout = "scroll",
47
- onWidthChange,
48
- labels,
49
- ref,
50
- className
51
- }) {
52
- const text = { ...LABELS, ...labels };
53
- const frame = useRef(null);
54
- const [width, setWidth] = useState(0);
55
- const reportWidth = useRef(onWidthChange);
56
- reportWidth.current = onWidthChange;
57
- const measures = onWidthChange !== void 0 || columns.some((one) => one.hideBelow !== void 0);
58
- useLayoutEffect(() => {
59
- const el = frame.current;
60
- if (!measures || !el) return;
61
- const read = (next) => setWidth(Math.round(next));
62
- read(el.getBoundingClientRect().width);
63
- if (typeof ResizeObserver !== "function") return;
64
- const observer = new ResizeObserver(([entry]) => {
65
- if (entry) read(entry.contentRect.width);
66
- });
67
- observer.observe(el);
68
- return () => observer.disconnect();
69
- }, [measures]);
70
- useEffect(() => {
71
- if (width > 0) reportWidth.current?.(width);
72
- }, [width]);
73
- const drawn = useMemo(
74
- () => columns.filter((one) => one.hideBelow === void 0 || width <= 0 || width >= one.hideBelow),
75
- [columns, width]
76
- );
77
- const tree = useTreeState(forest, selectedId, { defaultExpanded, expanded: held, onExpandedChange });
78
- const { model, expanded, rows, active, setActive, toggle } = tree;
79
- const [column, setColumn] = useState(null);
80
- const [menuFor, setMenuFor] = useState(null);
81
- const current = useRef({ addRow, onSelect });
82
- current.current = { addRow, onSelect };
83
- const isAddRow = (id) => current.current.addRow?.(id) ?? null;
84
- const rowEls = useRef(/* @__PURE__ */ new Map());
85
- const refs = useRef(/* @__PURE__ */ new Map());
86
- const rowRef = (id) => {
87
- let callback = refs.current.get(id);
88
- if (!callback) {
89
- callback = (el) => {
90
- if (el) rowEls.current.set(id, el);
91
- else rowEls.current.delete(id);
92
- };
93
- refs.current.set(id, callback);
94
- }
95
- return callback;
96
- };
97
- const [request, setRequest] = useState(null);
98
- const focusAt = useCallback(
99
- (id, col) => {
100
- if (current.current.addRow?.(id) == null) current.current.onSelect?.(id);
101
- setActive(id);
102
- setColumn(col);
103
- setRequest({ id, column: col });
104
- },
105
- [setActive]
106
- );
107
- useLayoutEffect(() => {
108
- const row = request ? rowEls.current.get(request.id) : void 0;
109
- if (!request || !row) return;
110
- if (request.column === null) {
111
- row.focus();
112
- return;
113
- }
114
- const cell = row.querySelector(`[aria-colindex="${request.column}"]`);
115
- const control = cell ? controlIn(cell) : null;
116
- (control ?? cell ?? row).focus();
117
- }, [request]);
118
- const focusRef = useRef(() => {
119
- });
120
- focusRef.current = (id) => {
121
- if (!model.parent.has(id)) return;
122
- tree.open(id);
123
- focusAt(id, null);
124
- };
125
- const { expandAll, collapseAll } = tree;
126
- useImperativeHandle(
127
- ref,
128
- () => ({ focusNode: (id) => focusRef.current(id), expandAll, collapseAll }),
129
- [expandAll, collapseAll]
130
- );
131
- function onKeyDownCapture(event) {
132
- const target = event.target;
133
- const row = target.closest("[data-tree-id]");
134
- if (!row) return;
135
- const id = row.getAttribute("data-tree-id");
136
- const onRow = target === row;
137
- const cellIndex = target.closest("[role='gridcell']")?.getAttribute("aria-colindex");
138
- const col = onRow || !cellIndex ? null : Number(cellIndex);
139
- const add = isAddRow(id);
140
- const cells = add ? add.cells : drawn.length;
141
- const handled = () => {
142
- event.preventDefault();
143
- event.stopPropagation();
144
- };
145
- if (onRow && add === null) {
146
- if (onRowKeyDown?.(id, event)) {
147
- handled();
148
- return;
149
- }
150
- const action = treeItemAction(event);
151
- if (action === "menu") {
152
- if (hasRowMenu?.(id)) {
153
- handled();
154
- setMenuFor(id);
155
- }
156
- return;
157
- }
158
- if (action !== null) {
159
- if (onRowKey?.(id, action)) handled();
160
- return;
161
- }
162
- }
163
- if (event.ctrlKey || event.metaKey || event.altKey) return;
164
- const sameColumn = (next) => {
165
- if (next === null) return;
166
- const other = isAddRow(next);
167
- const count = other ? other.cells : drawn.length;
168
- focusAt(next, col === null ? null : Math.min(col, count));
169
- };
170
- if (col !== null && caretKey(target, event.key)) return;
171
- if (col !== null) {
172
- switch (event.key) {
173
- case "ArrowRight":
174
- handled();
175
- if (col < cells) focusAt(id, col + 1);
176
- return;
177
- case "ArrowLeft":
178
- handled();
179
- focusAt(id, col > 1 ? col - 1 : null);
180
- return;
181
- case "Home":
182
- handled();
183
- focusAt(id, 1);
184
- return;
185
- case "End":
186
- handled();
187
- focusAt(id, cells);
188
- return;
189
- case "ArrowDown":
190
- handled();
191
- sameColumn(treeNext(model, expanded, id));
192
- return;
193
- case "ArrowUp":
194
- handled();
195
- sameColumn(treePrevious(model, expanded, id));
196
- return;
197
- default:
198
- return;
199
- }
200
- }
201
- if (event.key === "ArrowRight" && !(treeExpandable(model, id) && !expanded.has(id))) {
202
- handled();
203
- focusAt(id, 1);
204
- return;
205
- }
206
- if (add !== null && event.key === "Enter") {
207
- handled();
208
- focusAt(id, 1);
209
- return;
210
- }
211
- const step = treeStep(tree, id, event);
212
- if (step === void 0) return;
213
- handled();
214
- if (step === null) return;
215
- if ("toggle" in step) toggle(step.toggle);
216
- else focusAt(step.focus, null);
217
- }
218
- const [layer, setLayer] = useState(null);
219
- const onScroll = () => layer?.dispatchEvent(new CustomEvent(LAYER_REPOSITION_EVENT));
220
- const stop = (id, col) => id === active && column === col;
221
- const grid = {
222
- expanded: (id) => expanded.has(id),
223
- expandable: (id) => treeExpandable(model, id),
224
- toggle,
225
- tabStop: stop,
226
- opened: (id, col) => {
227
- setActive(id);
228
- setColumn(col);
229
- },
230
- press: (id) => ({
231
- onMouseDown: (event) => {
232
- event.preventDefault();
233
- focusAt(id, null);
234
- }
235
- }),
236
- menuOpen: (id) => menuFor === id,
237
- setMenuOpen: (id, open) => setMenuFor((was) => open ? id : was === id ? null : was),
238
- columnKey: (col) => drawn[col - 1]?.key,
239
- shown: (key) => drawn.some((one) => one.key === key)
240
- };
241
- const template = drawn.map(tableTrack).join(" ");
242
- return /* @__PURE__ */ jsx(
243
- "div",
244
- {
245
- ref: frame,
246
- className: cx(
247
- "crewlet-tree-grid",
248
- headless && "crewlet-tree-grid--headless",
249
- layout === "container" && "crewlet-tree-grid--container",
250
- className
251
- ),
252
- children: /* @__PURE__ */ jsxs(LayerHost, { className: "crewlet-tree-grid__layer", children: [
253
- /* @__PURE__ */ jsx("div", { className: "crewlet-tree-grid__scroller", onScroll, children: /* @__PURE__ */ jsxs(
254
- "div",
255
- {
256
- role: "treegrid",
257
- "aria-label": label,
258
- "aria-colcount": drawn.length,
259
- "aria-readonly": readOnly || void 0,
260
- className: "crewlet-tree-grid__grid",
261
- style: { "--crewlet-tree-grid-columns": template },
262
- onKeyDownCapture,
263
- children: [
264
- /* @__PURE__ */ jsx("div", { role: "rowgroup", className: "crewlet-tree-grid__head", children: /* @__PURE__ */ jsx("div", { role: "row", className: "crewlet-tree-grid__row", children: drawn.map((one, index) => /* @__PURE__ */ jsx("div", { role: "columnheader", "aria-colindex": index + 1, children: one.headerHidden ? /* @__PURE__ */ jsx(VisuallyHidden, { children: one.header }) : one.header }, one.key)) }) }),
265
- /* @__PURE__ */ jsx("div", { role: "rowgroup", className: "crewlet-tree-grid__body", children: rows.map((id) => {
266
- const add = isAddRow(id);
267
- const cells = add ? add.cells : drawn.length;
268
- const expandable = treeExpandable(model, id);
269
- const open = expanded.has(id);
270
- const name = model.label.get(id) ?? "";
271
- return (
272
- /* The row's keys are the GRID's, captured at the treegrid so
273
- one handler serves every row and reaches a cell's control
274
- first. A listener on the row itself would be a second
275
- place for them to live. */
276
- /* eslint-disable-next-line jsx-a11y/click-events-have-key-events -- see above */
277
- /* @__PURE__ */ jsx(
278
- "div",
279
- {
280
- role: "row",
281
- "data-tree-id": id,
282
- ref: rowRef(id),
283
- tabIndex: id === active && column === null ? 0 : -1,
284
- "aria-level": treeLevel(model, id),
285
- "aria-setsize": treeSetSize(model, id),
286
- "aria-posinset": treePosInSet(model, id),
287
- "aria-expanded": expandable ? open : void 0,
288
- "aria-selected": add ? void 0 : id === selectedId,
289
- "aria-label": add ? add.label : void 0,
290
- className: cx("crewlet-tree-grid__row", add && "crewlet-tree-grid__row--add"),
291
- style: { "--crewlet-tree-grid-depth": treeLevel(model, id) - 1 },
292
- onClick: (event) => {
293
- if (!event.currentTarget.contains(event.target)) return;
294
- if (event.target.closest("button, input, label, [role='menu']")) return;
295
- focusAt(id, null);
296
- },
297
- children: Array.from({ length: cells }, (_, index) => {
298
- const col = index + 1;
299
- return /* @__PURE__ */ jsxs(
300
- "div",
301
- {
302
- role: "gridcell",
303
- "aria-colindex": col,
304
- tabIndex: stop(id, col) && !cellHasControl?.(id, col, drawn[col - 1]?.key ?? "") ? 0 : -1,
305
- "data-size": !add && drawn[col - 1]?.size === "sm" ? "sm" : void 0,
306
- className: "crewlet-tree-grid__cell",
307
- children: [
308
- col === 1 && /* THE PRESS LANDS ON THE ROW. The chevron is a
309
- pointer-only control hidden from assistive
310
- technology (the keyboard opens and closes a row
311
- with Right and Left), and focus inside a hidden
312
- subtree is focus nowhere, so the press is stopped
313
- from focusing it and the row takes the focus. */
314
- /* @__PURE__ */ jsx(
315
- "span",
316
- {
317
- className: "crewlet-tree-grid__toggle",
318
- "data-open": open ? "" : void 0,
319
- "aria-hidden": "true",
320
- ...grid.press(id),
321
- children: expandable && /* @__PURE__ */ jsx(
322
- IconButton,
323
- {
324
- size: "sm",
325
- label: open ? text.collapse(name) : text.expand(name),
326
- icon: /* @__PURE__ */ jsx(ChevronRightGlyph, {}),
327
- tabIndex: -1,
328
- onClick: () => toggle(id)
329
- }
330
- )
331
- }
332
- ),
333
- renderCell(id, col, grid)
334
- ]
335
- },
336
- col
337
- );
338
- })
339
- },
340
- id
341
- )
342
- );
343
- }) })
344
- ]
345
- }
346
- ) }),
347
- /* @__PURE__ */ jsx(LayerNodeBridge, { onNode: setLayer })
348
- ] })
349
- }
350
- );
351
- }
352
-
353
- export { TreeGrid };
@@ -1,9 +1,9 @@
1
1
  import { releaseFocus, usePresence } from './chunk-PCAT2EFB.js';
2
2
  import { useRailShape, RailShapeContext, RailLeavingContext } from './chunk-JLOESTT2.js';
3
- import { Menu } from './chunk-JK6WLRYP.js';
4
3
  import { useMediaMatch } from './chunk-YJQXESOJ.js';
5
- import { isApplePlatform, ariaKeyshortcuts, Kbd } from './chunk-CMAZZY2I.js';
4
+ import { Menu } from './chunk-JK6WLRYP.js';
6
5
  import { PeekContext, AsideContext, ResizeHandle, clampSize } from './chunk-PIYJNCN7.js';
6
+ import { isApplePlatform, ariaKeyshortcuts, Kbd } from './chunk-CMAZZY2I.js';
7
7
  import { HIT_AREA_CLASS } from './chunk-2YTOOH3A.js';
8
8
  import { IconButton } from './chunk-WDLAAZFZ.js';
9
9
  import { Tooltip } from './chunk-QZKGFBAR.js';
@@ -1,5 +1,5 @@
1
- import { Menu } from './chunk-JK6WLRYP.js';
2
1
  import { useReorder } from './chunk-BVML4UVB.js';
2
+ import { Menu } from './chunk-JK6WLRYP.js';
3
3
  import { Input } from './chunk-56ES76ST.js';
4
4
  import { IconButton } from './chunk-WDLAAZFZ.js';
5
5
  import { VisuallyHidden } from './chunk-UT6CW3C7.js';
@@ -1,6 +1,6 @@
1
1
  import { SlideStage } from './chunk-O6EV6GKI.js';
2
- import { Menu } from './chunk-JK6WLRYP.js';
3
2
  import { useReorder } from './chunk-BVML4UVB.js';
3
+ import { Menu } from './chunk-JK6WLRYP.js';
4
4
  import { Kbd, isApplePlatform } from './chunk-CMAZZY2I.js';
5
5
  import { VisuallyHidden } from './chunk-UT6CW3C7.js';
6
6
  import { cx } from './chunk-ODEQTPFM.js';
@@ -3,10 +3,10 @@ import { PrincipalAvatar } from './chunk-HF5L56YQ.js';
3
3
  import { RelativeTime } from './chunk-EJNJMHQG.js';
4
4
  import { Card } from './chunk-U2IQNDDR.js';
5
5
  import { AvatarStack } from './chunk-YTLWOHOY.js';
6
+ import { ArtifactAccessGlyph } from './chunk-DOY3KC6I.js';
6
7
  import { ArtifactKindGround } from './chunk-J5T5TDM2.js';
7
- import { ArtifactKindGlyph } from './chunk-RSKW25Y5.js';
8
8
  import { Checkbox } from './chunk-M6G7XLLP.js';
9
- import { ArtifactAccessGlyph } from './chunk-DOY3KC6I.js';
9
+ import { ArtifactKindGlyph } from './chunk-RSKW25Y5.js';
10
10
  import { VisuallyHidden } from './chunk-UT6CW3C7.js';
11
11
  import { cx } from './chunk-ODEQTPFM.js';
12
12
  import './ArtifactKinds-27TE3KJL.css';
@@ -1,5 +1,5 @@
1
- import { normalizeHex } from './chunk-7W3LYIOC.js';
2
1
  import { Tag } from './chunk-SJ3EUCFD.js';
2
+ import { normalizeHex } from './chunk-7W3LYIOC.js';
3
3
  import { VisuallyHidden } from './chunk-UT6CW3C7.js';
4
4
  import { cx } from './chunk-ODEQTPFM.js';
5
5
  import './ContrastBadge-CBZPGG3G.css';
@@ -1,5 +1,5 @@
1
- import { ButtonLink } from './chunk-6KUOHUY5.js';
2
1
  import { useAppShellPeek, ResizeHandle } from './chunk-PIYJNCN7.js';
2
+ import { ButtonLink } from './chunk-6KUOHUY5.js';
3
3
  import { IconButton } from './chunk-WDLAAZFZ.js';
4
4
  import { cx } from './chunk-ODEQTPFM.js';
5
5
  import './HitArea-QUOS6ZDJ.css';