@oliasoft-open-source/react-ui-library 4.6.0-beta-1 → 4.7.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 +9 -2
- package/dist/index.js +136 -63
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-6VNJS4EI-GxhKC8e4.js → Color-6VNJS4EI-NPUHt_3q.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-NNNQARDV-qNtI0g6x.js → DocsRenderer-NNNQARDV-HIEKjKKN.js} +1 -1
- package/dist/storybook/assets/{WithTooltip-4HIR6TLV-Oz_GUhfl.js → WithTooltip-4HIR6TLV-XVy3Qn7b.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-DAmwlTmm.js → accordion.stories-Uipdifbl.js} +1 -1
- package/dist/storybook/assets/{actions-SGexXf58.js → actions-Z9jDWreP.js} +1 -1
- package/dist/storybook/assets/{actions.stories-dDCC23QK.js → actions.stories-Qrio9EMy.js} +1 -1
- package/dist/storybook/assets/{afe.stories-1YkAm2l2.js → afe.stories-mangk6LB.js} +1 -1
- package/dist/storybook/assets/{badge.stories-nzXJ1qip.js → badge.stories-C0MXS15j.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-ro9WCHli.js → blowout.stories-i7Ii3760.js} +1 -1
- package/dist/storybook/assets/{button-IoNblLER.js → button-7V8oA22w.js} +1 -1
- package/dist/storybook/assets/{button-group-KeeGgC4K.js → button-group-q8QKkLVU.js} +1 -1
- package/dist/storybook/assets/{button-group.stories-DG3i2d7K.js → button-group.stories-tLZpLTfD.js} +1 -1
- package/dist/storybook/assets/{button.stories-vebimSi_.js → button.stories-PhWmZXOu.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-e5muuefU.js → buttons-and-links-gkg6hOs-.js} +1 -1
- package/dist/storybook/assets/{card.stories-OtRekExg.js → card.stories-HzHJW6ek.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories--oHbAVn4.js → casing-loads.stories-4eIPrrhL.js} +1 -1
- package/dist/storybook/assets/{cell.stories-nm3Q_0D8.js → cell.stories-X4sboJCw.js} +1 -1
- package/dist/storybook/assets/{check-box-BX5dfQFk.js → check-box-LZdXXKhv.js} +1 -1
- package/dist/storybook/assets/{check-box.stories-FNs72smP.js → check-box.stories-0XCykxnz.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-IpxCdjQR.js → chunk-HLWAVYOI-YF156CNQ.js} +1 -1
- package/dist/storybook/assets/{color-HUGaUBn2.js → color-PIYd2VAw.js} +1 -1
- package/dist/storybook/assets/{column.stories-5pd3N4bE.js → column.stories-6OLsjlcP.js} +1 -1
- package/dist/storybook/assets/{dialog-dekS0lUR.js → dialog-WKHRZcjc.js} +1 -1
- package/dist/storybook/assets/{drawer-TM-jK3WR.js → drawer-WuErQ5Z8.js} +1 -1
- package/dist/storybook/assets/{drawer.stories-OE24f2Y4.js → drawer.stories-RFRPs_pQ.js} +1 -1
- package/dist/storybook/assets/{empty.stories-KIByp315.js → empty.stories-lva3DbfI.js} +1 -1
- package/dist/storybook/assets/{field-kOZPBHf6.js → field-eknsj_Ll.js} +1 -1
- package/dist/storybook/assets/{field.stories-aEccauPi.js → field.stories-RmhJ16HT.js} +1 -1
- package/dist/storybook/assets/{file-input.stories-rkAlSDHE.js → file-input.stories-SF8BeFpu.js} +1 -1
- package/dist/storybook/assets/{flex-KzhjL9yc.js → flex-RYZsoWEN.js} +1 -1
- package/dist/storybook/assets/{flex.stories-rDfMJbP6.js → flex.stories-lLz0Xrt_.js} +1 -1
- package/dist/storybook/assets/{footer.stories-FmE2JKok.js → footer.stories-L0qQuABW.js} +1 -1
- package/dist/storybook/assets/{form.stories-LRkCBjZR.js → form.stories-qQsjBbOk.js} +1 -1
- package/dist/storybook/assets/{formation.stories-ZGzBQKt1.js → formation.stories-E8DV_cIY.js} +1 -1
- package/dist/storybook/assets/{formatter-SWP5E3XI-8JJuES-v.js → formatter-SWP5E3XI-uJi-Y6Jy.js} +1 -1
- package/dist/storybook/assets/{heading-cUVItwKq.js → heading-Bk0bpNfe.js} +1 -1
- package/dist/storybook/assets/{heading.stories-UJlMVVI-.js → heading.stories-HLMPkIPo.js} +1 -1
- package/dist/storybook/assets/{help-icon-nI9A506M.js → help-icon--rUDxLUD.js} +1 -1
- package/dist/storybook/assets/{help-icon.stories-Qz7MKCnQ.js → help-icon.stories-vifwJgNA.js} +1 -1
- package/dist/storybook/assets/{icon.stories-D_XEmSGG.js → icon.stories-W-UgTWyK.js} +1 -1
- package/dist/storybook/assets/iframe-NU_z28D3.js +7 -0
- package/dist/storybook/assets/{index-txtTsAry.js → index-_waogfzH.js} +5 -5
- package/dist/storybook/assets/{input-group.stories-EouZEW-v.js → input-group.stories-WljyIQ0a.js} +1 -1
- package/dist/storybook/assets/{input-iDZqV-2m.js → input-u1He-wWs.js} +1 -1
- package/dist/storybook/assets/{input-validation-YadXYe7E.js → input-validation-XFS-LWhH.js} +1 -1
- package/dist/storybook/assets/{input.stories-iopguZKB.js → input.stories-rLdDRxtU.js} +1 -1
- package/dist/storybook/assets/{inputs-YvlPtTke.js → inputs-vo_nTpyh.js} +1 -1
- package/dist/storybook/assets/{label-RpB4JmHX.js → label-0_Qf6I8t.js} +1 -1
- package/dist/storybook/assets/{label.stories-HcdQ1bEB.js → label.stories-aXdU5_Ql.js} +1 -1
- package/dist/storybook/assets/{layout-forms-2UsPyZyz.js → layout-forms-w8JJQQqh.js} +1 -1
- package/dist/storybook/assets/{layout-general-ma7VihYF.js → layout-general-QgIJDQ4H.js} +1 -1
- package/dist/storybook/assets/{list-ciYNlkVM.js → list-8l-RGDgw.js} +1 -1
- package/dist/storybook/assets/{list-heading-XbqCJOHh.js → list-heading-Vd3hu5Pf.js} +1 -1
- package/dist/storybook/assets/{list.stories-G1n5uCjl.js → list.stories-Vp0Dm7UU.js} +1 -1
- package/dist/storybook/assets/{list.stories-data-8eswVWst.js → list.stories-data-IcFu6vvd.js} +1 -1
- package/dist/storybook/assets/{loader.stories-G8Q_Fm8u.js → loader.stories-0OwmnNML.js} +1 -1
- package/dist/storybook/assets/{menu.stories-GFJs09Wk.js → menu.stories-VwRF_Pbx.js} +1 -1
- package/dist/storybook/assets/{menu.stories-data-c8X93fYM.js → menu.stories-data-hEz8P1yK.js} +1 -1
- package/dist/storybook/assets/{message.stories-BqM_-mrZ.js → message.stories-CDgUaLZP.js} +1 -1
- package/dist/storybook/assets/{modal.stories-K4XxeWTp.js → modal.stories-15sY1c5H.js} +1 -1
- package/dist/storybook/assets/{number-input-d7hXQldd.js → number-input-SvjJIGsW.js} +1 -1
- package/dist/storybook/assets/{number-input.stories-SOsG2FLJ.js → number-input.stories-BURENIFo.js} +1 -1
- package/dist/storybook/assets/{option-dropdown.stories-1Y5JDaBF.js → option-dropdown.stories-Q2zd2AcS.js} +1 -1
- package/dist/storybook/assets/{padding-and-spacing-KtiMa5GK.js → padding-and-spacing-J_Zb8SJm.js} +1 -1
- package/dist/storybook/assets/{page.stories-B5gzoAi8.js → page.stories-pa-9WU0e.js} +1 -1
- package/dist/storybook/assets/{pagination-Eaj_UOBW.js → pagination-5n5spTRo.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-sl2a8BMq.js → pagination.stories-g4a-aSxq.js} +1 -1
- package/dist/storybook/assets/{pop-confirm.stories-94l3Xg8w.js → pop-confirm.stories-_agvSFJd.js} +1 -1
- package/dist/storybook/assets/{popover-uAo1e4-D.js → popover-Y3FpGdUS.js} +1 -1
- package/dist/storybook/assets/{popover.stories-JVzzF0Jm.js → popover.stories-b7Tt4S0j.js} +1 -1
- package/dist/storybook/assets/{preview-lDu82Bod.js → preview-D7BEK6_6.js} +2 -2
- package/dist/storybook/assets/{preview-f1_nby1-.js → preview-WIFbPoA-.js} +1 -1
- package/dist/storybook/assets/{projects.stories-ojOsn6HU.js → projects.stories-YPlCLdRE.js} +1 -1
- package/dist/storybook/assets/{radio-button-QcS9mLYi.js → radio-button-jHcwHUA4.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-KCS981-F.js → radio-button.stories-LkCJsp5P.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-Dg5QFAXV.js → reservoirs.stories-hhPblhmv.js} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-D55Op5Gf.js → rich-text-input.stories-7UzvJ-A1.js} +1 -1
- package/dist/storybook/assets/{row.stories-2iigGv-u.js → row.stories-juQv80h3.js} +1 -1
- package/dist/storybook/assets/{select-Z1HqJ5aU.js → select-JjEPivho.js} +1 -1
- package/dist/storybook/assets/{select.stories-oUxeDUts.js → select.stories-qFDyxRFm.js} +1 -1
- package/dist/storybook/assets/{side-bar-GJ2tcZYY.js → side-bar-Fjr2t9MT.js} +1 -1
- package/dist/storybook/assets/{side-bar.stories-Ld0zOToQ.js → side-bar.stories-sxBJCVnV.js} +1 -1
- package/dist/storybook/assets/{site.stories-OEW6o2C_.js → site.stories-QHCzFOnt.js} +1 -1
- package/dist/storybook/assets/{slider-_5NQKbM-.js → slider-nl2rJ9LF.js} +1 -1
- package/dist/storybook/assets/{slider.stories-QyyBB_rz.js → slider.stories--aZa8kf-.js} +1 -1
- package/dist/storybook/assets/{spacer.stories--ynGgvN4.js → spacer.stories-eCrKj4b3.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-NMPM6SWI-q0TZrkav.js → syntaxhighlighter-NMPM6SWI--OA96ou_.js} +1 -1
- package/dist/storybook/assets/{table-_jWgMFOi.js → table-i8WT9qpj.js} +1 -1
- package/dist/storybook/assets/{table.stories-data-w897tYMJ.js → table.stories-data-4h6h0P0V.js} +1 -1
- package/dist/storybook/assets/{table.stories-QupkMmra.js → table.stories-tEvulp9K.js} +1 -1
- package/dist/storybook/assets/{textarea-2SpO5fge.js → textarea-gxvxVBdC.js} +1 -1
- package/dist/storybook/assets/{textarea.stories-IgfK-23t.js → textarea.stories-MZHVAwSx.js} +1 -1
- package/dist/storybook/assets/{title.stories-14d2lIxy.js → title.stories-cmteB9lx.js} +1 -1
- package/dist/storybook/assets/{toaster.stories-XhUo3pbR.js → toaster.stories-S25S4g_F.js} +1 -1
- package/dist/storybook/assets/{toggle-wk0GbVB8.js → toggle-BPI2y-lU.js} +1 -1
- package/dist/storybook/assets/{toggle.stories-ItCMhW4M.js → toggle.stories-aVmjpons.js} +1 -1
- package/dist/storybook/assets/{tooltip-ZHdi6rl-.js → tooltip-HEHiU__l.js} +1 -1
- package/dist/storybook/assets/{tooltip.stories-gTfOeEzv.js → tooltip.stories-tiOgoWHH.js} +1 -1
- package/dist/storybook/assets/{tooltip.test-case.stories-L2bW8Ijz.js → tooltip.test-case.stories-kIeZayHw.js} +1 -1
- package/dist/storybook/assets/{top-bar-0fDAFWyC.js → top-bar-9iOkm7Gq.js} +1 -1
- package/dist/storybook/assets/{top-bar.stories-YKtteM_h.js → top-bar.stories-5jcHi3Q_.js} +1 -1
- package/dist/storybook/assets/{top-bar.testcase.stories-Z-6C5D2R.js → top-bar.testcase.stories-7acJvLc_.js} +1 -1
- package/dist/storybook/assets/tree.stories-_5t-Rrls.js +128 -0
- package/dist/storybook/assets/unit-input.stories-j3Ykteob.js +273 -0
- package/dist/storybook/assets/unit-table.stories-4XYwgJwY.js +100 -0
- package/dist/storybook/assets/use-previous-VKMmnaK7.js +1 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/stories.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/iframe-yZ0ImE73.js +0 -7
- package/dist/storybook/assets/tree.stories-5fjCVN1S.js +0 -180
- package/dist/storybook/assets/unit-input.stories-ZdrR9JWT.js +0 -273
package/dist/index.d.ts
CHANGED
|
@@ -1494,7 +1494,6 @@ export declare interface ITreeProps {
|
|
|
1494
1494
|
expand: React_2.ReactNode;
|
|
1495
1495
|
collapse: React_2.ReactNode;
|
|
1496
1496
|
};
|
|
1497
|
-
allowParentReassignment?: boolean;
|
|
1498
1497
|
}
|
|
1499
1498
|
|
|
1500
1499
|
export declare interface IUnitInputProps {
|
|
@@ -1711,7 +1710,7 @@ export declare const Tooltip: ({ children, text, error, placement, possiblePlace
|
|
|
1711
1710
|
|
|
1712
1711
|
export declare const TopBar: ({ title, appSwitcher, content, contentRight, warning, height, fixedPosition, }: ITopBarProps) => JSX_2.Element;
|
|
1713
1712
|
|
|
1714
|
-
export declare const Tree: ({ list, draggable, onListReorder, onChangeOpen, testId, isInitialOpen, treeRef, itemHasChild, onItemToggle, icons,
|
|
1713
|
+
export declare const Tree: ({ list, draggable, onListReorder, onChangeOpen, testId, isInitialOpen, treeRef, itemHasChild, onItemToggle, icons, }: ITreeProps) => JSX_2.Element;
|
|
1715
1714
|
|
|
1716
1715
|
export declare enum TriggerType {
|
|
1717
1716
|
TEXT = "Text",
|
|
@@ -1749,6 +1748,14 @@ export declare type TTriggerType = 'Text' | 'Button' | 'DropDownButton' | 'Compo
|
|
|
1749
1748
|
|
|
1750
1749
|
export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, doNotConvertValue, testId, warning, predefinedOptions, initialPredefinedOption, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, autoValue, }: IUnitInputProps) => JSX_2.Element;
|
|
1751
1750
|
|
|
1751
|
+
export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, convertBackToString, enableCosmeticRounding, }: {
|
|
1752
|
+
table: any;
|
|
1753
|
+
unitConfig: any;
|
|
1754
|
+
convertBackToStorageUnit?: boolean | undefined;
|
|
1755
|
+
convertBackToString?: boolean | undefined;
|
|
1756
|
+
enableCosmeticRounding?: boolean | undefined;
|
|
1757
|
+
}) => JSX_2.Element;
|
|
1758
|
+
|
|
1752
1759
|
export declare const useFocus: () => UseFocusReturnType;
|
|
1753
1760
|
|
|
1754
1761
|
declare type UseFocusReturnType = [MutableRefObject<HTMLInputElement | null>, TEmpty];
|
package/dist/index.js
CHANGED
|
@@ -10,8 +10,8 @@ import React__default, { useContext, isValidElement, useState, useRef, useEffect
|
|
|
10
10
|
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
|
-
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 } from "lodash";
|
|
14
|
-
import { validateNumber, cleanNumStr, unitFromQuantity, isValueWithUnit, withUnit, convertSamePrecision, getValue as getValue$1, getUnit, KNOWN_UNITS, split as split$1, checkAndCleanDecimalComma, label as label$b, altUnitsList } from "@oliasoft-open-source/units";
|
|
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 { 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, roundToPrecision } 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) {
|
|
@@ -70010,75 +70010,24 @@ const Tree = ({
|
|
|
70010
70010
|
treeRef,
|
|
70011
70011
|
itemHasChild,
|
|
70012
70012
|
onItemToggle,
|
|
70013
|
-
icons: icons2
|
|
70014
|
-
allowParentReassignment
|
|
70013
|
+
icons: icons2
|
|
70015
70014
|
}) => {
|
|
70016
70015
|
var _a;
|
|
70017
|
-
const
|
|
70018
|
-
if (
|
|
70019
|
-
|
|
70020
|
-
}
|
|
70021
|
-
};
|
|
70022
|
-
const findNodeIndexById = (tree22, id2) => {
|
|
70023
|
-
return (tree22 == null ? void 0 : tree22.findIndex((node2) => (node2 == null ? void 0 : node2.id) === id2)) ?? -1;
|
|
70024
|
-
};
|
|
70025
|
-
const setDragSourceParentToGrandparent = (dragSource, workingTree) => {
|
|
70026
|
-
const dragSourceParentIndex = findNodeIndexById(
|
|
70027
|
-
workingTree,
|
|
70028
|
-
dragSource == null ? void 0 : dragSource.parent
|
|
70029
|
-
);
|
|
70030
|
-
if (dragSourceParentIndex >= 0) {
|
|
70031
|
-
const grandparent = workingTree == null ? void 0 : workingTree.find(
|
|
70032
|
-
(node2) => {
|
|
70033
|
-
var _a2;
|
|
70034
|
-
return (node2 == null ? void 0 : node2.id) === ((_a2 = workingTree[dragSourceParentIndex]) == null ? void 0 : _a2.parent);
|
|
70035
|
-
}
|
|
70036
|
-
);
|
|
70037
|
-
dragSource.parent = grandparent ? grandparent.id : 0;
|
|
70038
|
-
}
|
|
70039
|
-
};
|
|
70040
|
-
const removeDragSourceFromWorkingTree = (dragSource, workingTree) => {
|
|
70041
|
-
return (workingTree == null ? void 0 : workingTree.filter((node2) => (node2 == null ? void 0 : node2.id) !== (dragSource == null ? void 0 : dragSource.id))) ?? [];
|
|
70042
|
-
};
|
|
70043
|
-
const insertDragSourceAfterParentInWorkingTree = (dragSource, dragSourceParentIndex, workingTree) => {
|
|
70044
|
-
workingTree == null ? void 0 : workingTree.splice(dragSourceParentIndex, 0, dragSource);
|
|
70045
|
-
return workingTree;
|
|
70046
|
-
};
|
|
70047
|
-
const transformTreeToList = (tree22) => {
|
|
70048
|
-
return tree22.map(({ id: id2, parent, droppable: droppable2, data }) => {
|
|
70049
|
-
return {
|
|
70016
|
+
const handleDrop = (newTree) => {
|
|
70017
|
+
if (onListReorder) {
|
|
70018
|
+
const newList = newTree.map(({ id: id2, parent, droppable: droppable2, data }) => ({
|
|
70050
70019
|
id: id2,
|
|
70051
70020
|
parent,
|
|
70052
70021
|
droppable: droppable2,
|
|
70053
70022
|
...data
|
|
70054
|
-
};
|
|
70055
|
-
|
|
70023
|
+
}));
|
|
70024
|
+
onListReorder(newList);
|
|
70025
|
+
}
|
|
70056
70026
|
};
|
|
70057
|
-
const
|
|
70058
|
-
|
|
70059
|
-
|
|
70060
|
-
if (!onListReorder)
|
|
70061
|
-
return;
|
|
70062
|
-
const dragSourceIndex = findNodeIndexById(workingTree, dragSource == null ? void 0 : dragSource.id);
|
|
70063
|
-
const dragSourceParentIndex = findNodeIndexById(
|
|
70064
|
-
workingTree,
|
|
70065
|
-
dragSource == null ? void 0 : dragSource.parent
|
|
70066
|
-
);
|
|
70067
|
-
let newList = [];
|
|
70068
|
-
if ((dragSource == null ? void 0 : dragSource.parent) === (dropTarget2 == null ? void 0 : dropTarget2.id) && dragSourceIndex === 0 && allowParentReassignment) {
|
|
70069
|
-
setDragSourceParentToGrandparent(dragSource, workingTree);
|
|
70070
|
-
workingTree = removeDragSourceFromWorkingTree(
|
|
70071
|
-
dragSource,
|
|
70072
|
-
workingTree
|
|
70073
|
-
);
|
|
70074
|
-
workingTree = insertDragSourceAfterParentInWorkingTree(
|
|
70075
|
-
dragSource,
|
|
70076
|
-
dragSourceParentIndex,
|
|
70077
|
-
workingTree
|
|
70078
|
-
);
|
|
70027
|
+
const handleOpen = (id2) => {
|
|
70028
|
+
if (onChangeOpen) {
|
|
70029
|
+
onChangeOpen(id2);
|
|
70079
70030
|
}
|
|
70080
|
-
newList = transformTreeToList(workingTree);
|
|
70081
|
-
onListReorder(newList);
|
|
70082
70031
|
};
|
|
70083
70032
|
const tree2 = (_a = list2 == null ? void 0 : list2.items) == null ? void 0 : _a.map(({ id: id2, droppable: droppable2, parent, name: name2, ...rest }) => ({
|
|
70084
70033
|
id: id2,
|
|
@@ -70595,6 +70544,129 @@ const UnitInput = ({
|
|
|
70595
70544
|
}
|
|
70596
70545
|
);
|
|
70597
70546
|
};
|
|
70547
|
+
const normalizeUnits = (unitConfig) => unitConfig.reduce(
|
|
70548
|
+
({ preferredUnits, storageUnits }, { unitKey, preferredUnit, storageUnit }) => {
|
|
70549
|
+
preferredUnits[unitKey] = preferredUnit;
|
|
70550
|
+
storageUnits[unitKey] = storageUnit;
|
|
70551
|
+
return { preferredUnits, storageUnits };
|
|
70552
|
+
},
|
|
70553
|
+
{ preferredUnits: {}, storageUnits: {} }
|
|
70554
|
+
);
|
|
70555
|
+
const convertVisibleRows = ({
|
|
70556
|
+
headers,
|
|
70557
|
+
rows,
|
|
70558
|
+
selectedUnits,
|
|
70559
|
+
storageUnits,
|
|
70560
|
+
onChangeUnit,
|
|
70561
|
+
convertBackToStorageUnit,
|
|
70562
|
+
convertBackToString,
|
|
70563
|
+
enableCosmeticRounding
|
|
70564
|
+
}) => {
|
|
70565
|
+
const convertedHeaders = headers.map((headerRow) => ({
|
|
70566
|
+
...headerRow,
|
|
70567
|
+
cells: headerRow.cells.map((headerCell) => {
|
|
70568
|
+
if (headerCell.type === "AutoUnit") {
|
|
70569
|
+
const { unitKey } = headerCell;
|
|
70570
|
+
return {
|
|
70571
|
+
value: selectedUnits[unitKey],
|
|
70572
|
+
type: "Select",
|
|
70573
|
+
options: getUnitsForQuantity(unitKey),
|
|
70574
|
+
native: true,
|
|
70575
|
+
onChange: (evt) => onChangeUnit({ unitKey, value: evt.target.value })
|
|
70576
|
+
};
|
|
70577
|
+
}
|
|
70578
|
+
return headerCell;
|
|
70579
|
+
})
|
|
70580
|
+
}));
|
|
70581
|
+
const convertedRows = rows.map((row2, rowIndex) => ({
|
|
70582
|
+
...row2,
|
|
70583
|
+
cells: row2.cells.map((cell2, cellIndex) => {
|
|
70584
|
+
if (cell2.autoUnit) {
|
|
70585
|
+
const { formatDisplayValue } = cell2;
|
|
70586
|
+
const convertedValue = convertAndGetValue(
|
|
70587
|
+
cell2.value,
|
|
70588
|
+
selectedUnits[cell2.unitKey],
|
|
70589
|
+
storageUnits[cell2.unitKey]
|
|
70590
|
+
);
|
|
70591
|
+
const displayValue = enableCosmeticRounding ? roundToPrecision(convertedValue, 14) : convertedValue;
|
|
70592
|
+
const formattedDisplayValue = formatDisplayValue ? formatDisplayValue(displayValue) : displayValue;
|
|
70593
|
+
return {
|
|
70594
|
+
...cell2,
|
|
70595
|
+
value: formattedDisplayValue,
|
|
70596
|
+
onChange: (evt) => {
|
|
70597
|
+
const { value } = evt.target;
|
|
70598
|
+
const { unitKey } = cell2;
|
|
70599
|
+
const storageUnit = storageUnits[unitKey];
|
|
70600
|
+
const selectedUnit = selectedUnits[unitKey];
|
|
70601
|
+
const unitChanged = selectedUnit !== storageUnit;
|
|
70602
|
+
const nextValueConverted = unitChanged && convertBackToStorageUnit ? convertAndGetValue(value, storageUnit, selectedUnit) : value;
|
|
70603
|
+
const nextValue = convertBackToString ? String(nextValueConverted) : nextValueConverted;
|
|
70604
|
+
const nextUnit = convertBackToStorageUnit ? storageUnit : selectedUnit;
|
|
70605
|
+
cell2.onChange({
|
|
70606
|
+
rowIndex,
|
|
70607
|
+
cellIndex,
|
|
70608
|
+
value: nextValue,
|
|
70609
|
+
unit: nextUnit
|
|
70610
|
+
});
|
|
70611
|
+
}
|
|
70612
|
+
};
|
|
70613
|
+
}
|
|
70614
|
+
return cell2;
|
|
70615
|
+
})
|
|
70616
|
+
}));
|
|
70617
|
+
return { convertedHeaders, convertedRows };
|
|
70618
|
+
};
|
|
70619
|
+
const UnitTable = ({
|
|
70620
|
+
table: table2,
|
|
70621
|
+
unitConfig,
|
|
70622
|
+
convertBackToStorageUnit = true,
|
|
70623
|
+
convertBackToString = false,
|
|
70624
|
+
enableCosmeticRounding = true
|
|
70625
|
+
}) => {
|
|
70626
|
+
const { rows, headers, otherProps } = table2;
|
|
70627
|
+
const { storageUnits, preferredUnits } = normalizeUnits(unitConfig);
|
|
70628
|
+
const previousPreferredUnits = usePrevious(preferredUnits);
|
|
70629
|
+
const [selectedUnits, setSelectedUnits] = useState(preferredUnits);
|
|
70630
|
+
const onChangeUnit = ({ unitKey, value }) => setSelectedUnits({
|
|
70631
|
+
...selectedUnits,
|
|
70632
|
+
[unitKey]: value
|
|
70633
|
+
});
|
|
70634
|
+
const convertViewData = (selectedUnits2) => convertVisibleRows({
|
|
70635
|
+
headers,
|
|
70636
|
+
rows,
|
|
70637
|
+
selectedUnits: selectedUnits2,
|
|
70638
|
+
storageUnits,
|
|
70639
|
+
onChangeUnit,
|
|
70640
|
+
convertBackToStorageUnit,
|
|
70641
|
+
convertBackToString,
|
|
70642
|
+
enableCosmeticRounding
|
|
70643
|
+
});
|
|
70644
|
+
const convertedViewData = convertViewData(selectedUnits);
|
|
70645
|
+
const [viewData, setViewData] = useState(convertedViewData);
|
|
70646
|
+
useEffect(() => {
|
|
70647
|
+
const templateChanged = !isEqual$4(preferredUnits, previousPreferredUnits);
|
|
70648
|
+
if (templateChanged) {
|
|
70649
|
+
setSelectedUnits(preferredUnits);
|
|
70650
|
+
setViewData(convertViewData(preferredUnits));
|
|
70651
|
+
}
|
|
70652
|
+
}, [unitConfig]);
|
|
70653
|
+
useEffect(() => {
|
|
70654
|
+
setViewData(convertViewData(selectedUnits));
|
|
70655
|
+
}, [table2]);
|
|
70656
|
+
useEffect(() => {
|
|
70657
|
+
setViewData(convertViewData(selectedUnits));
|
|
70658
|
+
}, [selectedUnits]);
|
|
70659
|
+
return /* @__PURE__ */ jsx(
|
|
70660
|
+
Table,
|
|
70661
|
+
{
|
|
70662
|
+
table: {
|
|
70663
|
+
...otherProps,
|
|
70664
|
+
headers: viewData.convertedHeaders,
|
|
70665
|
+
rows: viewData.convertedRows
|
|
70666
|
+
}
|
|
70667
|
+
}
|
|
70668
|
+
);
|
|
70669
|
+
};
|
|
70598
70670
|
export {
|
|
70599
70671
|
Accordion,
|
|
70600
70672
|
AccordionWithDefaultToggle,
|
|
@@ -70674,6 +70746,7 @@ export {
|
|
|
70674
70746
|
Tree,
|
|
70675
70747
|
TriggerType,
|
|
70676
70748
|
UnitInput,
|
|
70749
|
+
UnitTable,
|
|
70677
70750
|
dismissToast,
|
|
70678
70751
|
readFile,
|
|
70679
70752
|
toast,
|