@oliasoft-open-source/react-ui-library 5.9.0 → 5.10.0-beta-1

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
@@ -1866,6 +1866,12 @@ export declare interface IUnitTableRow extends Omit<TRowType, 'cells'> {
1866
1866
  declare interface IUnitTableStaticCell extends IStaticCell, IUnitTableCell {
1867
1867
  }
1868
1868
 
1869
+ export declare interface IUsageTrackerProps {
1870
+ onNavigate: (args: NavigationEventArgs) => void;
1871
+ getAnalyticsModuleName: (pathname: string) => string;
1872
+ onStartNavigationTimeEvent?: () => void;
1873
+ }
1874
+
1869
1875
  declare type JsonDelta = Record<string, any>;
1870
1876
 
1871
1877
  export declare const Label: ({ label, width, helpText, helpTextMaxWidth, onClickHelp, lock, info, libraryIcon, labelLeft, textTransform, }: ILabelProps) => JSX_2.Element;
@@ -1906,6 +1912,13 @@ export declare const Modal: ({ children, visible, centered, width, onEnter, onEs
1906
1912
 
1907
1913
  export declare const NativeSelect: ({ disabled, error, warning, tooltip, options, onChange, onFocus, onBlur, right, small, tabIndex, selectedOption, width, groupOrder, testId, isInTable, clearable, placeholder, hasNonExistentValue, maxTooltipWidth, borderRadius, }: INativeSelectProps) => JSX_2.Element;
1908
1914
 
1915
+ declare interface NavigationEventArgs {
1916
+ moduleName: string;
1917
+ moduleUrl: string;
1918
+ startTime: number;
1919
+ endTime: number;
1920
+ }
1921
+
1909
1922
  export declare const NumberInput: ({ name, placeholder, disabled, error, left, small, width, value, onChange, onFocus, onBlur, selectOnFocus, tabIndex, testId, tooltip, warning, validationCallback, allowEmpty, isInTable, groupOrder, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, disableInternalErrorValidationMessages, disableValidationOnFocus, }: INumberInputProps) => JSX_2.Element;
1910
1923
 
1911
1924
  export declare const OptionDropdown: ({ name, label, options, onChange, small, showHeader, maxHeight, testId, }: IOptionDropdownProps) => ReactElement;
@@ -2217,6 +2230,8 @@ export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, er
2217
2230
 
2218
2231
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, onListReorder, canListReorder, beforeRenderRow: beforeRenderRowProp, }: IUnitTableProps) => JSX_2.Element;
2219
2232
 
2233
+ export declare const UsageTracker: ({ onNavigate, getAnalyticsModuleName, onStartNavigationTimeEvent, }: IUsageTrackerProps) => null;
2234
+
2220
2235
  export declare const useFocus: () => UseFocusReturnType;
2221
2236
 
2222
2237
  declare type UseFocusReturnType = [MutableRefObject<HTMLInputElement | null>, TEmpty];
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ import "remirror/styles/all.css";
30
30
  import { DndProvider } from "react-dnd";
31
31
  import { MultiBackend, Tree as Tree$1, getBackendOptions } from "@minoru/react-dnd-treeview";
32
32
  import ReactDiffViewer, { DiffMethod } from "react-diff-viewer-continued";
33
+ import { useLocation } from "react-router-dom";
33
34
  let TriggerType = /* @__PURE__ */ function(e) {
34
35
  return e.TEXT = "Text", e.BUTTON = "Button", e.DROP_DOWN_BUTTON = "DropDownButton", e.COMPONENT = "Component", e;
35
36
  }({}), GroupOrder = /* @__PURE__ */ function(e) {
@@ -6611,7 +6612,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6611
6612
  } : {
6612
6613
  value: G,
6613
6614
  unit: U
6614
- }), Nd = k || K?.value === void 0, [J, Pd] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Fd = !!(O || n), Y = C && C.find((e) => {
6615
+ }), Fd = k || K?.value === void 0, [J, Id] = useState(w ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM), Ld = !!(O || n), Y = C && C.find((e) => {
6615
6616
  if (!e?.value) return;
6616
6617
  if (E) return E === e.valueKey;
6617
6618
  let t = isValueWithUnit(e.value) ? getUnit(e.value) : "", { value: n = l } = convertUnit({
@@ -6620,7 +6621,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6620
6621
  toUnit: t
6621
6622
  });
6622
6623
  return withUnit(n, t) === e.value;
6623
- }), Id = () => {
6624
+ }), Rd = () => {
6624
6625
  let e = l ?? "", t = K.unit;
6625
6626
  if (checkConversion({
6626
6627
  value: e,
@@ -6634,7 +6635,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6634
6635
  return null;
6635
6636
  }
6636
6637
  } else return getAltUnitsListByQuantity(u)?.map((e) => ["", e?.unit]);
6637
- }, Ld = (t) => {
6638
+ }, zd = (t) => {
6638
6639
  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;
6639
6640
  h({ target: {
6640
6641
  value: s,
@@ -6647,7 +6648,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6647
6648
  }), R(() => {
6648
6649
  r.selectionStart = a, r.selectionEnd = a;
6649
6650
  });
6650
- }, Rd = (e, t) => {
6651
+ }, Bd = (e, t) => {
6651
6652
  t === K.unit || isNaN(Number(e)) || (q({
6652
6653
  value: e,
6653
6654
  unit: t
@@ -6678,7 +6679,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6678
6679
  e !== void 0 && q({
6679
6680
  value: e,
6680
6681
  unit: t
6681
- }), C && Pd(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6682
+ }), C && Id(Y && T ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM);
6682
6683
  }
6683
6684
  }, [
6684
6685
  U,
@@ -6686,7 +6687,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6686
6687
  i,
6687
6688
  T
6688
6689
  ]);
6689
- let X = Id(), Z = label(K.unit) || K.unit || "", zd = p || !X || X && X.length === 1, Q = getStringName(e), $, Bd = (t) => {
6690
+ let X = Rd(), Z = label(K.unit) || K.unit || "", Vd = p || !X || X && X.length === 1, Q = getStringName(e), $, Hd = (t) => {
6690
6691
  let r = t?.value ? t.value : "", [i = "", a = ""] = isValueWithUnit(r) ? split(r) : [r], o = withPrettyUnitLabel(r);
6691
6692
  if (checkConversion({
6692
6693
  value: r,
@@ -6706,7 +6707,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6706
6707
  type: MenuType.OPTION,
6707
6708
  inline: !0,
6708
6709
  onClick: () => {
6709
- validateNumber(i).valid && !n && (Pd(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6710
+ validateNumber(i).valid && !n && (Id(PredefinedOptionsMenuState.PREDEFINED), h({ target: {
6710
6711
  value: r,
6711
6712
  name: typeof e == "string" ? e : e?.fieldName || "",
6712
6713
  predefinedSelected: !0,
@@ -6733,10 +6734,10 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6733
6734
  label: "Custom",
6734
6735
  selected: J === PredefinedOptionsMenuState.CUSTOM
6735
6736
  }], C?.length) {
6736
- let e = C.map(Bd);
6737
+ let e = C.map(Hd);
6737
6738
  $ = [...$, ...e];
6738
6739
  }
6739
- let Vd = (e) => {
6740
+ let Ud = (e) => {
6740
6741
  if (isValueWithUnit(e)) {
6741
6742
  let t = getUnit(e), { value: n } = safeConvertValue({
6742
6743
  value: e,
@@ -6748,7 +6749,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6748
6749
  return n;
6749
6750
  }
6750
6751
  return e;
6751
- }, Hd = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Ud = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6752
+ }, Wd = !C && (!F || F === GroupOrder.FIRST) ? GroupOrder.FIRST : GroupOrder.MIDDLE, Gd = !F || F === GroupOrder.LAST ? GroupOrder.LAST : GroupOrder.MIDDLE;
6752
6753
  return /* @__PURE__ */ jsx("div", {
6753
6754
  className: J === PredefinedOptionsMenuState.PREDEFINED ? cx(unit_input_module_default.predefinedMenuActive) : "",
6754
6755
  children: /* @__PURE__ */ jsxs(InputGroup, {
@@ -6780,31 +6781,31 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6780
6781
  name: Q,
6781
6782
  testId: x,
6782
6783
  disabled: n,
6783
- placeholder: Vd(t),
6784
+ placeholder: Ud(t),
6784
6785
  value: K.value,
6785
- onChange: Ld,
6786
+ onChange: zd,
6786
6787
  onFocus: v,
6787
6788
  error: i === null ? void 0 : i,
6788
6789
  warning: S === null ? void 0 : S,
6789
6790
  left: a,
6790
- allowEmpty: Nd,
6791
+ allowEmpty: Fd,
6791
6792
  validationCallback: (e, t) => D(Q, t),
6792
6793
  enableCosmeticRounding: j,
6793
6794
  enableDisplayRounding: M,
6794
6795
  roundDisplayValue: N,
6795
- groupOrder: Hd,
6796
- disableInternalErrorValidationMessages: Fd,
6796
+ groupOrder: Wd,
6797
+ disableInternalErrorValidationMessages: Ld,
6797
6798
  small: o,
6798
6799
  selectOnFocus: P,
6799
6800
  tooltip: I
6800
6801
  }, Q)
6801
6802
  }),
6802
- Z && (zd || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6803
- groupOrder: Ud,
6803
+ Z && (Vd || !H ? /* @__PURE__ */ jsx(InputGroupAddon, {
6804
+ groupOrder: Gd,
6804
6805
  small: o,
6805
6806
  children: Z
6806
6807
  }) : /* @__PURE__ */ jsx(Menu, {
6807
- groupOrder: Ud,
6808
+ groupOrder: Gd,
6808
6809
  maxHeight: 380,
6809
6810
  disabled: r,
6810
6811
  testId: x && `${x}-menu`,
@@ -6820,7 +6821,7 @@ const UnitInput = ({ name: e, placeholder: t = "", disabled: n = !1, disabledUni
6820
6821
  label: j ? safeRoundNumbers(i) : i,
6821
6822
  inline: !0,
6822
6823
  onClick: (n) => {
6823
- n.stopPropagation(), Rd(e, t);
6824
+ n.stopPropagation(), Bd(e, t);
6824
6825
  },
6825
6826
  description: r,
6826
6827
  selected: r === Z,
@@ -8688,6 +8689,29 @@ const ComparisonViewModal = ({ auditLog: e, auditLogs: t, data: n, isOpen: r, se
8688
8689
  auditLog: f,
8689
8690
  data: t
8690
8691
  })] });
8692
+ }, UsageTracker = ({ onNavigate: e, getAnalyticsModuleName: t, onStartNavigationTimeEvent: n }) => {
8693
+ let { pathname: r } = useLocation(), i = window.location.href, a = t(r), o = useRef(i);
8694
+ return useEffect(() => {
8695
+ o.current = i;
8696
+ let t = Date.now();
8697
+ n && n();
8698
+ let r = () => {
8699
+ e({
8700
+ moduleName: a,
8701
+ moduleUrl: o.current,
8702
+ startTime: t,
8703
+ endTime: Date.now()
8704
+ });
8705
+ };
8706
+ return window.addEventListener("beforeunload", r), () => {
8707
+ window.removeEventListener("beforeunload", r), e({
8708
+ moduleName: a,
8709
+ moduleUrl: o.current,
8710
+ startTime: t,
8711
+ endTime: Date.now()
8712
+ });
8713
+ };
8714
+ }, [r, a]), null;
8691
8715
  }, isPrimitiveValue = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null, initializeGuiLibrary = (e) => {
8692
8716
  setConfig(ConfigKeyType.LanguageKey, e.languageKey), Object.entries(e).forEach(([e, t]) => {
8693
8717
  if (e === ConfigKeyType.Translations) setConfig(e, getTranslations(t));
@@ -8697,4 +8721,4 @@ const ComparisonViewModal = ({ auditLog: e, auditLogs: t, data: n, isOpen: r, se
8697
8721
  }
8698
8722
  });
8699
8723
  };
8700
- export { Accordion, AccordionWithDefaultToggle, Actions, Align, AuditLog, 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 };
8724
+ export { Accordion, AccordionWithDefaultToggle, Actions, Align, AuditLog, 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, UsageTracker, 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.9.0",
3
+ "version": "5.10.0-beta-1",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {