@hybridcore/ui 1.5.23 → 1.5.25

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.
@@ -1,125 +1,148 @@
1
- import { jsx as i, Fragment as c, jsxs as x } from "react/jsx-runtime";
2
- import { useState as b, useMemo as R } from "react";
3
- import { DataGrid as m } from "@mui/x-data-grid";
4
- import { ButtonBase as D, Box as M } from "@mui/material";
5
- import { DataGridActions as N } from "./styled.js";
6
- import F from "dayjs";
7
- import G from "lodash";
8
- const $ = ({
9
- template: n,
10
- data: s,
11
- selectedIds: p = [],
12
- sortColumnsBy: f = "type",
13
- actions: l,
14
- actionsWidth: a = 50,
15
- enableCheckboxSelection: h = !1,
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: u
18
+ onTitleClick: y
18
19
  }) => {
19
- const [y, g] = b(p), w = R(() => [
20
- {
21
- field: "template",
22
- headerName: "",
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
- src: n.icon,
31
- height: 20,
32
- style: { display: "inline", maxWidth: 20 }
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
- ) : /* @__PURE__ */ i(c, {})
35
- },
36
- {
37
- field: "title",
38
- headerName: "Title",
39
- width: 400,
40
- sortable: !1,
41
- valueGetter: (e) => e.row.title,
42
- renderCell: (e) => {
43
- const { row: t, value: r } = e;
44
- return u ? /* @__PURE__ */ i(
45
- D,
46
- {
47
- onClick: () => u(t),
48
- sx: { "&:hover": { textDecoration: "underline" } },
49
- disableRipple: !0,
50
- children: r
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
- ) : r;
53
- }
54
- },
55
- ...n ? [
56
- ...n.properties.filter(
57
- (e) => e.visible && e.type !== "geometry" && e.type !== "coordinate"
58
- ).sort(
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
- width: 150,
67
- valueFormatter: (r) => r.value && e.type === "date" ? F(r.value).format("DD/MM/YYYY HH:mm") : r.value,
68
- valueGetter: (r) => G.get(r.row, t)
69
- };
70
- })
71
- ] : []
72
- ], [n]), v = (o) => {
73
- g(o), d && d(o);
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__ */ x(M, { position: "relative", children: [
76
- /* @__PURE__ */ i(
77
- m,
98
+ return /* @__PURE__ */ j(A, { position: "relative", children: [
99
+ /* @__PURE__ */ o(
100
+ N,
78
101
  {
79
- columns: w,
80
- rows: s,
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: l ? `${a}px` : 0
109
+ marginRight: u ? `${m}px` : 0
87
110
  }
88
111
  },
89
- getRowId: (o) => o.id,
112
+ getRowId: (a) => a.id,
90
113
  hideFooterPagination: !0,
91
114
  hideFooter: !0,
92
- checkboxSelection: h,
93
- rowSelectionModel: y,
94
- onRowSelectionModelChange: v,
115
+ checkboxSelection: M,
116
+ rowSelectionModel: F,
117
+ onRowSelectionModelChange: Y,
95
118
  keepNonExistentRowsSelected: !0
96
119
  }
97
120
  ),
98
- l !== void 0 && /* @__PURE__ */ i(N, { width: a, children: /* @__PURE__ */ i(
99
- m,
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: a,
128
+ width: m,
106
129
  headerClassName: "pinned",
107
- getActions: () => l
130
+ getActions: () => u
108
131
  }
109
132
  ],
110
- rows: s,
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__ */ i(c, {})
139
+ noRowsOverlay: () => /* @__PURE__ */ o(D, {})
117
140
  },
118
- getRowId: (o) => o.id
141
+ getRowId: (a) => a.id
119
142
  }
120
143
  ) })
121
144
  ] });
122
145
  };
123
146
  export {
124
- $ as InstanceTable
147
+ U as InstanceTable
125
148
  };