@cognite/aura 1.47905.0 → 1.48084.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/DESIGN.md +4 -0
- package/dist/components/ui/core/accordion/accordion.gallery.d.ts +2 -0
- package/dist/components/ui/core/accordion/accordion.gallery.js +46 -0
- package/dist/components/ui/core/accordion/accordion.gallery.js.map +1 -0
- package/dist/components/ui/core/card/card.gallery.d.ts +2 -0
- package/dist/components/ui/core/card/card.gallery.js +66 -0
- package/dist/components/ui/core/card/card.gallery.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +2 -1
- package/dist/components/ui/core/data-grid/data-grid-header-row.js +3 -3
- package/dist/components/ui/core/data-grid/data-grid-header-row.js.map +1 -1
- package/dist/components/ui/core/data-grid/data-grid-row.d.ts +7 -1
- package/dist/components/ui/core/data-grid/data-grid-row.js +22 -5
- package/dist/components/ui/core/data-grid/data-grid-row.js.map +1 -1
- package/dist/components/ui/core/data-grid/data-grid.d.ts +10 -1
- package/dist/components/ui/core/data-grid/data-grid.js +11 -11
- package/dist/components/ui/core/data-grid/data-grid.js.map +1 -1
- package/dist/components/ui/core/item/item.gallery.d.ts +2 -0
- package/dist/components/ui/core/item/item.gallery.js +65 -0
- package/dist/components/ui/core/item/item.gallery.js.map +1 -0
- package/dist/components/ui/core/popover/popover.gallery.d.ts +2 -0
- package/dist/components/ui/core/popover/popover.gallery.js +46 -0
- package/dist/components/ui/core/popover/popover.gallery.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ui/core/accordion/accordion.md +52 -0
- package/src/components/ui/core/card/card.md +47 -0
- package/src/components/ui/core/item/item.md +55 -0
- package/src/components/ui/core/popover/popover.md +53 -0
package/DESIGN.md
CHANGED
|
@@ -1001,6 +1001,7 @@ When a component has a guidance file, treat it as the primary reference and its
|
|
|
1001
1001
|
|
|
1002
1002
|
**Storybook-slug:** accordion
|
|
1003
1003
|
**Docs-slug:** accordion
|
|
1004
|
+
**Full guidance:** [accordion.md](./src/components/ui/core/accordion/accordion.md)
|
|
1004
1005
|
|
|
1005
1006
|
**Definition**
|
|
1006
1007
|
Accordion reveals and hides grouped content sections to reduce cognitive load and page density.
|
|
@@ -1284,6 +1285,7 @@ Visually joins related buttons into a connected row, clarifying that the actions
|
|
|
1284
1285
|
|
|
1285
1286
|
**Storybook-slug:** card
|
|
1286
1287
|
**Docs-slug:** card
|
|
1288
|
+
**Full guidance:** [card.md](./src/components/ui/core/card/card.md)
|
|
1287
1289
|
|
|
1288
1290
|
**Definition**
|
|
1289
1291
|
A structural container with optional header, body, and footer slots for displaying data artifacts, widgets, or media. The Card with Count variant adds a numeric indicator to the header.
|
|
@@ -1707,6 +1709,7 @@ Single-line text field for capturing short text-based information in forms and t
|
|
|
1707
1709
|
|
|
1708
1710
|
**Storybook-slug:** item
|
|
1709
1711
|
**Docs-slug:** item
|
|
1712
|
+
**Full guidance:** [item.md](./src/components/ui/core/item/item.md)
|
|
1710
1713
|
|
|
1711
1714
|
**Definition**
|
|
1712
1715
|
A flexible list-row primitive for displaying a title, optional description, leading media, and trailing actions. Composes into groups for lists, trees, cards, and popovers.
|
|
@@ -1848,6 +1851,7 @@ Divides large datasets into pages, giving users control over navigation and impr
|
|
|
1848
1851
|
|
|
1849
1852
|
**Storybook-slug:** popover
|
|
1850
1853
|
**Docs-slug:** popover
|
|
1854
|
+
**Full guidance:** [popover.md](./src/components/ui/core/popover/popover.md)
|
|
1851
1855
|
|
|
1852
1856
|
**Definition**
|
|
1853
1857
|
A click-triggered panel for interactive or structured supplemental content. Stays open until dismissed.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "./accordion.js";
|
|
3
|
+
export function AccordionGallery() {
|
|
4
|
+
return /*#__PURE__*/ _jsxs(Accordion, {
|
|
5
|
+
type: "single",
|
|
6
|
+
collapsible: true,
|
|
7
|
+
className: "w-100 max-w-full",
|
|
8
|
+
children: [
|
|
9
|
+
/*#__PURE__*/ _jsxs(AccordionItem, {
|
|
10
|
+
value: "item-1",
|
|
11
|
+
children: [
|
|
12
|
+
/*#__PURE__*/ _jsx(AccordionTrigger, {
|
|
13
|
+
children: "Is it accessible?"
|
|
14
|
+
}),
|
|
15
|
+
/*#__PURE__*/ _jsx(AccordionContent, {
|
|
16
|
+
children: "Yes. It adheres to the WAI-ARIA design pattern."
|
|
17
|
+
})
|
|
18
|
+
]
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ _jsxs(AccordionItem, {
|
|
21
|
+
value: "item-2",
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsx(AccordionTrigger, {
|
|
24
|
+
children: "Is it styled?"
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ _jsx(AccordionContent, {
|
|
27
|
+
children: "Yes. It comes with default styles that match your theme."
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ _jsxs(AccordionItem, {
|
|
32
|
+
value: "item-3",
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ _jsx(AccordionTrigger, {
|
|
35
|
+
children: "Is it animated?"
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ _jsx(AccordionContent, {
|
|
38
|
+
children: "Yes. It uses smooth transitions for opening and closing."
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=accordion.gallery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/accordion/accordion.gallery.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\n\nimport {\n Accordion,\n AccordionContent,\n AccordionItem,\n AccordionTrigger,\n} from './accordion';\n\nexport function AccordionGallery(): ReactElement {\n return (\n <Accordion type=\"single\" collapsible className=\"w-100 max-w-full\">\n <AccordionItem value=\"item-1\">\n <AccordionTrigger>Is it accessible?</AccordionTrigger>\n <AccordionContent>\n Yes. It adheres to the WAI-ARIA design pattern.\n </AccordionContent>\n </AccordionItem>\n <AccordionItem value=\"item-2\">\n <AccordionTrigger>Is it styled?</AccordionTrigger>\n <AccordionContent>\n Yes. It comes with default styles that match your theme.\n </AccordionContent>\n </AccordionItem>\n <AccordionItem value=\"item-3\">\n <AccordionTrigger>Is it animated?</AccordionTrigger>\n <AccordionContent>\n Yes. It uses smooth transitions for opening and closing.\n </AccordionContent>\n </AccordionItem>\n </Accordion>\n );\n}\n"],"names":["Accordion","AccordionContent","AccordionItem","AccordionTrigger","AccordionGallery","type","collapsible","className","value"],"mappings":";AAEA,SACEA,SAAS,EACTC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,QACX,iBAAc;AAErB,OAAO,SAASC;IACd,qBACE,MAACJ;QAAUK,MAAK;QAASC,WAAW;QAACC,WAAU;;0BAC7C,MAACL;gBAAcM,OAAM;;kCACnB,KAACL;kCAAiB;;kCAClB,KAACF;kCAAiB;;;;0BAIpB,MAACC;gBAAcM,OAAM;;kCACnB,KAACL;kCAAiB;;kCAClB,KAACF;kCAAiB;;;;0BAIpB,MAACC;gBAAcM,OAAM;;kCACnB,KAACL;kCAAiB;;kCAClB,KAACF;kCAAiB;;;;;;AAM1B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconCube, IconDotsVertical } from "@tabler/icons-react";
|
|
3
|
+
import { Avatar, AvatarIcon } from "../avatar/avatar.js";
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { Card, CardContent, CardDescription, CardFooter, CardFooterEnd, CardFooterStart, CardHeader, CardHeaderCenter, CardHeaderEnd, CardHeaderStart, CardTitle } from "./card.js";
|
|
6
|
+
export function CardGallery() {
|
|
7
|
+
return /*#__PURE__*/ _jsxs(Card, {
|
|
8
|
+
className: "w-[440px] max-w-full",
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ _jsxs(CardHeader, {
|
|
11
|
+
children: [
|
|
12
|
+
/*#__PURE__*/ _jsx(CardHeaderStart, {
|
|
13
|
+
children: /*#__PURE__*/ _jsx(Avatar, {
|
|
14
|
+
variant: "overflow",
|
|
15
|
+
"aria-label": "Card leading icon",
|
|
16
|
+
className: "rounded-lg",
|
|
17
|
+
children: /*#__PURE__*/ _jsx(AvatarIcon, {
|
|
18
|
+
children: /*#__PURE__*/ _jsx(IconCube, {})
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
}),
|
|
22
|
+
/*#__PURE__*/ _jsxs(CardHeaderCenter, {
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ _jsx(CardTitle, {
|
|
25
|
+
children: "Title"
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ _jsx(CardDescription, {
|
|
28
|
+
children: "Subtitle"
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
/*#__PURE__*/ _jsx(CardHeaderEnd, {
|
|
33
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
34
|
+
variant: "ghost",
|
|
35
|
+
size: "icon-sm",
|
|
36
|
+
"aria-label": "More options",
|
|
37
|
+
children: /*#__PURE__*/ _jsx(IconDotsVertical, {
|
|
38
|
+
className: "size-4"
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ _jsx(CardContent, {
|
|
45
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
46
|
+
className: "w-full h-44 bg-muted-background rounded flex items-center justify-center text-secondary-foreground text-sm",
|
|
47
|
+
children: "Main content slot"
|
|
48
|
+
})
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ _jsxs(CardFooter, {
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ _jsx(CardFooterStart, {}),
|
|
53
|
+
/*#__PURE__*/ _jsx(CardFooterEnd, {
|
|
54
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
55
|
+
variant: "outline",
|
|
56
|
+
size: "sm",
|
|
57
|
+
children: "Button"
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=card.gallery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/card/card.gallery.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\n\nimport { IconCube, IconDotsVertical } from '@tabler/icons-react';\n\nimport { Avatar, AvatarIcon } from '../avatar/avatar';\nimport { Button } from '../button/button';\n\nimport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardFooterEnd,\n CardFooterStart,\n CardHeader,\n CardHeaderCenter,\n CardHeaderEnd,\n CardHeaderStart,\n CardTitle,\n} from './card';\n\nexport function CardGallery(): ReactElement {\n return (\n <Card className=\"w-[440px] max-w-full\">\n <CardHeader>\n <CardHeaderStart>\n <Avatar\n variant=\"overflow\"\n aria-label=\"Card leading icon\"\n className=\"rounded-lg\"\n >\n <AvatarIcon>\n <IconCube />\n </AvatarIcon>\n </Avatar>\n </CardHeaderStart>\n <CardHeaderCenter>\n <CardTitle>Title</CardTitle>\n <CardDescription>Subtitle</CardDescription>\n </CardHeaderCenter>\n <CardHeaderEnd>\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label=\"More options\">\n <IconDotsVertical className=\"size-4\" />\n </Button>\n </CardHeaderEnd>\n </CardHeader>\n <CardContent>\n <div className=\"w-full h-44 bg-muted-background rounded flex items-center justify-center text-secondary-foreground text-sm\">\n Main content slot\n </div>\n </CardContent>\n <CardFooter>\n <CardFooterStart />\n <CardFooterEnd>\n <Button variant=\"outline\" size=\"sm\">\n Button\n </Button>\n </CardFooterEnd>\n </CardFooter>\n </Card>\n );\n}\n"],"names":["IconCube","IconDotsVertical","Avatar","AvatarIcon","Button","Card","CardContent","CardDescription","CardFooter","CardFooterEnd","CardFooterStart","CardHeader","CardHeaderCenter","CardHeaderEnd","CardHeaderStart","CardTitle","CardGallery","className","variant","aria-label","size","div"],"mappings":";AAEA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,sBAAsB;AAEjE,SAASC,MAAM,EAAEC,UAAU,QAAQ,sBAAmB;AACtD,SAASC,MAAM,QAAQ,sBAAmB;AAE1C,SACEC,IAAI,EACJC,WAAW,EACXC,eAAe,EACfC,UAAU,EACVC,aAAa,EACbC,eAAe,EACfC,UAAU,EACVC,gBAAgB,EAChBC,aAAa,EACbC,eAAe,EACfC,SAAS,QACJ,YAAS;AAEhB,OAAO,SAASC;IACd,qBACE,MAACX;QAAKY,WAAU;;0BACd,MAACN;;kCACC,KAACG;kCACC,cAAA,KAACZ;4BACCgB,SAAQ;4BACRC,cAAW;4BACXF,WAAU;sCAEV,cAAA,KAACd;0CACC,cAAA,KAACH;;;;kCAIP,MAACY;;0CACC,KAACG;0CAAU;;0CACX,KAACR;0CAAgB;;;;kCAEnB,KAACM;kCACC,cAAA,KAACT;4BAAOc,SAAQ;4BAAQE,MAAK;4BAAUD,cAAW;sCAChD,cAAA,KAAClB;gCAAiBgB,WAAU;;;;;;0BAIlC,KAACX;0BACC,cAAA,KAACe;oBAAIJ,WAAU;8BAA6G;;;0BAI9H,MAACT;;kCACC,KAACE;kCACD,KAACD;kCACC,cAAA,KAACL;4BAAOc,SAAQ;4BAAUE,MAAK;sCAAK;;;;;;;AAO9C"}
|
|
@@ -7,6 +7,7 @@ type DataGridHeaderRowProps<TData> = {
|
|
|
7
7
|
pinnedColumnIds: Set<string>;
|
|
8
8
|
lastPinnedColumnId: string | undefined;
|
|
9
9
|
isResizingColumn: boolean;
|
|
10
|
+
emphasizeHeader?: boolean;
|
|
10
11
|
};
|
|
11
|
-
declare function DataGridHeaderRow<TData>({ headerGroup, headerRowIndex, resolvedHeaderHeight, pinnedColumnIds, lastPinnedColumnId, isResizingColumn }: DataGridHeaderRowProps<TData>): ReactElement;
|
|
12
|
+
declare function DataGridHeaderRow<TData>({ headerGroup, headerRowIndex, resolvedHeaderHeight, pinnedColumnIds, lastPinnedColumnId, isResizingColumn, emphasizeHeader }: DataGridHeaderRowProps<TData>): ReactElement;
|
|
12
13
|
export { DataGridHeaderRow, type DataGridHeaderRowProps };
|
|
@@ -5,14 +5,14 @@ import { flexRender } from "@tanstack/react-table";
|
|
|
5
5
|
import { cn, focusState } from "../../../../lib/utils.js";
|
|
6
6
|
import { DataGridColumnResizer } from "./data-grid-column-resizer.js";
|
|
7
7
|
import { PINNED_COLUMN_Z_INDEX, getAriaSort } from "./data-grid.utils.js";
|
|
8
|
-
function DataGridHeaderRow({ headerGroup, headerRowIndex, resolvedHeaderHeight, pinnedColumnIds, lastPinnedColumnId, isResizingColumn }) {
|
|
8
|
+
function DataGridHeaderRow({ headerGroup, headerRowIndex, resolvedHeaderHeight, pinnedColumnIds, lastPinnedColumnId, isResizingColumn, emphasizeHeader = false }) {
|
|
9
9
|
const headerRowInstanceId = useId();
|
|
10
10
|
return /*#__PURE__*/ _jsx("div", {
|
|
11
11
|
"data-slot": "data-grid-header-row",
|
|
12
12
|
role: "row",
|
|
13
13
|
"aria-rowindex": headerRowIndex + 1,
|
|
14
14
|
className: cn(// z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the header row.
|
|
15
|
-
'sticky z-[20] grid bg-background', headerRowIndex === 0 ? 'border-y' : 'border-b'),
|
|
15
|
+
'sticky z-[20] grid bg-base-background', headerRowIndex === 0 ? 'border-y' : 'border-b'),
|
|
16
16
|
style: {
|
|
17
17
|
top: headerRowIndex * resolvedHeaderHeight,
|
|
18
18
|
gridTemplateColumns: 'var(--data-grid-template-columns)',
|
|
@@ -37,7 +37,7 @@ function DataGridHeaderRow({ headerGroup, headerRowIndex, resolvedHeaderHeight,
|
|
|
37
37
|
"aria-colspan": header.colSpan > 1 ? header.colSpan : undefined,
|
|
38
38
|
"aria-sort": getAriaSort(sortDirection, canSort),
|
|
39
39
|
"aria-labelledby": showResizer ? headerTitleId : undefined,
|
|
40
|
-
className: cn('group/header relative flex min-w-0 items-center overflow-hidden pr-3 text-left text-sm font-medium text-muted-foreground', header.index === 0 ? 'pl-4' : 'pl-3', isGroupedHeader && 'justify-center text-base font-semibold text-foreground/70', header.isPlaceholder && 'pointer-events-none', isPinned && 'sticky left-0 z-10 bg-background', isLastPinned && 'shadow-pinned-column', (canSort || showResizer) && !isResizingColumn && 'hover:bg-medium-background-hover', isResizing && 'bg-medium-background-hover'),
|
|
40
|
+
className: cn('group/header relative flex min-w-0 items-center overflow-hidden pr-3 text-left text-sm', emphasizeHeader ? 'font-semibold text-foreground' : 'font-medium text-muted-foreground', header.index === 0 ? 'pl-4' : 'pl-3', isGroupedHeader && 'justify-center text-base font-semibold text-foreground/70', header.isPlaceholder && 'pointer-events-none', isPinned && 'sticky left-0 z-10 bg-base-background', isLastPinned && 'shadow-pinned-column', (canSort || showResizer) && !isResizingColumn && 'hover:bg-medium-background-hover', isResizing && 'bg-medium-background-hover'),
|
|
41
41
|
style: {
|
|
42
42
|
gridColumn: `span ${header.colSpan} / span ${header.colSpan}`,
|
|
43
43
|
...isPinned ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-header-row.tsx"],"sourcesContent":["import { type ReactElement, useId } from 'react';\n\nimport { IconArrowDown, IconSelector } from '@tabler/icons-react';\nimport { type HeaderGroup, flexRender } from '@tanstack/react-table';\n\nimport { cn, focusState } from '../../../../lib/utils';\n\nimport { DataGridColumnResizer } from './data-grid-column-resizer';\nimport { PINNED_COLUMN_Z_INDEX, getAriaSort } from './data-grid.utils';\n\ntype DataGridHeaderRowProps<TData> = {\n headerGroup: HeaderGroup<TData>;\n headerRowIndex: number;\n resolvedHeaderHeight: number;\n pinnedColumnIds: Set<string>;\n lastPinnedColumnId: string | undefined;\n isResizingColumn: boolean;\n};\n\nfunction DataGridHeaderRow<TData>({\n headerGroup,\n headerRowIndex,\n resolvedHeaderHeight,\n pinnedColumnIds,\n lastPinnedColumnId,\n isResizingColumn,\n}: DataGridHeaderRowProps<TData>): ReactElement {\n const headerRowInstanceId = useId();\n\n return (\n <div\n data-slot=\"data-grid-header-row\"\n role=\"row\"\n aria-rowindex={headerRowIndex + 1}\n className={cn(\n // z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the header row.\n 'sticky z-[20] grid bg-background',\n headerRowIndex === 0 ? 'border-y' : 'border-b'\n )}\n style={{\n top: headerRowIndex * resolvedHeaderHeight,\n gridTemplateColumns: 'var(--data-grid-template-columns)',\n minHeight: resolvedHeaderHeight,\n }}\n >\n {headerGroup.headers.map((header) => {\n const isLeafHeader = header.colSpan === 1;\n const isPinned = isLeafHeader && pinnedColumnIds.has(header.column.id);\n const isLastPinned =\n isPinned && lastPinnedColumnId === header.column.id;\n const sortDirection = header.column.getIsSorted();\n const canSort = isLeafHeader && header.column.getCanSort();\n const isGroupedHeader = header.colSpan > 1;\n const renderedHeader = header.isPlaceholder\n ? null\n : flexRender(header.column.columnDef.header, header.getContext());\n const isPlainTextHeader =\n typeof renderedHeader === 'string' ||\n typeof renderedHeader === 'number';\n const showResizer = isLeafHeader && header.column.getCanResize();\n const isResizing = showResizer && header.column.getIsResizing();\n const headerTitleId = `${headerRowInstanceId}-${header.id}-title`;\n\n return (\n <div\n key={header.id}\n data-slot=\"data-grid-column-header\"\n role=\"columnheader\"\n aria-colindex={header.index + 1}\n aria-colspan={header.colSpan > 1 ? header.colSpan : undefined}\n aria-sort={getAriaSort(sortDirection, canSort)}\n aria-labelledby={showResizer ? headerTitleId : undefined}\n className={cn(\n 'group/header relative flex min-w-0 items-center overflow-hidden pr-3 text-left text-sm font-medium text-muted-foreground',\n header.index === 0 ? 'pl-4' : 'pl-3',\n isGroupedHeader &&\n 'justify-center text-base font-semibold text-foreground/70',\n header.isPlaceholder && 'pointer-events-none',\n isPinned && 'sticky left-0 z-10 bg-background',\n isLastPinned && 'shadow-pinned-column',\n (canSort || showResizer) &&\n !isResizingColumn &&\n 'hover:bg-medium-background-hover',\n isResizing && 'bg-medium-background-hover'\n )}\n style={{\n gridColumn: `span ${header.colSpan} / span ${header.colSpan}`,\n ...(isPinned\n ? {\n position: 'sticky',\n left: header.column.getStart('left'),\n zIndex: PINNED_COLUMN_Z_INDEX,\n }\n : {}),\n }}\n >\n <div\n id={showResizer ? headerTitleId : undefined}\n className=\"flex min-w-0 items-center\"\n >\n {canSort ? (\n <button\n type=\"button\"\n className={cn(\n 'group/sort inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-sm select-none',\n focusState\n )}\n onClick={header.column.getToggleSortingHandler()}\n >\n {isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">\n {renderedHeader}\n </span>\n ) : (\n renderedHeader\n )}\n {sortDirection ? (\n <IconArrowDown\n aria-hidden=\"true\"\n className={cn(\n 'size-3.5 shrink-0',\n sortDirection === 'asc' && 'rotate-180'\n )}\n />\n ) : (\n <IconSelector\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 opacity-30 group-hover/header:opacity-100 group-focus-visible/sort:opacity-100\"\n />\n )}\n </button>\n ) : isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">{renderedHeader}</span>\n ) : (\n renderedHeader\n )}\n </div>\n {showResizer && (\n <DataGridColumnResizer\n header={header}\n columnLabel={\n isPlainTextHeader ? String(renderedHeader) : header.column.id\n }\n />\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport { DataGridHeaderRow, type DataGridHeaderRowProps };\n"],"names":["useId","IconArrowDown","IconSelector","flexRender","cn","focusState","DataGridColumnResizer","PINNED_COLUMN_Z_INDEX","getAriaSort","DataGridHeaderRow","headerGroup","headerRowIndex","resolvedHeaderHeight","pinnedColumnIds","lastPinnedColumnId","isResizingColumn","headerRowInstanceId","div","data-slot","role","aria-rowindex","className","style","top","gridTemplateColumns","minHeight","headers","map","header","isLeafHeader","colSpan","isPinned","has","column","id","isLastPinned","sortDirection","getIsSorted","canSort","getCanSort","isGroupedHeader","renderedHeader","isPlaceholder","columnDef","getContext","isPlainTextHeader","showResizer","getCanResize","isResizing","getIsResizing","headerTitleId","aria-colindex","index","aria-colspan","undefined","aria-sort","aria-labelledby","gridColumn","position","left","getStart","zIndex","button","type","onClick","getToggleSortingHandler","span","aria-hidden","columnLabel","String"],"mappings":";AAAA,SAA4BA,KAAK,QAAQ,QAAQ;AAEjD,SAASC,aAAa,EAAEC,YAAY,QAAQ,sBAAsB;AAClE,SAA2BC,UAAU,QAAQ,wBAAwB;AAErE,SAASC,EAAE,EAAEC,UAAU,QAAQ,2BAAwB;AAEvD,SAASC,qBAAqB,QAAQ,gCAA6B;AACnE,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,uBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-header-row.tsx"],"sourcesContent":["import { type ReactElement, useId } from 'react';\n\nimport { IconArrowDown, IconSelector } from '@tabler/icons-react';\nimport { type HeaderGroup, flexRender } from '@tanstack/react-table';\n\nimport { cn, focusState } from '../../../../lib/utils';\n\nimport { DataGridColumnResizer } from './data-grid-column-resizer';\nimport { PINNED_COLUMN_Z_INDEX, getAriaSort } from './data-grid.utils';\n\ntype DataGridHeaderRowProps<TData> = {\n headerGroup: HeaderGroup<TData>;\n headerRowIndex: number;\n resolvedHeaderHeight: number;\n pinnedColumnIds: Set<string>;\n lastPinnedColumnId: string | undefined;\n isResizingColumn: boolean;\n emphasizeHeader?: boolean;\n};\n\nfunction DataGridHeaderRow<TData>({\n headerGroup,\n headerRowIndex,\n resolvedHeaderHeight,\n pinnedColumnIds,\n lastPinnedColumnId,\n isResizingColumn,\n emphasizeHeader = false,\n}: DataGridHeaderRowProps<TData>): ReactElement {\n const headerRowInstanceId = useId();\n\n return (\n <div\n data-slot=\"data-grid-header-row\"\n role=\"row\"\n aria-rowindex={headerRowIndex + 1}\n className={cn(\n // z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the header row.\n 'sticky z-[20] grid bg-base-background',\n headerRowIndex === 0 ? 'border-y' : 'border-b'\n )}\n style={{\n top: headerRowIndex * resolvedHeaderHeight,\n gridTemplateColumns: 'var(--data-grid-template-columns)',\n minHeight: resolvedHeaderHeight,\n }}\n >\n {headerGroup.headers.map((header) => {\n const isLeafHeader = header.colSpan === 1;\n const isPinned = isLeafHeader && pinnedColumnIds.has(header.column.id);\n const isLastPinned =\n isPinned && lastPinnedColumnId === header.column.id;\n const sortDirection = header.column.getIsSorted();\n const canSort = isLeafHeader && header.column.getCanSort();\n const isGroupedHeader = header.colSpan > 1;\n const renderedHeader = header.isPlaceholder\n ? null\n : flexRender(header.column.columnDef.header, header.getContext());\n const isPlainTextHeader =\n typeof renderedHeader === 'string' ||\n typeof renderedHeader === 'number';\n const showResizer = isLeafHeader && header.column.getCanResize();\n const isResizing = showResizer && header.column.getIsResizing();\n const headerTitleId = `${headerRowInstanceId}-${header.id}-title`;\n\n return (\n <div\n key={header.id}\n data-slot=\"data-grid-column-header\"\n role=\"columnheader\"\n aria-colindex={header.index + 1}\n aria-colspan={header.colSpan > 1 ? header.colSpan : undefined}\n aria-sort={getAriaSort(sortDirection, canSort)}\n aria-labelledby={showResizer ? headerTitleId : undefined}\n className={cn(\n 'group/header relative flex min-w-0 items-center overflow-hidden pr-3 text-left text-sm',\n emphasizeHeader\n ? 'font-semibold text-foreground'\n : 'font-medium text-muted-foreground',\n header.index === 0 ? 'pl-4' : 'pl-3',\n isGroupedHeader &&\n 'justify-center text-base font-semibold text-foreground/70',\n header.isPlaceholder && 'pointer-events-none',\n isPinned && 'sticky left-0 z-10 bg-base-background',\n isLastPinned && 'shadow-pinned-column',\n (canSort || showResizer) &&\n !isResizingColumn &&\n 'hover:bg-medium-background-hover',\n isResizing && 'bg-medium-background-hover'\n )}\n style={{\n gridColumn: `span ${header.colSpan} / span ${header.colSpan}`,\n ...(isPinned\n ? {\n position: 'sticky',\n left: header.column.getStart('left'),\n zIndex: PINNED_COLUMN_Z_INDEX,\n }\n : {}),\n }}\n >\n <div\n id={showResizer ? headerTitleId : undefined}\n className=\"flex min-w-0 items-center\"\n >\n {canSort ? (\n <button\n type=\"button\"\n className={cn(\n 'group/sort inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-sm select-none',\n focusState\n )}\n onClick={header.column.getToggleSortingHandler()}\n >\n {isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">\n {renderedHeader}\n </span>\n ) : (\n renderedHeader\n )}\n {sortDirection ? (\n <IconArrowDown\n aria-hidden=\"true\"\n className={cn(\n 'size-3.5 shrink-0',\n sortDirection === 'asc' && 'rotate-180'\n )}\n />\n ) : (\n <IconSelector\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 opacity-30 group-hover/header:opacity-100 group-focus-visible/sort:opacity-100\"\n />\n )}\n </button>\n ) : isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">{renderedHeader}</span>\n ) : (\n renderedHeader\n )}\n </div>\n {showResizer && (\n <DataGridColumnResizer\n header={header}\n columnLabel={\n isPlainTextHeader ? String(renderedHeader) : header.column.id\n }\n />\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport { DataGridHeaderRow, type DataGridHeaderRowProps };\n"],"names":["useId","IconArrowDown","IconSelector","flexRender","cn","focusState","DataGridColumnResizer","PINNED_COLUMN_Z_INDEX","getAriaSort","DataGridHeaderRow","headerGroup","headerRowIndex","resolvedHeaderHeight","pinnedColumnIds","lastPinnedColumnId","isResizingColumn","emphasizeHeader","headerRowInstanceId","div","data-slot","role","aria-rowindex","className","style","top","gridTemplateColumns","minHeight","headers","map","header","isLeafHeader","colSpan","isPinned","has","column","id","isLastPinned","sortDirection","getIsSorted","canSort","getCanSort","isGroupedHeader","renderedHeader","isPlaceholder","columnDef","getContext","isPlainTextHeader","showResizer","getCanResize","isResizing","getIsResizing","headerTitleId","aria-colindex","index","aria-colspan","undefined","aria-sort","aria-labelledby","gridColumn","position","left","getStart","zIndex","button","type","onClick","getToggleSortingHandler","span","aria-hidden","columnLabel","String"],"mappings":";AAAA,SAA4BA,KAAK,QAAQ,QAAQ;AAEjD,SAASC,aAAa,EAAEC,YAAY,QAAQ,sBAAsB;AAClE,SAA2BC,UAAU,QAAQ,wBAAwB;AAErE,SAASC,EAAE,EAAEC,UAAU,QAAQ,2BAAwB;AAEvD,SAASC,qBAAqB,QAAQ,gCAA6B;AACnE,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,uBAAoB;AAYvE,SAASC,kBAAyB,EAChCC,WAAW,EACXC,cAAc,EACdC,oBAAoB,EACpBC,eAAe,EACfC,kBAAkB,EAClBC,gBAAgB,EAChBC,kBAAkB,KAAK,EACO;IAC9B,MAAMC,sBAAsBjB;IAE5B,qBACE,KAACkB;QACCC,aAAU;QACVC,MAAK;QACLC,iBAAeV,iBAAiB;QAChCW,WAAWlB,GACT,4FAA4F;QAC5F,yCACAO,mBAAmB,IAAI,aAAa;QAEtCY,OAAO;YACLC,KAAKb,iBAAiBC;YACtBa,qBAAqB;YACrBC,WAAWd;QACb;kBAECF,YAAYiB,OAAO,CAACC,GAAG,CAAC,CAACC;YACxB,MAAMC,eAAeD,OAAOE,OAAO,KAAK;YACxC,MAAMC,WAAWF,gBAAgBjB,gBAAgBoB,GAAG,CAACJ,OAAOK,MAAM,CAACC,EAAE;YACrE,MAAMC,eACJJ,YAAYlB,uBAAuBe,OAAOK,MAAM,CAACC,EAAE;YACrD,MAAME,gBAAgBR,OAAOK,MAAM,CAACI,WAAW;YAC/C,MAAMC,UAAUT,gBAAgBD,OAAOK,MAAM,CAACM,UAAU;YACxD,MAAMC,kBAAkBZ,OAAOE,OA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AuB;;gCAE7CpB,kCACC,KAACqB;oCAAK7C,WAAU;8CACboB;qCAGHA;gCAEDL,8BACC,KAACpC;oCACCmE,eAAY;oCACZ9C,WAAWlB,GACT,qBACAiC,kBAAkB,SAAS;mDAI/B,KAACnC;oCACCkE,eAAY;oCACZ9C,WAAU;;;6BAIdwB,kCACF,KAACqB;4BAAK7C,WAAU;sCAA0BoB;6BAE1CA;;oBAGHK,6BACC,KAACzC;wBACCuB,QAAQA;wBACRwC,aACEvB,oBAAoBwB,OAAO5B,kBAAkBb,OAAOK,MAAM,CAACC,EAAE;;;eA/E9DN,OAAOM,EAAE;QAqFpB;;AAGN;AAEA,SAAS1B,iBAAiB,GAAgC"}
|
|
@@ -9,7 +9,13 @@ type DataGridRowProps<TData> = {
|
|
|
9
9
|
lastPinnedColumnId: string | undefined;
|
|
10
10
|
maxDepth: number;
|
|
11
11
|
hasExpanding: boolean;
|
|
12
|
+
striped?: boolean;
|
|
13
|
+
wrapCells?: boolean;
|
|
14
|
+
/** The grid's base row height; wrapped rows never shrink below it. */
|
|
15
|
+
minRowHeight?: number;
|
|
16
|
+
/** The virtualizer's `measureElement`, set when rows size to their content. */
|
|
17
|
+
measureElement?: (element: HTMLDivElement | null) => void;
|
|
12
18
|
onRowClick?: (row: Row<TData>) => void;
|
|
13
19
|
};
|
|
14
|
-
declare function DataGridRow<TData>({ row, virtualRow, headerGroupCount, pinnedColumnIds, lastPinnedColumnId, maxDepth, hasExpanding, onRowClick }: DataGridRowProps<TData>): ReactElement;
|
|
20
|
+
declare function DataGridRow<TData>({ row, virtualRow, headerGroupCount, pinnedColumnIds, lastPinnedColumnId, maxDepth, hasExpanding, striped, wrapCells, minRowHeight, measureElement, onRowClick }: DataGridRowProps<TData>): ReactElement;
|
|
15
21
|
export { DataGridRow, type DataGridRowProps };
|
|
@@ -6,10 +6,15 @@ import { Button } from "../button/button.js";
|
|
|
6
6
|
import { DataGridCell } from "./data-grid-cell.js";
|
|
7
7
|
import { isDataGridRowHighlighted } from "./data-grid-selection-state.js";
|
|
8
8
|
import { PINNED_COLUMN_Z_INDEX, getTextValue, isAccessorColumn, isFromExpandToggleTarget, isFromIgnoredCellTarget } from "./data-grid.utils.js";
|
|
9
|
-
function DataGridRow({ row, virtualRow, headerGroupCount, pinnedColumnIds, lastPinnedColumnId, maxDepth, hasExpanding, onRowClick }) {
|
|
9
|
+
function DataGridRow({ row, virtualRow, headerGroupCount, pinnedColumnIds, lastPinnedColumnId, maxDepth, hasExpanding, striped = false, wrapCells = false, minRowHeight, measureElement, onRowClick }) {
|
|
10
10
|
const canExpand = row.getCanExpand();
|
|
11
11
|
const isRowInteractive = onRowClick !== undefined;
|
|
12
12
|
const isHighlighted = isDataGridRowHighlighted(row);
|
|
13
|
+
// Rows are virtualized and absolutely positioned, so DOM order doesn't match
|
|
14
|
+
// table order and `even:` selectors can't be used; stripe by the row's index instead.
|
|
15
|
+
const isStripedRow = striped && virtualRow.index % 2 === 1;
|
|
16
|
+
// A hover shade on read-only striped rows reads as another stripe, so only clickable rows get one.
|
|
17
|
+
const showHover = !striped || isRowInteractive;
|
|
13
18
|
const handleRowActivation = isRowInteractive ? (triggerTarget)=>{
|
|
14
19
|
if (isFromIgnoredCellTarget(triggerTarget)) return;
|
|
15
20
|
if (isFromExpandToggleTarget(triggerTarget)) return;
|
|
@@ -19,15 +24,24 @@ function DataGridRow({ row, virtualRow, headerGroupCount, pinnedColumnIds, lastP
|
|
|
19
24
|
const resolvedTreeColumnIndex = visibleCells.findIndex((cell)=>isAccessorColumn(cell.column.columnDef));
|
|
20
25
|
const treeColumnIndex = resolvedTreeColumnIndex >= 0 ? resolvedTreeColumnIndex : 0;
|
|
21
26
|
return /*#__PURE__*/ _jsx("div", {
|
|
27
|
+
ref: measureElement,
|
|
28
|
+
"data-index": virtualRow.index,
|
|
22
29
|
"data-slot": "data-grid-row",
|
|
23
30
|
role: "row",
|
|
24
31
|
"aria-rowindex": virtualRow.index + 1 + headerGroupCount,
|
|
25
32
|
"aria-expanded": canExpand ? row.getIsExpanded() : undefined,
|
|
26
33
|
"aria-selected": row.getIsSelected() ? true : undefined,
|
|
27
|
-
className: cn('group absolute left-0 right-0 grid border-b bg-background transition-colors', '
|
|
34
|
+
className: cn('group absolute left-0 right-0 grid border-b bg-base-background transition-colors', isStripedRow && 'bg-muted-background', isHighlighted && 'bg-medium-background', showHover && (isHighlighted ? 'hover:bg-medium-background-hover' : 'hover:bg-active-muted-background'), isRowInteractive && cn('cursor-pointer focus-visible:bg-active-muted-background', focusState)),
|
|
28
35
|
style: {
|
|
29
36
|
gridTemplateColumns: 'var(--data-grid-template-columns)',
|
|
30
|
-
|
|
37
|
+
// Wrapped rows are measured, so they must be free to grow and shrink with their content.
|
|
38
|
+
// `virtualRow.size` is the last measured height, so using it as the minimum would stop
|
|
39
|
+
// rows from shrinking back, e.g. after a column is widened.
|
|
40
|
+
...wrapCells ? {
|
|
41
|
+
minHeight: minRowHeight
|
|
42
|
+
} : {
|
|
43
|
+
height: virtualRow.size
|
|
44
|
+
},
|
|
31
45
|
transform: `translateY(${virtualRow.start}px)`
|
|
32
46
|
},
|
|
33
47
|
tabIndex: isRowInteractive ? 0 : undefined,
|
|
@@ -75,6 +89,8 @@ function DataGridRow({ row, virtualRow, headerGroupCount, pinnedColumnIds, lastP
|
|
|
75
89
|
isPinned: isPinned,
|
|
76
90
|
isLastPinned: isLastPinned,
|
|
77
91
|
colIndex: cellIndex + 1,
|
|
92
|
+
// Top-aligned with vertical padding, a single line keeps the default row height.
|
|
93
|
+
className: wrapCells ? 'items-start py-2' : undefined,
|
|
78
94
|
style: cellStyle,
|
|
79
95
|
children: [
|
|
80
96
|
showChevron && /*#__PURE__*/ _jsx(Button, {
|
|
@@ -99,8 +115,9 @@ function DataGridRow({ row, virtualRow, headerGroupCount, pinnedColumnIds, lastP
|
|
|
99
115
|
"aria-hidden": "true"
|
|
100
116
|
}),
|
|
101
117
|
/*#__PURE__*/ _jsx("span", {
|
|
102
|
-
className:
|
|
103
|
-
|
|
118
|
+
className: cn('block min-w-0 flex-1', wrapCells ? 'wrap-break-word' : 'not-has-[*]:truncate'),
|
|
119
|
+
// Wrapped content is shown in full, so a tooltip would only repeat it.
|
|
120
|
+
title: wrapCells ? undefined : cellTitle,
|
|
104
121
|
children: renderedCell
|
|
105
122
|
})
|
|
106
123
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-row.tsx"],"sourcesContent":["import type {\n CSSProperties,\n KeyboardEvent,\n MouseEvent,\n ReactElement,\n ReactNode,\n} from 'react';\n\nimport { IconChevronRight } from '@tabler/icons-react';\nimport { type Cell, type Row, flexRender } from '@tanstack/react-table';\nimport type { VirtualItem } from '@tanstack/react-virtual';\n\nimport { cn, focusState } from '../../../../lib/utils';\nimport { Button } from '../button/button';\n\nimport { DataGridCell } from './data-grid-cell';\nimport { isDataGridRowHighlighted } from './data-grid-selection-state';\nimport {\n PINNED_COLUMN_Z_INDEX,\n getTextValue,\n isAccessorColumn,\n isFromExpandToggleTarget,\n isFromIgnoredCellTarget,\n} from './data-grid.utils';\n\ntype DataGridRowProps<TData> = {\n row: Row<TData>;\n virtualRow: VirtualItem;\n headerGroupCount: number;\n pinnedColumnIds: Set<string>;\n lastPinnedColumnId: string | undefined;\n maxDepth: number;\n hasExpanding: boolean;\n onRowClick?: (row: Row<TData>) => void;\n};\n\nfunction DataGridRow<TData>({\n row,\n virtualRow,\n headerGroupCount,\n pinnedColumnIds,\n lastPinnedColumnId,\n maxDepth,\n hasExpanding,\n onRowClick,\n}: DataGridRowProps<TData>): ReactElement {\n const canExpand = row.getCanExpand();\n const isRowInteractive = onRowClick !== undefined;\n const isHighlighted = isDataGridRowHighlighted(row);\n\n const handleRowActivation = isRowInteractive\n ? (triggerTarget?: EventTarget | null) => {\n if (isFromIgnoredCellTarget(triggerTarget)) return;\n if (isFromExpandToggleTarget(triggerTarget)) return;\n onRowClick?.(row);\n }\n : undefined;\n\n const visibleCells = row.getVisibleCells();\n const resolvedTreeColumnIndex = visibleCells.findIndex((cell) =>\n isAccessorColumn(cell.column.columnDef)\n );\n const treeColumnIndex =\n resolvedTreeColumnIndex >= 0 ? resolvedTreeColumnIndex : 0;\n\n return (\n <div\n data-slot=\"data-grid-row\"\n role=\"row\"\n aria-rowindex={virtualRow.index + 1 + headerGroupCount}\n aria-expanded={canExpand ? row.getIsExpanded() : undefined}\n aria-selected={row.getIsSelected() ? true : undefined}\n className={cn(\n 'group absolute left-0 right-0 grid border-b bg-background transition-colors',\n 'hover:bg-active-muted-background',\n isHighlighted &&\n 'bg-medium-background hover:bg-medium-background-hover',\n isRowInteractive &&\n cn(\n 'cursor-pointer focus-visible:bg-active-muted-background',\n focusState\n )\n )}\n style={{\n gridTemplateColumns: 'var(--data-grid-template-columns)',\n height: virtualRow.size,\n transform: `translateY(${virtualRow.start}px)`,\n }}\n tabIndex={isRowInteractive ? 0 : undefined}\n onClick={\n handleRowActivation\n ? (event: MouseEvent<HTMLDivElement>) =>\n handleRowActivation(event.target)\n : undefined\n }\n onKeyDown={\n handleRowActivation\n ? (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (isFromIgnoredCellTarget(event.target)) return;\n if (isFromExpandToggleTarget(event.target)) return;\n event.preventDefault();\n handleRowActivation(event.target);\n }\n : undefined\n }\n >\n {visibleCells.map((cell: Cell<TData, unknown>, cellIndex: number) => {\n const isPinned = pinnedColumnIds.has(cell.column.id);\n const isLastPinned = isPinned && lastPinnedColumnId === cell.column.id;\n const cellContext = cell.getContext();\n const cellRenderer = cell.column.columnDef.cell;\n let renderedCell: ReactNode;\n let cellTitle: string | undefined;\n\n if (typeof cellRenderer === 'function') {\n const cellContent = cellRenderer(cellContext);\n cellTitle = getTextValue(cellContent);\n renderedCell = cellContent;\n } else {\n renderedCell = flexRender(cellRenderer, cellContext);\n cellTitle = getTextValue(renderedCell);\n }\n\n const isTreeColumn = cellIndex === treeColumnIndex;\n const depth = Math.min(row.depth, maxDepth);\n const indentPx = isTreeColumn && depth > 0 ? depth * 16 : 0;\n const showChevron = isTreeColumn && canExpand;\n const showChevronSpacer =\n isTreeColumn && hasExpanding && !canExpand && depth > 0;\n\n const pinnedStyle: CSSProperties | undefined = isPinned\n ? {\n position: 'sticky',\n left: cell.column.getStart('left'),\n zIndex: PINNED_COLUMN_Z_INDEX,\n }\n : undefined;\n\n const cellStyle: CSSProperties | undefined =\n indentPx > 0 || pinnedStyle\n ? {\n ...pinnedStyle,\n ...(indentPx > 0\n ? { paddingInlineStart: `${indentPx + 12}px` }\n : {}),\n }\n : undefined;\n\n return (\n <DataGridCell\n key={cell.id}\n data-row-activation={\n isAccessorColumn(cell.column.columnDef) ? undefined : 'ignore'\n }\n isPinned={isPinned}\n isLastPinned={isLastPinned}\n colIndex={cellIndex + 1}\n style={cellStyle}\n >\n {showChevron && (\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className=\"mr-2\"\n data-row-expand-toggle=\"true\"\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n row.toggleExpanded();\n }}\n aria-label={row.getIsExpanded() ? 'Collapse row' : 'Expand row'}\n >\n <IconChevronRight\n width={5}\n height={8}\n className={cn(row.getIsExpanded() && 'rotate-90')}\n aria-hidden=\"true\"\n />\n </Button>\n )}\n {showChevronSpacer && (\n <span\n className=\"mr-2 inline-block h-7 w-7 shrink-0\"\n aria-hidden=\"true\"\n />\n )}\n <span\n className=\"block min-w-0 flex-1 not-has-[*]:truncate\"\n title={cellTitle}\n >\n {renderedCell}\n </span>\n </DataGridCell>\n );\n })}\n </div>\n );\n}\n\nexport { DataGridRow, type DataGridRowProps };\n"],"names":["IconChevronRight","flexRender","cn","focusState","Button","DataGridCell","isDataGridRowHighlighted","PINNED_COLUMN_Z_INDEX","getTextValue","isAccessorColumn","isFromExpandToggleTarget","isFromIgnoredCellTarget","DataGridRow","row","virtualRow","headerGroupCount","pinnedColumnIds","lastPinnedColumnId","maxDepth","hasExpanding","onRowClick","canExpand","getCanExpand","isRowInteractive","undefined","isHighlighted","handleRowActivation","triggerTarget","visibleCells","getVisibleCells","resolvedTreeColumnIndex","findIndex","cell","column","columnDef","treeColumnIndex","div","data-slot","role","aria-rowindex","index","aria-expanded","getIsExpanded","aria-selected","getIsSelected","className","style","gridTemplateColumns","height","size","transform","start","tabIndex","onClick","event","target","onKeyDown","key","preventDefault","map","cellIndex","isPinned","has","id","isLastPinned","cellContext","getContext","cellRenderer","renderedCell","cellTitle","cellContent","isTreeColumn","depth","Math","min","indentPx","showChevron","showChevronSpacer","pinnedStyle","position","left","getStart","zIndex","cellStyle","paddingInlineStart","data-row-activation","colIndex","variant","data-row-expand-toggle","stopPropagation","toggleExpanded","aria-label","width","aria-hidden","span","title"],"mappings":";AAQA,SAASA,gBAAgB,QAAQ,sBAAsB;AACvD,SAA8BC,UAAU,QAAQ,wBAAwB;AAGxE,SAASC,EAAE,EAAEC,UAAU,QAAQ,2BAAwB;AACvD,SAASC,MAAM,QAAQ,sBAAmB;AAE1C,SAASC,YAAY,QAAQ,sBAAmB;AAChD,SAASC,wBAAwB,QAAQ,iCAA8B;AACvE,SACEC,qBAAqB,EACrBC,YAAY,EACZC,gBAAgB,EAChBC,wBAAwB,EACxBC,uBAAuB,QAClB,uBAAoB;AAa3B,SAASC,YAAmB,EAC1BC,GAAG,EACHC,UAAU,EACVC,gBAAgB,EAChBC,eAAe,EACfC,kBAAkB,EAClBC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACc;IACxB,MAAMC,YAAYR,IAAIS,YAAY;IAClC,MAAMC,mBAAmBH,eAAeI;IACxC,MAAMC,gBAAgBnB,yBAAyBO;IAE/C,MAAMa,sBAAsBH,mBACxB,CAACI;QACC,IAAIhB,wBAAwBgB,gBAAgB;QAC5C,IAAIjB,yBAAyBiB,gBAAgB;QAC7CP,aAAaP;IACf,IACAW;IAEJ,MAAMI,eAAef,IAAIgB,eAAe;IACxC,MAAMC,0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ND;;;eAvCEpC,KAAK+B,EAAE;QA2ClB;;AAGN;AAEA,SAASnD,WAAW,GAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-row.tsx"],"sourcesContent":["import type {\n CSSProperties,\n KeyboardEvent,\n MouseEvent,\n ReactElement,\n ReactNode,\n} from 'react';\n\nimport { IconChevronRight } from '@tabler/icons-react';\nimport { type Cell, type Row, flexRender } from '@tanstack/react-table';\nimport type { VirtualItem } from '@tanstack/react-virtual';\n\nimport { cn, focusState } from '../../../../lib/utils';\nimport { Button } from '../button/button';\n\nimport { DataGridCell } from './data-grid-cell';\nimport { isDataGridRowHighlighted } from './data-grid-selection-state';\nimport {\n PINNED_COLUMN_Z_INDEX,\n getTextValue,\n isAccessorColumn,\n isFromExpandToggleTarget,\n isFromIgnoredCellTarget,\n} from './data-grid.utils';\n\ntype DataGridRowProps<TData> = {\n row: Row<TData>;\n virtualRow: VirtualItem;\n headerGroupCount: number;\n pinnedColumnIds: Set<string>;\n lastPinnedColumnId: string | undefined;\n maxDepth: number;\n hasExpanding: boolean;\n striped?: boolean;\n wrapCells?: boolean;\n /** The grid's base row height; wrapped rows never shrink below it. */\n minRowHeight?: number;\n /** The virtualizer's `measureElement`, set when rows size to their content. */\n measureElement?: (element: HTMLDivElement | null) => void;\n onRowClick?: (row: Row<TData>) => void;\n};\n\nfunction DataGridRow<TData>({\n row,\n virtualRow,\n headerGroupCount,\n pinnedColumnIds,\n lastPinnedColumnId,\n maxDepth,\n hasExpanding,\n striped = false,\n wrapCells = false,\n minRowHeight,\n measureElement,\n onRowClick,\n}: DataGridRowProps<TData>): ReactElement {\n const canExpand = row.getCanExpand();\n const isRowInteractive = onRowClick !== undefined;\n const isHighlighted = isDataGridRowHighlighted(row);\n // Rows are virtualized and absolutely positioned, so DOM order doesn't match\n // table order and `even:` selectors can't be used; stripe by the row's index instead.\n const isStripedRow = striped && virtualRow.index % 2 === 1;\n // A hover shade on read-only striped rows reads as another stripe, so only clickable rows get one.\n const showHover = !striped || isRowInteractive;\n\n const handleRowActivation = isRowInteractive\n ? (triggerTarget?: EventTarget | null) => {\n if (isFromIgnoredCellTarget(triggerTarget)) return;\n if (isFromExpandToggleTarget(triggerTarget)) return;\n onRowClick?.(row);\n }\n : undefined;\n\n const visibleCells = row.getVisibleCells();\n const resolvedTreeColumnIndex = visibleCells.findIndex((cell) =>\n isAccessorColumn(cell.column.columnDef)\n );\n const treeColumnIndex =\n resolvedTreeColumnIndex >= 0 ? resolvedTreeColumnIndex : 0;\n\n return (\n <div\n ref={measureElement}\n data-index={virtualRow.index}\n data-slot=\"data-grid-row\"\n role=\"row\"\n aria-rowindex={virtualRow.index + 1 + headerGroupCount}\n aria-expanded={canExpand ? row.getIsExpanded() : undefined}\n aria-selected={row.getIsSelected() ? true : undefined}\n className={cn(\n 'group absolute left-0 right-0 grid border-b bg-base-background transition-colors',\n isStripedRow && 'bg-muted-background',\n isHighlighted && 'bg-medium-background',\n showHover &&\n (isHighlighted\n ? 'hover:bg-medium-background-hover'\n : 'hover:bg-active-muted-background'),\n isRowInteractive &&\n cn(\n 'cursor-pointer focus-visible:bg-active-muted-background',\n focusState\n )\n )}\n style={{\n gridTemplateColumns: 'var(--data-grid-template-columns)',\n // Wrapped rows are measured, so they must be free to grow and shrink with their content.\n // `virtualRow.size` is the last measured height, so using it as the minimum would stop\n // rows from shrinking back, e.g. after a column is widened.\n ...(wrapCells\n ? { minHeight: minRowHeight }\n : { height: virtualRow.size }),\n transform: `translateY(${virtualRow.start}px)`,\n }}\n tabIndex={isRowInteractive ? 0 : undefined}\n onClick={\n handleRowActivation\n ? (event: MouseEvent<HTMLDivElement>) =>\n handleRowActivation(event.target)\n : undefined\n }\n onKeyDown={\n handleRowActivation\n ? (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n if (isFromIgnoredCellTarget(event.target)) return;\n if (isFromExpandToggleTarget(event.target)) return;\n event.preventDefault();\n handleRowActivation(event.target);\n }\n : undefined\n }\n >\n {visibleCells.map((cell: Cell<TData, unknown>, cellIndex: number) => {\n const isPinned = pinnedColumnIds.has(cell.column.id);\n const isLastPinned = isPinned && lastPinnedColumnId === cell.column.id;\n const cellContext = cell.getContext();\n const cellRenderer = cell.column.columnDef.cell;\n let renderedCell: ReactNode;\n let cellTitle: string | undefined;\n\n if (typeof cellRenderer === 'function') {\n const cellContent = cellRenderer(cellContext);\n cellTitle = getTextValue(cellContent);\n renderedCell = cellContent;\n } else {\n renderedCell = flexRender(cellRenderer, cellContext);\n cellTitle = getTextValue(renderedCell);\n }\n\n const isTreeColumn = cellIndex === treeColumnIndex;\n const depth = Math.min(row.depth, maxDepth);\n const indentPx = isTreeColumn && depth > 0 ? depth * 16 : 0;\n const showChevron = isTreeColumn && canExpand;\n const showChevronSpacer =\n isTreeColumn && hasExpanding && !canExpand && depth > 0;\n\n const pinnedStyle: CSSProperties | undefined = isPinned\n ? {\n position: 'sticky',\n left: cell.column.getStart('left'),\n zIndex: PINNED_COLUMN_Z_INDEX,\n }\n : undefined;\n\n const cellStyle: CSSProperties | undefined =\n indentPx > 0 || pinnedStyle\n ? {\n ...pinnedStyle,\n ...(indentPx > 0\n ? { paddingInlineStart: `${indentPx + 12}px` }\n : {}),\n }\n : undefined;\n\n return (\n <DataGridCell\n key={cell.id}\n data-row-activation={\n isAccessorColumn(cell.column.columnDef) ? undefined : 'ignore'\n }\n isPinned={isPinned}\n isLastPinned={isLastPinned}\n colIndex={cellIndex + 1}\n // Top-aligned with vertical padding, a single line keeps the default row height.\n className={wrapCells ? 'items-start py-2' : undefined}\n style={cellStyle}\n >\n {showChevron && (\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className=\"mr-2\"\n data-row-expand-toggle=\"true\"\n onClick={(event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n row.toggleExpanded();\n }}\n aria-label={row.getIsExpanded() ? 'Collapse row' : 'Expand row'}\n >\n <IconChevronRight\n width={5}\n height={8}\n className={cn(row.getIsExpanded() && 'rotate-90')}\n aria-hidden=\"true\"\n />\n </Button>\n )}\n {showChevronSpacer && (\n <span\n className=\"mr-2 inline-block h-7 w-7 shrink-0\"\n aria-hidden=\"true\"\n />\n )}\n <span\n className={cn(\n 'block min-w-0 flex-1',\n wrapCells ? 'wrap-break-word' : 'not-has-[*]:truncate'\n )}\n // Wrapped content is shown in full, so a tooltip would only repeat it.\n title={wrapCells ? undefined : cellTitle}\n >\n {renderedCell}\n </span>\n </DataGridCell>\n );\n })}\n </div>\n );\n}\n\nexport { DataGridRow, type DataGridRowProps };\n"],"names":["IconChevronRight","flexRender","cn","focusState","Button","DataGridCell","isDataGridRowHighlighted","PINNED_COLUMN_Z_INDEX","getTextValue","isAccessorColumn","isFromExpandToggleTarget","isFromIgnoredCellTarget","DataGridRow","row","virtualRow","headerGroupCount","pinnedColumnIds","lastPinnedColumnId","maxDepth","hasExpanding","striped","wrapCells","minRowHeight","measureElement","onRowClick","canExpand","getCanExpand","isRowInteractive","undefined","isHighlighted","isStripedRow","index","showHover","handleRowActivation","triggerTarget","visibleCells","getVisibleCells","resolvedTreeColumnIndex","findIndex","cell","column","columnDef","treeColumnIndex","div","ref","data-index","data-slot","role","aria-rowindex","aria-expanded","getIsExpanded","aria-selected","getIsSelected","className","style","gridTemplateColumns","minHeight","height","size","transform","start","tabIndex","onClick","event","target","onKeyDown","key","preventDefault","map","cellIndex","isPinned","has","id","isLastPinned","cellContext","getContext","cellRenderer","renderedCell","cellTitle","cellContent","isTreeColumn","depth","Math","min","indentPx","showChevron","showChevronSpacer","pinnedStyle","position","left","getStart","zIndex","cellStyle","paddingInlineStart","data-row-activation","colIndex","variant","data-row-expand-toggle","stopPropagation","toggleExpanded","aria-label","width","aria-hidden","span","title"],"mappings":";AAQA,SAASA,gBAAgB,QAAQ,sBAAsB;AACvD,SAA8BC,UAAU,QAAQ,wBAAwB;AAGxE,SAASC,EAAE,EAAEC,UAAU,QAAQ,2BAAwB;AACv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aseProps<TData> = {
|
|
|
72
72
|
onExpandedChange?: (value: ExpandedState) => void;
|
|
73
73
|
getRowCanExpand?: (row: Row<TData>) => boolean;
|
|
74
74
|
maxDepth?: number;
|
|
75
|
+
/** Shades every other row to help scan long, read-only tables. */
|
|
76
|
+
striped?: boolean;
|
|
77
|
+
/** Shows column titles semibold in the primary text color instead of muted. */
|
|
78
|
+
emphasizeHeader?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Wraps long cell content onto multiple lines instead of truncating it.
|
|
81
|
+
* Rows grow to fit their content, with `rowHeight` as the minimum height.
|
|
82
|
+
*/
|
|
83
|
+
wrapCells?: boolean;
|
|
75
84
|
pinnedColumns?: string[];
|
|
76
85
|
gridRef?: RefObject<DataGridHandle | null>;
|
|
77
86
|
size?: DataGridSize;
|
|
@@ -104,7 +113,7 @@ type DataGridAccessibleNameProps = {
|
|
|
104
113
|
"aria-label"?: string;
|
|
105
114
|
};
|
|
106
115
|
type DataGridProps<TData> = DataGridBaseProps<TData> & DataGridAccessibleNameProps;
|
|
107
|
-
declare function DataGrid<TData>({ data, columns, getRowId, rowCount, globalFilterFn, enableRowSelection, enableSorting, enableColumnResizing, columnGrow, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination, manualSorting, rowSelection, defaultRowSelection, onRowSelectionChange, selectionActions, sorting, defaultSorting, onSortingChange, columnFilters, defaultColumnFilters, onColumnFiltersChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth, pinnedColumns, gridRef, size, children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode, loading, loadingVariant, loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: DataGridProps<TData>): ReactElement;
|
|
116
|
+
declare function DataGrid<TData>({ data, columns, getRowId, rowCount, globalFilterFn, enableRowSelection, enableSorting, enableColumnResizing, columnGrow, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination, manualSorting, rowSelection, defaultRowSelection, onRowSelectionChange, selectionActions, sorting, defaultSorting, onSortingChange, columnFilters, defaultColumnFilters, onColumnFiltersChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth, striped, emphasizeHeader, wrapCells, pinnedColumns, gridRef, size, children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode, loading, loadingVariant, loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: DataGridProps<TData>): ReactElement;
|
|
108
117
|
declare function DataGridCheckboxHeader<TData>({ table }: {
|
|
109
118
|
table: Table<TData>;
|
|
110
119
|
}): ReactElement;
|
|
@@ -19,13 +19,8 @@ import { DataGridSelectionToolbar } from "./data-grid-selection-toolbar.js";
|
|
|
19
19
|
import { PINNED_COLUMN_Z_INDEX, getTextValue } from "./data-grid.utils.js";
|
|
20
20
|
const EMPTY_PINNED_COLUMNS = [];
|
|
21
21
|
function defaultDataGridCell({ renderValue }) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return /*#__PURE__*/ _jsx("span", {
|
|
25
|
-
className: "block min-w-0 truncate",
|
|
26
|
-
title: text,
|
|
27
|
-
children: text
|
|
28
|
-
});
|
|
22
|
+
// Plain text so the row's cell wrapper can truncate or wrap it and add the title.
|
|
23
|
+
return getTextValue(renderValue()) ?? null;
|
|
29
24
|
}
|
|
30
25
|
const DEFAULT_COLUMN = {
|
|
31
26
|
cell: defaultDataGridCell,
|
|
@@ -44,7 +39,7 @@ const HEADER_HEIGHT_MAP = {
|
|
|
44
39
|
default: 36,
|
|
45
40
|
compact: 32
|
|
46
41
|
};
|
|
47
|
-
function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto', enableRowSelection = false, enableSorting = false, enableColumnResizing = false, columnGrow = false, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination = false, manualSorting = false, rowSelection, defaultRowSelection, onRowSelectionChange, selectionActions, sorting, defaultSorting, onSortingChange, columnFilters, defaultColumnFilters, onColumnFiltersChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth = 5, pinnedColumns = EMPTY_PINNED_COLUMNS, gridRef, size = 'default', children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode = 'client', loading = false, loadingVariant = 'skeleton', loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }) {
|
|
42
|
+
function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto', enableRowSelection = false, enableSorting = false, enableColumnResizing = false, columnGrow = false, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination = false, manualSorting = false, rowSelection, defaultRowSelection, onRowSelectionChange, selectionActions, sorting, defaultSorting, onSortingChange, columnFilters, defaultColumnFilters, onColumnFiltersChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth = 5, striped = false, emphasizeHeader = false, wrapCells = false, pinnedColumns = EMPTY_PINNED_COLUMNS, gridRef, size = 'default', children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode = 'client', loading = false, loadingVariant = 'skeleton', loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }) {
|
|
48
43
|
const scrollContainerRef = useRef(null);
|
|
49
44
|
const labels = {
|
|
50
45
|
...defaultDataGridLabels,
|
|
@@ -262,7 +257,8 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
|
|
|
262
257
|
resolvedHeaderHeight: resolvedHeaderHeight,
|
|
263
258
|
pinnedColumnIds: pinnedColumnIds,
|
|
264
259
|
lastPinnedColumnId: lastPinnedColumnId,
|
|
265
|
-
isResizingColumn: isResizingColumn
|
|
260
|
+
isResizingColumn: isResizingColumn,
|
|
261
|
+
emphasizeHeader: emphasizeHeader
|
|
266
262
|
}, headerGroup.id))
|
|
267
263
|
}),
|
|
268
264
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -276,7 +272,7 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
|
|
|
276
272
|
}, (_, rowIndex)=>/*#__PURE__*/ _jsx("div", {
|
|
277
273
|
"data-slot": "data-grid-row-loading",
|
|
278
274
|
"aria-hidden": "true",
|
|
279
|
-
className: "absolute left-0 right-0 grid border-b bg-background",
|
|
275
|
+
className: "absolute left-0 right-0 grid border-b bg-base-background",
|
|
280
276
|
style: {
|
|
281
277
|
gridTemplateColumns: 'var(--data-grid-template-columns)',
|
|
282
278
|
height: resolvedRowHeight,
|
|
@@ -315,6 +311,10 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
|
|
|
315
311
|
lastPinnedColumnId: lastPinnedColumnId,
|
|
316
312
|
maxDepth: maxDepth,
|
|
317
313
|
hasExpanding: hasExpanding,
|
|
314
|
+
striped: striped,
|
|
315
|
+
wrapCells: wrapCells,
|
|
316
|
+
minRowHeight: resolvedRowHeight,
|
|
317
|
+
measureElement: wrapCells ? virtualizer.measureElement : undefined,
|
|
318
318
|
onRowClick: onRowClick
|
|
319
319
|
}, rows[virtualRow.index].id)),
|
|
320
320
|
!loading && hasNoRows && emptyState != null && /*#__PURE__*/ _jsx("div", {
|
|
@@ -331,7 +331,7 @@ function DataGrid({ data, columns, getRowId, rowCount, globalFilterFn = 'auto',
|
|
|
331
331
|
!loading && hasNoResults && /*#__PURE__*/ _jsx("div", {
|
|
332
332
|
className: "pt-2",
|
|
333
333
|
children: /*#__PURE__*/ _jsx("div", {
|
|
334
|
-
className: "flex items-center justify-center bg-background",
|
|
334
|
+
className: "flex items-center justify-center bg-base-background",
|
|
335
335
|
children: renderDataGridState(noResultsState, {
|
|
336
336
|
type: 'no-results',
|
|
337
337
|
title: 'No results found',
|