@wow-two-beta/ui 0.0.13 → 0.0.14
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/dist/{chunk-PRRVOVUC.js → chunk-ASXB42MH.js} +524 -4
- package/dist/chunk-ASXB42MH.js.map +1 -0
- package/dist/{chunk-A4N52LL6.js → chunk-BQTO7XY6.js} +172 -313
- package/dist/chunk-BQTO7XY6.js.map +1 -0
- package/dist/{chunk-EU6JT5B4.js → chunk-FS6DTWWH.js} +117 -142
- package/dist/chunk-FS6DTWWH.js.map +1 -0
- package/dist/display/dataTable/DataTable.d.ts +34 -0
- package/dist/display/dataTable/DataTable.d.ts.map +1 -0
- package/dist/display/dataTable/index.d.ts +2 -0
- package/dist/display/dataTable/index.d.ts.map +1 -0
- package/dist/display/index.d.ts +5 -0
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +1 -1
- package/dist/display/list/List.d.ts +23 -0
- package/dist/display/list/List.d.ts.map +1 -0
- package/dist/display/list/List.variants.d.ts +89 -0
- package/dist/display/list/List.variants.d.ts.map +1 -0
- package/dist/display/list/index.d.ts +2 -0
- package/dist/display/list/index.d.ts.map +1 -0
- package/dist/display/table/Table.d.ts +35 -0
- package/dist/display/table/Table.d.ts.map +1 -0
- package/dist/display/table/index.d.ts +2 -0
- package/dist/display/table/index.d.ts.map +1 -0
- package/dist/display/timeline/Timeline.d.ts +29 -0
- package/dist/display/timeline/Timeline.d.ts.map +1 -0
- package/dist/display/timeline/index.d.ts +2 -0
- package/dist/display/timeline/index.d.ts.map +1 -0
- package/dist/display/tree/Tree.d.ts +30 -0
- package/dist/display/tree/Tree.d.ts.map +1 -0
- package/dist/display/tree/index.d.ts +2 -0
- package/dist/display/tree/index.d.ts.map +1 -0
- package/dist/forms/MonthGrid.d.ts +29 -0
- package/dist/forms/MonthGrid.d.ts.map +1 -0
- package/dist/forms/calendar/Calendar.d.ts.map +1 -1
- package/dist/forms/index.js +2 -2
- package/dist/forms/multiSelect/MultiSelect.d.ts +4 -5
- package/dist/forms/multiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/forms/rangeCalendar/RangeCalendar.d.ts.map +1 -1
- package/dist/forms/select/Select.d.ts +5 -9
- package/dist/forms/select/Select.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/overlays/OverlayChrome.d.ts +34 -0
- package/dist/overlays/OverlayChrome.d.ts.map +1 -0
- package/dist/overlays/dialog/Dialog.d.ts +7 -25
- package/dist/overlays/dialog/Dialog.d.ts.map +1 -1
- package/dist/overlays/dialog/index.d.ts +1 -1
- package/dist/overlays/dialog/index.d.ts.map +1 -1
- package/dist/overlays/drawer/Drawer.d.ts +7 -21
- package/dist/overlays/drawer/Drawer.d.ts.map +1 -1
- package/dist/overlays/drawer/index.d.ts +1 -1
- package/dist/overlays/drawer/index.d.ts.map +1 -1
- package/dist/overlays/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-A4N52LL6.js.map +0 -1
- package/dist/chunk-EU6JT5B4.js.map +0 -1
- package/dist/chunk-PRRVOVUC.js.map +0 -1
|
@@ -6,7 +6,7 @@ import { composeRefs } from './chunk-DN7WBRIV.js';
|
|
|
6
6
|
import { cn } from './chunk-KZ4VFY2T.js';
|
|
7
7
|
import { forwardRef, useState, Children, isValidElement, Fragment as Fragment$1, createContext, useId, useMemo, useCallback, useContext, useRef, cloneElement } from 'react';
|
|
8
8
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
9
|
-
import { X, TrendingUp, TrendingDown, Check, Copy, ChevronDown } from 'lucide-react';
|
|
9
|
+
import { X, TrendingUp, TrendingDown, Check, Copy, ChevronDown, ChevronRight, ArrowUp, ArrowDown, ArrowUpDown } from 'lucide-react';
|
|
10
10
|
|
|
11
11
|
// src/display/heading/Heading.variants.ts
|
|
12
12
|
var headingVariants = tv({
|
|
@@ -1145,6 +1145,526 @@ Tabs.List = TabsList;
|
|
|
1145
1145
|
Tabs.Tab = TabsTab;
|
|
1146
1146
|
Tabs.Panel = TabsPanel;
|
|
1147
1147
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1148
|
+
// src/display/list/List.variants.ts
|
|
1149
|
+
var listVariants = tv({
|
|
1150
|
+
base: "list-outside",
|
|
1151
|
+
variants: {
|
|
1152
|
+
marker: {
|
|
1153
|
+
none: "list-none pl-0",
|
|
1154
|
+
disc: "list-disc pl-5",
|
|
1155
|
+
decimal: "list-decimal pl-5",
|
|
1156
|
+
check: "list-none pl-0"
|
|
1157
|
+
},
|
|
1158
|
+
spacing: {
|
|
1159
|
+
tight: "[&>li]:py-0.5",
|
|
1160
|
+
normal: "[&>li]:py-1",
|
|
1161
|
+
loose: "[&>li]:py-2"
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
defaultVariants: {
|
|
1165
|
+
marker: "none",
|
|
1166
|
+
spacing: "normal"
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
var listItemVariants = tv({
|
|
1170
|
+
base: "flex items-start gap-3 text-sm text-foreground"
|
|
1171
|
+
});
|
|
1172
|
+
var List = forwardRef(function List2({ ordered, marker, spacing, className, children, ...rest }, ref) {
|
|
1173
|
+
const Component = ordered ? "ol" : "ul";
|
|
1174
|
+
return /* @__PURE__ */ jsx(
|
|
1175
|
+
Component,
|
|
1176
|
+
{
|
|
1177
|
+
ref,
|
|
1178
|
+
className: cn(listVariants({ marker, spacing }), className),
|
|
1179
|
+
...rest,
|
|
1180
|
+
children
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1183
|
+
});
|
|
1184
|
+
var ListItem = forwardRef(function ListItem2({ leading, trailing, showCheckMarker, className, children, ...rest }, ref) {
|
|
1185
|
+
return /* @__PURE__ */ jsxs("li", { ref, className: cn(listItemVariants(), className), ...rest, children: [
|
|
1186
|
+
showCheckMarker && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mt-0.5 shrink-0 text-primary", children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }),
|
|
1187
|
+
leading && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mt-0.5 shrink-0 text-muted-foreground", children: leading }),
|
|
1188
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children }),
|
|
1189
|
+
trailing && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground", children: trailing })
|
|
1190
|
+
] });
|
|
1191
|
+
});
|
|
1192
|
+
List.Item = ListItem;
|
|
1193
|
+
var TimelineContext = createContext(null);
|
|
1194
|
+
var Timeline = forwardRef(function Timeline2({ align = "left", className, children, ...rest }, ref) {
|
|
1195
|
+
const total = Children.toArray(children).filter(isValidElement).length;
|
|
1196
|
+
return /* @__PURE__ */ jsx(TimelineContext.Provider, { value: { align, total }, children: /* @__PURE__ */ jsx(
|
|
1197
|
+
"ol",
|
|
1198
|
+
{
|
|
1199
|
+
ref,
|
|
1200
|
+
className: cn(
|
|
1201
|
+
"flex list-none flex-col",
|
|
1202
|
+
align === "right" && "items-end",
|
|
1203
|
+
className
|
|
1204
|
+
),
|
|
1205
|
+
...rest,
|
|
1206
|
+
children: Children.map(children, (child, idx) => {
|
|
1207
|
+
if (!isValidElement(child)) return child;
|
|
1208
|
+
return idx === total - 1 ? (
|
|
1209
|
+
// mark the last item so the connector line is suppressed
|
|
1210
|
+
{ ...child, props: { ...child.props, "data-last": "" } }
|
|
1211
|
+
) : child;
|
|
1212
|
+
})
|
|
1213
|
+
}
|
|
1214
|
+
) });
|
|
1215
|
+
});
|
|
1216
|
+
var STATUS_BG = {
|
|
1217
|
+
default: "bg-muted text-muted-foreground border-border",
|
|
1218
|
+
primary: "bg-primary text-primary-foreground border-primary",
|
|
1219
|
+
success: "bg-success text-success-foreground border-success",
|
|
1220
|
+
warning: "bg-warning text-warning-foreground border-warning",
|
|
1221
|
+
destructive: "bg-destructive text-destructive-foreground border-destructive",
|
|
1222
|
+
info: "bg-info text-info-foreground border-info"
|
|
1223
|
+
};
|
|
1224
|
+
var TimelineItem = forwardRef(function TimelineItem2({ status = "default", icon, className, children, ...rest }, ref) {
|
|
1225
|
+
const ctx = useContext(TimelineContext);
|
|
1226
|
+
const isLast = rest["data-last"] !== void 0;
|
|
1227
|
+
return /* @__PURE__ */ jsxs(
|
|
1228
|
+
"li",
|
|
1229
|
+
{
|
|
1230
|
+
ref,
|
|
1231
|
+
"data-status": status,
|
|
1232
|
+
className: cn("relative flex gap-3 pb-6 last:pb-0", className),
|
|
1233
|
+
...rest,
|
|
1234
|
+
children: [
|
|
1235
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex flex-col items-center", children: [
|
|
1236
|
+
/* @__PURE__ */ jsx(
|
|
1237
|
+
"span",
|
|
1238
|
+
{
|
|
1239
|
+
"aria-hidden": "true",
|
|
1240
|
+
className: cn(
|
|
1241
|
+
"relative z-10 grid h-7 w-7 place-items-center rounded-full border-2",
|
|
1242
|
+
STATUS_BG[status]
|
|
1243
|
+
),
|
|
1244
|
+
children: icon ?? /* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-current" })
|
|
1245
|
+
}
|
|
1246
|
+
),
|
|
1247
|
+
!isLast && /* @__PURE__ */ jsx(
|
|
1248
|
+
"span",
|
|
1249
|
+
{
|
|
1250
|
+
"aria-hidden": "true",
|
|
1251
|
+
className: cn(
|
|
1252
|
+
"absolute left-1/2 top-7 h-full w-px -translate-x-1/2 bg-border"
|
|
1253
|
+
)
|
|
1254
|
+
}
|
|
1255
|
+
)
|
|
1256
|
+
] }),
|
|
1257
|
+
/* @__PURE__ */ jsx("div", { className: cn("flex-1 pt-0.5", ctx?.align === "right" && "order-first text-right"), children })
|
|
1258
|
+
]
|
|
1259
|
+
}
|
|
1260
|
+
);
|
|
1261
|
+
});
|
|
1262
|
+
function TimelineTitle({ className, children, ...rest }) {
|
|
1263
|
+
return /* @__PURE__ */ jsx("h4", { className: cn("text-sm font-medium text-foreground", className), ...rest, children });
|
|
1264
|
+
}
|
|
1265
|
+
function TimelineDescription({
|
|
1266
|
+
className,
|
|
1267
|
+
children,
|
|
1268
|
+
...rest
|
|
1269
|
+
}) {
|
|
1270
|
+
return /* @__PURE__ */ jsx("p", { className: cn("text-xs text-muted-foreground", className), ...rest, children });
|
|
1271
|
+
}
|
|
1272
|
+
Timeline.Item = TimelineItem;
|
|
1273
|
+
Timeline.Title = TimelineTitle;
|
|
1274
|
+
Timeline.Description = TimelineDescription;
|
|
1275
|
+
var TreeContext = createContext(null);
|
|
1276
|
+
function useTreeContext() {
|
|
1277
|
+
const ctx = useContext(TreeContext);
|
|
1278
|
+
if (!ctx) throw new Error("Tree.* must be used inside <Tree>");
|
|
1279
|
+
return ctx;
|
|
1280
|
+
}
|
|
1281
|
+
var TreeLevelContext = createContext({ level: 1 });
|
|
1282
|
+
function useTreeLevel() {
|
|
1283
|
+
return useContext(TreeLevelContext).level;
|
|
1284
|
+
}
|
|
1285
|
+
var Tree = forwardRef(function Tree2({
|
|
1286
|
+
selectedValue,
|
|
1287
|
+
defaultSelectedValue,
|
|
1288
|
+
onSelectionChange,
|
|
1289
|
+
expanded,
|
|
1290
|
+
defaultExpanded,
|
|
1291
|
+
onExpandedChange,
|
|
1292
|
+
className,
|
|
1293
|
+
children,
|
|
1294
|
+
...rest
|
|
1295
|
+
}, ref) {
|
|
1296
|
+
const [selected, setSelected] = useControlled({
|
|
1297
|
+
controlled: selectedValue,
|
|
1298
|
+
default: defaultSelectedValue ?? null,
|
|
1299
|
+
onChange: onSelectionChange
|
|
1300
|
+
});
|
|
1301
|
+
const [expandedList, setExpandedList] = useControlled({
|
|
1302
|
+
controlled: expanded,
|
|
1303
|
+
default: defaultExpanded ?? [],
|
|
1304
|
+
onChange: onExpandedChange
|
|
1305
|
+
});
|
|
1306
|
+
const expandedSet = useMemo(() => new Set(expandedList), [expandedList]);
|
|
1307
|
+
const toggleExpanded = useCallback(
|
|
1308
|
+
(value) => {
|
|
1309
|
+
const next = new Set(expandedSet);
|
|
1310
|
+
if (next.has(value)) next.delete(value);
|
|
1311
|
+
else next.add(value);
|
|
1312
|
+
setExpandedList(Array.from(next));
|
|
1313
|
+
},
|
|
1314
|
+
[expandedSet, setExpandedList]
|
|
1315
|
+
);
|
|
1316
|
+
const ctx = useMemo(
|
|
1317
|
+
() => ({
|
|
1318
|
+
selectedValue: selected,
|
|
1319
|
+
setSelectedValue: setSelected,
|
|
1320
|
+
expanded: expandedSet,
|
|
1321
|
+
toggleExpanded
|
|
1322
|
+
}),
|
|
1323
|
+
[selected, setSelected, expandedSet, toggleExpanded]
|
|
1324
|
+
);
|
|
1325
|
+
return /* @__PURE__ */ jsx(TreeContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
1326
|
+
RovingFocusGroup,
|
|
1327
|
+
{
|
|
1328
|
+
ref,
|
|
1329
|
+
orientation: "vertical",
|
|
1330
|
+
loop: true,
|
|
1331
|
+
role: "tree",
|
|
1332
|
+
className: cn("flex flex-col text-sm", className),
|
|
1333
|
+
...rest,
|
|
1334
|
+
children
|
|
1335
|
+
}
|
|
1336
|
+
) });
|
|
1337
|
+
});
|
|
1338
|
+
function NodeRow({
|
|
1339
|
+
level,
|
|
1340
|
+
selected,
|
|
1341
|
+
expanded,
|
|
1342
|
+
hasChildren,
|
|
1343
|
+
disabled,
|
|
1344
|
+
onActivate,
|
|
1345
|
+
label
|
|
1346
|
+
}) {
|
|
1347
|
+
const roving = useRovingFocusItem();
|
|
1348
|
+
const handleKeyDown = useCallback(
|
|
1349
|
+
(e) => {
|
|
1350
|
+
roving.onKeyDown(e);
|
|
1351
|
+
if (e.defaultPrevented || disabled) return;
|
|
1352
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1353
|
+
e.preventDefault();
|
|
1354
|
+
onActivate();
|
|
1355
|
+
}
|
|
1356
|
+
},
|
|
1357
|
+
[roving, disabled, onActivate]
|
|
1358
|
+
);
|
|
1359
|
+
return /* @__PURE__ */ jsxs(
|
|
1360
|
+
"div",
|
|
1361
|
+
{
|
|
1362
|
+
ref: roving.ref,
|
|
1363
|
+
role: "treeitem",
|
|
1364
|
+
"aria-level": level,
|
|
1365
|
+
"aria-selected": selected || void 0,
|
|
1366
|
+
"aria-expanded": hasChildren ? expanded : void 0,
|
|
1367
|
+
"aria-disabled": disabled || void 0,
|
|
1368
|
+
"data-selected": dataAttr(selected),
|
|
1369
|
+
"data-disabled": dataAttr(disabled),
|
|
1370
|
+
tabIndex: roving.tabIndex,
|
|
1371
|
+
onFocus: roving.onFocus,
|
|
1372
|
+
onKeyDown: handleKeyDown,
|
|
1373
|
+
onClick: () => {
|
|
1374
|
+
if (!disabled) onActivate();
|
|
1375
|
+
},
|
|
1376
|
+
style: { paddingLeft: `${(level - 1) * 16}px` },
|
|
1377
|
+
className: cn(
|
|
1378
|
+
"flex cursor-pointer items-center gap-1 rounded-sm px-2 py-1 transition-colors",
|
|
1379
|
+
"hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1380
|
+
selected && "bg-primary-soft text-primary-soft-foreground",
|
|
1381
|
+
disabled && "pointer-events-none opacity-50"
|
|
1382
|
+
),
|
|
1383
|
+
children: [
|
|
1384
|
+
hasChildren ? /* @__PURE__ */ jsx(
|
|
1385
|
+
ChevronRight,
|
|
1386
|
+
{
|
|
1387
|
+
className: cn(
|
|
1388
|
+
"h-4 w-4 shrink-0 text-muted-foreground transition-transform",
|
|
1389
|
+
expanded && "rotate-90"
|
|
1390
|
+
)
|
|
1391
|
+
}
|
|
1392
|
+
) : /* @__PURE__ */ jsx("span", { className: "w-4 shrink-0" }),
|
|
1393
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1 truncate", children: label })
|
|
1394
|
+
]
|
|
1395
|
+
}
|
|
1396
|
+
);
|
|
1397
|
+
}
|
|
1398
|
+
var TreeGroup = forwardRef(function TreeGroup2({ value, label, disabled = false, className, children, ...rest }, ref) {
|
|
1399
|
+
const ctx = useTreeContext();
|
|
1400
|
+
const level = useTreeLevel();
|
|
1401
|
+
const expanded = ctx.expanded.has(value);
|
|
1402
|
+
return /* @__PURE__ */ jsxs(
|
|
1403
|
+
"li",
|
|
1404
|
+
{
|
|
1405
|
+
ref,
|
|
1406
|
+
role: "presentation",
|
|
1407
|
+
"data-state": expanded ? "open" : "closed",
|
|
1408
|
+
className: cn("list-none", className),
|
|
1409
|
+
...rest,
|
|
1410
|
+
children: [
|
|
1411
|
+
/* @__PURE__ */ jsx(
|
|
1412
|
+
NodeRow,
|
|
1413
|
+
{
|
|
1414
|
+
level,
|
|
1415
|
+
selected: false,
|
|
1416
|
+
expanded,
|
|
1417
|
+
hasChildren: true,
|
|
1418
|
+
disabled,
|
|
1419
|
+
onActivate: () => ctx.toggleExpanded(value),
|
|
1420
|
+
label
|
|
1421
|
+
}
|
|
1422
|
+
),
|
|
1423
|
+
expanded && /* @__PURE__ */ jsx(TreeLevelContext.Provider, { value: { level: level + 1 }, children: /* @__PURE__ */ jsx("ul", { role: "group", className: "flex flex-col", children }) })
|
|
1424
|
+
]
|
|
1425
|
+
}
|
|
1426
|
+
);
|
|
1427
|
+
});
|
|
1428
|
+
var TreeItem = forwardRef(function TreeItem2({ value, disabled = false, className, children, ...rest }, ref) {
|
|
1429
|
+
const ctx = useTreeContext();
|
|
1430
|
+
const level = useTreeLevel();
|
|
1431
|
+
const selected = ctx.selectedValue === value;
|
|
1432
|
+
return /* @__PURE__ */ jsx("li", { ref, role: "presentation", className: cn("list-none", className), ...rest, children: /* @__PURE__ */ jsx(
|
|
1433
|
+
NodeRow,
|
|
1434
|
+
{
|
|
1435
|
+
level,
|
|
1436
|
+
selected,
|
|
1437
|
+
hasChildren: false,
|
|
1438
|
+
disabled,
|
|
1439
|
+
onActivate: () => ctx.setSelectedValue(value),
|
|
1440
|
+
label: children
|
|
1441
|
+
}
|
|
1442
|
+
) });
|
|
1443
|
+
});
|
|
1444
|
+
Tree.Group = TreeGroup;
|
|
1445
|
+
Tree.Item = TreeItem;
|
|
1446
|
+
var TableContext = createContext({
|
|
1447
|
+
striped: false,
|
|
1448
|
+
hoverable: false,
|
|
1449
|
+
density: "cozy"
|
|
1450
|
+
});
|
|
1451
|
+
var DENSITY_CELL = {
|
|
1452
|
+
compact: "px-2 py-1.5 text-sm",
|
|
1453
|
+
cozy: "px-3 py-2 text-sm",
|
|
1454
|
+
comfortable: "px-4 py-3 text-sm"
|
|
1455
|
+
};
|
|
1456
|
+
var Table = forwardRef(function Table2({ striped = false, hoverable = false, density = "cozy", bare = false, className, children, ...rest }, ref) {
|
|
1457
|
+
const ctx = { striped, hoverable, density };
|
|
1458
|
+
const tableEl = /* @__PURE__ */ jsx(
|
|
1459
|
+
"table",
|
|
1460
|
+
{
|
|
1461
|
+
ref,
|
|
1462
|
+
className: cn("w-full caption-bottom border-collapse text-left", className),
|
|
1463
|
+
...rest,
|
|
1464
|
+
children
|
|
1465
|
+
}
|
|
1466
|
+
);
|
|
1467
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: ctx, children: bare ? tableEl : /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-x-auto rounded-md border border-border", children: tableEl }) });
|
|
1468
|
+
});
|
|
1469
|
+
var TableHead = forwardRef(
|
|
1470
|
+
function TableHead2({ className, ...rest }, ref) {
|
|
1471
|
+
return /* @__PURE__ */ jsx(
|
|
1472
|
+
"thead",
|
|
1473
|
+
{
|
|
1474
|
+
ref,
|
|
1475
|
+
className: cn("border-b border-border bg-muted/50 text-xs font-semibold uppercase tracking-wide text-muted-foreground", className),
|
|
1476
|
+
...rest
|
|
1477
|
+
}
|
|
1478
|
+
);
|
|
1479
|
+
}
|
|
1480
|
+
);
|
|
1481
|
+
var TableBody = forwardRef(
|
|
1482
|
+
function TableBody2({ className, ...rest }, ref) {
|
|
1483
|
+
const ctx = useContext(TableContext);
|
|
1484
|
+
return /* @__PURE__ */ jsx(
|
|
1485
|
+
"tbody",
|
|
1486
|
+
{
|
|
1487
|
+
ref,
|
|
1488
|
+
className: cn(
|
|
1489
|
+
ctx.striped && "[&>tr:nth-child(even)]:bg-muted/30",
|
|
1490
|
+
ctx.hoverable && "[&>tr:hover]:bg-muted",
|
|
1491
|
+
className
|
|
1492
|
+
),
|
|
1493
|
+
...rest
|
|
1494
|
+
}
|
|
1495
|
+
);
|
|
1496
|
+
}
|
|
1497
|
+
);
|
|
1498
|
+
var TableFooter = forwardRef(
|
|
1499
|
+
function TableFooter2({ className, ...rest }, ref) {
|
|
1500
|
+
return /* @__PURE__ */ jsx(
|
|
1501
|
+
"tfoot",
|
|
1502
|
+
{
|
|
1503
|
+
ref,
|
|
1504
|
+
className: cn("border-t border-border bg-muted/50 font-medium", className),
|
|
1505
|
+
...rest
|
|
1506
|
+
}
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
);
|
|
1510
|
+
var TableRow = forwardRef(
|
|
1511
|
+
function TableRow2({ className, ...rest }, ref) {
|
|
1512
|
+
return /* @__PURE__ */ jsx(
|
|
1513
|
+
"tr",
|
|
1514
|
+
{
|
|
1515
|
+
ref,
|
|
1516
|
+
className: cn("border-b border-border last:border-0 transition-colors data-[selected]:bg-primary-soft", className),
|
|
1517
|
+
...rest
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
var TableHeaderCell = forwardRef(
|
|
1523
|
+
function TableHeaderCell2({ className, ...rest }, ref) {
|
|
1524
|
+
const ctx = useContext(TableContext);
|
|
1525
|
+
return /* @__PURE__ */ jsx(
|
|
1526
|
+
"th",
|
|
1527
|
+
{
|
|
1528
|
+
ref,
|
|
1529
|
+
scope: "col",
|
|
1530
|
+
className: cn(DENSITY_CELL[ctx.density], "font-semibold text-foreground", className),
|
|
1531
|
+
...rest
|
|
1532
|
+
}
|
|
1533
|
+
);
|
|
1534
|
+
}
|
|
1535
|
+
);
|
|
1536
|
+
var TableCell = forwardRef(function TableCell2({ className, ...rest }, ref) {
|
|
1537
|
+
const ctx = useContext(TableContext);
|
|
1538
|
+
return /* @__PURE__ */ jsx(
|
|
1539
|
+
"td",
|
|
1540
|
+
{
|
|
1541
|
+
ref,
|
|
1542
|
+
className: cn(DENSITY_CELL[ctx.density], "align-middle", className),
|
|
1543
|
+
...rest
|
|
1544
|
+
}
|
|
1545
|
+
);
|
|
1546
|
+
});
|
|
1547
|
+
var TableCaption = forwardRef(function TableCaption2({ className, ...rest }, ref) {
|
|
1548
|
+
return /* @__PURE__ */ jsx(
|
|
1549
|
+
"caption",
|
|
1550
|
+
{
|
|
1551
|
+
ref,
|
|
1552
|
+
className: cn("mt-2 text-sm text-muted-foreground", className),
|
|
1553
|
+
...rest
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
1556
|
+
});
|
|
1557
|
+
Table.Head = TableHead;
|
|
1558
|
+
Table.Body = TableBody;
|
|
1559
|
+
Table.Footer = TableFooter;
|
|
1560
|
+
Table.Row = TableRow;
|
|
1561
|
+
Table.HeaderCell = TableHeaderCell;
|
|
1562
|
+
Table.Cell = TableCell;
|
|
1563
|
+
Table.Caption = TableCaption;
|
|
1564
|
+
function defaultCompare(a, b) {
|
|
1565
|
+
if (a === b) return 0;
|
|
1566
|
+
if (a === null || a === void 0) return 1;
|
|
1567
|
+
if (b === null || b === void 0) return -1;
|
|
1568
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
1569
|
+
if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
|
|
1570
|
+
return String(a).localeCompare(String(b));
|
|
1571
|
+
}
|
|
1572
|
+
function DataTable({
|
|
1573
|
+
columns,
|
|
1574
|
+
data,
|
|
1575
|
+
rowKey,
|
|
1576
|
+
onRowClick,
|
|
1577
|
+
sortBy,
|
|
1578
|
+
defaultSortBy,
|
|
1579
|
+
onSortChange,
|
|
1580
|
+
striped,
|
|
1581
|
+
hoverable = !!onRowClick,
|
|
1582
|
+
density,
|
|
1583
|
+
bare,
|
|
1584
|
+
emptyContent = "No results.",
|
|
1585
|
+
className,
|
|
1586
|
+
"aria-label": ariaLabel
|
|
1587
|
+
}) {
|
|
1588
|
+
const [sort, setSort] = useControlled({
|
|
1589
|
+
controlled: sortBy,
|
|
1590
|
+
default: defaultSortBy ?? null,
|
|
1591
|
+
onChange: onSortChange
|
|
1592
|
+
});
|
|
1593
|
+
const sortedData = useMemo(() => {
|
|
1594
|
+
if (!sort) return data;
|
|
1595
|
+
const col = columns.find((c) => c.key === sort.columnKey);
|
|
1596
|
+
if (!col?.accessor) return data;
|
|
1597
|
+
const accessor = col.accessor;
|
|
1598
|
+
const sorted = [...data].sort((a, b) => {
|
|
1599
|
+
const r = defaultCompare(accessor(a), accessor(b));
|
|
1600
|
+
return sort.direction === "asc" ? r : -r;
|
|
1601
|
+
});
|
|
1602
|
+
return sorted;
|
|
1603
|
+
}, [data, columns, sort]);
|
|
1604
|
+
const cycleSort = (columnKey) => {
|
|
1605
|
+
if (!sort || sort.columnKey !== columnKey) {
|
|
1606
|
+
setSort({ columnKey, direction: "asc" });
|
|
1607
|
+
} else if (sort.direction === "asc") {
|
|
1608
|
+
setSort({ columnKey, direction: "desc" });
|
|
1609
|
+
} else {
|
|
1610
|
+
setSort(null);
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
const alignClass = (a) => a === "right" ? "text-right" : a === "center" ? "text-center" : "text-left";
|
|
1614
|
+
return /* @__PURE__ */ jsxs(
|
|
1615
|
+
Table,
|
|
1616
|
+
{
|
|
1617
|
+
striped,
|
|
1618
|
+
hoverable,
|
|
1619
|
+
density,
|
|
1620
|
+
bare,
|
|
1621
|
+
className,
|
|
1622
|
+
"aria-label": ariaLabel,
|
|
1623
|
+
children: [
|
|
1624
|
+
/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: columns.map((col) => {
|
|
1625
|
+
const isSorted = sort?.columnKey === col.key;
|
|
1626
|
+
const ariaSort = isSorted ? sort?.direction === "asc" ? "ascending" : "descending" : col.sortable ? "none" : void 0;
|
|
1627
|
+
return /* @__PURE__ */ jsx(
|
|
1628
|
+
TableHeaderCell,
|
|
1629
|
+
{
|
|
1630
|
+
"aria-sort": ariaSort,
|
|
1631
|
+
style: col.width ? { width: col.width } : void 0,
|
|
1632
|
+
className: alignClass(col.align),
|
|
1633
|
+
children: col.sortable ? /* @__PURE__ */ jsxs(
|
|
1634
|
+
"button",
|
|
1635
|
+
{
|
|
1636
|
+
type: "button",
|
|
1637
|
+
onClick: () => cycleSort(col.key),
|
|
1638
|
+
className: cn(
|
|
1639
|
+
"inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
1640
|
+
),
|
|
1641
|
+
children: [
|
|
1642
|
+
/* @__PURE__ */ jsx("span", { children: col.header }),
|
|
1643
|
+
isSorted ? sort?.direction === "asc" ? /* @__PURE__ */ jsx(ArrowUp, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(ArrowDown, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(ArrowUpDown, { className: "h-3.5 w-3.5 opacity-50" })
|
|
1644
|
+
]
|
|
1645
|
+
}
|
|
1646
|
+
) : col.header
|
|
1647
|
+
},
|
|
1648
|
+
col.key
|
|
1649
|
+
);
|
|
1650
|
+
}) }) }),
|
|
1651
|
+
/* @__PURE__ */ jsx(TableBody, { children: sortedData.length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: columns.length, className: "py-8 text-center text-muted-foreground", children: emptyContent }) }) : sortedData.map((row, rowIndex) => {
|
|
1652
|
+
const key = rowKey ? rowKey(row, rowIndex) : rowIndex;
|
|
1653
|
+
return /* @__PURE__ */ jsx(
|
|
1654
|
+
TableRow,
|
|
1655
|
+
{
|
|
1656
|
+
onClick: onRowClick ? () => onRowClick(row, rowIndex) : void 0,
|
|
1657
|
+
className: cn(onRowClick && "cursor-pointer"),
|
|
1658
|
+
children: columns.map((col) => /* @__PURE__ */ jsx(TableCell, { className: alignClass(col.align), children: col.cell ? col.cell(row, rowIndex) : col.accessor ? col.accessor(row) : null }, col.key))
|
|
1659
|
+
},
|
|
1660
|
+
key
|
|
1661
|
+
);
|
|
1662
|
+
}) })
|
|
1663
|
+
]
|
|
1664
|
+
}
|
|
1665
|
+
);
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Avatar, AvatarGroup, Badge, BadgeOverlay, Card, Code, Collapsible, CollapsibleContent, CollapsibleTrigger, CountBadge, DataTable, DescriptionList, EmptyState, Heading, Highlight, Image, InfoRow, Kbd, KeyboardShortcut, List, ListItem, Mark, NotificationDot, Quote, SectionHeader, Separator, Snippet, Stat, Status, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeaderCell, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Tag, Text, Timeline, TimelineDescription, TimelineItem, TimelineTitle, Tooltip, Tree, TreeGroup, TreeItem, avatarVariants, badgeVariants, codeVariants, headingVariants, tagVariants, textVariants };
|
|
1669
|
+
//# sourceMappingURL=chunk-ASXB42MH.js.map
|
|
1670
|
+
//# sourceMappingURL=chunk-ASXB42MH.js.map
|