@oliasoft-open-source/react-ui-library 5.6.5 → 5.7.0-beta-2

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,6 +35,22 @@ export declare enum Align {
35
35
  CENTER = "center"
36
36
  }
37
37
 
38
+ export declare interface AuditLogItem {
39
+ id: string;
40
+ userName: string;
41
+ operation: AuditLogOperation;
42
+ source: AuditLogSource;
43
+ createdAt: string;
44
+ diffs: JsonDelta | JsonDelta[];
45
+ operationMetaData?: string;
46
+ }
47
+
48
+ declare type AuditLogOperation = 'Created' | 'Cloned' | 'Reverted' | 'Imported' | 'Updated';
49
+
50
+ declare type AuditLogSource = 'System' | 'Application' | 'API';
51
+
52
+ export declare function AuditLogTable({ logs, onClick, loading }: IAuditLogTableProps): JSX_2.Element;
53
+
38
54
  export declare const Badge: ({ children, color, title, dot, margin, small, }: IBadgeProps) => JSX_2.Element;
39
55
 
40
56
  export declare const Breadcrumb: ({ links, small }: IBreadcrumbProps) => JSX_2.Element;
@@ -168,6 +184,12 @@ export declare interface IActionProps {
168
184
  closeLayer?: TEmpty;
169
185
  }
170
186
 
187
+ declare interface IAuditLogTableProps {
188
+ logs: AuditLogItem[];
189
+ loading?: boolean;
190
+ onClick: (log: AuditLogItem) => void;
191
+ }
192
+
171
193
  export declare interface IBadgeProps {
172
194
  children?: ReactNode;
173
195
  color?: string;
@@ -1821,6 +1843,8 @@ export declare interface IUnitTableRow extends Omit<TRowType, 'cells'> {
1821
1843
  declare interface IUnitTableStaticCell extends IStaticCell, IUnitTableCell {
1822
1844
  }
1823
1845
 
1846
+ declare type JsonDelta = Record<string, any>;
1847
+
1824
1848
  export declare const Label: ({ label, width, helpText, helpTextMaxWidth, onClickHelp, lock, info, libraryIcon, labelLeft, textTransform, }: ILabelProps) => JSX_2.Element;
1825
1849
 
1826
1850
  export declare const List: ({ list, bordered, expanding, narrow, toggleNarrow, onToggleNarrow, invokeEditOnRowClick, noHeader, stickyHeader, draggable, onListReorder, marginBottom, height, testId, scrollDetails, }: IListProps) => 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
- }), wu = k || K?.value === void 0, [J, Tu] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Eu = !!(O || n), Y = C && C.find((e) => {
6572
+ }), ku = k || K?.value === void 0, [J, Au] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), ju = !!(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
- }), Du = () => {
6581
+ }), Mu = () => {
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
- }, Ou = (t) => {
6595
+ }, Nu = (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
- }, ku = (e, t) => {
6608
+ }, Pu = (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 && Tu(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6639
+ }), C && Au(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 = Du(), Z = label(K.unit) || K.unit || "", Au = p || !X || X && X.length === 1, Q = getStringName(e), $, ju = (t) => {
6647
+ let X = Mu(), Z = label(K.unit) || K.unit || "", Fu = p || !X || X && X.length === 1, Q = getStringName(e), $, Iu = (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 && (Tu(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6667
+ validateNumber(i).valid && !n && (Au(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(ju);
6694
+ let e = C.map(Iu);
6695
6695
  $ = [...$, ...e];
6696
6696
  }
6697
- let Mu = (e) => {
6697
+ let Lu = (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
- }, Nu = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Pu = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6709
+ }, Ru = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, zu = !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: Mu(t),
6741
+ placeholder: Lu(t),
6742
6742
  value: K.value,
6743
- onChange: Ou,
6743
+ onChange: Nu,
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: wu,
6748
+ allowEmpty: ku,
6749
6749
  validationCallback: (e, t) => D(Q, t),
6750
6750
  enableCosmeticRounding: j,
6751
6751
  enableDisplayRounding: M,
6752
6752
  roundDisplayValue: N,
6753
- groupOrder: Nu,
6754
- disableInternalErrorValidationMessages: Eu,
6753
+ groupOrder: Ru,
6754
+ disableInternalErrorValidationMessages: ju,
6755
6755
  small: o,
6756
6756
  selectOnFocus: P,
6757
6757
  tooltip: I
6758
6758
  }, Q)
6759
6759
  }),
6760
- Z && (Au || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6761
- groupOrder: Pu,
6760
+ Z && (Fu || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6761
+ groupOrder: zu,
6762
6762
  small: o,
6763
6763
  children: Z
6764
6764
  }) : /* @__PURE__ */ jsx(Menu, {
6765
- groupOrder: Pu,
6765
+ groupOrder: zu,
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(), ku(e, t);
6781
+ n.stopPropagation(), Pu(e, t);
6782
6782
  },
6783
6783
  description: r,
6784
6784
  selected: r === Z,
@@ -7057,7 +7057,193 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7057
7057
  compareMethod: DiffMethod.WORDS
7058
7058
  })
7059
7059
  }) });
7060
- }, isPrimitiveValue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null, initializeGuiLibrary = (e) => {
7060
+ };
7061
+ function formatDate({ date: e, showTime: t, showSeconds: n, timeZone: r, showTimeZone: i, locale: a }) {
7062
+ return e ? new Date(e).toLocaleString(a, {
7063
+ year: "numeric",
7064
+ month: "short",
7065
+ day: "2-digit",
7066
+ hour: t ? "2-digit" : void 0,
7067
+ minute: t ? "2-digit" : void 0,
7068
+ second: n ? "2-digit" : void 0,
7069
+ timeZone: r,
7070
+ timeZoneName: i ? "short" : void 0
7071
+ }) : null;
7072
+ }
7073
+ var isObj = (e) => !!e && typeof e == "object" && !Array.isArray(e), countOne = (e) => {
7074
+ let t = {
7075
+ total: 0,
7076
+ added: 0,
7077
+ removed: 0,
7078
+ modified: 0,
7079
+ moved: 0,
7080
+ text: 0
7081
+ }, n = (e) => {
7082
+ if (Array.isArray(e)) {
7083
+ let n = e[0];
7084
+ if (typeof n == "string" && n.startsWith("@@")) {
7085
+ t.text++, t.total++;
7086
+ return;
7087
+ }
7088
+ if (e.length === 1) {
7089
+ t.added++, t.total++;
7090
+ return;
7091
+ }
7092
+ if (e.length === 2) {
7093
+ t.modified++, t.total++;
7094
+ return;
7095
+ }
7096
+ if (e.length === 3) {
7097
+ let n = e[2];
7098
+ if (n === 0) {
7099
+ t.removed++, t.total++;
7100
+ return;
7101
+ }
7102
+ if (n === 3) {
7103
+ t.moved++, t.total++;
7104
+ return;
7105
+ }
7106
+ t.modified++, t.total++;
7107
+ return;
7108
+ }
7109
+ t.modified++, t.total++;
7110
+ return;
7111
+ }
7112
+ if (isObj(e)) {
7113
+ if (e._t === "a") {
7114
+ for (let t in e) t !== "_t" && n(e[t]);
7115
+ return;
7116
+ }
7117
+ for (let t in e) n(e[t]);
7118
+ }
7119
+ };
7120
+ return n(e), t;
7121
+ };
7122
+ function countDeltas(e) {
7123
+ return (Array.isArray(e) ? e : e ? [e] : []).reduce((e, t) => {
7124
+ let n = countOne(t);
7125
+ 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;
7126
+ }, {
7127
+ total: 0,
7128
+ added: 0,
7129
+ removed: 0,
7130
+ modified: 0,
7131
+ moved: 0,
7132
+ text: 0
7133
+ });
7134
+ }
7135
+ function AuditLogTable({ logs: e, onClick: t, loading: n }) {
7136
+ let [r, i] = useState(!0), [a, o] = useState(!0), s = [
7137
+ {
7138
+ label: "10 / page",
7139
+ value: 10
7140
+ },
7141
+ {
7142
+ label: "20 / page",
7143
+ value: 20
7144
+ },
7145
+ {
7146
+ label: "50 / page",
7147
+ value: 50
7148
+ },
7149
+ {
7150
+ label: "Show all",
7151
+ value: 0
7152
+ }
7153
+ ], [c, l] = useState(10), [u, d] = useState(1), f = ({ diffs: e, userName: t, source: n, operation: r, operationMetaData: i }) => {
7154
+ let a = countDeltas(e), o = a.total ? `${a.total} change${a.total === 1 ? "" : "s"}` : "no field changes";
7155
+ if (n === "API") return r === "Created" ? `Created through API by ${t || "Unknown user"}` : `Changed through API by ${t || "Unknown user"}`;
7156
+ switch (r) {
7157
+ case "Created": return `Created by ${t}`;
7158
+ case "Cloned": return `Cloned by ${t} (from ${i || "unknown"})`;
7159
+ case "Reverted": return `Reverted by ${t}`;
7160
+ case "Imported": return `Imported by ${t}`;
7161
+ case "Updated": return `Updated by ${t} (${o})`;
7162
+ default: return `Change by ${t}`;
7163
+ }
7164
+ }, p = (u - 1) * (c || e.length || 1), h = c === 0 ? e.length : p + c, g = e.slice(p, h), _ = [{ cells: [
7165
+ { value: "Change" },
7166
+ { value: "Modified by" },
7167
+ { value: "Using" },
7168
+ { value: "Operation" },
7169
+ { value: "Date" }
7170
+ ] }], v = g.map((e) => ({ cells: [
7171
+ {
7172
+ value: f(e),
7173
+ type: "Link",
7174
+ onClick: () => t(e),
7175
+ breakWord: !0
7176
+ },
7177
+ {
7178
+ value: e.userName || "Unknown",
7179
+ type: "Static"
7180
+ },
7181
+ {
7182
+ value: e.source || "System",
7183
+ type: "Static"
7184
+ },
7185
+ {
7186
+ value: e.operation,
7187
+ type: "Static"
7188
+ },
7189
+ {
7190
+ value: formatDate({
7191
+ date: e.createdAt,
7192
+ showTime: !0
7193
+ }),
7194
+ type: "Static"
7195
+ }
7196
+ ] }));
7197
+ return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(Card, {
7198
+ heading: /* @__PURE__ */ jsxs(Flex, {
7199
+ gap: !0,
7200
+ wrap: !0,
7201
+ children: [
7202
+ /* @__PURE__ */ jsx(Heading, { children: "CHANGES" }),
7203
+ /* @__PURE__ */ jsx(Toggle, {
7204
+ small: !0,
7205
+ checked: r,
7206
+ onChange: () => i(!r),
7207
+ label: "Include company settings"
7208
+ }),
7209
+ /* @__PURE__ */ jsx(Toggle, {
7210
+ small: !0,
7211
+ checked: a,
7212
+ onChange: () => o(!a),
7213
+ label: "Include migrations"
7214
+ })
7215
+ ]
7216
+ }),
7217
+ padding: !1,
7218
+ children: n ? /* @__PURE__ */ jsx(Loader, {
7219
+ height: "100px",
7220
+ cover: !0,
7221
+ theme: Theme.WHITE,
7222
+ children: /* @__PURE__ */ jsx(Spinner, { dark: !0 })
7223
+ }) : /* @__PURE__ */ jsx(Table, { table: {
7224
+ headers: _,
7225
+ rows: v,
7226
+ fixedWidth: "100%",
7227
+ bordered: !1,
7228
+ actionsRight: !0,
7229
+ footer: { pagination: {
7230
+ rowCount: e.length,
7231
+ selectedPage: u,
7232
+ rowsPerPage: {
7233
+ onChange: (e) => {
7234
+ let { value: t } = e.target;
7235
+ l(Number(t)), d(1);
7236
+ },
7237
+ options: s,
7238
+ value: c
7239
+ },
7240
+ onSelectPage: (e) => d(e),
7241
+ small: !0
7242
+ } }
7243
+ } })
7244
+ }) });
7245
+ }
7246
+ const isPrimitiveValue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null, initializeGuiLibrary = (e) => {
7061
7247
  setConfig(ConfigKeyType.LanguageKey, e.languageKey), Object.entries(e).forEach(([e, t]) => {
7062
7248
  if (e === ConfigKeyType.Translations) setConfig(e, getTranslations(t));
7063
7249
  else {
@@ -7066,4 +7252,4 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7066
7252
  }
7067
7253
  });
7068
7254
  };
7069
- export { Accordion, AccordionWithDefaultToggle, Actions, Align, Badge, Breadcrumb, BreadcrumbLinkType, Button, ButtonGroup, ButtonPosition, ButtonType, Card, CheckBox, Chevron, Color, Column, Dialog, DiffViewer, DisabledContext, Divider, Drawer, ElementType, Empty, Field, FileButton, FileInput, Flex, FormRow, Grid, GroupOrder, Heading, HelpIcon, Icon, IconType, Input, InputGroup, InputGroupAddon, InputReaderMethods, InputType, Label, List, ListHeading, ListSubheading, Loader, Menu, MenuCarat, MenuType, Message, MessageType, Modal, NativeSelect, NumberInput, OptionDropdown, Page, Pagination, PopConfirm, Popover, Portal, PrintHeader, ProgressBar, RadioButton, RichTextInput, Row, Select, SettingField, SideBar, Slider, SmartUploadModal, Spacer, Spinner, Table, TableImportExport, Tabs, Text, TextArea, TextLink, TextTransform, Theme, Toaster, Toggle, Tooltip, TopBar, Tree, TriggerType, UnitInput, UnitTable, dismissToast, initializeContext, initializeGuiLibrary, readFile, toast, useFocus, useKeyboardEvent, useWindowWidth };
7255
+ export { Accordion, AccordionWithDefaultToggle, Actions, Align, AuditLogTable, Badge, Breadcrumb, BreadcrumbLinkType, Button, ButtonGroup, ButtonPosition, ButtonType, Card, CheckBox, Chevron, Color, Column, Dialog, DiffViewer, DisabledContext, Divider, Drawer, ElementType, Empty, Field, FileButton, FileInput, Flex, FormRow, Grid, GroupOrder, Heading, HelpIcon, Icon, IconType, Input, InputGroup, InputGroupAddon, InputReaderMethods, InputType, Label, List, ListHeading, ListSubheading, Loader, Menu, MenuCarat, MenuType, Message, MessageType, Modal, NativeSelect, NumberInput, OptionDropdown, Page, Pagination, PopConfirm, Popover, Portal, PrintHeader, ProgressBar, RadioButton, RichTextInput, Row, Select, SettingField, SideBar, Slider, SmartUploadModal, Spacer, Spinner, Table, TableImportExport, Tabs, Text, TextArea, TextLink, TextTransform, Theme, Toaster, Toggle, Tooltip, TopBar, Tree, TriggerType, UnitInput, UnitTable, dismissToast, initializeContext, initializeGuiLibrary, readFile, toast, useFocus, useKeyboardEvent, useWindowWidth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "5.6.5",
3
+ "version": "5.7.0-beta-2",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {
@@ -88,6 +88,9 @@
88
88
  "styled-components": "^6.1.15"
89
89
  },
90
90
  "devDependencies": {
91
+ "@dnd-kit/core": "^6.3.1",
92
+ "@dnd-kit/sortable": "^8.0.0",
93
+ "@dnd-kit/utilities": "^3.2.2",
91
94
  "@eslint/eslintrc": "^3.3.0",
92
95
  "@eslint/js": "^9.21.0",
93
96
  "@mdx-js/react": "^3",
@@ -146,12 +149,12 @@
146
149
  "vite-plugin-html": "^3.2.2",
147
150
  "vite-preset-react": "^2.3.0",
148
151
  "vite-tsconfig-paths": "^5.1.4",
149
- "vitest": "^3.0.7",
150
- "@dnd-kit/core": "^6.3.1",
151
- "@dnd-kit/sortable": "^8.0.0",
152
- "@dnd-kit/utilities": "^3.2.2"
152
+ "vitest": "^3.0.7"
153
153
  },
154
154
  "peerDependencies": {
155
+ "@dnd-kit/core": "^6.3.1",
156
+ "@dnd-kit/sortable": "^8.0.0",
157
+ "@dnd-kit/utilities": "^3.2.2",
155
158
  "@oliasoft-open-source/units": "^4.3.1",
156
159
  "ajv": "^8.17.1",
157
160
  "ajv-errors": "^3.0.0",
@@ -159,10 +162,7 @@
159
162
  "lodash": "^4",
160
163
  "prop-types": "^15",
161
164
  "react": ">=17 <19",
162
- "react-dom": ">= 17 <19",
163
- "@dnd-kit/core": "^6.3.1",
164
- "@dnd-kit/sortable": "^8.0.0",
165
- "@dnd-kit/utilities": "^3.2.2"
165
+ "react-dom": ">= 17 <19"
166
166
  },
167
167
  "resolutions": {
168
168
  "jackspeak": "2.1.1"