@bsol-oss/react-datatable5 12.0.0-beta.16 → 12.0.0-beta.18
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 +35 -41
- package/dist/index.js +88 -136
- package/dist/index.mjs +89 -137
- package/dist/types/components/DataTable/DefaultTable.d.ts +6 -9
- package/dist/types/components/DataTable/display/TableBody.d.ts +1 -1
- package/dist/types/components/DataTable/display/TableHeader.d.ts +4 -8
- package/package.json +1 -1
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: ({ pinnedBgColor, 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,88 +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 = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, 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
|
-
background: pinnedBgColor.light,
|
|
2940
|
-
position: "sticky",
|
|
2941
|
-
zIndex: -1,
|
|
2942
|
-
_dark: {
|
|
2943
|
-
backgroundColor: pinnedBgColor.dark,
|
|
2944
|
-
},
|
|
2945
|
-
}
|
|
2946
|
-
: {};
|
|
2947
|
-
return tdProps;
|
|
2948
|
-
};
|
|
2949
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2950
|
-
if (hoveredRow === -1) {
|
|
2951
|
-
return {};
|
|
2952
|
-
}
|
|
2953
|
-
if (hoveredRow === index) {
|
|
2954
|
-
return {
|
|
2955
|
-
opacity: "1",
|
|
2956
|
-
};
|
|
2957
|
-
}
|
|
2958
|
-
return {
|
|
2959
|
-
opacity: "0.8",
|
|
2960
|
-
};
|
|
2961
|
-
};
|
|
2962
|
-
return (jsxRuntime.jsx(react.Table.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2963
|
-
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) => {
|
|
2964
|
-
return (jsxRuntime.jsx(react.Table.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2965
|
-
// styling resize and pinning start
|
|
2966
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, backgroundColor: "white", ...getTdProps(cell), _dark: {
|
|
2967
|
-
backgroundColor: "gray.950",
|
|
2968
|
-
}, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2969
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
2970
|
-
}) }));
|
|
2971
|
-
};
|
|
2972
|
-
const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, alwaysShowSelector = true, }) => {
|
|
2973
|
-
const { table } = useDataTableContext();
|
|
2974
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2975
|
-
const isCheckBoxVisible = (current_index, current_row) => {
|
|
2976
|
-
if (alwaysShowSelector) {
|
|
2977
|
-
return true;
|
|
2978
|
-
}
|
|
2979
|
-
if (current_row.getIsSelected()) {
|
|
2980
|
-
return true;
|
|
2981
|
-
}
|
|
2982
|
-
if (hoveredRow == current_index) {
|
|
2983
|
-
return true;
|
|
2984
|
-
}
|
|
2985
|
-
return false;
|
|
2986
|
-
};
|
|
2987
|
-
return (jsxRuntime.jsxs(react.Table.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
2988
|
-
? {
|
|
2989
|
-
left: `0px`,
|
|
2990
|
-
backgroundColor: pinnedBgColor.light,
|
|
2991
|
-
position: "sticky",
|
|
2992
|
-
zIndex: 1,
|
|
2993
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
2994
|
-
}
|
|
2995
|
-
: {}),
|
|
2996
|
-
// styling resize and pinning end
|
|
2997
|
-
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(),
|
|
2998
|
-
disabled: !row.getCanSelect(),
|
|
2999
|
-
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
3000
|
-
};
|
|
3001
|
-
|
|
3002
2920
|
const Tooltip = React__namespace.forwardRef(function Tooltip(props, ref) {
|
|
3003
2921
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
3004
2922
|
if (disabled)
|
|
@@ -3086,6 +3004,81 @@ const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children
|
|
|
3086
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, {}) })] })] }));
|
|
3087
3005
|
};
|
|
3088
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
|
+
|
|
3089
3082
|
const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
|
|
3090
3083
|
const table = useDataTableContext().table;
|
|
3091
3084
|
const SELECTION_BOX_WIDTH = 20;
|
|
@@ -3146,37 +3139,17 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3146
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}`))) }));
|
|
3147
3140
|
};
|
|
3148
3141
|
|
|
3149
|
-
const TableHeader = ({ canResize = true,
|
|
3142
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3150
3143
|
const { table } = useDataTableContext();
|
|
3151
3144
|
const SELECTION_BOX_WIDTH = 20;
|
|
3152
|
-
const [hoveredCheckBox, setHoveredCheckBox] = React.useState(false);
|
|
3153
|
-
const handleRowHover = (isHovered) => {
|
|
3154
|
-
setHoveredCheckBox(isHovered);
|
|
3155
|
-
};
|
|
3156
|
-
const isCheckBoxVisible = () => {
|
|
3157
|
-
if (alwaysShowSelector) {
|
|
3158
|
-
return true;
|
|
3159
|
-
}
|
|
3160
|
-
if (table.getIsAllRowsSelected()) {
|
|
3161
|
-
return true;
|
|
3162
|
-
}
|
|
3163
|
-
if (hoveredCheckBox) {
|
|
3164
|
-
return true;
|
|
3165
|
-
}
|
|
3166
|
-
return false;
|
|
3167
|
-
};
|
|
3168
3145
|
const getThProps = (header) => {
|
|
3169
3146
|
const thProps = header.column.getIsPinned()
|
|
3170
3147
|
? {
|
|
3171
3148
|
left: showSelector
|
|
3172
3149
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3173
3150
|
: `${header.getStart("left")}px`,
|
|
3174
|
-
background: pinnedBgColor.light,
|
|
3175
3151
|
position: "sticky",
|
|
3176
3152
|
zIndex: 100 + 1,
|
|
3177
|
-
_dark: {
|
|
3178
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3179
|
-
},
|
|
3180
3153
|
}
|
|
3181
3154
|
: {};
|
|
3182
3155
|
return thProps;
|
|
@@ -3185,21 +3158,11 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3185
3158
|
position: "sticky",
|
|
3186
3159
|
top: 0,
|
|
3187
3160
|
};
|
|
3188
|
-
return (jsxRuntime.jsx(react.Table.Header, { ...(isSticky ? stickyProps : {}), ...
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
backgroundColor: pinnedBgColor.light,
|
|
3194
|
-
position: "sticky",
|
|
3195
|
-
zIndex: 1,
|
|
3196
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3197
|
-
}
|
|
3198
|
-
: {}),
|
|
3199
|
-
// styling resize and pinning end
|
|
3200
|
-
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(),
|
|
3201
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3202
|
-
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(react.Box, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }) })), headerGroup.headers.map((header) => {
|
|
3203
3166
|
const resizeProps = {
|
|
3204
3167
|
onMouseDown: header.getResizeHandler(),
|
|
3205
3168
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3207,7 +3170,11 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3207
3170
|
};
|
|
3208
3171
|
return (jsxRuntime.jsxs(react.Table.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3209
3172
|
// styling resize and pinning start
|
|
3210
|
-
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index,
|
|
3173
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3174
|
+
base: "colorPalette.800",
|
|
3175
|
+
_dark: "colorPalette.200",
|
|
3176
|
+
},
|
|
3177
|
+
bg: { base: "colorPalette.100", _dark: "colorPalette.900" }, ...getThProps(header), children: [jsxRuntime.jsxs(MenuRoot, { children: [jsxRuntime.jsx(MenuTrigger, { asChild: true, children: jsxRuntime.jsx(react.Flex, { padding: `${table.getDensityValue()}px`, alignItems: "center", justifyContent: "start", borderRadius: "0rem", overflow: "auto", _hover: {
|
|
3211
3178
|
backgroundColor: "gray.100",
|
|
3212
3179
|
_dark: {
|
|
3213
3180
|
backgroundColor: "gray.700",
|
|
@@ -3246,21 +3213,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3246
3213
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3247
3214
|
};
|
|
3248
3215
|
|
|
3249
|
-
const
|
|
3250
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3251
|
-
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] }) }));
|
|
3252
|
-
});
|
|
3253
|
-
|
|
3254
|
-
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" })] }) }));
|
|
3255
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3256
|
-
const { table } = useDataTableContext();
|
|
3257
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
3258
|
-
return emptyComponent;
|
|
3259
|
-
}
|
|
3260
|
-
return (jsxRuntime.jsx(react.Table.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3261
|
-
};
|
|
3262
|
-
|
|
3263
|
-
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, controlProps = {}, tableFooterProps = {}, variant = "", }) => {
|
|
3216
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3264
3217
|
if (variant === "greedy") {
|
|
3265
3218
|
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 }))] }) }));
|
|
3266
3219
|
}
|
|
@@ -3871,7 +3824,6 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3871
3824
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: "undefined" });
|
|
3872
3825
|
}
|
|
3873
3826
|
return (jsxRuntime.jsx(Tag, { closable: true, onClick: () => {
|
|
3874
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3875
3827
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3876
3828
|
}, children: !!renderDisplay === true
|
|
3877
3829
|
? renderDisplay(item)
|
|
@@ -3882,7 +3834,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3882
3834
|
setOpenSearchResult(true);
|
|
3883
3835
|
}, children: watchEnum === undefined
|
|
3884
3836
|
? ""
|
|
3885
|
-
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsxRuntime.jsx(react.Input, { placeholder: translate.t(`${column}.
|
|
3837
|
+
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxRuntime.jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsxRuntime.jsx(PopoverTrigger, {}), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsxRuntime.jsx(react.Input, { placeholder: translate.t(`${column}.type_to_search`), onChange: (event) => {
|
|
3886
3838
|
onSearchChange(event);
|
|
3887
3839
|
setOpenSearchResult(true);
|
|
3888
3840
|
}, autoComplete: "off", ref: ref }), jsxRuntime.jsx(PopoverTitle, {}), jsxRuntime.jsx(react.Text, { children: `${translate.t(`${column}.total`)}: ${count}, ${translate.t(`${column}.showing`)} ${limit}` }), jsxRuntime.jsxs(react.Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsxRuntime.jsx(react.Flex, { flexFlow: "column wrap", children: filterArray(dataList, searchText ?? "").map((item) => {
|
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,88 +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 = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, 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
|
-
background: pinnedBgColor.light,
|
|
2920
|
-
position: "sticky",
|
|
2921
|
-
zIndex: -1,
|
|
2922
|
-
_dark: {
|
|
2923
|
-
backgroundColor: pinnedBgColor.dark,
|
|
2924
|
-
},
|
|
2925
|
-
}
|
|
2926
|
-
: {};
|
|
2927
|
-
return tdProps;
|
|
2928
|
-
};
|
|
2929
|
-
const getTrProps = ({ hoveredRow, index, }) => {
|
|
2930
|
-
if (hoveredRow === -1) {
|
|
2931
|
-
return {};
|
|
2932
|
-
}
|
|
2933
|
-
if (hoveredRow === index) {
|
|
2934
|
-
return {
|
|
2935
|
-
opacity: "1",
|
|
2936
|
-
};
|
|
2937
|
-
}
|
|
2938
|
-
return {
|
|
2939
|
-
opacity: "0.8",
|
|
2940
|
-
};
|
|
2941
|
-
};
|
|
2942
|
-
return (jsx(Table$1.Body, { children: table.getRowModel().rows.map((row, index) => {
|
|
2943
|
-
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) => {
|
|
2944
|
-
return (jsx(Table$1.Cell, { padding: `${table.getDensityValue()}px`,
|
|
2945
|
-
// styling resize and pinning start
|
|
2946
|
-
flex: `${canResize ? "0" : "1"} 0 ${cell.column.getSize()}px`, backgroundColor: "white", ...getTdProps(cell), _dark: {
|
|
2947
|
-
backgroundColor: "gray.950",
|
|
2948
|
-
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `chakra-table-rowcell-${cell.id}-${index}`));
|
|
2949
|
-
})] }, `chakra-table-row-${row.id}`));
|
|
2950
|
-
}) }));
|
|
2951
|
-
};
|
|
2952
|
-
const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, alwaysShowSelector = true, }) => {
|
|
2953
|
-
const { table } = useDataTableContext();
|
|
2954
|
-
const SELECTION_BOX_WIDTH = 20;
|
|
2955
|
-
const isCheckBoxVisible = (current_index, current_row) => {
|
|
2956
|
-
if (alwaysShowSelector) {
|
|
2957
|
-
return true;
|
|
2958
|
-
}
|
|
2959
|
-
if (current_row.getIsSelected()) {
|
|
2960
|
-
return true;
|
|
2961
|
-
}
|
|
2962
|
-
if (hoveredRow == current_index) {
|
|
2963
|
-
return true;
|
|
2964
|
-
}
|
|
2965
|
-
return false;
|
|
2966
|
-
};
|
|
2967
|
-
return (jsxs(Table$1.Cell, { padding: `${table.getDensityValue()}px`, ...(table.getIsSomeColumnsPinned("left")
|
|
2968
|
-
? {
|
|
2969
|
-
left: `0px`,
|
|
2970
|
-
backgroundColor: pinnedBgColor.light,
|
|
2971
|
-
position: "sticky",
|
|
2972
|
-
zIndex: 1,
|
|
2973
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
2974
|
-
}
|
|
2975
|
-
: {}),
|
|
2976
|
-
// styling resize and pinning end
|
|
2977
|
-
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(),
|
|
2978
|
-
disabled: !row.getCanSelect(),
|
|
2979
|
-
onChange: row.getToggleSelectedHandler() }) }))] }));
|
|
2980
|
-
};
|
|
2981
|
-
|
|
2982
2900
|
const Tooltip = React.forwardRef(function Tooltip(props, ref) {
|
|
2983
2901
|
const { showArrow, children, disabled, portalled, content, contentProps, portalRef, ...rest } = props;
|
|
2984
2902
|
if (disabled)
|
|
@@ -3066,6 +2984,81 @@ const TableControls = ({ fitTableWidth = false, fitTableHeight = false, children
|
|
|
3066
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, {}) })] })] }));
|
|
3067
2985
|
};
|
|
3068
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
|
+
|
|
3069
3062
|
const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, showSelector = false, alwaysShowSelector = true, }) => {
|
|
3070
3063
|
const table = useDataTableContext().table;
|
|
3071
3064
|
const SELECTION_BOX_WIDTH = 20;
|
|
@@ -3126,37 +3119,17 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, s
|
|
|
3126
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}`))) }));
|
|
3127
3120
|
};
|
|
3128
3121
|
|
|
3129
|
-
const TableHeader = ({ canResize = true,
|
|
3122
|
+
const TableHeader = ({ canResize = true, showSelector = false, isSticky = true, tableHeaderProps = {}, tableRowProps = {}, }) => {
|
|
3130
3123
|
const { table } = useDataTableContext();
|
|
3131
3124
|
const SELECTION_BOX_WIDTH = 20;
|
|
3132
|
-
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
3133
|
-
const handleRowHover = (isHovered) => {
|
|
3134
|
-
setHoveredCheckBox(isHovered);
|
|
3135
|
-
};
|
|
3136
|
-
const isCheckBoxVisible = () => {
|
|
3137
|
-
if (alwaysShowSelector) {
|
|
3138
|
-
return true;
|
|
3139
|
-
}
|
|
3140
|
-
if (table.getIsAllRowsSelected()) {
|
|
3141
|
-
return true;
|
|
3142
|
-
}
|
|
3143
|
-
if (hoveredCheckBox) {
|
|
3144
|
-
return true;
|
|
3145
|
-
}
|
|
3146
|
-
return false;
|
|
3147
|
-
};
|
|
3148
3125
|
const getThProps = (header) => {
|
|
3149
3126
|
const thProps = header.column.getIsPinned()
|
|
3150
3127
|
? {
|
|
3151
3128
|
left: showSelector
|
|
3152
3129
|
? `${header.getStart("left") + SELECTION_BOX_WIDTH + table.getDensityValue() * 2}px`
|
|
3153
3130
|
: `${header.getStart("left")}px`,
|
|
3154
|
-
background: pinnedBgColor.light,
|
|
3155
3131
|
position: "sticky",
|
|
3156
3132
|
zIndex: 100 + 1,
|
|
3157
|
-
_dark: {
|
|
3158
|
-
backgroundColor: pinnedBgColor.dark,
|
|
3159
|
-
},
|
|
3160
3133
|
}
|
|
3161
3134
|
: {};
|
|
3162
3135
|
return thProps;
|
|
@@ -3165,21 +3138,11 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3165
3138
|
position: "sticky",
|
|
3166
3139
|
top: 0,
|
|
3167
3140
|
};
|
|
3168
|
-
return (jsx(Table$1.Header, { ...(isSticky ? stickyProps : {}), ...
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
backgroundColor: pinnedBgColor.light,
|
|
3174
|
-
position: "sticky",
|
|
3175
|
-
zIndex: 1,
|
|
3176
|
-
_dark: { backgroundColor: pinnedBgColor.dark },
|
|
3177
|
-
}
|
|
3178
|
-
: {}),
|
|
3179
|
-
// styling resize and pinning end
|
|
3180
|
-
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(),
|
|
3181
|
-
// indeterminate: table.getIsSomeRowsSelected(),
|
|
3182
|
-
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(Box, { width: `${SELECTION_BOX_WIDTH}px`, height: `${SELECTION_BOX_WIDTH}px` }) })), headerGroup.headers.map((header) => {
|
|
3183
3146
|
const resizeProps = {
|
|
3184
3147
|
onMouseDown: header.getResizeHandler(),
|
|
3185
3148
|
onTouchStart: header.getResizeHandler(),
|
|
@@ -3187,7 +3150,11 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3187
3150
|
};
|
|
3188
3151
|
return (jsxs(Table$1.ColumnHeader, { padding: 0, columnSpan: `${header.colSpan}`,
|
|
3189
3152
|
// styling resize and pinning start
|
|
3190
|
-
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index,
|
|
3153
|
+
flex: `${canResize ? "0" : "1"} 0 ${header.column.getSize()}px`, display: "grid", gridTemplateColumns: "1fr auto", zIndex: 1500 + header.index, color: {
|
|
3154
|
+
base: "colorPalette.800",
|
|
3155
|
+
_dark: "colorPalette.200",
|
|
3156
|
+
},
|
|
3157
|
+
bg: { base: "colorPalette.100", _dark: "colorPalette.900" }, ...getThProps(header), children: [jsxs(MenuRoot, { children: [jsx(MenuTrigger, { asChild: true, children: jsx(Flex, { padding: `${table.getDensityValue()}px`, alignItems: "center", justifyContent: "start", borderRadius: "0rem", overflow: "auto", _hover: {
|
|
3191
3158
|
backgroundColor: "gray.100",
|
|
3192
3159
|
_dark: {
|
|
3193
3160
|
backgroundColor: "gray.700",
|
|
@@ -3226,21 +3193,7 @@ const TableHeader = ({ canResize = true, pinnedBgColor = { light: "gray.50", dar
|
|
|
3226
3193
|
})] }, `chakra-table-headergroup-${headerGroup.id}`))) }));
|
|
3227
3194
|
};
|
|
3228
3195
|
|
|
3229
|
-
const
|
|
3230
|
-
const { title, description, icon, children, ...rest } = props;
|
|
3231
|
-
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] }) }));
|
|
3232
|
-
});
|
|
3233
|
-
|
|
3234
|
-
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" })] }) }));
|
|
3235
|
-
const Table = ({ children, emptyComponent = EmptyResult, canResize = true, ...props }) => {
|
|
3236
|
-
const { table } = useDataTableContext();
|
|
3237
|
-
if (table.getRowModel().rows.length <= 0) {
|
|
3238
|
-
return emptyComponent;
|
|
3239
|
-
}
|
|
3240
|
-
return (jsx(Table$1.Root, { stickyHeader: true, variant: "outline", width: canResize ? table.getCenterTotalSize() : undefined, display: "grid", alignContent: "start", overflowY: "auto", ...props, children: children }));
|
|
3241
|
-
};
|
|
3242
|
-
|
|
3243
|
-
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, controlProps = {}, tableFooterProps = {}, variant = "", }) => {
|
|
3196
|
+
const DefaultTable = ({ showFooter = false, tableProps = {}, tableHeaderProps = {}, tableBodyProps = {}, tableFooterProps = {}, controlProps = {}, variant = "", }) => {
|
|
3244
3197
|
if (variant === "greedy") {
|
|
3245
3198
|
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 }))] }) }));
|
|
3246
3199
|
}
|
|
@@ -3851,7 +3804,6 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3851
3804
|
return jsx(Fragment, { children: "undefined" });
|
|
3852
3805
|
}
|
|
3853
3806
|
return (jsx(Tag, { closable: true, onClick: () => {
|
|
3854
|
-
// setSelectedEnums((state) => state.filter((id) => id != item));
|
|
3855
3807
|
setValue(column, watchEnums.filter((id) => id != item));
|
|
3856
3808
|
}, children: !!renderDisplay === true
|
|
3857
3809
|
? renderDisplay(item)
|
|
@@ -3862,7 +3814,7 @@ const EnumPicker = ({ column, isMultiple = false, schema, prefix, }) => {
|
|
|
3862
3814
|
setOpenSearchResult(true);
|
|
3863
3815
|
}, children: watchEnum === undefined
|
|
3864
3816
|
? ""
|
|
3865
|
-
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsx(PopoverTrigger, {}), jsx(PopoverContent, { children: jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsx(Input, { placeholder: translate.t(`${column}.
|
|
3817
|
+
: translate.t(removeIndex(`${colLabel}.${watchEnum}`)) })), jsxs(PopoverRoot, { open: openSearchResult, onOpenChange: (e) => setOpenSearchResult(e.open), closeOnInteractOutside: true, initialFocusEl: () => ref.current, positioning: { placement: "bottom-start" }, children: [jsx(PopoverTrigger, {}), jsx(PopoverContent, { children: jsxs(PopoverBody, { display: "grid", gap: 1, children: [jsx(Input, { placeholder: translate.t(`${column}.type_to_search`), onChange: (event) => {
|
|
3866
3818
|
onSearchChange(event);
|
|
3867
3819
|
setOpenSearchResult(true);
|
|
3868
3820
|
}, autoComplete: "off", ref: ref }), jsx(PopoverTitle, {}), jsx(Text, { children: `${translate.t(`${column}.total`)}: ${count}, ${translate.t(`${column}.showing`)} ${limit}` }), jsxs(Grid, { gridTemplateColumns: "repeat(auto-fit, minmax(15rem, 1fr))", overflow: "auto", maxHeight: "50vh", children: [jsx(Flex, { flexFlow: "column wrap", children: filterArray(dataList, searchText ?? "").map((item) => {
|
|
@@ -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;
|
|
@@ -18,4 +18,4 @@ export interface TableRowSelectorProps<TData> {
|
|
|
18
18
|
};
|
|
19
19
|
alwaysShowSelector?: boolean;
|
|
20
20
|
}
|
|
21
|
-
export declare const TableBody: ({
|
|
21
|
+
export declare const TableBody: ({ showSelector, alwaysShowSelector, canResize, }: TableBodyProps) => 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;
|