pallote-react 0.16.8 → 0.16.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/components/DataTable.d.ts +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { ReactNode, HTMLAttributes } from 'react';
|
|
2
2
|
import { type TableCellKind } from './TableCell';
|
|
3
3
|
export type DataTableFilterType = 'text' | 'select';
|
|
4
|
+
/** Option value for filtering; label is shown in the dropdown. Use when row values are raw (e.g. in_progress) but you want formatted labels (e.g. In progress). */
|
|
5
|
+
export type DataTableFilterOption = string | {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
4
9
|
export interface DataTableColumnDef<TData> {
|
|
5
10
|
accessorKey: keyof TData & string;
|
|
6
11
|
header: string;
|
|
7
12
|
enableSorting?: boolean;
|
|
8
13
|
enableFiltering?: boolean;
|
|
9
14
|
filterType?: DataTableFilterType;
|
|
10
|
-
filterOptions?:
|
|
15
|
+
filterOptions?: DataTableFilterOption[];
|
|
11
16
|
cell?: (value: TData[keyof TData & string], row: TData) => ReactNode;
|
|
12
17
|
className?: string;
|
|
13
18
|
kind?: TableCellKind;
|
package/dist/index.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export type { CardMediaProps } from './components/CardMedia';
|
|
|
68
68
|
export type { CheckboxProps } from './components/Checkbox';
|
|
69
69
|
export type { CheckboxesProps } from './components/Checkboxes';
|
|
70
70
|
export type { ChipProps } from './components/Chip';
|
|
71
|
-
export type { DataTableProps, DataTableColumnDef, DataTableFilterType } from './components/DataTable';
|
|
71
|
+
export type { DataTableProps, DataTableColumnDef, DataTableFilterType, DataTableFilterOption } from './components/DataTable';
|
|
72
72
|
export type { DividerProps } from './components/Divider';
|
|
73
73
|
export type { InputProps } from './components/Input';
|
|
74
74
|
export type { InputLabelProps } from './components/InputLabel';
|
package/dist/index.js
CHANGED
|
@@ -790,13 +790,17 @@ const Input = ({ onChange, type = 'text', id, placeholder, label = 'Input', icon
|
|
|
790
790
|
: null), ...props })] }));
|
|
791
791
|
};
|
|
792
792
|
|
|
793
|
+
function normalizeFilterOption(opt) {
|
|
794
|
+
return typeof opt === 'string' ? { value: opt, label: opt } : opt;
|
|
795
|
+
}
|
|
793
796
|
function ColumnFilter({ header }) {
|
|
794
797
|
const columnDef = header.column.columnDef.meta;
|
|
795
798
|
const filterType = columnDef?.filterType ?? 'text';
|
|
796
799
|
const filterOptions = columnDef?.filterOptions ?? [];
|
|
797
800
|
const filterValue = header.column.getFilterValue() ?? '';
|
|
798
801
|
if (filterType === 'select') {
|
|
799
|
-
|
|
802
|
+
const options = filterOptions.map(normalizeFilterOption);
|
|
803
|
+
return (jsxs(Select, { dense: true, id: `filter-${header.id}`, label: `Filter ${header.column.columnDef.header}`, hideLabel: true, className: "datatable_filter", value: filterValue, onChange: (e) => header.column.setFilterValue(e.target.value || undefined), children: [jsx("option", { value: "", children: "All" }), options.map(({ value, label }) => (jsx("option", { value: value, children: label }, value)))] }));
|
|
800
804
|
}
|
|
801
805
|
return (jsx(Input, { dense: true, id: `filter-${header.id}`, label: `Filter ${header.column.columnDef.header}`, hideLabel: true, placeholder: "Filter...", className: "datatable_filter", value: filterValue, onChange: (e) => header.column.setFilterValue(e.target.value || undefined) }));
|
|
802
806
|
}
|
package/dist/package.json
CHANGED