@tsed/react-formio 2.2.2 → 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 +52 -25
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +51 -21
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -3
- package/src/components/pagination/pagination.component.tsx +1 -1
- 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
|
@@ -400,7 +400,9 @@ function Pagination(props) {
|
|
|
400
400
|
}, /*#__PURE__*/React__default["default"].createElement("span", null, i18n("Page"), "\xA0"), /*#__PURE__*/React__default["default"].createElement("strong", null, pageIndex + 1, " of ", pageOptions.length)), totalLength !== undefined && /*#__PURE__*/React__default["default"].createElement("li", {
|
|
401
401
|
className: "mb-3 flex items-center",
|
|
402
402
|
"data-testid": "pagination-total-items"
|
|
403
|
-
}, i18n("Total"), ": ", /*#__PURE__*/React__default["default"].createElement("strong",
|
|
403
|
+
}, i18n("Total"), ": ", /*#__PURE__*/React__default["default"].createElement("strong", {
|
|
404
|
+
className: "mx-1"
|
|
405
|
+
}, new Intl.NumberFormat(undefined).format(totalLength)), " ", i18n("items")));
|
|
404
406
|
}
|
|
405
407
|
|
|
406
408
|
function DefaultArrowSort(_ref) {
|
|
@@ -519,7 +521,10 @@ function DefaultCells(_ref) {
|
|
|
519
521
|
}
|
|
520
522
|
return /*#__PURE__*/React__default["default"].createElement("td", _extends({
|
|
521
523
|
colSpan: colspan
|
|
522
|
-
}, cell.getCellProps(
|
|
524
|
+
}, cell.getCellProps({
|
|
525
|
+
className: cell.column.className,
|
|
526
|
+
style: cell.column.style
|
|
527
|
+
}), {
|
|
523
528
|
key: "tableInstance.page.cells." + (cell.value || "value") + "." + i
|
|
524
529
|
}), cell.render("Cell"));
|
|
525
530
|
}));
|
|
@@ -2518,35 +2523,55 @@ function FormSettings(props) {
|
|
|
2518
2523
|
}, i18n("Save settings")));
|
|
2519
2524
|
}
|
|
2520
2525
|
|
|
2521
|
-
function
|
|
2522
|
-
var column =
|
|
2526
|
+
function useSelectColumnFilter(props) {
|
|
2527
|
+
var column = props.column;
|
|
2523
2528
|
var id = column.id,
|
|
2524
|
-
preFilteredRows = column.preFilteredRows
|
|
2525
|
-
filterValue = column.filterValue,
|
|
2526
|
-
setFilter = column.setFilter;
|
|
2529
|
+
preFilteredRows = column.preFilteredRows;
|
|
2527
2530
|
var customChoices = column.choices;
|
|
2528
|
-
var
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
}
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
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 {
|
|
2542
2555
|
value: filterValue,
|
|
2556
|
+
onChange: onChange,
|
|
2543
2557
|
choices: [{
|
|
2544
2558
|
value: "",
|
|
2545
2559
|
label: "All"
|
|
2546
|
-
}].concat(choices)
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
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
|
|
2550
2575
|
});
|
|
2551
2576
|
}
|
|
2552
2577
|
|
|
@@ -7543,6 +7568,7 @@ function mapFormToColumns(form) {
|
|
|
7543
7568
|
var column = {
|
|
7544
7569
|
Header: component.label || component.title || component.key,
|
|
7545
7570
|
accessor: "data." + component.key,
|
|
7571
|
+
className: "text-center",
|
|
7546
7572
|
Cell: function Cell(props) {
|
|
7547
7573
|
return /*#__PURE__*/React__default["default"].createElement(DefaultCell, _extends({}, props, {
|
|
7548
7574
|
render: function render(value) {
|
|
@@ -7774,5 +7800,6 @@ exports.useForm = useForm;
|
|
|
7774
7800
|
exports.useFormEdit = useFormEdit;
|
|
7775
7801
|
exports.useModal = useModal;
|
|
7776
7802
|
exports.useOperations = useOperations;
|
|
7803
|
+
exports.useSelectColumnFilter = useSelectColumnFilter;
|
|
7777
7804
|
exports.useTooltip = useTooltip;
|
|
7778
7805
|
//# sourceMappingURL=index.js.map
|