@oliasoft-open-source/react-ui-library 4.3.0-beta-1 → 4.3.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 +54 -0
- package/dist/index.js +151 -1
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/Color-6VNJS4EI-e16af034.js +1 -0
- package/dist/storybook/assets/DocsRenderer-NNNQARDV-eaf66766.js +1 -0
- package/dist/storybook/assets/WithTooltip-4HIR6TLV-86dbd99d.js +1 -0
- package/dist/storybook/assets/{accordion-168fa7c5.js → accordion-1b587708.js} +1 -1
- package/dist/storybook/assets/{accordion-with-default-toggle-0b4845c8.js → accordion-with-default-toggle-775c8135.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-ad491954.js → accordion.stories-a9cecbe0.js} +2 -2
- package/dist/storybook/assets/{actions-2d4e1c8e.js → actions-83a2a04e.js} +1 -1
- package/dist/storybook/assets/{actions.stories-81a7cb7a.js → actions.stories-a38cd26e.js} +1 -1
- package/dist/storybook/assets/{afe.stories-49904fdb.js → afe.stories-e25ea064.js} +2 -2
- package/dist/storybook/assets/{badge.stories-5ce7957f.js → badge.stories-1cbf35f9.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-ee7f932b.js → blowout.stories-af7f9432.js} +1 -1
- package/dist/storybook/assets/{button-74c97e4a.js → button-050c998a.js} +1 -1
- package/dist/storybook/assets/{button-group-fa895d0c.js → button-group-0176fca3.js} +1 -1
- package/dist/storybook/assets/{button-group.stories-22f072b7.js → button-group.stories-7659a587.js} +1 -1
- package/dist/storybook/assets/{button.stories-9b954335.js → button.stories-5f73ddef.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-6c701fa6.js → buttons-and-links-153efc05.js} +2 -2
- package/dist/storybook/assets/{card.stories-537a1772.js → card.stories-0437a4e2.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-dff0b8fc.js → casing-loads.stories-90bc0b91.js} +2 -2
- package/dist/storybook/assets/{cell.stories-524a7418.js → cell.stories-0ae4bf08.js} +2 -2
- package/dist/storybook/assets/{check-box-e21258d5.js → check-box-b38490e5.js} +1 -1
- package/dist/storybook/assets/{check-box.stories-5f7d06e0.js → check-box.stories-9bf1c260.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-d8be29f3.js → chunk-HLWAVYOI-64001074.js} +1 -1
- package/dist/storybook/assets/color-e82f5009.js +25 -0
- package/dist/storybook/assets/{column.stories-ae7588c5.js → column.stories-d5ca2c42.js} +1 -1
- package/dist/storybook/assets/{drawer-7f450988.js → drawer-308b0a03.js} +1 -1
- package/dist/storybook/assets/{drawer.stories-59cd794a.js → drawer.stories-724ec941.js} +2 -2
- package/dist/storybook/assets/{empty.stories-c98807b8.js → empty.stories-1871df42.js} +1 -1
- package/dist/storybook/assets/extends-98964cd2.js +1 -0
- package/dist/storybook/assets/{field-a094cd72.js → field-248df38c.js} +1 -1
- package/dist/storybook/assets/{field.stories-f1318053.js → field.stories-60d1a82f.js} +1 -1
- package/dist/storybook/assets/{file-input-a3594635.js → file-input-31a9b5bf.js} +1 -1
- package/dist/storybook/assets/{file-input.stories-3d2e95e7.js → file-input.stories-dbedc9fc.js} +1 -1
- package/dist/storybook/assets/{flex.stories-09e9c602.js → flex.stories-6a278b40.js} +1 -1
- package/dist/storybook/assets/footer.stories-50a2e3db.js +3 -0
- package/dist/storybook/assets/form.stories-2184d699.js +49 -0
- package/dist/storybook/assets/formation.stories-e27935eb.js +74 -0
- package/dist/storybook/assets/{formatter-SWP5E3XI-c42be4d9.js → formatter-SWP5E3XI-598bdf16.js} +2 -2
- package/dist/storybook/assets/{heading-d29eb744.js → heading-39e599c8.js} +1 -1
- package/dist/storybook/assets/{heading.stories-9689bddc.js → heading.stories-6ff7f5ed.js} +1 -1
- package/dist/storybook/assets/{help-icon-d4189b1b.js → help-icon-c0abd380.js} +1 -1
- package/dist/storybook/assets/{help-icon.stories-15d1620d.js → help-icon.stories-a30b7058.js} +1 -1
- package/dist/storybook/assets/icon-8acf9925.js +8 -0
- package/dist/storybook/assets/{icon.stories-8dae69e1.js → icon.stories-466d158f.js} +1 -1
- package/dist/storybook/assets/iframe-2ec6fd1b.js +1 -0
- package/dist/storybook/assets/{index-56f304c1.js → index-85e6b336.js} +4 -4
- package/dist/storybook/assets/{index.es-85cc7dfc.js → index.es-37e2ce0d.js} +4 -4
- package/dist/storybook/assets/inheritsLoose-c82a83d4.js +1 -0
- package/dist/storybook/assets/{input-d68625a5.js → input-05f21b51.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-a2a3400e.js → input-group.stories-602e1e93.js} +2 -2
- package/dist/storybook/assets/{input-validation-1b895773.js → input-validation-83a841e7.js} +2 -2
- package/dist/storybook/assets/{input.stories-164d93ab.js → input.stories-bf58ba7c.js} +1 -1
- package/dist/storybook/assets/{inputs-e51c1c31.js → inputs-679d81e4.js} +14 -14
- package/dist/storybook/assets/{label-13d490a3.js → label-e6d15b59.js} +1 -1
- package/dist/storybook/assets/{label.stories-427ba162.js → label.stories-1c98204a.js} +1 -1
- package/dist/storybook/assets/layout-forms-9382a8d3.js +16 -0
- package/dist/storybook/assets/{layout-general-245ef20f.js → layout-general-cab7e55d.js} +2 -2
- package/dist/storybook/assets/{list-e6e7e5ed.js → list-d40713ca.js} +1 -1
- package/dist/storybook/assets/{list.stories-e2d00aea.js → list.stories-5daa007f.js} +2 -2
- package/dist/storybook/assets/{list.stories-data-94f7c623.js → list.stories-data-ba40864f.js} +1 -1
- package/dist/storybook/assets/{loader.stories-6107832a.js → loader.stories-4e8e8df7.js} +1 -1
- package/dist/storybook/assets/{menu.stories-927adf3d.js → menu.stories-8d724757.js} +1 -1
- package/dist/storybook/assets/{message-dabd76a8.js → message-f4352d69.js} +1 -1
- package/dist/storybook/assets/{message.stories-6f612f7c.js → message.stories-bb7952c5.js} +1 -1
- package/dist/storybook/assets/{meta-content-6f132e03.js → meta-content-c2771b33.js} +1 -1
- package/dist/storybook/assets/{modal-ad69eee9.js → modal-90ebced9.js} +1 -1
- package/dist/storybook/assets/{modal.stories-448cc75d.js → modal.stories-24646454.js} +2 -2
- package/dist/storybook/assets/{number-input-7d49b0b3.js → number-input-cfbd9eb7.js} +1 -1
- package/dist/storybook/assets/{number-input.stories-02528124.js → number-input.stories-8137782e.js} +2 -2
- package/dist/storybook/assets/{option-dropdown-fbe54c09.js → option-dropdown-14e7d023.js} +1 -1
- package/dist/storybook/assets/{option-dropdown.stories-8b7ee529.js → option-dropdown.stories-f251610f.js} +1 -1
- package/dist/storybook/assets/{padding-and-spacing-27e63c65.js → padding-and-spacing-89974d3f.js} +2 -2
- package/dist/storybook/assets/{page.stories-4ad3bea8.js → page.stories-7a6f330e.js} +1 -1
- package/dist/storybook/assets/{pagination-8aade846.js → pagination-443065a8.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-423b4938.js → pagination.stories-985230f7.js} +2 -2
- package/dist/storybook/assets/{pop-confirm-e6b7cc0c.js → pop-confirm-ce206de8.js} +1 -1
- package/dist/storybook/assets/{pop-confirm.stories-27da1975.js → pop-confirm.stories-5772f622.js} +1 -1
- package/dist/storybook/assets/{popover-06e375a5.js → popover-c1234faa.js} +1 -1
- package/dist/storybook/assets/popover.stories-7542a367.js +1 -0
- package/dist/storybook/assets/preview-65e4021c.js +1 -0
- package/dist/storybook/assets/{preview-72d84988.js → preview-a99e63ce.js} +3 -3
- package/dist/storybook/assets/projects.stories-f8294ed5.js +47 -0
- package/dist/storybook/assets/{radio-button-135a9615.js → radio-button-d69b72e4.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-0e8377ea.js → radio-button.stories-6ff0dc9b.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-b4549b91.js → reservoirs.stories-80ad2f26.js} +2 -2
- package/dist/storybook/assets/{rich-text-input-977847ce.js → rich-text-input-a0f4a598.js} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-b770908d.js → rich-text-input.stories-988bbe20.js} +2 -2
- package/dist/storybook/assets/{row.stories-d5b6b4a6.js → row.stories-c12a3e52.js} +2 -2
- package/dist/storybook/assets/select-d4593fc0.js +1 -0
- package/dist/storybook/assets/{select.stories-60f055e6.js → select.stories-6651d3f2.js} +2 -2
- package/dist/storybook/assets/{side-bar-88e8cf41.js → side-bar-10cceacd.js} +1 -1
- package/dist/storybook/assets/{side-bar.stories-2c06f8a6.js → side-bar.stories-02211e0d.js} +1 -1
- package/dist/storybook/assets/{site.stories-80a441ea.js → site.stories-284e27be.js} +2 -2
- package/dist/storybook/assets/slider-5d5442fe.js +7 -0
- package/dist/storybook/assets/{slider.stories-79ab0e97.js → slider.stories-a55df653.js} +2 -2
- package/dist/storybook/assets/{spacer.stories-38071af8.js → spacer.stories-a2798d47.js} +1 -1
- package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-007a6982.js +1 -0
- package/dist/storybook/assets/{table-da6f6045.js → table-134da40b.js} +1 -1
- package/dist/storybook/assets/{table.stories-67a3023a.js → table.stories-8dd2a568.js} +2 -2
- package/dist/storybook/assets/{table.stories-data-8a836b92.js → table.stories-data-ddbcf8c3.js} +1 -1
- package/dist/storybook/assets/{textarea-d48efea2.js → textarea-820c62b6.js} +1 -1
- package/dist/storybook/assets/{textarea.stories-89c8afd7.js → textarea.stories-aeaa9aa0.js} +1 -1
- package/dist/storybook/assets/{title.stories-5b4a226c.js → title.stories-2ba6aa87.js} +2 -2
- package/dist/storybook/assets/{toaster-3fba1dd3.js → toaster-55ac121d.js} +1 -1
- package/dist/storybook/assets/{toaster.stories-4cdefe35.js → toaster.stories-28d11f39.js} +1 -1
- package/dist/storybook/assets/{toggle-bb34b2a2.js → toggle-6f4d5797.js} +1 -1
- package/dist/storybook/assets/{toggle.stories-b771ed81.js → toggle.stories-a289f544.js} +1 -1
- package/dist/storybook/assets/{tooltip-23e84186.js → tooltip-856042a7.js} +1 -1
- package/dist/storybook/assets/{tooltip.stories-e8ba5fff.js → tooltip.stories-666868d0.js} +1 -1
- package/dist/storybook/assets/{tooltip.test-case.stories-9817078b.js → tooltip.test-case.stories-4c1ea273.js} +1 -1
- package/dist/storybook/assets/{top-bar-a84b9365.js → top-bar-38689fe2.js} +1 -1
- package/dist/storybook/assets/{top-bar.stories-e93330f0.js → top-bar.stories-3d9a6da1.js} +1 -1
- package/dist/storybook/assets/{top-bar.testcase.stories-3a824a14.js → top-bar.testcase.stories-dc051455.js} +1 -1
- package/dist/storybook/assets/{tree-a5de7d3a.js → tree-a2bbc2e4.js} +1 -1
- package/dist/storybook/assets/{tree.stories-b16724d6.js → tree.stories-0e132447.js} +1 -1
- package/dist/storybook/assets/{unit-input-9bf08434.js → unit-input-c16535f7.js} +1 -1
- package/dist/storybook/assets/{unit-input.stories-65646cf3.js → unit-input.stories-0f7705d6.js} +1 -1
- package/dist/storybook/assets/unit-table.stories-71ef347c.js +229 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/Color-6VNJS4EI-caa8bffa.js +0 -1
- package/dist/storybook/assets/DocsRenderer-NNNQARDV-e463e8a5.js +0 -1
- package/dist/storybook/assets/WithTooltip-4HIR6TLV-9514f93a.js +0 -1
- package/dist/storybook/assets/color-9e78f280.js +0 -25
- package/dist/storybook/assets/footer.stories-57f07ea2.js +0 -3
- package/dist/storybook/assets/form.stories-45c0cd59.js +0 -49
- package/dist/storybook/assets/formation.stories-5eeaa826.js +0 -74
- package/dist/storybook/assets/icon-e9cbb4d7.js +0 -8
- package/dist/storybook/assets/iframe-8d80f428.js +0 -1
- package/dist/storybook/assets/inheritsLoose-d4851ab8.js +0 -1
- package/dist/storybook/assets/layout-forms-29ceb520.js +0 -16
- package/dist/storybook/assets/popover.stories-f651a81c.js +0 -1
- package/dist/storybook/assets/preview-608a4ee9.js +0 -1
- package/dist/storybook/assets/projects.stories-c383cdce.js +0 -47
- package/dist/storybook/assets/select-205cd538.js +0 -1
- package/dist/storybook/assets/slider-160e2152.js +0 -7
- package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-73149e16.js +0 -1
- package/dist/storybook/assets/unit-table.stories-4706910f.js +0 -229
package/dist/index.d.ts
CHANGED
|
@@ -158,6 +158,8 @@ export declare interface IActionProps {
|
|
|
158
158
|
closeLayer?: TEmpty;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
declare type IActionsType = (IAction | ISubAction | IChildComponent)[];
|
|
162
|
+
|
|
161
163
|
export declare interface IBadgeProps {
|
|
162
164
|
children?: ReactNode;
|
|
163
165
|
color?: string;
|
|
@@ -231,6 +233,20 @@ export declare interface ICardProps {
|
|
|
231
233
|
children?: ReactNode;
|
|
232
234
|
}
|
|
233
235
|
|
|
236
|
+
declare interface ICell {
|
|
237
|
+
value: number | string;
|
|
238
|
+
type: string;
|
|
239
|
+
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
240
|
+
placeholder?: string;
|
|
241
|
+
testId?: string;
|
|
242
|
+
disabled?: boolean;
|
|
243
|
+
style?: object;
|
|
244
|
+
options?: {
|
|
245
|
+
label: string;
|
|
246
|
+
value: string | number;
|
|
247
|
+
}[];
|
|
248
|
+
}
|
|
249
|
+
|
|
234
250
|
declare interface ICheckBoxCell extends TCommonCell {
|
|
235
251
|
label?: string | null;
|
|
236
252
|
checked: boolean;
|
|
@@ -257,6 +273,11 @@ export declare interface ICheckBoxProps {
|
|
|
257
273
|
onClickHelp?: TEmpty;
|
|
258
274
|
}
|
|
259
275
|
|
|
276
|
+
declare interface IChildComponent {
|
|
277
|
+
childComponent: ReactNode | (() => ReactNode);
|
|
278
|
+
testId?: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
260
281
|
/**
|
|
261
282
|
* Icon wrapper component to support different icon formats:
|
|
262
283
|
* - string names (default recommendation)
|
|
@@ -1271,6 +1292,25 @@ declare interface ISubAction_2 {
|
|
|
1271
1292
|
onClick: TEmpty;
|
|
1272
1293
|
}
|
|
1273
1294
|
|
|
1295
|
+
declare interface ITableActions {
|
|
1296
|
+
addRow?: () => void;
|
|
1297
|
+
reorderComponents?: () => void;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
declare interface ITableDefinition {
|
|
1301
|
+
key: string;
|
|
1302
|
+
header: string;
|
|
1303
|
+
translationKey: string;
|
|
1304
|
+
type: string;
|
|
1305
|
+
convertible: boolean;
|
|
1306
|
+
unitKey: string;
|
|
1307
|
+
columnAlignment: string;
|
|
1308
|
+
columnWidth: string;
|
|
1309
|
+
defaultValue?: number | string | null;
|
|
1310
|
+
options?: Array<any>;
|
|
1311
|
+
placeholder?: string;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1274
1314
|
export declare interface ITableProps {
|
|
1275
1315
|
onListReorder?: (obj: {
|
|
1276
1316
|
from: number;
|
|
@@ -1521,6 +1561,18 @@ export declare interface IUnitInputProps {
|
|
|
1521
1561
|
unitTemplate?: Record<string, any>;
|
|
1522
1562
|
}
|
|
1523
1563
|
|
|
1564
|
+
declare interface IUnitTableProps {
|
|
1565
|
+
data: Array<any>;
|
|
1566
|
+
unitTemplate: Record<string, any>;
|
|
1567
|
+
tableDef: ITableDefinition[];
|
|
1568
|
+
convertToCells: (displayedData: Array<any>, displayedUnits: Record<string, any>) => {
|
|
1569
|
+
cells: ICell[];
|
|
1570
|
+
actions: IActionsType;
|
|
1571
|
+
}[];
|
|
1572
|
+
tableActions: ITableActions;
|
|
1573
|
+
testId: string;
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1524
1576
|
export declare const Label: ({ label, width, helpText, helpTextMaxWidth, onClickHelp, lock, info, libraryIcon, labelLeft, }: ILabelProps) => JSX_2.Element;
|
|
1525
1577
|
|
|
1526
1578
|
export declare const List: ({ list, bordered, expanding, narrow, toggleNarrow, onToggleNarrow, invokeEditOnRowClick, noHeader, stickyHeader, draggable, onListReorder, marginBottom, height, testId, scrollDetails, }: IListProps) => JSX_2.Element;
|
|
@@ -1735,6 +1787,8 @@ export declare type TTriggerType = 'Text' | 'Button' | 'DropDownButton' | 'Compo
|
|
|
1735
1787
|
|
|
1736
1788
|
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;
|
|
1737
1789
|
|
|
1790
|
+
export declare const UnitTable: ({ data, unitTemplate, tableDef, convertToCells, tableActions, testId, }: IUnitTableProps) => JSX_2.Element;
|
|
1791
|
+
|
|
1738
1792
|
export declare const useFocus: () => UseFocusReturnType;
|
|
1739
1793
|
|
|
1740
1794
|
declare type UseFocusReturnType = [MutableRefObject<HTMLInputElement | null>, TEmpty];
|
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 } 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";
|
|
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, convertAndGetValue, isNumeric, getAltUnitsListByQuantity } from "@oliasoft-open-source/units";
|
|
15
15
|
import { isValueWithUnit as isValueWithUnit$1 } from "@oliasoft-open-source/units/dist/units";
|
|
16
16
|
const global$2 = "";
|
|
17
17
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
@@ -70545,6 +70545,155 @@ const UnitInput = ({
|
|
|
70545
70545
|
}
|
|
70546
70546
|
);
|
|
70547
70547
|
};
|
|
70548
|
+
const getUnitCells = ({
|
|
70549
|
+
tableDef,
|
|
70550
|
+
displayedUnits,
|
|
70551
|
+
handleUnitChange
|
|
70552
|
+
}) => {
|
|
70553
|
+
return tableDef.map(({ convertible, unitKey, key: key2 }) => {
|
|
70554
|
+
var _a;
|
|
70555
|
+
if (!convertible) {
|
|
70556
|
+
return { value: "" };
|
|
70557
|
+
}
|
|
70558
|
+
const oldUnit = displayedUnits[key2];
|
|
70559
|
+
const options = (_a = getAltUnitsListByQuantity(unitKey)) == null ? void 0 : _a.map(
|
|
70560
|
+
({ unit: unit2, label: label2 }) => ({
|
|
70561
|
+
label: label2,
|
|
70562
|
+
value: unit2
|
|
70563
|
+
})
|
|
70564
|
+
);
|
|
70565
|
+
const onChange = ({
|
|
70566
|
+
target: { value: newUnit }
|
|
70567
|
+
}) => {
|
|
70568
|
+
if (newUnit === oldUnit) {
|
|
70569
|
+
return;
|
|
70570
|
+
}
|
|
70571
|
+
handleUnitChange(key2, newUnit);
|
|
70572
|
+
};
|
|
70573
|
+
return {
|
|
70574
|
+
value: oldUnit,
|
|
70575
|
+
options,
|
|
70576
|
+
type: "Select",
|
|
70577
|
+
onChange
|
|
70578
|
+
};
|
|
70579
|
+
});
|
|
70580
|
+
};
|
|
70581
|
+
const getHeaders = ({ tableDef }) => tableDef.map(({ header: header2 }) => ({
|
|
70582
|
+
value: header2
|
|
70583
|
+
}));
|
|
70584
|
+
const onConvertData = (data, displayedUnits, tableDef) => {
|
|
70585
|
+
if (!(data == null ? void 0 : data.length))
|
|
70586
|
+
return [];
|
|
70587
|
+
return data.map((row2) => {
|
|
70588
|
+
const convertedRow = tableDef.reduce((prev2, colDef) => {
|
|
70589
|
+
const { key: key2, defaultValue } = colDef;
|
|
70590
|
+
const unitTo = displayedUnits[key2];
|
|
70591
|
+
let value = row2[key2];
|
|
70592
|
+
let displayedValue = value ?? defaultValue;
|
|
70593
|
+
if (isValueWithUnit(value) && unitTo) {
|
|
70594
|
+
displayedValue = convertAndGetValue(displayedValue, unitTo) || 0;
|
|
70595
|
+
}
|
|
70596
|
+
return {
|
|
70597
|
+
...prev2,
|
|
70598
|
+
[key2]: isNumeric(displayedValue) ? withUnit(displayedValue, unitTo) : displayedValue
|
|
70599
|
+
};
|
|
70600
|
+
}, {});
|
|
70601
|
+
return convertedRow;
|
|
70602
|
+
});
|
|
70603
|
+
};
|
|
70604
|
+
const addRowHeader = (addRow, data, displayedUnits) => ({
|
|
70605
|
+
label: "Add",
|
|
70606
|
+
icon: "plus",
|
|
70607
|
+
primary: true,
|
|
70608
|
+
onClick: () => addRow(data, displayedUnits),
|
|
70609
|
+
testId: "lithology-table-add-new-row"
|
|
70610
|
+
});
|
|
70611
|
+
const getDisplayedUnits = (tableDef, unitTemplate) => {
|
|
70612
|
+
return tableDef.reduce((prev2, curr) => {
|
|
70613
|
+
const { key: key2, unitKey } = curr;
|
|
70614
|
+
return {
|
|
70615
|
+
...prev2,
|
|
70616
|
+
[key2]: unitTemplate[unitKey]
|
|
70617
|
+
};
|
|
70618
|
+
}, {});
|
|
70619
|
+
};
|
|
70620
|
+
const buildTable = ({
|
|
70621
|
+
rows,
|
|
70622
|
+
tableDef,
|
|
70623
|
+
displayedUnits,
|
|
70624
|
+
handleUnitChange,
|
|
70625
|
+
tableActions
|
|
70626
|
+
}) => {
|
|
70627
|
+
if (!rows) {
|
|
70628
|
+
return {
|
|
70629
|
+
rows: [],
|
|
70630
|
+
headers: []
|
|
70631
|
+
};
|
|
70632
|
+
}
|
|
70633
|
+
const { addRow } = tableActions;
|
|
70634
|
+
const headers = [
|
|
70635
|
+
{
|
|
70636
|
+
cells: getHeaders({ tableDef }),
|
|
70637
|
+
actions: addRow ? [addRowHeader(addRow, rows, displayedUnits)] : []
|
|
70638
|
+
},
|
|
70639
|
+
{
|
|
70640
|
+
cells: getUnitCells({
|
|
70641
|
+
tableDef,
|
|
70642
|
+
displayedUnits,
|
|
70643
|
+
handleUnitChange
|
|
70644
|
+
})
|
|
70645
|
+
}
|
|
70646
|
+
];
|
|
70647
|
+
return {
|
|
70648
|
+
headers,
|
|
70649
|
+
rows
|
|
70650
|
+
};
|
|
70651
|
+
};
|
|
70652
|
+
const UnitTable = ({
|
|
70653
|
+
data,
|
|
70654
|
+
unitTemplate,
|
|
70655
|
+
tableDef,
|
|
70656
|
+
convertToCells,
|
|
70657
|
+
tableActions,
|
|
70658
|
+
testId
|
|
70659
|
+
}) => {
|
|
70660
|
+
const [displayedUnits, setDisplayedUnits] = useState(
|
|
70661
|
+
getDisplayedUnits(tableDef, unitTemplate)
|
|
70662
|
+
);
|
|
70663
|
+
useEffect(() => {
|
|
70664
|
+
setDisplayedUnits(getDisplayedUnits(tableDef, unitTemplate));
|
|
70665
|
+
}, [unitTemplate]);
|
|
70666
|
+
const handleUnitChange = (key2, unit2) => {
|
|
70667
|
+
setDisplayedUnits((prev2) => ({ ...prev2, [key2]: unit2 }));
|
|
70668
|
+
};
|
|
70669
|
+
const { headers, rows } = useMemo$1(
|
|
70670
|
+
() => buildTable({
|
|
70671
|
+
rows: convertToCells(
|
|
70672
|
+
onConvertData(data, displayedUnits, tableDef),
|
|
70673
|
+
displayedUnits
|
|
70674
|
+
),
|
|
70675
|
+
tableDef,
|
|
70676
|
+
displayedUnits,
|
|
70677
|
+
handleUnitChange,
|
|
70678
|
+
tableActions
|
|
70679
|
+
}),
|
|
70680
|
+
[data, displayedUnits]
|
|
70681
|
+
);
|
|
70682
|
+
return /* @__PURE__ */ jsx(
|
|
70683
|
+
Table,
|
|
70684
|
+
{
|
|
70685
|
+
table: {
|
|
70686
|
+
testId,
|
|
70687
|
+
headers,
|
|
70688
|
+
rows,
|
|
70689
|
+
columnAlignment: tableDef.map((def) => def.columnAlignment),
|
|
70690
|
+
columnWidths: tableDef.map((def) => def.columnWidth),
|
|
70691
|
+
fixedWidth: "auto"
|
|
70692
|
+
},
|
|
70693
|
+
onListReorder: (tableActions == null ? void 0 : tableActions.reorderComponents) || void 0
|
|
70694
|
+
}
|
|
70695
|
+
);
|
|
70696
|
+
};
|
|
70548
70697
|
export {
|
|
70549
70698
|
Accordion,
|
|
70550
70699
|
AccordionWithDefaultToggle,
|
|
@@ -70624,6 +70773,7 @@ export {
|
|
|
70624
70773
|
Tree,
|
|
70625
70774
|
TriggerType,
|
|
70626
70775
|
UnitInput,
|
|
70776
|
+
UnitTable,
|
|
70627
70777
|
dismissToast,
|
|
70628
70778
|
readFile,
|
|
70629
70779
|
toast,
|