@bsol-oss/react-datatable5 12.0.0-beta.8 → 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,7 +441,10 @@ 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
- declare const TableDataDisplay: () => react_jsx_runtime.JSX.Element;
444
+ interface TableDataDisplayProps {
445
+ colorPalette?: string;
446
+ }
447
+ declare const TableDataDisplay: ({ colorPalette }: TableDataDisplayProps) => react_jsx_runtime.JSX.Element;
445
448
 
446
449
  interface FilterOptionsProps {
447
450
  column: string;
@@ -614,4 +617,4 @@ declare module "@tanstack/react-table" {
614
617
  }
615
618
  }
616
619
 
617
- 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, 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,23 +3520,36 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
3518
3520
  return columns;
3519
3521
  };
3520
3522
 
3521
- const TableDataDisplay = () => {
3522
- const { table, columns, translate } = useDataTableContext();
3523
- const { query } = useDataTableServerContext();
3524
- const { data } = query;
3523
+ const TableDataDisplay = ({ colorPalette }) => {
3524
+ const { table, columns, translate, data } = useDataTableContext();
3525
3525
  const columnDef = table._getColumnDefs();
3526
3526
  console.log(columnDef, "glp");
3527
3527
  console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
3528
3528
  const columnsMap = Object.fromEntries(columns.map((def) => {
3529
- return [def.accessorKey, def];
3529
+ const { accessorKey, id } = def;
3530
+ if (accessorKey) {
3531
+ return [accessorKey, def];
3532
+ }
3533
+ return [id, def];
3530
3534
  }));
3531
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);
3532
3547
  const columnWidths = columns
3533
3548
  .map(({ size }) => {
3534
3549
  if (!!size === false) {
3535
3550
  return "1fr";
3536
3551
  }
3537
- return `${size}px`;
3552
+ return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
3538
3553
  })
3539
3554
  .join(" ");
3540
3555
  console.log({ columnWidths }, "hadfg");
@@ -3545,10 +3560,11 @@ const TableDataDisplay = () => {
3545
3560
  py: "1",
3546
3561
  borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
3547
3562
  borderBottomWidth: "1px",
3563
+ ...{ colorPalette },
3548
3564
  };
3549
- return (jsxRuntime.jsxs(react.Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, children: [jsxRuntime.jsx(react.Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, children: columnHeaders.map((header) => {
3550
- return (jsxRuntime.jsx(react.Box, { flex: "1 0 0%", paddingX: "2", py: "1", children: translate.t(`column_header.${header}`) }));
3551
- }) }), data?.data.map((record) => {
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) => {
3552
3568
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columnHeaders.map((header) => {
3553
3569
  if (!!record === false) {
3554
3570
  return (jsxRuntime.jsx(react.Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
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,23 +3500,36 @@ const getColumns = ({ schema, include = [], ignore = [], width = [], meta = {},
3498
3500
  return columns;
3499
3501
  };
3500
3502
 
3501
- const TableDataDisplay = () => {
3502
- const { table, columns, translate } = useDataTableContext();
3503
- const { query } = useDataTableServerContext();
3504
- const { data } = query;
3503
+ const TableDataDisplay = ({ colorPalette }) => {
3504
+ const { table, columns, translate, data } = useDataTableContext();
3505
3505
  const columnDef = table._getColumnDefs();
3506
3506
  console.log(columnDef, "glp");
3507
3507
  console.log(columnDef, columns, table.getState().columnOrder, data, "glp");
3508
3508
  const columnsMap = Object.fromEntries(columns.map((def) => {
3509
- return [def.accessorKey, def];
3509
+ const { accessorKey, id } = def;
3510
+ if (accessorKey) {
3511
+ return [accessorKey, def];
3512
+ }
3513
+ return [id, def];
3510
3514
  }));
3511
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);
3512
3527
  const columnWidths = columns
3513
3528
  .map(({ size }) => {
3514
3529
  if (!!size === false) {
3515
3530
  return "1fr";
3516
3531
  }
3517
- return `${size}px`;
3532
+ return `minmax(${size}px, ${(size / totalWidths) * 100}%)`;
3518
3533
  })
3519
3534
  .join(" ");
3520
3535
  console.log({ columnWidths }, "hadfg");
@@ -3525,10 +3540,11 @@ const TableDataDisplay = () => {
3525
3540
  py: "1",
3526
3541
  borderBottomColor: { base: "colorPalette.200", _dark: "colorPalette.800" },
3527
3542
  borderBottomWidth: "1px",
3543
+ ...{ colorPalette },
3528
3544
  };
3529
- return (jsxs(Grid, { templateColumns: `${columnWidths}`, overflow: "auto", borderWidth: "1px", borderColor: { base: "colorPalette.200", _dark: "colorPalette.800" }, children: [jsx(Grid, { templateColumns: `${columnWidths}`, column: `1/span ${columns.length}`, bg: { base: "colorPalette.200", _dark: "colorPalette.800" }, children: columnHeaders.map((header) => {
3530
- return (jsx(Box, { flex: "1 0 0%", paddingX: "2", py: "1", children: translate.t(`column_header.${header}`) }));
3531
- }) }), data?.data.map((record) => {
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) => {
3532
3548
  return (jsx(Fragment, { children: columnHeaders.map((header) => {
3533
3549
  if (!!record === false) {
3534
3550
  return (jsx(Box, { ...cellProps, children: translate.t(`column_cell.placeholder`) }));
@@ -1 +1,4 @@
1
- export declare const TableDataDisplay: () => import("react/jsx-runtime").JSX.Element;
1
+ export interface TableDataDisplayProps {
2
+ colorPalette?: string;
3
+ }
4
+ export declare const TableDataDisplay: ({ colorPalette }: TableDataDisplayProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsol-oss/react-datatable5",
3
- "version": "12.0.0-beta.8",
3
+ "version": "12.0.0-beta.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",