@oliasoft-open-source/react-ui-library 5.7.0-beta-15 → 5.7.0-beta-17

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,7 +43,7 @@ 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
 
@@ -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;
@@ -2112,6 +2118,26 @@ declare const TRANSLATION_FALLBACK: {
2112
2118
  allUsers: string;
2113
2119
  adminOnly: string;
2114
2120
  custom: string;
2121
+ created: string;
2122
+ modified: string;
2123
+ using: string;
2124
+ operation: string;
2125
+ date: string;
2126
+ changes: string;
2127
+ change: string;
2128
+ modifiedBy: string;
2129
+ updatedBy: string;
2130
+ createdBy: string;
2131
+ clonedBy: string;
2132
+ revertedBy: string;
2133
+ importedBy: string;
2134
+ singularChange: string;
2135
+ pluralChanges: string;
2136
+ createdThroughApiBy: string;
2137
+ changedThroughApiBy: string;
2138
+ showAll: string;
2139
+ rowsPerPage: string;
2140
+ unknown: string;
2115
2141
  };
2116
2142
 
2117
2143
  export declare const Tree: ({ list, draggable, onListReorder, onChangeOpen, testId, isInitialOpen, treeRef, itemHasChild, onItemToggle, icons, allowParentReassignment, stickyHeader, }: ITreeProps) => JSX_2.Element;
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,
@@ -6802,7 +6802,27 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6802
6802
  companySettingDifferent: "Company setting is different",
6803
6803
  allUsers: "All users",
6804
6804
  adminOnly: "Admin only",
6805
- custom: "Custom"
6805
+ custom: "Custom",
6806
+ created: "Created",
6807
+ modified: "Modified",
6808
+ using: "Using",
6809
+ operation: "Operation",
6810
+ date: "Date",
6811
+ changes: "Changes",
6812
+ change: "Change",
6813
+ modifiedBy: "Modified by",
6814
+ updatedBy: "Updated by {{userName}} ({{changes}})",
6815
+ createdBy: "Created by {{userName}}",
6816
+ clonedBy: "Created by {{username}} from {{operationMetaData}}",
6817
+ revertedBy: "Reverted by {{userName}}",
6818
+ importedBy: "Imported by {{userName}}",
6819
+ singularChange: "change",
6820
+ pluralChanges: "changes",
6821
+ createdThroughApiBy: "Created through API by {{userName}}",
6822
+ changedThroughApiBy: "Changed through API by {{userName}}",
6823
+ showAll: "Show all",
6824
+ rowsPerPage: "{{rows}} / page",
6825
+ unknown: "Unknown"
6806
6826
  }, getTranslations = (e) => Object.keys(TRANSLATION_FALLBACK).reduce((t, n) => ({
6807
6827
  ...t,
6808
6828
  [n]: e?.[n] || TRANSLATION_FALLBACK?.[n]
@@ -7020,8 +7040,8 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7020
7040
  }, [n]);
7021
7041
  let s = ({ target: { value: e } }) => {
7022
7042
  a(e);
7023
- }, { added: l, removed: u } = renderLinesCount(e, t), d = l + u, f = d > 3500;
7024
- 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, {
7025
7045
  bordered: !0,
7026
7046
  heading: /* @__PURE__ */ jsxs(Flex, {
7027
7047
  gap: !0,
@@ -7035,7 +7055,7 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7035
7055
  }), /* @__PURE__ */ jsxs(Text, {
7036
7056
  error: !0,
7037
7057
  children: ["-", u]
7038
- })] }) }), !f && /* @__PURE__ */ jsx(RadioButton, {
7058
+ })] }) }), !d && /* @__PURE__ */ jsx(RadioButton, {
7039
7059
  name: "viewType",
7040
7060
  options: o,
7041
7061
  value: i,
@@ -7044,7 +7064,7 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7044
7064
  })]
7045
7065
  }),
7046
7066
  padding: !1,
7047
- children: f ? /* @__PURE__ */ jsx("div", {
7067
+ children: d ? /* @__PURE__ */ jsx("div", {
7048
7068
  style: { padding: "5px" },
7049
7069
  children: /* @__PURE__ */ jsx(Text, {
7050
7070
  muted: !0,
@@ -8309,80 +8329,77 @@ diff_match_patch.Diff = function(e, t) {
8309
8329
  }
8310
8330
  return n.join("").replace(/%20/g, " ");
8311
8331
  };
8312
- const createDiffPatcher = (e = {}) => create({
8332
+ var jsondiffpatcher = ((e = {}) => create({
8313
8333
  ...e,
8314
8334
  textDiff: {
8315
8335
  diffMatchPatch: diff_match_patch,
8316
8336
  minLength: 120
8317
8337
  },
8318
8338
  cloneDiffValues: !0
8319
- });
8320
- var sectionMap = Object.fromEntries([
8321
- {
8322
- sectionKey: "hierarchy",
8323
- sectionLabel: "Hierarchy"
8324
- },
8325
- {
8326
- sectionKey: "hierarchyPermissions",
8327
- sectionLabel: "Hierarchy Permissions"
8328
- },
8329
- {
8330
- sectionKey: "hierarchyOptionalParameters",
8331
- sectionLabel: "Hierarchy Optional Parameters"
8332
- },
8333
- {
8334
- sectionKey: "appearance",
8335
- sectionLabel: "General"
8336
- },
8337
- {
8338
- sectionKey: "generalUnitPrecision",
8339
- sectionLabel: "General — Unit Precision"
8340
- },
8341
- {
8342
- sectionKey: "trajectory",
8343
- sectionLabel: "Trajectory"
8344
- },
8345
- {
8346
- sectionKey: "antiCollision",
8347
- sectionLabel: "Anti-Collision"
8348
- },
8349
- {
8350
- sectionKey: "casingDesign",
8351
- sectionLabel: "Casing Design"
8352
- },
8353
- {
8354
- sectionKey: "annularFluidExpansion",
8355
- sectionLabel: "Annular Fluid Expansion"
8356
- },
8357
- {
8358
- sectionKey: "drillingMechanics",
8359
- sectionLabel: "Drilling Mechanics"
8360
- },
8361
- {
8362
- sectionKey: "wear",
8363
- sectionLabel: "Drilling Mechanics"
8364
- },
8365
- {
8366
- sectionKey: "tempsim",
8367
- sectionLabel: "Temperature Simulation"
8368
- },
8369
- {
8370
- sectionKey: "libraries",
8371
- sectionLabel: "Libraries"
8372
- },
8373
- {
8374
- sectionKey: "automaticDesign",
8375
- sectionLabel: "Automatic Design"
8376
- },
8377
- {
8378
- sectionKey: "webhooks",
8379
- sectionLabel: "Webhooks"
8380
- }
8381
- ].map((e) => [e.sectionKey, e.sectionLabel]));
8382
- const getSectionName = (e) => {
8383
- for (let t = e.length - 1; t >= 0; t--) {
8384
- let n = e[t], r = sectionMap[n];
8385
- 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;
8386
8403
  }
8387
8404
  return "";
8388
8405
  }, defaultMessage = (e) => {
@@ -8417,25 +8434,49 @@ const getSectionName = (e) => {
8417
8434
  after: ""
8418
8435
  };
8419
8436
  }
8420
- }, ChangesOverview = ({ diffs: e }) => {
8421
- 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 = {
8422
8463
  headers: [{ cells: [
8423
8464
  { value: "Type" },
8424
8465
  { value: "Before" },
8425
8466
  { value: "After" },
8426
8467
  { value: "" }
8427
8468
  ] }],
8428
- rows: e.map((e) => {
8429
- 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);
8430
8471
  return { cells: [
8431
- { value: i },
8432
8472
  { value: a },
8433
8473
  { value: o },
8434
- { value: r }
8474
+ { value: s },
8475
+ { value: i }
8435
8476
  ] };
8436
8477
  })
8437
8478
  };
8438
- return /* @__PURE__ */ jsx(Table, { table: t });
8479
+ return /* @__PURE__ */ jsx(Table, { table: n });
8439
8480
  }, viewTypes = Object.freeze({
8440
8481
  summary: {
8441
8482
  label: "Summary",
@@ -8446,7 +8487,7 @@ const getSectionName = (e) => {
8446
8487
  value: "compare"
8447
8488
  }
8448
8489
  });
8449
- 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) => {
8450
8491
  let t = ["user", "unittemplate"], n = [], r = [], i = (e) => {
8451
8492
  e && Object.keys(e).forEach((a) => {
8452
8493
  t.includes(a) || (r.push(a), isArray(e[a]) ? n.push({
@@ -8457,37 +8498,14 @@ var jsondiffpatcher = createDiffPatcher(), isDeltaArray = (e) => Array.isArray(e
8457
8498
  };
8458
8499
  return e ? (i(e), n) : [];
8459
8500
  };
8460
- const createDiffJson = (e, t, n) => {
8461
- let r = t.filter((t) => !!t.diffs && t.createdAt >= e.createdAt), i = Array(r.length + 1);
8462
- i[0] = cloneDeep(n);
8463
- let a = "", o = "";
8464
- try {
8465
- for (let e = 0; e < r.length; e++) {
8466
- let t = r[e]?.diffs ?? null;
8467
- if (!t) {
8468
- i[e + 1] = i[e];
8469
- continue;
8470
- }
8471
- i[e + 1] = unpatchWith(i[e], t);
8472
- }
8473
- let e = r.length > 0 ? i[r.length - 1] : n, t = r.length > 0 ? i[r.length] : n;
8474
- a = JSON.stringify(t ?? "", null, 2), o = JSON.stringify(e ?? "", null, 2);
8475
- } catch (e) {
8476
- console.error("err", e);
8477
- }
8478
- return {
8479
- oldJson: a,
8480
- newJson: o
8481
- };
8482
- };
8483
- var comparison_view_modal_default = ({ auditLog: e, auditLogs: t, data: n, isOpen: r, onClose: i }) => {
8484
- let { diffs: a = void 0 } = e || {};
8485
- if (!a) return null;
8486
- 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 }) => ({
8487
8505
  label: e,
8488
8506
  value: t
8489
- })), [s, c] = useState(o[0]), { oldJson: l, newJson: u } = createDiffJson(e, t, n);
8490
- 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, {
8491
8509
  visible: r,
8492
8510
  centered: !0,
8493
8511
  children: /* @__PURE__ */ jsx(Dialog, { dialog: {
@@ -8495,86 +8513,27 @@ var comparison_view_modal_default = ({ auditLog: e, auditLogs: t, data: n, isOpe
8495
8513
  heading: "Comparison view",
8496
8514
  content: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tabs, {
8497
8515
  name: "ViewTab",
8498
- onChange: (e) => c(o.find((t) => t.value === e.target.value)),
8499
- options: o,
8500
- value: s
8501
- }), s.value === "summary" ? /* @__PURE__ */ jsx(ChangesOverview, { diffs: transformDiffs(a) }) : /* @__PURE__ */ jsx(DiffViewer, {
8502
- oldJson: l,
8503
- 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
8504
8525
  })] }),
8505
8526
  footer: /* @__PURE__ */ jsx(Button, {
8506
8527
  label: "Cancel",
8507
- onClick: i
8528
+ onClick: a
8508
8529
  }),
8509
- onClose: i,
8530
+ onClose: a,
8510
8531
  width: "90vw",
8511
8532
  height: "90vh"
8512
8533
  } })
8513
8534
  });
8514
- }, isObj = (e) => !!e && typeof e == "object" && !Array.isArray(e), countOne = (e) => {
8515
- let t = {
8516
- total: 0,
8517
- added: 0,
8518
- removed: 0,
8519
- modified: 0,
8520
- moved: 0,
8521
- text: 0
8522
- }, n = (e) => {
8523
- if (Array.isArray(e)) {
8524
- let n = e[0];
8525
- if (typeof n == "string" && n.startsWith("@@")) {
8526
- t.text++, t.total++;
8527
- return;
8528
- }
8529
- if (e.length === 1) {
8530
- t.added++, t.total++;
8531
- return;
8532
- }
8533
- if (e.length === 2) {
8534
- t.modified++, t.total++;
8535
- return;
8536
- }
8537
- if (e.length === 3) {
8538
- let n = e[2];
8539
- if (n === 0) {
8540
- t.removed++, t.total++;
8541
- return;
8542
- }
8543
- if (n === 3) {
8544
- t.moved++, t.total++;
8545
- return;
8546
- }
8547
- t.modified++, t.total++;
8548
- return;
8549
- }
8550
- t.modified++, t.total++;
8551
- return;
8552
- }
8553
- if (isObj(e)) {
8554
- if (e._t === "a") {
8555
- for (let t in e) t !== "_t" && n(e[t]);
8556
- return;
8557
- }
8558
- for (let t in e) n(e[t]);
8559
- }
8560
- };
8561
- return n(e), t;
8562
- };
8563
- function countDeltas(e) {
8564
- return (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) => {
8565
- let n = countOne(t);
8566
- 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;
8567
- }, {
8568
- total: 0,
8569
- added: 0,
8570
- removed: 0,
8571
- modified: 0,
8572
- moved: 0,
8573
- text: 0
8574
- });
8575
- }
8576
- function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, rowsPerPage: a, filterToggles: o = [], onChangeRowsPerPage: s, onSelectPage: c }) {
8577
- 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 = [
8578
8537
  {
8579
8538
  label: "10 / page",
8580
8539
  value: 10
@@ -8591,7 +8550,7 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8591
8550
  label: "Show all",
8592
8551
  value: 0
8593
8552
  }
8594
- ], h = ({ diffs: e, userName: t, source: n, operation: r, operationMetaData: i }) => {
8553
+ ], g = ({ diffs: e, userName: t, source: n, operation: r, operationMetaData: i }) => {
8595
8554
  let a = countDeltas(e), o = a.total ? `${a.total} change${a.total === 1 ? "" : "s"}` : "no field changes";
8596
8555
  if (n === "API") return r === "Created" ? `Created through API by ${t || "Unknown user"}` : `Changed through API by ${t || "Unknown user"}`;
8597
8556
  switch (r) {
@@ -8602,18 +8561,18 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8602
8561
  case "Updated": return `Updated by ${t} (${o})`;
8603
8562
  default: return `Change by ${t}`;
8604
8563
  }
8605
- }, g = [{ cells: [
8564
+ }, _ = [{ cells: [
8606
8565
  { value: "Change" },
8607
8566
  { value: "Modified by" },
8608
8567
  { value: "Using" },
8609
8568
  { value: "Operation" },
8610
8569
  { value: "Date" }
8611
- ] }], _ = e.map((e) => ({ cells: [
8570
+ ] }], v = e.map((e) => ({ cells: [
8612
8571
  {
8613
- value: h(e),
8572
+ value: g(e),
8614
8573
  type: "Link",
8615
8574
  onClick: () => {
8616
- u(!0), f(e);
8575
+ d(!0), p(e);
8617
8576
  },
8618
8577
  breakWord: !0
8619
8578
  },
@@ -8641,7 +8600,7 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8641
8600
  heading: /* @__PURE__ */ jsxs(Flex, {
8642
8601
  gap: !0,
8643
8602
  wrap: !0,
8644
- 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, {
8645
8604
  small: e.small ?? !0,
8646
8605
  checked: e.checked,
8647
8606
  onChange: e.onChange,
@@ -8655,8 +8614,8 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8655
8614
  theme: Theme.WHITE,
8656
8615
  children: /* @__PURE__ */ jsx(Spinner, { dark: !0 })
8657
8616
  }) : /* @__PURE__ */ jsx(Table, { table: {
8658
- headers: g,
8659
- rows: _,
8617
+ headers: _,
8618
+ rows: v,
8660
8619
  fixedWidth: "100%",
8661
8620
  bordered: !1,
8662
8621
  actionsRight: !0,
@@ -8666,24 +8625,24 @@ function AuditLog({ logs: e, data: t, total: n, loading: r, selectedPage: i, row
8666
8625
  rowsPerPage: {
8667
8626
  onChange: (e) => {
8668
8627
  let { value: t } = e.target;
8669
- s(Number(t));
8628
+ c(Number(t));
8670
8629
  },
8671
- options: p,
8630
+ options: h,
8672
8631
  value: a
8673
8632
  },
8674
- onSelectPage: (e) => c(e),
8633
+ onSelectPage: (e) => l(e),
8675
8634
  small: !0
8676
8635
  } }
8677
8636
  } })
8678
- }), l && d && /* @__PURE__ */ jsx(comparison_view_modal_default, {
8679
- isOpen: l,
8680
- onClose: () => u(!1),
8637
+ }), u && f && /* @__PURE__ */ jsx(ComparisonViewModal, {
8638
+ sectionNames: o,
8639
+ isOpen: u,
8640
+ onClose: () => d(!1),
8681
8641
  auditLogs: e,
8682
- auditLog: d,
8642
+ auditLog: f,
8683
8643
  data: t
8684
8644
  })] });
8685
- }
8686
- 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) => {
8687
8646
  setConfig(ConfigKeyType.LanguageKey, e.languageKey), Object.entries(e).forEach(([e, t]) => {
8688
8647
  if (e === ConfigKeyType.Translations) setConfig(e, getTranslations(t));
8689
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-15",
3
+ "version": "5.7.0-beta-17",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {