@hybridcore/ui 1.5.63 → 1.5.65

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
  };
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;
@@ -936,16 +960,23 @@ export declare interface TemplateFormHandle {
936
960
  }
937
961
 
938
962
  declare interface TemplateFormProps<
939
- T extends ONTOLOGY.Object | ONTOLOGY.Event | ONTOLOGY.Agent | ONTOLOGY.File,
963
+ T extends
964
+ | ONTOLOGY.Object
965
+ | ONTOLOGY.Event
966
+ | ONTOLOGY.Agent
967
+ | ONTOLOGY.File
968
+ | ONTOLOGY.System,
940
969
  K extends
941
970
  | ONTOLOGY.CreateObjectDTO
942
971
  | ONTOLOGY.CreateEventDTO
943
972
  | ONTOLOGY.CreateFileDTO
944
973
  | ONTOLOGY.CreateAgentDTO
974
+ | ONTOLOGY.CreateSystemOntologyDTO
945
975
  | ONTOLOGY.UpdateObjectDTO
946
976
  | ONTOLOGY.UpdateEventDTO
947
977
  | ONTOLOGY.UpdateFileDTO
948
978
  | ONTOLOGY.UpdateAgentDTO
979
+ | ONTOLOGY.UpdateSystemOntologyDTO
949
980
  > {
950
981
  mappedTemplates: Map<string | number, T>;
951
982
 
@@ -954,10 +985,12 @@ K extends
954
985
  ONTOLOGY.CreateEventDTO &
955
986
  ONTOLOGY.CreateFileDTO &
956
987
  ONTOLOGY.CreateAgentDTO &
988
+ ONTOLOGY.CreateSystemOntologyDTO &
957
989
  ONTOLOGY.UpdateObjectDTO &
958
990
  ONTOLOGY.UpdateEventDTO &
959
991
  ONTOLOGY.UpdateFileDTO &
960
- ONTOLOGY.UpdateAgentDTO
992
+ ONTOLOGY.UpdateAgentDTO &
993
+ ONTOLOGY.UpdateSystemOntologyDTO
961
994
  >;
962
995
  loading?: boolean;
963
996
  agentTemplates?: Map<string | number, ONTOLOGY.Agent>;
@@ -1562,11 +1595,40 @@ declare namespace INSTANCE {
1562
1595
  id: number;
1563
1596
  }
1564
1597
 
1598
+ interface System {
1599
+ id: number;
1600
+ title: string;
1601
+ description: string;
1602
+ template: ONTOLOGY.GenericTemplateView;
1603
+ templateHierarchy: ONTOLOGY.GenericTemplateView[];
1604
+ variables: GroupedVariables;
1605
+ createDate?: string;
1606
+ createUser?: string;
1607
+ updateDate?: string;
1608
+ updateUser?: string;
1609
+ securityLevelId: number;
1610
+ disseminationList: string[];
1611
+ }
1612
+
1613
+ interface CreateSystemDTO {
1614
+ title: string;
1615
+ templateId: number;
1616
+ description?: string;
1617
+ variables: Variable;
1618
+ securityLevelId: number;
1619
+ disseminationList: string[];
1620
+ }
1621
+
1622
+ interface UpdateSystemDTO extends CreateSystemDTO {
1623
+ id: number;
1624
+ }
1625
+
1565
1626
  type InstanceType =
1566
1627
  | INSTANCE.Object
1567
1628
  | INSTANCE.Event
1568
1629
  | INSTANCE.File
1569
- | INSTANCE.Agent;
1630
+ | INSTANCE.Agent
1631
+ | INSTANCE.System;
1570
1632
  }
1571
1633
 
1572
1634
  declare namespace ONTOLOGY {
@@ -1767,11 +1829,45 @@ declare namespace ONTOLOGY {
1767
1829
  id: number;
1768
1830
  }
1769
1831
 
1832
+ interface System {
1833
+ id: number;
1834
+ templateKey: string;
1835
+ name: string;
1836
+ description: string;
1837
+ type: string;
1838
+ ontologyId: number;
1839
+ parent: string;
1840
+ icon: string;
1841
+ properties: Property[];
1842
+ version: any;
1843
+ creatable: boolean;
1844
+ editable: boolean;
1845
+ }
1846
+
1847
+ interface CreateSystemOntologyDTO {
1848
+ templateKey: string;
1849
+ name: string;
1850
+ description: string;
1851
+ type: string;
1852
+ ontologyId: number;
1853
+ parent: string;
1854
+ icon: string;
1855
+ properties: Property[];
1856
+ version: any;
1857
+ creatable: boolean;
1858
+ editable: boolean;
1859
+ }
1860
+
1861
+ interface UpdateSystemOntologyDTO extends CreateSystemOntologyDTO {
1862
+ id: number;
1863
+ }
1864
+
1770
1865
  type TemplateType =
1771
1866
  | ONTOLOGY.Object
1772
1867
  | ONTOLOGY.Event
1773
1868
  | ONTOLOGY.Agent
1774
- | ONTOLOGY.File;
1869
+ | ONTOLOGY.File
1870
+ | ONTOLOGY.System;
1775
1871
  }
1776
1872
 
1777
1873
  declare namespace POLICY {
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.63",
4
+ "version": "1.5.65",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",