@hybridcore/ui 1.5.43 → 1.5.44

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,42 +1,42 @@
1
- import { useRef as a, useState as l, useEffect as b } from "react";
2
- import { b64toBlob as g, printBlob as p, downloadBlob as w } from "./utils.js";
1
+ import { useRef as f, useState as s, useEffect as g } from "react";
2
+ import { b64toBlob as b, printBlob as w, downloadBlob as p } from "./utils.js";
3
3
  const D = ({
4
- data: o,
5
- title: s,
6
- rightPanel: c,
7
- rightPanelWidth: t = 450
4
+ data: e,
5
+ title: c,
6
+ rightPanel: u,
7
+ rightPanelWidth: n = 450
8
8
  }) => {
9
- const n = a(null), [e, u] = l();
10
- b(() => ((async () => {
11
- if (o) {
12
- const f = await g(o, "application/pdf");
13
- u(f);
9
+ const t = f(null), [o, a] = s();
10
+ g(() => ((async () => {
11
+ if (e) {
12
+ const i = await b(e, "application/pdf");
13
+ console.log(await i.text()), a(i);
14
14
  }
15
15
  })(), () => {
16
- }), [o]);
17
- const [r, i] = l(
18
- c ? t : 0
16
+ }), [e]);
17
+ const [l, r] = s(
18
+ u ? n : 0
19
19
  );
20
20
  return {
21
21
  refs: {
22
- viewer: n
22
+ viewer: t
23
23
  },
24
24
  state: {
25
- blob: e,
26
- rightPanelWidth: r
25
+ blob: o,
26
+ rightPanelWidth: l
27
27
  },
28
28
  action: {
29
29
  onPrint: () => {
30
- e && p(e);
30
+ o && w(o);
31
31
  },
32
32
  onFullScreen: () => {
33
- n.current && n.current.requestFullscreen();
33
+ t.current && t.current.requestFullscreen();
34
34
  },
35
35
  onDownload: () => {
36
- e && w(e, s);
36
+ o && p(o, c);
37
37
  },
38
38
  toggleRightPanel: () => {
39
- i(r ? 0 : t);
39
+ r(l ? 0 : n);
40
40
  }
41
41
  }
42
42
  };
@@ -1,41 +1,41 @@
1
1
  import { jsxs as c, jsx as i, Fragment as b } from "react/jsx-runtime";
2
2
  import { CloseOutlined as le, ChevronRight as ie, ErrorOutline as ne, Check as oe, Refresh as ae } from "@mui/icons-material";
3
- import { Dialog as de, DialogTitle as pe, Box as m, Typography as $, TextField as R, IconButton as J, DialogContent as se, DialogActions as ce, Button as W, FormControl as V, Select as _, MenuItem as A } from "@mui/material";
3
+ import { Dialog as de, DialogTitle as se, Box as m, Typography as $, TextField as D, IconButton as W, DialogContent as pe, DialogActions as ce, Button as V, FormControl as _, Select as H, MenuItem as A } from "@mui/material";
4
4
  import { DataGrid as fe } from "@mui/x-data-grid";
5
- import { useState as H, useEffect as ue } from "react";
5
+ import { useState as P, useEffect as ue } from "react";
6
6
  import h from "lodash";
7
7
  import { d as ye } from "../../ol-lGwSyEIV.js";
8
8
  import { V as he } from "../../index-OtGK6phq.js";
9
9
  import { RangeSelector as me } from "../range-selector/index.js";
10
10
  const $e = ({
11
- open: F,
12
- data: P,
11
+ open: I,
12
+ data: K,
13
13
  objectTemplate: q,
14
14
  agent: a,
15
15
  enableValueInput: T,
16
- loading: B,
17
- agentTemplates: K,
16
+ loading: E,
17
+ agentTemplates: j,
18
18
  catalogueInstances: v,
19
- objectInstance: I,
19
+ objectInstance: O,
20
20
  disableCatalogueSource: G,
21
21
  disableObjectSource: U,
22
22
  scenario: C,
23
- mapboxAccessToken: E,
23
+ mapboxAccessToken: z,
24
24
  onSubmit: M,
25
- onClose: O
25
+ onClose: N
26
26
  }) => {
27
- const [k, j] = H(P), [L, N] = H(/* @__PURE__ */ new Map());
28
- ue(() => (N(/* @__PURE__ */ new Map()), () => {
29
- }), [F]);
27
+ const [k, F] = P(K), [L, B] = P(/* @__PURE__ */ new Map());
28
+ ue(() => (B(/* @__PURE__ */ new Map()), I && F(K), () => {
29
+ }), [I]);
30
30
  const Q = () => {
31
31
  a ? M(a, !0) : M(k);
32
- }, D = (n) => {
33
- const { name: d, value: p } = n.target;
34
- let o = p;
32
+ }, R = (n) => {
33
+ const { name: d, value: s } = n.target;
34
+ let o = s;
35
35
  d === "criticalityScore" && (o = o.replace(",", "."), o = o.replace(/[^\d.-]+/g, "")), X(d)(o);
36
36
  }, X = (n) => (d) => {
37
37
  a && M({ ...a, [n]: d });
38
- }, S = (n, d, p, o) => (r) => {
38
+ }, S = (n, d, s, o) => (r) => {
39
39
  if (a) {
40
40
  let t = [...a.propertyInfoMap];
41
41
  const e = t.findIndex(
@@ -46,17 +46,17 @@ const $e = ({
46
46
  t.splice(e, 1, {
47
47
  ...t[e],
48
48
  value: l,
49
- source: p ? p || "" : t[e].source,
49
+ source: s ? s || "" : t[e].source,
50
50
  sourceField: o !== void 0 ? o || "" : t[e].sourceField
51
51
  }), M && M({ ...a, propertyInfoMap: t });
52
52
  }
53
53
  }
54
54
  }, Y = (n) => () => {
55
- const { policyKey: d, key: p, source: o, sourceField: r } = n;
55
+ const { policyKey: d, key: s, source: o, sourceField: r } = n;
56
56
  let t = "";
57
57
  if (o === "OBJECT")
58
58
  t = h.get(
59
- I,
59
+ O,
60
60
  `variables.${n.dataType.type}.${r}`
61
61
  );
62
62
  else if (o) {
@@ -70,25 +70,25 @@ const $e = ({
70
70
  v
71
71
  );
72
72
  }
73
- t && (S(d, p)({ value: t }), N((e) => {
73
+ t && (S(d, s)({ value: t }), B((e) => {
74
74
  const l = new Map(e);
75
75
  return l.set(
76
- `${h.get(a, "referenceObjectInstanceId")}:${d}:${p}`,
76
+ `${h.get(a, "referenceObjectInstanceId")}:${d}:${s}`,
77
77
  "Updated"
78
78
  ), l;
79
79
  }), setTimeout(() => {
80
- N((e) => {
80
+ B((e) => {
81
81
  const l = new Map(e);
82
82
  return l.set(
83
83
  `${h.get(
84
84
  a,
85
85
  "referenceObjectInstanceId"
86
- )}:${d}:${p}`,
86
+ )}:${d}:${s}`,
87
87
  "Default"
88
88
  ), l;
89
89
  });
90
90
  }, 2e3));
91
- }, Z = (n, d) => (p) => {
91
+ }, Z = (n, d) => (s) => {
92
92
  if (a) {
93
93
  let o = [...a.propertyInfoMap];
94
94
  const r = o.findIndex(
@@ -96,14 +96,14 @@ const $e = ({
96
96
  );
97
97
  o[r] && (o.splice(r, 1, {
98
98
  ...o[r],
99
- randomInfo: p
99
+ randomInfo: s
100
100
  }), M && M({ ...a, propertyInfoMap: o }));
101
101
  }
102
102
  }, ee = (n) => (d) => {
103
- const p = d.target.name;
103
+ const s = d.target.name;
104
104
  let o = [...k];
105
105
  const r = o[n], t = r.propertyMappings.findIndex(
106
- (l) => l.key === p
106
+ (l) => l.key === s
107
107
  ), e = r.propertyMappings[t];
108
108
  h.set(
109
109
  o,
@@ -113,31 +113,31 @@ const $e = ({
113
113
  o,
114
114
  `${n}.propertyMappings.${t}.sourceField`,
115
115
  ""
116
- ), j(o), a && S(
116
+ ), F(o), a && S(
117
117
  r.key,
118
118
  e.key,
119
119
  String(d.target.value),
120
120
  ""
121
121
  )({ value: "" });
122
122
  }, re = (n) => (d) => {
123
- const p = d.target.name;
123
+ const s = d.target.name;
124
124
  let o = [...k];
125
125
  const r = o[n], t = r.propertyMappings.findIndex(
126
- (l) => l.key === p
126
+ (l) => l.key === s
127
127
  ), e = r.propertyMappings[t];
128
128
  if (h.set(
129
129
  o,
130
130
  `${n}.propertyMappings.${t}.sourceField`,
131
131
  d.target.value
132
- ), j(o), T && a) {
132
+ ), F(o), T && a) {
133
133
  const l = h.get(
134
134
  o,
135
135
  `${n}.propertyMappings.${t}.source`
136
136
  );
137
137
  if (l === "OBJECT") {
138
- if (I) {
138
+ if (O) {
139
139
  const u = h.get(
140
- I.variables,
140
+ O.variables,
141
141
  `${e.dataType.type}.${d.target.value}`
142
142
  ) || "";
143
143
  S(
@@ -170,7 +170,7 @@ const $e = ({
170
170
  }
171
171
  }
172
172
  }, te = (n, d) => {
173
- let p = {
173
+ let s = {
174
174
  field: "value",
175
175
  headerName: "Value",
176
176
  sortable: !1,
@@ -180,39 +180,39 @@ const $e = ({
180
180
  renderCell: (r) => {
181
181
  var x, g;
182
182
  const { key: t, dataType: e } = r.row;
183
- let l = "", u = /* @__PURE__ */ i(b, {}), y = /* @__PURE__ */ i(b, {}), s = r.row.source;
183
+ let l = "", u = /* @__PURE__ */ i(b, {}), y = /* @__PURE__ */ i(b, {}), p = r.row.source;
184
184
  if (T && a) {
185
185
  const f = a.propertyInfoMap.find(
186
186
  (w) => w.key === t && w.policyKey === n.key
187
187
  );
188
188
  if (f) {
189
- const { valid: w, validationErrors: z } = f;
190
- l = f.value, s = f.source, w === !1 && (u = /* @__PURE__ */ i(
189
+ const { valid: w, validationErrors: J } = f;
190
+ l = f.value, p = f.source, w === !1 && (u = /* @__PURE__ */ i(
191
191
  ne,
192
192
  {
193
193
  color: "error",
194
194
  fontSize: "small",
195
195
  sx: { ml: 1 },
196
- titleAccess: z ? z.join(", ") : "Value is not valid!"
196
+ titleAccess: J ? J.join(", ") : "Value is not valid!"
197
197
  }
198
- )), s && (L.get(
198
+ )), p && (L.get(
199
199
  `${h.get(a, "referenceObjectInstanceId")}:${f.policyKey}:${f.key}`
200
200
  ) === "Updated" ? y = /* @__PURE__ */ i(oe, { color: "success", sx: { mr: 1 }, titleAccess: "Updated" }) : y = /* @__PURE__ */ i(
201
- J,
201
+ W,
202
202
  {
203
203
  onClick: Y(f),
204
- title: `Reload value from the ${s === "OBJECT" ? "Object" : "Catalogue"}`,
204
+ title: `Reload value from the ${p === "OBJECT" ? "Object" : "Catalogue"}`,
205
205
  children: /* @__PURE__ */ i(ae, {})
206
206
  }
207
207
  ));
208
208
  }
209
- if (s === "STATIC") {
209
+ if (p === "STATIC") {
210
210
  const w = (x = C == null ? void 0 : C.environment.context) != null && x.boundingBox ? ye(C.environment.context.boundingBox) : void 0;
211
211
  return /* @__PURE__ */ c(b, { children: [
212
212
  /* @__PURE__ */ i(
213
213
  he,
214
214
  {
215
- mapboxAccessToken: E,
215
+ mapboxAccessToken: z,
216
216
  property: {
217
217
  propertyId: "value",
218
218
  type: e.type,
@@ -231,7 +231,7 @@ const $e = ({
231
231
  u
232
232
  ] });
233
233
  }
234
- if (s === "RANDOM" || s === "SMART_RANDOM")
234
+ if (p === "RANDOM" || p === "SMART_RANDOM")
235
235
  return /* @__PURE__ */ c(b, { children: [
236
236
  /* @__PURE__ */ i(
237
237
  me,
@@ -241,7 +241,7 @@ const $e = ({
241
241
  innerType: (g = e.innerType) == null ? void 0 : g.type,
242
242
  minDate: C ? C.startTime : "",
243
243
  maxDate: C ? C.endTime : "",
244
- mapboxAccessToken: E,
244
+ mapboxAccessToken: z,
245
245
  onChange: Z(n.key, t)
246
246
  }
247
247
  ),
@@ -339,8 +339,8 @@ const $e = ({
339
339
  );
340
340
  e && (t = e.source || "");
341
341
  }
342
- return /* @__PURE__ */ i(V, { fullWidth: !0, size: "small", children: /* @__PURE__ */ c(
343
- _,
342
+ return /* @__PURE__ */ i(_, { fullWidth: !0, size: "small", children: /* @__PURE__ */ c(
343
+ H,
344
344
  {
345
345
  onChange: ee(d),
346
346
  name: String(r.id),
@@ -365,26 +365,26 @@ const $e = ({
365
365
  const { dataType: t } = r.row;
366
366
  let e = r.row.source, l = r.row.sourceField;
367
367
  if (a) {
368
- const s = a.propertyInfoMap.find(
368
+ const p = a.propertyInfoMap.find(
369
369
  (x) => x.policyKey === n.key && x.key === r.id
370
370
  );
371
- s && (e = s.source, l = s.sourceField || "");
371
+ p && (e = p.source, l = p.sourceField || "");
372
372
  }
373
373
  let u = l || "";
374
374
  if (e === "RANDOM" || e === "STATIC" || e === "SMART_RANDOM")
375
375
  return /* @__PURE__ */ i(b, {});
376
376
  let y = [];
377
377
  if (e === "OBJECT")
378
- y = q.properties.map((s) => ({
379
- value: s.propertyId,
380
- text: s.name
378
+ y = q.properties.map((p) => ({
379
+ value: p.propertyId,
380
+ text: p.name
381
381
  }));
382
382
  else if (e !== null) {
383
- const s = Number(e), x = v == null ? void 0 : v.find(
384
- (g) => g.id === s
383
+ const p = Number(e), x = v == null ? void 0 : v.find(
384
+ (g) => g.id === p
385
385
  );
386
- if (x && K) {
387
- const g = K.find(
386
+ if (x && j) {
387
+ const g = j.find(
388
388
  (f) => f.templateKey === x.template.templateKey
389
389
  );
390
390
  g && (y = g.properties.map((f) => ({
@@ -393,14 +393,14 @@ const $e = ({
393
393
  })));
394
394
  }
395
395
  }
396
- return /* @__PURE__ */ i(V, { fullWidth: !0, size: "small", children: /* @__PURE__ */ c(
397
- _,
396
+ return /* @__PURE__ */ i(_, { fullWidth: !0, size: "small", children: /* @__PURE__ */ c(
397
+ H,
398
398
  {
399
399
  onChange: re(d),
400
400
  name: String(r.id),
401
401
  value: u,
402
402
  children: [
403
- y.map((s, x) => /* @__PURE__ */ i(A, { value: s.value, children: s.text }, x)),
403
+ y.map((p, x) => /* @__PURE__ */ i(A, { value: p.value, children: p.text }, x)),
404
404
  y.length === 0 && /* @__PURE__ */ c(A, { disabled: !0, children: [
405
405
  "No ",
406
406
  t.type,
@@ -412,11 +412,11 @@ const $e = ({
412
412
  }
413
413
  }
414
414
  ];
415
- return T ? [...o, p] : o;
415
+ return T ? [...o, s] : o;
416
416
  };
417
- return /* @__PURE__ */ c(de, { open: F, fullWidth: !0, maxWidth: "lg", onClose: O, children: [
417
+ return /* @__PURE__ */ c(de, { open: I, fullWidth: !0, maxWidth: "lg", onClose: N, children: [
418
418
  /* @__PURE__ */ c(
419
- pe,
419
+ se,
420
420
  {
421
421
  component: "div",
422
422
  lineHeight: 1,
@@ -436,13 +436,13 @@ const $e = ({
436
436
  minWidth: 200,
437
437
  children: [
438
438
  /* @__PURE__ */ i(
439
- R,
439
+ D,
440
440
  {
441
441
  name: "name",
442
442
  variant: "standard",
443
443
  value: a.name,
444
444
  placeholder: "Add name",
445
- onChange: D,
445
+ onChange: R,
446
446
  sx: {
447
447
  "& .MuiInputBase-root:before": {
448
448
  border: "none"
@@ -451,14 +451,14 @@ const $e = ({
451
451
  }
452
452
  ),
453
453
  "description" in a && /* @__PURE__ */ i(
454
- R,
454
+ D,
455
455
  {
456
456
  name: "description",
457
457
  variant: "standard",
458
458
  size: "small",
459
459
  value: a.description,
460
460
  placeholder: "Add description",
461
- onChange: D,
461
+ onChange: R,
462
462
  sx: {
463
463
  "& .MuiInputBase-root:before": {
464
464
  border: "none"
@@ -471,7 +471,7 @@ const $e = ({
471
471
  ),
472
472
  /* @__PURE__ */ c(m, { ml: 4, children: [
473
473
  "count" in a && /* @__PURE__ */ i(
474
- R,
474
+ D,
475
475
  {
476
476
  name: "count",
477
477
  label: "Count",
@@ -479,11 +479,11 @@ const $e = ({
479
479
  required: !0,
480
480
  sx: { width: 100, mr: 1 },
481
481
  value: a.count,
482
- onChange: D
482
+ onChange: R
483
483
  }
484
484
  ),
485
485
  "criticalityScore" in a && /* @__PURE__ */ i(
486
- R,
486
+ D,
487
487
  {
488
488
  name: "criticalityScore",
489
489
  label: "Criticality Score",
@@ -492,26 +492,26 @@ const $e = ({
492
492
  title: "Should be between 0 and 1",
493
493
  sx: { width: 150 },
494
494
  value: a.criticalityScore,
495
- onChange: D
495
+ onChange: R
496
496
  }
497
497
  )
498
498
  ] })
499
499
  ] }) }),
500
- /* @__PURE__ */ i(m, { flex: 1, textAlign: "end", children: /* @__PURE__ */ i(J, { onClick: O, children: /* @__PURE__ */ i(le, {}) }) })
500
+ /* @__PURE__ */ i(m, { flex: 1, textAlign: "end", children: /* @__PURE__ */ i(W, { onClick: N, children: /* @__PURE__ */ i(le, {}) }) })
501
501
  ]
502
502
  }
503
503
  ),
504
- /* @__PURE__ */ i(se, { sx: { minHeight: 300 }, children: k.map((n, d) => /* @__PURE__ */ c(
504
+ /* @__PURE__ */ i(pe, { sx: { minHeight: 300 }, children: k.map((n, d) => /* @__PURE__ */ c(
505
505
  m,
506
506
  {
507
- boxShadow: (p) => p.shadows[1],
507
+ boxShadow: (s) => s.shadows[1],
508
508
  mt: 0.1,
509
509
  mb: 2,
510
510
  overflow: "hidden",
511
511
  borderRadius: 1,
512
512
  children: [
513
513
  /* @__PURE__ */ c(m, { display: "flex", alignItems: "center", p: 2, children: [
514
- /* @__PURE__ */ i($, { children: n.catalogInstances.map((p) => p.name).join(", ") }),
514
+ /* @__PURE__ */ i($, { children: n.catalogInstances.map((s) => s.name).join(", ") }),
515
515
  /* @__PURE__ */ i(ie, { color: "disabled", sx: { mx: 1 } }),
516
516
  /* @__PURE__ */ i($, { variant: "caption", color: "GrayText", children: n.name || n.key })
517
517
  ] }),
@@ -525,12 +525,12 @@ const $e = ({
525
525
  sx: {
526
526
  border: "none",
527
527
  "& .MuiDataGrid-columnHeadersInner": {
528
- backgroundColor: (p) => p.palette.grey[200]
528
+ backgroundColor: (s) => s.palette.grey[200]
529
529
  }
530
530
  },
531
531
  hideFooterPagination: !0,
532
532
  hideFooter: !0,
533
- getRowId: (p) => p.key
533
+ getRowId: (s) => s.key
534
534
  }
535
535
  )
536
536
  ]
@@ -538,15 +538,15 @@ const $e = ({
538
538
  d
539
539
  )) }),
540
540
  /* @__PURE__ */ c(ce, { children: [
541
- /* @__PURE__ */ i(W, { color: "inherit", variant: "contained", onClick: O, children: "Cancel" }),
541
+ /* @__PURE__ */ i(V, { color: "inherit", variant: "contained", onClick: N, children: "Cancel" }),
542
542
  /* @__PURE__ */ i(
543
- W,
543
+ V,
544
544
  {
545
545
  color: "primary",
546
546
  variant: "contained",
547
- disabled: k.length === 0 || B,
547
+ disabled: k.length === 0 || E,
548
548
  onClick: Q,
549
- children: B ? "Saving..." : "Save"
549
+ children: E ? "Saving..." : "Save"
550
550
  }
551
551
  )
552
552
  ] })
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.43",
4
+ "version": "1.5.44",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",