@oliasoft-open-source/react-ui-library 4.2.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.
Files changed (178) hide show
  1. package/dist/index.d.ts +54 -0
  2. package/dist/index.js +151 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/Color-6VNJS4EI-e16af034.js +1 -0
  5. package/dist/storybook/assets/DocsRenderer-NNNQARDV-eaf66766.js +1 -0
  6. package/dist/storybook/assets/WithTooltip-4HIR6TLV-86dbd99d.js +1 -0
  7. package/dist/storybook/assets/{accordion-168fa7c5.js → accordion-1b587708.js} +1 -1
  8. package/dist/storybook/assets/accordion-with-default-toggle-775c8135.js +1 -0
  9. package/dist/storybook/assets/accordion.stories-a9cecbe0.js +170 -0
  10. package/dist/storybook/assets/{actions-2d4e1c8e.js → actions-83a2a04e.js} +1 -1
  11. package/dist/storybook/assets/{actions.stories-81a7cb7a.js → actions.stories-a38cd26e.js} +1 -1
  12. package/dist/storybook/assets/{afe.stories-afb9be07.js → afe.stories-e25ea064.js} +2 -2
  13. package/dist/storybook/assets/{badge.stories-5ce7957f.js → badge.stories-1cbf35f9.js} +1 -1
  14. package/dist/storybook/assets/{blowout.stories-ee7f932b.js → blowout.stories-af7f9432.js} +1 -1
  15. package/dist/storybook/assets/breadcrumb-f8742fbd.js +1 -0
  16. package/dist/storybook/assets/breadcrumb.stories-b5582cfb.js +1 -0
  17. package/dist/storybook/assets/{button-74c97e4a.js → button-050c998a.js} +1 -1
  18. package/dist/storybook/assets/{button-group-fa895d0c.js → button-group-0176fca3.js} +1 -1
  19. package/dist/storybook/assets/{button-group.stories-22f072b7.js → button-group.stories-7659a587.js} +1 -1
  20. package/dist/storybook/assets/{button.stories-9b954335.js → button.stories-5f73ddef.js} +1 -1
  21. package/dist/storybook/assets/buttons-and-links-153efc05.js +14 -0
  22. package/dist/storybook/assets/{card.stories-537a1772.js → card.stories-0437a4e2.js} +1 -1
  23. package/dist/storybook/assets/casing-loads.stories-90bc0b91.js +209 -0
  24. package/dist/storybook/assets/{cell.stories-524a7418.js → cell.stories-0ae4bf08.js} +2 -2
  25. package/dist/storybook/assets/{check-box-e21258d5.js → check-box-b38490e5.js} +1 -1
  26. package/dist/storybook/assets/{check-box.stories-5f7d06e0.js → check-box.stories-9bf1c260.js} +1 -1
  27. package/dist/storybook/assets/{chunk-HLWAVYOI-6a96cff0.js → chunk-HLWAVYOI-64001074.js} +1 -1
  28. package/dist/storybook/assets/color-e82f5009.js +25 -0
  29. package/dist/storybook/assets/{column.stories-ae7588c5.js → column.stories-d5ca2c42.js} +1 -1
  30. package/dist/storybook/assets/{drawer-7f450988.js → drawer-308b0a03.js} +1 -1
  31. package/dist/storybook/assets/{drawer.stories-39625e91.js → drawer.stories-724ec941.js} +2 -2
  32. package/dist/storybook/assets/empty-2d83d50b.js +1 -0
  33. package/dist/storybook/assets/empty.stories-1871df42.js +1 -0
  34. package/dist/storybook/assets/extends-98964cd2.js +1 -0
  35. package/dist/storybook/assets/{field-a094cd72.js → field-248df38c.js} +1 -1
  36. package/dist/storybook/assets/{field.stories-f1318053.js → field.stories-60d1a82f.js} +1 -1
  37. package/dist/storybook/assets/file-input-31a9b5bf.js +1 -0
  38. package/dist/storybook/assets/file-input.stories-dbedc9fc.js +55 -0
  39. package/dist/storybook/assets/{flex.stories-09e9c602.js → flex.stories-6a278b40.js} +1 -1
  40. package/dist/storybook/assets/footer.stories-50a2e3db.js +3 -0
  41. package/dist/storybook/assets/form.stories-2184d699.js +49 -0
  42. package/dist/storybook/assets/formation.stories-e27935eb.js +74 -0
  43. package/dist/storybook/assets/{formatter-SWP5E3XI-06c7911e.js → formatter-SWP5E3XI-598bdf16.js} +2 -2
  44. package/dist/storybook/assets/{preview-d47a2f40.css → global-aa71ac9c.css} +1 -1
  45. package/dist/storybook/assets/{heading-d29eb744.js → heading-39e599c8.js} +1 -1
  46. package/dist/storybook/assets/{heading.stories-9689bddc.js → heading.stories-6ff7f5ed.js} +1 -1
  47. package/dist/storybook/assets/{help-icon-d4189b1b.js → help-icon-c0abd380.js} +1 -1
  48. package/dist/storybook/assets/{help-icon.stories-15d1620d.js → help-icon.stories-a30b7058.js} +1 -1
  49. package/dist/storybook/assets/icon-8acf9925.js +8 -0
  50. package/dist/storybook/assets/{icon.stories-8dae69e1.js → icon.stories-466d158f.js} +1 -1
  51. package/dist/storybook/assets/iframe-2ec6fd1b.js +1 -0
  52. package/dist/storybook/assets/{index-97b8789c.js → index-85e6b336.js} +4 -4
  53. package/dist/storybook/assets/{index.es-85cc7dfc.js → index.es-37e2ce0d.js} +4 -4
  54. package/dist/storybook/assets/inheritsLoose-c82a83d4.js +1 -0
  55. package/dist/storybook/assets/{input-d68625a5.js → input-05f21b51.js} +1 -1
  56. package/dist/storybook/assets/{input-group.stories-a2a3400e.js → input-group.stories-602e1e93.js} +2 -2
  57. package/dist/storybook/assets/{input-validation-64e7abcc.js → input-validation-83a841e7.js} +2 -2
  58. package/dist/storybook/assets/{input.stories-164d93ab.js → input.stories-bf58ba7c.js} +1 -1
  59. package/dist/storybook/assets/{inputs-e48e1acb.js → inputs-679d81e4.js} +14 -14
  60. package/dist/storybook/assets/{label-13d490a3.js → label-e6d15b59.js} +1 -1
  61. package/dist/storybook/assets/{label.stories-427ba162.js → label.stories-1c98204a.js} +1 -1
  62. package/dist/storybook/assets/layout-forms-9382a8d3.js +16 -0
  63. package/dist/storybook/assets/{layout-general-545e69b0.js → layout-general-cab7e55d.js} +2 -2
  64. package/dist/storybook/assets/{list-0dc3df85.js → list-d40713ca.js} +1 -1
  65. package/dist/storybook/assets/{list.stories-5715452e.js → list.stories-5daa007f.js} +2 -2
  66. package/dist/storybook/assets/{list.stories-data-94f7c623.js → list.stories-data-ba40864f.js} +1 -1
  67. package/dist/storybook/assets/{loader.stories-6107832a.js → loader.stories-4e8e8df7.js} +1 -1
  68. package/dist/storybook/assets/{menu.stories-927adf3d.js → menu.stories-8d724757.js} +1 -1
  69. package/dist/storybook/assets/{message-7e627e60.js → message-f4352d69.js} +1 -1
  70. package/dist/storybook/assets/{message.stories-f41a0c22.js → message.stories-bb7952c5.js} +1 -1
  71. package/dist/storybook/assets/meta-content-c2771b33.js +1 -0
  72. package/dist/storybook/assets/modal-90ebced9.js +1 -0
  73. package/dist/storybook/assets/modal-f1e8e468.css +1 -0
  74. package/dist/storybook/assets/{modal.stories-0e068cc1.js → modal.stories-24646454.js} +2 -2
  75. package/dist/storybook/assets/{number-input-7d49b0b3.js → number-input-cfbd9eb7.js} +1 -1
  76. package/dist/storybook/assets/{number-input.stories-02528124.js → number-input.stories-8137782e.js} +2 -2
  77. package/dist/storybook/assets/option-dropdown-14e7d023.js +1 -0
  78. package/dist/storybook/assets/option-dropdown.stories-f251610f.js +21 -0
  79. package/dist/storybook/assets/{padding-and-spacing-7aefd342.js → padding-and-spacing-89974d3f.js} +2 -2
  80. package/dist/storybook/assets/page.stories-7a6f330e.js +57 -0
  81. package/dist/storybook/assets/{pagination-8aade846.js → pagination-443065a8.js} +1 -1
  82. package/dist/storybook/assets/{pagination.stories-423b4938.js → pagination.stories-985230f7.js} +2 -2
  83. package/dist/storybook/assets/pop-confirm-ce206de8.js +1 -0
  84. package/dist/storybook/assets/pop-confirm.stories-5772f622.js +7 -0
  85. package/dist/storybook/assets/{popover-06e375a5.js → popover-c1234faa.js} +1 -1
  86. package/dist/storybook/assets/popover.stories-7542a367.js +1 -0
  87. package/dist/storybook/assets/preview-65e4021c.js +1 -0
  88. package/dist/storybook/assets/preview-a5b25924.css +1 -0
  89. package/dist/storybook/assets/{preview-88cc5d68.js → preview-a99e63ce.js} +3 -3
  90. package/dist/storybook/assets/print-header-bd013690.js +1 -0
  91. package/dist/storybook/assets/projects.stories-f8294ed5.js +47 -0
  92. package/dist/storybook/assets/{radio-button-135a9615.js → radio-button-d69b72e4.js} +1 -1
  93. package/dist/storybook/assets/{radio-button.stories-0e8377ea.js → radio-button.stories-6ff0dc9b.js} +1 -1
  94. package/dist/storybook/assets/{reservoirs.stories-6b14a37f.js → reservoirs.stories-80ad2f26.js} +2 -2
  95. package/dist/storybook/assets/{rich-text-input.stories-661f34f1.js → rich-text-input-a0f4a598.js} +52 -127
  96. package/dist/storybook/assets/rich-text-input.stories-988bbe20.js +76 -0
  97. package/dist/storybook/assets/{row.stories-d5b6b4a6.js → row.stories-c12a3e52.js} +2 -2
  98. package/dist/storybook/assets/select-d4593fc0.js +1 -0
  99. package/dist/storybook/assets/{select.stories-60f055e6.js → select.stories-6651d3f2.js} +2 -2
  100. package/dist/storybook/assets/{side-bar-88e8cf41.js → side-bar-10cceacd.js} +1 -1
  101. package/dist/storybook/assets/{side-bar.stories-2c06f8a6.js → side-bar.stories-02211e0d.js} +1 -1
  102. package/dist/storybook/assets/{site.stories-dee8ce1c.js → site.stories-284e27be.js} +2 -2
  103. package/dist/storybook/assets/slider-5d5442fe.js +7 -0
  104. package/dist/storybook/assets/{slider.stories-79ab0e97.js → slider.stories-a55df653.js} +2 -2
  105. package/dist/storybook/assets/{spacer.stories-38071af8.js → spacer.stories-a2798d47.js} +1 -1
  106. package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-007a6982.js +1 -0
  107. package/dist/storybook/assets/{table-da6f6045.js → table-134da40b.js} +1 -1
  108. package/dist/storybook/assets/{table.stories-67a3023a.js → table.stories-8dd2a568.js} +2 -2
  109. package/dist/storybook/assets/{table.stories-data-8a836b92.js → table.stories-data-ddbcf8c3.js} +1 -1
  110. package/dist/storybook/assets/text-link-f4589768.js +1 -0
  111. package/dist/storybook/assets/text-link.stories-6b7c8329.js +1 -0
  112. package/dist/storybook/assets/{textarea-d48efea2.js → textarea-820c62b6.js} +1 -1
  113. package/dist/storybook/assets/{textarea.stories-89c8afd7.js → textarea.stories-aeaa9aa0.js} +1 -1
  114. package/dist/storybook/assets/{title.stories-5b4a226c.js → title.stories-2ba6aa87.js} +2 -2
  115. package/dist/storybook/assets/{toaster-541ce85b.js → toaster-55ac121d.js} +1 -1
  116. package/dist/storybook/assets/{toaster.stories-5e4d95b1.js → toaster.stories-28d11f39.js} +1 -1
  117. package/dist/storybook/assets/{toggle-bb34b2a2.js → toggle-6f4d5797.js} +1 -1
  118. package/dist/storybook/assets/{toggle.stories-b771ed81.js → toggle.stories-a289f544.js} +1 -1
  119. package/dist/storybook/assets/{tooltip-23e84186.js → tooltip-856042a7.js} +1 -1
  120. package/dist/storybook/assets/{tooltip.stories-e8ba5fff.js → tooltip.stories-666868d0.js} +1 -1
  121. package/dist/storybook/assets/{tooltip.test-case.stories-9817078b.js → tooltip.test-case.stories-4c1ea273.js} +1 -1
  122. package/dist/storybook/assets/{top-bar-a84b9365.js → top-bar-38689fe2.js} +1 -1
  123. package/dist/storybook/assets/{top-bar.stories-e93330f0.js → top-bar.stories-3d9a6da1.js} +1 -1
  124. package/dist/storybook/assets/{top-bar.testcase.stories-3a824a14.js → top-bar.testcase.stories-dc051455.js} +1 -1
  125. package/dist/storybook/assets/tree-a2bbc2e4.js +6 -0
  126. package/dist/storybook/assets/tree.stories-0e132447.js +123 -0
  127. package/dist/storybook/assets/unit-input-c16535f7.js +1 -0
  128. package/dist/storybook/assets/unit-input.stories-0f7705d6.js +273 -0
  129. package/dist/storybook/assets/unit-table.stories-71ef347c.js +229 -0
  130. package/dist/storybook/iframe.html +1 -1
  131. package/dist/storybook/index.json +1 -1
  132. package/dist/storybook/project.json +1 -1
  133. package/dist/storybook/stories.json +1 -1
  134. package/package.json +1 -1
  135. package/dist/404.html +0 -1
  136. package/dist/storybook/assets/Color-6VNJS4EI-11a1508d.js +0 -1
  137. package/dist/storybook/assets/DocsRenderer-NNNQARDV-8f214a0a.js +0 -1
  138. package/dist/storybook/assets/WithTooltip-4HIR6TLV-bcdb019a.js +0 -1
  139. package/dist/storybook/assets/accordion.stories-0f8af16e.js +0 -170
  140. package/dist/storybook/assets/breadcrumb.stories-e4334a75.js +0 -1
  141. package/dist/storybook/assets/buttons-and-links-72daa9ae.js +0 -14
  142. package/dist/storybook/assets/casing-loads.stories-cfbab702.js +0 -209
  143. package/dist/storybook/assets/color-9bdf643a.js +0 -25
  144. package/dist/storybook/assets/dialog-8e840c50.css +0 -1
  145. package/dist/storybook/assets/dialog-cd58dd09.js +0 -1
  146. package/dist/storybook/assets/empty.stories-e0e3ac78.js +0 -1
  147. package/dist/storybook/assets/file-input.stories-1c6ce0ea.js +0 -55
  148. package/dist/storybook/assets/footer.stories-57f07ea2.js +0 -3
  149. package/dist/storybook/assets/form.stories-45c0cd59.js +0 -49
  150. package/dist/storybook/assets/formation.stories-5eeaa826.js +0 -74
  151. package/dist/storybook/assets/icon-e9cbb4d7.js +0 -8
  152. package/dist/storybook/assets/iframe-c1fab5c5.js +0 -1
  153. package/dist/storybook/assets/inheritsLoose-d4851ab8.js +0 -1
  154. package/dist/storybook/assets/layout-forms-289235b9.js +0 -16
  155. package/dist/storybook/assets/list-heading-88cc8a9b.js +0 -1
  156. package/dist/storybook/assets/option-dropdown.stories-5030bdb8.js +0 -21
  157. package/dist/storybook/assets/page.stories-7cb68fed.js +0 -57
  158. package/dist/storybook/assets/pop-confirm.stories-81b30901.js +0 -7
  159. package/dist/storybook/assets/popover.stories-f651a81c.js +0 -1
  160. package/dist/storybook/assets/preview-5405e1e8.js +0 -1
  161. package/dist/storybook/assets/projects.stories-3884a80c.js +0 -47
  162. package/dist/storybook/assets/select-205cd538.js +0 -1
  163. package/dist/storybook/assets/slider-160e2152.js +0 -7
  164. package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-5e884b35.js +0 -1
  165. package/dist/storybook/assets/text-link.stories-c1227c6f.js +0 -1
  166. package/dist/storybook/assets/tree.stories-590bdd69.js +0 -128
  167. package/dist/storybook/assets/unit-input.stories-50ac8b0f.js +0 -257
  168. /package/dist/storybook/assets/{accordion.stories-e92bccf3.css → accordion-with-default-toggle-e92bccf3.css} +0 -0
  169. /package/dist/storybook/assets/{breadcrumb.stories-a644544e.css → breadcrumb-a644544e.css} +0 -0
  170. /package/dist/storybook/assets/{empty.stories-9914c767.css → empty-9914c767.css} +0 -0
  171. /package/dist/storybook/assets/{file-input.stories-f40408e6.css → file-input-f40408e6.css} +0 -0
  172. /package/dist/storybook/assets/{list-heading-d7e578fa.css → meta-content-d7e578fa.css} +0 -0
  173. /package/dist/storybook/assets/{option-dropdown.stories-ddc96b15.css → option-dropdown-ddc96b15.css} +0 -0
  174. /package/dist/storybook/assets/{pop-confirm.stories-c9faec6b.css → pop-confirm-c9faec6b.css} +0 -0
  175. /package/dist/storybook/assets/{page.stories-dd8c1b35.css → print-header-dd8c1b35.css} +0 -0
  176. /package/dist/storybook/assets/{rich-text-input.stories-023a1c99.css → rich-text-input-023a1c99.css} +0 -0
  177. /package/dist/storybook/assets/{tree.stories-3406c5f6.css → tree-3406c5f6.css} +0 -0
  178. /package/dist/storybook/assets/{unit-input.stories-c251e2c8.css → unit-input-c251e2c8.css} +0 -0
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,