@oliasoft-open-source/react-ui-library 5.7.4-beta-1 → 5.7.4-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,23 @@ 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
+ date: string;
44
+ description?: string;
45
+ diffs: any[];
46
+ operationMetaData?: string;
47
+ }
48
+
49
+ declare type AuditLogOperation = 'Created' | 'Cloned' | 'Reverted' | 'Imported' | 'Updated';
50
+
51
+ declare type AuditLogSource = 'System' | 'Application' | 'API';
52
+
53
+ export declare function AuditLogTable({ logs, loading }: IAuditLogTableProps): JSX_2.Element;
54
+
38
55
  export declare const Badge: ({ children, color, title, dot, margin, small, }: IBadgeProps) => JSX_2.Element;
39
56
 
40
57
  export declare const Breadcrumb: ({ links, small }: IBreadcrumbProps) => JSX_2.Element;
@@ -168,6 +185,11 @@ export declare interface IActionProps {
168
185
  closeLayer?: TEmpty;
169
186
  }
170
187
 
188
+ declare interface IAuditLogTableProps {
189
+ logs: AuditLogItem[];
190
+ loading?: boolean;
191
+ }
192
+
171
193
  export declare interface IBadgeProps {
172
194
  children?: ReactNode;
173
195
  color?: string;
package/dist/index.js CHANGED
@@ -6563,7 +6563,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6563
6563
  } : {
6564
6564
  value: G,
6565
6565
  unit: U
6566
- }), wu = k || K?.value === void 0, [J, Tu] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Eu = !!(O || n), Y = C && C.find((e) => {
6566
+ }), Ou = k || K?.value === void 0, [J, ku] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Au = !!(O || n), Y = C && C.find((e) => {
6567
6567
  if (!e?.value) return;
6568
6568
  if (E) return E === e.valueKey;
6569
6569
  let t = isValueWithUnit(e.value) ? getUnit(e.value) : "", { value: n = l } = convertUnit({
@@ -6572,7 +6572,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6572
6572
  toUnit: t
6573
6573
  });
6574
6574
  return withUnit(n, t) === e.value;
6575
- }), Du = () => {
6575
+ }), ju = () => {
6576
6576
  let e = l ?? "", t = K.unit;
6577
6577
  if (checkConversion({
6578
6578
  value: e,
@@ -6586,7 +6586,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6586
6586
  return null;
6587
6587
  }
6588
6588
  } else return getAltUnitsListByQuantity(u)?.map((e) => ["", e?.unit]);
6589
- }, Ou = (t) => {
6589
+ }, Mu = (t) => {
6590
6590
  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;
6591
6591
  h({ target: {
6592
6592
  value: s,
@@ -6599,7 +6599,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6599
6599
  }), R(() => {
6600
6600
  r.selectionStart = a, r.selectionEnd = a;
6601
6601
  });
6602
- }, ku = (e, t) => {
6602
+ }, Nu = (e, t) => {
6603
6603
  t === K.unit || isNaN(Number(e)) || (q({
6604
6604
  value: e,
6605
6605
  unit: t
@@ -6630,7 +6630,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6630
6630
  e !== void 0 && q({
6631
6631
  value: e,
6632
6632
  unit: t
6633
- }), C && Tu(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6633
+ }), C && ku(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6634
6634
  }
6635
6635
  }, [
6636
6636
  U,
@@ -6638,7 +6638,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6638
6638
  i,
6639
6639
  T
6640
6640
  ]);
6641
- let X = Du(), Z = label(K.unit) || K.unit || "", Au = p || !X || X && X.length === 1, Q = getStringName(e), $, ju = (t) => {
6641
+ let X = ju(), Z = label(K.unit) || K.unit || "", Pu = p || !X || X && X.length === 1, Q = getStringName(e), $, Fu = (t) => {
6642
6642
  let r = t?.value ? t.value : "", [i = "", a = ""] = isValueWithUnit(r) ? split(r) : [r], o = withPrettyUnitLabel(r);
6643
6643
  if (checkConversion({
6644
6644
  value: r,
@@ -6658,7 +6658,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6658
6658
  type: MenuType.OPTION,
6659
6659
  inline: !0,
6660
6660
  onClick: () => {
6661
- validateNumber(i).valid && !n && (Tu(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6661
+ validateNumber(i).valid && !n && (ku(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6662
6662
  value: r,
6663
6663
  name: typeof e == "string" ? e : e?.fieldName || "",
6664
6664
  predefinedSelected: !0,
@@ -6685,10 +6685,10 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6685
6685
  label: "Custom",
6686
6686
  selected: J === PredefinedOptionsMenuState.CUSTOM
6687
6687
  }], C?.length) {
6688
- let e = C.map(ju);
6688
+ let e = C.map(Fu);
6689
6689
  $ = [...$, ...e];
6690
6690
  }
6691
- let Mu = (e) => {
6691
+ let Iu = (e) => {
6692
6692
  if (isValueWithUnit(e)) {
6693
6693
  let t = getUnit(e), { value: n } = safeConvertValue({
6694
6694
  value: e,
@@ -6700,7 +6700,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6700
6700
  return n;
6701
6701
  }
6702
6702
  return e;
6703
- }, Nu = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Pu = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6703
+ }, Lu = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Ru = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6704
6704
  return /* @__PURE__ */ jsx("div", {
6705
6705
  className: J === PredefinedOptionsMenuState.PREDEFINED ? cx(unit_input_module_default.predefinedMenuActive) : "",
6706
6706
  children: /* @__PURE__ */ jsxs(InputGroup, {
@@ -6732,31 +6732,31 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6732
6732
  name: Q,
6733
6733
  testId: x,
6734
6734
  disabled: n,
6735
- placeholder: Mu(t),
6735
+ placeholder: Iu(t),
6736
6736
  value: K.value,
6737
- onChange: Ou,
6737
+ onChange: Mu,
6738
6738
  onFocus: v,
6739
6739
  error: i === null ? void 0 : i,
6740
6740
  warning: S === null ? void 0 : S,
6741
6741
  left: a,
6742
- allowEmpty: wu,
6742
+ allowEmpty: Ou,
6743
6743
  validationCallback: (e, t) => D(Q, t),
6744
6744
  enableCosmeticRounding: j,
6745
6745
  enableDisplayRounding: M,
6746
6746
  roundDisplayValue: N,
6747
- groupOrder: Nu,
6748
- disableInternalErrorValidationMessages: Eu,
6747
+ groupOrder: Lu,
6748
+ disableInternalErrorValidationMessages: Au,
6749
6749
  small: o,
6750
6750
  selectOnFocus: P,
6751
6751
  tooltip: I
6752
6752
  }, Q)
6753
6753
  }),
6754
- Z && (Au || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6755
- groupOrder: Pu,
6754
+ Z && (Pu || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6755
+ groupOrder: Ru,
6756
6756
  small: o,
6757
6757
  children: Z
6758
6758
  }) : /* @__PURE__ */ jsx(Menu, {
6759
- groupOrder: Pu,
6759
+ groupOrder: Ru,
6760
6760
  maxHeight: 380,
6761
6761
  disabled: r,
6762
6762
  testId: x && `${x}-menu`,
@@ -6772,7 +6772,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6772
6772
  label: j ? safeRoundNumbers(i) : i,
6773
6773
  inline: !0,
6774
6774
  onClick: (n) => {
6775
- n.stopPropagation(), ku(e, t);
6775
+ n.stopPropagation(), Nu(e, t);
6776
6776
  },
6777
6777
  description: r,
6778
6778
  selected: r === Z,
@@ -7051,7 +7051,199 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7051
7051
  compareMethod: DiffMethod.WORDS
7052
7052
  })
7053
7053
  }) });
7054
- }, isPrimitiveValue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null, initializeGuiLibrary = (e) => {
7054
+ };
7055
+ function formatDate({ date: e, showTime: t, showSeconds: n, timeZone: r, showTimeZone: i, locale: a }) {
7056
+ return e ? new Date(e).toLocaleString(a, {
7057
+ year: "numeric",
7058
+ month: "short",
7059
+ day: "2-digit",
7060
+ hour: t ? "2-digit" : void 0,
7061
+ minute: t ? "2-digit" : void 0,
7062
+ second: n ? "2-digit" : void 0,
7063
+ timeZone: r,
7064
+ timeZoneName: i ? "short" : void 0
7065
+ }) : null;
7066
+ }
7067
+ var SOURCE_OPTIONS = [
7068
+ {
7069
+ label: "System",
7070
+ value: "System"
7071
+ },
7072
+ {
7073
+ label: "Application",
7074
+ value: "Application"
7075
+ },
7076
+ {
7077
+ label: "API",
7078
+ value: "API"
7079
+ }
7080
+ ];
7081
+ const OPERATION_OPTIONS = [
7082
+ {
7083
+ label: "Created",
7084
+ value: "Created"
7085
+ },
7086
+ {
7087
+ label: "Updated",
7088
+ value: "Updated"
7089
+ },
7090
+ {
7091
+ label: "Imported",
7092
+ value: "Imported"
7093
+ },
7094
+ {
7095
+ label: "Cloned",
7096
+ value: "Cloned"
7097
+ },
7098
+ {
7099
+ label: "Reverted",
7100
+ value: "Reverted"
7101
+ }
7102
+ ];
7103
+ function AuditLogTable({ logs: e, loading: t }) {
7104
+ let [n, r] = useState(!0), [i, a] = useState(!0), o = [
7105
+ {
7106
+ label: "10 / page",
7107
+ value: 10
7108
+ },
7109
+ {
7110
+ label: "20 / page",
7111
+ value: 20
7112
+ },
7113
+ {
7114
+ label: "50 / page",
7115
+ value: 50
7116
+ },
7117
+ {
7118
+ label: "Show all",
7119
+ value: 0
7120
+ }
7121
+ ], [s, c] = useState(10), [l, u] = useState(1), [d, f] = useState(""), [p, h] = useState(""), [g, _] = useState(""), [v, y] = useState(""), b = (e) => f(e.target.value), x = (e) => h(e.target.value), S = ({ diffs: e = [], userName: t, source: n, operation: r, operationMetaData: i }) => {
7122
+ if (n === "API") return r === "Created" ? `Created through API by ${t || "Unknown user"}` : `Changed through API by ${t || "Unknown user"}`;
7123
+ switch (r) {
7124
+ case "Created": return `Created by ${t}`;
7125
+ case "Cloned": return `Cloned by ${t} (from ${i || "unknown"})`;
7126
+ case "Reverted": return `Reverted by ${t}`;
7127
+ case "Imported": return `Imported by ${t}`;
7128
+ case "Updated": return `Updated by ${t} (${e.length} changes)`;
7129
+ default: return `Change by ${t}`;
7130
+ }
7131
+ }, C = e.filter((e) => {
7132
+ let t = e.description?.toLowerCase().includes(d.toLowerCase()) || !1, n = p ? e.userName?.toLowerCase().includes(p.toLowerCase()) : !0, r = g ? e.operation === g : !0, i = v ? e.source === v : !0;
7133
+ return t && n && r && i;
7134
+ }), w = (l - 1) * (s || C.length || 1), T = s === 0 ? C.length : w + s, E = C.slice(w, T), D = [{ cells: [
7135
+ { value: "Change" },
7136
+ { value: "Modified by" },
7137
+ { value: "Using" },
7138
+ { value: "Operation" },
7139
+ { value: "Date" }
7140
+ ] }, { cells: [
7141
+ {
7142
+ value: d,
7143
+ type: "Input",
7144
+ placeholder: "Search",
7145
+ onChange: b
7146
+ },
7147
+ {
7148
+ value: p,
7149
+ type: "Input",
7150
+ placeholder: "Search user",
7151
+ onChange: x
7152
+ },
7153
+ {
7154
+ value: v,
7155
+ type: "Select",
7156
+ placeholder: "Select",
7157
+ options: SOURCE_OPTIONS,
7158
+ onChange: (e) => y(e)
7159
+ },
7160
+ {
7161
+ value: g,
7162
+ type: "Select",
7163
+ placeholder: "Select",
7164
+ options: OPERATION_OPTIONS,
7165
+ onChange: (e) => _(e)
7166
+ },
7167
+ {
7168
+ value: "",
7169
+ type: "Input",
7170
+ placeholder: "Search"
7171
+ }
7172
+ ] }], O = E.map((e) => ({ cells: [
7173
+ {
7174
+ value: S(e),
7175
+ type: "Static"
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.date,
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: n,
7206
+ onChange: () => r(!n),
7207
+ label: "Include company settings"
7208
+ }),
7209
+ /* @__PURE__ */ jsx(Toggle, {
7210
+ small: !0,
7211
+ checked: i,
7212
+ onChange: () => a(!i),
7213
+ label: "Include migrations"
7214
+ })
7215
+ ]
7216
+ }),
7217
+ padding: !1,
7218
+ children: t ? /* @__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: D,
7225
+ rows: O,
7226
+ fixedWidth: "100%",
7227
+ bordered: !1,
7228
+ actionsRight: !0,
7229
+ footer: { pagination: {
7230
+ rowCount: C.length,
7231
+ selectedPage: l,
7232
+ rowsPerPage: {
7233
+ onChange: (e) => {
7234
+ let { value: t } = e.target;
7235
+ c(Number(t)), u(1);
7236
+ },
7237
+ options: o,
7238
+ value: s
7239
+ },
7240
+ onSelectPage: (e) => u(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) => {
7055
7247
  setConfig(ConfigKeyType.LanguageKey, e.languageKey), Object.entries(e).forEach(([e, t]) => {
7056
7248
  if (e === ConfigKeyType.Translations) setConfig(e, getTranslations(t));
7057
7249
  else {
@@ -7060,4 +7252,4 @@ const DiffViewer = ({ oldJson: e, newJson: t, viewType: n = SPLIT_VIEW }) => {
7060
7252
  }
7061
7253
  });
7062
7254
  };
7063
- 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, 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, 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.7.4-beta-1",
3
+ "version": "5.7.4-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": {