@hybridcore/ui 1.5.64 → 1.5.66

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,26 +1,26 @@
1
- import { jsx as a, Fragment as D, jsxs as Y } from "react/jsx-runtime";
1
+ import { jsx as o, Fragment as D, jsxs as Y } from "react/jsx-runtime";
2
2
  import { useMemo as j } from "react";
3
- import { DataGrid as N } from "@mui/x-data-grid";
3
+ import { DataGrid as G, GridActionsCellItem as A } from "@mui/x-data-grid";
4
4
  import { ButtonBase as B, Box as S } from "@mui/material";
5
5
  import { DataGridActions as $ } from "./styled.js";
6
- import k from "dayjs";
7
- import A from "lodash";
8
- const K = ({
9
- template: l,
10
- data: h,
11
- selectedIds: R = [],
12
- sortColumnsBy: G = "type",
13
- actions: u,
14
- actionsWidth: m = 50,
15
- enableCheckboxSelection: M = !1,
6
+ import i from "dayjs";
7
+ import E from "lodash";
8
+ const L = ({
9
+ template: n,
10
+ data: w,
11
+ selectedIds: M = [],
12
+ sortColumnsBy: N = "type",
13
+ actions: h,
14
+ actionsWidth: y = 50,
15
+ enableCheckboxSelection: R = !1,
16
16
  fieldOptions: e,
17
- onSelect: d,
18
- onTitleClick: y
17
+ onSelect: s,
18
+ onTitleClick: C
19
19
  }) => {
20
- const F = j(() => {
21
- var w, g, v, b, s, x, C, I;
20
+ const k = j(() => {
21
+ var l, c, d, g, v, b, x, I;
22
22
  return [
23
- ...(w = e == null ? void 0 : e.templateIcon) != null && w.hidden ? [] : [
23
+ ...(l = e == null ? void 0 : e.templateIcon) != null && l.hidden ? [] : [
24
24
  {
25
25
  field: "template",
26
26
  headerName: "",
@@ -28,17 +28,17 @@ const K = ({
28
28
  filterable: !1,
29
29
  align: "center",
30
30
  width: 30,
31
- renderCell: (g = e == null ? void 0 : e.templateIcon) != null && g.renderCell ? (v = e == null ? void 0 : e.templateIcon) == null ? void 0 : v.renderCell : () => l ? /* @__PURE__ */ a(
31
+ renderCell: (c = e == null ? void 0 : e.templateIcon) != null && c.renderCell ? (d = e == null ? void 0 : e.templateIcon) == null ? void 0 : d.renderCell : () => n ? /* @__PURE__ */ o(
32
32
  "img",
33
33
  {
34
- src: l.icon,
34
+ src: n.icon,
35
35
  height: 20,
36
36
  style: { display: "inline", maxWidth: 20 }
37
37
  }
38
- ) : /* @__PURE__ */ a(D, {})
38
+ ) : /* @__PURE__ */ o(D, {})
39
39
  }
40
40
  ],
41
- ...(b = e == null ? void 0 : e.title) != null && b.hidden ? [] : [
41
+ ...(g = e == null ? void 0 : e.title) != null && g.hidden ? [] : [
42
42
  {
43
43
  field: "title",
44
44
  headerName: "Title",
@@ -46,21 +46,21 @@ const K = ({
46
46
  sortable: !1,
47
47
  filterable: !1,
48
48
  valueGetter: (r) => r.row.title,
49
- renderCell: (s = e == null ? void 0 : e.title) != null && s.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__ */ a(
49
+ renderCell: (v = e == null ? void 0 : e.title) != null && v.renderCell ? (b = e == null ? void 0 : e.title) == null ? void 0 : b.renderCell : (r) => {
50
+ const { row: a, value: u } = r;
51
+ return C ? /* @__PURE__ */ o(
52
52
  B,
53
53
  {
54
- onClick: () => y(t),
54
+ onClick: () => C(a),
55
55
  sx: { "&:hover": { textDecoration: "underline" } },
56
56
  disableRipple: !0,
57
- children: c
57
+ children: u
58
58
  }
59
- ) : c;
59
+ ) : u;
60
60
  }
61
61
  }
62
62
  ],
63
- ...(C = e == null ? void 0 : e.description) != null && C.hidden ? [] : [
63
+ ...(x = e == null ? void 0 : e.description) != null && x.hidden ? [] : [
64
64
  {
65
65
  field: "description",
66
66
  headerName: "Description",
@@ -71,78 +71,90 @@ const K = ({
71
71
  renderCell: (I = e == null ? void 0 : e.description) == null ? void 0 : I.renderCell
72
72
  }
73
73
  ],
74
- ...l ? [
75
- ...l.properties.filter(
74
+ ...n ? [
75
+ ...n.properties.filter(
76
76
  (r) => (!e || !e[r.propertyId] || !e[r.propertyId].hidden) && r.visible && r.type !== "geometry" && r.type !== "coordinate"
77
77
  ).sort(
78
- (r, t) => G === "type" ? r.type < t.type ? -1 : r.type > t.type ? 1 : 0 : r.name < t.name ? -1 : 1
78
+ (r, a) => N === "type" ? r.type < a.type ? -1 : r.type > a.type ? 1 : 0 : r.name < a.name ? -1 : 1
79
79
  ).map((r) => {
80
- var c;
81
- const t = `variables.${r.type}.${r.propertyId}`;
80
+ var u;
81
+ const a = `variables.${r.type}.${r.propertyId}`;
82
82
  return {
83
- field: t,
83
+ field: a,
84
84
  headerName: r.name,
85
85
  sortable: !1,
86
86
  filterable: !1,
87
87
  width: 150,
88
- valueFormatter: (n) => n.value && r.type === "date" ? k(n.value).format("DD/MM/YYYY HH:mm") : n.value,
89
- valueGetter: (n) => A.get(n.row, t),
90
- renderCell: e && ((c = e[r.propertyId]) == null ? void 0 : c.renderCell)
88
+ valueFormatter: (m) => m.value && r.type === "date" ? i(m.value).format("DD/MM/YYYY HH:mm") : m.value,
89
+ valueGetter: (m) => E.get(m.row, a),
90
+ renderCell: e && ((u = e[r.propertyId]) == null ? void 0 : u.renderCell)
91
91
  };
92
92
  })
93
93
  ] : []
94
94
  ];
95
- }, [l]), H = (o) => {
96
- d && d(o);
97
- };
95
+ }, [n]), F = (t) => {
96
+ s && s(t);
97
+ }, H = (t) => h ? h.map((l) => {
98
+ const { showInMenu: c, ...d } = l;
99
+ return /* @__PURE__ */ o(
100
+ A,
101
+ {
102
+ ...d,
103
+ ...c ? { showInMenu: c } : void 0,
104
+ onClick: () => {
105
+ l.onClick && l.onClick(t);
106
+ }
107
+ }
108
+ );
109
+ }) : [];
98
110
  return /* @__PURE__ */ Y(S, { position: "relative", children: [
99
- /* @__PURE__ */ a(
100
- N,
111
+ /* @__PURE__ */ o(
112
+ G,
101
113
  {
102
- columns: F,
103
- rows: h,
114
+ columns: k,
115
+ rows: w,
104
116
  autoHeight: !0,
105
117
  density: "compact",
106
118
  sx: {
107
119
  border: "none",
108
120
  "& .MuiDataGrid-main": {
109
- marginRight: u ? `${m}px` : 0
121
+ marginRight: h ? `${y}px` : 0
110
122
  }
111
123
  },
112
- getRowId: (o) => o.id,
124
+ getRowId: (t) => t.id,
113
125
  hideFooterPagination: !0,
114
126
  hideFooter: !0,
115
- checkboxSelection: M,
116
- rowSelectionModel: R,
117
- onRowSelectionModelChange: H,
127
+ checkboxSelection: R,
128
+ rowSelectionModel: M,
129
+ onRowSelectionModelChange: F,
118
130
  keepNonExistentRowsSelected: !0
119
131
  }
120
132
  ),
121
- u !== void 0 && /* @__PURE__ */ a($, { width: m, children: /* @__PURE__ */ a(
122
- N,
133
+ h !== void 0 && /* @__PURE__ */ o($, { width: y, children: /* @__PURE__ */ o(
134
+ G,
123
135
  {
124
136
  columns: [
125
137
  {
126
138
  field: "actions",
127
139
  type: "actions",
128
- width: m,
140
+ width: y,
129
141
  headerClassName: "pinned",
130
- getActions: () => u
142
+ getActions: H
131
143
  }
132
144
  ],
133
- rows: h,
145
+ rows: w,
134
146
  autoHeight: !0,
135
147
  density: "compact",
136
148
  hideFooter: !0,
137
149
  sx: { border: "none" },
138
150
  slots: {
139
- noRowsOverlay: () => /* @__PURE__ */ a(D, {})
151
+ noRowsOverlay: () => /* @__PURE__ */ o(D, {})
140
152
  },
141
- getRowId: (o) => o.id
153
+ getRowId: (t) => t.id
142
154
  }
143
155
  ) })
144
156
  ] });
145
157
  };
146
158
  export {
147
- K as InstanceTable
159
+ L as InstanceTable
148
160
  };
@@ -3,6 +3,7 @@ const o = [
3
3
  "boolean",
4
4
  "byte",
5
5
  "composite-list",
6
+ "composite-matrix",
6
7
  "coordinate",
7
8
  "date",
8
9
  "double",
package/dist/main.d.ts CHANGED
@@ -14,8 +14,9 @@ import { Extent } from 'ol/extent';
14
14
  import { FC } from 'react';
15
15
  import { Feature } from 'ol';
16
16
  import { Geometry } from 'ol/geom';
17
- import { GridActionsCellItemProps } from '@mui/x-data-grid';
18
17
  import { GridRenderCellParams } from '@mui/x-data-grid';
18
+ import { GridRowParams } from '@mui/x-data-grid';
19
+ import { IconButtonClasses } from '@mui/material';
19
20
  import { IconButtonProps } from '@mui/material/IconButton';
20
21
  import { JSX as JSX_2 } from 'react/jsx-runtime';
21
22
  import { LocalizationProvider } from '@mui/x-date-pickers';
@@ -424,7 +425,7 @@ declare interface InstanceHierarchyTableProps {
424
425
  selectedIds?: number[];
425
426
  enableCheckboxSelection?: boolean;
426
427
  sortColumnsBy?: "name" | "type";
427
- actions?: React.ReactElement<GridActionsCellItemProps>[];
428
+ actions?: InstanceTableActionType[];
428
429
  actionsWidth?: number;
429
430
  onSelect?(selectedIds: number[]): void;
430
431
  onTitleClick?(instance: INSTANCE.GenericInstanceView): void;
@@ -432,6 +433,29 @@ declare interface InstanceHierarchyTableProps {
432
433
 
433
434
  export declare const InstanceTable: FC<InstanceTableProps>;
434
435
 
436
+ export declare interface InstanceTableActionType {
437
+ label: string;
438
+ icon: React.ReactElement;
439
+ showInMenu?: boolean;
440
+ children?: React.ReactNode;
441
+ classes?: Partial<IconButtonClasses>;
442
+ color?:
443
+ | "inherit"
444
+ | "default"
445
+ | "warning"
446
+ | "error"
447
+ | "success"
448
+ | "info"
449
+ | "primary"
450
+ | "secondary";
451
+ disabled?: boolean;
452
+ disableFocusRipple?: boolean;
453
+ edge?: false | "end" | "start";
454
+ size?: "medium" | "large" | "small";
455
+ sx?: SxProps;
456
+ onClick?(params: GridRowParams<INSTANCE.GenericInstanceView>): void;
457
+ }
458
+
435
459
  declare interface InstanceTableFieldOptions {
436
460
  hidden?: boolean;
437
461
  renderCell?(params: GridRenderCellParams<any>): React.ReactElement;
@@ -443,7 +467,7 @@ declare interface InstanceTableProps {
443
467
  selectedIds?: number[];
444
468
  enableCheckboxSelection?: boolean;
445
469
  sortColumnsBy?: "name" | "type";
446
- actions?: React.ReactElement<GridActionsCellItemProps>[];
470
+ actions?: InstanceTableActionType[];
447
471
  actionsWidth?: number;
448
472
  fieldOptions?: {
449
473
  templateIcon?: InstanceTableFieldOptions;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridcore/ui",
3
3
  "description": "Hybrid Core UI Library",
4
- "version": "1.5.64",
4
+ "version": "1.5.66",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",