@crewlethq/ui 0.149.0 → 0.150.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 (44) hide show
  1. package/dist/DataGrid/index.js +2 -1
  2. package/dist/DurationField/DurationField.d.ts +59 -0
  3. package/dist/DurationField/index.d.ts +3 -0
  4. package/dist/DurationField/index.js +32 -0
  5. package/dist/DurationField-TJFIAUMW.css +23 -0
  6. package/dist/LinkInterstitial/index.js +2 -2
  7. package/dist/NumberField/NumberField.d.ts +56 -0
  8. package/dist/NumberField/index.d.ts +3 -0
  9. package/dist/NumberField/index.js +29 -0
  10. package/dist/NumberField-G7H4VNZP.css +30 -0
  11. package/dist/OrgTable/index.js +4 -3
  12. package/dist/PresetChips/PresetChips.d.ts +27 -0
  13. package/dist/PresetChips/index.d.ts +2 -0
  14. package/dist/PresetChips/index.js +21 -0
  15. package/dist/RailList/index.js +3 -3
  16. package/dist/SettingForm/SettingForm.d.ts +50 -0
  17. package/dist/SettingForm/index.d.ts +3 -0
  18. package/dist/SettingForm/index.js +20 -0
  19. package/dist/SettingForm-ODVZZ7JZ.css +30 -0
  20. package/dist/SettingsTable/SettingsTable.d.ts +47 -34
  21. package/dist/SettingsTable/index.d.ts +3 -2
  22. package/dist/SettingsTable/index.js +3 -1
  23. package/dist/SettingsTable-KAMWVCQB.css +169 -0
  24. package/dist/SheetColumnEditor/index.js +1 -1
  25. package/dist/TreeGrid/index.js +3 -2
  26. package/dist/{chunk-5C7MP4C7.js → chunk-3Q5USPLM.js} +1 -1
  27. package/dist/chunk-6QWSGM4W.js +21 -0
  28. package/dist/chunk-BQMDD2FD.js +224 -0
  29. package/dist/chunk-DDGHRDGV.js +134 -0
  30. package/dist/chunk-HU56GCZ7.js +198 -0
  31. package/dist/chunk-NG6GEBSJ.js +53 -0
  32. package/dist/chunk-OX332RI7.js +127 -0
  33. package/dist/{chunk-3SUIU2ZO.js → chunk-Q3SHCEXN.js} +5 -194
  34. package/dist/{chunk-O3CY4MHN.js → chunk-RUKSDKG5.js} +2 -1
  35. package/dist/generated/index.d.ts +4 -0
  36. package/dist/generated/index.js +65 -60
  37. package/dist/index.js +65 -60
  38. package/dist/styles.css +166 -87
  39. package/package.json +3 -3
  40. package/dist/SettingsTable-MTZJTKA6.css +0 -182
  41. package/dist/chunk-RTMFZLU3.js +0 -94
  42. package/dist/{chunk-II7TPQ64.js → chunk-2DASEYUG.js} +0 -0
  43. package/dist/{chunk-UPQ4MDPE.js → chunk-733FZXNS.js} +1 -1
  44. package/dist/{chunk-3GWCWUSY.js → chunk-ECYA6XZL.js} +1 -1
@@ -0,0 +1,198 @@
1
+ import { titleWhenCut, titleIfCut } from './chunk-WSIJDWUG.js';
2
+ import { Button } from './chunk-IMF3CPTY.js';
3
+ import { VisuallyHidden } from './chunk-RRRK2KB6.js';
4
+ import { cx } from './chunk-ODEQTPFM.js';
5
+ import { ArrowDownGlyph, ArrowUpGlyph, ArrowUpDownGlyph } from '@crewlethq/icons/glyphs';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+
8
+ // src/utils/tableTrack.ts
9
+ var SHORT_COLUMN_PX = 192;
10
+ var SHRINK_SHARE = 0.2;
11
+ function tableTrack({ width, shrink, floor, short }) {
12
+ if (width) return width;
13
+ if (shrink) return `fit-content(${SHRINK_SHARE * 100}%)`;
14
+ if (short) return floor === "max-content" || !floor ? "max-content" : `minmax(${floor}, max-content)`;
15
+ return `minmax(${floor ?? 0}, 1fr)`;
16
+ }
17
+ var GRID_ICON_TRACK = "calc(var(--size-target-min) + var(--spacing-3) * 2)";
18
+ function alignOf(column) {
19
+ return column.align ?? (column.icon ? "center" : "left");
20
+ }
21
+ function headerWord(column) {
22
+ return typeof column.header === "string" ? column.header : "";
23
+ }
24
+ function columnName(column) {
25
+ return headerWord(column) || column.label || column.key;
26
+ }
27
+ function parseGridSort(raw) {
28
+ if (!raw) return null;
29
+ return raw.startsWith("-") ? { key: raw.slice(1), desc: true } : { key: raw, desc: false };
30
+ }
31
+ function nextGridSort(column, sort, defaultSort = "") {
32
+ const chosen = sort === defaultSort ? "" : sort;
33
+ const current = parseGridSort(chosen || defaultSort);
34
+ let next;
35
+ if (current?.key !== column) next = column;
36
+ else if (!current.desc) next = `-${column}`;
37
+ else next = chosen ? "" : column;
38
+ return next === defaultSort ? "" : next;
39
+ }
40
+ function compare(a, b) {
41
+ if (typeof a === "number" && typeof b === "number") {
42
+ if (Number.isNaN(a)) return Number.isNaN(b) ? 0 : 1;
43
+ if (Number.isNaN(b)) return -1;
44
+ return a < b ? -1 : a > b ? 1 : 0;
45
+ }
46
+ return String(a).localeCompare(String(b), void 0, { numeric: true, sensitivity: "base" });
47
+ }
48
+ function sortByValue(items, get, desc) {
49
+ return [...items].sort((a, b) => {
50
+ const av = get(a);
51
+ const bv = get(b);
52
+ if (av == null && bv == null) return 0;
53
+ if (av == null) return 1;
54
+ if (bv == null) return -1;
55
+ const cmp = compare(av, bv);
56
+ return desc ? -cmp : cmp;
57
+ });
58
+ }
59
+ var GRID_FOOT_LABELS = {
60
+ hiddenToFit: (names) => `Hidden to fit: ${names}`,
61
+ loadMore: "Load more",
62
+ showEveryColumn: "Show every column",
63
+ and: "and"
64
+ };
65
+ function droppedNames(columns, dropped, and) {
66
+ const names = dropped.map((key) => {
67
+ const c = columns.find((col) => col.key === key);
68
+ return c ? columnName(c) : key;
69
+ });
70
+ return names.length <= 1 ? names[0] ?? "" : `${names.slice(0, -1).join(", ")} ${and} ${names[names.length - 1]}`;
71
+ }
72
+ function GridHeadCell({
73
+ column,
74
+ sort,
75
+ sortable,
76
+ onSort,
77
+ hidden = false,
78
+ colIndex,
79
+ actionsLabel
80
+ }) {
81
+ const align = alignOf(column);
82
+ const sorted = sort?.key === column.key;
83
+ const headClass = cx(
84
+ "crewlet-data-grid__th",
85
+ align !== "left" && `crewlet-data-grid__th--${align}`,
86
+ column.icon && "crewlet-data-grid__th--icon",
87
+ column.shrink && "crewlet-data-grid__th--shrink",
88
+ sorted && "crewlet-data-grid__th--sorted",
89
+ !sortable && "crewlet-data-grid__th--plain"
90
+ );
91
+ const worded = column.header !== "" && column.header !== null && column.header !== void 0;
92
+ const label = !worded ? null : hidden ? /* @__PURE__ */ jsx(VisuallyHidden, { children: column.header }) : /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__truncate", onMouseEnter: titleWhenCut, children: column.header });
93
+ const arrow = sorted ? sort?.desc ? /* @__PURE__ */ jsx(ArrowDownGlyph, { size: "xs" }) : /* @__PURE__ */ jsx(ArrowUpGlyph, { size: "xs" }) : sortable ? /* @__PURE__ */ jsx(ArrowUpDownGlyph, { size: "xs" }) : null;
94
+ const ariaSort = sorted ? sort?.desc ? "descending" : "ascending" : void 0;
95
+ const mark = arrow && /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__sort-mark", "aria-hidden": "true", children: arrow });
96
+ if (!sortable) {
97
+ const word = headerWord(column);
98
+ const glyph = !word && !column.action ? column.label : void 0;
99
+ const named = word ? void 0 : glyph ?? (column.action && !worded ? column.label ?? actionsLabel : void 0);
100
+ return /* @__PURE__ */ jsxs("div", { className: headClass, role: "columnheader", "aria-colindex": colIndex, title: glyph, "aria-sort": ariaSort, children: [
101
+ label,
102
+ mark,
103
+ named && /* @__PURE__ */ jsx(VisuallyHidden, { children: named })
104
+ ] });
105
+ }
106
+ return /* @__PURE__ */ jsx("div", { className: headClass, role: "columnheader", "aria-colindex": colIndex, "aria-sort": ariaSort, children: /* @__PURE__ */ jsxs(
107
+ "button",
108
+ {
109
+ type: "button",
110
+ className: "crewlet-data-grid__sort",
111
+ onClick: onSort,
112
+ "aria-label": headerWord(column) ? void 0 : column.label,
113
+ children: [
114
+ label,
115
+ mark
116
+ ]
117
+ }
118
+ ) });
119
+ }
120
+ function GridFoot({ footer, dropped, loadedNote, onLoadMore, onReset, labels, columns }) {
121
+ const shows = Boolean(footer) || Boolean(onLoadMore) || Boolean(loadedNote) || dropped !== "";
122
+ if (!shows && !onReset) return null;
123
+ const table = columns !== void 0;
124
+ const cell = (className, children) => table ? /* @__PURE__ */ jsx("div", { role: "cell", "aria-colspan": columns, className, children }) : /* @__PURE__ */ jsx("div", { className, children });
125
+ return /* @__PURE__ */ jsxs("div", { role: table ? "rowgroup" : void 0, className: "crewlet-data-grid__foot-group", children: [
126
+ shows && /* @__PURE__ */ jsx("div", { role: table ? "row" : void 0, className: "crewlet-data-grid__foot", children: cell(
127
+ "crewlet-data-grid__foot-cell",
128
+ /* @__PURE__ */ jsxs(Fragment, { children: [
129
+ footer,
130
+ /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__foot-spacer", "aria-hidden": "true" }),
131
+ dropped !== "" && /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__note", children: labels.hiddenToFit(dropped) }),
132
+ loadedNote && /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__note", children: loadedNote }),
133
+ onLoadMore && /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", onClick: onLoadMore, children: labels.loadMore })
134
+ ] })
135
+ ) }),
136
+ onReset && /* @__PURE__ */ jsx("div", { role: table ? "row" : void 0, className: "crewlet-data-grid__reset", children: cell(
137
+ "crewlet-data-grid__reset-cell",
138
+ /* @__PURE__ */ jsx("button", { type: "button", className: "crewlet-data-grid__cols-reset", onClick: onReset, children: labels.showEveryColumn })
139
+ ) })
140
+ ] });
141
+ }
142
+ var CUT = ".crewlet-data-grid__truncate, .crewlet-table-cell__truncate, .crewlet-text--truncate";
143
+ function titleBeneath(link, x, y) {
144
+ const row = link.closest('[role="row"]');
145
+ if (!row || typeof document.elementsFromPoint !== "function") return null;
146
+ const under = document.elementsFromPoint(x, y).find((el) => el !== link && row.contains(el) && el !== row);
147
+ if (!under) return null;
148
+ const titled = under.closest("[title]");
149
+ const own = titled && row.contains(titled) && titled !== row ? titled : null;
150
+ if (own && !own.matches(CUT)) return own.getAttribute("title");
151
+ const cut = under.closest(CUT);
152
+ if (cut && row.contains(cut)) {
153
+ titleIfCut(cut);
154
+ return cut.getAttribute("title");
155
+ }
156
+ return own?.getAttribute("title") ?? null;
157
+ }
158
+ var rowLinkTitle = {
159
+ onMouseMove: (event) => {
160
+ const title = titleBeneath(event.currentTarget, event.clientX, event.clientY);
161
+ if (title) event.currentTarget.setAttribute("title", title);
162
+ else event.currentTarget.removeAttribute("title");
163
+ },
164
+ onMouseLeave: (event) => event.currentTarget.removeAttribute("title")
165
+ };
166
+ var SQUEEZE_SAMPLE_ROWS = 12;
167
+ function overrunning(box, head) {
168
+ const last = head?.lastElementChild;
169
+ if (!last) return false;
170
+ const inner = box.getBoundingClientRect().left + box.clientLeft + box.clientWidth;
171
+ return last.getBoundingClientRect().right > inner + 0.5;
172
+ }
173
+ function cutShort(el) {
174
+ for (const node of [el, ...el.querySelectorAll("*")]) {
175
+ const box = node;
176
+ if (box.clientWidth > 1 && box.scrollWidth > box.clientWidth + 1) return true;
177
+ }
178
+ return false;
179
+ }
180
+ function squeezedCells(width, heads, rows, cellsOf, visible, leading = 0) {
181
+ const cap = width * SHRINK_SHARE - 1;
182
+ const sample = rows.slice(0, SQUEEZE_SAMPLE_ROWS);
183
+ let headCut = false;
184
+ for (let i = 0; i < visible.length; i++) {
185
+ const column = visible[i];
186
+ if (!column.shrink || column.width || column.icon) continue;
187
+ const head = heads[i + leading];
188
+ if (!head || head.getBoundingClientRect().width >= cap) continue;
189
+ if (cutShort(head)) headCut = true;
190
+ for (const row of sample) {
191
+ const cell = cellsOf(row)[i + leading];
192
+ if (cell && cutShort(cell)) return "values";
193
+ }
194
+ }
195
+ return headCut ? "heads" : null;
196
+ }
197
+
198
+ export { GRID_FOOT_LABELS, GRID_ICON_TRACK, GridFoot, GridHeadCell, SHORT_COLUMN_PX, alignOf, droppedNames, headerWord, nextGridSort, overrunning, parseGridSort, rowLinkTitle, sortByValue, squeezedCells, tableTrack };
@@ -0,0 +1,53 @@
1
+ import { FormField } from './chunk-XQMRSL7Z.js';
2
+ import { Button } from './chunk-IMF3CPTY.js';
3
+ import { cx } from './chunk-ODEQTPFM.js';
4
+ import './SettingForm-ODVZZ7JZ.css';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ var SETTING_FORM_LABELS = { save: "Save", cancel: "Cancel" };
8
+ function SettingForm({
9
+ label,
10
+ htmlFor,
11
+ subject,
12
+ children,
13
+ hint,
14
+ error,
15
+ status,
16
+ onSave,
17
+ onCancel,
18
+ saving = false,
19
+ saveHeld,
20
+ saveLabel,
21
+ labels: overrides,
22
+ className,
23
+ ...rest
24
+ }) {
25
+ const labels = { ...SETTING_FORM_LABELS, ...overrides };
26
+ const submit = (event) => {
27
+ event.preventDefault();
28
+ if (saving || saveHeld !== void 0) return;
29
+ onSave();
30
+ };
31
+ return /* @__PURE__ */ jsxs("form", { ...rest, noValidate: true, "aria-busy": saving || void 0, className: cx("crewlet-setting-form", className), onSubmit: submit, children: [
32
+ subject ? /* @__PURE__ */ jsx("p", { className: "crewlet-setting-form__subject", children: subject }) : null,
33
+ /* @__PURE__ */ jsx(FormField, { htmlFor, label, helper: hint, error, children }),
34
+ status ? /* @__PURE__ */ jsx("div", { className: "crewlet-setting-form__status", children: status }) : null,
35
+ /* @__PURE__ */ jsxs("div", { className: "crewlet-setting-form__actions", children: [
36
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "small", variant: "ghost", onClick: onCancel, children: labels.cancel }),
37
+ /* @__PURE__ */ jsx(
38
+ Button,
39
+ {
40
+ type: "submit",
41
+ size: "small",
42
+ variant: "primary",
43
+ loading: saving,
44
+ disabledReason: saveHeld,
45
+ tooltip: saveHeld !== void 0,
46
+ children: saveLabel ?? labels.save
47
+ }
48
+ )
49
+ ] })
50
+ ] });
51
+ }
52
+
53
+ export { SETTING_FORM_LABELS, SettingForm };
@@ -0,0 +1,127 @@
1
+ import { Select } from './chunk-657WR3MX.js';
2
+ import { typedNumber, NumberField } from './chunk-DDGHRDGV.js';
3
+ import { PresetChips } from './chunk-6QWSGM4W.js';
4
+ import { cx } from './chunk-ODEQTPFM.js';
5
+ import './DurationField-TJFIAUMW.css';
6
+ import { useId } from 'react';
7
+ import { jsxs, jsx } from 'react/jsx-runtime';
8
+
9
+ var DURATION_UNIT_SECONDS = {
10
+ days: 86400,
11
+ hours: 3600,
12
+ minutes: 60,
13
+ seconds: 1
14
+ };
15
+ var UNITS_LARGEST_FIRST = ["days", "hours", "minutes", "seconds"];
16
+ var DURATION_FIELD_LABELS = {
17
+ units: {
18
+ seconds: ["second", "seconds"],
19
+ minutes: ["minute", "minutes"],
20
+ hours: ["hour", "hours"],
21
+ days: ["day", "days"]
22
+ },
23
+ unit: "Unit",
24
+ defaultPreset: (words) => `Default (${words})`,
25
+ presets: "Common durations",
26
+ decrease: "Decrease",
27
+ increase: "Increase"
28
+ };
29
+ function unitOf(seconds, units) {
30
+ const ordered = UNITS_LARGEST_FIRST.filter((u) => units.includes(u));
31
+ for (const unit of ordered) {
32
+ if (seconds !== 0 && seconds % DURATION_UNIT_SECONDS[unit] === 0) return unit;
33
+ }
34
+ return ordered[ordered.length - 1] ?? "seconds";
35
+ }
36
+ function durationValue(seconds, fallback = null, units = UNITS_LARGEST_FIRST) {
37
+ if (seconds === null) return { amount: "", unit: unitOf(fallback ?? 0, units) };
38
+ const unit = unitOf(seconds, units);
39
+ return { amount: String(seconds / DURATION_UNIT_SECONDS[unit]), unit };
40
+ }
41
+ function durationSeconds(value) {
42
+ if (value.amount.trim() === "") return null;
43
+ const n = typedNumber(value.amount);
44
+ return n === null ? Number.NaN : n * DURATION_UNIT_SECONDS[value.unit];
45
+ }
46
+ function durationWords(seconds, labels = DURATION_FIELD_LABELS) {
47
+ const { amount, unit } = durationValue(seconds);
48
+ const n = Number(amount);
49
+ const [one, many] = labels.units[unit];
50
+ return `${n.toLocaleString()} ${n === 1 ? one : many}`;
51
+ }
52
+ function DurationField({
53
+ id,
54
+ value,
55
+ onValueChange,
56
+ defaultValue,
57
+ min,
58
+ max,
59
+ units = UNITS_LARGEST_FIRST,
60
+ presets,
61
+ error,
62
+ disabled = false,
63
+ focusOnMount,
64
+ labels: overrides,
65
+ className,
66
+ ...aria
67
+ }) {
68
+ const labels = { ...DURATION_FIELD_LABELS, ...overrides };
69
+ const unitId = useId();
70
+ const size = DURATION_UNIT_SECONDS[value.unit];
71
+ const fallback = defaultValue === void 0 ? void 0 : defaultValue / size;
72
+ const seconds = durationSeconds(value);
73
+ const words = (s) => durationWords(s, labels);
74
+ const chosen = seconds === null ? "" : (presets ?? []).find((p) => p === seconds) !== void 0 ? String(seconds) : "#typed";
75
+ const chips = [
76
+ ...defaultValue === void 0 ? [] : [{ value: "", label: labels.defaultPreset(words(defaultValue)) }],
77
+ ...(presets ?? []).map((p) => ({ value: String(p), label: words(p) }))
78
+ ];
79
+ return /* @__PURE__ */ jsxs("div", { className: cx("crewlet-duration-field", className), children: [
80
+ /* @__PURE__ */ jsxs("div", { className: "crewlet-duration-field__row", children: [
81
+ /* @__PURE__ */ jsx(
82
+ NumberField,
83
+ {
84
+ id,
85
+ value: value.amount,
86
+ onValueChange: (amount) => onValueChange({ amount, unit: value.unit }),
87
+ defaultValue: fallback !== void 0 && Number.isInteger(fallback) ? fallback : void 0,
88
+ min: min === void 0 ? 0 : Math.ceil(min / size),
89
+ max: max === void 0 ? void 0 : Math.floor(max / size),
90
+ error,
91
+ disabled,
92
+ focusOnMount,
93
+ "aria-label": aria["aria-label"],
94
+ "aria-describedby": aria["aria-describedby"],
95
+ labels: { decrease: labels.decrease, increase: labels.increase },
96
+ className: "crewlet-duration-field__amount"
97
+ }
98
+ ),
99
+ /* @__PURE__ */ jsx(
100
+ Select,
101
+ {
102
+ id: unitId,
103
+ ariaLabel: labels.unit,
104
+ size: "md",
105
+ width: "auto",
106
+ disabled,
107
+ value: value.unit,
108
+ options: UNITS_LARGEST_FIRST.filter((u) => units.includes(u)).reverse().map((u) => ({ value: u, label: labels.units[u][1] })),
109
+ onChange: (next) => onValueChange({ amount: value.amount, unit: next }),
110
+ className: "crewlet-duration-field__unit"
111
+ }
112
+ )
113
+ ] }),
114
+ chips.length > 0 ? /* @__PURE__ */ jsx(
115
+ PresetChips,
116
+ {
117
+ label: labels.presets,
118
+ options: chips,
119
+ value: chosen,
120
+ disabled,
121
+ onPick: (picked) => onValueChange(picked === "" ? durationValue(null, defaultValue ?? null, units) : durationValue(Number(picked), null, units))
122
+ }
123
+ ) : null
124
+ ] });
125
+ }
126
+
127
+ export { DURATION_FIELD_LABELS, DURATION_UNIT_SECONDS, DurationField, durationSeconds, durationValue, durationWords };
@@ -1,208 +1,19 @@
1
+ import { GRID_FOOT_LABELS, GRID_ICON_TRACK, headerWord, sortByValue, parseGridSort, overrunning, tableTrack, GridHeadCell, GridFoot, droppedNames, nextGridSort, rowLinkTitle, squeezedCells, SHORT_COLUMN_PX, alignOf } from './chunk-HU56GCZ7.js';
1
2
  import { Skeleton } from './chunk-WFAJYBLX.js';
2
- import { titleWhenCut, titleIfCut } from './chunk-WSIJDWUG.js';
3
+ import { titleWhenCut } from './chunk-WSIJDWUG.js';
3
4
  import { useReorder } from './chunk-JMBPMSNI.js';
4
5
  import { Checkbox } from './chunk-BRMJPZC4.js';
5
6
  import { EmptyState } from './chunk-PPUR46MK.js';
6
7
  import { useMediaMatch } from './chunk-COS6LJ4K.js';
7
- import { Button } from './chunk-IMF3CPTY.js';
8
8
  import { IconButton } from './chunk-KM5OKCW6.js';
9
9
  import { VisuallyHidden } from './chunk-RRRK2KB6.js';
10
10
  import { cx } from './chunk-ODEQTPFM.js';
11
11
  import './DataGrid-XX6ALDIM.css';
12
12
  import { useId, useRef, useState, useMemo, useCallback, useLayoutEffect, useImperativeHandle, useSyncExternalStore, useEffect, Fragment as Fragment$1 } from 'react';
13
13
  import { breakpoint } from '@crewlethq/tokens';
14
- import { ArrowDownGlyph, ArrowUpGlyph, ArrowUpDownGlyph, GripVerticalGlyph, ChevronRightGlyph } from '@crewlethq/icons/glyphs';
15
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
+ import { GripVerticalGlyph, ChevronRightGlyph } from '@crewlethq/icons/glyphs';
15
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
16
16
 
17
- // src/utils/tableTrack.ts
18
- var SHORT_COLUMN_PX = 192;
19
- var SHRINK_SHARE = 0.2;
20
- function tableTrack({ width, shrink, floor, short }) {
21
- if (width) return width;
22
- if (shrink) return `fit-content(${SHRINK_SHARE * 100}%)`;
23
- if (short) return floor === "max-content" || !floor ? "max-content" : `minmax(${floor}, max-content)`;
24
- return `minmax(${floor ?? 0}, 1fr)`;
25
- }
26
- var GRID_ICON_TRACK = "calc(var(--size-target-min) + var(--spacing-3) * 2)";
27
- function alignOf(column) {
28
- return column.align ?? (column.icon ? "center" : "left");
29
- }
30
- function headerWord(column) {
31
- return typeof column.header === "string" ? column.header : "";
32
- }
33
- function columnName(column) {
34
- return headerWord(column) || column.label || column.key;
35
- }
36
- function parseGridSort(raw) {
37
- if (!raw) return null;
38
- return raw.startsWith("-") ? { key: raw.slice(1), desc: true } : { key: raw, desc: false };
39
- }
40
- function nextGridSort(column, sort, defaultSort = "") {
41
- const chosen = sort === defaultSort ? "" : sort;
42
- const current2 = parseGridSort(chosen || defaultSort);
43
- let next;
44
- if (current2?.key !== column) next = column;
45
- else if (!current2.desc) next = `-${column}`;
46
- else next = chosen ? "" : column;
47
- return next === defaultSort ? "" : next;
48
- }
49
- function compare(a, b) {
50
- if (typeof a === "number" && typeof b === "number") {
51
- if (Number.isNaN(a)) return Number.isNaN(b) ? 0 : 1;
52
- if (Number.isNaN(b)) return -1;
53
- return a < b ? -1 : a > b ? 1 : 0;
54
- }
55
- return String(a).localeCompare(String(b), void 0, { numeric: true, sensitivity: "base" });
56
- }
57
- function sortByValue(items, get, desc) {
58
- return [...items].sort((a, b) => {
59
- const av = get(a);
60
- const bv = get(b);
61
- if (av == null && bv == null) return 0;
62
- if (av == null) return 1;
63
- if (bv == null) return -1;
64
- const cmp = compare(av, bv);
65
- return desc ? -cmp : cmp;
66
- });
67
- }
68
- var GRID_FOOT_LABELS = {
69
- hiddenToFit: (names) => `Hidden to fit: ${names}`,
70
- loadMore: "Load more",
71
- showEveryColumn: "Show every column",
72
- and: "and"
73
- };
74
- function droppedNames(columns, dropped, and) {
75
- const names = dropped.map((key) => {
76
- const c = columns.find((col) => col.key === key);
77
- return c ? columnName(c) : key;
78
- });
79
- return names.length <= 1 ? names[0] ?? "" : `${names.slice(0, -1).join(", ")} ${and} ${names[names.length - 1]}`;
80
- }
81
- function GridHeadCell({
82
- column,
83
- sort,
84
- sortable,
85
- onSort,
86
- hidden = false,
87
- colIndex,
88
- actionsLabel
89
- }) {
90
- const align = alignOf(column);
91
- const sorted = sort?.key === column.key;
92
- const headClass = cx(
93
- "crewlet-data-grid__th",
94
- align !== "left" && `crewlet-data-grid__th--${align}`,
95
- column.icon && "crewlet-data-grid__th--icon",
96
- column.shrink && "crewlet-data-grid__th--shrink",
97
- sorted && "crewlet-data-grid__th--sorted",
98
- !sortable && "crewlet-data-grid__th--plain"
99
- );
100
- const worded = column.header !== "" && column.header !== null && column.header !== void 0;
101
- const label = !worded ? null : hidden ? /* @__PURE__ */ jsx(VisuallyHidden, { children: column.header }) : /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__truncate", onMouseEnter: titleWhenCut, children: column.header });
102
- const arrow = sorted ? sort?.desc ? /* @__PURE__ */ jsx(ArrowDownGlyph, { size: "xs" }) : /* @__PURE__ */ jsx(ArrowUpGlyph, { size: "xs" }) : sortable ? /* @__PURE__ */ jsx(ArrowUpDownGlyph, { size: "xs" }) : null;
103
- const ariaSort = sorted ? sort?.desc ? "descending" : "ascending" : void 0;
104
- const mark = arrow && /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__sort-mark", "aria-hidden": "true", children: arrow });
105
- if (!sortable) {
106
- const word = headerWord(column);
107
- const glyph = !word && !column.action ? column.label : void 0;
108
- const named = word ? void 0 : glyph ?? (column.action && !worded ? column.label ?? actionsLabel : void 0);
109
- return /* @__PURE__ */ jsxs("div", { className: headClass, role: "columnheader", "aria-colindex": colIndex, title: glyph, "aria-sort": ariaSort, children: [
110
- label,
111
- mark,
112
- named && /* @__PURE__ */ jsx(VisuallyHidden, { children: named })
113
- ] });
114
- }
115
- return /* @__PURE__ */ jsx("div", { className: headClass, role: "columnheader", "aria-colindex": colIndex, "aria-sort": ariaSort, children: /* @__PURE__ */ jsxs(
116
- "button",
117
- {
118
- type: "button",
119
- className: "crewlet-data-grid__sort",
120
- onClick: onSort,
121
- "aria-label": headerWord(column) ? void 0 : column.label,
122
- children: [
123
- label,
124
- mark
125
- ]
126
- }
127
- ) });
128
- }
129
- function GridFoot({ footer, dropped, loadedNote, onLoadMore, onReset, labels, columns }) {
130
- const shows = Boolean(footer) || Boolean(onLoadMore) || Boolean(loadedNote) || dropped !== "";
131
- if (!shows && !onReset) return null;
132
- const table = columns !== void 0;
133
- const cell = (className, children) => table ? /* @__PURE__ */ jsx("div", { role: "cell", "aria-colspan": columns, className, children }) : /* @__PURE__ */ jsx("div", { className, children });
134
- return /* @__PURE__ */ jsxs("div", { role: table ? "rowgroup" : void 0, className: "crewlet-data-grid__foot-group", children: [
135
- shows && /* @__PURE__ */ jsx("div", { role: table ? "row" : void 0, className: "crewlet-data-grid__foot", children: cell(
136
- "crewlet-data-grid__foot-cell",
137
- /* @__PURE__ */ jsxs(Fragment, { children: [
138
- footer,
139
- /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__foot-spacer", "aria-hidden": "true" }),
140
- dropped !== "" && /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__note", children: labels.hiddenToFit(dropped) }),
141
- loadedNote && /* @__PURE__ */ jsx("span", { className: "crewlet-data-grid__note", children: loadedNote }),
142
- onLoadMore && /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", onClick: onLoadMore, children: labels.loadMore })
143
- ] })
144
- ) }),
145
- onReset && /* @__PURE__ */ jsx("div", { role: table ? "row" : void 0, className: "crewlet-data-grid__reset", children: cell(
146
- "crewlet-data-grid__reset-cell",
147
- /* @__PURE__ */ jsx("button", { type: "button", className: "crewlet-data-grid__cols-reset", onClick: onReset, children: labels.showEveryColumn })
148
- ) })
149
- ] });
150
- }
151
- var CUT = ".crewlet-data-grid__truncate, .crewlet-table-cell__truncate, .crewlet-text--truncate";
152
- function titleBeneath(link, x, y) {
153
- const row = link.closest('[role="row"]');
154
- if (!row || typeof document.elementsFromPoint !== "function") return null;
155
- const under = document.elementsFromPoint(x, y).find((el) => el !== link && row.contains(el) && el !== row);
156
- if (!under) return null;
157
- const titled = under.closest("[title]");
158
- const own = titled && row.contains(titled) && titled !== row ? titled : null;
159
- if (own && !own.matches(CUT)) return own.getAttribute("title");
160
- const cut = under.closest(CUT);
161
- if (cut && row.contains(cut)) {
162
- titleIfCut(cut);
163
- return cut.getAttribute("title");
164
- }
165
- return own?.getAttribute("title") ?? null;
166
- }
167
- var rowLinkTitle = {
168
- onMouseMove: (event) => {
169
- const title = titleBeneath(event.currentTarget, event.clientX, event.clientY);
170
- if (title) event.currentTarget.setAttribute("title", title);
171
- else event.currentTarget.removeAttribute("title");
172
- },
173
- onMouseLeave: (event) => event.currentTarget.removeAttribute("title")
174
- };
175
- var SQUEEZE_SAMPLE_ROWS = 12;
176
- function overrunning(box, head) {
177
- const last = head?.lastElementChild;
178
- if (!last) return false;
179
- const inner = box.getBoundingClientRect().left + box.clientLeft + box.clientWidth;
180
- return last.getBoundingClientRect().right > inner + 0.5;
181
- }
182
- function cutShort(el) {
183
- for (const node of [el, ...el.querySelectorAll("*")]) {
184
- const box = node;
185
- if (box.clientWidth > 1 && box.scrollWidth > box.clientWidth + 1) return true;
186
- }
187
- return false;
188
- }
189
- function squeezedCells(width, heads, rows, cellsOf, visible, leading = 0) {
190
- const cap = width * SHRINK_SHARE - 1;
191
- const sample = rows.slice(0, SQUEEZE_SAMPLE_ROWS);
192
- let headCut = false;
193
- for (let i = 0; i < visible.length; i++) {
194
- const column = visible[i];
195
- if (!column.shrink || column.width || column.icon) continue;
196
- const head = heads[i + leading];
197
- if (!head || head.getBoundingClientRect().width >= cap) continue;
198
- if (cutShort(head)) headCut = true;
199
- for (const row of sample) {
200
- const cell = cellsOf(row)[i + leading];
201
- if (cell && cutShort(cell)) return "values";
202
- }
203
- }
204
- return headCut ? "heads" : null;
205
- }
206
17
  var DATA_GRID_ICON_TRACK = GRID_ICON_TRACK;
207
18
  function sortsBy(column) {
208
19
  return column.sortable ?? column.sortValue !== void 0;
@@ -987,4 +798,4 @@ function useAnyDataGridDriving() {
987
798
  return drivable.length > 0;
988
799
  }
989
800
 
990
- export { ChooserList, ColumnChooser, DATA_GRID_ICON_TRACK, DataGrid, GRID_FOOT_LABELS, GRID_ICON_TRACK, GridFoot, GridHeadCell, alignOf, columnChoicesOf, countDataGridRows, droppedNames, fitGridColumns, headerWord, nextGridSort, overrunning, parseGridSort, rowLinkTitle, sortByValue, sortGridRows, squeezedCells, tableTrack, useAnyDataGridDriving, useDataGridDriving };
801
+ export { ChooserList, ColumnChooser, DATA_GRID_ICON_TRACK, DataGrid, columnChoicesOf, countDataGridRows, fitGridColumns, sortGridRows, useAnyDataGridDriving, useDataGridDriving };
@@ -1,5 +1,6 @@
1
1
  import { useTreeState, treeExpandable, treeLevel, treePosInSet, treeSetSize, treeItemAction, treePrevious, treeNext, treeStep } from './chunk-MY374UUD.js';
2
- import { GRID_FOOT_LABELS, parseGridSort, overrunning, squeezedCells, fitGridColumns, tableTrack, GRID_ICON_TRACK, GridHeadCell, alignOf, rowLinkTitle, headerWord, GridFoot, droppedNames, nextGridSort, sortByValue } from './chunk-3SUIU2ZO.js';
2
+ import { fitGridColumns } from './chunk-Q3SHCEXN.js';
3
+ import { GRID_FOOT_LABELS, parseGridSort, overrunning, squeezedCells, tableTrack, GRID_ICON_TRACK, GridHeadCell, alignOf, rowLinkTitle, headerWord, GridFoot, droppedNames, nextGridSort, sortByValue } from './chunk-HU56GCZ7.js';
3
4
  import { LayerNodeBridge } from './chunk-CUEPPDBC.js';
4
5
  import { Checkbox } from './chunk-BRMJPZC4.js';
5
6
  import { EmptyState } from './chunk-PPUR46MK.js';
@@ -95,6 +95,7 @@ export * from '../DockColumn/index.js';
95
95
  export * from '../Document/index.js';
96
96
  export * from '../DocumentDiff/index.js';
97
97
  export * from '../DownloadButton/index.js';
98
+ export * from '../DurationField/index.js';
98
99
  export * from '../EditingStatus/index.js';
99
100
  export * from '../EmojiPicker/index.js';
100
101
  export * from '../EmptyState/index.js';
@@ -158,6 +159,7 @@ export * from '../Modal/index.js';
158
159
  export * from '../NewItemsNotice/index.js';
159
160
  export * from '../Note/index.js';
160
161
  export * from '../NoticeList/index.js';
162
+ export * from '../NumberField/index.js';
161
163
  export * from '../ObjectHeader/index.js';
162
164
  export * from '../OpenInAppCard/index.js';
163
165
  export * from '../OrgLabel/index.js';
@@ -176,6 +178,7 @@ export * from '../PresenceModel/index.js';
176
178
  export * from '../PresenceRing/index.js';
177
179
  export * from '../PresenceStack/index.js';
178
180
  export * from '../PresenterView/index.js';
181
+ export * from '../PresetChips/index.js';
179
182
  export * from '../PricingCard/index.js';
180
183
  export * from '../Principal/index.js';
181
184
  export * from '../PrincipalPicker/index.js';
@@ -208,6 +211,7 @@ export * from '../Select/index.js';
208
211
  export * from '../SelectionBar/index.js';
209
212
  export * from '../SendButton/index.js';
210
213
  export * from '../SendKeys/index.js';
214
+ export * from '../SettingForm/index.js';
211
215
  export * from '../SettingsTable/index.js';
212
216
  export * from '../SetupWizard/index.js';
213
217
  export * from '../ShareDialog/index.js';