@crewlethq/ui 0.39.0 → 0.40.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 (93) hide show
  1. package/README.md +43 -1
  2. package/dist/AppShell/AppShell.d.ts +13 -2
  3. package/dist/AppShell/index.js +1 -1
  4. package/dist/{AppShell-NDU4XMGF.css → AppShell-NPSWZ3XW.css} +45 -4
  5. package/dist/ArtifactBar/index.js +6 -5
  6. package/dist/AvatarPicker/index.js +10 -6
  7. package/dist/CatalogTile/index.js +1 -1
  8. package/dist/{CatalogTile-TGR2ZZVQ.css → CatalogTile-XL4XLFUH.css} +8 -4
  9. package/dist/CharacterPicker/index.js +2 -2
  10. package/dist/Charts/Histogram.d.ts +71 -0
  11. package/dist/Charts/index.d.ts +2 -0
  12. package/dist/Charts/index.js +1 -1
  13. package/dist/{Charts-MBJG72BS.css → Charts-TZ744HT6.css} +118 -0
  14. package/dist/DataGrid/DataGrid.d.ts +267 -0
  15. package/dist/DataGrid/index.d.ts +3 -0
  16. package/dist/DataGrid/index.js +7 -0
  17. package/dist/DataGrid-AQKPJD7W.css +482 -0
  18. package/dist/HuePicker/index.js +11 -4
  19. package/dist/LayersList/index.js +2 -2
  20. package/dist/LockedLabel/LockedLabel.d.ts +34 -0
  21. package/dist/LockedLabel/index.d.ts +3 -0
  22. package/dist/LockedLabel/index.js +3 -0
  23. package/dist/LockedLabel-VQEGEB7G.css +16 -0
  24. package/dist/MarkdownEditor/index.js +8 -5
  25. package/dist/MergeConflicts/index.js +11 -5
  26. package/dist/PageNote/PageNote.d.ts +14 -0
  27. package/dist/PageNote/index.d.ts +3 -0
  28. package/dist/PageNote/index.js +2 -0
  29. package/dist/PageNote-RHLXH3ML.css +12 -0
  30. package/dist/PropertyList/PropertyList.d.ts +88 -0
  31. package/dist/PropertyList/index.d.ts +3 -0
  32. package/dist/PropertyList/index.js +7 -0
  33. package/dist/PropertyList-SCYM66LL.css +96 -0
  34. package/dist/RelatedRow/RelatedRow.d.ts +27 -0
  35. package/dist/RelatedRow/index.d.ts +3 -0
  36. package/dist/RelatedRow/index.js +9 -0
  37. package/dist/RelatedRow-2FVS6QQA.css +6 -0
  38. package/dist/RichEditor/index.js +1 -1
  39. package/dist/SectionFrame/SectionFrame.d.ts +76 -0
  40. package/dist/SectionFrame/index.d.ts +3 -0
  41. package/dist/SectionFrame/index.js +7 -0
  42. package/dist/SectionFrame-M62UUVFQ.css +164 -0
  43. package/dist/SegmentedControl/index.js +11 -4
  44. package/dist/SheetColumnEditor/index.js +6 -5
  45. package/dist/SheetGrid/index.js +3 -3
  46. package/dist/SidebarNav/SidebarNav.d.ts +35 -2
  47. package/dist/SidebarNav/index.js +2 -1
  48. package/dist/{SidebarNav-7SGUZYKK.css → SidebarNav-YI74SPDC.css} +10 -0
  49. package/dist/Tabs/Tabs.d.ts +55 -1
  50. package/dist/Tabs/fold.d.ts +54 -0
  51. package/dist/Tabs/index.d.ts +1 -1
  52. package/dist/Tabs/index.js +9 -2
  53. package/dist/Tabs/roving.d.ts +3 -3
  54. package/dist/{Tabs-WIF7457H.css → Tabs-S7F4RWAN.css} +77 -0
  55. package/dist/TagsInput/index.js +1 -1
  56. package/dist/ThemeGallery/index.js +2 -2
  57. package/dist/ThemeSwitcher/index.js +12 -5
  58. package/dist/VersionCompare/index.js +12 -5
  59. package/dist/{chunk-B5J23C73.js → chunk-2PEXZ7L4.js} +1 -1
  60. package/dist/{chunk-TZYFTC4M.js → chunk-2VOHUGUA.js} +1 -1
  61. package/dist/{chunk-2QZ2VPHR.js → chunk-4OK4DX3V.js} +2 -2
  62. package/dist/{chunk-ECGGQX2H.js → chunk-A44YHLCQ.js} +2 -2
  63. package/dist/{chunk-F4LPQA4E.js → chunk-BA32AVKS.js} +1 -1
  64. package/dist/chunk-CV4NES3P.js +9 -0
  65. package/dist/{chunk-PPHTIKZO.js → chunk-E4BOVKNJ.js} +1 -1
  66. package/dist/{chunk-W7PAIVAP.js → chunk-E7QLG3PG.js} +30 -9
  67. package/dist/{chunk-RKKO7QHH.js → chunk-EGMQURBR.js} +5 -4
  68. package/dist/{chunk-GMW4ZHST.js → chunk-EX22Q5SH.js} +2 -2
  69. package/dist/{chunk-F3WZ5AKM.js → chunk-GFYQKMQZ.js} +1 -1
  70. package/dist/{chunk-HG5VF3TZ.js → chunk-HMVQQEHW.js} +91 -2
  71. package/dist/chunk-INVSUFJK.js +71 -0
  72. package/dist/{chunk-4LRAJXHL.js → chunk-JSWOXRRE.js} +1 -1
  73. package/dist/{chunk-DYB66CNM.js → chunk-KKNHMXTE.js} +6 -3
  74. package/dist/{chunk-ZMDYQ2HH.js → chunk-KWWP3D7M.js} +1 -1
  75. package/dist/{chunk-46RL3E54.js → chunk-M6NQ4XGK.js} +1 -1
  76. package/dist/chunk-OHGH7O6T.js +19 -0
  77. package/dist/{chunk-4ISUIS6F.js → chunk-OOC7Q67K.js} +1 -1
  78. package/dist/{chunk-XNXK5MA4.js → chunk-PCT47E7O.js} +1 -1
  79. package/dist/{chunk-X3UYTAOG.js → chunk-PFZOFAQ6.js} +1 -1
  80. package/dist/{chunk-YEVG2X5R.js → chunk-SNQRGH4A.js} +1 -1
  81. package/dist/chunk-T6MXORP5.js +116 -0
  82. package/dist/chunk-X4IXXLWM.js +306 -0
  83. package/dist/chunk-XIDD7PJO.js +416 -0
  84. package/dist/chunk-ZUTUI27P.js +21 -0
  85. package/dist/generated/index.d.ts +6 -0
  86. package/dist/generated/index.js +60 -54
  87. package/dist/index.js +60 -54
  88. package/dist/styles.css +1061 -17
  89. package/package.json +3 -3
  90. package/dist/chunk-7SDUKCNW.js +0 -141
  91. package/dist/{Editor-QV4JP242.js → Editor-IRDQ3JDZ.js} +1 -1
  92. package/dist/{chunk-JZPK4IXR.js → chunk-3PR65I3H.js} +2 -2
  93. /package/dist/{chunk-QRLIWCLX.js → chunk-S3QTFUJX.js} +0 -0
@@ -0,0 +1,71 @@
1
+ import { SidebarNav } from './chunk-E7QLG3PG.js';
2
+ import { VisuallyHidden } from './chunk-BZFWDIV6.js';
3
+ import { cx } from './chunk-ODEQTPFM.js';
4
+ import './SectionFrame-M62UUVFQ.css';
5
+ import { useState, useId } from 'react';
6
+ import { ChevronDownGlyph } from '@crewlethq/icons/glyphs';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
+
9
+ function SectionFrame({ columnWidth, folded = false, className, children }) {
10
+ return /* @__PURE__ */ jsx(
11
+ "div",
12
+ {
13
+ className: cx("crewlet-section-frame", className),
14
+ "data-folded": folded || void 0,
15
+ style: { "--crewlet-section-frame-column": columnWidth },
16
+ children
17
+ }
18
+ );
19
+ }
20
+ function SectionFrameNav({ scope, current, location, openOnArrival = false, children }) {
21
+ const [open, setOpen] = useState(openOnArrival);
22
+ const [openedAt, setOpenedAt] = useState(location);
23
+ const [picked, setPicked] = useState(null);
24
+ if (openedAt !== location) {
25
+ setOpenedAt(location);
26
+ setOpen(picked !== location && openOnArrival);
27
+ setPicked(null);
28
+ }
29
+ const listId = useId();
30
+ function pick(event) {
31
+ const link = event.target.closest("a[href]");
32
+ if (!link) return;
33
+ setOpen(false);
34
+ const to = link.getAttribute("href");
35
+ if (to !== null && to !== location) setPicked(to);
36
+ }
37
+ return /* @__PURE__ */ jsxs("div", { className: "crewlet-section-frame__nav", "data-open": open || void 0, children: [
38
+ /* @__PURE__ */ jsxs(
39
+ "button",
40
+ {
41
+ type: "button",
42
+ className: "crewlet-section-frame__toggle",
43
+ "aria-expanded": open,
44
+ "aria-controls": listId,
45
+ onClick: () => setOpen((was) => !was),
46
+ children: [
47
+ current?.icon ? /* @__PURE__ */ jsx("span", { className: "crewlet-section-frame__toggle-icon", "aria-hidden": "true", children: current.icon }) : null,
48
+ /* @__PURE__ */ jsx("span", { className: "crewlet-section-frame__toggle-name", children: current ? /* @__PURE__ */ jsxs(Fragment, { children: [
49
+ /* @__PURE__ */ jsxs("span", { className: "crewlet-section-frame__toggle-prefix", children: [
50
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: scope }),
51
+ " Section",
52
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " \xB7" }),
53
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: ":" })
54
+ ] }),
55
+ " ",
56
+ current.label
57
+ ] }) : `${scope} sections` }),
58
+ /* @__PURE__ */ jsx(ChevronDownGlyph, { size: "xs", "aria-hidden": "true", className: "crewlet-section-frame__chevron" })
59
+ ]
60
+ }
61
+ ),
62
+ /* @__PURE__ */ jsx("div", { id: listId, className: "crewlet-section-frame__list", onClick: pick, children: /* @__PURE__ */ jsx(SidebarNav, { label: `${scope} sections`, children }) })
63
+ ] });
64
+ }
65
+ function SectionFrameBody({ children, className }) {
66
+ return /* @__PURE__ */ jsx("div", { className: cx("crewlet-section-frame__body", className), children });
67
+ }
68
+ SectionFrame.Nav = SectionFrameNav;
69
+ SectionFrame.Body = SectionFrameBody;
70
+
71
+ export { SectionFrame, SectionFrameBody, SectionFrameNav };
@@ -1,5 +1,5 @@
1
1
  import { diffLines, diffStat, collapseDiff, DiffSummary, DiffView } from './chunk-BVWSLXTY.js';
2
- import { SegmentedControl } from './chunk-2QZ2VPHR.js';
2
+ import { SegmentedControl } from './chunk-4OK4DX3V.js';
3
3
  import { EmptyState } from './chunk-RA2ULG6H.js';
4
4
  import { useHeadingLevel, headingTag, nextHeadingLevel, HeadingLevelProvider } from './chunk-PQADV6P6.js';
5
5
  import { cx } from './chunk-ODEQTPFM.js';
@@ -6,7 +6,7 @@ import { IconButton } from './chunk-4FQT6ZAY.js';
6
6
  import { VisuallyHidden } from './chunk-BZFWDIV6.js';
7
7
  import { cx } from './chunk-ODEQTPFM.js';
8
8
  import './HitArea-QUOS6ZDJ.css';
9
- import './AppShell-NDU4XMGF.css';
9
+ import './AppShell-NPSWZ3XW.css';
10
10
  import { createContext, forwardRef, useContext, useId, useState, useRef, useCallback, useEffect, useLayoutEffect } from 'react';
11
11
  import { breakpoint } from '@crewlethq/tokens';
12
12
  import { ChevronUpGlyph, ChevronsUpDownGlyph, ChevronRightGlyph, MenuGlyph } from '@crewlethq/icons/glyphs';
@@ -231,10 +231,13 @@ function ShellDrawer({
231
231
  }
232
232
  );
233
233
  }
234
- function AppShellRail({ header, footer, className, children }) {
234
+ function AppShellRail({ header, search, footer, className, children }) {
235
235
  return /* @__PURE__ */ jsxs("div", { className: cx("crewlet-app-shell__rail-inner", className), children: [
236
236
  header ? /* @__PURE__ */ jsx("div", { className: "crewlet-app-shell__rail-head", children: header }) : null,
237
- /* @__PURE__ */ jsx("div", { className: "crewlet-app-shell__rail-body", children }),
237
+ /* @__PURE__ */ jsxs("div", { className: "crewlet-app-shell__rail-body", children: [
238
+ search ? /* @__PURE__ */ jsx("div", { className: "crewlet-app-shell__rail-search", children: search }) : null,
239
+ children
240
+ ] }),
238
241
  footer ? /* @__PURE__ */ jsx("div", { className: "crewlet-app-shell__rail-foot", children: footer }) : null
239
242
  ] });
240
243
  }
@@ -1,5 +1,5 @@
1
1
  import { useThemePreference, useDensityPreference } from './chunk-Z24ZUSTX.js';
2
- import { SegmentedControl } from './chunk-2QZ2VPHR.js';
2
+ import { SegmentedControl } from './chunk-4OK4DX3V.js';
3
3
  import { SunGlyph, MonitorGlyph, MoonGlyph } from '@crewlethq/icons/glyphs';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
@@ -1,4 +1,4 @@
1
- import { useRoving } from './chunk-RKKO7QHH.js';
1
+ import { useRoving } from './chunk-EGMQURBR.js';
2
2
  import { cx } from './chunk-ODEQTPFM.js';
3
3
  import './LayersList-TBNF4XGL.css';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
@@ -0,0 +1,19 @@
1
+ import { VisuallyHidden } from './chunk-BZFWDIV6.js';
2
+ import { cx } from './chunk-ODEQTPFM.js';
3
+ import './LockedLabel-VQEGEB7G.css';
4
+ import { KeyGlyph } from '@crewlethq/icons/glyphs';
5
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
6
+
7
+ function LockedLabel({ children, reason, mark = true, className }) {
8
+ if (reason === void 0 || reason === "") return /* @__PURE__ */ jsx(Fragment, { children });
9
+ return /* @__PURE__ */ jsxs("span", { className: cx("crewlet-locked-label", className), title: reason, children: [
10
+ children,
11
+ mark ? /* @__PURE__ */ jsx(KeyGlyph, { size: "xs", "aria-hidden": "true", className: "crewlet-locked-label__key" }) : null,
12
+ /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
13
+ ", ",
14
+ reason
15
+ ] })
16
+ ] });
17
+ }
18
+
19
+ export { LockedLabel };
@@ -1,3 +1,3 @@
1
1
  import './HitArea-QUOS6ZDJ.css';
2
- import './Tabs-WIF7457H.css';
2
+ import './Tabs-S7F4RWAN.css';
3
3
  import './SegmentedControl-B7XCUOML.css';
@@ -1,6 +1,6 @@
1
1
  import { useHeadingLevel, headingTag } from './chunk-PQADV6P6.js';
2
2
  import { cx } from './chunk-ODEQTPFM.js';
3
- import './CatalogTile-TGR2ZZVQ.css';
3
+ import './CatalogTile-XL4XLFUH.css';
4
4
  import { useId } from 'react';
5
5
  import { jsxs, jsx } from 'react/jsx-runtime';
6
6
 
@@ -9,7 +9,7 @@ import { jsx } from 'react/jsx-runtime';
9
9
  var engine = null;
10
10
  var loading = null;
11
11
  function loadEngine() {
12
- loading ??= import('./Editor-QV4JP242.js').then(
12
+ loading ??= import('./Editor-IRDQ3JDZ.js').then(
13
13
  (module) => {
14
14
  engine = module.Editor;
15
15
  return engine;
@@ -1,4 +1,4 @@
1
- import { useRoving, tabStop } from './chunk-RKKO7QHH.js';
1
+ import { useRoving, tabStop } from './chunk-EGMQURBR.js';
2
2
  import { Avatar } from './chunk-PZKHBB7D.js';
3
3
  import { cx } from './chunk-ODEQTPFM.js';
4
4
  import { CREWLET_CHARACTERS, CREWLET_CHARACTER_GEOMETRY } from '@crewlethq/icons/characters';
@@ -0,0 +1,116 @@
1
+ import { SetByLine } from './chunk-ODOJJGXH.js';
2
+ import { Link } from './chunk-FBSEJO2C.js';
3
+ import { DescriptionList, DescriptionListItem } from './chunk-MFS6F2P7.js';
4
+ import { EmptyValue } from './chunk-EUCC37WY.js';
5
+ import { cx } from './chunk-ODEQTPFM.js';
6
+ import './PropertyList-SCYM66LL.css';
7
+ import { useId, Fragment } from 'react';
8
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
9
+
10
+ function absent(value) {
11
+ return value === null || value === void 0 || value === "";
12
+ }
13
+ function drawnSetBy(item) {
14
+ if (!item.setBy) return void 0;
15
+ if (absent(item.value) && !item.setBy.cleared) return void 0;
16
+ return item.setBy;
17
+ }
18
+ function attributions(items) {
19
+ const out = items.map(() => void 0);
20
+ let start = -1;
21
+ let key = "";
22
+ const close = (end) => {
23
+ if (start < 0) return;
24
+ out[end] = {
25
+ setBy: drawnSetBy(items[start]),
26
+ labels: items.slice(start, end + 1).map((item) => item.label)
27
+ };
28
+ start = -1;
29
+ key = "";
30
+ };
31
+ items.forEach((item, i) => {
32
+ const line = drawnSetBy(item);
33
+ if (!line) {
34
+ close(i - 1);
35
+ return;
36
+ }
37
+ const next = [line.actor, line.ago, line.turnHref, line.cleared, item.change].join("\0");
38
+ if (start >= 0 && next === key) return;
39
+ close(i - 1);
40
+ start = i;
41
+ key = next;
42
+ });
43
+ close(items.length - 1);
44
+ return out;
45
+ }
46
+ function PropertyList({
47
+ groups,
48
+ headings = "eyebrow",
49
+ emptyLabel = "Not set",
50
+ turnLabel,
51
+ "aria-label": ariaLabel,
52
+ className
53
+ }) {
54
+ const id = useId();
55
+ return /* @__PURE__ */ jsx(
56
+ "div",
57
+ {
58
+ role: ariaLabel ? "group" : void 0,
59
+ "aria-label": ariaLabel,
60
+ className: cx("crewlet-property-list", `crewlet-property-list--${headings}`, className),
61
+ children: groups.map((group, index) => {
62
+ const headingId = `${id}-group-${index}`;
63
+ const collapsed = group.whenAllAbsent !== void 0 && group.items.every((item) => absent(item.value));
64
+ const lines = collapsed ? [] : attributions(group.items);
65
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
66
+ group.name ? /* @__PURE__ */ jsx("div", { id: headingId, className: "crewlet-property-list__heading", children: group.name }) : null,
67
+ collapsed ? /* @__PURE__ */ jsx("p", { className: "crewlet-property-list__empty", children: group.whenAllAbsent }) : /* @__PURE__ */ jsx(
68
+ DescriptionList,
69
+ {
70
+ className: "crewlet-property-list__group",
71
+ "aria-labelledby": group.name ? headingId : void 0,
72
+ children: group.items.map((item, row) => {
73
+ const line = lines[row];
74
+ return /* @__PURE__ */ jsxs(
75
+ DescriptionListItem,
76
+ {
77
+ term: item.title || item.identifierLabel ? /* @__PURE__ */ jsx(
78
+ "span",
79
+ {
80
+ title: item.title,
81
+ className: item.identifierLabel ? "crewlet-property-list__identifier" : void 0,
82
+ children: item.label
83
+ }
84
+ ) : item.label,
85
+ children: [
86
+ /* @__PURE__ */ jsx(Value, { item, emptyLabel }),
87
+ line ? /* @__PURE__ */ jsx(
88
+ SetByLine,
89
+ {
90
+ setBy: line.setBy,
91
+ fields: line.labels,
92
+ turnLabel,
93
+ className: "crewlet-property-list__set-by"
94
+ }
95
+ ) : null
96
+ ]
97
+ },
98
+ item.label
99
+ );
100
+ })
101
+ }
102
+ )
103
+ ] }, group.name ?? index);
104
+ })
105
+ }
106
+ );
107
+ }
108
+ function Value({ item, emptyLabel }) {
109
+ if (absent(item.value)) return /* @__PURE__ */ jsx(EmptyValue, { label: emptyLabel });
110
+ if (item.href) {
111
+ return /* @__PURE__ */ jsx(Link, { href: item.href, size: "inherit", children: item.value });
112
+ }
113
+ return /* @__PURE__ */ jsx(Fragment$1, { children: item.value });
114
+ }
115
+
116
+ export { PropertyList };
@@ -0,0 +1,306 @@
1
+ import { StatusDot } from './chunk-WIATRXEJ.js';
2
+ import { useRoving, tabStop } from './chunk-EGMQURBR.js';
3
+ import { Count } from './chunk-BHHIIK3M.js';
4
+ import { Menu } from './chunk-D6FEHY5G.js';
5
+ import { HIT_AREA_CLASS } from './chunk-2YTOOH3A.js';
6
+ import { VisuallyHidden } from './chunk-BZFWDIV6.js';
7
+ import { cx } from './chunk-ODEQTPFM.js';
8
+ import './HitArea-QUOS6ZDJ.css';
9
+ import './Tabs-S7F4RWAN.css';
10
+ import React, { useRef, useImperativeHandle, useLayoutEffect, useState } from 'react';
11
+ import { ChevronDownGlyph } from '@crewlethq/icons/glyphs';
12
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
13
+
14
+ function foldTabs({
15
+ widths,
16
+ current,
17
+ space,
18
+ gap,
19
+ more
20
+ }) {
21
+ const all = widths.reduce((sum, w) => sum + w, 0) + gap * Math.max(0, widths.length - 1);
22
+ if (all <= space) return [];
23
+ let used = more + (current >= 0 ? (widths[current] ?? 0) + gap : 0);
24
+ const kept = new Set(current >= 0 ? [current] : []);
25
+ for (let i = 0; i < widths.length; i++) {
26
+ if (i === current) continue;
27
+ const next = used + (widths[i] ?? 0) + gap;
28
+ if (next > space) break;
29
+ used = next;
30
+ kept.add(i);
31
+ }
32
+ return widths.map((_, i) => i).filter((i) => !kept.has(i));
33
+ }
34
+ function noteFits({
35
+ widths,
36
+ space,
37
+ gap,
38
+ note
39
+ }) {
40
+ if (note <= 0) return false;
41
+ const tabs = widths.reduce((sum, w) => sum + w, 0) + gap * Math.max(0, widths.length - 1);
42
+ return tabs + gap + note <= space;
43
+ }
44
+ var NOTHING_FOLDED = { folded: [], note: true };
45
+ var px = (value) => parseFloat(value) || 0;
46
+ var widthOf = (el) => el ? el.getBoundingClientRect().width : 0;
47
+ function useFold(enabled, box, row, values, current) {
48
+ const [fold, setFold] = useState(NOTHING_FOLDED);
49
+ const signature = values.join("\n");
50
+ useLayoutEffect(() => {
51
+ const outer = box.current;
52
+ const inner = row.current;
53
+ if (!enabled || !outer || !inner) return;
54
+ const keys = signature === "" ? [] : signature.split("\n");
55
+ const measure = () => {
56
+ const boxStyle = getComputedStyle(outer);
57
+ let space = outer.clientWidth - px(boxStyle.paddingLeft) - px(boxStyle.paddingRight);
58
+ const rowStyle = getComputedStyle(inner);
59
+ const gap = px(rowStyle.columnGap);
60
+ let more = widthOf(outer.querySelector("[data-tabs-more]"));
61
+ if (inner !== outer) {
62
+ space -= px(rowStyle.paddingLeft) + px(rowStyle.paddingRight) + px(rowStyle.borderLeftWidth) + px(rowStyle.borderRightWidth);
63
+ more += px(boxStyle.columnGap) - gap;
64
+ }
65
+ const trailing = outer.querySelector("[data-tabs-trailing]");
66
+ if (trailing) space -= widthOf(trailing) + gap;
67
+ const widths = [...inner.querySelectorAll(".crewlet-tabs__tab")].map(widthOf);
68
+ const next = foldTabs({ widths, current: current ? keys.indexOf(current) : -1, space, gap, more }).map((i) => keys[i]).filter((key) => key !== void 0);
69
+ const note = noteFits({ widths, space, gap, note: widthOf(outer.querySelector("[data-tabs-note]")) });
70
+ setFold(
71
+ (was) => was.note === note && was.folded.join("\n") === next.join("\n") ? was : { folded: next, note }
72
+ );
73
+ };
74
+ measure();
75
+ if (typeof ResizeObserver !== "function") return;
76
+ const watch = new ResizeObserver(measure);
77
+ watch.observe(outer);
78
+ for (const item of outer.querySelectorAll(
79
+ ".crewlet-tabs__tab, [data-tabs-more], [data-tabs-note], [data-tabs-trailing]"
80
+ )) {
81
+ watch.observe(item);
82
+ }
83
+ return () => watch.disconnect();
84
+ }, [enabled, box, row, signature, current]);
85
+ return enabled ? fold : NOTHING_FOLDED;
86
+ }
87
+ var FOLDED = { "aria-hidden": true, inert: true };
88
+ var SHOWN = {};
89
+ function figureOf(count) {
90
+ if (count === null || count === void 0 || count === "") return void 0;
91
+ return typeof count === "number" ? count.toLocaleString() : count;
92
+ }
93
+ function tabId(panelId, value) {
94
+ return `${panelId}-tab-${value}`;
95
+ }
96
+ function reveal(nav) {
97
+ const active = nav.querySelector(".crewlet-tabs__tab.is-active");
98
+ if (!active) return;
99
+ const row = nav.getBoundingClientRect();
100
+ const tab = active.getBoundingClientRect();
101
+ if (tab.left < row.left) nav.scrollLeft -= row.left - tab.left;
102
+ else if (tab.right > row.right) nav.scrollLeft += tab.right - row.right;
103
+ }
104
+ function Tabs({
105
+ items,
106
+ variant = "pill",
107
+ size = "md",
108
+ ariaLabel,
109
+ className = "",
110
+ value,
111
+ onValueChange,
112
+ panelId,
113
+ renderItem,
114
+ trailing,
115
+ overflow = "scroll",
116
+ moreLabel = "More",
117
+ moreMenuLabel,
118
+ note,
119
+ ref
120
+ }) {
121
+ const navRef = useRef(null);
122
+ const boxRef = useRef(null);
123
+ const folding = overflow === "menu";
124
+ const boxed = folding && !renderItem;
125
+ useImperativeHandle(ref, () => boxed ? boxRef.current : navRef.current, [boxed]);
126
+ const { buttons, onKeyDown } = useRoving(items.length, null);
127
+ const fold = useFold(
128
+ folding,
129
+ boxed ? boxRef : navRef,
130
+ navRef,
131
+ items.map((item) => item.value),
132
+ value
133
+ );
134
+ const isFolded = (item) => fold.folded.includes(item.value);
135
+ useLayoutEffect(() => {
136
+ if (variant !== "underline") return;
137
+ const nav = navRef.current;
138
+ if (!nav) return;
139
+ const update = () => {
140
+ const active = nav.querySelector(".crewlet-tabs__tab.is-active");
141
+ if (!active) {
142
+ nav.style.setProperty("--crewlet-tabs-slider-width", "0px");
143
+ return;
144
+ }
145
+ const navRect = nav.getBoundingClientRect();
146
+ const activeRect = active.getBoundingClientRect();
147
+ const left = activeRect.left - navRect.left + nav.scrollLeft;
148
+ nav.style.setProperty("--crewlet-tabs-slider-left", `${left}px`);
149
+ nav.style.setProperty("--crewlet-tabs-slider-width", `${activeRect.width}px`);
150
+ };
151
+ update();
152
+ reveal(nav);
153
+ const mutation = new MutationObserver(update);
154
+ const resize = typeof ResizeObserver === "function" ? new ResizeObserver(update) : null;
155
+ nav.querySelectorAll(".crewlet-tabs__tab").forEach((tab) => {
156
+ mutation.observe(tab, { attributes: true, attributeFilter: ["class"] });
157
+ resize?.observe(tab);
158
+ });
159
+ resize?.observe(nav);
160
+ return () => {
161
+ mutation.disconnect();
162
+ resize?.disconnect();
163
+ };
164
+ }, [variant, value, items]);
165
+ const rootClass = cx(
166
+ "crewlet-tabs",
167
+ `crewlet-tabs--${variant}`,
168
+ `crewlet-tabs--${size}`,
169
+ folding && "crewlet-tabs--fold",
170
+ !boxed && className
171
+ );
172
+ const selected = tabStop(
173
+ items.map((item) => ({ disabled: item.disabled || isFolded(item) })),
174
+ Math.max(
175
+ 0,
176
+ items.findIndex((item) => item.value === value)
177
+ )
178
+ );
179
+ const rows = items.map((item, index) => {
180
+ const isActive = value !== void 0 && value === item.value;
181
+ const folded = isFolded(item);
182
+ const tabClassName = cx(
183
+ "crewlet-tabs__tab",
184
+ HIT_AREA_CLASS,
185
+ isActive && "is-active",
186
+ item.disabled && "is-disabled",
187
+ folded && "is-folded"
188
+ );
189
+ const icon = item.live ? /* @__PURE__ */ jsx(StatusDot, { tone: "info", pulse: true }) : item.icon;
190
+ const children = /* @__PURE__ */ jsxs(Fragment, { children: [
191
+ icon ? /* @__PURE__ */ jsx("span", { className: "crewlet-tabs__icon", children: icon }) : null,
192
+ /* @__PURE__ */ jsxs("span", { className: "crewlet-tabs__label", children: [
193
+ item.label,
194
+ item.live ? /* @__PURE__ */ jsx(VisuallyHidden, { children: `, ${item.live}` }) : null
195
+ ] }),
196
+ item.marker ? item.marker.tone === "danger" ? /* @__PURE__ */ jsxs("span", { className: "crewlet-tabs__marker crewlet-tabs__marker--danger", children: [
197
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: item.marker.count }),
198
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: item.marker.label })
199
+ ] }) : /* @__PURE__ */ jsx("span", { className: `crewlet-tabs__marker crewlet-tabs__marker--${item.marker.tone}`, children: /* @__PURE__ */ jsx(VisuallyHidden, { children: item.marker.label }) }) : item.count != null && item.count !== "" ? /* @__PURE__ */ jsx(Count, { value: item.count }) : null
200
+ ] });
201
+ const onSelect = () => {
202
+ if (item.disabled) return;
203
+ onValueChange?.(item.value);
204
+ };
205
+ if (renderItem) {
206
+ return /* @__PURE__ */ jsx(React.Fragment, { children: renderItem({
207
+ item,
208
+ className: tabClassName,
209
+ isActive,
210
+ onSelect,
211
+ children,
212
+ folded,
213
+ foldProps: folded ? FOLDED : SHOWN
214
+ }) }, item.value);
215
+ }
216
+ return /* @__PURE__ */ jsx(
217
+ "button",
218
+ {
219
+ ref: (el) => {
220
+ buttons.current[index] = el;
221
+ },
222
+ type: "button",
223
+ role: "tab",
224
+ id: panelId ? tabId(panelId, item.value) : void 0,
225
+ "aria-selected": isActive,
226
+ "aria-controls": panelId,
227
+ tabIndex: index === selected ? 0 : -1,
228
+ disabled: item.disabled,
229
+ className: tabClassName,
230
+ ...folded ? FOLDED : SHOWN,
231
+ onClick: onSelect,
232
+ onKeyDown: (event) => onKeyDown(event, false),
233
+ children
234
+ },
235
+ item.value
236
+ );
237
+ });
238
+ const out = folding ? items.filter(isFolded) : [];
239
+ const more = folding ? /* @__PURE__ */ jsx(
240
+ "span",
241
+ {
242
+ className: cx("crewlet-tabs__more", out.length === 0 && "is-folded"),
243
+ "data-tabs-more": "",
244
+ ...out.length === 0 ? FOLDED : SHOWN,
245
+ children: /* @__PURE__ */ jsx(
246
+ Menu,
247
+ {
248
+ label: moreMenuLabel ?? (ariaLabel ? `More of ${ariaLabel}` : moreLabel),
249
+ trigger: moreLabel,
250
+ trailingIcon: /* @__PURE__ */ jsx(ChevronDownGlyph, { size: "xs", "aria-hidden": "true" }),
251
+ triggerVariant: "ghost",
252
+ align: "end",
253
+ items: out.map(
254
+ (item) => ({
255
+ key: item.value,
256
+ label: item.menuLabel ?? (typeof item.label === "string" ? item.label : item.value),
257
+ hint: figureOf(item.count),
258
+ disabled: item.disabled,
259
+ ...item.live ? { icon: /* @__PURE__ */ jsx(StatusDot, { tone: "info", pulse: true }), description: item.live } : {},
260
+ ...!item.live && item.marker ? { description: item.marker.label } : {},
261
+ onSelect: () => onValueChange?.(item.value)
262
+ })
263
+ )
264
+ }
265
+ )
266
+ }
267
+ ) : null;
268
+ const noteNode = folding && note ? /* @__PURE__ */ jsx(
269
+ "span",
270
+ {
271
+ className: cx("crewlet-tabs__note", !fold.note && "is-folded"),
272
+ "data-tabs-note": "",
273
+ ...fold.note ? {} : { "aria-hidden": true },
274
+ children: note
275
+ }
276
+ ) : null;
277
+ if (renderItem) {
278
+ return /* @__PURE__ */ jsxs("nav", { ref: navRef, className: rootClass, "aria-label": ariaLabel, children: [
279
+ rows,
280
+ more,
281
+ noteNode,
282
+ folding && trailing ? /* @__PURE__ */ jsx("span", { className: "crewlet-tabs__trailing", "data-tabs-trailing": "", children: trailing }) : trailing
283
+ ] });
284
+ }
285
+ const list = /* @__PURE__ */ jsx("div", { ref: navRef, className: rootClass, "aria-label": ariaLabel, role: "tablist", children: rows });
286
+ if (!boxed) return list;
287
+ return /* @__PURE__ */ jsxs("div", { ref: boxRef, className: cx("crewlet-tabs-fold", `crewlet-tabs-fold--${variant}`, className), children: [
288
+ list,
289
+ more,
290
+ noteNode
291
+ ] });
292
+ }
293
+ function TabPanel({ id, value, children, className }) {
294
+ return /* @__PURE__ */ jsx(
295
+ "div",
296
+ {
297
+ role: "tabpanel",
298
+ id,
299
+ "aria-labelledby": tabId(id, value),
300
+ className: cx("crewlet-tab-panel", className),
301
+ children
302
+ }
303
+ );
304
+ }
305
+
306
+ export { TabPanel, Tabs, tabId };