@oliasoft-open-source/react-ui-library 5.17.0 → 5.17.1-beta-4

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.
Files changed (2) hide show
  1. package/dist/index.js +40 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { cloneDeep, cloneDeepWith, debounce, every, get, isArray, isBoolean, isE
10
10
  import styled, { css } from "styled-components";
11
11
  import { Resizable } from "react-resizable";
12
12
  import { createPortal } from "react-dom";
13
- import { ALT_UNITS, KNOWN_UNITS, altUnitsList, cleanNumStr, convertAndGetValue, convertSamePrecision, getAltUnitsListByQuantity, getUnit, getUnitsForQuantity, getValue, isScientificStringNum, isValidNum, isValueWithUnit, label, roundByMagnitude, roundByMagnitudeToFixed, roundToFixed, roundToPrecision, split, stripLeadingZeros, toNum, toString, unitFromQuantity, validateNumber, withPrettyUnitLabel, withUnit } from "@oliasoft-open-source/units";
13
+ import { ALT_UNITS, KNOWN_UNITS, altUnitsList, cleanNumStr, convertAndGetValue, convertSamePrecision, getAltUnitsListByQuantity, getUnit, getUnitsForQuantity, getValue, isNumeric, isScientificStringNum, isValidNum, isValueWithUnit, label, roundByMagnitude, roundByMagnitudeToFixed, roundToFixed, roundToPrecision, split, stripLeadingZeros, toNum, toString, unitFromQuantity, validateNumber, withPrettyUnitLabel, withUnit } from "@oliasoft-open-source/units";
14
14
  import { FixedSizeList } from "react-window";
15
15
  import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
16
16
  import { CSS } from "@dnd-kit/utilities";
@@ -8926,7 +8926,7 @@ const countDeltas = (e) => (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) =
8926
8926
  case 1: {
8927
8927
  let [t] = e;
8928
8928
  return {
8929
- type: "Created",
8929
+ type: "created",
8930
8930
  before: "",
8931
8931
  after: toText(t)
8932
8932
  };
@@ -8934,7 +8934,7 @@ const countDeltas = (e) => (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) =
8934
8934
  case 2: {
8935
8935
  let [t, n] = e;
8936
8936
  return {
8937
- type: "Modified",
8937
+ type: "modified",
8938
8938
  before: toText(t),
8939
8939
  after: toText(n)
8940
8940
  };
@@ -8942,13 +8942,13 @@ const countDeltas = (e) => (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) =
8942
8942
  case 3: {
8943
8943
  let [t] = e;
8944
8944
  return {
8945
- type: "Deleted",
8945
+ type: "deleted",
8946
8946
  before: toText(t),
8947
8947
  after: ""
8948
8948
  };
8949
8949
  }
8950
8950
  default: return {
8951
- type: "Modified",
8951
+ type: "modified",
8952
8952
  before: "",
8953
8953
  after: ""
8954
8954
  };
@@ -8978,23 +8978,43 @@ const createDiffJson = (e, t, n) => {
8978
8978
  oldJson: a,
8979
8979
  newJson: o
8980
8980
  };
8981
- }, ChangesOverview = ({ sectionNames: e, userName: t, diffs: n }) => /* @__PURE__ */ jsx(Table, { table: {
8982
- headers: [{ cells: [
8983
- { value: "Modified By" },
8984
- { value: "Type" },
8985
- { value: "Before" },
8986
- { value: "After" },
8987
- { value: "" }
8988
- ] }],
8981
+ };
8982
+ var humanize = (e) => e.replace(/\[\d+\]/g, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\s+/g, " ").trim().replace(/^./, (e) => e.toUpperCase()), formatValue = (e) => {
8983
+ if (e == null || e === "") return "empty";
8984
+ if (typeof e == "boolean") return e ? "true" : "false";
8985
+ if (typeof e == "string") return e;
8986
+ if (typeof e == "number") return String(e);
8987
+ if (Array.isArray(e)) return e.length ? e.join(", ") : "empty";
8988
+ try {
8989
+ return JSON.stringify(e);
8990
+ } catch {
8991
+ return String(e);
8992
+ }
8993
+ }, findReasonableProperty = (e, t = e.length - 1) => {
8994
+ if (t >= e.length) return "Value";
8995
+ let n = e[t];
8996
+ return !n || isNumeric(n) ? findReasonableProperty(e, t - 1) : humanize(n);
8997
+ }, buildChangeSentence = ({ userName: e, type: t, property: n, before: r, after: i, sectionName: a }) => {
8998
+ let o = formatValue(r), s = formatValue(i);
8999
+ switch (t) {
9000
+ case "modified": return `${e} updated ${n} from ${o} to ${s} in ${a}.`;
9001
+ case "created": return `${e} created ${s} in ${a}.`;
9002
+ case "deleted": return `${e} deleted ${o} in ${a}.`;
9003
+ default: return `${e} changed ${n} in ${a}.`;
9004
+ }
9005
+ };
9006
+ const ChangesOverview = ({ sectionNames: e, userName: t, diffs: n }) => /* @__PURE__ */ jsx(Table, { table: {
9007
+ headers: [{ cells: [{ value: "Changes" }] }],
8989
9008
  rows: n.map((n) => {
8990
9009
  let { deltaFormat: r, path: i } = n, a = getSectionName(e, i), { type: o, before: s, after: c } = defaultMessage(r);
8991
- return { cells: [
8992
- { value: t },
8993
- { value: o },
8994
- { value: s },
8995
- { value: c },
8996
- { value: a }
8997
- ] };
9010
+ return { cells: [{ value: buildChangeSentence({
9011
+ userName: t,
9012
+ type: o,
9013
+ property: findReasonableProperty(i),
9014
+ before: s,
9015
+ after: c,
9016
+ sectionName: a
9017
+ }) }] };
8998
9018
  })
8999
9019
  } }), viewTypes = Object.freeze({
9000
9020
  summary: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "5.17.0",
3
+ "version": "5.17.1-beta-4",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {