@oliasoft-open-source/react-ui-library 5.7.0-beta-16 → 5.7.0-beta-18

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/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export declare enum Align {
35
35
  CENTER = "center"
36
36
  }
37
37
 
38
- export declare function AuditLog({ logs, data, total, loading, selectedPage, rowsPerPage, filterToggles, onChangeRowsPerPage, onSelectPage, }: IAuditLogProps): JSX_2.Element;
38
+ export declare const AuditLog: React.FC<IAuditLogProps>;
39
39
 
40
40
  export declare interface AuditLogItem {
41
41
  id: string;
@@ -43,13 +43,13 @@ export declare interface AuditLogItem {
43
43
  operation: AuditLogOperation;
44
44
  source: AuditLogSource;
45
45
  createdAt: string;
46
- diffs: JsonDelta | JsonDelta[];
46
+ diffs: JsonDelta | JsonDelta[] | null;
47
47
  operationMetaData?: string;
48
48
  }
49
49
 
50
- declare type AuditLogOperation = 'Created' | 'Cloned' | 'Reverted' | 'Imported' | 'Updated';
50
+ export declare type AuditLogOperation = 'Created' | 'Cloned' | 'Reverted' | 'Imported' | 'Updated';
51
51
 
52
- declare type AuditLogSource = 'System' | 'Application' | 'API';
52
+ export declare type AuditLogSource = 'System' | 'Application' | 'API';
53
53
 
54
54
  export declare const Badge: ({ children, color, title, dot, margin, small, }: IBadgeProps) => JSX_2.Element;
55
55
 
@@ -200,6 +200,7 @@ declare interface IAuditLogProps {
200
200
  selectedPage: number;
201
201
  rowsPerPage: number;
202
202
  filterToggles?: FilterToggle[];
203
+ sectionNames: ISectionName[];
203
204
  onSelectPage: (page: number) => void;
204
205
  onChangeRowsPerPage: (n: number) => void;
205
206
  data: any;
@@ -1253,6 +1254,11 @@ declare interface IScrollDetails {
1253
1254
  infiniteScroll?: boolean;
1254
1255
  }
1255
1256
 
1257
+ declare interface ISectionName {
1258
+ sectionKey: string;
1259
+ sectionLabel: string;
1260
+ }
1261
+
1256
1262
  declare interface ISelectCell extends TCommonCell {
1257
1263
  type: TCellType;
1258
1264
  name?: string;
package/dist/index.js CHANGED
@@ -6569,7 +6569,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6569
6569
  } : {
6570
6570
  value: G,
6571
6571
  unit: U
6572
- }), Ad = k || K?.value === void 0, [J, jd] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Md = !!(O || n), Y = C && C.find((e) => {
6572
+ }), Od = k || K?.value === void 0, [J, kd] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Ad = !!(O || n), Y = C && C.find((e) => {
6573
6573
  if (!e?.value) return;
6574
6574
  if (E) return E === e.valueKey;
6575
6575
  let t = isValueWithUnit(e.value) ? getUnit(e.value) : "", { value: n = l } = convertUnit({
@@ -6578,7 +6578,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6578
6578
  toUnit: t
6579
6579
  });
6580
6580
  return withUnit(n, t) === e.value;
6581
- }), Nd = () => {
6581
+ }), jd = () => {
6582
6582
  let e = l ?? "", t = K.unit;
6583
6583
  if (checkConversion({
6584
6584
  value: e,
@@ -6592,7 +6592,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6592
6592
  return null;
6593
6593
  }
6594
6594
  } else return getAltUnitsListByQuantity(u)?.map((e) => ["", e?.unit]);
6595
- }, Pd = (t) => {
6595
+ }, Md = (t) => {
6596
6596
  let n = getStringName(e), r = t.target, { value: i, selectionStart: a } = r, o = withUnit(i, K?.unit || ""), s = A ? withUnit(convertAndGetValue(o, B), B) : o;
6597
6597
  h({ target: {
6598
6598
  value: s,
@@ -6605,7 +6605,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6605
6605
  }), R(() => {
6606
6606
  r.selectionStart = a, r.selectionEnd = a;
6607
6607
  });
6608
- }, Fd = (e, t) => {
6608
+ }, Nd = (e, t) => {
6609
6609
  t === K.unit || isNaN(Number(e)) || (q({
6610
6610
  value: e,
6611
6611
  unit: t
@@ -6636,7 +6636,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6636
6636
  e !== void 0 && q({
6637
6637
  value: e,
6638
6638
  unit: t
6639
- }), C && jd(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6639
+ }), C && kd(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6640
6640
  }
6641
6641
  }, [
6642
6642
  U,
@@ -6644,7 +6644,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6644
6644
  i,
6645
6645
  T
6646
6646
  ]);
6647
- let X = Nd(), Z = label(K.unit) || K.unit || "", Id = p || !X || X && X.length === 1, Q = getStringName(e), $, Ld = (t) => {
6647
+ let X = jd(), Z = label(K.unit) || K.unit || "", Pd = p || !X || X && X.length === 1, Q = getStringName(e), $, Fd = (t) => {
6648
6648
  let r = t?.value ? t.value : "", [i = "", a = ""] = isValueWithUnit(r) ? split(r) : [r], o = withPrettyUnitLabel(r);
6649
6649
  if (checkConversion({
6650
6650
  value: r,
@@ -6664,7 +6664,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6664
6664
  type: MenuType.OPTION,
6665
6665
  inline: !0,
6666
6666
  onClick: () => {
6667
- validateNumber(i).valid && !n && (jd(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6667
+ validateNumber(i).valid && !n && (kd(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6668
6668
  value: r,
6669
6669
  name: typeof e == "string" ? e : e?.fieldName || "",
6670
6670
  predefinedSelected: !0,
@@ -6691,10 +6691,10 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6691
6691
  label: "Custom",
6692
6692
  selected: J === PredefinedOptionsMenuState.CUSTOM
6693
6693
  }], C?.length) {
6694
- let e = C.map(Ld);
6694
+ let e = C.map(Fd);
6695
6695
  $ = [...$, ...e];
6696
6696
  }
6697
- let Rd = (e) => {
6697
+ let Id = (e) => {
6698
6698
  if (isValueWithUnit(e)) {
6699
6699
  let t = getUnit(e), { value: n } = safeConvertValue({
6700
6700
  value: e,
@@ -6706,7 +6706,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6706
6706
  return n;
6707
6707
  }
6708
6708
  return e;
6709
- }, zd = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Bd = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6709
+ }, Ld = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Rd = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6710
6710
  return /* @__PURE__ */ jsx("div", {
6711
6711
  className: J === PredefinedOptionsMenuState.PREDEFINED ? cx(unit_input_module_default.predefinedMenuActive) : "",
6712
6712
  children: /* @__PURE__ */ jsxs(InputGroup, {
@@ -6738,31 +6738,31 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6738
6738
  name: Q,
6739
6739
  testId: x,
6740
6740
  disabled: n,
6741
- placeholder: Rd(t),
6741
+ placeholder: Id(t),
6742
6742
  value: K.value,
6743
- onChange: Pd,
6743
+ onChange: Md,
6744
6744
  onFocus: v,
6745
6745
  error: i === null ? void 0 : i,
6746
6746
  warning: S === null ? void 0 : S,
6747
6747
  left: a,
6748
- allowEmpty: Ad,
6748
+ allowEmpty: Od,
6749
6749
  validationCallback: (e, t) => D(Q, t),
6750
6750
  enableCosmeticRounding: j,
6751
6751
  enableDisplayRounding: M,
6752
6752
  roundDisplayValue: N,
6753
- groupOrder: zd,
6754
- disableInternalErrorValidationMessages: Md,
6753
+ groupOrder: Ld,
6754
+ disableInternalErrorValidationMessages: Ad,
6755
6755
  small: o,
6756
6756
  selectOnFocus: P,
6757
6757
  tooltip: I
6758
6758
  }, Q)
6759
6759
  }),
6760
- Z && (Id || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6761
- groupOrder: Bd,
6760
+ Z && (Pd || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6761
+ groupOrder: Rd,
6762
6762
  small: o,
6763
6763
  children: Z
6764
6764
  }) : /* @__PURE__ */ jsx(Menu, {
6765
- groupOrder: Bd,
6765
+ groupOrder: Rd,
6766
6766
  maxHeight: 380,
6767
6767
  disabled: r,
6768
6768
  testId: x && `${x}-menu`,
@@ -6778,7 +6778,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6778
6778
  label: j ? safeRoundNumbers(i) : i,
6779
6779
  inline: !0,
6780
6780
  onClick: (n) => {
6781
- n.stopPropagation(), Fd(e, t);
6781
+ n.stopPropagation(), Nd(e, t);
6782
6782
  },
6783
6783
  description: r,
6784
6784
  selected: r === Z,
@@ -7040,8 +7040,8 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7040
7040
  }, [n]);
7041
7041
  let s = ({ target: { value: e } }) => {
7042
7042
  a(e);
7043
- }, { added: l, removed: u } = renderLinesCount(e, t), d = l + u, f = d > 3500;
7044
- return console.log("typeof ReactDiffViewer:", typeof ReactDiffViewer), console.log(typeof e, typeof t), console.log("logs", n, l, u, d, f, DiffMethod.WORDS), /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Card, {
7043
+ }, { added: l, removed: u } = renderLinesCount(e, t), d = l + u > 3500;
7044
+ return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Card, {
7045
7045
  bordered: !0,
7046
7046
  heading: /* @__PURE__ */ jsxs(Flex, {
7047
7047
  gap: !0,
@@ -7055,7 +7055,7 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7055
7055
  }), /* @__PURE__ */ jsxs(Text, {
7056
7056
  error: !0,
7057
7057
  children: ["-", u]
7058
- })] }) }), !f && /* @__PURE__ */ jsx(RadioButton, {
7058
+ })] }) }), !d && /* @__PURE__ */ jsx(RadioButton, {
7059
7059
  name: "viewType",
7060
7060
  options: o,
7061
7061
  value: i,
@@ -7064,7 +7064,7 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7064
7064
  })]
7065
7065
  }),
7066
7066
  padding: !1,
7067
- children: f ? /* @__PURE__ */ jsx("div", {
7067
+ children: d ? /* @__PURE__ */ jsx("div", {
7068
7068
  style: { padding: "5px" },
7069
7069
  children: /* @__PURE__ */ jsx(Text, {
7070
7070
  muted: !0,
@@ -8329,80 +8329,77 @@ diff_match_patch.Diff = function(e, t) {
8329
8329
  }
8330
8330
  return n.join("").replace(/%20/g, " ");
8331
8331
  };
8332
- const createDiffPatcher = (e = {}) => create({
8332
+ var jsondiffpatcher = ((e = {}) => create({
8333
8333
  ...e,
8334
8334
  textDiff: {
8335
8335
  diffMatchPatch: diff_match_patch,
8336
8336
  minLength: 120
8337
8337
  },
8338
8338
  cloneDiffValues: !0
8339
- });
8340
- var sectionMap = Object.fromEntries([
8341
- {
8342
- sectionKey: "hierarchy",
8343
- sectionLabel: "Hierarchy"
8344
- },
8345
- {
8346
- sectionKey: "hierarchyPermissions",
8347
- sectionLabel: "Hierarchy Permissions"
8348
- },
8349
- {
8350
- sectionKey: "hierarchyOptionalParameters",
8351
- sectionLabel: "Hierarchy Optional Parameters"
8352
- },
8353
- {
8354
- sectionKey: "appearance",
8355
- sectionLabel: "General"
8356
- },
8357
- {
8358
- sectionKey: "generalUnitPrecision",
8359
- sectionLabel: "General — Unit Precision"
8360
- },
8361
- {
8362
- sectionKey: "trajectory",
8363
- sectionLabel: "Trajectory"
8364
- },
8365
- {
8366
- sectionKey: "antiCollision",
8367
- sectionLabel: "Anti-Collision"
8368
- },
8369
- {
8370
- sectionKey: "casingDesign",
8371
- sectionLabel: "Casing Design"
8372
- },
8373
- {
8374
- sectionKey: "annularFluidExpansion",
8375
- sectionLabel: "Annular Fluid Expansion"
8376
- },
8377
- {
8378
- sectionKey: "drillingMechanics",
8379
- sectionLabel: "Drilling Mechanics"
8380
- },
8381
- {
8382
- sectionKey: "wear",
8383
- sectionLabel: "Drilling Mechanics"
8384
- },
8385
- {
8386
- sectionKey: "tempsim",
8387
- sectionLabel: "Temperature Simulation"
8388
- },
8389
- {
8390
- sectionKey: "libraries",
8391
- sectionLabel: "Libraries"
8392
- },
8393
- {
8394
- sectionKey: "automaticDesign",
8395
- sectionLabel: "Automatic Design"
8396
- },
8397
- {
8398
- sectionKey: "webhooks",
8399
- sectionLabel: "Webhooks"
8400
- }
8401
- ].map((e) => [e.sectionKey, e.sectionLabel]));
8402
- const getSectionName = (e) => {
8403
- for (let t = e.length - 1; t >= 0; t--) {
8404
- let n = e[t], r = sectionMap[n];
8405
- if (r) return r;
8339
+ }))(), isObj = (e) => isObject(e) && !Array.isArray(e), countOne = (e) => {
8340
+ let t = {
8341
+ total: 0,
8342
+ added: 0,
8343
+ removed: 0,
8344
+ modified: 0,
8345
+ moved: 0,
8346
+ text: 0
8347
+ }, n = (e) => {
8348
+ if (Array.isArray(e)) {
8349
+ let n = e[0];
8350
+ if (typeof n == "string" && n.startsWith("@@")) {
8351
+ t.text++, t.total++;
8352
+ return;
8353
+ }
8354
+ if (e.length === 1) {
8355
+ t.added++, t.total++;
8356
+ return;
8357
+ }
8358
+ if (e.length === 2) {
8359
+ t.modified++, t.total++;
8360
+ return;
8361
+ }
8362
+ if (e.length === 3) {
8363
+ let n = e[2];
8364
+ if (n === 0) {
8365
+ t.removed++, t.total++;
8366
+ return;
8367
+ }
8368
+ if (n === 3) {
8369
+ t.moved++, t.total++;
8370
+ return;
8371
+ }
8372
+ t.modified++, t.total++;
8373
+ return;
8374
+ }
8375
+ t.modified++, t.total++;
8376
+ return;
8377
+ }
8378
+ if (isObj(e)) {
8379
+ if (e._t === "a") {
8380
+ for (let t in e) t !== "_t" && n(e[t]);
8381
+ return;
8382
+ }
8383
+ for (let t in e) n(e[t]);
8384
+ }
8385
+ };
8386
+ return n(e), t;
8387
+ };
8388
+ const countDeltas = (e) => (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) => {
8389
+ let n = countOne(t);
8390
+ return e.total += n.total, e.added += n.added, e.removed += n.removed, e.modified += n.modified, e.moved += n.moved, e.text += n.text, e;
8391
+ }, {
8392
+ total: 0,
8393
+ added: 0,
8394
+ removed: 0,
8395
+ modified: 0,
8396
+ moved: 0,
8397
+ text: 0
8398
+ }), getSectionName = (e, t) => {
8399
+ let n = Object.fromEntries(e.map((e) => [e.sectionKey, e.sectionLabel]));
8400
+ for (let e = t.length - 1; e >= 0; e--) {
8401
+ let r = t[e], i = n[r];
8402
+ if (i) return i;
8406
8403
  }
8407
8404
  return "";
8408
8405
  }, defaultMessage = (e) => {
@@ -8437,25 +8434,49 @@ const getSectionName = (e) => {
8437
8434
  after: ""
8438
8435
  };
8439
8436
  }
8440
- }, ChangesOverview = ({ diffs: e }) => {
8441
- let t = {
8437
+ };
8438
+ var isDeltaArray = (e) => Array.isArray(e), unpatchWith = (e, t) => t ? isDeltaArray(t) ? t.length === 0 ? e : t.reduce((e, t) => jsondiffpatcher.unpatch(cloneDeep(e), cloneDeep(t)), cloneDeep(e)) : jsondiffpatcher.unpatch(cloneDeep(e), cloneDeep(t)) : e;
8439
+ const createDiffJson = (e, t, n) => {
8440
+ let r = t.filter((t) => !!t.diffs && t.createdAt >= e.createdAt), i = Array(r.length + 1);
8441
+ i[0] = cloneDeep(n);
8442
+ let a = "", o = "";
8443
+ try {
8444
+ for (let e = 0; e < r.length; e++) {
8445
+ let t = r[e]?.diffs ?? null;
8446
+ if (!t) {
8447
+ i[e + 1] = i[e];
8448
+ continue;
8449
+ }
8450
+ i[e + 1] = unpatchWith(i[e], t);
8451
+ }
8452
+ let e = r.length > 0 ? i[r.length - 1] : n, t = r.length > 0 ? i[r.length] : n;
8453
+ a = JSON.stringify(t ?? "", null, 2), o = JSON.stringify(e ?? "", null, 2);
8454
+ } catch (e) {
8455
+ console.error("err", e);
8456
+ }
8457
+ return {
8458
+ oldJson: a,
8459
+ newJson: o
8460
+ };
8461
+ }, ChangesOverview = ({ sectionNames: e, diffs: t }) => {
8462
+ let n = {
8442
8463
  headers: [{ cells: [
8443
8464
  { value: "Type" },
8444
8465
  { value: "Before" },
8445
8466
  { value: "After" },
8446
8467
  { value: "" }
8447
8468
  ] }],
8448
- rows: e.map((e) => {
8449
- let { deltaFormat: t, path: n } = e, r = getSectionName(n), { type: i, before: a, after: o } = defaultMessage(t);
8469
+ rows: t.map((t) => {
8470
+ let { deltaFormat: n, path: r } = t, i = getSectionName(e, r), { type: a, before: o, after: s } = defaultMessage(n);
8450
8471
  return { cells: [
8451
- { value: i },
8452
8472
  { value: a },
8453
8473
  { value: o },
8454
- { value: r }
8474
+ { value: s },
8475
+ { value: i }
8455
8476
  ] };
8456
8477
  })
8457
8478
  };
8458
- return /* @__PURE__ */ jsx(Table, { table: t });
8479
+ return /* @__PURE__ */ jsx(Table, { table: n });
8459
8480
  }, viewTypes = Object.freeze({
8460
8481
  summary: {
8461
8482
  label: "Summary",
@@ -8466,7 +8487,7 @@ const getSectionName = (e) => {
8466
8487
  value: "compare"
8467
8488
  }
8468
8489
  });
8469
- var jsondiffpatcher = createDiffPatcher(), isDeltaArray = (e) => Array.isArray(e), unpatchWith = (e, t) => t ? isDeltaArray(t) ? t.length === 0 ? e : t.reduce((e, t) => jsondiffpatcher.unpatch(cloneDeep(e), cloneDeep(t)), cloneDeep(e)) : jsondiffpatcher.unpatch(cloneDeep(e), cloneDeep(t)) : e, transformDiffs = (e) => {
8490
+ var transformDiffs = (e) => {
8470
8491
  let t = ["user", "unittemplate"], n = [], r = [], i = (e) => {
8471
8492
  e && Object.keys(e).forEach((a) => {
8472
8493
  t.includes(a) || (r.push(a), isArray(e[a]) ? n.push({
@@ -8477,37 +8498,14 @@ var jsondiffpatcher = createDiffPatcher(), isDeltaArray = (e) => Array.isArray(e
8477
8498
  };
8478
8499
  return e ? (i(e), n) : [];
8479
8500
  };
8480
- const createDiffJson = (e, t, n) => {
8481
- let r = t.filter((t) => !!t.diffs && t.createdAt >= e.createdAt), i = Array(r.length + 1);
8482
- i[0] = cloneDeep(n);
8483
- let a = "", o = "";
8484
- try {
8485
- for (let e = 0; e < r.length; e++) {
8486
- let t = r[e]?.diffs ?? null;
8487
- if (!t) {
8488
- i[e + 1] = i[e];
8489
- continue;
8490
- }
8491
- i[e + 1] = unpatchWith(i[e], t);
8492
- }
8493
- let e = r.length > 0 ? i[r.length - 1] : n, t = r.length > 0 ? i[r.length] : n;
8494
- a = JSON.stringify(t ?? "", null, 2), o = JSON.stringify(e ?? "", null, 2);
8495
- } catch (e) {
8496
- console.error("err", e);
8497
- }
8498
- return {
8499
- oldJson: a,
8500
- newJson: o
8501
- };
8502
- };
8503
- var comparison_view_modal_default = ({ auditLog: e, auditLogs: t, data: n, isOpen: r, onClose: i }) => {
8504
- let { diffs: a = void 0 } = e || {};
8505
- if (!a) return null;
8506
- let o = [viewTypes.summary, viewTypes.compare].map(({ label: e, value: t }) => ({
8501
+ const ComparisonViewModal = ({ auditLog: e, auditLogs: t, data: n, isOpen: r, sectionNames: i, onClose: a }) => {
8502
+ let { diffs: o = void 0 } = e || {};
8503
+ if (!o) return null;
8504
+ let s = [viewTypes.summary, viewTypes.compare].map(({ label: e, value: t }) => ({
8507
8505
  label: e,
8508
8506
  value: t
8509
- })), [s, c] = useState(o[0]), { oldJson: l, newJson: u } = createDiffJson(e, t, n);
8510
- return console.log(typeof l, typeof u), console.log("React gui library:", l, u), /* @__PURE__ */ jsx(Modal, {
8507
+ })), [c, l] = useState(s[0]), { oldJson: u, newJson: d } = createDiffJson(e, t, n);
8508
+ return /* @__PURE__ */ jsx(Modal, {
8511
8509
  visible: r,
8512
8510
  centered: !0,
8513
8511
  children: /* @__PURE__ */ jsx(Dialog, { dialog: {
@@ -8515,86 +8513,27 @@ var comparison_view_modal_default = ({ auditLog: e, auditLogs: t, data: n, isOpe
8515
8513
  heading: "Comparison view",
8516
8514
  content: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tabs, {
8517
8515
  name: "ViewTab",
8518
- onChange: (e) => c(o.find((t) => t.value === e.target.value)),
8519
- options: o,
8520
- value: s
8521
- }), s.value === "summary" ? /* @__PURE__ */ jsx(ChangesOverview, { diffs: transformDiffs(a) }) : /* @__PURE__ */ jsx(DiffViewer, {
8522
- oldJson: l,
8523
- newJson: u
8516
+ onChange: (e) => l(s.find((t) => t.value === e.target.value)),
8517
+ options: s,
8518
+ value: c
8519
+ }), c.value === "summary" ? /* @__PURE__ */ jsx(ChangesOverview, {
8520
+ sectionNames: i,
8521
+ diffs: transformDiffs(o)
8522
+ }) : /* @__PURE__ */ jsx(DiffViewer, {
8523
+ oldJson: u,
8524
+ newJson: d
8524
8525
  })] }),
8525
8526
  footer: /* @__PURE__ */ jsx(Button, {
8526
8527
  label: "Cancel",
8527
- onClick: i
8528
+ onClick: a
8528
8529
  }),
8529
- onClose: i,
8530
+ onClose: a,
8530
8531
  width: "90vw",
8531
8532
  height: "90vh"
8532
8533
  } })
8533
8534
  });
8534
- }, isObj = (e) => !!e && typeof e == "object" && !Array.isArray(e), countOne = (e) => {
8535
- let t = {
8536
- total: 0,
8537
- added: 0,
8538
- removed: 0,
8539
- modified: 0,
8540
- moved: 0,
8541
- text: 0
8542
- }, n = (e) => {
8543
- if (Array.isArray(e)) {
8544
- let n = e[0];
8545
- if (typeof n == "string" && n.startsWith("@@")) {
8546
- t.text++, t.total++;
8547
- return;
8548
- }
8549
- if (e.length === 1) {
8550
- t.added++, t.total++;
8551
- return;
8552
- }
8553
- if (e.length === 2) {
8554
- t.modified++, t.total++;
8555
- return;
8556
- }
8557
- if (e.length === 3) {
8558
- let n = e[2];
8559
- if (n === 0) {
8560
- t.removed++, t.total++;
8561
- return;
8562
- }
8563
- if (n === 3) {
8564
- t.moved++, t.total++;
8565
- return;
8566
- }
8567
- t.modified++, t.total++;
8568
- return;
8569
- }
8570
- t.modified++, t.total++;
8571
- return;
8572
- }
8573
- if (isObj(e)) {
8574
- if (e._t === "a") {
8575
- for (let t in e) t !== "_t" && n(e[t]);
8576
- return;
8577
- }
8578
- for (let t in e) n(e[t]);
8579
- }
8580
- };
8581
- return n(e), t;
8582
- };
8583
- function countDeltas(e) {
8584
- return (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) => {
8585
- let n = countOne(t);
8586
- return e.total += n.total, e.added += n.added, e.removed += n.removed, e.modified += n.modified, e.moved += n.moved, e.text += n.text, e;
8587
- }, {
8588
- total: 0,
8589
- added: 0,
8590
- removed: 0,
8591
- modified: 0,
8592
- moved: 0,
8593
- text: 0
8594
- });
8595
- }
8596
- function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, rowsPerPage: a, filterToggles: o = [], onChangeRowsPerPage: s, onSelectPage: c }) {
8597
- let [l, u] = useState(!1), [d, f] = useState(null), p = [
8535
+ }, AuditLog = ({ logs: e, data: t, total: n, loading: r, selectedPage: i, rowsPerPage: a, sectionNames: o, filterToggles: s = [], onChangeRowsPerPage: c, onSelectPage: l }) => {
8536
+ let [u, d] = useState(!1), [f, p] = useState(null), h = [
8598
8537
  {
8599
8538
  label: "10 / page",
8600
8539
  value: 10
@@ -8611,7 +8550,7 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8611
8550
  label: "Show all",
8612
8551
  value: 0
8613
8552
  }
8614
- ], h = ({ diffs: e, userName: t, source: n, operation: r, operationMetaData: i }) => {
8553
+ ], g = ({ diffs: e, userName: t, source: n, operation: r, operationMetaData: i }) => {
8615
8554
  let a = countDeltas(e), o = a.total ? `${a.total} change${a.total === 1 ? "" : "s"}` : "no field changes";
8616
8555
  if (n === "API") return r === "Created" ? `Created through API by ${t || "Unknown user"}` : `Changed through API by ${t || "Unknown user"}`;
8617
8556
  switch (r) {
@@ -8622,18 +8561,18 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8622
8561
  case "Updated": return `Updated by ${t} (${o})`;
8623
8562
  default: return `Change by ${t}`;
8624
8563
  }
8625
- }, g = [{ cells: [
8564
+ }, _ = [{ cells: [
8626
8565
  { value: "Change" },
8627
8566
  { value: "Modified by" },
8628
8567
  { value: "Using" },
8629
8568
  { value: "Operation" },
8630
8569
  { value: "Date" }
8631
- ] }], _ = e.map((e) => ({ cells: [
8570
+ ] }], v = e.map((e) => ({ cells: [
8632
8571
  {
8633
- value: h(e),
8572
+ value: g(e),
8634
8573
  type: "Link",
8635
8574
  onClick: () => {
8636
- u(!0), f(e);
8575
+ d(!0), p(e);
8637
8576
  },
8638
8577
  breakWord: !0
8639
8578
  },
@@ -8661,7 +8600,7 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8661
8600
  heading: /* @__PURE__ */ jsxs(Flex, {
8662
8601
  gap: !0,
8663
8602
  wrap: !0,
8664
- children: [/* @__PURE__ */ jsx(Heading, { children: "CHANGES" }), o?.map((e) => /* @__PURE__ */ jsx(Toggle, {
8603
+ children: [/* @__PURE__ */ jsx(Heading, { children: "CHANGES" }), s?.map((e) => /* @__PURE__ */ jsx(Toggle, {
8665
8604
  small: e.small ?? !0,
8666
8605
  checked: e.checked,
8667
8606
  onChange: e.onChange,
@@ -8675,8 +8614,8 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8675
8614
  theme: Theme.WHITE,
8676
8615
  children: /* @__PURE__ */ jsx(Spinner, { dark: !0 })
8677
8616
  }) : /* @__PURE__ */ jsx(Table, { table: {
8678
- headers: g,
8679
- rows: _,
8617
+ headers: _,
8618
+ rows: v,
8680
8619
  fixedWidth: "100%",
8681
8620
  bordered: !1,
8682
8621
  actionsRight: !0,
@@ -8686,24 +8625,24 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8686
8625
  rowsPerPage: {
8687
8626
  onChange: (e) => {
8688
8627
  let { value: t } = e.target;
8689
- s(Number(t));
8628
+ c(Number(t));
8690
8629
  },
8691
- options: p,
8630
+ options: h,
8692
8631
  value: a
8693
8632
  },
8694
- onSelectPage: (e) => c(e),
8633
+ onSelectPage: (e) => l(e),
8695
8634
  small: !0
8696
8635
  } }
8697
8636
  } })
8698
- }), l && d && /* @__PURE__ */ jsx(comparison_view_modal_default, {
8699
- isOpen: l,
8700
- onClose: () => u(!1),
8637
+ }), u && f && /* @__PURE__ */ jsx(ComparisonViewModal, {
8638
+ sectionNames: o,
8639
+ isOpen: u,
8640
+ onClose: () => d(!1),
8701
8641
  auditLogs: e,
8702
- auditLog: d,
8642
+ auditLog: f,
8703
8643
  data: t
8704
8644
  })] });
8705
- }
8706
- const isPrimitiveValue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null, initializeGuiLibrary = (e) => {
8645
+ }, isPrimitiveValue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null, initializeGuiLibrary = (e) => {
8707
8646
  setConfig(ConfigKeyType.LanguageKey, e.languageKey), Object.entries(e).forEach(([e, t]) => {
8708
8647
  if (e === ConfigKeyType.Translations) setConfig(e, getTranslations(t));
8709
8648
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "5.7.0-beta-16",
3
+ "version": "5.7.0-beta-18",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {