@crewlethq/ui 0.4.3 → 0.5.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.
- package/README.md +888 -24
- package/dist/Accordion/index.js +2 -2
- package/dist/AddPill/index.js +1 -1
- package/dist/{AddPill-DFWXYLIQ.css → AddPill-IJQYCY6C.css} +9 -0
- package/dist/AppShell/AppShell.d.ts +26 -5
- package/dist/AppShell/index.js +3 -3
- package/dist/{AppShell-NVE6LHNI.css → AppShell-XARELGIH.css} +178 -25
- package/dist/Avatar/Avatar.d.ts +85 -40
- package/dist/Avatar/AvatarStack.d.ts +76 -0
- package/dist/Avatar/index.d.ts +5 -2
- package/dist/Avatar/index.js +1 -1
- package/dist/Avatar-XID7Z74C.css +200 -0
- package/dist/AvatarStack-GEJBNV7E.css +72 -0
- package/dist/BrandLockup/index.js +1 -1
- package/dist/{BrandLockup-6ISDEHPJ.css → BrandLockup-JKGXFCZF.css} +25 -19
- package/dist/Button/Button.d.ts +7 -2
- package/dist/Button/index.js +1 -1
- package/dist/{Button-D4J6B4MA.css → Button-X4B2TJAQ.css} +50 -19
- package/dist/Callout/index.js +1 -1
- package/dist/Canvas/index.js +4 -4
- package/dist/Card/Card.d.ts +9 -5
- package/dist/Card/index.js +1 -1
- package/dist/{Card-RLR254LD.css → Card-GLP7SUV6.css} +25 -18
- package/dist/Charts/BarList.d.ts +18 -1
- package/dist/Charts/ChartTooltip.d.ts +68 -0
- package/dist/Charts/StackedBar.d.ts +25 -7
- package/dist/Charts/StackedColumns.d.ts +112 -0
- package/dist/Charts/TimeSeries.d.ts +33 -2
- package/dist/Charts/dataColor.d.ts +22 -14
- package/dist/Charts/index.d.ts +6 -0
- package/dist/Charts/index.js +1 -1
- package/dist/Charts/useChartHover.d.ts +56 -0
- package/dist/Charts-B3YEF7R4.css +742 -0
- package/dist/Checkbox/index.js +1 -1
- package/dist/{Checkbox-VGW26YLQ.css → Checkbox-BOXQ747I.css} +2 -2
- package/dist/CodeBlock/index.js +4 -4
- package/dist/Combobox/index.js +5 -5
- package/dist/CommandPalette/CommandPalette.d.ts +97 -6
- package/dist/CommandPalette/index.d.ts +1 -1
- package/dist/CommandPalette/index.js +9 -7
- package/dist/CommandPalette-C5AMKGN2.css +259 -0
- package/dist/Copyable/index.js +3 -3
- package/dist/DataTable/index.js +7 -7
- package/dist/{DataTable-ITNACQ2X.css → DataTable-OLHPF7D4.css} +44 -43
- package/dist/DataView/index.js +14 -14
- package/dist/{DataView-256YF32J.css → DataView-N6JX464S.css} +5 -4
- package/dist/DateTimePicker/index.js +5 -5
- package/dist/DiffList/index.js +1 -1
- package/dist/Disclosure/index.js +2 -2
- package/dist/EntityChip/EntityChip.d.ts +9 -12
- package/dist/EntityChip/index.d.ts +1 -1
- package/dist/EntityChip/index.js +2 -2
- package/dist/ErrorBoundary/index.js +2 -2
- package/dist/{ErrorBoundary-ME36CQTA.css → ErrorBoundary-U2PA3LY2.css} +4 -4
- package/dist/IconButton/index.js +1 -1
- package/dist/{IconButton-VQGNMJDI.css → IconButton-TVEUWK6L.css} +2 -2
- package/dist/ImageUpload/ImageUpload.d.ts +10 -7
- package/dist/ImageUpload/index.js +2 -2
- package/dist/{ImageUpload-HKFIZR6D.css → ImageUpload-YCHJMUGX.css} +24 -10
- package/dist/Input/index.js +2 -2
- package/dist/Kbd/Kbd.d.ts +14 -4
- package/dist/Kbd/index.js +1 -1
- package/dist/Kbd-JPLDVJIP.css +71 -0
- package/dist/Layer/index.js +1 -1
- package/dist/Link/index.js +1 -1
- package/dist/List/index.js +1 -1
- package/dist/{List-XTHESXLR.css → List-MYJIV6MP.css} +12 -2
- package/dist/ListInput/index.js +5 -5
- package/dist/Listbox/index.js +2 -2
- package/dist/Listbox/useListbox.d.ts +16 -0
- package/dist/Listbox/useOptionKeys.d.ts +12 -1
- package/dist/{Listbox-X2DOTSQA.css → Listbox-6WJNJQVQ.css} +60 -7
- package/dist/Menu/index.js +4 -4
- package/dist/{Menu-6DE7I66I.css → Menu-BT5PMFJI.css} +15 -0
- package/dist/Meter/Meter.d.ts +103 -16
- package/dist/Meter/index.d.ts +2 -2
- package/dist/Meter/index.js +1 -1
- package/dist/{Meter-SKOOXQBC.css → Meter-5VCSFMZW.css} +46 -7
- package/dist/Modal/index.js +4 -4
- package/dist/{Modal-XYQJ4BL6.css → Modal-JAYBS2KS.css} +13 -4
- package/dist/OrgLabel/OrgLabel.d.ts +60 -24
- package/dist/OrgLabel/index.d.ts +1 -1
- package/dist/OrgLabel/index.js +2 -1
- package/dist/{OrgLabel-D7U6QJZD.css → OrgLabel-CR233G34.css} +9 -18
- package/dist/OrgNode/index.js +3 -2
- package/dist/OrgTable/OrgTable.d.ts +2 -2
- package/dist/OrgTable/index.js +8 -7
- package/dist/Popover/index.js +2 -2
- package/dist/PricingCard/index.js +3 -3
- package/dist/{PricingCard-JFI7RYXP.css → PricingCard-7EFXRSD2.css} +4 -5
- package/dist/SearchTrigger/SearchTrigger.d.ts +23 -4
- package/dist/SearchTrigger/index.d.ts +1 -1
- package/dist/SearchTrigger/index.js +1 -1
- package/dist/SearchTrigger-Z5D4AAY7.css +112 -0
- package/dist/SegmentedControl/index.js +2 -2
- package/dist/SegmentedMeter/SegmentedMeter.d.ts +107 -0
- package/dist/SegmentedMeter/index.d.ts +3 -0
- package/dist/SegmentedMeter/index.js +2 -0
- package/dist/SegmentedMeter-KQNML2TW.css +109 -0
- package/dist/Select/index.js +3 -3
- package/dist/{Select-2X77FSWR.css → Select-E24U5LBC.css} +34 -0
- package/dist/Shortcut/index.js +2 -2
- package/dist/SidebarNav/SidebarNav.d.ts +85 -25
- package/dist/SidebarNav/index.d.ts +1 -1
- package/dist/SidebarNav/index.js +1 -1
- package/dist/SidebarNav-X5NLZNWA.css +424 -0
- package/dist/StatCard/StatCard.d.ts +59 -12
- package/dist/StatCard/index.d.ts +1 -1
- package/dist/StatCard/index.js +1 -1
- package/dist/StatCard-KPAFD4E2.css +204 -0
- package/dist/StatGroup/index.js +1 -1
- package/dist/{StatGroup-TGB6AEKM.css → StatGroup-HVG6O62W.css} +8 -9
- package/dist/StatusDot/StatusDot.d.ts +24 -6
- package/dist/StatusDot/index.js +1 -1
- package/dist/StatusDot-7OMCQCZF.css +186 -0
- package/dist/Stepper/Stepper.d.ts +78 -0
- package/dist/Stepper/index.d.ts +3 -0
- package/dist/Stepper/index.js +4 -0
- package/dist/Stepper-HW4JM3YH.css +176 -0
- package/dist/Table/index.js +1 -1
- package/dist/{Table-MDOLVUAW.css → Table-TGCS4C3F.css} +14 -4
- package/dist/Tabs/index.js +1 -1
- package/dist/{Tabs-VLICJFVB.css → Tabs-XCNPHA7B.css} +79 -27
- package/dist/Tag/Tag.d.ts +29 -22
- package/dist/Tag/index.js +2 -2
- package/dist/{Tag-VNZEYLB6.css → Tag-GBE7LQJP.css} +82 -83
- package/dist/TagsInput/index.js +6 -6
- package/dist/ThemeSwitcher/ThemeSwitcher.d.ts +53 -21
- package/dist/ThemeSwitcher/index.d.ts +3 -3
- package/dist/ThemeSwitcher/index.js +4 -3
- package/dist/ThemeSwitcher/preferences.d.ts +19 -5
- package/dist/ThemeToggle/ThemeToggle.d.ts +40 -0
- package/dist/ThemeToggle/index.d.ts +2 -0
- package/dist/ThemeToggle/index.js +5 -0
- package/dist/TimeWindowPicker/index.js +8 -8
- package/dist/Toaster/index.js +2 -2
- package/dist/Toolbar/index.js +2 -2
- package/dist/{Toolbar-IP6LXN45.css → Toolbar-HUOSMNTH.css} +3 -1
- package/dist/Tooltip/index.js +2 -2
- package/dist/Tree/index.d.ts +2 -2
- package/dist/Tree/index.js +1 -1
- package/dist/Tree/layout.d.ts +103 -28
- package/dist/TreeCanvas/TreeCanvas.d.ts +60 -14
- package/dist/TreeCanvas/index.d.ts +1 -1
- package/dist/TreeCanvas/index.js +6 -6
- package/dist/TreeCanvas/motion.d.ts +3 -2
- package/dist/{TreeCanvas-WBNQPHC7.css → TreeCanvas-HVOV4SQN.css} +154 -30
- package/dist/TreeGrid/index.js +4 -4
- package/dist/{chunk-F6OE5FH3.js → chunk-2FPENTCF.js} +1 -1
- package/dist/chunk-4AK52VHB.js +88 -0
- package/dist/{chunk-7EM5T4ME.js → chunk-4IQD3HUQ.js} +2 -2
- package/dist/{chunk-YODNNSZL.js → chunk-4PZ6FJKW.js} +43 -13
- package/dist/{chunk-F27EPQ7D.js → chunk-4UQ7SMPK.js} +1 -1
- package/dist/chunk-5QWIJSQM.js +73 -0
- package/dist/{chunk-GTOUGQQK.js → chunk-6MU7HNB4.js} +13 -10
- package/dist/{chunk-S2XHHEW4.js → chunk-74KMX7YH.js} +4 -4
- package/dist/{chunk-WNI2WSJF.js → chunk-7KBNFFM3.js} +1 -1
- package/dist/{chunk-DD5BBGBE.js → chunk-AUS5FNQE.js} +9 -5
- package/dist/{chunk-CMEE37QJ.js → chunk-BMYPGGPV.js} +4 -4
- package/dist/{chunk-H4FBTAYS.js → chunk-BNCCEER3.js} +8 -8
- package/dist/chunk-C5WJUZVR.js +56 -0
- package/dist/{chunk-5WS6L6FA.js → chunk-CAIHUYXV.js} +9 -9
- package/dist/{chunk-XV6WRMBC.js → chunk-CQY5NTRS.js} +4 -1
- package/dist/{chunk-UOGSZKLT.js → chunk-D6EVJUGU.js} +2 -2
- package/dist/{chunk-6ZFVFA56.js → chunk-DHPUMOTX.js} +2 -2
- package/dist/{chunk-HZ5XZNPS.js → chunk-DS2C73RJ.js} +3 -3
- package/dist/{chunk-O6232G37.js → chunk-DSUY5F4E.js} +17 -5
- package/dist/{chunk-Q4ZPPART.js → chunk-EFYPAJT3.js} +3 -3
- package/dist/{chunk-WQX73TWF.js → chunk-ERVO6OUF.js} +18 -17
- package/dist/{chunk-BZYDZBAN.js → chunk-ETYEBKR4.js} +3 -3
- package/dist/{chunk-34VGEDVV.js → chunk-FD5UEN6X.js} +30 -30
- package/dist/{chunk-5SDBMKUO.js → chunk-FIFNP6PL.js} +3 -3
- package/dist/{chunk-7HPRF5XN.js → chunk-FUF52K7E.js} +98 -16
- package/dist/{chunk-5KPQ6D7N.js → chunk-FZVJDJFN.js} +2 -2
- package/dist/chunk-IA232OTU.js +156 -0
- package/dist/{chunk-2EOKFKHX.js → chunk-IG27QX7Q.js} +7 -7
- package/dist/chunk-IKB6HFGK.js +55 -0
- package/dist/{chunk-FBZAKNSX.js → chunk-IPVQKAHO.js} +10 -7
- package/dist/{chunk-3EYF6HKB.js → chunk-IVFJD7WY.js} +28 -9
- package/dist/{chunk-WOYYD2YR.js → chunk-JGRNTBF2.js} +11 -11
- package/dist/chunk-K3OWD7BJ.js +121 -0
- package/dist/{chunk-BJSKPEZI.js → chunk-KD4H66L6.js} +7 -20
- package/dist/{chunk-SFZOKW2G.js → chunk-KJ34ZBBI.js} +8 -3
- package/dist/{chunk-HQNHV7D6.js → chunk-LFHCXZO5.js} +6 -6
- package/dist/{chunk-LWKJQTOM.js → chunk-MICH6QSJ.js} +1 -1
- package/dist/chunk-N3DPO6HG.js +226 -0
- package/dist/{chunk-S4GZWSKR.js → chunk-OM5E3TTK.js} +1 -1
- package/dist/{chunk-3QRYCPXQ.js → chunk-OPKIKM35.js} +6 -6
- package/dist/{chunk-5EKIWVOR.js → chunk-PGRPNDWM.js} +2 -2
- package/dist/{chunk-LFJ6UJTI.js → chunk-PQNILU27.js} +9 -9
- package/dist/{chunk-QNCVHRZL.js → chunk-QVAFL2LE.js} +1 -1
- package/dist/{chunk-QEUY3A5P.js → chunk-QY7UU5ZB.js} +3 -2
- package/dist/{chunk-ITHXJHBB.js → chunk-R25RGPUB.js} +1 -0
- package/dist/{chunk-KLJCCMF3.js → chunk-R6735B37.js} +2 -2
- package/dist/{chunk-3ZP55QZE.js → chunk-R6FBDTP3.js} +4 -4
- package/dist/{chunk-7FZ53WDJ.js → chunk-RIAZM6L3.js} +1 -1
- package/dist/chunk-RJM4QCGG.js +550 -0
- package/dist/{chunk-NTRZGNEX.js → chunk-S3BCVWTU.js} +215 -46
- package/dist/chunk-S7KW47IQ.js +121 -0
- package/dist/{chunk-OFHBK7RI.js → chunk-SJQ546ID.js} +34 -14
- package/dist/{chunk-D35VTV2Z.js → chunk-SV7QAONL.js} +1 -1
- package/dist/{chunk-IAJLHVUA.js → chunk-TIWAHZZ6.js} +1 -1
- package/dist/{chunk-2PRH365R.js → chunk-UA7O3KKJ.js} +1 -1
- package/dist/{chunk-NPZY6YYL.js → chunk-UG5ZMAXW.js} +6 -6
- package/dist/{chunk-FEFTGVMF.js → chunk-V2N3BMOT.js} +7 -2
- package/dist/{chunk-NDCATSW7.js → chunk-V34H2YCY.js} +1 -1
- package/dist/chunk-WIATRXEJ.js +22 -0
- package/dist/{chunk-5C5YMZQU.js → chunk-WOFOMTGB.js} +16 -10
- package/dist/{chunk-QYOFACSP.js → chunk-WSOFKOLP.js} +3 -3
- package/dist/{chunk-MNAXYY3R.js → chunk-WUVZDFHS.js} +31 -11
- package/dist/{chunk-UG46QBLT.js → chunk-YIMOT5OO.js} +10 -10
- package/dist/{chunk-2ZQMA2WB.js → chunk-ZPSOF6VL.js} +2 -2
- package/dist/generated/index.d.ts +3 -0
- package/dist/generated/index.js +66 -62
- package/dist/index.js +66 -62
- package/dist/styles.css +2719 -799
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/tone.d.ts +7 -12
- package/package.json +4 -4
- package/scripts/check-css-literals.mjs +159 -23
- package/scripts/check-css-variables.mjs +5 -3
- package/scripts/css-source.mjs +97 -5
- package/dist/Avatar-P2KRQM2B.css +0 -156
- package/dist/Charts-D7G2BSXH.css +0 -277
- package/dist/CommandPalette-CSJDUCQA.css +0 -115
- package/dist/Kbd-W66MXQI5.css +0 -61
- package/dist/SearchTrigger-QXOYAUUY.css +0 -79
- package/dist/SidebarNav-QGSFKZYA.css +0 -319
- package/dist/StatCard-KYPKZUWX.css +0 -111
- package/dist/StatusDot-HA2L2FSX.css +0 -84
- package/dist/chunk-22O7LAW2.js +0 -41
- package/dist/chunk-2HQR4U4D.js +0 -143
- package/dist/chunk-ESCO4XYW.js +0 -144
- package/dist/chunk-F4PJZ4ED.js +0 -245
- package/dist/chunk-PNFASD6F.js +0 -98
- package/dist/chunk-PZSWF74H.js +0 -15
- /package/dist/{chunk-ZCR6YGQ4.js → chunk-PKIN4IMB.js} +0 -0
|
@@ -146,28 +146,36 @@ function treeTypeAhead(tree, expanded, from, text) {
|
|
|
146
146
|
|
|
147
147
|
// src/Tree/layout.ts
|
|
148
148
|
var MIN_OUTLINE_HEIGHT = 1;
|
|
149
|
-
function
|
|
149
|
+
function roomOf(membership) {
|
|
150
|
+
return { head: membership?.group.inset.top ?? 0, foot: membership?.group.inset.bottom ?? 0 };
|
|
151
|
+
}
|
|
152
|
+
function bandsOf(roots, gapY, groupOf) {
|
|
150
153
|
const height = [];
|
|
154
|
+
const head = [];
|
|
155
|
+
const foot = [];
|
|
151
156
|
const visit = (node, depth) => {
|
|
157
|
+
const room = roomOf(groupOf.get(node.id));
|
|
152
158
|
height[depth] = Math.max(height[depth] ?? 0, node.height);
|
|
159
|
+
head[depth] = Math.max(head[depth] ?? 0, room.head);
|
|
160
|
+
foot[depth] = Math.max(foot[depth] ?? 0, room.foot);
|
|
153
161
|
node.children.forEach((child) => visit(child, depth + 1));
|
|
154
162
|
};
|
|
155
163
|
roots.forEach((root) => visit(root, 0));
|
|
156
164
|
const top = [];
|
|
157
165
|
let at = 0;
|
|
158
166
|
for (let depth = 0; depth < height.length; depth++) {
|
|
159
|
-
top[depth] = at;
|
|
160
|
-
at
|
|
167
|
+
top[depth] = at + head[depth];
|
|
168
|
+
at = top[depth] + height[depth] + foot[depth] + gapY;
|
|
161
169
|
}
|
|
162
170
|
return { top, height };
|
|
163
171
|
}
|
|
164
172
|
function shift(outline, dx, dy) {
|
|
165
|
-
return outline.map((s) => ({ top: s.top + dy, bottom: s.bottom + dy, value: s.value + dx }));
|
|
173
|
+
return outline.map((s) => ({ ...s, top: s.top + dy, bottom: s.bottom + dy, value: s.value + dx }));
|
|
166
174
|
}
|
|
167
175
|
function mirror(outline) {
|
|
168
176
|
return outline.map((s) => ({ ...s, value: -s.value }));
|
|
169
177
|
}
|
|
170
|
-
function merge(a, b,
|
|
178
|
+
function merge(a, b, keep) {
|
|
171
179
|
const cuts = [...new Set([...a, ...b].flatMap((s) => [s.top, s.bottom]))].sort((x, y) => x - y);
|
|
172
180
|
const out = [];
|
|
173
181
|
let i = 0;
|
|
@@ -177,13 +185,16 @@ function merge(a, b, pick) {
|
|
|
177
185
|
const hi = cuts[k + 1];
|
|
178
186
|
while (i < a.length && a[i].bottom <= lo) i++;
|
|
179
187
|
while (j < b.length && b[j].bottom <= lo) j++;
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
188
|
+
const sa = i < a.length && a[i].top <= lo ? a[i] : void 0;
|
|
189
|
+
const sb = j < b.length && b[j].top <= lo ? b[j] : void 0;
|
|
190
|
+
const chosen = sa && sb ? (keep === "max" ? sb.value > sa.value : sb.value < sa.value) ? sb : sa : sa ?? sb;
|
|
191
|
+
if (chosen === void 0) continue;
|
|
184
192
|
const last = out[out.length - 1];
|
|
185
|
-
if (last && last.bottom === lo && last.value === value
|
|
186
|
-
|
|
193
|
+
if (last && last.bottom === lo && last.value === chosen.value && last.group === chosen.group) {
|
|
194
|
+
last.bottom = hi;
|
|
195
|
+
} else {
|
|
196
|
+
out.push({ top: lo, bottom: hi, value: chosen.value, group: chosen.group, pad: chosen.pad });
|
|
197
|
+
}
|
|
187
198
|
}
|
|
188
199
|
return out;
|
|
189
200
|
}
|
|
@@ -193,7 +204,9 @@ function separation(right, left, gap) {
|
|
|
193
204
|
for (const s of left) {
|
|
194
205
|
while (i < right.length && right[i].bottom <= s.top) i++;
|
|
195
206
|
for (let k = i; k < right.length && right[k].top < s.bottom; k++) {
|
|
196
|
-
|
|
207
|
+
const edge = right[k];
|
|
208
|
+
const inside = edge.group !== null && edge.group === s.group ? edge.pad + s.pad : 0;
|
|
209
|
+
need = Math.max(need, edge.value - s.value - inside);
|
|
197
210
|
}
|
|
198
211
|
}
|
|
199
212
|
if (Number.isFinite(need)) return need + gap;
|
|
@@ -207,7 +220,7 @@ function packFromLeft(kids2, gap) {
|
|
|
207
220
|
for (let i = 1; i < kids2.length; i++) {
|
|
208
221
|
const at = separation(reach, kids2[i].left, gap);
|
|
209
222
|
positions.push(at);
|
|
210
|
-
reach = merge(reach, shift(kids2[i].right, at, 0),
|
|
223
|
+
reach = merge(reach, shift(kids2[i].right, at, 0), "max");
|
|
211
224
|
}
|
|
212
225
|
return positions;
|
|
213
226
|
}
|
|
@@ -220,24 +233,42 @@ function pack(kids2, gap) {
|
|
|
220
233
|
const centre = (averaged[0] + averaged[averaged.length - 1]) / 2;
|
|
221
234
|
return averaged.map((p) => p - centre);
|
|
222
235
|
}
|
|
223
|
-
function
|
|
224
|
-
const
|
|
236
|
+
function childDrop(node, gaps, groupOf) {
|
|
237
|
+
const own = groupOf.get(node.id);
|
|
238
|
+
const body = own ? own.tallest : node.height;
|
|
239
|
+
let head = 0;
|
|
240
|
+
for (const child of node.children) head = Math.max(head, roomOf(groupOf.get(child.id)).head);
|
|
241
|
+
return body + roomOf(own).foot + gaps.gapY + head;
|
|
242
|
+
}
|
|
243
|
+
function build(node, gaps, bands, depth, groupOf) {
|
|
244
|
+
const kids2 = node.children.map((child) => build(child, gaps, bands, depth + 1, groupOf));
|
|
225
245
|
const half = node.width / 2;
|
|
226
246
|
const tall = Math.max(node.height, MIN_OUTLINE_HEIGHT);
|
|
227
247
|
const inBand = bands ? (bands.height[depth] - node.height) / 2 : 0;
|
|
228
|
-
|
|
229
|
-
|
|
248
|
+
const member = groupOf.get(node.id);
|
|
249
|
+
const pad = member?.group.inset.x ?? 0;
|
|
250
|
+
const group = member?.group.id ?? null;
|
|
251
|
+
let top = inBand;
|
|
252
|
+
let bottom = inBand + tall;
|
|
253
|
+
if (member) {
|
|
254
|
+
const body = Math.max(member.tallest, MIN_OUTLINE_HEIGHT);
|
|
255
|
+
const at = bands ? (bands.height[depth] - member.tallest) / 2 : 0;
|
|
256
|
+
top = at - member.group.inset.top;
|
|
257
|
+
bottom = at + body + member.group.inset.bottom;
|
|
258
|
+
}
|
|
259
|
+
let left = [{ top, bottom, value: -half - pad, group, pad }];
|
|
260
|
+
let right = [{ top, bottom, value: half + pad, group, pad }];
|
|
230
261
|
if (kids2.length === 0) return { node, kids: kids2, offsets: [], inBand, left, right };
|
|
231
262
|
const offsets = pack(kids2, gaps.gapX);
|
|
232
|
-
const childTop = bands ? bands.top[depth + 1] - bands.top[depth] : node
|
|
263
|
+
const childTop = bands ? bands.top[depth + 1] - bands.top[depth] : childDrop(node, gaps, groupOf);
|
|
233
264
|
if (!bands && childTop > node.height) {
|
|
234
|
-
const band = (value) => [{ top: node.height, bottom: childTop, value }];
|
|
235
|
-
left = merge(left, band(Math.min(-half, offsets[0])),
|
|
236
|
-
right = merge(right, band(Math.max(half, offsets[offsets.length - 1])),
|
|
265
|
+
const band = (value) => [{ top: node.height, bottom: childTop, value, group: null, pad: 0 }];
|
|
266
|
+
left = merge(left, band(Math.min(-half, offsets[0])), "min");
|
|
267
|
+
right = merge(right, band(Math.max(half, offsets[offsets.length - 1])), "max");
|
|
237
268
|
}
|
|
238
269
|
kids2.forEach((kid, i) => {
|
|
239
|
-
left = merge(left, shift(kid.left, offsets[i], childTop),
|
|
240
|
-
right = merge(right, shift(kid.right, offsets[i], childTop),
|
|
270
|
+
left = merge(left, shift(kid.left, offsets[i], childTop), "min");
|
|
271
|
+
right = merge(right, shift(kid.right, offsets[i], childTop), "max");
|
|
241
272
|
});
|
|
242
273
|
return { node, kids: kids2, offsets, inBand, left, right };
|
|
243
274
|
}
|
|
@@ -251,30 +282,107 @@ function validate(roots, gaps) {
|
|
|
251
282
|
if (gaps.ranks !== void 0 && gaps.ranks !== "per-parent" && gaps.ranks !== "shared") {
|
|
252
283
|
throw new RangeError(`layoutForest: ranks is "${gaps.ranks}"; it is "per-parent" or "shared"`);
|
|
253
284
|
}
|
|
254
|
-
const seen = /* @__PURE__ */ new
|
|
255
|
-
const
|
|
285
|
+
const seen = /* @__PURE__ */ new Map();
|
|
286
|
+
const place = /* @__PURE__ */ new Map();
|
|
287
|
+
const visit = (node, parent, index) => {
|
|
256
288
|
if (seen.has(node.id)) {
|
|
257
289
|
throw new RangeError(`layoutForest: the id "${node.id}" appears twice; every box needs its own id`);
|
|
258
290
|
}
|
|
259
|
-
seen.
|
|
291
|
+
seen.set(node.id, node);
|
|
292
|
+
place.set(node.id, { parent, index });
|
|
260
293
|
if (!size(node.width) || !size(node.height)) {
|
|
261
294
|
throw new RangeError(
|
|
262
295
|
`layoutForest: "${node.id}" is ${node.width} by ${node.height}; a size must be finite and non-negative`
|
|
263
296
|
);
|
|
264
297
|
}
|
|
265
|
-
node.children.forEach(visit);
|
|
298
|
+
node.children.forEach((child, i) => visit(child, node.id, i));
|
|
266
299
|
};
|
|
267
|
-
roots.forEach(visit);
|
|
300
|
+
roots.forEach((root, i) => visit(root, null, i));
|
|
301
|
+
const groupOf = /* @__PURE__ */ new Map();
|
|
302
|
+
const named = /* @__PURE__ */ new Set();
|
|
303
|
+
for (const group of gaps.groups ?? []) {
|
|
304
|
+
const { id, members, inset } = group;
|
|
305
|
+
if (named.has(id)) throw new RangeError(`layoutForest: the group "${id}" appears twice`);
|
|
306
|
+
named.add(id);
|
|
307
|
+
if (!size(inset.x) || !size(inset.top) || !size(inset.bottom)) {
|
|
308
|
+
throw new RangeError(
|
|
309
|
+
`layoutForest: the group "${id}" has the inset ${JSON.stringify(inset)}; each side must be finite and non-negative`
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
if (members.length === 0) throw new RangeError(`layoutForest: the group "${id}" has no members`);
|
|
313
|
+
let tallest = 0;
|
|
314
|
+
const indices = [];
|
|
315
|
+
let parent;
|
|
316
|
+
for (const member of members) {
|
|
317
|
+
const node = seen.get(member);
|
|
318
|
+
if (!node) throw new RangeError(`layoutForest: the group "${id}" names "${member}", which is no box of the forest`);
|
|
319
|
+
const other = groupOf.get(member);
|
|
320
|
+
if (other) {
|
|
321
|
+
throw new RangeError(
|
|
322
|
+
`layoutForest: "${member}" is in the group "${other.group.id}" and in "${id}"; a box is in one group at most`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
const at = place.get(member);
|
|
326
|
+
if (parent !== void 0 && at.parent !== parent) {
|
|
327
|
+
throw new RangeError(
|
|
328
|
+
`layoutForest: the group "${id}" holds boxes of different parents; a group is a run of siblings`
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
parent = at.parent;
|
|
332
|
+
indices.push(at.index);
|
|
333
|
+
tallest = Math.max(tallest, node.height);
|
|
334
|
+
groupOf.set(member, { group, tallest: 0 });
|
|
335
|
+
}
|
|
336
|
+
indices.sort((a, b) => a - b);
|
|
337
|
+
if (indices[indices.length - 1] - indices[0] + 1 !== indices.length) {
|
|
338
|
+
throw new RangeError(
|
|
339
|
+
`layoutForest: the group "${id}" skips a sibling between its members; a group is a CONSECUTIVE run of siblings`
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
for (const member of members) groupOf.set(member, { group, tallest });
|
|
343
|
+
}
|
|
344
|
+
return groupOf;
|
|
345
|
+
}
|
|
346
|
+
function placeGroups(byId, groups) {
|
|
347
|
+
return groups.map(({ id, members, inset }) => {
|
|
348
|
+
let left = Infinity;
|
|
349
|
+
let top = Infinity;
|
|
350
|
+
let right = -Infinity;
|
|
351
|
+
let bottom = -Infinity;
|
|
352
|
+
for (const member of members) {
|
|
353
|
+
const box = byId.get(member);
|
|
354
|
+
if (!box) continue;
|
|
355
|
+
left = Math.min(left, box.x);
|
|
356
|
+
top = Math.min(top, box.y);
|
|
357
|
+
right = Math.max(right, box.x + box.width);
|
|
358
|
+
bottom = Math.max(bottom, box.y + box.height);
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
id,
|
|
362
|
+
members,
|
|
363
|
+
inset,
|
|
364
|
+
x: left - inset.x,
|
|
365
|
+
y: top - inset.top,
|
|
366
|
+
width: right - left + inset.x * 2,
|
|
367
|
+
height: bottom - top + inset.top + inset.bottom
|
|
368
|
+
};
|
|
369
|
+
});
|
|
268
370
|
}
|
|
269
371
|
function layoutForest(roots, gaps) {
|
|
270
|
-
validate(roots, gaps);
|
|
372
|
+
const groupOf = validate(roots, gaps);
|
|
271
373
|
const margin = gaps.margin ?? 0;
|
|
272
374
|
const nodes = [];
|
|
273
375
|
if (roots.length === 0) {
|
|
274
|
-
return {
|
|
376
|
+
return {
|
|
377
|
+
nodes,
|
|
378
|
+
byId: /* @__PURE__ */ new Map(),
|
|
379
|
+
groups: [],
|
|
380
|
+
ranks: gaps.ranks ?? "per-parent",
|
|
381
|
+
bounds: { x: 0, y: 0, width: 0, height: 0 }
|
|
382
|
+
};
|
|
275
383
|
}
|
|
276
|
-
const bands = gaps.ranks === "shared" ? bandsOf(roots, gaps.gapY) : null;
|
|
277
|
-
const trees = roots.map((root) => build(root, gaps, bands, 0));
|
|
384
|
+
const bands = gaps.ranks === "shared" ? bandsOf(roots, gaps.gapY, groupOf) : null;
|
|
385
|
+
const trees = roots.map((root) => build(root, gaps, bands, 0, groupOf));
|
|
278
386
|
const centres = pack(trees, gaps.gapX);
|
|
279
387
|
const place = (tree, centre, top, depth, parent) => {
|
|
280
388
|
const { node } = tree;
|
|
@@ -287,29 +395,74 @@ function layoutForest(roots, gaps) {
|
|
|
287
395
|
depth,
|
|
288
396
|
parent
|
|
289
397
|
});
|
|
290
|
-
const childTop = bands ? bands.top[depth + 1] : top + node
|
|
398
|
+
const childTop = bands ? bands.top[depth + 1] : top + childDrop(node, gaps, groupOf);
|
|
291
399
|
tree.kids.forEach((kid, i) => place(kid, centre + tree.offsets[i], childTop, depth + 1, node.id));
|
|
292
400
|
};
|
|
293
|
-
|
|
401
|
+
let rootHead = 0;
|
|
402
|
+
for (const root of roots) rootHead = Math.max(rootHead, roomOf(groupOf.get(root.id)).head);
|
|
403
|
+
trees.forEach((tree, i) => place(tree, centres[i], bands ? bands.top[0] : rootHead, 0, null));
|
|
404
|
+
const padOf = (id) => groupOf.get(id)?.group.inset.x ?? 0;
|
|
294
405
|
let minX = Infinity;
|
|
295
|
-
for (const node of nodes) minX = Math.min(minX, node.x);
|
|
296
|
-
let maxX = -Infinity;
|
|
297
|
-
let maxY = 0;
|
|
406
|
+
for (const node of nodes) minX = Math.min(minX, node.x - padOf(node.id));
|
|
298
407
|
for (const node of nodes) {
|
|
299
408
|
node.x += margin - minX;
|
|
300
409
|
node.y += margin;
|
|
301
|
-
|
|
302
|
-
|
|
410
|
+
}
|
|
411
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
412
|
+
const groups = placeGroups(byId, gaps.groups ?? []);
|
|
413
|
+
let maxX = -Infinity;
|
|
414
|
+
let maxY = 0;
|
|
415
|
+
for (const one of [...nodes, ...groups]) {
|
|
416
|
+
maxX = Math.max(maxX, one.x + one.width);
|
|
417
|
+
maxY = Math.max(maxY, one.y + one.height);
|
|
303
418
|
}
|
|
304
419
|
return {
|
|
305
420
|
nodes,
|
|
306
|
-
byId
|
|
421
|
+
byId,
|
|
422
|
+
groups,
|
|
423
|
+
ranks: gaps.ranks ?? "per-parent",
|
|
307
424
|
bounds: { x: 0, y: 0, width: maxX + margin, height: maxY + margin }
|
|
308
425
|
};
|
|
309
426
|
}
|
|
310
|
-
var
|
|
311
|
-
|
|
427
|
+
var ELBOW_RADIUS = 6;
|
|
428
|
+
var CENTRED = 1e-6;
|
|
429
|
+
var STEP_RADIUS = 12;
|
|
430
|
+
function busOf(layout) {
|
|
431
|
+
const boxOf = /* @__PURE__ */ new Map();
|
|
432
|
+
for (const group of layout.groups ?? []) for (const member of group.members) boxOf.set(member, group);
|
|
433
|
+
const topOf = (node) => Math.min(boxOf.get(node.id)?.y ?? node.y, node.y);
|
|
434
|
+
const bottomOf = (node) => {
|
|
435
|
+
const box = boxOf.get(node.id);
|
|
436
|
+
return Math.max(box ? box.y + box.height : -Infinity, node.y + node.height);
|
|
437
|
+
};
|
|
438
|
+
const shared = layout.ranks === "shared";
|
|
439
|
+
const rankTop = /* @__PURE__ */ new Map();
|
|
440
|
+
const rankBottom = /* @__PURE__ */ new Map();
|
|
441
|
+
if (shared) {
|
|
442
|
+
for (const node of layout.nodes) {
|
|
443
|
+
rankTop.set(node.depth, Math.min(rankTop.get(node.depth) ?? Infinity, topOf(node)));
|
|
444
|
+
rankBottom.set(node.depth, Math.max(rankBottom.get(node.depth) ?? -Infinity, bottomOf(node)));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
const reach = /* @__PURE__ */ new Map();
|
|
448
|
+
for (const node of layout.nodes) {
|
|
449
|
+
if (node.parent === null) continue;
|
|
450
|
+
const top = shared ? rankTop.get(node.depth) : topOf(node);
|
|
451
|
+
reach.set(node.parent, Math.min(reach.get(node.parent) ?? Infinity, top));
|
|
452
|
+
}
|
|
453
|
+
const bus = /* @__PURE__ */ new Map();
|
|
454
|
+
for (const [id, top] of reach) {
|
|
455
|
+
const parent = layout.byId.get(id);
|
|
456
|
+
if (!parent) continue;
|
|
457
|
+
const bottom = parent.y + parent.height;
|
|
458
|
+
const from = shared ? rankBottom.get(parent.depth) : bottomOf(parent);
|
|
459
|
+
bus.set(id, Math.min(Math.max(from + (top - from) / 2, bottom), top));
|
|
460
|
+
}
|
|
461
|
+
return bus;
|
|
462
|
+
}
|
|
463
|
+
function layoutConnectors(layout, shape = "elbow") {
|
|
312
464
|
const out = [];
|
|
465
|
+
const bus = busOf(layout);
|
|
313
466
|
for (const node of layout.nodes) {
|
|
314
467
|
if (node.parent === null) continue;
|
|
315
468
|
const parent = layout.byId.get(node.parent);
|
|
@@ -318,19 +471,35 @@ function layoutConnectors(layout, shape = "step") {
|
|
|
318
471
|
const fromY = parent.y + parent.height;
|
|
319
472
|
const toX = node.x + node.width / 2;
|
|
320
473
|
const toY = node.y;
|
|
321
|
-
const midY = fromY + (toY - fromY) / 2;
|
|
474
|
+
const midY = bus.get(parent.id) ?? fromY + (toY - fromY) / 2;
|
|
322
475
|
const across = toX - fromX;
|
|
323
476
|
const at = (d) => out.push({ id: node.id, parent: parent.id, d });
|
|
477
|
+
if (shape === "straight") {
|
|
478
|
+
at(`M${fromX} ${fromY}L${toX} ${toY}`);
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
324
481
|
if (shape === "curve") {
|
|
325
482
|
at(`M ${fromX} ${fromY} C ${fromX} ${midY}, ${toX} ${midY}, ${toX} ${toY}`);
|
|
326
483
|
continue;
|
|
327
484
|
}
|
|
328
|
-
if (Math.abs(across) <
|
|
485
|
+
if (Math.abs(across) < CENTRED) {
|
|
329
486
|
at(`M${fromX} ${fromY}V${toY}`);
|
|
330
487
|
continue;
|
|
331
488
|
}
|
|
332
|
-
const radius = Math.min(
|
|
489
|
+
const radius = Math.min(
|
|
490
|
+
shape === "elbow" ? ELBOW_RADIUS : STEP_RADIUS,
|
|
491
|
+
Math.abs(across) / 2,
|
|
492
|
+
Math.max(0, midY - fromY),
|
|
493
|
+
Math.max(0, toY - midY)
|
|
494
|
+
);
|
|
333
495
|
const step = across > 0 ? radius : -radius;
|
|
496
|
+
if (shape === "elbow") {
|
|
497
|
+
const first = across > 0 ? 0 : 1;
|
|
498
|
+
at(
|
|
499
|
+
`M${fromX} ${fromY}V${midY - radius}A${radius} ${radius} 0 0 ${first} ${fromX + step} ${midY}H${toX - step}A${radius} ${radius} 0 0 ${1 - first} ${toX} ${midY + radius}V${toY}`
|
|
500
|
+
);
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
334
503
|
at(
|
|
335
504
|
`M${fromX} ${fromY}V${midY - radius}Q${fromX} ${midY},${fromX + step} ${midY}H${toX - step}Q${toX} ${midY},${toX} ${midY + radius}V${toY}`
|
|
336
505
|
);
|
|
@@ -526,4 +695,4 @@ function useLayoutAnchor(positions, anchorId, keep) {
|
|
|
526
695
|
}, [positions, anchorId]);
|
|
527
696
|
}
|
|
528
697
|
|
|
529
|
-
export { SIZE_EPSILON, TYPE_AHEAD_RESET_MS, createTreeModel, isTypeAheadKey, layoutConnectors, layoutForest, treeAllExpandable, treeAncestors, treeCollapseOrAscend, treeExpandOrDescend, treeExpandTo, treeExpandable, treeFirst, treeFirstChild, treeItemAction, treeLast, treeLevel, treeNext, treeParent, treePosInSet, treePrevious, treeSetSize, treeStep, treeTypeAhead, treeVisible, typeAheadBuffer, useLayoutAnchor, useMeasuredSizes, useTreeState };
|
|
698
|
+
export { SIZE_EPSILON, TYPE_AHEAD_RESET_MS, createTreeModel, isTypeAheadKey, layoutConnectors, layoutForest, placeGroups, treeAllExpandable, treeAncestors, treeCollapseOrAscend, treeExpandOrDescend, treeExpandTo, treeExpandable, treeFirst, treeFirstChild, treeItemAction, treeLast, treeLevel, treeNext, treeParent, treePosInSet, treePrevious, treeSetSize, treeStep, treeTypeAhead, treeVisible, typeAheadBuffer, useLayoutAnchor, useMeasuredSizes, useTreeState };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useThemePreference, useDensityPreference } from './chunk-K3OWD7BJ.js';
|
|
2
|
+
import { SegmentedControl } from './chunk-DHPUMOTX.js';
|
|
3
|
+
import { SunGlyph, MonitorGlyph, MoonGlyph } from '@crewlethq/icons/glyphs';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function ThemeSwitcher(props) {
|
|
7
|
+
if (props.value !== void 0) {
|
|
8
|
+
const { storageKey: _none, ...controlled } = props;
|
|
9
|
+
return /* @__PURE__ */ jsx(ThemeRow, { ...controlled });
|
|
10
|
+
}
|
|
11
|
+
const { value: _stored, storageKey = "crewlet_theme", ...row } = props;
|
|
12
|
+
return /* @__PURE__ */ jsx(StoredThemeSwitcher, { ...row, storageKey });
|
|
13
|
+
}
|
|
14
|
+
function StoredThemeSwitcher({
|
|
15
|
+
storageKey,
|
|
16
|
+
onChange,
|
|
17
|
+
...row
|
|
18
|
+
}) {
|
|
19
|
+
const [theme, choose] = useThemePreference({ storageKey });
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
ThemeRow,
|
|
22
|
+
{
|
|
23
|
+
...row,
|
|
24
|
+
value: theme,
|
|
25
|
+
onChange: (next) => {
|
|
26
|
+
choose(next);
|
|
27
|
+
onChange?.(next);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
function ThemeRow({
|
|
33
|
+
value,
|
|
34
|
+
onChange,
|
|
35
|
+
label = "Theme",
|
|
36
|
+
lightLabel = "Light",
|
|
37
|
+
systemLabel = "Follow the system",
|
|
38
|
+
darkLabel = "Dark",
|
|
39
|
+
size = "sm",
|
|
40
|
+
className
|
|
41
|
+
}) {
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
SegmentedControl,
|
|
44
|
+
{
|
|
45
|
+
label,
|
|
46
|
+
semantics: "radio",
|
|
47
|
+
size,
|
|
48
|
+
className,
|
|
49
|
+
value,
|
|
50
|
+
onValueChange: onChange,
|
|
51
|
+
options: [
|
|
52
|
+
{ value: "light", icon: /* @__PURE__ */ jsx(SunGlyph, {}), srLabel: lightLabel, title: lightLabel },
|
|
53
|
+
{ value: "system", icon: /* @__PURE__ */ jsx(MonitorGlyph, {}), srLabel: systemLabel, title: systemLabel },
|
|
54
|
+
{ value: "dark", icon: /* @__PURE__ */ jsx(MoonGlyph, {}), srLabel: darkLabel, title: darkLabel }
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function DensitySwitcher(props) {
|
|
60
|
+
if (props.value !== void 0) {
|
|
61
|
+
const { storageKey: _none, ...controlled } = props;
|
|
62
|
+
return /* @__PURE__ */ jsx(DensityRow, { ...controlled });
|
|
63
|
+
}
|
|
64
|
+
const { value: _stored, storageKey = "crewlet_density", ...row } = props;
|
|
65
|
+
return /* @__PURE__ */ jsx(StoredDensitySwitcher, { ...row, storageKey });
|
|
66
|
+
}
|
|
67
|
+
function StoredDensitySwitcher({
|
|
68
|
+
storageKey,
|
|
69
|
+
onChange,
|
|
70
|
+
...row
|
|
71
|
+
}) {
|
|
72
|
+
const [density, choose] = useDensityPreference({ storageKey });
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
DensityRow,
|
|
75
|
+
{
|
|
76
|
+
...row,
|
|
77
|
+
value: density,
|
|
78
|
+
onChange: (next) => {
|
|
79
|
+
choose(next);
|
|
80
|
+
onChange?.(next);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
function DensityRow({
|
|
86
|
+
value,
|
|
87
|
+
onChange,
|
|
88
|
+
label = "Density",
|
|
89
|
+
compactLabel = "Compact",
|
|
90
|
+
normalLabel = "Normal",
|
|
91
|
+
comfortableLabel = "Comfortable",
|
|
92
|
+
compactMark = "S",
|
|
93
|
+
normalMark = "M",
|
|
94
|
+
comfortableMark = "L",
|
|
95
|
+
size = "sm",
|
|
96
|
+
className
|
|
97
|
+
}) {
|
|
98
|
+
return /* @__PURE__ */ jsx(
|
|
99
|
+
SegmentedControl,
|
|
100
|
+
{
|
|
101
|
+
label,
|
|
102
|
+
semantics: "radio",
|
|
103
|
+
size,
|
|
104
|
+
className,
|
|
105
|
+
value,
|
|
106
|
+
onValueChange: onChange,
|
|
107
|
+
options: [
|
|
108
|
+
{ value: "compact", label: compactMark, srLabel: compactLabel, title: compactLabel },
|
|
109
|
+
{ value: "normal", label: normalMark, srLabel: normalLabel, title: normalLabel },
|
|
110
|
+
{
|
|
111
|
+
value: "comfortable",
|
|
112
|
+
label: comfortableMark,
|
|
113
|
+
srLabel: comfortableLabel,
|
|
114
|
+
title: comfortableLabel
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { DensitySwitcher, ThemeSwitcher };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useListbox, useOptionKeys } from './chunk-
|
|
1
|
+
import { useListbox, useOptionKeys } from './chunk-6MU7HNB4.js';
|
|
2
2
|
import { useLayerContainer, viewportBounds, outsideBounds, placePopup, LAYER_GAP, LAYER_REPOSITION_EVENT } from './chunk-7RPGY3JE.js';
|
|
3
3
|
import { cx } from './chunk-ODEQTPFM.js';
|
|
4
|
-
import './Select-
|
|
4
|
+
import './Select-E24U5LBC.css';
|
|
5
5
|
import { forwardRef, useId, useMemo, useState, useRef, useCallback, useEffect, useLayoutEffect } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
|
-
import {
|
|
7
|
+
import { ChevronDownGlyph, CheckGlyph, SearchGlyph } from '@crewlethq/icons/glyphs';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
|
|
10
10
|
var same = (a, b) => String(a) === String(b);
|
|
@@ -77,6 +77,7 @@ var Select = forwardRef(function Select2({
|
|
|
77
77
|
className: classes,
|
|
78
78
|
menuClassName,
|
|
79
79
|
size,
|
|
80
|
+
width,
|
|
80
81
|
align,
|
|
81
82
|
active,
|
|
82
83
|
error,
|
|
@@ -138,7 +139,7 @@ var NativeSelect = forwardRef(function NativeSelect2({ id, value, onChange, opti
|
|
|
138
139
|
]
|
|
139
140
|
}
|
|
140
141
|
),
|
|
141
|
-
/* @__PURE__ */ jsx(
|
|
142
|
+
/* @__PURE__ */ jsx(ChevronDownGlyph, { className: "crewlet-select__chevron", size: "sm" })
|
|
142
143
|
]
|
|
143
144
|
}
|
|
144
145
|
);
|
|
@@ -153,6 +154,7 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
153
154
|
className,
|
|
154
155
|
menuClassName,
|
|
155
156
|
size,
|
|
157
|
+
width,
|
|
156
158
|
align,
|
|
157
159
|
active,
|
|
158
160
|
error,
|
|
@@ -236,6 +238,11 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
236
238
|
listbox,
|
|
237
239
|
count: flat.length,
|
|
238
240
|
disabled: (index2) => flat[index2]?.disabled === true,
|
|
241
|
+
// AND NEITHER ARE THE ENDS, for the same reason type-ahead is withheld
|
|
242
|
+
// below: with a search box on screen those keys are the caret's, and the
|
|
243
|
+
// query's own start and end are otherwise unreachable — the panel is
|
|
244
|
+
// portalled, so a pointer cannot place the caret either.
|
|
245
|
+
ends: !searchable,
|
|
239
246
|
...searchable ? {} : {
|
|
240
247
|
textOf: (index2) => {
|
|
241
248
|
const option = flat[index2];
|
|
@@ -247,6 +254,11 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
247
254
|
if (!open) return;
|
|
248
255
|
listbox.setActive(keys.opening(flat.findIndex((option) => isChosen(option.value))));
|
|
249
256
|
}, [open]);
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
if (!open || listbox.active < 0) return;
|
|
259
|
+
if (flat[listbox.active]?.disabled !== true) return;
|
|
260
|
+
listbox.setActive(keys.step(listbox.active, 1));
|
|
261
|
+
}, [open, flat]);
|
|
250
262
|
useEffect(() => {
|
|
251
263
|
if (open && searchable) search.current?.focus();
|
|
252
264
|
}, [open, searchable]);
|
|
@@ -269,27 +281,32 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
269
281
|
const inHost = container !== document.body;
|
|
270
282
|
const host = inHost ? container.getBoundingClientRect() : viewportBounds();
|
|
271
283
|
const rect = at.getBoundingClientRect();
|
|
272
|
-
const
|
|
284
|
+
const matches = width === "full";
|
|
285
|
+
box.style.width = matches ? `${rect.width}px` : "";
|
|
286
|
+
box.style.minWidth = matches ? "" : `${rect.width}px`;
|
|
287
|
+
const own = box.getBoundingClientRect();
|
|
273
288
|
const local = {
|
|
274
|
-
x: (align === "right" ? rect.right - width : rect.left) - (inHost ? host.x : 0),
|
|
289
|
+
x: (align === "right" ? rect.right - own.width : rect.left) - (inHost ? host.x : 0),
|
|
275
290
|
y: rect.top - (inHost ? host.y : 0),
|
|
276
291
|
width: rect.width,
|
|
277
292
|
height: rect.height
|
|
278
293
|
};
|
|
279
294
|
const whole = { x: 0, y: 0, width: host.width, height: host.height };
|
|
280
295
|
if (outsideBounds(local, whole)) {
|
|
281
|
-
close(false);
|
|
296
|
+
close(panel.current?.contains(document.activeElement) ?? false);
|
|
282
297
|
return;
|
|
283
298
|
}
|
|
284
299
|
const spot = placePopup(
|
|
285
300
|
local,
|
|
286
|
-
{ width, height:
|
|
301
|
+
{ width: own.width, height: own.height },
|
|
287
302
|
{ x: LAYER_GAP, y: LAYER_GAP, width: host.width - 2 * LAYER_GAP, height: host.height - 2 * LAYER_GAP }
|
|
288
303
|
);
|
|
304
|
+
const applied = matches ? rect.width : void 0;
|
|
305
|
+
const floor = matches ? void 0 : rect.width;
|
|
289
306
|
setPlace(
|
|
290
|
-
(was) => was && was.left === spot.left && was.top === spot.top && was.width ===
|
|
307
|
+
(was) => was && was.left === spot.left && was.top === spot.top && was.width === applied && was.minWidth === floor ? was : { left: spot.left, top: spot.top, width: applied, minWidth: floor }
|
|
291
308
|
);
|
|
292
|
-
}, [align, close, container]);
|
|
309
|
+
}, [align, close, container, width]);
|
|
293
310
|
useLayoutEffect(() => {
|
|
294
311
|
if (!open) {
|
|
295
312
|
setPlace(null);
|
|
@@ -306,6 +323,9 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
306
323
|
window.removeEventListener("scroll", onLayout, true);
|
|
307
324
|
};
|
|
308
325
|
}, [open, container, position]);
|
|
326
|
+
useLayoutEffect(() => {
|
|
327
|
+
if (open) position();
|
|
328
|
+
}, [open, flat.length, position]);
|
|
309
329
|
function onKeyDown(event) {
|
|
310
330
|
if (disabled) return;
|
|
311
331
|
if (!open) {
|
|
@@ -339,7 +359,7 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
339
359
|
hasValue = false;
|
|
340
360
|
}
|
|
341
361
|
const listId = listbox.listId;
|
|
342
|
-
const activeId = open &&
|
|
362
|
+
const activeId = open && listbox.active >= 0 ? listbox.optionId(listbox.active) : void 0;
|
|
343
363
|
const comboOnTrigger = !searchable;
|
|
344
364
|
const requiredForAria = ariaRequired ?? required;
|
|
345
365
|
let index = -1;
|
|
@@ -388,6 +408,7 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
388
408
|
{
|
|
389
409
|
ref: (el) => {
|
|
390
410
|
panel.current = el;
|
|
411
|
+
listbox.panelRef(el);
|
|
391
412
|
},
|
|
392
413
|
className: cx(
|
|
393
414
|
"crewlet-select__menu",
|
|
@@ -395,7 +416,7 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
395
416
|
container !== null && container !== document.body ? "crewlet-select__menu--in-host" : "crewlet-select__menu--fixed",
|
|
396
417
|
menuClassName
|
|
397
418
|
),
|
|
398
|
-
style: place ? { left: place.left, top: place.top, width: place.width } : (
|
|
419
|
+
style: place ? { left: place.left, top: place.top, width: place.width, minWidth: place.minWidth } : (
|
|
399
420
|
// Laid out but not painted, so its own height can be measured
|
|
400
421
|
// before it is placed and no reader sees it in a corner first.
|
|
401
422
|
{ visibility: "hidden" }
|
|
@@ -430,7 +451,6 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
430
451
|
{
|
|
431
452
|
ref: (el) => {
|
|
432
453
|
list.current = el;
|
|
433
|
-
listbox.listRef(el);
|
|
434
454
|
},
|
|
435
455
|
id: listId,
|
|
436
456
|
className: cx("crewlet-listbox", "crewlet-select__list"),
|
|
@@ -485,7 +505,7 @@ var ListboxSelect = forwardRef(function ListboxSelect2({
|
|
|
485
505
|
onKeyDown,
|
|
486
506
|
children: [
|
|
487
507
|
renderTrigger ? renderTrigger(single, { open }) : /* @__PURE__ */ jsx("span", { className: cx("crewlet-select__label", !hasValue && "is-placeholder"), children: label }),
|
|
488
|
-
/* @__PURE__ */ jsx(
|
|
508
|
+
/* @__PURE__ */ jsx(ChevronDownGlyph, { className: "crewlet-select__chevron", size: "sm" })
|
|
489
509
|
]
|
|
490
510
|
}
|
|
491
511
|
),
|