@tsed/react-formio 2.2.3 → 2.3.0
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/table/components/defaultCell.component.d.ts +1 -0
- package/dist/components/table/filters/selectColumnFilter.component.d.ts +9 -1
- package/dist/components/table/hooks/useCustomTable.hook.d.ts +15 -1
- package/dist/components/table/hooks/useDragnDropRow.hook.d.ts +1 -0
- package/dist/components/table/table.stories.d.ts +2 -2
- package/dist/components/table/utils/mapFormToColumns.d.ts +2 -2
- package/dist/index.js +49 -24
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +48 -20
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -3
- package/src/components/table/components/defaultCells.component.tsx +12 -3
- package/src/components/table/filters/selectColumnFilter.component.spec.tsx +21 -0
- package/src/components/table/filters/selectColumnFilter.component.tsx +38 -12
- package/src/components/table/hooks/useCustomTable.hook.tsx +31 -1
- package/src/components/table/table.component.tsx +1 -0
- package/src/components/table/utils/mapFormToColumns.tsx +5 -4
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FilterProps } from "react-table";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function useSelectColumnFilter<D extends Record<string, unknown> = {}>(props: FilterProps<D>): {
|
|
4
|
+
value: any;
|
|
5
|
+
onChange: (_: string, value: any) => void;
|
|
6
|
+
choices: {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export declare function SelectColumnFilter<D extends Record<string, unknown> = {}>(props: FilterProps<D>): React.JSX.Element;
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { CellProps, FilterProps, Renderer, TableOptions } from "react-table";
|
|
2
|
+
import { Cell, CellProps, Column, FilterProps, Renderer, TableOptions } from "react-table";
|
|
3
3
|
import { OnClickOperation, Operation, QueryOptions } from "../../../interfaces";
|
|
4
4
|
import { Pagination as DefaultPagination } from "../../pagination/pagination.component";
|
|
5
5
|
import { DefaultCellHeaderProps } from "../components/defaultCellHeader.component";
|
|
6
6
|
import { DefaultRow, DefaultRowProps } from "../components/defaultRow.component";
|
|
7
|
+
export interface ExtraColumnProps {
|
|
8
|
+
colspan?: number;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
export type ExtendedColumn<Data extends object = any> = Column<Data> & ExtraColumnProps;
|
|
14
|
+
export type ExtendedCell<Data extends object = any> = Cell<Data, any> & {
|
|
15
|
+
column: ExtraColumnProps;
|
|
16
|
+
};
|
|
7
17
|
export interface TableProps<Data extends object = any> extends TableOptions<Data>, Partial<QueryOptions> {
|
|
18
|
+
/**
|
|
19
|
+
* extended columns interface
|
|
20
|
+
*/
|
|
21
|
+
columns: ReadonlyArray<ExtendedColumn<Data>>;
|
|
8
22
|
className?: string;
|
|
9
23
|
/**
|
|
10
24
|
* Call the listener when a filter / pagination / sort change.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
/// <reference types="react" />
|
|
2
3
|
import { DefaultRowProps } from "../components/defaultRow.component";
|
|
3
4
|
export declare function useDndRow<Data extends object = {}>({ onDrag, onDrop, index, ...props }: DefaultRowProps<Data>): {
|
|
4
5
|
opacity: number;
|
|
@@ -24,7 +24,7 @@ export declare const Sandbox: {
|
|
|
24
24
|
modified: string;
|
|
25
25
|
form: string;
|
|
26
26
|
}[];
|
|
27
|
-
columns: import("
|
|
27
|
+
columns: import(".").ExtendedColumn<any>[];
|
|
28
28
|
operations: ({
|
|
29
29
|
title: string;
|
|
30
30
|
action: string;
|
|
@@ -49,7 +49,7 @@ export declare const TableWithDragNDrop: {
|
|
|
49
49
|
args: {
|
|
50
50
|
enableDragNDrop: boolean;
|
|
51
51
|
data: never[];
|
|
52
|
-
columns: import("
|
|
52
|
+
columns: import(".").ExtendedColumn<any>[];
|
|
53
53
|
operations: ({
|
|
54
54
|
title: string;
|
|
55
55
|
action: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Column } from "react-table";
|
|
2
1
|
import { FormSchema } from "../../../interfaces";
|
|
3
|
-
|
|
2
|
+
import { ExtendedColumn } from "../hooks/useCustomTable.hook";
|
|
3
|
+
export declare function mapFormToColumns(form: FormSchema): ExtendedColumn[];
|
package/dist/index.js
CHANGED
|
@@ -521,7 +521,10 @@ function DefaultCells(_ref) {
|
|
|
521
521
|
}
|
|
522
522
|
return /*#__PURE__*/React__default["default"].createElement("td", _extends({
|
|
523
523
|
colSpan: colspan
|
|
524
|
-
}, cell.getCellProps(
|
|
524
|
+
}, cell.getCellProps({
|
|
525
|
+
className: cell.column.className,
|
|
526
|
+
style: cell.column.style
|
|
527
|
+
}), {
|
|
525
528
|
key: "tableInstance.page.cells." + (cell.value || "value") + "." + i
|
|
526
529
|
}), cell.render("Cell"));
|
|
527
530
|
}));
|
|
@@ -2520,35 +2523,55 @@ function FormSettings(props) {
|
|
|
2520
2523
|
}, i18n("Save settings")));
|
|
2521
2524
|
}
|
|
2522
2525
|
|
|
2523
|
-
function
|
|
2524
|
-
var column =
|
|
2526
|
+
function useSelectColumnFilter(props) {
|
|
2527
|
+
var column = props.column;
|
|
2525
2528
|
var id = column.id,
|
|
2526
|
-
preFilteredRows = column.preFilteredRows
|
|
2527
|
-
filterValue = column.filterValue,
|
|
2528
|
-
setFilter = column.setFilter;
|
|
2529
|
+
preFilteredRows = column.preFilteredRows;
|
|
2529
2530
|
var customChoices = column.choices;
|
|
2530
|
-
var
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2531
|
+
var filterValue = column.filterValue,
|
|
2532
|
+
setFilter = column.setFilter;
|
|
2533
|
+
var choices = function () {
|
|
2534
|
+
if (customChoices) {
|
|
2535
|
+
if (typeof customChoices === "function") {
|
|
2536
|
+
return customChoices(props);
|
|
2537
|
+
}
|
|
2538
|
+
return customChoices;
|
|
2539
|
+
}
|
|
2540
|
+
return [].concat(new Set(preFilteredRows.map(function (row) {
|
|
2541
|
+
return row.values[id];
|
|
2542
|
+
}))).filter(function (value) {
|
|
2543
|
+
return value;
|
|
2544
|
+
}).map(function (value) {
|
|
2545
|
+
return {
|
|
2546
|
+
label: value,
|
|
2547
|
+
value: value
|
|
2548
|
+
};
|
|
2549
|
+
});
|
|
2550
|
+
}();
|
|
2551
|
+
var onChange = function onChange(_, value) {
|
|
2552
|
+
setFilter(value || undefined);
|
|
2553
|
+
};
|
|
2554
|
+
return {
|
|
2544
2555
|
value: filterValue,
|
|
2556
|
+
onChange: onChange,
|
|
2545
2557
|
choices: [{
|
|
2546
2558
|
value: "",
|
|
2547
2559
|
label: "All"
|
|
2548
|
-
}].concat(choices)
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2560
|
+
}].concat(choices)
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
function SelectColumnFilter(props) {
|
|
2564
|
+
var _useSelectColumnFilte = useSelectColumnFilter(props),
|
|
2565
|
+
value = _useSelectColumnFilte.value,
|
|
2566
|
+
choices = _useSelectColumnFilte.choices,
|
|
2567
|
+
onChange = _useSelectColumnFilte.onChange;
|
|
2568
|
+
return /*#__PURE__*/React__default["default"].createElement(Select, {
|
|
2569
|
+
key: "filter-" + props.column.id,
|
|
2570
|
+
name: "filter-" + props.column.id,
|
|
2571
|
+
size: "sm",
|
|
2572
|
+
value: value,
|
|
2573
|
+
choices: choices,
|
|
2574
|
+
onChange: onChange
|
|
2552
2575
|
});
|
|
2553
2576
|
}
|
|
2554
2577
|
|
|
@@ -7545,6 +7568,7 @@ function mapFormToColumns(form) {
|
|
|
7545
7568
|
var column = {
|
|
7546
7569
|
Header: component.label || component.title || component.key,
|
|
7547
7570
|
accessor: "data." + component.key,
|
|
7571
|
+
className: "text-center",
|
|
7548
7572
|
Cell: function Cell(props) {
|
|
7549
7573
|
return /*#__PURE__*/React__default["default"].createElement(DefaultCell, _extends({}, props, {
|
|
7550
7574
|
render: function render(value) {
|
|
@@ -7776,5 +7800,6 @@ exports.useForm = useForm;
|
|
|
7776
7800
|
exports.useFormEdit = useFormEdit;
|
|
7777
7801
|
exports.useModal = useModal;
|
|
7778
7802
|
exports.useOperations = useOperations;
|
|
7803
|
+
exports.useSelectColumnFilter = useSelectColumnFilter;
|
|
7779
7804
|
exports.useTooltip = useTooltip;
|
|
7780
7805
|
//# sourceMappingURL=index.js.map
|