@bsol-oss/react-datatable5 3.4.3 → 5.0.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 +1 -1
- package/dist/index.d.ts +12 -17
- package/dist/index.js +265 -117
- package/dist/index.mjs +217 -87
- package/dist/types/components/Controls/EditFilterButton.d.ts +1 -1
- package/dist/types/components/DataTable/DefaultTable.d.ts +2 -2
- package/dist/types/components/DataTable/Table.d.ts +4 -3
- package/dist/types/components/DataTable/TableComponent.d.ts +1 -1
- package/dist/types/components/DataTable/TableHeader.d.ts +2 -2
- package/dist/types/components/DataTable/TablePagination.d.ts +1 -3
- package/dist/types/components/DataTable/TextCell.d.ts +2 -3
- package/dist/types/components/Filter/GlobalFilter.d.ts +1 -3
- package/dist/types/components/ui/avatar.d.ts +17 -0
- package/dist/types/components/ui/button.d.ts +10 -0
- package/dist/types/components/ui/checkbox.d.ts +8 -0
- package/dist/types/components/ui/close-button.d.ts +4 -0
- package/dist/types/components/ui/color-mode.d.ts +17 -0
- package/dist/types/components/ui/dialog.d.ts +19 -0
- package/dist/types/components/ui/drawer.d.ts +19 -0
- package/dist/types/components/ui/empty-state.d.ts +8 -0
- package/dist/types/components/ui/field.d.ts +9 -0
- package/dist/types/components/ui/input-group.d.ts +12 -0
- package/dist/types/components/ui/menu.d.ts +24 -0
- package/dist/types/components/ui/popover.d.ts +17 -0
- package/dist/types/components/ui/provider.d.ts +2 -0
- package/dist/types/components/ui/radio.d.ts +8 -0
- package/dist/types/components/ui/select.d.ts +25 -0
- package/dist/types/components/ui/slider.d.ts +11 -0
- package/dist/types/components/ui/switch.d.ts +15 -0
- package/dist/types/components/ui/tag.d.ts +9 -0
- package/dist/types/components/ui/tooltip.d.ts +11 -0
- package/package.json +11 -10
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { IconButton, Button,
|
|
2
|
+
import { IconButton, Button as Button$1, Portal, Dialog, useDisclosure, Flex, DialogRoot as DialogRoot$1, DialogBackdrop, DialogTrigger as DialogTrigger$1, DialogContent as DialogContent$1, DialogCloseTrigger as DialogCloseTrigger$1, DialogHeader as DialogHeader$1, DialogTitle as DialogTitle$1, DialogBody as DialogBody$1, DialogFooter as DialogFooter$1, Text, Menu, AbsoluteCenter, Tag as Tag$1, Grid, Image, Checkbox as Checkbox$1, Table as Table$1, Box, Tooltip as Tooltip$1, Spinner, Icon, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Span, EmptyState as EmptyState$1, VStack, List, Card, Input, Slider as Slider$1, HStack, For, RadioGroup as RadioGroup$1, Group, Switch as Switch$1, InputElement } from '@chakra-ui/react';
|
|
3
3
|
import { AiOutlineColumnWidth } from 'react-icons/ai';
|
|
4
4
|
import { MdFilterAlt, MdOutlineMoveDown, MdOutlineSort, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdClear, MdArrowUpward, MdArrowDownward, MdFirstPage, MdArrowBack, MdArrowForward, MdLastPage, MdOutlineChecklist, MdClose, MdSearch } from 'react-icons/md';
|
|
5
|
-
import
|
|
5
|
+
import * as React from 'react';
|
|
6
6
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
7
|
+
import { LuX, LuCheck, LuChevronRight } from 'react-icons/lu';
|
|
8
|
+
import { UpDownIcon, ChevronDownIcon, ChevronUpIcon, CloseIcon } from '@chakra-ui/icons';
|
|
7
9
|
import { IoMdEye, IoMdCheckbox } from 'react-icons/io';
|
|
8
10
|
import { makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, flexRender } from '@tanstack/react-table';
|
|
9
11
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
10
|
-
import { Tbody, Tr, Td } from '@chakra-ui/table';
|
|
11
12
|
import { BsExclamationCircleFill } from 'react-icons/bs';
|
|
12
13
|
import { GrAscend, GrDescend } from 'react-icons/gr';
|
|
13
14
|
import { IoReload } from 'react-icons/io5';
|
|
15
|
+
import { HiColorSwatch } from 'react-icons/hi';
|
|
16
|
+
import { CgClose } from 'react-icons/cg';
|
|
14
17
|
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
15
18
|
import { FaGripLinesVertical } from 'react-icons/fa';
|
|
16
19
|
import axios from 'axios';
|
|
@@ -19,19 +22,39 @@ const DensityToggleButton = ({ text, icon = jsx(AiOutlineColumnWidth, {}), }) =>
|
|
|
19
22
|
const { table } = useDataTableContext();
|
|
20
23
|
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { variant: "ghost", "aria-label": "Toggle Density", icon: icon, onClick: () => {
|
|
21
24
|
table.toggleDensity();
|
|
22
|
-
} })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", "aria-label": "Toggle Density", onClick: () => {
|
|
25
|
+
} })), !!text !== false && (jsx(Button$1, { leftIcon: icon, variant: "ghost", "aria-label": "Toggle Density", onClick: () => {
|
|
23
26
|
table.toggleDensity();
|
|
24
27
|
}, children: text }))] }));
|
|
25
28
|
};
|
|
26
29
|
|
|
27
|
-
const
|
|
30
|
+
const CloseButton = React.forwardRef(function CloseButton(props, ref) {
|
|
31
|
+
return (jsx(IconButton, { variant: "ghost", "aria-label": "Close", ref: ref, ...props, children: props.children ?? jsx(LuX, {}) }));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const DialogContent = React.forwardRef(function DialogContent(props, ref) {
|
|
35
|
+
const { children, portalled = true, portalRef, backdrop = true, ...rest } = props;
|
|
36
|
+
return (jsxs(Portal, { disabled: !portalled, container: portalRef, children: [backdrop && jsx(Dialog.Backdrop, {}), jsx(Dialog.Positioner, { children: jsx(Dialog.Content, { ref: ref, ...rest, asChild: false, children: children }) })] }));
|
|
37
|
+
});
|
|
38
|
+
const DialogCloseTrigger = React.forwardRef(function DialogCloseTrigger(props, ref) {
|
|
39
|
+
return (jsx(Dialog.CloseTrigger, { position: "absolute", top: "2", insetEnd: "2", ...props, asChild: true, children: jsx(CloseButton, { size: "sm", ref: ref, children: props.children }) }));
|
|
40
|
+
});
|
|
41
|
+
const DialogRoot = Dialog.Root;
|
|
42
|
+
const DialogFooter = Dialog.Footer;
|
|
43
|
+
const DialogHeader = Dialog.Header;
|
|
44
|
+
const DialogBody = Dialog.Body;
|
|
45
|
+
Dialog.Backdrop;
|
|
46
|
+
const DialogTitle = Dialog.Title;
|
|
47
|
+
Dialog.Description;
|
|
48
|
+
const DialogTrigger = Dialog.Trigger;
|
|
49
|
+
const DialogActionTrigger = Dialog.ActionTrigger;
|
|
50
|
+
|
|
51
|
+
const EditFilterButton = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsx(MdFilterAlt, {}), }) => {
|
|
28
52
|
const filterModal = useDisclosure();
|
|
29
|
-
return (
|
|
53
|
+
return (jsx(Fragment, { children: jsx(DialogRoot, { size: ["full", "full", "md", "md"], children: jsxs(DialogRoot, { children: [jsx(DialogTrigger, { asChild: true, children: jsxs(Button$1, { variant: "outline", children: [icon, " ", text] }) }), jsxs(DialogContent, { children: [jsx(DialogHeader, { children: jsx(DialogTitle, { children: title }) }), jsx(DialogBody, { children: jsxs(Flex, { flexFlow: "column", gap: "1rem", children: [jsx(TableFilter, {}), jsx(ResetFilteringButton, { text: resetText })] }) }), jsxs(DialogFooter, { children: [jsx(DialogActionTrigger, { asChild: true, children: jsx(Button$1, { onClick: filterModal.onClose, children: closeText }) }), jsx(Button$1, { children: "Save" })] }), jsx(DialogCloseTrigger, {})] })] }) }) }));
|
|
30
54
|
};
|
|
31
55
|
|
|
32
56
|
const EditOrderButton = ({ text, icon = jsx(MdOutlineMoveDown, {}), title = "Change Order", }) => {
|
|
33
|
-
|
|
34
|
-
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { icon: icon, variant: "ghost", onClick: orderModal.onOpen, "aria-label": "change order" })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", onClick: orderModal.onOpen, children: text })), jsxs(Modal, { isOpen: orderModal.isOpen, onClose: orderModal.onClose, size: ["full", "full", "md", "md"], children: [jsx(ModalOverlay, {}), jsxs(ModalContent, { padding: "0 0 1rem 0", children: [jsx(ModalHeader, { children: title }), jsx(ModalCloseButton, {}), jsx(ModalBody, { children: jsx(Flex, { flexFlow: "column", gap: "0.25rem", children: jsx(TableOrderer, {}) }) })] })] })] }));
|
|
57
|
+
return (jsx(Fragment, { children: jsxs(DialogRoot$1, { size: "cover", children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger$1, { asChild: true, children: jsxs(Button$1, { variant: "ghost", children: [icon, text] }) }), jsxs(DialogContent$1, { children: [jsx(DialogCloseTrigger$1, {}), jsxs(DialogHeader$1, { children: [jsx(DialogTitle$1, {}), title] }), jsx(DialogBody$1, { children: jsx(Flex, { flexFlow: "column", gap: "0.25rem", children: jsx(TableOrderer, {}) }) }), jsx(DialogFooter$1, {})] })] }) }));
|
|
35
58
|
};
|
|
36
59
|
|
|
37
60
|
const TableContext = createContext({
|
|
@@ -61,9 +84,9 @@ const TableSorter = () => {
|
|
|
61
84
|
const displayName = header.column.columnDef.meta === undefined
|
|
62
85
|
? header.column.id
|
|
63
86
|
: header.column.columnDef.meta.displayName;
|
|
64
|
-
return (jsx(Fragment, { children: header.column.getCanSort() && (jsxs(Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsx(Text, { children: displayName }), jsxs(Button, { variant: "ghost", onClick: () => {
|
|
87
|
+
return (jsx(Fragment, { children: header.column.getCanSort() && (jsxs(Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsx(Text, { children: displayName }), jsxs(Button$1, { variant: "ghost", onClick: () => {
|
|
65
88
|
header.column.toggleSorting();
|
|
66
|
-
}, children: [header.column.getIsSorted() === false && jsx(UpDownIcon, {}), header.column.getIsSorted() === "asc" && (jsx(ChevronDownIcon, {})), header.column.getIsSorted() === "desc" && (jsx(ChevronUpIcon, {}))] }), header.column.getIsSorted() && (jsx(Button, { onClick: () => {
|
|
89
|
+
}, children: [header.column.getIsSorted() === false && jsx(UpDownIcon, {}), header.column.getIsSorted() === "asc" && (jsx(ChevronDownIcon, {})), header.column.getIsSorted() === "desc" && (jsx(ChevronUpIcon, {}))] }), header.column.getIsSorted() && (jsx(Button$1, { onClick: () => {
|
|
67
90
|
header.column.clearSorting();
|
|
68
91
|
}, children: jsx(CloseIcon, {}) }))] })) }));
|
|
69
92
|
}) }))) }));
|
|
@@ -71,38 +94,69 @@ const TableSorter = () => {
|
|
|
71
94
|
|
|
72
95
|
const EditSortingButton = ({ text, icon = jsx(MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
73
96
|
const sortingModal = useDisclosure();
|
|
74
|
-
return (
|
|
97
|
+
return (jsx(Fragment, { children: jsxs(DialogRoot, { size: ["full", "full", "md", "md"], children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { children: jsxs(Button$1, { variant: "ghost", onClick: sortingModal.onOpen, children: [icon, " ", text] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsxs(DialogHeader, { children: [jsx(DialogTitle, {}), title] }), jsx(DialogBody, { children: jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(TableSorter, {}), jsx(ResetSortingButton, {})] }) }), jsx(DialogFooter, {})] })] }) }));
|
|
75
98
|
};
|
|
76
99
|
|
|
77
100
|
const EditViewButton = ({ text, icon = jsx(IoMdEye, {}), title = "Edit View", }) => {
|
|
78
101
|
const viewModel = useDisclosure();
|
|
79
|
-
return (
|
|
102
|
+
return (jsx(Fragment, { children: jsxs(DialogRoot, { children: [jsx(DialogBackdrop, {}), jsx(DialogTrigger, { children: jsxs(Button$1, { variant: "ghost", onClick: viewModel.onOpen, children: [icon, " ", text] }) }), jsxs(DialogContent, { children: [jsx(DialogCloseTrigger, {}), jsxs(DialogHeader, { children: [jsx(DialogTitle, {}), title] }), jsx(DialogBody, { children: jsx(TableViewer, {}) }), jsx(DialogFooter, {})] })] }) }));
|
|
80
103
|
};
|
|
81
104
|
|
|
105
|
+
const MenuContent = React.forwardRef(function MenuContent(props, ref) {
|
|
106
|
+
const { portalled = true, portalRef, ...rest } = props;
|
|
107
|
+
return (jsx(Portal, { disabled: !portalled, container: portalRef, children: jsx(Menu.Positioner, { children: jsx(Menu.Content, { ref: ref, ...rest }) }) }));
|
|
108
|
+
});
|
|
109
|
+
React.forwardRef(function MenuArrow(props, ref) {
|
|
110
|
+
return (jsx(Menu.Arrow, { ref: ref, ...props, children: jsx(Menu.ArrowTip, {}) }));
|
|
111
|
+
});
|
|
112
|
+
React.forwardRef(function MenuCheckboxItem(props, ref) {
|
|
113
|
+
return (jsxs(Menu.CheckboxItem, { ref: ref, ...props, children: [jsx(Menu.ItemIndicator, { hidden: false, children: jsx(LuCheck, {}) }), props.children] }));
|
|
114
|
+
});
|
|
115
|
+
React.forwardRef(function MenuRadioItem(props, ref) {
|
|
116
|
+
const { children, ...rest } = props;
|
|
117
|
+
return (jsxs(Menu.RadioItem, { ps: "8", ref: ref, ...rest, children: [jsx(AbsoluteCenter, { axis: "horizontal", left: "4", asChild: true, children: jsx(Menu.ItemIndicator, { children: jsx(LuCheck, {}) }) }), jsx(Menu.ItemText, { children: children })] }));
|
|
118
|
+
});
|
|
119
|
+
React.forwardRef(function MenuItemGroup(props, ref) {
|
|
120
|
+
const { title, children, ...rest } = props;
|
|
121
|
+
return (jsxs(Menu.ItemGroup, { ref: ref, ...rest, children: [title && (jsx(Menu.ItemGroupLabel, { userSelect: "none", children: title })), children] }));
|
|
122
|
+
});
|
|
123
|
+
React.forwardRef(function MenuTriggerItem(props, ref) {
|
|
124
|
+
const { startIcon, children, ...rest } = props;
|
|
125
|
+
return (jsxs(Menu.TriggerItem, { ref: ref, ...rest, children: [startIcon, children, jsx(LuChevronRight, {})] }));
|
|
126
|
+
});
|
|
127
|
+
Menu.RadioItemGroup;
|
|
128
|
+
Menu.ContextTrigger;
|
|
129
|
+
const MenuRoot = Menu.Root;
|
|
130
|
+
Menu.Separator;
|
|
131
|
+
const MenuItem = Menu.Item;
|
|
132
|
+
Menu.ItemText;
|
|
133
|
+
Menu.ItemCommand;
|
|
134
|
+
const MenuTrigger = Menu.Trigger;
|
|
135
|
+
|
|
82
136
|
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
83
137
|
const { table } = useDataTableContext();
|
|
84
|
-
return (jsx(Fragment, { children: jsxs(
|
|
138
|
+
return (jsx(Fragment, { children: jsxs(MenuRoot, { children: [jsx(MenuTrigger, { asChild: true, children: jsxs(Button$1, { variant: "ghost", gap: "0.5rem", children: [table.getState().pagination.pageSize, " ", jsx(ChevronDownIcon, {})] }) }), jsx(MenuContent, { children: pageSizes.map((pageSize) => (jsx(MenuItem, { value: `chakra-table-pageSize-${pageSize}`, onClick: () => {
|
|
85
139
|
table.setPageSize(Number(pageSize));
|
|
86
|
-
}, children: pageSize }
|
|
140
|
+
}, children: pageSize }))) })] }) }));
|
|
87
141
|
};
|
|
88
142
|
|
|
89
143
|
const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
90
144
|
const { table } = useDataTableContext();
|
|
91
|
-
return (jsx(Button, { onClick: () => {
|
|
145
|
+
return (jsx(Button$1, { onClick: () => {
|
|
92
146
|
table.resetColumnFilters();
|
|
93
147
|
}, children: text }));
|
|
94
148
|
};
|
|
95
149
|
|
|
96
150
|
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
97
151
|
const { table } = useDataTableContext();
|
|
98
|
-
return (jsx(Button, { onClick: () => {
|
|
152
|
+
return (jsx(Button$1, { onClick: () => {
|
|
99
153
|
table.resetRowSelection();
|
|
100
154
|
}, children: text }));
|
|
101
155
|
};
|
|
102
156
|
|
|
103
157
|
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
104
158
|
const { table } = useDataTableContext();
|
|
105
|
-
return (jsx(Button, { onClick: () => {
|
|
159
|
+
return (jsx(Button$1, { onClick: () => {
|
|
106
160
|
table.resetSorting();
|
|
107
161
|
}, children: text }));
|
|
108
162
|
};
|
|
@@ -328,6 +382,11 @@ const DataTableServer = ({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
328
382
|
}, children: children }));
|
|
329
383
|
};
|
|
330
384
|
|
|
385
|
+
const Tag = React.forwardRef(function Tag(props, ref) {
|
|
386
|
+
const { startElement, endElement, onClose, closable = !!onClose, children, ...rest } = props;
|
|
387
|
+
return (jsxs(Tag$1.Root, { ref: ref, ...rest, children: [startElement && (jsx(Tag$1.StartElement, { children: startElement })), jsx(Tag$1.Label, { children: children }), endElement && (jsx(Tag$1.EndElement, { children: endElement })), closable && (jsx(Tag$1.EndElement, { children: jsx(Tag$1.CloseTrigger, { onClick: onClose }) }))] }));
|
|
388
|
+
});
|
|
389
|
+
|
|
331
390
|
const DefaultCard = ({ row, imageColumnId = undefined, titleColumnId = undefined, tagColumnId = undefined, tagIcon = undefined, showTag = true, }) => {
|
|
332
391
|
if (!!row.original === false) {
|
|
333
392
|
return jsx(Fragment, {});
|
|
@@ -341,9 +400,14 @@ const DefaultCard = ({ row, imageColumnId = undefined, titleColumnId = undefined
|
|
|
341
400
|
// const tagIdExists = Object.keys(row.original).some((key) => {
|
|
342
401
|
// return key === tagColumnId;
|
|
343
402
|
// });
|
|
344
|
-
return (jsxs(Grid, { templateRows: "auto auto", gap: "1rem", children: [jsx(Flex, { justifyContent: "center", alignItems: "center", children: jsx(Image, { src: row.original[imageColumnId] }) }), jsxs(Flex, { gap: "0.5rem", flexFlow: "wrap", children: [jsx(Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] }), showTag && (
|
|
403
|
+
return (jsxs(Grid, { templateRows: "auto auto", gap: "1rem", children: [jsx(Flex, { justifyContent: "center", alignItems: "center", children: jsx(Image, { src: row.original[imageColumnId] }) }), jsxs(Flex, { gap: "0.5rem", flexFlow: "wrap", children: [jsx(Text, { fontWeight: "bold", fontSize: "large", children: row.original[titleColumnId] }), showTag && (jsx(Tag, { fontSize: "large", startElement: tagIcon && tagIcon({}), children: row.original[tagColumnId] }))] })] }));
|
|
345
404
|
};
|
|
346
405
|
|
|
406
|
+
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
407
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
408
|
+
return (jsxs(Checkbox$1.Root, { ref: rootRef, ...rest, children: [jsx(Checkbox$1.HiddenInput, { ref: ref, ...inputProps }), jsx(Checkbox$1.Control, { children: icon || jsx(Checkbox$1.Indicator, {}) }), children != null && (jsx(Checkbox$1.Label, { children: children }))] }));
|
|
409
|
+
});
|
|
410
|
+
|
|
347
411
|
const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
|
|
348
412
|
const { table } = useContext(TableContext);
|
|
349
413
|
const SELECTION_BOX_WIDTH = 20;
|
|
@@ -356,10 +420,10 @@ const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, sho
|
|
|
356
420
|
? {
|
|
357
421
|
left: showSelector
|
|
358
422
|
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
359
|
-
: `${cell.column.getStart("left")
|
|
423
|
+
: `${cell.column.getStart("left")}px`,
|
|
360
424
|
background: pinnedBgColor.light,
|
|
361
425
|
position: "sticky",
|
|
362
|
-
zIndex: 1,
|
|
426
|
+
zIndex: -1,
|
|
363
427
|
_dark: {
|
|
364
428
|
backgroundColor: pinnedBgColor.dark,
|
|
365
429
|
},
|
|
@@ -367,9 +431,9 @@ const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, sho
|
|
|
367
431
|
: {};
|
|
368
432
|
return tdProps;
|
|
369
433
|
};
|
|
370
|
-
return (jsx(
|
|
371
|
-
return (jsxs(
|
|
372
|
-
return (jsx(
|
|
434
|
+
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
435
|
+
return (jsxs(Table$1.Row, { display: "flex", _hover: { backgroundColor: "rgba(178,178,178,0.1)" }, zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), children: [showSelector && (jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow, alwaysShowSelector: alwaysShowSelector })), row.getVisibleCells().map((cell, index) => {
|
|
436
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
373
437
|
// styling resize and pinning start
|
|
374
438
|
maxWidth: `${cell.column.getSize()}px`, width: `${cell.column.getSize()}px`, ...getTdProps(cell), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
375
439
|
})] }, `chakra-table-row-${row.id}`));
|
|
@@ -390,7 +454,7 @@ const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gr
|
|
|
390
454
|
}
|
|
391
455
|
return false;
|
|
392
456
|
};
|
|
393
|
-
return (jsxs(
|
|
457
|
+
return (jsxs(Table$1.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
394
458
|
? {
|
|
395
459
|
left: `0px`,
|
|
396
460
|
backgroundColor: pinnedBgColor.light,
|
|
@@ -400,15 +464,22 @@ const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gr
|
|
|
400
464
|
}
|
|
401
465
|
: {}),
|
|
402
466
|
// styling resize and pinning end
|
|
403
|
-
display: "grid", children: [!isCheckBoxVisible(index, row) && (jsx(Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` })), isCheckBoxVisible(index, row) && (jsx(
|
|
467
|
+
display: "grid", children: [!isCheckBoxVisible(index, row) && (jsx(Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` })), isCheckBoxVisible(index, row) && (jsx(Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: row.getIsSelected(),
|
|
404
468
|
disabled: !row.getCanSelect(),
|
|
405
469
|
// indeterminate: row.getIsSomeSelected(),
|
|
406
470
|
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
407
471
|
};
|
|
408
472
|
|
|
473
|
+
const Tooltip = React.forwardRef(function Tooltip(props, ref) {
|
|
474
|
+
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
475
|
+
if (disabled)
|
|
476
|
+
return children;
|
|
477
|
+
return (jsxs(Tooltip$1.Root, { ...rest, children: [jsx(Tooltip$1.Trigger, { asChild: true, children: children }), jsx(Portal, { disabled: !portalled, container: portalRef, children: jsx(Tooltip$1.Positioner, { children: jsxs(Tooltip$1.Content, { ref: ref, ...contentProps, children: [showArrow && (jsx(Tooltip$1.Arrow, { children: jsx(Tooltip$1.ArrowTip, {}) })), content] }) }) })] }));
|
|
478
|
+
});
|
|
479
|
+
|
|
409
480
|
const TableControls = ({ totalText = "Total:", showFilter = false, fitTableWidth = false, fitTableHeight = false, isMobile = false, children = jsx(Fragment, {}), showFilterName = false, showFilterTags = false, showReload = false, filterOptions = [], extraItems = jsx(Fragment, {}), }) => {
|
|
410
481
|
const { loading, hasError } = useDataTableContext();
|
|
411
|
-
return (jsxs(Grid, { templateRows: "auto auto auto 1fr auto", templateColumns: "1fr 1fr", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", justifySelf: "center", alignSelf: "center", gap: "0.5rem", children: [jsxs(Flex, { justifyContent: "space-between", gridColumn: "1 / span 2", children: [jsx(Box, { children: jsx(EditViewButton, { text: isMobile ? undefined : "View", icon: jsx(MdOutlineViewColumn, {}) }) }), jsxs(Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsx(Spinner, { size: "sm" }), hasError && (jsx(Tooltip, {
|
|
482
|
+
return (jsxs(Grid, { templateRows: "auto auto auto 1fr auto", templateColumns: "1fr 1fr", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", justifySelf: "center", alignSelf: "center", gap: "0.5rem", children: [jsxs(Flex, { justifyContent: "space-between", gridColumn: "1 / span 2", children: [jsx(Box, { children: jsx(EditViewButton, { text: isMobile ? undefined : "View", icon: jsx(MdOutlineViewColumn, {}) }) }), jsxs(Flex, { gap: "0.5rem", alignItems: "center", justifySelf: "end", children: [loading && jsx(Spinner, { size: "sm" }), hasError && (jsx(Tooltip, { content: "An error occurred while fetching data", children: jsx(Icon, { as: BsExclamationCircleFill, color: "red.400" }) })), showFilter && (jsxs(Fragment, { children: [jsx(GlobalFilter, {}), jsx(EditFilterButton, { text: isMobile ? undefined : "Advanced Filter" })] })), showReload && jsx(ReloadButton, {}), extraItems] })] }), jsx(Flex, { gridColumn: "1 / span 2", flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
|
|
412
483
|
return (jsxs(Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxs(Text, { children: [column, ":"] }), jsx(FilterOptions, { column: column })] }, column));
|
|
413
484
|
}) }), jsx(Flex, { gridColumn: "1 / span 2", children: showFilterTags && jsx(TableFilterTags, {}) }), jsx(Box, { overflow: "auto", gridColumn: "1 / span 2", width: "100%", height: "100%", children: children }), jsxs(Flex, { gap: "1rem", alignItems: "center", children: [jsx(PageSizeControl, {}), jsxs(Flex, { children: [jsx(Text, { paddingRight: "0.5rem", children: totalText }), jsx(RowCountText, {})] })] }), jsx(Box, { justifySelf: "end", children: jsx(TablePagination, {}) })] }));
|
|
414
485
|
};
|
|
@@ -448,7 +519,7 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
448
519
|
: {};
|
|
449
520
|
return thProps;
|
|
450
521
|
};
|
|
451
|
-
return (jsx(
|
|
522
|
+
return (jsx(Table$1.Footer, { children: table.getFooterGroups().map((footerGroup) => (jsxs(Table$1.Row, { display: "flex", children: [showSelector && (jsxs(Table$1.Header
|
|
452
523
|
// styling resize and pinning start
|
|
453
524
|
, {
|
|
454
525
|
// styling resize and pinning start
|
|
@@ -462,17 +533,22 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
462
533
|
}
|
|
463
534
|
: {}),
|
|
464
535
|
// styling resize and pinning end
|
|
465
|
-
onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsx(
|
|
536
|
+
onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsx(Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
466
537
|
// indeterminate: table.getIsSomeRowsSelected(),
|
|
467
|
-
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsx(Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }))] })), footerGroup.headers.map((header) => (jsx(
|
|
538
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsx(Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }))] })), footerGroup.headers.map((header) => (jsx(Table$1.Header, { padding: "0", columnSpan: `${header.colSpan}`,
|
|
468
539
|
// styling resize and pinning start
|
|
469
|
-
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid", ...getThProps(header), children: jsx(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
540
|
+
maxWidth: `${header.getSize()}px`, width: `${header.getSize()}px`, display: "grid", ...getThProps(header), children: jsx(MenuRoot$1, { children: jsx(MenuTrigger$1, { asChild: true, children: jsx(Box, { padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", _hover: { backgroundColor: "gray.100" }, children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
541
|
+
? null
|
|
542
|
+
: flexRender(header.column.columnDef.footer, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && (
|
|
543
|
+
// <UpDownIcon />
|
|
544
|
+
jsx(Fragment, {})), header.column.getIsSorted() === "asc" && (jsx(ChevronUpIcon, {})), header.column.getIsSorted() === "desc" && (jsx(ChevronDownIcon, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
474
545
|
};
|
|
475
546
|
|
|
547
|
+
const Button = React.forwardRef(function Button(props, ref) {
|
|
548
|
+
const { loading, disabled, loadingText, children, ...rest } = props;
|
|
549
|
+
return (jsx(Button$1, { disabled: loading || disabled, ref: ref, ...rest, children: loading && !loadingText ? (jsxs(Fragment, { children: [jsx(AbsoluteCenter, { display: "inline-flex", children: jsx(Spinner, { size: "inherit", color: "inherit" }) }), jsx(Span, { opacity: 0, children: children })] })) : loading && loadingText ? (jsxs(Fragment, { children: [jsx(Spinner, { size: "inherit", color: "inherit" }), loadingText] })) : (children) }));
|
|
550
|
+
});
|
|
551
|
+
|
|
476
552
|
const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, isSticky = true, alwaysShowSelector = true, tHeadProps = {}, }) => {
|
|
477
553
|
const { table } = useDataTableContext();
|
|
478
554
|
const SELECTION_BOX_WIDTH = 20;
|
|
@@ -497,7 +573,7 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
497
573
|
? {
|
|
498
574
|
left: showSelector
|
|
499
575
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
500
|
-
: `${header.getStart("left")
|
|
576
|
+
: `${header.getStart("left")}px`,
|
|
501
577
|
background: pinnedBgColor.light,
|
|
502
578
|
position: "sticky",
|
|
503
579
|
zIndex: 1,
|
|
@@ -508,10 +584,11 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
508
584
|
: {};
|
|
509
585
|
return thProps;
|
|
510
586
|
};
|
|
511
|
-
const
|
|
587
|
+
const stickyProps = {
|
|
512
588
|
position: "sticky",
|
|
589
|
+
top: 0,
|
|
513
590
|
};
|
|
514
|
-
return (jsx(
|
|
591
|
+
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), ...tHeadProps, children: table.getHeaderGroups().map((headerGroup) => (jsxs(Table$1.Row, { display: "flex", children: [showSelector && (jsxs(Table$1.ColumnHeader
|
|
515
592
|
// styling resize and pinning start
|
|
516
593
|
, { ...(table.getIsSomeColumnsPinned("left")
|
|
517
594
|
? {
|
|
@@ -523,7 +600,7 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
523
600
|
}
|
|
524
601
|
: {}),
|
|
525
602
|
// styling resize and pinning end
|
|
526
|
-
padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsx(
|
|
603
|
+
padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsx(Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
527
604
|
// indeterminate: table.getIsSomeRowsSelected(),
|
|
528
605
|
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsx(Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }))] })), headerGroup.headers.map((header) => {
|
|
529
606
|
const resizeProps = {
|
|
@@ -531,15 +608,15 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
531
608
|
onTouchStart: header.getResizeHandler(),
|
|
532
609
|
cursor: "col-resize",
|
|
533
610
|
};
|
|
534
|
-
return (jsxs(
|
|
611
|
+
return (jsxs(Table$1.ColumnHeader, { padding: "0rem", columnSpan: `${header.colSpan}`,
|
|
535
612
|
// styling resize and pinning start
|
|
536
|
-
width: `${header.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: header.index, ...getThProps(header), children: [jsxs(
|
|
537
|
-
|
|
538
|
-
|
|
613
|
+
width: `${header.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: header.index, ...getThProps(header), children: [jsxs(MenuRoot, { children: [jsx(MenuTrigger, { asChild: true, children: jsx(Grid, { padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", overflow: "auto", _hover: { backgroundColor: "gray.100" }, children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
614
|
+
? null
|
|
615
|
+
: flexRender(header.column.columnDef.header, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && jsx(Fragment, {}), header.column.getIsSorted() === "asc" && (jsx(ChevronUpIcon, {})), header.column.getIsSorted() === "desc" && (jsx(ChevronDownIcon, {}))] })) }), jsx(Box, { children: header.column.getIsFiltered() && jsx(MdFilterListAlt, {}) })] }) }) }), jsxs(MenuContent, { children: [!header.column.getIsPinned() && (jsx(MenuItem, { asChild: true, value: "pin-column", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
539
616
|
header.column.pin("left");
|
|
540
|
-
}, children: "Pin Column" })), header.column.getIsPinned() && (jsx(MenuItem, {
|
|
617
|
+
}, children: [jsx(MdPushPin, {}), "Pin Column"] }) })), header.column.getIsPinned() && (jsx(MenuItem, { asChild: true, value: "cancel-pin", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
541
618
|
header.column.pin(false);
|
|
542
|
-
}, children: "Cancel Pin" })), header.column.getCanSort() && (jsxs(Fragment, { children: [jsx(MenuItem, {
|
|
619
|
+
}, children: [jsx(MdCancel, {}), "Cancel Pin"] }) })), header.column.getCanSort() && (jsxs(Fragment, { children: [jsx(MenuItem, { asChild: true, value: "sort-ascend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
543
620
|
table.setSorting((state) => {
|
|
544
621
|
return [
|
|
545
622
|
...state.filter((column) => {
|
|
@@ -548,7 +625,7 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
548
625
|
{ id: header.id, desc: false },
|
|
549
626
|
];
|
|
550
627
|
});
|
|
551
|
-
}, children: "Sort Ascending" }), jsx(MenuItem, {
|
|
628
|
+
}, children: [jsx(GrAscend, {}), "Sort Ascending"] }) }), jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
552
629
|
table.setSorting((state) => {
|
|
553
630
|
return [
|
|
554
631
|
...state.filter((column) => {
|
|
@@ -557,9 +634,9 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
557
634
|
{ id: header.id, desc: true },
|
|
558
635
|
];
|
|
559
636
|
});
|
|
560
|
-
}, children: "Sort Descending" }), header.column.getIsSorted() && (jsx(MenuItem, {
|
|
637
|
+
}, children: [jsx(GrDescend, {}), "Sort Descending"] }) }), header.column.getIsSorted() && (jsx(MenuItem, { asChild: true, value: "sort-descend", children: jsxs(Button, { variant: "ghost", onClick: () => {
|
|
561
638
|
header.column.clearSorting();
|
|
562
|
-
}, children: "Clear Sorting" })
|
|
639
|
+
}, children: [jsx(MdClear, {}), "Clear Sorting"] }) }))] }))] })] }), canResize && (jsx(Box, { borderRight: "0.2rem solid", borderRightColor: header.column.getIsResizing() ? "gray.700" : "transparent", position: "relative", right: "0.1rem", width: "2px", height: "100%", userSelect: "none", style: { touchAction: "none" }, _hover: {
|
|
563
640
|
borderRightColor: header.column.getIsResizing()
|
|
564
641
|
? "gray.700"
|
|
565
642
|
: "gray.400",
|
|
@@ -574,21 +651,27 @@ const DefaultTable = ({ totalText = "Total:", showFilter = false, showFooter = f
|
|
|
574
651
|
const ReloadButton = ({ text = "Reload", variant = "icon", }) => {
|
|
575
652
|
const { refreshData } = useDataTableContext();
|
|
576
653
|
if (variant === "icon") {
|
|
577
|
-
return (jsx(Tooltip, {
|
|
654
|
+
return (jsx(Tooltip, { showArrow: true, content: "This is the tooltip content", children: jsx(Button, { variant: "ghost", onClick: () => {
|
|
578
655
|
refreshData();
|
|
579
|
-
}, "aria-label": "refresh" }) }));
|
|
656
|
+
}, "aria-label": "refresh", children: jsx(IoReload, {}) }) }));
|
|
580
657
|
}
|
|
581
658
|
return (jsx(Button, { variant: "ghost", leftIcon: jsx(IoReload, {}), onClick: () => {
|
|
582
659
|
refreshData();
|
|
583
660
|
}, children: text }));
|
|
584
661
|
};
|
|
585
662
|
|
|
586
|
-
const
|
|
587
|
-
const {
|
|
588
|
-
|
|
589
|
-
|
|
663
|
+
const EmptyState = React.forwardRef(function EmptyState(props, ref) {
|
|
664
|
+
const { title, description, icon, children, ...rest } = props;
|
|
665
|
+
return (jsx(EmptyState$1.Root, { ref: ref, ...rest, children: jsxs(EmptyState$1.Content, { children: [icon && (jsx(EmptyState$1.Indicator, { children: icon })), description ? (jsxs(VStack, { textAlign: "center", children: [jsx(EmptyState$1.Title, { children: title }), jsx(EmptyState$1.Description, { children: description })] })) : (jsx(EmptyState$1.Title, { children: title })), children] }) }));
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
const EmptyResult = (jsx(EmptyState, { icon: jsx(HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxs(List.Root, { variant: "marker", children: [jsx(List.Item, { children: "Try removing filters" }), jsx(List.Item, { children: "Try different keywords" })] }) }));
|
|
669
|
+
const Table = ({ children, emptyComponent = EmptyResult, ...props }) => {
|
|
670
|
+
const { table } = useDataTableContext();
|
|
671
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
672
|
+
return emptyComponent;
|
|
590
673
|
}
|
|
591
|
-
return (jsx(
|
|
674
|
+
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: table.getCenterTotalSize(), ...props, children: children }));
|
|
592
675
|
};
|
|
593
676
|
|
|
594
677
|
const TableCardContainer = ({ children, ...props }) => {
|
|
@@ -601,11 +684,10 @@ const DefaultCardTitle = () => {
|
|
|
601
684
|
const TableCards = ({ isSelectable = false, showDisplayNameOnly = false, renderTitle = DefaultCardTitle, cardBodyProps = {} }) => {
|
|
602
685
|
const { table } = useContext(TableContext);
|
|
603
686
|
return (jsx(Fragment, { children: table.getRowModel().rows.map((row) => {
|
|
604
|
-
return (jsx(Card, { children: jsxs(
|
|
687
|
+
return (jsx(Card.Root, { children: jsxs(Card.Body, { display: "flex", flexFlow: "column", gap: "0.5rem", ...cardBodyProps, children: [isSelectable && (jsx(Checkbox, { isChecked: row.getIsSelected(),
|
|
605
688
|
disabled: !row.getCanSelect(),
|
|
606
689
|
// indeterminate: row.getIsSomeSelected(),
|
|
607
690
|
onChange: row.getToggleSelectedHandler() })), renderTitle(row), jsx(Grid, { templateColumns: "auto 1fr", gap: "1rem", children: row.getVisibleCells().map((cell) => {
|
|
608
|
-
console.log(table.getColumn(cell.column.id), "dko");
|
|
609
691
|
return (jsxs(Fragment, { children: [jsxs(Box, { children: [showDisplayNameOnly && (jsx(Text, { fontWeight: "bold", children: cell.column.columnDef.meta?.displayName ??
|
|
610
692
|
cell.column.id })), !showDisplayNameOnly && (jsx(Fragment, { children: flexRender(cell.column.columnDef.header,
|
|
611
693
|
// @ts-expect-error Assuming the CellContext interface is the same as HeaderContext
|
|
@@ -623,11 +705,39 @@ const TableComponent = ({ render = () => {
|
|
|
623
705
|
|
|
624
706
|
const DateRangeFilter = ({ startDate, endDate, setStartDate, setEndDate, }) => {
|
|
625
707
|
console.log(startDate, endDate, "dflp");
|
|
626
|
-
return (jsx(Box, { p:
|
|
708
|
+
return (jsx(Box, { p: "1rem", children: jsxs(VStack, { children: [jsxs(Box, { children: [jsx(Box, { children: "Start Date" }), jsx(Input, { id: "start-date", type: "date", value: startDate, onChange: (e) => setStartDate(e.target.value) })] }), jsxs(Box, { children: [jsx(Box, { children: "End Date" }), jsx(Input, { id: "end-date", type: "date", value: endDate, onChange: (e) => setEndDate(e.target.value) })] })] }) }));
|
|
627
709
|
};
|
|
628
710
|
|
|
711
|
+
const Slider = React.forwardRef(function Slider(props, ref) {
|
|
712
|
+
const { marks: marksProp, label, showValue, ...rest } = props;
|
|
713
|
+
const value = props.defaultValue ?? props.value;
|
|
714
|
+
const marks = marksProp?.map((mark) => {
|
|
715
|
+
if (typeof mark === "number")
|
|
716
|
+
return { value: mark, label: undefined };
|
|
717
|
+
return mark;
|
|
718
|
+
});
|
|
719
|
+
const hasMarkLabel = !!marks?.some((mark) => mark.label);
|
|
720
|
+
return (jsxs(Slider$1.Root, { ref: ref, thumbAlignment: "center", ...rest, children: [label && !showValue && (jsx(Slider$1.Label, { children: label })), label && showValue && (jsxs(HStack, { justify: "space-between", children: [jsx(Slider$1.Label, { children: label }), jsx(Slider$1.ValueText, {})] })), jsxs(Slider$1.Control, { "data-has-mark-label": hasMarkLabel || undefined, children: [jsx(Slider$1.Track, { children: jsx(Slider$1.Range, {}) }), jsx(SliderThumbs, { value: value }), jsx(SliderMarks, { marks: marks })] })] }));
|
|
721
|
+
});
|
|
722
|
+
function SliderThumbs(props) {
|
|
723
|
+
const { value } = props;
|
|
724
|
+
return (jsx(For, { each: value, children: (_, index) => (jsx(Slider$1.Thumb, { index: index, children: jsx(Slider$1.HiddenInput, {}) }, index)) }));
|
|
725
|
+
}
|
|
726
|
+
const SliderMarks = React.forwardRef(function SliderMarks(props, ref) {
|
|
727
|
+
const { marks } = props;
|
|
728
|
+
if (!marks?.length)
|
|
729
|
+
return null;
|
|
730
|
+
return (jsx(Slider$1.MarkerGroup, { ref: ref, children: marks.map((mark, index) => {
|
|
731
|
+
const value = typeof mark === "number" ? mark : mark.value;
|
|
732
|
+
const label = typeof mark === "number" ? undefined : mark.label;
|
|
733
|
+
return (jsxs(Slider$1.Marker, { value: value, children: [jsx(Slider$1.MarkerIndicator, {}), label] }, index));
|
|
734
|
+
}) }));
|
|
735
|
+
});
|
|
736
|
+
|
|
629
737
|
const RangeFilter = ({ range, setRange, defaultValue, min, max, step, }) => {
|
|
630
|
-
return (jsx(Box, { p: 8, children:
|
|
738
|
+
return (jsx(Box, { p: 8, children: jsx(Slider, { width: "full", min: min, max: max, defaultValue: defaultValue, step: step, name: `Selected Range: ${range[0]} - ${range[1]}`,
|
|
739
|
+
// value={field.value}
|
|
740
|
+
onValueChange: (val) => setRange(val.value) }) }));
|
|
631
741
|
};
|
|
632
742
|
|
|
633
743
|
const TagFilter = ({ availableTags, selectedTags, onTagChange, }) => {
|
|
@@ -639,13 +749,22 @@ const TagFilter = ({ availableTags, selectedTags, onTagChange, }) => {
|
|
|
639
749
|
onTagChange([...selectedTags, tag]);
|
|
640
750
|
}
|
|
641
751
|
};
|
|
642
|
-
return (jsx(Flex, { flexFlow: "wrap", p: "0.5rem", gap: "0.5rem", children: availableTags.map((tag) => (jsx(
|
|
752
|
+
return (jsx(Flex, { flexFlow: "wrap", p: "0.5rem", gap: "0.5rem", children: availableTags.map((tag) => (jsx(Tag, { variant: selectedTags.includes(tag) ? "solid" : "outline", cursor: "pointer", closable: selectedTags.includes(tag) ? true : undefined, onClick: () => toggleTag(tag), children: tag }))) }));
|
|
643
753
|
};
|
|
644
754
|
|
|
645
|
-
function
|
|
755
|
+
const Radio = React.forwardRef(function Radio(props, ref) {
|
|
756
|
+
const { children, inputProps, rootRef, ...rest } = props;
|
|
757
|
+
return (jsxs(RadioGroup$1.Item, { ref: rootRef, ...rest, children: [jsx(RadioGroup$1.ItemHiddenInput, { ref: ref, ...inputProps }), jsx(RadioGroup$1.ItemIndicator, {}), children && (jsx(RadioGroup$1.ItemText, { children: children }))] }));
|
|
758
|
+
});
|
|
759
|
+
const RadioGroup = RadioGroup$1.Root;
|
|
760
|
+
|
|
761
|
+
const Filter = ({ column }) => {
|
|
646
762
|
const { filterVariant } = column.columnDef.meta ?? {};
|
|
647
763
|
const displayName = column.columnDef.meta?.displayName ?? column.id;
|
|
648
764
|
const filterOptions = column.columnDef.meta?.filterOptions ?? [];
|
|
765
|
+
// const collection = createListCollection({
|
|
766
|
+
// items: filterOptions,
|
|
767
|
+
// });
|
|
649
768
|
if (column.columns.length > 0) {
|
|
650
769
|
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), column.columns.map((column) => {
|
|
651
770
|
return jsx(Filter, { column: column }, column.id);
|
|
@@ -655,11 +774,9 @@ function Filter({ column }) {
|
|
|
655
774
|
return jsx(Fragment, {});
|
|
656
775
|
}
|
|
657
776
|
if (filterVariant === "select") {
|
|
658
|
-
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(
|
|
659
|
-
column.setFilterValue(
|
|
660
|
-
}, children: filterOptions.map((
|
|
661
|
-
return (jsx("option", { value: option, children: option }, `${option}`));
|
|
662
|
-
}) })] }, column.id));
|
|
777
|
+
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(RadioGroup, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onValueChange: (details) => {
|
|
778
|
+
column.setFilterValue(details.value);
|
|
779
|
+
}, children: jsx(Flex, { flexFlow: 'wrap', gap: '0.5rem', children: filterOptions.map((item) => (jsx(Radio, { value: item, children: item }, item))) }) })] }, column.id));
|
|
663
780
|
}
|
|
664
781
|
if (filterVariant === "tag") {
|
|
665
782
|
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(TagFilter, { availableTags: filterOptions, selectedTags: (column.getFilterValue() ?? []), onTagChange: (tags) => {
|
|
@@ -719,7 +836,7 @@ function Filter({ column }) {
|
|
|
719
836
|
return (jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(Text, { children: displayName }), jsx(Input, { value: column.getFilterValue() ? String(column.getFilterValue()) : "", onChange: (e) => {
|
|
720
837
|
column.setFilterValue(e.target.value);
|
|
721
838
|
} })] }, column.id));
|
|
722
|
-
}
|
|
839
|
+
};
|
|
723
840
|
const TableFilter = () => {
|
|
724
841
|
const { table } = useDataTableContext();
|
|
725
842
|
return (jsx(Fragment, { children: table.getAllColumns().map((column) => {
|
|
@@ -730,11 +847,11 @@ const TableFilter = () => {
|
|
|
730
847
|
const TableFilterTags = () => {
|
|
731
848
|
const { table } = useDataTableContext();
|
|
732
849
|
return (jsx(Flex, { gap: "0.5rem", flexFlow: "wrap", children: table.getState().columnFilters.map(({ id, value }) => {
|
|
733
|
-
return (jsxs(Tag, {
|
|
850
|
+
return (jsxs(Tag, { gap: "0.5rem", children: [`${id}: ${value}`, jsx(IconButton, { variant: "ghost", "aria-label": "remove filter", onClick: () => {
|
|
734
851
|
table.setColumnFilters(table.getState().columnFilters.filter((filter) => {
|
|
735
852
|
return filter.value != value;
|
|
736
853
|
}));
|
|
737
|
-
},
|
|
854
|
+
}, children: jsx(CgClose, {}) })] }, `${id}-${value}`));
|
|
738
855
|
}) }));
|
|
739
856
|
};
|
|
740
857
|
|
|
@@ -785,9 +902,9 @@ const ColumnOrderChanger = ({ columns }) => {
|
|
|
785
902
|
if (nextIndex < order.length) {
|
|
786
903
|
handleChangeOrder(index, nextIndex);
|
|
787
904
|
}
|
|
788
|
-
}, disabled: index === order.length - 1, "aria-label": "", children: jsx(MdArrowDownward, {}) })] }, columnId))) }), jsxs(Flex, { gap: "0.25rem", children: [jsx(Button, { onClick: () => {
|
|
905
|
+
}, disabled: index === order.length - 1, "aria-label": "", children: jsx(MdArrowDownward, {}) })] }, columnId))) }), jsxs(Flex, { gap: "0.25rem", children: [jsx(Button$1, { onClick: () => {
|
|
789
906
|
table.setColumnOrder(order);
|
|
790
|
-
}, children: "Apply" }), jsx(Button, { onClick: () => {
|
|
907
|
+
}, children: "Apply" }), jsx(Button$1, { onClick: () => {
|
|
791
908
|
table.setColumnOrder(originalOrder);
|
|
792
909
|
}, children: "Reset" })] })] }));
|
|
793
910
|
};
|
|
@@ -796,31 +913,36 @@ const TableOrderer = () => {
|
|
|
796
913
|
return (jsx(Fragment, { children: jsx(ColumnOrderChanger, { columns: table.getState().columnOrder }) }));
|
|
797
914
|
};
|
|
798
915
|
|
|
799
|
-
const TablePagination = (
|
|
916
|
+
const TablePagination = () => {
|
|
800
917
|
const { firstPage, getCanPreviousPage, previousPage, getState, nextPage, getCanNextPage, lastPage, } = useDataTableContext().table;
|
|
801
|
-
return (jsxs(
|
|
918
|
+
return (jsxs(Group, { attached: true, children: [jsx(IconButton, { onClick: () => firstPage(), disabled: !getCanPreviousPage(), "aria-label": "first-page", variant: "ghost", children: jsx(MdFirstPage, {}) }), jsx(IconButton, { onClick: () => previousPage(), disabled: !getCanPreviousPage(), "aria-label": "previous-page", variant: "ghost", children: jsx(MdArrowBack, {}) }), jsx(Button, { variant: "ghost", onClick: () => { }, disabled: !getCanPreviousPage(), children: getState().pagination.pageIndex + 1 }), jsx(IconButton, { onClick: () => nextPage(), disabled: !getCanNextPage(), "aria-label": "next-page", variant: "ghost", children: jsx(MdArrowForward, {}) }), jsx(IconButton, { onClick: () => lastPage(), disabled: !getCanNextPage(), "aria-label": "last-page", variant: "ghost", children: jsx(MdLastPage, {}) })] }));
|
|
802
919
|
};
|
|
803
920
|
|
|
804
921
|
const SelectAllRowsToggle = ({ selectAllIcon = jsx(MdOutlineChecklist, {}), clearAllIcon = jsx(MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
805
922
|
const { table } = useDataTableContext();
|
|
806
923
|
return (jsxs(Fragment, { children: [!!selectAllText === false && (jsx(IconButton, { icon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", "aria-label": table.getIsAllRowsSelected() ? clearAllText : selectAllText, onClick: (event) => {
|
|
807
924
|
table.getToggleAllRowsSelectedHandler()(event);
|
|
808
|
-
} })), !!selectAllText !== false && (jsx(Button, { leftIcon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", onClick: (event) => {
|
|
925
|
+
} })), !!selectAllText !== false && (jsx(Button$1, { leftIcon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", onClick: (event) => {
|
|
809
926
|
table.getToggleAllRowsSelectedHandler()(event);
|
|
810
927
|
}, children: table.getIsAllRowsSelected() ? clearAllText : selectAllText }))] }));
|
|
811
928
|
};
|
|
812
929
|
|
|
813
930
|
const TableSelector = () => {
|
|
814
931
|
const { table } = useContext(TableContext);
|
|
815
|
-
return (jsxs(Fragment, { children: [table.getSelectedRowModel().rows.length > 0 && (jsxs(Button, { onClick: () => { }, variant: "ghost", display: "flex", gap: "0.25rem", children: [jsx(Box, { fontSize: "sm", children: `${table.getSelectedRowModel().rows.length}` }), jsx(Icon, { as: IoMdCheckbox })] })), !table.getIsAllPageRowsSelected() && jsx(SelectAllRowsToggle, {}), table.getSelectedRowModel().rows.length > 0 && (jsx(IconButton, { variant: "ghost", icon: jsx(Icon, { as: MdClear }), onClick: () => {
|
|
932
|
+
return (jsxs(Fragment, { children: [table.getSelectedRowModel().rows.length > 0 && (jsxs(Button$1, { onClick: () => { }, variant: "ghost", display: "flex", gap: "0.25rem", children: [jsx(Box, { fontSize: "sm", children: `${table.getSelectedRowModel().rows.length}` }), jsx(Icon, { as: IoMdCheckbox })] })), !table.getIsAllPageRowsSelected() && jsx(SelectAllRowsToggle, {}), table.getSelectedRowModel().rows.length > 0 && (jsx(IconButton, { variant: "ghost", icon: jsx(Icon, { as: MdClear }), onClick: () => {
|
|
816
933
|
table.resetRowSelection();
|
|
817
934
|
}, "aria-label": "reset selection" }))] }));
|
|
818
935
|
};
|
|
819
936
|
|
|
937
|
+
const Switch = React.forwardRef(function Switch(props, ref) {
|
|
938
|
+
const { inputProps, children, rootRef, trackLabel, thumbLabel, ...rest } = props;
|
|
939
|
+
return (jsxs(Switch$1.Root, { ref: rootRef, ...rest, children: [jsx(Switch$1.HiddenInput, { ref: ref, ...inputProps }), jsxs(Switch$1.Control, { children: [jsx(Switch$1.Thumb, { children: thumbLabel && (jsx(Switch$1.ThumbIndicator, { fallback: thumbLabel?.off, children: thumbLabel?.on })) }), trackLabel && (jsx(Switch$1.Indicator, { fallback: trackLabel.off, children: trackLabel.on }))] }), children != null && (jsx(Switch$1.Label, { children: children }))] }));
|
|
940
|
+
});
|
|
941
|
+
|
|
820
942
|
const TableViewer = () => {
|
|
821
943
|
const { table } = useDataTableContext();
|
|
822
944
|
const columns = table.getAllLeafColumns();
|
|
823
|
-
const [columnOrder, setColumnOrder] = useState(columns.map(column => column.id));
|
|
945
|
+
const [columnOrder, setColumnOrder] = useState(columns.map((column) => column.id));
|
|
824
946
|
const handleDragEnd = (result) => {
|
|
825
947
|
if (!result.destination)
|
|
826
948
|
return;
|
|
@@ -832,15 +954,15 @@ const TableViewer = () => {
|
|
|
832
954
|
};
|
|
833
955
|
return (jsx(DragDropContext, { onDragEnd: handleDragEnd, children: jsx(Droppable, { droppableId: "columns", children: (provided) => (jsxs(Flex, { flexFlow: "column", gap: "0.5rem", ref: provided.innerRef, ...provided.droppableProps, children: [columns.map((column, index) => {
|
|
834
956
|
const displayName = column.columnDef.meta?.displayName || column.id;
|
|
835
|
-
return (jsx(Draggable, { draggableId: column.id, index: index, children: (provided) => (jsxs(Grid, { ref: provided.innerRef, ...provided.draggableProps, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", children: [jsx(Flex, { ...provided.dragHandleProps, alignItems: "center", padding: "0", children: jsx(
|
|
957
|
+
return (jsx(Draggable, { draggableId: column.id, index: index, children: (provided) => (jsxs(Grid, { ref: provided.innerRef, ...provided.draggableProps, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", children: [jsx(Flex, { ...provided.dragHandleProps, alignItems: "center", padding: "0", children: jsx(FaGripLinesVertical, { color: "gray.400" }) }), jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [jsx(Box, { children: displayName }), jsx(Switch, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() })] })] })) }, column.id));
|
|
836
958
|
}), provided.placeholder] })) }) }));
|
|
837
959
|
};
|
|
838
960
|
|
|
839
|
-
const TextCell = ({ label,
|
|
961
|
+
const TextCell = ({ label, padding = "0rem", children, ...props }) => {
|
|
840
962
|
if (label) {
|
|
841
|
-
return (jsx(Flex, { alignItems: "center", height: "100%", padding: padding, children: jsx(Tooltip, {
|
|
963
|
+
return (jsx(Flex, { alignItems: "center", height: "100%", padding: padding, children: jsx(Tooltip, { content: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", children: label }), children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", ...props, children: children }) }) }));
|
|
842
964
|
}
|
|
843
|
-
return (jsx(Flex, { alignItems: "center", height: "100%", padding: padding, children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all",
|
|
965
|
+
return (jsx(Flex, { alignItems: "center", height: "100%", padding: padding, children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", ...props, children: children }) }));
|
|
844
966
|
};
|
|
845
967
|
|
|
846
968
|
const useDataFromUrl = ({ url, params = {}, disableFirstFetch = false, onFetchSuccess = () => { }, defaultData, }) => {
|
|
@@ -1030,7 +1152,7 @@ const FilterOptions = ({ column }) => {
|
|
|
1030
1152
|
const options = tableColumn?.columnDef.meta?.filterOptions ?? [];
|
|
1031
1153
|
return (jsx(Fragment, { children: options.map((option) => {
|
|
1032
1154
|
const selected = table.getColumn(column)?.getFilterValue() === option;
|
|
1033
|
-
return (jsxs(Button, { size: "sm", onClick: () => {
|
|
1155
|
+
return (jsxs(Button$1, { size: "sm", onClick: () => {
|
|
1034
1156
|
if (selected) {
|
|
1035
1157
|
table.setColumnFilters((state) => {
|
|
1036
1158
|
return state.filter((filter) => {
|
|
@@ -1044,14 +1166,22 @@ const FilterOptions = ({ column }) => {
|
|
|
1044
1166
|
}) }));
|
|
1045
1167
|
};
|
|
1046
1168
|
|
|
1047
|
-
const
|
|
1169
|
+
const InputGroup = React.forwardRef(function InputGroup(props, ref) {
|
|
1170
|
+
const { startElement, startElementProps, endElement, endElementProps, children, startOffset = "6px", endOffset = "6px", ...rest } = props;
|
|
1171
|
+
return (jsxs(Group, { ref: ref, ...rest, children: [startElement && (jsx(InputElement, { pointerEvents: "none", ...startElementProps, children: startElement })), React.cloneElement(children, {
|
|
1172
|
+
...(startElement && {
|
|
1173
|
+
ps: `calc(var(--input-height) - ${startOffset})`,
|
|
1174
|
+
}),
|
|
1175
|
+
...(endElement && { pe: `calc(var(--input-height) - ${endOffset})` }),
|
|
1176
|
+
...children.props,
|
|
1177
|
+
}), endElement && (jsx(InputElement, { placement: "end", ...endElementProps, children: endElement }))] }));
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1180
|
+
const GlobalFilter = () => {
|
|
1048
1181
|
const { table } = useDataTableContext();
|
|
1049
|
-
return (jsx(Fragment, { children: jsx(
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
}
|
|
1053
|
-
table.setGlobalFilter(e.target.value);
|
|
1054
|
-
} })] }) }) }));
|
|
1182
|
+
return (jsx(Fragment, { children: jsx(InputGroup, { flex: "1", startElement: jsx(MdSearch, {}), children: jsx(Input, { placeholder: "Outline", variant: "outline", onChange: (e) => {
|
|
1183
|
+
table.setGlobalFilter(e.target.value);
|
|
1184
|
+
} }) }) }));
|
|
1055
1185
|
};
|
|
1056
1186
|
|
|
1057
1187
|
export { DataTable, DataTableServer, DefaultCard, DefaultCardTitle, DefaultTable, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, FilterOptions, GlobalFilter, PageSizeControl, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, useDataFromUrl, useDataTable, useDataTableContext, useDataTableServer };
|