@bsol-oss/react-datatable5 12.0.0-beta.7 → 12.0.0-beta.9
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
|
@@ -441,6 +441,11 @@ interface GetColumnsConfigs<K extends RowData> {
|
|
|
441
441
|
declare const widthSanityCheck: <K extends unknown>(widthList: number[], ignoreList: K[], properties: { [key in K as string]?: object | undefined; }) => void;
|
|
442
442
|
declare const getColumns: <TData extends unknown>({ schema, include, ignore, width, meta, defaultWidth, translate, }: GetColumnsConfigs<TData>) => ColumnDef<TData>[];
|
|
443
443
|
|
|
444
|
+
interface TableDataDisplayProps {
|
|
445
|
+
colorPalette?: string;
|
|
446
|
+
}
|
|
447
|
+
declare const TableDataDisplay: ({ colorPalette }: TableDataDisplayProps) => react_jsx_runtime.JSX.Element;
|
|
448
|
+
|
|
444
449
|
interface FilterOptionsProps {
|
|
445
450
|
column: string;
|
|
446
451
|
}
|
|
@@ -612,4 +617,4 @@ declare module "@tanstack/react-table" {
|
|
|
612
617
|
}
|
|
613
618
|
}
|
|
614
619
|
|
|
615
|
-
export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerProps, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, FilterDialog, FilterOptions, type FilterOptionsProps, FormBody, FormRoot, type FormRootProps, FormTitle, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, Pagination, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
|
|
620
|
+
export { type CalendarProps, CardHeader, type CardHeaderProps, type CustomJSONSchema7Definition, DataDisplay, type DataDisplayProps, type DataResponse, DataTable, type DataTableDefaultState, type DataTableProps, DataTableServer, type DataTableServerProps, type DatePickerProps, DefaultCardTitle, DefaultForm, type DefaultFormProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, type EditFilterButtonProps, EditSortingButton, type EditSortingButtonProps, type EditViewButtonProps, EmptyState, type EmptyStateProps, ErrorAlert, type ErrorAlertProps, FilterDialog, FilterOptions, type FilterOptionsProps, FormBody, FormRoot, type FormRootProps, FormTitle, type GetColumnsConfigs, type GetDateColorProps, type GetMultiDatesProps, type GetRangeDatesProps, type GetStyleProps, type GetVariantProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, Pagination, type RangeCalendarProps, type RangeDatePickerProps, RecordDisplay, type RecordDisplayProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableDataDisplay, type TableDataDisplayProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, type UseDataTableProps, type UseDataTableReturn, type UseDataTableServerProps, type UseDataTableServerReturn, type UseFormProps, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
|
package/dist/index.js
CHANGED
|
@@ -2829,6 +2829,7 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2829
2829
|
setDensity,
|
|
2830
2830
|
columnVisibility,
|
|
2831
2831
|
setColumnVisibility,
|
|
2832
|
+
data,
|
|
2832
2833
|
}, children: children }));
|
|
2833
2834
|
}
|
|
2834
2835
|
|
|
@@ -2912,6 +2913,7 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2912
2913
|
setDensity,
|
|
2913
2914
|
columnVisibility,
|
|
2914
2915
|
setColumnVisibility,
|
|
2916
|
+
data: query.data?.data ?? [],
|
|
2915
2917
|
}, children: jsxRuntime.jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2916
2918
|
}
|
|
2917
2919
|
|
|
@@ -3518,6 +3520,66 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3518
3520
|
return columns;
|
|
3519
3521
|
};
|
|
3520
3522
|
|
|
3523
|
+
const TableDataDisplay = ({ colorPalette }) => {
|
|
3524
|
+
const { table, columns, translate, data } = useDataTableContext();
|
|
3525
|
+
const columnDef = table._getColumnDefs();
|
|
3526
|
+
console.log(columnDef, "glp");
|
|
3527
|
+
console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
|
|
3528
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3529
|
+
const { accessorKey, id } = def;
|
|
3530
|
+
if (accessorKey) {
|
|
3531
|
+
return [accessorKey, def];
|
|
3532
|
+
}
|
|
3533
|
+
return [id, def];
|
|
3534
|
+
}));
|
|
3535
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
3536
|
+
const totalWidths = columns
|
|
3537
|
+
.map(({ size }) => {
|
|
3538
|
+
if (!!size === false) {
|
|
3539
|
+
return 0;
|
|
3540
|
+
}
|
|
3541
|
+
if (typeof size === "number") {
|
|
3542
|
+
return size;
|
|
3543
|
+
}
|
|
3544
|
+
return 0;
|
|
3545
|
+
})
|
|
3546
|
+
.reduce((previous, current) => previous + current, 0);
|
|
3547
|
+
const columnWidths = columns
|
|
3548
|
+
.map(({ size }) => {
|
|
3549
|
+
if (!!size === false) {
|
|
3550
|
+
return "1fr";
|
|
3551
|
+
}
|
|
3552
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3553
|
+
})
|
|
3554
|
+
.join(" ");
|
|
3555
|
+
console.log({ columnWidths }, "hadfg");
|
|
3556
|
+
const cellProps = {
|
|
3557
|
+
flex: "1 0 0%",
|
|
3558
|
+
overflow: "auto",
|
|
3559
|
+
paddingX: "2",
|
|
3560
|
+
py: "1",
|
|
3561
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3562
|
+
borderBottomWidth: "1px",
|
|
3563
|
+
...{ colorPalette },
|
|
3564
|
+
};
|
|
3565
|
+
return (jsxRuntime.jsxs(react.Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: [jsxRuntime.jsx(react.Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: columnHeaders.map((header) => {
|
|
3566
|
+
return (jsxRuntime.jsx(react.Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3567
|
+
}) }), data.map((record) => {
|
|
3568
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columnHeaders.map((header) => {
|
|
3569
|
+
if (!!record === false) {
|
|
3570
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3571
|
+
}
|
|
3572
|
+
if (!!record[header] === false) {
|
|
3573
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3574
|
+
}
|
|
3575
|
+
if (typeof record[header] === "object") {
|
|
3576
|
+
return (jsxRuntime.jsx(react.Box, { ...cellProps, children: jsxRuntime.jsx(RecordDisplay, { object: record[header] }) }));
|
|
3577
|
+
}
|
|
3578
|
+
return jsxRuntime.jsx(react.Box, { ...cellProps, children: record[header] ?? "" });
|
|
3579
|
+
}) }));
|
|
3580
|
+
})] }));
|
|
3581
|
+
};
|
|
3582
|
+
|
|
3521
3583
|
const AccordionItemTrigger = React__namespace.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3522
3584
|
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3523
3585
|
return (jsxRuntime.jsxs(react.Accordion.ItemTrigger, { ...rest, ref: ref, children: [indicatorPlacement === "start" && (jsxRuntime.jsx(react.Accordion.ItemIndicator, { rotate: { base: "-90deg", _open: "0deg" }, children: jsxRuntime.jsx(lu.LuChevronDown, {}) })), jsxRuntime.jsx(react.HStack, { gap: "4", flex: "1", textAlign: "start", width: "full", children: children }), indicatorPlacement === "end" && (jsxRuntime.jsx(react.Accordion.ItemIndicator, { children: jsxRuntime.jsx(lu.LuChevronDown, {}) }))] }));
|
|
@@ -5135,6 +5197,7 @@ exports.TableCardContainer = TableCardContainer;
|
|
|
5135
5197
|
exports.TableCards = TableCards;
|
|
5136
5198
|
exports.TableComponent = TableComponent;
|
|
5137
5199
|
exports.TableControls = TableControls;
|
|
5200
|
+
exports.TableDataDisplay = TableDataDisplay;
|
|
5138
5201
|
exports.TableFilter = TableFilter;
|
|
5139
5202
|
exports.TableFilterTags = TableFilterTags;
|
|
5140
5203
|
exports.TableFooter = TableFooter;
|
package/dist/index.mjs
CHANGED
|
@@ -2809,6 +2809,7 @@ function DataTable({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
2809
2809
|
setDensity,
|
|
2810
2810
|
columnVisibility,
|
|
2811
2811
|
setColumnVisibility,
|
|
2812
|
+
data,
|
|
2812
2813
|
}, children: children }));
|
|
2813
2814
|
}
|
|
2814
2815
|
|
|
@@ -2892,6 +2893,7 @@ function DataTableServer({ columns, enableRowSelection = true, enableMultiRowSel
|
|
|
2892
2893
|
setDensity,
|
|
2893
2894
|
columnVisibility,
|
|
2894
2895
|
setColumnVisibility,
|
|
2896
|
+
data: query.data?.data ?? [],
|
|
2895
2897
|
}, children: jsx(DataTableServerContext.Provider, { value: { url, query }, children: children }) }));
|
|
2896
2898
|
}
|
|
2897
2899
|
|
|
@@ -3498,6 +3500,66 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
|
|
|
3498
3500
|
return columns;
|
|
3499
3501
|
};
|
|
3500
3502
|
|
|
3503
|
+
const TableDataDisplay = ({ colorPalette }) => {
|
|
3504
|
+
const { table, columns, translate, data } = useDataTableContext();
|
|
3505
|
+
const columnDef = table._getColumnDefs();
|
|
3506
|
+
console.log(columnDef, "glp");
|
|
3507
|
+
console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
|
|
3508
|
+
const columnsMap = Object.fromEntries(columns.map((def) => {
|
|
3509
|
+
const { accessorKey, id } = def;
|
|
3510
|
+
if (accessorKey) {
|
|
3511
|
+
return [accessorKey, def];
|
|
3512
|
+
}
|
|
3513
|
+
return [id, def];
|
|
3514
|
+
}));
|
|
3515
|
+
const columnHeaders = Object.keys(columnsMap);
|
|
3516
|
+
const totalWidths = columns
|
|
3517
|
+
.map(({ size }) => {
|
|
3518
|
+
if (!!size === false) {
|
|
3519
|
+
return 0;
|
|
3520
|
+
}
|
|
3521
|
+
if (typeof size === "number") {
|
|
3522
|
+
return size;
|
|
3523
|
+
}
|
|
3524
|
+
return 0;
|
|
3525
|
+
})
|
|
3526
|
+
.reduce((previous, current) => previous + current, 0);
|
|
3527
|
+
const columnWidths = columns
|
|
3528
|
+
.map(({ size }) => {
|
|
3529
|
+
if (!!size === false) {
|
|
3530
|
+
return "1fr";
|
|
3531
|
+
}
|
|
3532
|
+
return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
|
|
3533
|
+
})
|
|
3534
|
+
.join(" ");
|
|
3535
|
+
console.log({ columnWidths }, "hadfg");
|
|
3536
|
+
const cellProps = {
|
|
3537
|
+
flex: "1 0 0%",
|
|
3538
|
+
overflow: "auto",
|
|
3539
|
+
paddingX: "2",
|
|
3540
|
+
py: "1",
|
|
3541
|
+
borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
|
|
3542
|
+
borderBottomWidth: "1px",
|
|
3543
|
+
...{ colorPalette },
|
|
3544
|
+
};
|
|
3545
|
+
return (jsxs(Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: [jsx(Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, colorPalette, children: columnHeaders.map((header) => {
|
|
3546
|
+
return (jsx(Box, { flex: "1 0 0%", paddingX: "2", py: "1", overflow: "auto", textOverflow: "ellipsis", children: translate.t(`column_header.${header}`) }));
|
|
3547
|
+
}) }), data.map((record) => {
|
|
3548
|
+
return (jsx(Fragment, { children: columnHeaders.map((header) => {
|
|
3549
|
+
if (!!record === false) {
|
|
3550
|
+
return (jsx(Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3551
|
+
}
|
|
3552
|
+
if (!!record[header] === false) {
|
|
3553
|
+
return (jsx(Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
|
|
3554
|
+
}
|
|
3555
|
+
if (typeof record[header] === "object") {
|
|
3556
|
+
return (jsx(Box, { ...cellProps, children: jsx(RecordDisplay, { object: record[header] }) }));
|
|
3557
|
+
}
|
|
3558
|
+
return jsx(Box, { ...cellProps, children: record[header] ?? "" });
|
|
3559
|
+
}) }));
|
|
3560
|
+
})] }));
|
|
3561
|
+
};
|
|
3562
|
+
|
|
3501
3563
|
const AccordionItemTrigger = React.forwardRef(function AccordionItemTrigger(props, ref) {
|
|
3502
3564
|
const { children, indicatorPlacement = "end", ...rest } = props;
|
|
3503
3565
|
return (jsxs(Accordion.ItemTrigger, { ...rest, ref: ref, children: [indicatorPlacement === "start" && (jsx(Accordion.ItemIndicator, { rotate: { base: "-90deg", _open: "0deg" }, children: jsx(LuChevronDown, {}) })), jsx(HStack, { gap: "4", flex: "1", textAlign: "start", width: "full", children: children }), indicatorPlacement === "end" && (jsx(Accordion.ItemIndicator, { children: jsx(LuChevronDown, {}) }))] }));
|
|
@@ -5084,4 +5146,4 @@ const getMultiDates = ({ selected, selectedDate, selectedDates, selectable, }) =
|
|
|
5084
5146
|
}
|
|
5085
5147
|
};
|
|
5086
5148
|
|
|
5087
|
-
export { CardHeader, DataDisplay, DataTable, DataTableServer, DefaultCardTitle, DefaultForm, DefaultTable, DensityToggleButton, EditSortingButton, EmptyState$1 as EmptyState, ErrorAlert, FilterDialog, FilterOptions, FormBody, FormRoot, FormTitle, GlobalFilter, PageSizeControl, Pagination, RecordDisplay, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableSelector, TableSorter, TableViewer, TextCell, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
|
|
5149
|
+
export { CardHeader, DataDisplay, DataTable, DataTableServer, DefaultCardTitle, DefaultForm, DefaultTable, DensityToggleButton, EditSortingButton, EmptyState$1 as EmptyState, ErrorAlert, FilterDialog, FilterOptions, FormBody, FormRoot, FormTitle, GlobalFilter, PageSizeControl, Pagination, RecordDisplay, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableDataDisplay, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableSelector, TableSorter, TableViewer, TextCell, ViewDialog, getColumns, getMultiDates, getRangeDates, idPickerSanityCheck, useDataTable, useDataTableContext, useDataTableServer, useForm, widthSanityCheck };
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface TableDataDisplayProps {
|
|
2
|
+
colorPalette?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const TableDataDisplay: ({ colorPalette }: TableDataDisplayProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export * from "./components/DataTable/display/TextCell";
|
|
|
94
94
|
export * from "./components/DataTable/useDataTable";
|
|
95
95
|
export * from "./components/DataTable/useDataTableServer";
|
|
96
96
|
export * from "./components/DataTable/utils/getColumns";
|
|
97
|
+
export * from "./components/DataTable/display/TableDataDisplay";
|
|
97
98
|
export * from "./components/Filter/FilterOptions";
|
|
98
99
|
export * from "./components/Filter/GlobalFilter";
|
|
99
100
|
export * from "./components/Form/components/core/DefaultForm";
|