@bsol-oss/react-datatable5 12.0.0-beta.17 → 12.0.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Row, RowData, OnChangeFn, Updater, FilterFn, ColumnDef, RowSelectionSta
|
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import React__default, { ReactNode, Dispatch, SetStateAction } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
-
import { ImageProps, TableHeaderProps as TableHeaderProps$1,
|
|
6
|
+
import { ImageProps, TableRootProps, TableHeaderProps as TableHeaderProps$1, TableRowProps, GridProps, CardBodyProps, FlexProps, TextProps, BoxProps } from '@chakra-ui/react';
|
|
7
7
|
import { IconType } from 'react-icons';
|
|
8
8
|
import * as react_i18next from 'react-i18next';
|
|
9
9
|
import { UseTranslationResponse } from 'react-i18next';
|
|
@@ -290,27 +290,6 @@ interface DataTableServerProps<TData extends DataResponse = DataResponse<unknown
|
|
|
290
290
|
*/
|
|
291
291
|
declare function DataTableServer<TData extends DataResponse = DataResponse<unknown>>({ columns, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, query, url, translate, children, }: DataTableServerProps<TData>): react_jsx_runtime.JSX.Element;
|
|
292
292
|
|
|
293
|
-
interface TableBodyProps {
|
|
294
|
-
pinnedBgColor?: {
|
|
295
|
-
light: string;
|
|
296
|
-
dark: string;
|
|
297
|
-
};
|
|
298
|
-
showSelector?: boolean;
|
|
299
|
-
alwaysShowSelector?: boolean;
|
|
300
|
-
canResize?: boolean;
|
|
301
|
-
}
|
|
302
|
-
interface TableRowSelectorProps<TData> {
|
|
303
|
-
index: number;
|
|
304
|
-
row: Row<TData>;
|
|
305
|
-
hoveredRow: number;
|
|
306
|
-
pinnedBgColor?: {
|
|
307
|
-
light: string;
|
|
308
|
-
dark: string;
|
|
309
|
-
};
|
|
310
|
-
alwaysShowSelector?: boolean;
|
|
311
|
-
}
|
|
312
|
-
declare const TableBody: ({ showSelector, alwaysShowSelector, canResize, }: TableBodyProps) => react_jsx_runtime.JSX.Element;
|
|
313
|
-
|
|
314
293
|
interface TableControlsProps {
|
|
315
294
|
totalText?: string;
|
|
316
295
|
fitTableWidth?: boolean;
|
|
@@ -332,50 +311,65 @@ interface TableControlsProps {
|
|
|
332
311
|
}
|
|
333
312
|
declare const TableControls: ({ fitTableWidth, fitTableHeight, children, showGlobalFilter, showFilter, showFilterName, showFilterTags, showReload, showPagination, showPageSizeControl, showPageCountText, showView, filterOptions, extraItems, loading, hasError, }: TableControlsProps) => react_jsx_runtime.JSX.Element;
|
|
334
313
|
|
|
335
|
-
interface
|
|
314
|
+
interface TableProps extends TableRootProps {
|
|
315
|
+
showLoading?: boolean;
|
|
316
|
+
loadingComponent?: ReactNode;
|
|
317
|
+
emptyComponent?: ReactNode;
|
|
318
|
+
canResize?: boolean;
|
|
319
|
+
children: ReactNode;
|
|
320
|
+
}
|
|
321
|
+
declare const Table: ({ children, emptyComponent, canResize, ...props }: TableProps) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
|
|
322
|
+
|
|
323
|
+
interface TableBodyProps {
|
|
336
324
|
pinnedBgColor?: {
|
|
337
325
|
light: string;
|
|
338
326
|
dark: string;
|
|
339
327
|
};
|
|
340
328
|
showSelector?: boolean;
|
|
341
329
|
alwaysShowSelector?: boolean;
|
|
330
|
+
canResize?: boolean;
|
|
331
|
+
}
|
|
332
|
+
interface TableRowSelectorProps<TData> {
|
|
333
|
+
index: number;
|
|
334
|
+
row: Row<TData>;
|
|
335
|
+
hoveredRow: number;
|
|
336
|
+
pinnedBgColor?: {
|
|
337
|
+
light: string;
|
|
338
|
+
dark: string;
|
|
339
|
+
};
|
|
340
|
+
alwaysShowSelector?: boolean;
|
|
342
341
|
}
|
|
343
|
-
declare const
|
|
342
|
+
declare const TableBody: ({ showSelector, alwaysShowSelector, canResize, }: TableBodyProps) => react_jsx_runtime.JSX.Element;
|
|
344
343
|
|
|
345
|
-
interface
|
|
346
|
-
canResize?: boolean;
|
|
344
|
+
interface TableFooterProps {
|
|
347
345
|
pinnedBgColor?: {
|
|
348
346
|
light: string;
|
|
349
347
|
dark: string;
|
|
350
348
|
};
|
|
351
349
|
showSelector?: boolean;
|
|
352
|
-
isSticky?: boolean;
|
|
353
350
|
alwaysShowSelector?: boolean;
|
|
354
|
-
tHeadProps?: TableHeaderProps$1;
|
|
355
351
|
}
|
|
356
|
-
declare const
|
|
352
|
+
declare const TableFooter: ({ pinnedBgColor, showSelector, alwaysShowSelector, }: TableFooterProps) => react_jsx_runtime.JSX.Element;
|
|
357
353
|
|
|
358
|
-
interface
|
|
359
|
-
showLoading?: boolean;
|
|
360
|
-
loadingComponent?: ReactNode;
|
|
361
|
-
emptyComponent?: ReactNode;
|
|
354
|
+
interface TableHeaderProps {
|
|
362
355
|
canResize?: boolean;
|
|
363
|
-
|
|
356
|
+
showSelector?: boolean;
|
|
357
|
+
isSticky?: boolean;
|
|
358
|
+
tableHeaderProps?: TableHeaderProps$1;
|
|
359
|
+
tableRowProps?: TableRowProps;
|
|
364
360
|
}
|
|
365
|
-
declare const
|
|
361
|
+
declare const TableHeader: ({ canResize, showSelector, isSticky, tableHeaderProps, tableRowProps, }: TableHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
366
362
|
|
|
367
363
|
interface DefaultTableProps {
|
|
368
364
|
showFooter?: boolean;
|
|
369
|
-
showSelector?: boolean;
|
|
370
365
|
tableProps?: Omit<TableProps, "children">;
|
|
371
|
-
tHeadProps?: TableHeaderProps$1;
|
|
372
|
-
controlProps?: TableControlsProps;
|
|
373
|
-
tableFooterProps?: TableFooterProps;
|
|
374
|
-
tableBodyProps?: TableBodyProps;
|
|
375
366
|
tableHeaderProps?: TableHeaderProps;
|
|
367
|
+
tableBodyProps?: TableBodyProps;
|
|
368
|
+
tableFooterProps?: TableFooterProps;
|
|
369
|
+
controlProps?: TableControlsProps;
|
|
376
370
|
variant?: "" | "greedy";
|
|
377
371
|
}
|
|
378
|
-
declare const DefaultTable: ({ showFooter, tableProps, tableHeaderProps, tableBodyProps,
|
|
372
|
+
declare const DefaultTable: ({ showFooter, tableProps, tableHeaderProps, tableBodyProps, tableFooterProps, controlProps, variant, }: DefaultTableProps) => react_jsx_runtime.JSX.Element;
|
|
379
373
|
|
|
380
374
|
interface ReloadButtonProps {
|
|
381
375
|
text?: string;
|
package/dist/index.js
CHANGED
|
@@ -2917,85 +2917,6 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2917
2917
|
}, children: jsxRuntime.jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2918
2918
|
}
|
|
2919
2919
|
|
|
2920
|
-
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
2921
|
-
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
2922
|
-
return (jsxRuntime.jsxs(react.Checkbox.Root, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.Checkbox.HiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.Checkbox.Control, { children: icon || jsxRuntime.jsx(react.Checkbox.Indicator, {}) }), children != null && (jsxRuntime.jsx(react.Checkbox.Label, { children: children }))] }));
|
|
2923
|
-
});
|
|
2924
|
-
|
|
2925
|
-
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
2926
|
-
"use no memo";
|
|
2927
|
-
const { table } = useDataTableContext();
|
|
2928
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2929
|
-
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
2930
|
-
const handleRowHover = (index) => {
|
|
2931
|
-
setHoveredRow(index);
|
|
2932
|
-
};
|
|
2933
|
-
const getTdProps = (cell) => {
|
|
2934
|
-
const tdProps = cell.column.getIsPinned()
|
|
2935
|
-
? {
|
|
2936
|
-
left: showSelector
|
|
2937
|
-
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
2938
|
-
: `${cell.column.getStart("left")}px`,
|
|
2939
|
-
position: "relative",
|
|
2940
|
-
}
|
|
2941
|
-
: {};
|
|
2942
|
-
return tdProps;
|
|
2943
|
-
};
|
|
2944
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2945
|
-
if (hoveredRow === -1) {
|
|
2946
|
-
return {};
|
|
2947
|
-
}
|
|
2948
|
-
if (hoveredRow === index) {
|
|
2949
|
-
return {
|
|
2950
|
-
opacity: "1",
|
|
2951
|
-
};
|
|
2952
|
-
}
|
|
2953
|
-
return {
|
|
2954
|
-
opacity: "0.8",
|
|
2955
|
-
};
|
|
2956
|
-
};
|
|
2957
|
-
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2958
|
-
return (jsxRuntime.jsxs(react.Table.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsxRuntime.jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow, alwaysShowSelector: alwaysShowSelector })), row.getVisibleCells().map((cell, index) => {
|
|
2959
|
-
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2960
|
-
// styling resize and pinning start
|
|
2961
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
2962
|
-
base: "colorPalette.900",
|
|
2963
|
-
_dark: "colorPalette.100",
|
|
2964
|
-
},
|
|
2965
|
-
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2966
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
2967
|
-
}) }));
|
|
2968
|
-
};
|
|
2969
|
-
const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, alwaysShowSelector = true, }) => {
|
|
2970
|
-
const { table } = useDataTableContext();
|
|
2971
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2972
|
-
const isCheckBoxVisible = (current_index, current_row) => {
|
|
2973
|
-
if (alwaysShowSelector) {
|
|
2974
|
-
return true;
|
|
2975
|
-
}
|
|
2976
|
-
if (current_row.getIsSelected()) {
|
|
2977
|
-
return true;
|
|
2978
|
-
}
|
|
2979
|
-
if (hoveredRow == current_index) {
|
|
2980
|
-
return true;
|
|
2981
|
-
}
|
|
2982
|
-
return false;
|
|
2983
|
-
};
|
|
2984
|
-
return (jsxRuntime.jsxs(react.Table.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
2985
|
-
? {
|
|
2986
|
-
left: `0px`,
|
|
2987
|
-
backgroundColor: pinnedBgColor.light,
|
|
2988
|
-
position: "sticky",
|
|
2989
|
-
zIndex: 1,
|
|
2990
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
2991
|
-
}
|
|
2992
|
-
: {}),
|
|
2993
|
-
// styling resize and pinning end
|
|
2994
|
-
display: "grid", children: [!isCheckBoxVisible(index, row) && (jsxRuntime.jsx(react.Box, { as: "span", margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` })), isCheckBoxVisible(index, row) && (jsxRuntime.jsx(react.Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: row.getIsSelected(),
|
|
2995
|
-
disabled: !row.getCanSelect(),
|
|
2996
|
-
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
2997
|
-
};
|
|
2998
|
-
|
|
2999
2920
|
const Tooltip = React__namespace.forwardRef(function Tooltip(props, ref) {
|
|
3000
2921
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
3001
2922
|
if (disabled)
|
|
@@ -3083,6 +3004,81 @@ const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children
|
|
|
3083
3004
|
}, children: children }), jsxRuntime.jsxs(react.Flex, { justifyContent: "space-between", children: [jsxRuntime.jsxs(react.Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsxRuntime.jsx(PageSizeControl, {}), showPageCountText && (jsxRuntime.jsxs(react.Flex, { children: [jsxRuntime.jsx(react.Text, { paddingRight: "0.5rem", children: translate.t("rowcount.total") }), jsxRuntime.jsx(RowCountText, {})] }))] }), jsxRuntime.jsx(react.Box, { justifySelf: "end", children: showPagination && jsxRuntime.jsx(Pagination, {}) })] })] }));
|
|
3084
3005
|
};
|
|
3085
3006
|
|
|
3007
|
+
const EmptyState = React__namespace.forwardRef(function EmptyState(props, ref) {
|
|
3008
|
+
const { title, description, icon, children, ...rest } = props;
|
|
3009
|
+
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
3010
|
+
});
|
|
3011
|
+
|
|
3012
|
+
const EmptyResult = (jsxRuntime.jsx(EmptyState, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
3013
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3014
|
+
const { table } = useDataTableContext();
|
|
3015
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
3016
|
+
return emptyComponent;
|
|
3017
|
+
}
|
|
3018
|
+
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3019
|
+
};
|
|
3020
|
+
|
|
3021
|
+
const Checkbox = React__namespace.forwardRef(function Checkbox(props, ref) {
|
|
3022
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3023
|
+
return (jsxRuntime.jsxs(react.Checkbox.Root, { ref: rootRef, ...rest, children: [jsxRuntime.jsx(react.Checkbox.HiddenInput, { ref: ref, ...inputProps }), jsxRuntime.jsx(react.Checkbox.Control, { children: icon || jsxRuntime.jsx(react.Checkbox.Indicator, {}) }), children != null && (jsxRuntime.jsx(react.Checkbox.Label, { children: children }))] }));
|
|
3024
|
+
});
|
|
3025
|
+
|
|
3026
|
+
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
3027
|
+
"use no memo";
|
|
3028
|
+
const { table } = useDataTableContext();
|
|
3029
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3030
|
+
const [hoveredRow, setHoveredRow] = React.useState(-1);
|
|
3031
|
+
const handleRowHover = (index) => {
|
|
3032
|
+
setHoveredRow(index);
|
|
3033
|
+
};
|
|
3034
|
+
const getTdProps = (cell) => {
|
|
3035
|
+
const tdProps = cell.column.getIsPinned()
|
|
3036
|
+
? {
|
|
3037
|
+
left: showSelector
|
|
3038
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3039
|
+
: `${cell.column.getStart("left")}px`,
|
|
3040
|
+
position: "relative",
|
|
3041
|
+
}
|
|
3042
|
+
: {};
|
|
3043
|
+
return tdProps;
|
|
3044
|
+
};
|
|
3045
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3046
|
+
if (hoveredRow === -1) {
|
|
3047
|
+
return {};
|
|
3048
|
+
}
|
|
3049
|
+
if (hoveredRow === index) {
|
|
3050
|
+
return {
|
|
3051
|
+
opacity: "1",
|
|
3052
|
+
};
|
|
3053
|
+
}
|
|
3054
|
+
return {
|
|
3055
|
+
opacity: "0.8",
|
|
3056
|
+
};
|
|
3057
|
+
};
|
|
3058
|
+
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3059
|
+
return (jsxRuntime.jsxs(react.Table.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsxRuntime.jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow })), row.getVisibleCells().map((cell, index) => {
|
|
3060
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3061
|
+
// styling resize and pinning start
|
|
3062
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3063
|
+
base: "colorPalette.900",
|
|
3064
|
+
_dark: "colorPalette.100",
|
|
3065
|
+
},
|
|
3066
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3067
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3068
|
+
}) }));
|
|
3069
|
+
};
|
|
3070
|
+
const TableRowSelector = ({ index, row, }) => {
|
|
3071
|
+
const { table } = useDataTableContext();
|
|
3072
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3073
|
+
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3074
|
+
base: "colorPalette.900",
|
|
3075
|
+
_dark: "colorPalette.100",
|
|
3076
|
+
},
|
|
3077
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: row.getIsSelected(),
|
|
3078
|
+
disabled: !row.getCanSelect(),
|
|
3079
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3080
|
+
};
|
|
3081
|
+
|
|
3086
3082
|
const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
|
|
3087
3083
|
const table = useDataTableContext().table;
|
|
3088
3084
|
const SELECTION_BOX_WIDTH = 20;
|
|
@@ -3143,25 +3139,9 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3143
3139
|
jsxRuntime.jsx(jsxRuntime.Fragment, {})), header.column.getIsSorted() === "asc" && (jsxRuntime.jsx(bi.BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsxRuntime.jsx(bi.BiDownArrow, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${header.column.id}-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
3144
3140
|
};
|
|
3145
3141
|
|
|
3146
|
-
const TableHeader = ({ canResize = true,
|
|
3142
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3147
3143
|
const { table } = useDataTableContext();
|
|
3148
3144
|
const SELECTION_BOX_WIDTH = 20;
|
|
3149
|
-
const [hoveredCheckBox, setHoveredCheckBox] = React.useState(false);
|
|
3150
|
-
const handleRowHover = (isHovered) => {
|
|
3151
|
-
setHoveredCheckBox(isHovered);
|
|
3152
|
-
};
|
|
3153
|
-
const isCheckBoxVisible = () => {
|
|
3154
|
-
if (alwaysShowSelector) {
|
|
3155
|
-
return true;
|
|
3156
|
-
}
|
|
3157
|
-
if (table.getIsAllRowsSelected()) {
|
|
3158
|
-
return true;
|
|
3159
|
-
}
|
|
3160
|
-
if (hoveredCheckBox) {
|
|
3161
|
-
return true;
|
|
3162
|
-
}
|
|
3163
|
-
return false;
|
|
3164
|
-
};
|
|
3165
3145
|
const getThProps = (header) => {
|
|
3166
3146
|
const thProps = header.column.getIsPinned()
|
|
3167
3147
|
? {
|
|
@@ -3178,21 +3158,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3178
3158
|
position: "sticky",
|
|
3179
3159
|
top: 0,
|
|
3180
3160
|
};
|
|
3181
|
-
return (jsxRuntime.jsx(react.Table.Header, { ...(isSticky ? stickyProps : {}), ...
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
zIndex: 1,
|
|
3189
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3190
|
-
}
|
|
3191
|
-
: {}),
|
|
3192
|
-
// styling resize and pinning end
|
|
3193
|
-
padding: `${table.getDensityValue()}px`, onMouseEnter: () => handleRowHover(true), onMouseLeave: () => handleRowHover(false), display: "grid", children: [isCheckBoxVisible() && (jsxRuntime.jsx(react.Box, { margin: "0rem", display: "grid", justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, isChecked: table.getIsAllRowsSelected(),
|
|
3194
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3195
|
-
onChange: table.getToggleAllRowsSelectedHandler() }) })), !isCheckBoxVisible() && (jsxRuntime.jsx(react.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) => {
|
|
3161
|
+
return (jsxRuntime.jsx(react.Table.Header, { ...(isSticky ? stickyProps : {}), ...tableHeaderProps, children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsxs(react.Table.Row, { display: "flex", ...tableRowProps, children: [showSelector && (jsxRuntime.jsx(react.Table.ColumnHeader, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3162
|
+
base: "colorPalette.900",
|
|
3163
|
+
_dark: "colorPalette.100",
|
|
3164
|
+
},
|
|
3165
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsxRuntime.jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: table.getIsAllRowsSelected(),
|
|
3166
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3167
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3196
3168
|
const resizeProps = {
|
|
3197
3169
|
onMouseDown: header.getResizeHandler(),
|
|
3198
3170
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3243,21 +3215,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3243
3215
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3244
3216
|
};
|
|
3245
3217
|
|
|
3246
|
-
const
|
|
3247
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3248
|
-
return (jsxRuntime.jsx(react.EmptyState.Root, { ref: ref, ...rest, children: jsxRuntime.jsxs(react.EmptyState.Content, { children: [icon && (jsxRuntime.jsx(react.EmptyState.Indicator, { children: icon })), description ? (jsxRuntime.jsxs(react.VStack, { textAlign: "center", children: [jsxRuntime.jsx(react.EmptyState.Title, { children: title }), jsxRuntime.jsx(react.EmptyState.Description, { children: description })] })) : (jsxRuntime.jsx(react.EmptyState.Title, { children: title })), children] }) }));
|
|
3249
|
-
});
|
|
3250
|
-
|
|
3251
|
-
const EmptyResult = (jsxRuntime.jsx(EmptyState, { icon: jsxRuntime.jsx(hi.HiColorSwatch, {}), title: "No results found", description: "Try adjusting your search", children: jsxRuntime.jsxs(react.List.Root, { variant: "marker", children: [jsxRuntime.jsx(react.List.Item, { children: "Try removing filters" }), jsxRuntime.jsx(react.List.Item, { children: "Try different keywords" })] }) }));
|
|
3252
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3253
|
-
const { table } = useDataTableContext();
|
|
3254
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
3255
|
-
return emptyComponent;
|
|
3256
|
-
}
|
|
3257
|
-
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3258
|
-
};
|
|
3259
|
-
|
|
3260
|
-
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, controlProps = {}, tableFooterProps = {}, variant = "", }) => {
|
|
3218
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3261
3219
|
if (variant === "greedy") {
|
|
3262
3220
|
return (jsxRuntime.jsx(TableControls, { ...controlProps, children: jsxRuntime.jsxs(Table, { canResize: false, ...{ ...tableProps }, children: [jsxRuntime.jsx(TableHeader, { canResize: false, ...tableHeaderProps }), jsxRuntime.jsx(TableBody, { canResize: false, ...tableBodyProps }), showFooter && (jsxRuntime.jsx(TableFooter, { canResize: false, ...tableFooterProps }))] }) }));
|
|
3263
3221
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Tag as Tag$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, CheckboxCard as CheckboxCard$1, Image, EmptyState as EmptyState$2, VStack, Alert, Card,
|
|
2
|
+
import { Button as Button$1, AbsoluteCenter, Spinner, Span, IconButton, Portal, Dialog, Flex, Text, useDisclosure, DialogBackdrop, RadioGroup as RadioGroup$1, Grid, Box, Slider as Slider$1, HStack, For, Tag as Tag$1, Input, Menu, createRecipeContext, createContext as createContext$1, Pagination as Pagination$1, usePaginationContext, CheckboxCard as CheckboxCard$1, Image, EmptyState as EmptyState$2, VStack, Alert, Card, Tooltip as Tooltip$1, Group, InputElement, Icon, List, Table as Table$1, Checkbox as Checkbox$1, MenuRoot as MenuRoot$1, MenuTrigger as MenuTrigger$1, Accordion, Field as Field$1, Popover, NumberInput, Show, RadioCard, CheckboxGroup, Center, Heading } from '@chakra-ui/react';
|
|
3
3
|
import { AiOutlineColumnWidth } from 'react-icons/ai';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { createContext, useContext, useState, useEffect, useRef } from 'react';
|
|
@@ -2897,85 +2897,6 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2897
2897
|
}, children: jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2898
2898
|
}
|
|
2899
2899
|
|
|
2900
|
-
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
2901
|
-
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
2902
|
-
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 }))] }));
|
|
2903
|
-
});
|
|
2904
|
-
|
|
2905
|
-
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
2906
|
-
"use no memo";
|
|
2907
|
-
const { table } = useDataTableContext();
|
|
2908
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2909
|
-
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
2910
|
-
const handleRowHover = (index) => {
|
|
2911
|
-
setHoveredRow(index);
|
|
2912
|
-
};
|
|
2913
|
-
const getTdProps = (cell) => {
|
|
2914
|
-
const tdProps = cell.column.getIsPinned()
|
|
2915
|
-
? {
|
|
2916
|
-
left: showSelector
|
|
2917
|
-
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
2918
|
-
: `${cell.column.getStart("left")}px`,
|
|
2919
|
-
position: "relative",
|
|
2920
|
-
}
|
|
2921
|
-
: {};
|
|
2922
|
-
return tdProps;
|
|
2923
|
-
};
|
|
2924
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2925
|
-
if (hoveredRow === -1) {
|
|
2926
|
-
return {};
|
|
2927
|
-
}
|
|
2928
|
-
if (hoveredRow === index) {
|
|
2929
|
-
return {
|
|
2930
|
-
opacity: "1",
|
|
2931
|
-
};
|
|
2932
|
-
}
|
|
2933
|
-
return {
|
|
2934
|
-
opacity: "0.8",
|
|
2935
|
-
};
|
|
2936
|
-
};
|
|
2937
|
-
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2938
|
-
return (jsxs(Table$1.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow, alwaysShowSelector: alwaysShowSelector })), row.getVisibleCells().map((cell, index) => {
|
|
2939
|
-
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2940
|
-
// styling resize and pinning start
|
|
2941
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
2942
|
-
base: "colorPalette.900",
|
|
2943
|
-
_dark: "colorPalette.100",
|
|
2944
|
-
},
|
|
2945
|
-
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2946
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
2947
|
-
}) }));
|
|
2948
|
-
};
|
|
2949
|
-
const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, alwaysShowSelector = true, }) => {
|
|
2950
|
-
const { table } = useDataTableContext();
|
|
2951
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2952
|
-
const isCheckBoxVisible = (current_index, current_row) => {
|
|
2953
|
-
if (alwaysShowSelector) {
|
|
2954
|
-
return true;
|
|
2955
|
-
}
|
|
2956
|
-
if (current_row.getIsSelected()) {
|
|
2957
|
-
return true;
|
|
2958
|
-
}
|
|
2959
|
-
if (hoveredRow == current_index) {
|
|
2960
|
-
return true;
|
|
2961
|
-
}
|
|
2962
|
-
return false;
|
|
2963
|
-
};
|
|
2964
|
-
return (jsxs(Table$1.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
2965
|
-
? {
|
|
2966
|
-
left: `0px`,
|
|
2967
|
-
backgroundColor: pinnedBgColor.light,
|
|
2968
|
-
position: "sticky",
|
|
2969
|
-
zIndex: 1,
|
|
2970
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
2971
|
-
}
|
|
2972
|
-
: {}),
|
|
2973
|
-
// styling resize and pinning end
|
|
2974
|
-
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(),
|
|
2975
|
-
disabled: !row.getCanSelect(),
|
|
2976
|
-
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
2977
|
-
};
|
|
2978
|
-
|
|
2979
2900
|
const Tooltip = React.forwardRef(function Tooltip(props, ref) {
|
|
2980
2901
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
2981
2902
|
if (disabled)
|
|
@@ -3063,6 +2984,81 @@ const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children
|
|
|
3063
2984
|
}, children: children }), jsxs(Flex, { justifyContent: "space-between", children: [jsxs(Flex, { gap: "1rem", alignItems: "center", children: [showPageSizeControl && jsx(PageSizeControl, {}), showPageCountText && (jsxs(Flex, { children: [jsx(Text, { paddingRight: "0.5rem", children: translate.t("rowcount.total") }), jsx(RowCountText, {})] }))] }), jsx(Box, { justifySelf: "end", children: showPagination && jsx(Pagination, {}) })] })] }));
|
|
3064
2985
|
};
|
|
3065
2986
|
|
|
2987
|
+
const EmptyState = React.forwardRef(function EmptyState(props, ref) {
|
|
2988
|
+
const { title, description, icon, children, ...rest } = props;
|
|
2989
|
+
return (jsx(EmptyState$2.Root, { ref: ref, ...rest, children: jsxs(EmptyState$2.Content, { children: [icon && (jsx(EmptyState$2.Indicator, { children: icon })), description ? (jsxs(VStack, { textAlign: "center", children: [jsx(EmptyState$2.Title, { children: title }), jsx(EmptyState$2.Description, { children: description })] })) : (jsx(EmptyState$2.Title, { children: title })), children] }) }));
|
|
2990
|
+
});
|
|
2991
|
+
|
|
2992
|
+
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" })] }) }));
|
|
2993
|
+
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
2994
|
+
const { table } = useDataTableContext();
|
|
2995
|
+
if (table.getRowModel().rows.length <= 0) {
|
|
2996
|
+
return emptyComponent;
|
|
2997
|
+
}
|
|
2998
|
+
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
2999
|
+
};
|
|
3000
|
+
|
|
3001
|
+
const Checkbox = React.forwardRef(function Checkbox(props, ref) {
|
|
3002
|
+
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
3003
|
+
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 }))] }));
|
|
3004
|
+
});
|
|
3005
|
+
|
|
3006
|
+
const TableBody = ({ showSelector = false, alwaysShowSelector = true, canResize = true, }) => {
|
|
3007
|
+
"use no memo";
|
|
3008
|
+
const { table } = useDataTableContext();
|
|
3009
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3010
|
+
const [hoveredRow, setHoveredRow] = useState(-1);
|
|
3011
|
+
const handleRowHover = (index) => {
|
|
3012
|
+
setHoveredRow(index);
|
|
3013
|
+
};
|
|
3014
|
+
const getTdProps = (cell) => {
|
|
3015
|
+
const tdProps = cell.column.getIsPinned()
|
|
3016
|
+
? {
|
|
3017
|
+
left: showSelector
|
|
3018
|
+
? `${cell.column.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3019
|
+
: `${cell.column.getStart("left")}px`,
|
|
3020
|
+
position: "relative",
|
|
3021
|
+
}
|
|
3022
|
+
: {};
|
|
3023
|
+
return tdProps;
|
|
3024
|
+
};
|
|
3025
|
+
const getTrProps = ({ hoveredRow, index, }) => {
|
|
3026
|
+
if (hoveredRow === -1) {
|
|
3027
|
+
return {};
|
|
3028
|
+
}
|
|
3029
|
+
if (hoveredRow === index) {
|
|
3030
|
+
return {
|
|
3031
|
+
opacity: "1",
|
|
3032
|
+
};
|
|
3033
|
+
}
|
|
3034
|
+
return {
|
|
3035
|
+
opacity: "0.8",
|
|
3036
|
+
};
|
|
3037
|
+
};
|
|
3038
|
+
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
3039
|
+
return (jsxs(Table$1.Row, { display: "flex", zIndex: 1, onMouseEnter: () => handleRowHover(index), onMouseLeave: () => handleRowHover(-1), ...getTrProps({ hoveredRow, index }), children: [showSelector && (jsx(TableRowSelector, { index: index, row: row, hoveredRow: hoveredRow })), row.getVisibleCells().map((cell, index) => {
|
|
3040
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
3041
|
+
// styling resize and pinning start
|
|
3042
|
+
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, color: {
|
|
3043
|
+
base: "colorPalette.900",
|
|
3044
|
+
_dark: "colorPalette.100",
|
|
3045
|
+
},
|
|
3046
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, ...getTdProps(cell), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
3047
|
+
})] }, `chakra-table-row-${row.id}`));
|
|
3048
|
+
}) }));
|
|
3049
|
+
};
|
|
3050
|
+
const TableRowSelector = ({ index, row, }) => {
|
|
3051
|
+
const { table } = useDataTableContext();
|
|
3052
|
+
const SELECTION_BOX_WIDTH = 20;
|
|
3053
|
+
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3054
|
+
base: "colorPalette.900",
|
|
3055
|
+
_dark: "colorPalette.100",
|
|
3056
|
+
},
|
|
3057
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: row.getIsSelected(),
|
|
3058
|
+
disabled: !row.getCanSelect(),
|
|
3059
|
+
onCheckedChange: row.getToggleSelectedHandler() }) }));
|
|
3060
|
+
};
|
|
3061
|
+
|
|
3066
3062
|
const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
|
|
3067
3063
|
const table = useDataTableContext().table;
|
|
3068
3064
|
const SELECTION_BOX_WIDTH = 20;
|
|
@@ -3123,25 +3119,9 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3123
3119
|
jsx(Fragment, {})), header.column.getIsSorted() === "asc" && (jsx(BiUpArrow, {})), header.column.getIsSorted() === "desc" && (jsx(BiDownArrow, {}))] })) })] }) }) }) }) }, `chakra-table-footer-${header.column.id}-${footerGroup.id}`)))] }, `chakra-table-footergroup-${footerGroup.id}`))) }));
|
|
3124
3120
|
};
|
|
3125
3121
|
|
|
3126
|
-
const TableHeader = ({ canResize = true,
|
|
3122
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3127
3123
|
const { table } = useDataTableContext();
|
|
3128
3124
|
const SELECTION_BOX_WIDTH = 20;
|
|
3129
|
-
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
3130
|
-
const handleRowHover = (isHovered) => {
|
|
3131
|
-
setHoveredCheckBox(isHovered);
|
|
3132
|
-
};
|
|
3133
|
-
const isCheckBoxVisible = () => {
|
|
3134
|
-
if (alwaysShowSelector) {
|
|
3135
|
-
return true;
|
|
3136
|
-
}
|
|
3137
|
-
if (table.getIsAllRowsSelected()) {
|
|
3138
|
-
return true;
|
|
3139
|
-
}
|
|
3140
|
-
if (hoveredCheckBox) {
|
|
3141
|
-
return true;
|
|
3142
|
-
}
|
|
3143
|
-
return false;
|
|
3144
|
-
};
|
|
3145
3125
|
const getThProps = (header) => {
|
|
3146
3126
|
const thProps = header.column.getIsPinned()
|
|
3147
3127
|
? {
|
|
@@ -3158,21 +3138,13 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3158
3138
|
position: "sticky",
|
|
3159
3139
|
top: 0,
|
|
3160
3140
|
};
|
|
3161
|
-
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), ...
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
zIndex: 1,
|
|
3169
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3170
|
-
}
|
|
3171
|
-
: {}),
|
|
3172
|
-
// styling resize and pinning end
|
|
3173
|
-
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(),
|
|
3174
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3175
|
-
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) => {
|
|
3141
|
+
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), ...tableHeaderProps, children: table.getHeaderGroups().map((headerGroup) => (jsxs(Table$1.Row, { display: "flex", ...tableRowProps, children: [showSelector && (jsx(Table$1.ColumnHeader, { padding: `${table.getDensityValue()}px`, display: "grid", color: {
|
|
3142
|
+
base: "colorPalette.900",
|
|
3143
|
+
_dark: "colorPalette.100",
|
|
3144
|
+
},
|
|
3145
|
+
bg: { base: "colorPalette.50", _dark: "colorPalette.950" }, justifyItems: "center", alignItems: "center", children: jsx(Checkbox, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px`, checked: table.getIsAllRowsSelected(),
|
|
3146
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3147
|
+
onChange: table.getToggleAllRowsSelectedHandler() }) })), headerGroup.headers.map((header) => {
|
|
3176
3148
|
const resizeProps = {
|
|
3177
3149
|
onMouseDown: header.getResizeHandler(),
|
|
3178
3150
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3223,21 +3195,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3223
3195
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3224
3196
|
};
|
|
3225
3197
|
|
|
3226
|
-
const
|
|
3227
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3228
|
-
return (jsx(EmptyState$2.Root, { ref: ref, ...rest, children: jsxs(EmptyState$2.Content, { children: [icon && (jsx(EmptyState$2.Indicator, { children: icon })), description ? (jsxs(VStack, { textAlign: "center", children: [jsx(EmptyState$2.Title, { children: title }), jsx(EmptyState$2.Description, { children: description })] })) : (jsx(EmptyState$2.Title, { children: title })), children] }) }));
|
|
3229
|
-
});
|
|
3230
|
-
|
|
3231
|
-
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" })] }) }));
|
|
3232
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3233
|
-
const { table } = useDataTableContext();
|
|
3234
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
3235
|
-
return emptyComponent;
|
|
3236
|
-
}
|
|
3237
|
-
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3238
|
-
};
|
|
3239
|
-
|
|
3240
|
-
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, controlProps = {}, tableFooterProps = {}, variant = "", }) => {
|
|
3198
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3241
3199
|
if (variant === "greedy") {
|
|
3242
3200
|
return (jsx(TableControls, { ...controlProps, children: jsxs(Table, { canResize: false, ...{ ...tableProps }, children: [jsx(TableHeader, { canResize: false, ...tableHeaderProps }), jsx(TableBody, { canResize: false, ...tableBodyProps }), showFooter && (jsx(TableFooter, { canResize: false, ...tableFooterProps }))] }) }));
|
|
3243
3201
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { TableHeaderProps as ChakraHeaderProps } from "@chakra-ui/react";
|
|
2
|
-
import { TableBodyProps } from "./display/TableBody";
|
|
3
1
|
import { TableControlsProps } from "./controls/TableControls";
|
|
2
|
+
import { TableProps } from "./display/Table";
|
|
3
|
+
import { TableBodyProps } from "./display/TableBody";
|
|
4
4
|
import { TableFooterProps } from "./display/TableFooter";
|
|
5
5
|
import { TableHeaderProps } from "./display/TableHeader";
|
|
6
|
-
import { TableProps } from "./display/Table";
|
|
7
6
|
export interface DefaultTableProps {
|
|
8
7
|
showFooter?: boolean;
|
|
9
|
-
showSelector?: boolean;
|
|
10
8
|
tableProps?: Omit<TableProps, "children">;
|
|
11
|
-
tHeadProps?: ChakraHeaderProps;
|
|
12
|
-
controlProps?: TableControlsProps;
|
|
13
|
-
tableFooterProps?: TableFooterProps;
|
|
14
|
-
tableBodyProps?: TableBodyProps;
|
|
15
9
|
tableHeaderProps?: TableHeaderProps;
|
|
10
|
+
tableBodyProps?: TableBodyProps;
|
|
11
|
+
tableFooterProps?: TableFooterProps;
|
|
12
|
+
controlProps?: TableControlsProps;
|
|
16
13
|
variant?: "" | "greedy";
|
|
17
14
|
}
|
|
18
|
-
export declare const DefaultTable: ({ showFooter, tableProps, tableHeaderProps, tableBodyProps,
|
|
15
|
+
export declare const DefaultTable: ({ showFooter, tableProps, tableHeaderProps, tableBodyProps, tableFooterProps, controlProps, variant, }: DefaultTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { TableHeaderProps as ChakraTableHeaderProps } from "@chakra-ui/react";
|
|
1
|
+
import { TableHeaderProps as ChakraTableHeaderProps, TableRowProps } from "@chakra-ui/react";
|
|
2
2
|
export interface TableHeaderProps {
|
|
3
3
|
canResize?: boolean;
|
|
4
|
-
pinnedBgColor?: {
|
|
5
|
-
light: string;
|
|
6
|
-
dark: string;
|
|
7
|
-
};
|
|
8
4
|
showSelector?: boolean;
|
|
9
5
|
isSticky?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
tableHeaderProps?: ChakraTableHeaderProps;
|
|
7
|
+
tableRowProps?: TableRowProps;
|
|
12
8
|
}
|
|
13
|
-
export declare const TableHeader: ({ canResize,
|
|
9
|
+
export declare const TableHeader: ({ canResize, showSelector, isSticky, tableHeaderProps, tableRowProps, }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
|