@hybridcore/ui 1.5.23 → 1.5.24
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/instance-table/index.js +108 -85
- package/dist/main.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1,125 +1,148 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { DataGrid as
|
|
4
|
-
import { ButtonBase as
|
|
5
|
-
import { DataGridActions as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
const
|
|
9
|
-
template:
|
|
10
|
-
data:
|
|
11
|
-
selectedIds:
|
|
12
|
-
sortColumnsBy:
|
|
13
|
-
actions:
|
|
14
|
-
actionsWidth:
|
|
15
|
-
enableCheckboxSelection:
|
|
1
|
+
import { jsx as o, Fragment as D, jsxs as j } from "react/jsx-runtime";
|
|
2
|
+
import { useState as B, useMemo as $ } from "react";
|
|
3
|
+
import { DataGrid as N } from "@mui/x-data-grid";
|
|
4
|
+
import { ButtonBase as k, Box as A } from "@mui/material";
|
|
5
|
+
import { DataGridActions as E } from "./styled.js";
|
|
6
|
+
import P from "dayjs";
|
|
7
|
+
import T from "lodash";
|
|
8
|
+
const U = ({
|
|
9
|
+
template: l,
|
|
10
|
+
data: h,
|
|
11
|
+
selectedIds: R = [],
|
|
12
|
+
sortColumnsBy: G = "type",
|
|
13
|
+
actions: u,
|
|
14
|
+
actionsWidth: m = 50,
|
|
15
|
+
enableCheckboxSelection: M = !1,
|
|
16
|
+
fieldOptions: e,
|
|
16
17
|
onSelect: d,
|
|
17
|
-
onTitleClick:
|
|
18
|
+
onTitleClick: y
|
|
18
19
|
}) => {
|
|
19
|
-
const [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
sortable: !1,
|
|
24
|
-
filterable: !1,
|
|
25
|
-
align: "center",
|
|
26
|
-
width: 30,
|
|
27
|
-
renderCell: () => n ? /* @__PURE__ */ i(
|
|
28
|
-
"img",
|
|
20
|
+
const [F, H] = B(R), S = $(() => {
|
|
21
|
+
var w, g, s, v, b, x, C, I;
|
|
22
|
+
return [
|
|
23
|
+
...(w = e == null ? void 0 : e.templateIcon) != null && w.hidden ? [] : [
|
|
29
24
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
field: "template",
|
|
26
|
+
headerName: "",
|
|
27
|
+
sortable: !1,
|
|
28
|
+
filterable: !1,
|
|
29
|
+
align: "center",
|
|
30
|
+
width: 30,
|
|
31
|
+
renderCell: (g = e == null ? void 0 : e.templateIcon) != null && g.renderCell ? (s = e == null ? void 0 : e.templateIcon) == null ? void 0 : s.renderCell : () => l ? /* @__PURE__ */ o(
|
|
32
|
+
"img",
|
|
33
|
+
{
|
|
34
|
+
src: l.icon,
|
|
35
|
+
height: 20,
|
|
36
|
+
style: { display: "inline", maxWidth: 20 }
|
|
37
|
+
}
|
|
38
|
+
) : /* @__PURE__ */ o(D, {})
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
],
|
|
41
|
+
...(v = e == null ? void 0 : e.title) != null && v.hidden ? [] : [
|
|
42
|
+
{
|
|
43
|
+
field: "title",
|
|
44
|
+
headerName: "Title",
|
|
45
|
+
width: 400,
|
|
46
|
+
sortable: !1,
|
|
47
|
+
filterable: !1,
|
|
48
|
+
valueGetter: (r) => r.row.title,
|
|
49
|
+
renderCell: (b = e == null ? void 0 : e.title) != null && b.renderCell ? (x = e == null ? void 0 : e.title) == null ? void 0 : x.renderCell : (r) => {
|
|
50
|
+
const { row: t, value: c } = r;
|
|
51
|
+
return y ? /* @__PURE__ */ o(
|
|
52
|
+
k,
|
|
53
|
+
{
|
|
54
|
+
onClick: () => y(t),
|
|
55
|
+
sx: { "&:hover": { textDecoration: "underline" } },
|
|
56
|
+
disableRipple: !0,
|
|
57
|
+
children: c
|
|
58
|
+
}
|
|
59
|
+
) : c;
|
|
51
60
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(e, t) => f === "type" ? e.type < t.type ? -1 : e.type > t.type ? 1 : 0 : e.name < t.name ? -1 : 1
|
|
60
|
-
).map((e) => {
|
|
61
|
-
const t = `variables.${e.type}.${e.propertyId}`;
|
|
62
|
-
return {
|
|
63
|
-
field: t,
|
|
64
|
-
headerName: e.name,
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
...(C = e == null ? void 0 : e.description) != null && C.hidden ? [] : [
|
|
64
|
+
{
|
|
65
|
+
field: "description",
|
|
66
|
+
headerName: "Description",
|
|
67
|
+
width: 400,
|
|
65
68
|
sortable: !1,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
filterable: !1,
|
|
70
|
+
valueGetter: (r) => r.row.description,
|
|
71
|
+
renderCell: (I = e == null ? void 0 : e.description) == null ? void 0 : I.renderCell
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
...l ? [
|
|
75
|
+
...l.properties.filter(
|
|
76
|
+
(r) => (!e || !e[r.propertyId] || !e[r.propertyId].hidden) && r.visible && r.type !== "geometry" && r.type !== "coordinate"
|
|
77
|
+
).sort(
|
|
78
|
+
(r, t) => G === "type" ? r.type < t.type ? -1 : r.type > t.type ? 1 : 0 : r.name < t.name ? -1 : 1
|
|
79
|
+
).map((r) => {
|
|
80
|
+
var c;
|
|
81
|
+
const t = `variables.${r.type}.${r.propertyId}`;
|
|
82
|
+
return {
|
|
83
|
+
field: t,
|
|
84
|
+
headerName: r.name,
|
|
85
|
+
sortable: !1,
|
|
86
|
+
filterable: !1,
|
|
87
|
+
width: 150,
|
|
88
|
+
valueFormatter: (n) => n.value && r.type === "date" ? P(n.value).format("DD/MM/YYYY HH:mm") : n.value,
|
|
89
|
+
valueGetter: (n) => T.get(n.row, t),
|
|
90
|
+
renderCell: e && ((c = e[r.propertyId]) == null ? void 0 : c.renderCell)
|
|
91
|
+
};
|
|
92
|
+
})
|
|
93
|
+
] : []
|
|
94
|
+
];
|
|
95
|
+
}, [l]), Y = (a) => {
|
|
96
|
+
H(a), d && d(a);
|
|
74
97
|
};
|
|
75
|
-
return /* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
98
|
+
return /* @__PURE__ */ j(A, { position: "relative", children: [
|
|
99
|
+
/* @__PURE__ */ o(
|
|
100
|
+
N,
|
|
78
101
|
{
|
|
79
|
-
columns:
|
|
80
|
-
rows:
|
|
102
|
+
columns: S,
|
|
103
|
+
rows: h,
|
|
81
104
|
autoHeight: !0,
|
|
82
105
|
density: "compact",
|
|
83
106
|
sx: {
|
|
84
107
|
border: "none",
|
|
85
108
|
"& .MuiDataGrid-main": {
|
|
86
|
-
marginRight:
|
|
109
|
+
marginRight: u ? `${m}px` : 0
|
|
87
110
|
}
|
|
88
111
|
},
|
|
89
|
-
getRowId: (
|
|
112
|
+
getRowId: (a) => a.id,
|
|
90
113
|
hideFooterPagination: !0,
|
|
91
114
|
hideFooter: !0,
|
|
92
|
-
checkboxSelection:
|
|
93
|
-
rowSelectionModel:
|
|
94
|
-
onRowSelectionModelChange:
|
|
115
|
+
checkboxSelection: M,
|
|
116
|
+
rowSelectionModel: F,
|
|
117
|
+
onRowSelectionModelChange: Y,
|
|
95
118
|
keepNonExistentRowsSelected: !0
|
|
96
119
|
}
|
|
97
120
|
),
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
u !== void 0 && /* @__PURE__ */ o(E, { width: m, children: /* @__PURE__ */ o(
|
|
122
|
+
N,
|
|
100
123
|
{
|
|
101
124
|
columns: [
|
|
102
125
|
{
|
|
103
126
|
field: "actions",
|
|
104
127
|
type: "actions",
|
|
105
|
-
width:
|
|
128
|
+
width: m,
|
|
106
129
|
headerClassName: "pinned",
|
|
107
|
-
getActions: () =>
|
|
130
|
+
getActions: () => u
|
|
108
131
|
}
|
|
109
132
|
],
|
|
110
|
-
rows:
|
|
133
|
+
rows: h,
|
|
111
134
|
autoHeight: !0,
|
|
112
135
|
density: "compact",
|
|
113
136
|
hideFooter: !0,
|
|
114
137
|
sx: { border: "none" },
|
|
115
138
|
slots: {
|
|
116
|
-
noRowsOverlay: () => /* @__PURE__ */
|
|
139
|
+
noRowsOverlay: () => /* @__PURE__ */ o(D, {})
|
|
117
140
|
},
|
|
118
|
-
getRowId: (
|
|
141
|
+
getRowId: (a) => a.id
|
|
119
142
|
}
|
|
120
143
|
) })
|
|
121
144
|
] });
|
|
122
145
|
};
|
|
123
146
|
export {
|
|
124
|
-
|
|
147
|
+
U as InstanceTable
|
|
125
148
|
};
|
package/dist/main.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { FC } from 'react';
|
|
|
15
15
|
import { Feature } from 'ol';
|
|
16
16
|
import { Geometry } from 'ol/geom';
|
|
17
17
|
import { GridActionsCellItemProps } from '@mui/x-data-grid';
|
|
18
|
+
import { GridRenderCellParams } from '@mui/x-data-grid';
|
|
18
19
|
import { IconButtonProps } from '@mui/material/IconButton';
|
|
19
20
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
20
21
|
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
@@ -413,6 +414,11 @@ declare interface InstanceHierarchyTableProps {
|
|
|
413
414
|
|
|
414
415
|
export declare const InstanceTable: FC<InstanceTableProps>;
|
|
415
416
|
|
|
417
|
+
declare interface InstanceTableFieldOptions {
|
|
418
|
+
hidden?: boolean;
|
|
419
|
+
renderCell?(params: GridRenderCellParams<any>): React.ReactElement;
|
|
420
|
+
}
|
|
421
|
+
|
|
416
422
|
declare interface InstanceTableProps {
|
|
417
423
|
template: ONTOLOGY.TemplateType;
|
|
418
424
|
data: INSTANCE.GenericInstanceView[];
|
|
@@ -421,6 +427,12 @@ declare interface InstanceTableProps {
|
|
|
421
427
|
sortColumnsBy?: "name" | "type";
|
|
422
428
|
actions?: React.ReactElement<GridActionsCellItemProps>[];
|
|
423
429
|
actionsWidth?: number;
|
|
430
|
+
fieldOptions?: {
|
|
431
|
+
templateIcon?: InstanceTableFieldOptions;
|
|
432
|
+
title?: InstanceTableFieldOptions;
|
|
433
|
+
description?: InstanceTableFieldOptions;
|
|
434
|
+
[key: string]: InstanceTableFieldOptions;
|
|
435
|
+
};
|
|
424
436
|
onSelect?(selectedIds: number[]): void;
|
|
425
437
|
onTitleClick?(instance: INSTANCE.GenericInstanceView): void;
|
|
426
438
|
}
|