@tsed/react-formio 3.0.0-rc.13 → 3.0.0-rc.14
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/all.js +2 -0
- package/dist/all.js.map +1 -1
- package/dist/chunks/index2.js +19748 -22277
- package/dist/chunks/index2.js.map +1 -1
- package/dist/chunks/moment.js +2535 -0
- package/dist/chunks/moment.js.map +1 -0
- package/dist/molecules/forms/select/Select.interface.d.ts +0 -4
- package/dist/molecules/table/all.js +2 -0
- package/dist/molecules/table/all.js.map +1 -1
- package/dist/molecules/table/components/DefaultBooleanCell.d.ts +2 -0
- package/dist/molecules/table/components/DefaultBooleanCell.js +12 -0
- package/dist/molecules/table/components/DefaultBooleanCell.js.map +1 -0
- package/dist/molecules/table/components/DefaultCell.js +7 -7
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/components/DefaultDateCell.d.ts +2 -0
- package/dist/molecules/table/components/DefaultDateCell.js +16 -0
- package/dist/molecules/table/components/DefaultDateCell.js.map +1 -0
- package/dist/molecules/table/components/DefaultFilter.d.ts +5 -7
- package/dist/molecules/table/components/DefaultFilter.js +8 -8
- package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
- package/dist/molecules/table/interfaces/extends.d.ts +3 -0
- package/dist/molecules/table/utils/mapFormToColumns.js +36 -24
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js +1 -1
- package/package.json +3 -3
- package/src/all.ts +2 -0
- package/src/molecules/forms/select/Select.interface.ts +0 -4
- package/src/molecules/table/all.ts +2 -0
- package/src/molecules/table/components/DefaultBooleanCell.spec.tsx +42 -0
- package/src/molecules/table/components/DefaultBooleanCell.tsx +11 -0
- package/src/molecules/table/components/DefaultCell.tsx +1 -1
- package/src/molecules/table/components/DefaultDateCell.spec.tsx +43 -0
- package/src/molecules/table/components/DefaultDateCell.tsx +23 -0
- package/src/molecules/table/components/DefaultFilter.tsx +10 -7
- package/src/molecules/table/filters/Filters.d.ts +1 -0
- package/src/molecules/table/interfaces/extends.ts +3 -0
- package/src/molecules/table/utils/mapFormToColumns.spec.tsx +20 -0
- package/src/molecules/table/utils/mapFormToColumns.tsx +27 -14
|
@@ -9,18 +9,24 @@ import { getComponent } from "../../../registries/components";
|
|
|
9
9
|
import type { DefaultCell } from "../components/DefaultCell";
|
|
10
10
|
import type { FilterVariants } from "../filters/Filters.js";
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const MAP_FILTER_TYPES: Record<string, FilterVariants> = {
|
|
13
13
|
number: "range",
|
|
14
14
|
currency: "range",
|
|
15
15
|
checkbox: "boolean"
|
|
16
|
-
};
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
const MAP_TYPES = {
|
|
19
|
+
date: "date",
|
|
20
|
+
datetime: "date",
|
|
21
|
+
number: "number",
|
|
22
|
+
currency: "currency",
|
|
23
|
+
checkbox: "boolean"
|
|
24
|
+
} as const;
|
|
17
25
|
|
|
18
26
|
export function mapFormToColumns<Data = any>(form: FormType, columns: ColumnDefResolved<Data, any>[] = []): ColumnDef<Data, any>[] {
|
|
19
27
|
const columnHelper = createColumnHelper<Data>();
|
|
20
28
|
const columnsToKeep = cloneDeep(columns);
|
|
21
29
|
|
|
22
|
-
const Cell = getComponent<typeof DefaultCell>("Cell");
|
|
23
|
-
|
|
24
30
|
const columnsFromComponents = form.components
|
|
25
31
|
.flatMap((component) => {
|
|
26
32
|
if (component.type === "tabs") {
|
|
@@ -45,23 +51,30 @@ export function mapFormToColumns<Data = any>(form: FormType, columns: ColumnDefR
|
|
|
45
51
|
|
|
46
52
|
return columnHelper.accessor(`data.${component.key}` as any, {
|
|
47
53
|
header: (component.label || component.title || component.key)?.replace(/:/, ""),
|
|
48
|
-
cell: Cell,
|
|
49
54
|
meta: {
|
|
50
|
-
|
|
55
|
+
type: MAP_TYPES[component.type as keyof typeof MAP_TYPES] || component.type,
|
|
56
|
+
filter: {
|
|
57
|
+
...column?.meta?.filter,
|
|
58
|
+
variant: MAP_FILTER_TYPES[component.type!] || "text"
|
|
59
|
+
},
|
|
51
60
|
...(column?.meta || {})
|
|
52
61
|
},
|
|
53
62
|
...(column || {})
|
|
54
63
|
});
|
|
55
64
|
});
|
|
56
65
|
|
|
57
|
-
const mergedColumns = columnsFromComponents.concat(columnsToKeep as any[]).map((column, index) =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
const mergedColumns = columnsFromComponents.concat(columnsToKeep as any[]).map((column, index) => {
|
|
67
|
+
const Cell = getComponent<typeof DefaultCell>([`Cell.${column.id}`, `Cell.${column.meta?.type}`, "Cell"]);
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
...column,
|
|
71
|
+
meta: {
|
|
72
|
+
...column?.meta,
|
|
73
|
+
order: get(column, "meta.order", index * 10)
|
|
74
|
+
},
|
|
75
|
+
cell: column.cell || Cell
|
|
76
|
+
};
|
|
77
|
+
});
|
|
65
78
|
|
|
66
79
|
return mergedColumns.sort((a, b) => (a.meta.order > b.meta.order ? 1 : -1)) as ColumnDef<Data, any>[];
|
|
67
80
|
}
|