@oliasoft-open-source/react-ui-library 4.6.6 → 4.6.7-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.
Files changed (42) hide show
  1. package/dist/index.d.ts +22 -0
  2. package/dist/index.js +150 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-6VNJS4EI-BrOcbA6h.js → Color-6VNJS4EI-hQgbfk1_.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-NNNQARDV-tJI6VTjP.js → DocsRenderer-NNNQARDV-qVZ0Szzp.js} +1 -1
  6. package/dist/storybook/assets/{WithTooltip-V3YHNWJZ-YRJYbhNd.js → WithTooltip-V3YHNWJZ-EVkXusH9.js} +1 -1
  7. package/dist/storybook/assets/{accordion.stories-nYKTmoeA.js → accordion.stories-Je6TgVbI.js} +1 -1
  8. package/dist/storybook/assets/{buttons-and-links-VKKWJKFr.js → buttons-and-links-Htqi06fE.js} +1 -1
  9. package/dist/storybook/assets/{casing-loads.stories-oh3l5Q7X.js → casing-loads.stories-rv-r7qUR.js} +1 -1
  10. package/dist/storybook/assets/cell.stories-ntUcZ9Z2.js +245 -0
  11. package/dist/storybook/assets/{chunk-HLWAVYOI-83EByc66.js → chunk-HLWAVYOI-XUXGp0n7.js} +1 -1
  12. package/dist/storybook/assets/{color-ugWGhOJm.js → color-l-jFB8qa.js} +1 -1
  13. package/dist/storybook/assets/{file-input.stories-8w1taUk6.js → file-input.stories-lKF1ABXX.js} +1 -1
  14. package/dist/storybook/assets/{footer.stories-tB9ZiuYm.js → footer.stories-txHcy_rz.js} +1 -1
  15. package/dist/storybook/assets/{form.stories-b8fSf1KV.js → form.stories-AikCzsZc.js} +1 -1
  16. package/dist/storybook/assets/{formation.stories-4zFgtvwa.js → formation.stories-WYUKooZj.js} +1 -1
  17. package/dist/storybook/assets/{formatter-SWP5E3XI-umUJAuhQ.js → formatter-SWP5E3XI-2jpDZ32o.js} +1 -1
  18. package/dist/storybook/assets/{iframe-LJjp0O19.js → iframe-afwDQcyf.js} +2 -2
  19. package/dist/storybook/assets/{index-hMEOtd8c.js → index-WQN43Pdc.js} +5 -5
  20. package/dist/storybook/assets/{input-validation-5TXTtQCt.js → input-validation-1C25NF0D.js} +1 -1
  21. package/dist/storybook/assets/{inputs-rK_va801.js → inputs-dvl3Vxzi.js} +1 -1
  22. package/dist/storybook/assets/{layout-forms-4SDauXUc.js → layout-forms-aQDJspiu.js} +1 -1
  23. package/dist/storybook/assets/{layout-general-4b2v8KKO.js → layout-general-glx7j38t.js} +1 -1
  24. package/dist/storybook/assets/{padding-and-spacing-0ADtQv-B.js → padding-and-spacing-nDPUVOhE.js} +1 -1
  25. package/dist/storybook/assets/{preview-Jj3eWAFT.js → preview-8iAUReLe.js} +1 -1
  26. package/dist/storybook/assets/{preview-ZGYBin_R.js → preview-NgqKh_bR.js} +2 -2
  27. package/dist/storybook/assets/{row.stories-p0ssjvtr.js → row.stories-s3mq4p3b.js} +1 -1
  28. package/dist/storybook/assets/{syntaxhighlighter-B5GMVT5T-yVSKFRoH.js → syntaxhighlighter-B5GMVT5T-sSZfeghu.js} +1 -1
  29. package/dist/storybook/assets/table-5HZEOUW_.js +1 -0
  30. package/dist/storybook/assets/{table.stories-wdVWlpz1.js → table.stories-wP0SdJzJ.js} +1 -1
  31. package/dist/storybook/assets/{textarea-gwm6gdQO.js → textarea-TSoWqDT8.js} +1 -1
  32. package/dist/storybook/assets/{textarea.stories-eOTtHmL4.js → textarea.stories-w6XYooLd.js} +1 -1
  33. package/dist/storybook/assets/{title.stories-9QWP9XVr.js → title.stories-CDtRZqWr.js} +1 -1
  34. package/dist/storybook/assets/{unit-table.stories-ZHWCQMuq.js → unit-table.stories-M8TmG1IT.js} +1 -1
  35. package/dist/storybook/iframe.html +1 -1
  36. package/dist/storybook/index.json +1 -1
  37. package/dist/storybook/project.json +1 -1
  38. package/dist/storybook/stories.json +1 -1
  39. package/package.json +1 -1
  40. package/dist/404.html +0 -1
  41. package/dist/storybook/assets/cell.stories-dk65sciA.js +0 -212
  42. package/dist/storybook/assets/table-033R9jUC.js +0 -1
package/dist/index.d.ts CHANGED
@@ -1666,6 +1666,8 @@ export declare const SideBar: React_2.MemoExoticComponent<({ options, startOpen,
1666
1666
 
1667
1667
  export declare const Slider: ({ name, label, width, labelWidth, value, min, max, step, marks, showArrows, showTooltip, tooltipFormatter, disabled, range, small, vertical, onChange, }: ISliderProps) => JSX_2.Element;
1668
1668
 
1669
+ export declare const SmartUploadModal: ({ visible, prompt, onCloseModal, onUpload, onComplete, onFailed, onError, width, heading, dialogText, fileInputText, fileInputPlaceholder, uploadText, cancelText, testId, }: TSmartUploadModalProps) => JSX_2.Element;
1670
+
1669
1671
  export declare const Spacer: ({ height, width, flex, }: ISpacerProps) => JSX_2.Element;
1670
1672
 
1671
1673
  export declare const Spinner: ({ small, colored, dark, tiny, }: ISpinnerProps) => JSX_2.Element;
@@ -1801,6 +1803,26 @@ declare type TSliderMark = {
1801
1803
  tooltip?: number | string | ReactNode;
1802
1804
  };
1803
1805
 
1806
+ export declare type TSmartUploadModalProps = {
1807
+ visible: boolean;
1808
+ prompt: string;
1809
+ onCloseModal: () => void;
1810
+ onUpload: (prompt: string, file: File) => any;
1811
+ onComplete: (data: {
1812
+ [key: string]: string;
1813
+ }[]) => void;
1814
+ onFailed?: () => void;
1815
+ onError?: (error: any) => void;
1816
+ width?: number;
1817
+ heading?: string;
1818
+ dialogText?: string;
1819
+ fileInputText?: string;
1820
+ fileInputPlaceholder?: string;
1821
+ uploadText?: string;
1822
+ cancelText?: string;
1823
+ testId?: string;
1824
+ };
1825
+
1804
1826
  declare type TStringNumberNull = string | number | null;
1805
1827
 
1806
1828
  declare type TStringOrNumber = string | number;
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import * as PropTypes from "prop-types";
11
11
  import PropTypes__default from "prop-types";
12
12
  import ReactDOM, { createPortal, unstable_batchedUpdates, render } from "react-dom";
13
13
  import _$1, { set, get as get$2, isString as isString$3, isNumber as isNumber$1, isBoolean as isBoolean$2, isFunction as isFunction$3, isEmpty, isArray as isArray$1, toNumber, debounce as debounce$2, isObject as isObject$5, isObjectLike, has as has$1, isEqual as isEqual$4 } from "lodash";
14
- import { roundToFixed, validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, checkAndCleanDecimalComma, label as label$b, altUnitsList, getUnitsForQuantity, convertAndGetValue, isScientificStringNum, roundToPrecision } from "@oliasoft-open-source/units";
14
+ import { roundToFixed, validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, checkAndCleanDecimalComma, label as label$b, altUnitsList, getUnitsForQuantity, convertAndGetValue, isScientificStringNum, roundToPrecision, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
15
15
  import { isValueWithUnit as isValueWithUnit$1 } from "@oliasoft-open-source/units/dist/units";
16
16
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
17
17
  function getDefaultExportFromCjs(x2) {
@@ -70856,6 +70856,154 @@ const UnitTable = ({
70856
70856
  }
70857
70857
  );
70858
70858
  };
70859
+ const INTERVAL_TIME = 250;
70860
+ const REQUEST_TIME = 4e4;
70861
+ const FINISH_INTERVALS = 20;
70862
+ const FINISH_TIME = 500;
70863
+ const SmartUploadModal = ({
70864
+ visible,
70865
+ prompt,
70866
+ onCloseModal,
70867
+ onUpload,
70868
+ onComplete,
70869
+ onFailed,
70870
+ onError: onError3,
70871
+ width: width2,
70872
+ heading: heading2,
70873
+ dialogText,
70874
+ fileInputText,
70875
+ fileInputPlaceholder,
70876
+ uploadText,
70877
+ cancelText,
70878
+ testId
70879
+ }) => {
70880
+ const [file, setFile] = useState(void 0);
70881
+ const [isFetching, setFetching] = useState(false);
70882
+ const [requestTimer, setRequestTimer] = useState(0);
70883
+ let timer = 0;
70884
+ const updateTimer = () => {
70885
+ const newTime = timer + INTERVAL_TIME;
70886
+ timer = newTime;
70887
+ setRequestTimer(timer);
70888
+ };
70889
+ const finishTimer = (deltaTime) => {
70890
+ let newTime = timer + deltaTime;
70891
+ if (newTime >= 0.99 * REQUEST_TIME) {
70892
+ newTime = REQUEST_TIME;
70893
+ }
70894
+ timer = newTime;
70895
+ setRequestTimer(timer);
70896
+ };
70897
+ useEffect(() => {
70898
+ setFile(void 0);
70899
+ }, [visible]);
70900
+ const handleFileChange = (event) => {
70901
+ if (!event.target.value)
70902
+ return;
70903
+ setFile(event.target.value);
70904
+ };
70905
+ const handleUpload = async () => {
70906
+ setRequestTimer(0);
70907
+ const id2 = setInterval(updateTimer, INTERVAL_TIME);
70908
+ try {
70909
+ if (!file)
70910
+ return;
70911
+ setFetching(true);
70912
+ const data = await onUpload(prompt, file);
70913
+ if (!visible)
70914
+ return;
70915
+ if (data) {
70916
+ clearInterval(id2);
70917
+ const id22 = setInterval(
70918
+ finishTimer,
70919
+ FINISH_TIME / FINISH_INTERVALS,
70920
+ (REQUEST_TIME - timer) / (FINISH_INTERVALS - 1)
70921
+ );
70922
+ setTimeout(() => {
70923
+ onComplete(data);
70924
+ clearInterval(id22);
70925
+ setFetching(false);
70926
+ }, FINISH_TIME);
70927
+ } else {
70928
+ onFailed == null ? void 0 : onFailed();
70929
+ setFetching(false);
70930
+ }
70931
+ } catch (error2) {
70932
+ onError3 == null ? void 0 : onError3(error2);
70933
+ setFetching(false);
70934
+ } finally {
70935
+ clearInterval(id2);
70936
+ }
70937
+ };
70938
+ const onConfirm = () => {
70939
+ handleUpload();
70940
+ };
70941
+ const onClose = () => {
70942
+ onCloseModal();
70943
+ };
70944
+ const content2 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
70945
+ /* @__PURE__ */ jsx(Text, { children: dialogText || "Upload file and extract data using a LLM" }),
70946
+ /* @__PURE__ */ jsx(Spacer, {}),
70947
+ /* @__PURE__ */ jsx(
70948
+ FileInput,
70949
+ {
70950
+ placeholder: fileInputPlaceholder || "No file",
70951
+ label: fileInputText || "Select",
70952
+ file: file || void 0,
70953
+ onChange: handleFileChange,
70954
+ testId: `${testId}-file-input`,
70955
+ accept: "image/*"
70956
+ }
70957
+ ),
70958
+ isFetching && /* @__PURE__ */ jsxs(Fragment$1, { children: [
70959
+ /* @__PURE__ */ jsx(Spacer, {}),
70960
+ /* @__PURE__ */ jsx(
70961
+ ProgressBar$1,
70962
+ {
70963
+ percentage: roundByMagnitudeToFixed(
70964
+ 100 * requestTimer / REQUEST_TIME,
70965
+ 3
70966
+ )
70967
+ }
70968
+ )
70969
+ ] })
70970
+ ] });
70971
+ const footer2 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
70972
+ /* @__PURE__ */ jsx(
70973
+ Button$1,
70974
+ {
70975
+ label: uploadText || "Upload",
70976
+ colored: true,
70977
+ onClick: onConfirm,
70978
+ disabled: !file || isFetching,
70979
+ testId: `${testId}-button-upload`
70980
+ }
70981
+ ),
70982
+ /* @__PURE__ */ jsx(
70983
+ Button$1,
70984
+ {
70985
+ label: cancelText || "Cancel",
70986
+ onClick: onClose,
70987
+ testId: `${testId}-button-cancel`
70988
+ }
70989
+ )
70990
+ ] });
70991
+ useKeyboardEvent("Escape", () => onClose());
70992
+ return /* @__PURE__ */ jsx(Modal, { visible, centered: true, children: /* @__PURE__ */ jsx(
70993
+ Dialog,
70994
+ {
70995
+ dialog: {
70996
+ scroll: true,
70997
+ heading: heading2 || "Smart Upload",
70998
+ content: content2,
70999
+ footer: footer2,
71000
+ onClose,
71001
+ width: width2 || 350,
71002
+ testId
71003
+ }
71004
+ }
71005
+ ) });
71006
+ };
70859
71007
  export {
70860
71008
  Accordion,
70861
71009
  AccordionWithDefaultToggle,
@@ -70920,6 +71068,7 @@ export {
70920
71068
  Select,
70921
71069
  SideBar,
70922
71070
  Slider,
71071
+ SmartUploadModal,
70923
71072
  Spacer,
70924
71073
  Spinner$1 as Spinner,
70925
71074
  Table,