@oliasoft-open-source/react-ui-library 4.7.0-beta-1 → 4.7.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/README.md +12 -11
- package/dist/assets/{index-AkeNwthw.css → index-dOfLgtRX.css} +226 -183
- package/dist/assets/{index-neKlYvgy.js → index-ffnttoim.js} +285 -147
- package/dist/global.css +226 -183
- package/dist/index.d.ts +131 -22
- package/dist/index.html +1 -1
- package/dist/index.js +751 -391
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/Color-6VNJS4EI-9rJemzwR.js +1 -0
- package/dist/storybook/assets/DocsRenderer-NNNQARDV-DP7bJ7AB.js +1 -0
- package/dist/storybook/assets/WithTooltip-V3YHNWJZ-eL_Uxnix.js +1 -0
- package/dist/storybook/assets/{accordion-6_27SROY.js → accordion-MRdNs3mQ.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-Uipdifbl.js → accordion.stories-Ytyr6tn2.js} +2 -2
- package/dist/storybook/assets/actions-Z1pyUd57.js +1 -0
- package/dist/storybook/assets/actions-_FIB7bOt.css +1 -0
- package/dist/storybook/assets/actions.stories-JWaU0QAA.js +1 -0
- package/dist/storybook/assets/afe.stories-Ad1-l25x.js +88 -0
- package/dist/storybook/assets/badge.stories-2BykvoFl.js +1 -0
- package/dist/storybook/assets/blowout.stories--vPM-KpE.js +40 -0
- package/dist/storybook/assets/button-UQO14biP.js +1 -0
- package/dist/storybook/assets/{button-group-q8QKkLVU.js → button-group-g7HxxHTn.js} +1 -1
- package/dist/storybook/assets/{button-group.stories-tLZpLTfD.js → button-group.stories-hJ9V_va5.js} +2 -2
- package/dist/storybook/assets/button.stories-ihIU7iUf.js +80 -0
- package/dist/storybook/assets/{buttons-and-links-gkg6hOs-.js → buttons-and-links-fv_xHVqw.js} +2 -2
- package/dist/storybook/assets/card.stories-5YbTAbLy.js +1 -0
- package/dist/storybook/assets/casing-loads.stories-WfK3k-mh.js +209 -0
- package/dist/storybook/assets/cell.stories-Xy61z8ka.js +245 -0
- package/dist/storybook/assets/{check-box-LZdXXKhv.js → check-box-Q2GsbR79.js} +1 -1
- package/dist/storybook/assets/{check-box.stories-0XCykxnz.js → check-box.stories-iQby_Dan.js} +2 -2
- package/dist/storybook/assets/{chunk-HLWAVYOI-YF156CNQ.js → chunk-HLWAVYOI-RXldIcZr.js} +1 -1
- package/dist/storybook/assets/color-5ySMclFt.js +25 -0
- package/dist/storybook/assets/{column.stories-6OLsjlcP.js → column.stories-NnQNzY18.js} +7 -7
- package/dist/storybook/assets/dialog-hHTtMGls.js +1 -0
- package/dist/storybook/assets/{drawer-WuErQ5Z8.js → drawer-ChY55ghN.js} +1 -1
- package/dist/storybook/assets/{drawer.stories-RFRPs_pQ.js → drawer.stories-xv50_UKt.js} +4 -4
- package/dist/storybook/assets/empty.stories-dFjUCZln.js +1 -0
- package/dist/storybook/assets/entry-preview-TGgN7-T4.js +1 -0
- package/dist/storybook/assets/{config-b-_d5fwn.js → entry-preview-docs-KfUfHYQ7.js} +37 -37
- package/dist/storybook/assets/{field-eknsj_Ll.js → field-jD6TclDQ.js} +1 -1
- package/dist/storybook/assets/{field.stories-RmhJ16HT.js → field.stories-CeHr9rXs.js} +5 -5
- package/dist/storybook/assets/file-button.stories-XxMjOBfe.js +10 -0
- package/dist/storybook/assets/file-input-A0eGNEgX.js +1 -0
- package/dist/storybook/assets/file-input.stories-dM7UFPVo.js +66 -0
- package/dist/storybook/assets/{flex.stories-lLz0Xrt_.js → flex.stories-6qFQFEL7.js} +2 -2
- package/dist/storybook/assets/footer.stories-4cSc0hBz.js +3 -0
- package/dist/storybook/assets/form.stories--Sgi1gUF.js +49 -0
- package/dist/storybook/assets/formation.stories-VUtbgcsq.js +74 -0
- package/dist/storybook/assets/{formatter-SWP5E3XI-uJi-Y6Jy.js → formatter-SWP5E3XI-qYj9Quey.js} +2 -2
- package/dist/storybook/assets/{heading-Bk0bpNfe.js → heading-FcNTpGhR.js} +1 -1
- package/dist/storybook/assets/{heading.stories-HLMPkIPo.js → heading.stories-0MJHBHcQ.js} +2 -2
- package/dist/storybook/assets/{help-icon--rUDxLUD.js → help-icon-D6ZGAbgL.js} +1 -1
- package/dist/storybook/assets/help-icon.stories-YZw5pFQt.js +4 -0
- package/dist/storybook/assets/{icon-y1a2N5SZ.js → icon-_m67DAr0.js} +3 -3
- package/dist/storybook/assets/icon.stories-2aZia1VV.js +6 -0
- package/dist/storybook/assets/iframe-oMAlwWd9.js +7 -0
- package/dist/storybook/assets/index-PPLHz8o0.js +6 -0
- package/dist/storybook/assets/index-R5dkQuFe.js +3 -0
- package/dist/storybook/assets/{index-_waogfzH.js → index-RhTUHV_k.js} +20 -20
- package/dist/storybook/assets/index-VSx05S_2.js +14 -0
- package/dist/storybook/assets/index.es-HG2GUH9i.js +79 -0
- package/dist/storybook/assets/{input-u1He-wWs.js → input-fYKvBwPs.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-WljyIQ0a.js → input-group.stories-ZBffPltv.js} +5 -5
- package/dist/storybook/assets/{input-validation-XFS-LWhH.js → input-validation-bb_81fGi.js} +2 -2
- package/dist/storybook/assets/{input.stories-rLdDRxtU.js → input.stories-Y5X-JFWU.js} +1 -1
- package/dist/storybook/assets/{inputs-vo_nTpyh.js → inputs-MxyGbJ9Y.js} +14 -14
- package/dist/storybook/assets/{isPlainObject-4RuU_w9g.js → isPlainObject-OQlD0fAV.js} +1 -1
- package/dist/storybook/assets/{label-0_Qf6I8t.js → label-dla_bzHj.js} +1 -1
- package/dist/storybook/assets/label.stories-t-e2pWHW.js +11 -0
- package/dist/storybook/assets/layout-forms-_uf7qzAu.js +16 -0
- package/dist/storybook/assets/{layout-general-QgIJDQ4H.js → layout-general-rHEcWCrx.js} +2 -2
- package/dist/storybook/assets/list-Nr0UfaUw.js +8 -0
- package/dist/storybook/assets/list.stories-K1nFEsjX.js +478 -0
- package/dist/storybook/assets/{list.stories-data-IcFu6vvd.js → list.stories-data-WlepbhE1.js} +1 -1
- package/dist/storybook/assets/{loader.stories-0OwmnNML.js → loader.stories-eEBGjVSN.js} +5 -5
- package/dist/storybook/assets/menu.stories-nx6w59Nv.js +82 -0
- package/dist/storybook/assets/{message-uMHaTEXV.js → message-bbAE2zjv.js} +1 -1
- package/dist/storybook/assets/{message.stories-CDgUaLZP.js → message.stories-RJI8haIH.js} +2 -2
- package/dist/storybook/assets/meta-content-073TGkSN.js +1 -0
- package/dist/storybook/assets/meta-content-dR7AAq04.css +1 -0
- package/dist/storybook/assets/modal.stories-rjCFe4Mn.js +200 -0
- package/dist/storybook/assets/number-input-xqup0wHW.js +1 -0
- package/dist/storybook/assets/number-input.stories-Kzl7Diug.js +153 -0
- package/dist/storybook/assets/objectWithoutPropertiesLoose-9Q1jwsKS.js +1 -0
- package/dist/storybook/assets/option-dropdown.stories-M9-IYc-K.js +21 -0
- package/dist/storybook/assets/{padding-and-spacing-J_Zb8SJm.js → padding-and-spacing-dUA1CCP8.js} +2 -2
- package/dist/storybook/assets/page.stories-x7QRBnZm.js +57 -0
- package/dist/storybook/assets/{pagination-5n5spTRo.js → pagination-er5fRdi2.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-g4a-aSxq.js → pagination.stories-9_uskT8r.js} +2 -2
- package/dist/storybook/assets/pop-confirm.stories-QyBm5ZAb.js +9 -0
- package/dist/storybook/assets/popover-rJn7kxkX.js +1 -0
- package/dist/storybook/assets/popover.stories-5aZN8AoC.js +10 -0
- package/dist/storybook/assets/{portal.stories-UGkzdgVk.js → portal.stories-1Jnj3LXz.js} +1 -1
- package/dist/storybook/assets/{preview-WIFbPoA-.js → preview-3kPhKzar.js} +13 -13
- package/dist/storybook/assets/preview-64tDm6Er.js +7 -0
- package/dist/storybook/assets/preview-OnO0tzRj.js +17 -0
- package/dist/storybook/assets/projects.stories-wnXCxuJE.js +47 -0
- package/dist/storybook/assets/{radio-button-jHcwHUA4.js → radio-button-7TJh5k-h.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-LkCJsp5P.js → radio-button.stories-9mvBu2BH.js} +5 -5
- package/dist/storybook/assets/react-router-dom-4Z66xYqZ.js +8 -0
- package/dist/storybook/assets/{reservoirs.stories-hhPblhmv.js → reservoirs.stories-XGU7s6pI.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-7UzvJ-A1.js → rich-text-input.stories-3Xaavdx_.js} +3 -3
- package/dist/storybook/assets/row.stories-Ph7Ckyfn.js +130 -0
- package/dist/storybook/assets/{select-JjEPivho.js → select-KWgree43.js} +1 -1
- package/dist/storybook/assets/{select.stories-qFDyxRFm.js → select.stories-3D2KkC3_.js} +2 -2
- package/dist/storybook/assets/side-bar-kr46QLwI.js +1 -0
- package/dist/storybook/assets/side-bar.stories-bJoVvzG5.js +1 -0
- package/dist/storybook/assets/{site.stories-QHCzFOnt.js → site.stories-VpsCjYty.js} +2 -2
- package/dist/storybook/assets/slider-jx0z5OyT.js +7 -0
- package/dist/storybook/assets/slider.stories-CpY4L01U.js +171 -0
- package/dist/storybook/assets/smart-upload-modal.stories-hjd4L84J.js +25 -0
- package/dist/storybook/assets/spacer.stories-FpDFoVWE.js +1 -0
- package/dist/storybook/assets/syntaxhighlighter-B5GMVT5T-1rrvKZrw.js +1 -0
- package/dist/storybook/assets/table-4SISWUSt.js +1 -0
- package/dist/storybook/assets/table-smKT-hbF.css +1 -0
- package/dist/storybook/assets/table.stories-data-UqqhbXjA.js +1 -0
- package/dist/storybook/assets/{table.stories-tEvulp9K.js → table.stories-rKzdxDA4.js} +94 -18
- package/dist/storybook/assets/{tabs.stories-KtJc5Yci.js → tabs.stories-aps5NXFv.js} +2 -2
- package/dist/storybook/assets/text-link.stories-Plmiu8NV.js +14 -0
- package/dist/storybook/assets/{textarea-gxvxVBdC.js → textarea-JE26Eekm.js} +1 -1
- package/dist/storybook/assets/{textarea.stories-MZHVAwSx.js → textarea.stories-c1mkQU4s.js} +1 -1
- package/dist/storybook/assets/tiny-invariant-R4kOKlvx.js +8 -0
- package/dist/storybook/assets/title.stories-6AjYBLcL.js +37 -0
- package/dist/storybook/assets/{toaster-eOozfa7U.js → toaster-IL_npIpU.js} +1 -1
- package/dist/storybook/assets/toaster.stories-QL3_PKZL.js +86 -0
- package/dist/storybook/assets/{toggle-BPI2y-lU.js → toggle-vKuY4G3w.js} +1 -1
- package/dist/storybook/assets/{toggle.stories-aVmjpons.js → toggle.stories-fJ5QYzcQ.js} +2 -2
- package/dist/storybook/assets/{tooltip-HEHiU__l.js → tooltip-dueTLnwA.js} +2 -2
- package/dist/storybook/assets/{tooltip.stories-tiOgoWHH.js → tooltip.stories-a_gd0XYu.js} +1 -1
- package/dist/storybook/assets/tooltip.test-case.stories-0HiezXaS.js +5 -0
- package/dist/storybook/assets/top-bar-K-LdFikH.css +1 -0
- package/dist/storybook/assets/top-bar-pptAo2LU.js +1 -0
- package/dist/storybook/assets/top-bar.stories-H1OeyQS_.js +21 -0
- package/dist/storybook/assets/top-bar.testcase.stories-uJCoeG_m.js +30 -0
- package/dist/storybook/assets/tree-U4LtpVm9.css +1 -0
- package/dist/storybook/assets/tree.stories-a-UG4OFf.js +182 -0
- package/dist/storybook/assets/unit-input-OT-AqIIa.css +1 -0
- package/dist/storybook/assets/unit-input.stories--qvPjZnZ.js +349 -0
- package/dist/storybook/assets/unit-table.stories-4HlhxSjf.js +150 -0
- package/dist/storybook/iframe.html +3 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/sb-addons/actions-0/manager-bundle.js +1 -1
- package/dist/storybook/sb-preview/globals.js +1 -1
- package/dist/storybook/sb-preview/runtime.js +19 -19
- package/dist/storybook/stories.json +1 -1
- package/package.json +10 -9
- package/dist/storybook/assets/Color-6VNJS4EI-NPUHt_3q.js +0 -1
- package/dist/storybook/assets/DocsRenderer-NNNQARDV-HIEKjKKN.js +0 -1
- package/dist/storybook/assets/WithTooltip-4HIR6TLV-XVy3Qn7b.js +0 -1
- package/dist/storybook/assets/actions-W12osUP0.css +0 -1
- package/dist/storybook/assets/actions-Z9jDWreP.js +0 -1
- package/dist/storybook/assets/actions.stories-Qrio9EMy.js +0 -1
- package/dist/storybook/assets/afe.stories-mangk6LB.js +0 -88
- package/dist/storybook/assets/badge.stories-C0MXS15j.js +0 -1
- package/dist/storybook/assets/blowout.stories-i7Ii3760.js +0 -40
- package/dist/storybook/assets/button-7V8oA22w.js +0 -1
- package/dist/storybook/assets/button.stories-PhWmZXOu.js +0 -71
- package/dist/storybook/assets/card.stories-HzHJW6ek.js +0 -1
- package/dist/storybook/assets/casing-loads.stories-4eIPrrhL.js +0 -209
- package/dist/storybook/assets/cell.stories-X4sboJCw.js +0 -212
- package/dist/storybook/assets/color-PIYd2VAw.js +0 -25
- package/dist/storybook/assets/dialog-WKHRZcjc.js +0 -1
- package/dist/storybook/assets/empty.stories-lva3DbfI.js +0 -1
- package/dist/storybook/assets/file-input.stories-SF8BeFpu.js +0 -66
- package/dist/storybook/assets/footer.stories-L0qQuABW.js +0 -3
- package/dist/storybook/assets/form.stories-qQsjBbOk.js +0 -49
- package/dist/storybook/assets/formation.stories-E8DV_cIY.js +0 -74
- package/dist/storybook/assets/help-icon.stories-vifwJgNA.js +0 -4
- package/dist/storybook/assets/icon.stories-W-UgTWyK.js +0 -6
- package/dist/storybook/assets/iframe-NU_z28D3.js +0 -7
- package/dist/storybook/assets/index-IQMsp8Ab.js +0 -14
- package/dist/storybook/assets/index-gM75B7fB.js +0 -8
- package/dist/storybook/assets/index.es-JXn3JM7k.js +0 -86
- package/dist/storybook/assets/label.stories-aXdU5_Ql.js +0 -11
- package/dist/storybook/assets/layout-forms-w8JJQQqh.js +0 -16
- package/dist/storybook/assets/list-8l-RGDgw.js +0 -8
- package/dist/storybook/assets/list-heading-Vd3hu5Pf.js +0 -1
- package/dist/storybook/assets/list-heading-Y8BAUuV6.css +0 -1
- package/dist/storybook/assets/list.stories-Vp0Dm7UU.js +0 -457
- package/dist/storybook/assets/menu.stories-VwRF_Pbx.js +0 -60
- package/dist/storybook/assets/modal.stories-15sY1c5H.js +0 -173
- package/dist/storybook/assets/number-input-SvjJIGsW.js +0 -1
- package/dist/storybook/assets/number-input.stories-BURENIFo.js +0 -81
- package/dist/storybook/assets/option-dropdown.stories-Q2zd2AcS.js +0 -21
- package/dist/storybook/assets/page.stories-pa-9WU0e.js +0 -57
- package/dist/storybook/assets/pop-confirm.stories-_agvSFJd.js +0 -9
- package/dist/storybook/assets/popover-Y3FpGdUS.js +0 -1
- package/dist/storybook/assets/popover.stories-b7Tt4S0j.js +0 -1
- package/dist/storybook/assets/preview-D7BEK6_6.js +0 -7
- package/dist/storybook/assets/preview-Fi7DQdoQ.js +0 -1
- package/dist/storybook/assets/projects.stories-YPlCLdRE.js +0 -47
- package/dist/storybook/assets/row.stories-juQv80h3.js +0 -122
- package/dist/storybook/assets/side-bar-Fjr2t9MT.js +0 -1
- package/dist/storybook/assets/side-bar.stories-sxBJCVnV.js +0 -1
- package/dist/storybook/assets/slider-nl2rJ9LF.js +0 -7
- package/dist/storybook/assets/slider.stories--aZa8kf-.js +0 -127
- package/dist/storybook/assets/spacer.stories-eCrKj4b3.js +0 -1
- package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI--OA96ou_.js +0 -1
- package/dist/storybook/assets/table-PWodWi0p.css +0 -1
- package/dist/storybook/assets/table-i8WT9qpj.js +0 -1
- package/dist/storybook/assets/table.stories-data-4h6h0P0V.js +0 -1
- package/dist/storybook/assets/text-link.stories-kjfUeFtk.js +0 -1
- package/dist/storybook/assets/title.stories-cmteB9lx.js +0 -37
- package/dist/storybook/assets/toaster.stories-S25S4g_F.js +0 -86
- package/dist/storybook/assets/tooltip.test-case.stories-kIeZayHw.js +0 -3
- package/dist/storybook/assets/top-bar-9iOkm7Gq.js +0 -1
- package/dist/storybook/assets/top-bar-cBtxm6yr.css +0 -1
- package/dist/storybook/assets/top-bar.stories-5jcHi3Q_.js +0 -1
- package/dist/storybook/assets/top-bar.testcase.stories-7acJvLc_.js +0 -30
- package/dist/storybook/assets/tree-zmq4MRb6.css +0 -1
- package/dist/storybook/assets/tree.stories-_5t-Rrls.js +0 -128
- package/dist/storybook/assets/unit-input-qBUtqoTb.css +0 -1
- package/dist/storybook/assets/unit-input.stories-j3Ykteob.js +0 -273
- package/dist/storybook/assets/unit-table.stories-4XYwgJwY.js +0 -100
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._predefinedMenuActive_ye9w9_1 input{background:var(--color-background-disabled)!important}._inputWrapper_ye9w9_4{flex:1}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-FsUICBgo.js";import{r as u}from"./index-RfLt4OUa.js";import{d as r}from"./index-VSx05S_2.js";import{c as ft}from"./index-VW3EWkuE.js";import{u as bt}from"./use-previous-VKMmnaK7.js";import{M as Ae}from"./actions-Z1pyUd57.js";import{I as Ct}from"./input-group-addon-BHVsW9mL.js";import{B as c}from"./button-UQO14biP.js";import{T as Ut}from"./tooltip-dueTLnwA.js";import{I as yt}from"./input-group-R8LoqKRn.js";import{S as C}from"./spacer-Yji9g2AW.js";import{T as de}from"./text-6KQ6ntOV.js";import{M as De}from"./types-VB5zD18b.js";import{l as te}from"./lodash-Bmg8FrMx.js";import{N as xt,r as Vt}from"./number-input-xqup0wHW.js";import{D as jt}from"./divider-RwW2f_N0.js";import{R as Yn,C as be}from"./row-vFUhHoz5.js";import{F as x}from"./field-jD6TclDQ.js";import{M as ce}from"./message-bbAE2zjv.js";import{G as kt}from"./grid-u1mZpaML.js";import{C as R}from"./card-0r8RRVk-.js";import{H as F}from"./heading-FcNTpGhR.js";import{T as Pe}from"./toggle-vKuY4G3w.js";import{S as St}from"./select-KWgree43.js";import"./index-cCpkwrS5.js";import"./common-types-U65vzrrz.js";import"./disabled-context-urNQThQz.js";import"./icon-_m67DAr0.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-Y9jOMJLd.js";import"./tslib.es6-OIsz3r9a.js";import"./index-4QtD-hFu.js";import"./types-5uVBABF4.js";import"./badge-23Ty_zBt.js";import"./spinner-R8Il4aRe.js";import"./index-miLrID2P.js";import"./input-fYKvBwPs.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./label-dla_bzHj.js";import"./help-icon-D6ZGAbgL.js";import"./extends-dGVwEr9R.js";import"./assertThisInitialized-4q6YPdh3.js";import"./memoize-one.esm-hqe5SRxC.js";import"./select.input-zP5tW20f.js";const It=()=>{const n=u.useRef(null);return u.useLayoutEffect(()=>{n.current&&(n.current(),n.current=null)}),t=>{n.current=t}},wt=(n,a)=>{const t=a==null?void 0:a[n];return t||(console.log(`Warning: 'unitTemplate' does not define a preferred unit for '${n}'. Defaulting to standard unit.`),r.unitFromQuantity(n)??"")};var b=(n=>(n.CUSTOM="custom",n.PREDEFINED="predefined",n))(b||{});const Zn=n=>n==="undefined"||n===void 0||n===""||n==="null"||n===null||n==="NaN"||isNaN(n),Qn=(n="",a,t="",s=!1)=>{if(s)return n;if(a&&!Zn(n))try{const o=r.isValueWithUnit(n)?n:r.withUnit(n,t),m=r.convertSamePrecision(o,a);return r.getValue(m)}catch{}return n},Et=n=>n?!!r.getUnit(n):!1,B=(n="",a,t,s)=>{if(s)return n;const o=Et(n)||r.isValueWithUnit(n),m=r.getValue(n);return Zn(m)?m:o?Qn(m,a,t,s):n},Te=n=>te.isObject(n)&&!te.isArray(n)&&!te.isFunction(n)?te.get(n,"fieldName",""):typeof n=="string"?n:"",Re=(n="")=>{var a;return(a=r.KNOWN_UNITS)==null?void 0:a.includes(n)},Nt=(n,a)=>{const t=r.getUnit(n||"");return Re(a)&&Re(t)},At="_predefinedMenuActive_ye9w9_1",Dt="_inputWrapper_ye9w9_4",Fe={predefinedMenuActive:At,inputWrapper:Dt},p=({name:n,placeholder:a="",disabled:t=!1,disabledUnit:s=!1,error:o=!1,left:m=!1,small:l=!1,width:g="100%",value:h,unitkey:I="",initUnit:U,noConversion:pe=!1,onChange:me=()=>{},onClick:Tt=()=>{},onFocus:Xn=()=>{},onSwitchUnit:Ce=()=>{},unitTemplate:Ue,doNotConvertValue:D=!1,testId:w,warning:et=!1,predefinedOptions:V,initialPredefinedOption:nt=!1,shouldLinkAutomaticly:ye=!0,selectedPredefinedOptionKey:xe,validationCallback:Ve,disabledValidation:Rt=!1,allowEmpty:tt=!1,autoValue:E,convertBackToStorageUnit:at=!1,enableCosmeticRounding:je=!0,enableDisplayRounding:it=!1})=>{typeof h=="number"&&(h=`${h}`);const rt=It(),[ke="",k=""]=h!==void 0?r.split(h):[],Se=E?r.getUnit(E):"",Ie=u.useMemo(()=>wt(I,Ue),[I,Ue]),lt=Nt(h,Ie),y=U||Ie||k,st=bt(y),we=B(h,y,k,D),Ee=B(E,y,Se,D),ot=we!==""?{value:we,unit:y}:Ee!==""?{value:Ee,unit:y}:{value:ke,unit:k},[v,ge]=u.useState(ot),[S,he]=u.useState(nt?b.PREDEFINED:b.CUSTOM),ve=ke===""&&E,P=V&&V.find(i=>{if(xe)return xe===i.valueKey;const d=r.isValueWithUnit(i.value)?r.getUnit(i.value):"";return r.withUnit(Qn(h,d),d)===i.value}),ut=()=>{if(I)try{const i=ve?E:h??"";let d=r.altUnitsList(i,I);return r.getValue(i)===""?d.map(j=>["",j[1]]):d}catch{return null}},dt=i=>{const d=Te(n),j=i.target,{value:N,selectionStart:T}=j,ne=r.withUnit(N,(v==null?void 0:v.unit)||""),fe=at?r.withUnit(r.convertAndGetValue(ne,k),k):ne;me({target:{value:fe,name:d}});const[ht,vt]=r.split(ne);ge({value:ht,unit:vt}),rt(()=>{j.selectionStart=T,j.selectionEnd=T})},ct=(i,d)=>{d===v.unit||isNaN(Number(i))||(ge({value:i,unit:d}),Ce&&Ce(d))};u.useEffect(()=>{if(y){let i,d="";st!==y?(i=B(h,y,k,D),d=y):r.withUnit(v.value,v.unit)!==h&&(i=B(h,v.unit,k,D),d=v.unit),i!==void 0&&ge({value:i,unit:d}),V&&he(P&&ye?b.PREDEFINED:b.CUSTOM)}},[y,h,o,ye]);const Q=ut(),X=r.label(v.unit)||v.unit||"",pt=pe||!Q||Q&&Q.length===1,Ne=Te(n);let ee;const mt=i=>{const[d,j=""]=r.isValueWithUnit(i.value)?r.split(i.value):[i.value];return{type:De.OPTION,inline:!0,onClick:()=>{r.validateNumber(d).valid&&!t&&(he(b.PREDEFINED),me({target:{value:i.value,name:typeof n=="string"?n:(n==null?void 0:n.fieldName)||"",predefinedSelected:!0,predefinedOption:i}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(de,{children:i.label}),e.jsx(C,{width:"20px",height:"0"})]}),description:r.isValueWithUnit(i.value)?`${d} ${j}`:i.value,selected:P===i&&S===b.PREDEFINED}},gt=(i,d)=>{Ve&&Ve({name:i,error:d})};if(ee=[{type:De.OPTION,inline:!0,onClick:()=>{S!==b.CUSTOM&&!t&&me({target:{value:r.withUnit(v.value,v.unit),name:typeof n=="string"?n:(n==null?void 0:n.fieldName)||""}})},label:"Custom",selected:S===b.CUSTOM}],V!=null&&V.length){const i=V.map(mt);ee=[...ee,...i]}return e.jsx("div",{className:S===b.PREDEFINED?ft(Fe.predefinedMenuActive):"",children:e.jsxs(yt,{small:l,width:g,children:[V&&e.jsx(Ut,{text:S===b.PREDEFINED?P==null?void 0:P.label:"",children:e.jsx(Ae,{maxHeight:380,groupOrder:"first",testId:w&&`${w}-predefined-menu`,disabled:t,menu:{colored:!0,trigger:"Component",component:e.jsx(c,{groupOrder:"first",active:S===b.PREDEFINED,icon:S===b.PREDEFINED?"link":"unlink"}),small:l,sections:ee}})}),e.jsx("div",{className:Fe.inputWrapper,children:e.jsx(xt,{name:Ne,testId:w,disabled:t,placeholder:ve?B(E,v.unit,Se,D):a,value:v.value,onChange:dt,onFocus:Xn,error:o,warning:et,left:m,allowEmpty:tt,validationCallback:gt,enableCosmeticRounding:je,enableDisplayRounding:it,groupOrder:V?"middle":"first"},Ne)}),X&&(pt||!lt?e.jsx(Ct,{groupOrder:"last",children:X}):e.jsx(Ae,{maxHeight:380,groupOrder:"last",disabled:s,testId:w&&`${w}-menu`,menu:{label:X,trigger:"DropDownButton",small:l,sections:Q.map(([i,d,j])=>{const N=j||d||"",T=isNaN(Number(i))?"":i;return{type:"Option",label:je?Vt(T):T,inline:!0,onClick:fe=>{fe.stopPropagation(),ct(ve?"":i,d)},description:N,selected:N===X,testId:`${w}-unit-${N}`}})}}))]})})};try{p.displayName="UnitInput",p.__docgenInfo={description:"",displayName:"UnitInput",props:{name:{defaultValue:null,description:"",name:"name",required:!0,type:{name:"string | { fieldName?: string | undefined; }"}},placeholder:{defaultValue:{value:""},description:"",name:"placeholder",required:!1,type:{name:"string"}},disabled:{defaultValue:{value:"false"},description:"",name:"disabled",required:!1,type:{name:"boolean"}},disabledUnit:{defaultValue:{value:"false"},description:"",name:"disabledUnit",required:!1,type:{name:"boolean"}},error:{defaultValue:{value:"false"},description:"",name:"error",required:!1,type:{name:"string | boolean"}},left:{defaultValue:{value:"false"},description:"",name:"left",required:!1,type:{name:"boolean"}},small:{defaultValue:{value:"false"},description:"",name:"small",required:!1,type:{name:"boolean"}},width:{defaultValue:{value:"100%"},description:"",name:"width",required:!1,type:{name:"string | number"}},value:{defaultValue:null,description:"",name:"value",required:!1,type:{name:"string"}},unitkey:{defaultValue:{value:""},description:"",name:"unitkey",required:!1,type:{name:"string"}},initUnit:{defaultValue:null,description:"",name:"initUnit",required:!1,type:{name:"string"}},noConversion:{defaultValue:{value:"false"},description:"",name:"noConversion",required:!1,type:{name:"boolean"}},doNotConvertValue:{defaultValue:{value:"false"},description:"",name:"doNotConvertValue",required:!1,type:{name:"boolean"}},testId:{defaultValue:null,description:"",name:"testId",required:!1,type:{name:"string"}},warning:{defaultValue:{value:"false"},description:"",name:"warning",required:!1,type:{name:"string | boolean"}},predefinedOptions:{defaultValue:null,description:"",name:"predefinedOptions",required:!1,type:{name:"IPredefinedOption[]"}},initialPredefinedOption:{defaultValue:{value:"false"},description:"",name:"initialPredefinedOption",required:!1,type:{name:"boolean"}},shouldLinkAutomaticly:{defaultValue:{value:"true"},description:"",name:"shouldLinkAutomaticly",required:!1,type:{name:"boolean"}},selectedPredefinedOptionKey:{defaultValue:null,description:"",name:"selectedPredefinedOptionKey",required:!1,type:{name:"string"}},validationCallback:{defaultValue:null,description:"",name:"validationCallback",required:!1,type:{name:"((params: IUnitInputValidationCallbackPayload) => void)"}},disabledValidation:{defaultValue:{value:"false"},description:"",name:"disabledValidation",required:!1,type:{name:"boolean"}},allowEmpty:{defaultValue:{value:"false"},description:"",name:"allowEmpty",required:!1,type:{name:"boolean"}},autoValue:{defaultValue:null,description:"",name:"autoValue",required:!1,type:{name:"string"}},onChange:{defaultValue:{value:"() => {}"},description:"",name:"onChange",required:!1,type:{name:"(event: ChangeEvent<HTMLInputElement> | ICustomChangeEvent) => void"}},onSwitchUnit:{defaultValue:{value:"() => {}"},description:"",name:"onSwitchUnit",required:!1,type:{name:"((unit: string) => void)"}},onClick:{defaultValue:{value:"() => {}"},description:"",name:"onClick",required:!1,type:{name:"MouseEventHandler<HTMLInputElement>"}},onFocus:{defaultValue:{value:"() => {}"},description:"",name:"onFocus",required:!1,type:{name:"FocusEventHandler<HTMLInputElement>"}},unitTemplate:{defaultValue:null,description:"",name:"unitTemplate",required:!1,type:{name:"Record<string, any>"}},convertBackToStorageUnit:{defaultValue:{value:"false"},description:"",name:"convertBackToStorageUnit",required:!1,type:{name:"boolean"}},enableCosmeticRounding:{defaultValue:{value:"true"},description:"",name:"enableCosmeticRounding",required:!1,type:{name:"boolean"}},enableDisplayRounding:{defaultValue:{value:"false"},description:"",name:"enableDisplayRounding",required:!1,type:{name:"boolean"}}}}}catch{}const{useArgs:Pt}=__STORYBOOK_MODULE_ADDONS__,Sa={title:"Forms/UnitInput",component:p,args:{name:"example",unitkey:"length",value:"123|m"}},f=n=>{const[a,t]=Pt(),s=o=>{t({value:o.target.value})};return e.jsx(p,{...n,onChange:s})},ae=f.bind({}),M=f.bind({});M.args={initUnit:"ft",unitTemplate:{length:"ft"}};const _=f.bind({});_.args={value:'123|"',unitkey:'"'};const W=f.bind({});W.args={width:"180px"};const O=f.bind({});O.args={noConversion:!0};const q=f.bind({});q.args={small:!0};const H=f.bind({});H.args={error:"Error message goes here"};const L=f.bind({});L.args={value:"asas123asd|%"};const A=f.bind({});A.args={disabled:!0,disabledUnit:!0};A.parameters={docs:{description:{story:"Each part of UnitInput can be disabled separately. `disabled` disables only the main text input, `disabledUnit` disables only the unit menu. **Needs review (comes from Reservoir input requirements)**"}}};const K=f.bind({});K.args={disabled:!0,disabledUnit:!0,noConversion:!0};const G=f.bind({});G.args={disabledUnit:!0,unitkey:void 0};const $=f.bind({});$.args={disabledUnit:!0,unitkey:"length"};const z=f.bind({});z.args={disabledUnit:!1,disabled:!0};const J=n=>{const[a,t]=u.useState("123|m"),[s,o]=u.useState("223|m"),[m,l]=u.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(c,{label:"Change initUnit",onClick:()=>l(m==="m"?"ft":"m")}),e.jsx(C,{}),e.jsx(c,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(C,{}),e.jsx(p,{name:"example",onChange:g=>{t(g.target.value)},unitkey:"length",value:a,initUnit:m,onSwitchUnit:l}),e.jsx(C,{}),e.jsx(p,{name:"example2",onChange:g=>{o(g.target.value)},unitkey:"length",value:s,initUnit:m,onSwitchUnit:l}),e.jsx(jt,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(p,{name:"example",onChange:g=>{t(g.target.value)},unitkey:"length",value:a,onSwitchUnit:l}),e.jsx(p,{name:"example2",onChange:g=>{o(g.target.value)},unitkey:"length",value:s,onSwitchUnit:l})]})};J.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const Y=f.bind({});Y.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const Z=()=>{const n="500px",[a,t]=u.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(Yn,{children:[e.jsxs(be,{width:"25%",children:[e.jsx(c,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(c,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(be,{width:"25%",children:[e.jsx(c,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(x,{label:"Normal PUI",children:e.jsx(p,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:n,placeholder:"value|unit"})}),e.jsx(x,{label:"Disabled validation",children:e.jsx(p,{name:"example2",onChange:s=>t(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:n})}),e.jsx(x,{label:"Disabled validation and manual error",children:e.jsx(p,{name:"example3",onChange:s=>t(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:n})}),e.jsx(ce,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})},ie=()=>{const n="500px",[a,t]=u.useState("1|m"),[s,o]=u.useState("|m"),m="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(Yn,{children:e.jsxs(be,{width:"25%",children:[e.jsx(c,{label:"Change value to ''",onClick:()=>t("")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to 1",onClick:()=>t("1")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to 1|m",onClick:()=>t("1|m")}),e.jsx("br",{}),e.jsx(c,{label:"Change value to |m - empty value",onClick:()=>t("|m")})]})}),e.jsx("br",{}),e.jsx(x,{label:"Normal PUI (placeholder + auto)",children:e.jsx(p,{name:"example1",onChange:l=>t(l.target.value),value:a,unitkey:"length",width:n,placeholder:"value|unit",autoValue:m})}),e.jsx(x,{label:"Normal PUI (only auto)",children:e.jsx(p,{name:"example1",onChange:l=>t(l.target.value),value:a,unitkey:"length",width:n,autoValue:m})}),e.jsx(x,{label:"Empty PUI with autoValue",children:e.jsx(p,{name:"example1",onChange:l=>o(l.target.value),value:s,unitkey:"length",width:n,autoValue:m})}),e.jsx(x,{label:"Normal PUI (only placeholder)",children:e.jsx(p,{name:"example1",onChange:l=>t(l.target.value),value:a,unitkey:"length",width:n,placeholder:"Placeholder test"})}),e.jsx(x,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(p,{name:"example1",onChange:l=>t(l.target.value),value:a,unitkey:"length",width:n,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(ce,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};Z.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const re=()=>{const[n,a]=u.useState("123|%"),[t,s]=u.useState(null),o="This should be visible when an error appears",m=({name:l,error:g})=>(s(g),{name:l,error:g});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(p,{name:"example",onChange:l=>a(l.target.value),error:!t||o,validationCallback:m,value:n}),e.jsx("br",{}),e.jsx(C,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(ce,{message:{heading:t,visible:!0}})]})},le=()=>{const[n,a]=u.useState("123|m"),[t,s]=u.useState(""),[o,m]=u.useState("km"),l=()=>{m("ft"),s("placeholder"),a("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(p,{name:"example",onChange:g=>a(g.target.value),value:n,allowEmpty:!0,placeholder:t,initUnit:o,unitkey:"length"}),e.jsx("br",{}),e.jsx(C,{}),e.jsx(c,{label:"Change value |m and unit ft",onClick:()=>l()})]})},se=()=>{const[n,a]=u.useState("123|m"),[t,s]=u.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(p,{name:"example",onChange:o=>a(o.target.value),value:n,initUnit:t,unitkey:"length",onSwitchUnit:s}),e.jsx(C,{}),e.jsx(p,{name:"example",onChange:o=>a(o.target.value),value:n,initUnit:t,unitkey:"length",onSwitchUnit:s})]})},oe=()=>e.jsxs(e.Fragment,{children:[e.jsx(de,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(C,{}),e.jsx(p,{name:"example",onChange:()=>{},value:r.withUnit(r.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}})]}),ue=()=>{const[n,a]=u.useState("psi"),[t,s]=u.useState(!1),[o,m]=u.useState(!0),[l,g]=u.useState("672.2388357750001|bar"),[h,I]=u.useState("");return e.jsxs(kt,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(R,{heading:e.jsx(F,{children:"Settings"}),children:[e.jsx(x,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(Pe,{checked:t,onChange:U=>s(U.target.checked)})}),e.jsx(x,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(Pe,{checked:o,onChange:U=>m(U.target.checked)})})]}),e.jsxs(R,{heading:e.jsx(F,{children:"NumberInput (displayed in Meters)"}),children:[e.jsx(de,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(C,{}),e.jsx(de,{warning:!0,children:"Note: UnitInput uses convertSamePrecision internally (decision prior to cosmetic value implementation). This means not all rounding noise occurrences seen in NumberInput will be reproducible in UnitInput, because they get rounded off by other logic."}),e.jsx(C,{}),e.jsx(p,{name:"Example",unitkey:"pressure",initUnit:n,unitTemplate:{pressure:"psi"},value:l,onChange:U=>{g(U.target.value)},enableDisplayRounding:t,enableCosmeticRounding:o,error:r.convertAndGetValue(l,"bar")>=0?"":"Value must be positive",validationCallback:({name:U,error:pe})=>{I(pe??"")},convertBackToStorageUnit:!0})]}),e.jsx(R,{heading:e.jsx(F,{children:"Unit Template"}),children:e.jsx(St,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:n,width:70,onChange:U=>a(U.target.value)})}),e.jsx(R,{heading:e.jsx(F,{children:"Test Validation Callback"}),children:h&&e.jsx(ce,{message:{content:h,icon:!0,type:"Error",visible:!0}})}),e.jsxs(R,{heading:e.jsx(F,{children:"Storage State / Redux (stored in Feet)"}),children:[l,e.jsx(C,{}),e.jsx(c,{label:"Change value",onClick:()=>g(r.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})};var Be,Me,_e;ae.parameters={...ae.parameters,docs:{...(Be=ae.parameters)==null?void 0:Be.docs,source:{originalSource:`args => {
|
|
2
|
+
const [_, updateArgs] = useArgs();
|
|
3
|
+
const handleChange = (evt: any) => {
|
|
4
|
+
updateArgs({
|
|
5
|
+
value: evt.target.value
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
9
|
+
}`,...(_e=(Me=ae.parameters)==null?void 0:Me.docs)==null?void 0:_e.source}}};var We,Oe,qe;M.parameters={...M.parameters,docs:{...(We=M.parameters)==null?void 0:We.docs,source:{originalSource:`args => {
|
|
10
|
+
const [_, updateArgs] = useArgs();
|
|
11
|
+
const handleChange = (evt: any) => {
|
|
12
|
+
updateArgs({
|
|
13
|
+
value: evt.target.value
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
17
|
+
}`,...(qe=(Oe=M.parameters)==null?void 0:Oe.docs)==null?void 0:qe.source}}};var He,Le,Ke;_.parameters={..._.parameters,docs:{...(He=_.parameters)==null?void 0:He.docs,source:{originalSource:`args => {
|
|
18
|
+
const [_, updateArgs] = useArgs();
|
|
19
|
+
const handleChange = (evt: any) => {
|
|
20
|
+
updateArgs({
|
|
21
|
+
value: evt.target.value
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
25
|
+
}`,...(Ke=(Le=_.parameters)==null?void 0:Le.docs)==null?void 0:Ke.source}}};var Ge,$e,ze;W.parameters={...W.parameters,docs:{...(Ge=W.parameters)==null?void 0:Ge.docs,source:{originalSource:`args => {
|
|
26
|
+
const [_, updateArgs] = useArgs();
|
|
27
|
+
const handleChange = (evt: any) => {
|
|
28
|
+
updateArgs({
|
|
29
|
+
value: evt.target.value
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
33
|
+
}`,...(ze=($e=W.parameters)==null?void 0:$e.docs)==null?void 0:ze.source}}};var Je,Ye,Ze;O.parameters={...O.parameters,docs:{...(Je=O.parameters)==null?void 0:Je.docs,source:{originalSource:`args => {
|
|
34
|
+
const [_, updateArgs] = useArgs();
|
|
35
|
+
const handleChange = (evt: any) => {
|
|
36
|
+
updateArgs({
|
|
37
|
+
value: evt.target.value
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
41
|
+
}`,...(Ze=(Ye=O.parameters)==null?void 0:Ye.docs)==null?void 0:Ze.source}}};var Qe,Xe,en;q.parameters={...q.parameters,docs:{...(Qe=q.parameters)==null?void 0:Qe.docs,source:{originalSource:`args => {
|
|
42
|
+
const [_, updateArgs] = useArgs();
|
|
43
|
+
const handleChange = (evt: any) => {
|
|
44
|
+
updateArgs({
|
|
45
|
+
value: evt.target.value
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
49
|
+
}`,...(en=(Xe=q.parameters)==null?void 0:Xe.docs)==null?void 0:en.source}}};var nn,tn,an;H.parameters={...H.parameters,docs:{...(nn=H.parameters)==null?void 0:nn.docs,source:{originalSource:`args => {
|
|
50
|
+
const [_, updateArgs] = useArgs();
|
|
51
|
+
const handleChange = (evt: any) => {
|
|
52
|
+
updateArgs({
|
|
53
|
+
value: evt.target.value
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
57
|
+
}`,...(an=(tn=H.parameters)==null?void 0:tn.docs)==null?void 0:an.source}}};var rn,ln,sn;L.parameters={...L.parameters,docs:{...(rn=L.parameters)==null?void 0:rn.docs,source:{originalSource:`args => {
|
|
58
|
+
const [_, updateArgs] = useArgs();
|
|
59
|
+
const handleChange = (evt: any) => {
|
|
60
|
+
updateArgs({
|
|
61
|
+
value: evt.target.value
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
65
|
+
}`,...(sn=(ln=L.parameters)==null?void 0:ln.docs)==null?void 0:sn.source}}};var on,un,dn;A.parameters={...A.parameters,docs:{...(on=A.parameters)==null?void 0:on.docs,source:{originalSource:`args => {
|
|
66
|
+
const [_, updateArgs] = useArgs();
|
|
67
|
+
const handleChange = (evt: any) => {
|
|
68
|
+
updateArgs({
|
|
69
|
+
value: evt.target.value
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
73
|
+
}`,...(dn=(un=A.parameters)==null?void 0:un.docs)==null?void 0:dn.source}}};var cn,pn,mn;K.parameters={...K.parameters,docs:{...(cn=K.parameters)==null?void 0:cn.docs,source:{originalSource:`args => {
|
|
74
|
+
const [_, updateArgs] = useArgs();
|
|
75
|
+
const handleChange = (evt: any) => {
|
|
76
|
+
updateArgs({
|
|
77
|
+
value: evt.target.value
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
81
|
+
}`,...(mn=(pn=K.parameters)==null?void 0:pn.docs)==null?void 0:mn.source}}};var gn,hn,vn;G.parameters={...G.parameters,docs:{...(gn=G.parameters)==null?void 0:gn.docs,source:{originalSource:`args => {
|
|
82
|
+
const [_, updateArgs] = useArgs();
|
|
83
|
+
const handleChange = (evt: any) => {
|
|
84
|
+
updateArgs({
|
|
85
|
+
value: evt.target.value
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
89
|
+
}`,...(vn=(hn=G.parameters)==null?void 0:hn.docs)==null?void 0:vn.source}}};var fn,bn,Cn;$.parameters={...$.parameters,docs:{...(fn=$.parameters)==null?void 0:fn.docs,source:{originalSource:`args => {
|
|
90
|
+
const [_, updateArgs] = useArgs();
|
|
91
|
+
const handleChange = (evt: any) => {
|
|
92
|
+
updateArgs({
|
|
93
|
+
value: evt.target.value
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
97
|
+
}`,...(Cn=(bn=$.parameters)==null?void 0:bn.docs)==null?void 0:Cn.source}}};var Un,yn,xn;z.parameters={...z.parameters,docs:{...(Un=z.parameters)==null?void 0:Un.docs,source:{originalSource:`args => {
|
|
98
|
+
const [_, updateArgs] = useArgs();
|
|
99
|
+
const handleChange = (evt: any) => {
|
|
100
|
+
updateArgs({
|
|
101
|
+
value: evt.target.value
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
105
|
+
}`,...(xn=(yn=z.parameters)==null?void 0:yn.docs)==null?void 0:xn.source}}};var Vn,jn,kn;J.parameters={...J.parameters,docs:{...(Vn=J.parameters)==null?void 0:Vn.docs,source:{originalSource:`(args: IUnitInputProps) => {
|
|
106
|
+
const [value, setValue] = useState('123|m');
|
|
107
|
+
const [value2, setValue2] = useState('223|m');
|
|
108
|
+
const [initUnit, setInitUnit] = useState('ft');
|
|
109
|
+
return <>
|
|
110
|
+
<Button label="Change initUnit" onClick={() => setInitUnit(initUnit === 'm' ? 'ft' : 'm')} />
|
|
111
|
+
<Spacer />
|
|
112
|
+
<Button label="Change value" onClick={() => setValue(value === '123|m' ? '456|m' : '123|m')} />
|
|
113
|
+
<Spacer />
|
|
114
|
+
<UnitInput name="example" onChange={evt => {
|
|
115
|
+
setValue(evt.target.value);
|
|
116
|
+
}} unitkey="length" value={value} initUnit={initUnit} onSwitchUnit={setInitUnit} />
|
|
117
|
+
<Spacer />
|
|
118
|
+
<UnitInput name="example2" onChange={evt => {
|
|
119
|
+
setValue2(evt.target.value);
|
|
120
|
+
}} unitkey="length" value={value2} initUnit={initUnit} onSwitchUnit={setInitUnit} />
|
|
121
|
+
<Divider />
|
|
122
|
+
<h4>Without initUnit property (taken from the redux store)</h4>
|
|
123
|
+
<UnitInput name="example" onChange={evt => {
|
|
124
|
+
setValue(evt.target.value);
|
|
125
|
+
}} unitkey="length" value={value} onSwitchUnit={setInitUnit} />
|
|
126
|
+
<UnitInput name="example2" onChange={evt => {
|
|
127
|
+
setValue2(evt.target.value);
|
|
128
|
+
}} unitkey="length" value={value2} onSwitchUnit={setInitUnit} />
|
|
129
|
+
</>;
|
|
130
|
+
}`,...(kn=(jn=J.parameters)==null?void 0:jn.docs)==null?void 0:kn.source}}};var Sn,In,wn;Y.parameters={...Y.parameters,docs:{...(Sn=Y.parameters)==null?void 0:Sn.docs,source:{originalSource:`args => {
|
|
131
|
+
const [_, updateArgs] = useArgs();
|
|
132
|
+
const handleChange = (evt: any) => {
|
|
133
|
+
updateArgs({
|
|
134
|
+
value: evt.target.value
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return <UnitInput {...args} onChange={handleChange} />;
|
|
138
|
+
}`,...(wn=(In=Y.parameters)==null?void 0:In.docs)==null?void 0:wn.source}}};var En,Nn,An;Z.parameters={...Z.parameters,docs:{...(En=Z.parameters)==null?void 0:En.docs,source:{originalSource:`() => {
|
|
139
|
+
const width = '500px';
|
|
140
|
+
const [value, setValue] = useState<any>(undefined);
|
|
141
|
+
return <>
|
|
142
|
+
<h4>Different edge cases such as +/- infinity, undefined, NaN, null:</h4>
|
|
143
|
+
<Row>
|
|
144
|
+
<Column width="25%">
|
|
145
|
+
<Button label="Change value infinity" onClick={() => setValue(Infinity)} />
|
|
146
|
+
<br />
|
|
147
|
+
<Button label="Change value -infinity" onClick={() => setValue(-Infinity)} />
|
|
148
|
+
<br />
|
|
149
|
+
<Button label="Change value null" onClick={() => setValue(null)} />
|
|
150
|
+
<br />
|
|
151
|
+
<Button label="Change value - undefined" onClick={() => setValue(undefined)} />
|
|
152
|
+
<br />
|
|
153
|
+
<Button label="Change value - NaN" onClick={() => setValue(NaN)} />
|
|
154
|
+
<br />
|
|
155
|
+
<Button label="Change value - nothing (empty)" onClick={() => setValue(undefined)} />
|
|
156
|
+
<br />
|
|
157
|
+
<Button label="Change value - empty string" onClick={() => setValue('')} />
|
|
158
|
+
</Column>
|
|
159
|
+
<Column width="25%">
|
|
160
|
+
<Button label="Change value infinity|m" onClick={() => setValue(Infinity + '|m')} />
|
|
161
|
+
<br />
|
|
162
|
+
<Button label="Change value -infinity|m" onClick={() => setValue(-Infinity + '|m')} />
|
|
163
|
+
<br />
|
|
164
|
+
<Button label="Change value null|m" onClick={() => setValue(null + '|m')} />
|
|
165
|
+
<br />
|
|
166
|
+
<Button label="Change value - undefined|m" onClick={() => setValue(undefined + '|m')} />
|
|
167
|
+
<br />
|
|
168
|
+
<Button label="Change value - NaN|m" onClick={() => setValue(NaN + '|m')} />
|
|
169
|
+
<br />
|
|
170
|
+
<Button label="Change value - nothing (empty)|m" onClick={() => setValue('|m')} />
|
|
171
|
+
</Column>
|
|
172
|
+
</Row>
|
|
173
|
+
<br />
|
|
174
|
+
<Field label="Normal PUI">
|
|
175
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" />
|
|
176
|
+
</Field>
|
|
177
|
+
<Field label="Disabled validation">
|
|
178
|
+
<UnitInput name="example2" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" disabledValidation width={width} />
|
|
179
|
+
</Field>
|
|
180
|
+
<Field label="Disabled validation and manual error">
|
|
181
|
+
<UnitInput name="example3" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" error="test" disabledValidation width={width} />
|
|
182
|
+
</Field>
|
|
183
|
+
<Message message={{
|
|
184
|
+
heading: 'Current value inside PUI: ' + value,
|
|
185
|
+
visible: true
|
|
186
|
+
}} />
|
|
187
|
+
</>;
|
|
188
|
+
}`,...(An=(Nn=Z.parameters)==null?void 0:Nn.docs)==null?void 0:An.source}}};var Dn,Pn,Tn;ie.parameters={...ie.parameters,docs:{...(Dn=ie.parameters)==null?void 0:Dn.docs,source:{originalSource:`() => {
|
|
189
|
+
const width = '500px';
|
|
190
|
+
const [value, setValue] = useState<string>('1|m');
|
|
191
|
+
const [valueB, setValueB] = useState('|m');
|
|
192
|
+
const automaticValue = '123|km';
|
|
193
|
+
return <>
|
|
194
|
+
<h4>Different cases for automatic (placeholder) values:</h4>
|
|
195
|
+
<Row>
|
|
196
|
+
<Column width="25%">
|
|
197
|
+
<Button label="Change value to ''" onClick={() => setValue('')} />
|
|
198
|
+
<br />
|
|
199
|
+
<Button label="Change value to 1" onClick={() => setValue('1')} />
|
|
200
|
+
<br />
|
|
201
|
+
<Button label="Change value to 1|m" onClick={() => setValue('1|m')} />
|
|
202
|
+
<br />
|
|
203
|
+
<Button label="Change value to |m - empty value" onClick={() => setValue('|m')} />
|
|
204
|
+
</Column>
|
|
205
|
+
</Row>
|
|
206
|
+
<br />
|
|
207
|
+
<Field label="Normal PUI (placeholder + auto)">
|
|
208
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="value|unit" autoValue={automaticValue} />
|
|
209
|
+
</Field>
|
|
210
|
+
<Field label="Normal PUI (only auto)">
|
|
211
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} autoValue={automaticValue} />
|
|
212
|
+
</Field>
|
|
213
|
+
<Field label="Empty PUI with autoValue">
|
|
214
|
+
<UnitInput name="example1" onChange={evt => setValueB(evt.target.value)} value={valueB} unitkey="length" width={width} autoValue={automaticValue} />
|
|
215
|
+
</Field>
|
|
216
|
+
<Field label="Normal PUI (only placeholder)">
|
|
217
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" />
|
|
218
|
+
</Field>
|
|
219
|
+
<Field label="Normal PUI (placeholder + allowEmpty)">
|
|
220
|
+
<UnitInput name="example1" onChange={evt => setValue(evt.target.value)} value={value} unitkey="length" width={width} placeholder="Placeholder test" allowEmpty />
|
|
221
|
+
</Field>
|
|
222
|
+
<Message message={{
|
|
223
|
+
heading: 'Current value inside PUI: ' + value,
|
|
224
|
+
visible: true
|
|
225
|
+
}} />
|
|
226
|
+
</>;
|
|
227
|
+
}`,...(Tn=(Pn=ie.parameters)==null?void 0:Pn.docs)==null?void 0:Tn.source}}};var Rn,Fn,Bn;re.parameters={...re.parameters,docs:{...(Rn=re.parameters)==null?void 0:Rn.docs,source:{originalSource:`() => {
|
|
228
|
+
const [value, setValue] = useState('123|%');
|
|
229
|
+
const [validation, setValidation] = useState<string | null>(null);
|
|
230
|
+
const predictedMessage = 'This should be visible when an error appears';
|
|
231
|
+
const handleValidation = ({
|
|
232
|
+
name,
|
|
233
|
+
error
|
|
234
|
+
}: IUnitInputValidationCallbackPayload) => {
|
|
235
|
+
setValidation(error);
|
|
236
|
+
return {
|
|
237
|
+
name,
|
|
238
|
+
error
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
return <>
|
|
242
|
+
<h4>3rd party validation message when inputting invalid value:</h4>
|
|
243
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
|
|
244
|
+
<br />
|
|
245
|
+
<Spacer />
|
|
246
|
+
<h4>Original validation message: </h4>
|
|
247
|
+
<Message message={{
|
|
248
|
+
heading: validation,
|
|
249
|
+
visible: true
|
|
250
|
+
}} />
|
|
251
|
+
</>;
|
|
252
|
+
}`,...(Bn=(Fn=re.parameters)==null?void 0:Fn.docs)==null?void 0:Bn.source}}};var Mn,_n,Wn;le.parameters={...le.parameters,docs:{...(Mn=le.parameters)==null?void 0:Mn.docs,source:{originalSource:`() => {
|
|
253
|
+
const [value, setValue] = useState('123|m');
|
|
254
|
+
const [placeholder, setPlaceholder] = useState('');
|
|
255
|
+
const [initUnit, setInitUnit] = useState('km');
|
|
256
|
+
const setPlaceholderValue = () => {
|
|
257
|
+
setInitUnit('ft');
|
|
258
|
+
setPlaceholder('placeholder');
|
|
259
|
+
setValue('|m');
|
|
260
|
+
};
|
|
261
|
+
return <>
|
|
262
|
+
<h4>Empty value case:</h4>
|
|
263
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
|
|
264
|
+
<br />
|
|
265
|
+
<Spacer />
|
|
266
|
+
<Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
|
|
267
|
+
</>;
|
|
268
|
+
}`,...(Wn=(_n=le.parameters)==null?void 0:_n.docs)==null?void 0:Wn.source}}};var On,qn,Hn;se.parameters={...se.parameters,docs:{...(On=se.parameters)==null?void 0:On.docs,source:{originalSource:`() => {
|
|
269
|
+
const [value, setValue] = useState('123|m');
|
|
270
|
+
const [unit, setUnit] = useState('m');
|
|
271
|
+
return <>
|
|
272
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
273
|
+
<Spacer />
|
|
274
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
275
|
+
</>;
|
|
276
|
+
}`,...(Hn=(qn=se.parameters)==null?void 0:qn.docs)==null?void 0:Hn.source}}};var Ln,Kn,Gn;oe.parameters={...oe.parameters,docs:{...(Ln=oe.parameters)==null?void 0:Ln.docs,source:{originalSource:`() => {
|
|
277
|
+
return <>
|
|
278
|
+
<Text faint>
|
|
279
|
+
Reproduce OW-10614 rounding noise bug when storing values in a different
|
|
280
|
+
unit to the display unit
|
|
281
|
+
</Text>
|
|
282
|
+
<Spacer />
|
|
283
|
+
<UnitInput name="example" onChange={() => {}} value={withUnit(convertAndGetValue('9750|psi', 'bar'), 'bar')} initUnit="psi" unitkey="pressure" unitTemplate={{
|
|
284
|
+
pressure: 'psi'
|
|
285
|
+
}} />
|
|
286
|
+
</>;
|
|
287
|
+
}`,...(Gn=(Kn=oe.parameters)==null?void 0:Kn.docs)==null?void 0:Gn.source}}};var $n,zn,Jn;ue.parameters={...ue.parameters,docs:{...($n=ue.parameters)==null?void 0:$n.docs,source:{originalSource:`() => {
|
|
288
|
+
const [preferredUnit, setPreferredUnit] = useState('psi');
|
|
289
|
+
const [enableDisplayRounding, setEnableDisplayRounding] = useState(false);
|
|
290
|
+
const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(true);
|
|
291
|
+
const [value, setValue] = useState('672.2388357750001|bar');
|
|
292
|
+
const [callBackError, setCallBackError] = useState('');
|
|
293
|
+
return <Grid columns="1fr 1fr" gap>
|
|
294
|
+
<Card heading={<Heading>Settings</Heading>}>
|
|
295
|
+
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
296
|
+
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
297
|
+
</Field>
|
|
298
|
+
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
299
|
+
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
300
|
+
</Field>
|
|
301
|
+
</Card>
|
|
302
|
+
<Card heading={<Heading>NumberInput (displayed in Meters)</Heading>}>
|
|
303
|
+
<Text faint>
|
|
304
|
+
Cosmetic Rounding Test Case: type 9750 then return (compare with
|
|
305
|
+
enableCosmeticRounding on and off)
|
|
306
|
+
</Text>
|
|
307
|
+
<Spacer />
|
|
308
|
+
<Text warning>
|
|
309
|
+
Note: UnitInput uses convertSamePrecision internally (decision prior
|
|
310
|
+
to cosmetic value implementation). This means not all rounding noise
|
|
311
|
+
occurrences seen in NumberInput will be reproducible in UnitInput,
|
|
312
|
+
because they get rounded off by other logic.
|
|
313
|
+
</Text>
|
|
314
|
+
<Spacer />
|
|
315
|
+
<UnitInput name="Example" unitkey="pressure" initUnit={preferredUnit} unitTemplate={{
|
|
316
|
+
pressure: 'psi'
|
|
317
|
+
}} value={value} onChange={evt => {
|
|
318
|
+
setValue(evt.target.value);
|
|
319
|
+
}} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} error={convertAndGetValue(value, 'bar') >= 0 ? '' : 'Value must be positive'} validationCallback={({
|
|
320
|
+
name,
|
|
321
|
+
error
|
|
322
|
+
}) => {
|
|
323
|
+
setCallBackError(error ?? '');
|
|
324
|
+
}} convertBackToStorageUnit />
|
|
325
|
+
</Card>
|
|
326
|
+
<Card heading={<Heading>Unit Template</Heading>}>
|
|
327
|
+
<Select options={[{
|
|
328
|
+
label: 'Bar',
|
|
329
|
+
value: 'bar'
|
|
330
|
+
}, {
|
|
331
|
+
label: 'psi',
|
|
332
|
+
value: 'psi'
|
|
333
|
+
}]} value={preferredUnit} width={70} onChange={evt => setPreferredUnit(evt.target.value)} />
|
|
334
|
+
</Card>
|
|
335
|
+
<Card heading={<Heading>Test Validation Callback</Heading>}>
|
|
336
|
+
{callBackError && <Message message={{
|
|
337
|
+
content: callBackError,
|
|
338
|
+
icon: true,
|
|
339
|
+
type: 'Error',
|
|
340
|
+
visible: true
|
|
341
|
+
}} />}
|
|
342
|
+
</Card>
|
|
343
|
+
<Card heading={<Heading>Storage State / Redux (stored in Feet)</Heading>}>
|
|
344
|
+
{value}
|
|
345
|
+
<Spacer />
|
|
346
|
+
<Button label="Change value" onClick={() => setValue(withUnit(String(Math.floor(Math.random() * 100)), 'bar'))} />
|
|
347
|
+
</Card>
|
|
348
|
+
</Grid>;
|
|
349
|
+
}`,...(Jn=(zn=ue.parameters)==null?void 0:zn.docs)==null?void 0:Jn.source}}};const Ia=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI","onSwitchUnit","OW_10614TestCase","DemoCosmeticRounding"];export{le as AllowEmptyPUI,ie as AutomaticValues,ae as Default,ue as DemoCosmeticRounding,A as Disabled,K as DisabledNoConversion,$ as DisabledUnitWithUnitKey,G as DisabledUnitWithoutUnitKey,z as DisabledWithEnabledUnitMenu,H as Error,M as InitUnit,L as InternalValidationError,O as NoConversion,oe as OW_10614TestCase,Y as PredefinedOptionsMenu,q as Small,Z as TestEdgeCases,J as TestExternalStateChangeWithSynchronizedUnits,re as ValidationCallback,W as Width,Ia as __namedExportsOrder,Sa as default,_ as notKnownUnit,se as onSwitchUnit};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import{j as n}from"./jsx-runtime-FsUICBgo.js";import{r as v}from"./index-RfLt4OUa.js";import{f as M}from"./immer.esm-bD7SSJ7T.js";import{d as T}from"./index-VSx05S_2.js";import{G as X}from"./grid-u1mZpaML.js";import{S as Y}from"./spacer-Yji9g2AW.js";import{C as F}from"./card-0r8RRVk-.js";import{F as L}from"./field-jD6TclDQ.js";import{H as W}from"./heading-FcNTpGhR.js";import{S as K}from"./select-KWgree43.js";import{T as I}from"./toggle-vKuY4G3w.js";import{l as Z}from"./lodash-Bmg8FrMx.js";import{u as ee}from"./use-previous-VKMmnaK7.js";import{T as te,C as P}from"./table-4SISWUSt.js";import"./index-cCpkwrS5.js";import"./styled-components.browser.esm-qIipjd6c.js";import"./tslib.es6-OIsz3r9a.js";import"./index-VW3EWkuE.js";import"./label-dla_bzHj.js";import"./common-types-U65vzrrz.js";import"./help-icon-D6ZGAbgL.js";import"./tooltip-dueTLnwA.js";import"./index-miLrID2P.js";import"./icon-_m67DAr0.js";import"./objectWithoutPropertiesLoose-9Q1jwsKS.js";import"./inheritsLoose-Y9jOMJLd.js";import"./index-4QtD-hFu.js";import"./disabled-context-urNQThQz.js";import"./types-5uVBABF4.js";import"./extends-dGVwEr9R.js";import"./assertThisInitialized-4q6YPdh3.js";import"./memoize-one.esm-hqe5SRxC.js";import"./types-VB5zD18b.js";import"./text-6KQ6ntOV.js";import"./actions-Z1pyUd57.js";import"./button-UQO14biP.js";import"./spinner-R8Il4aRe.js";import"./badge-23Ty_zBt.js";import"./select.input-zP5tW20f.js";import"./index.es-HG2GUH9i.js";import"./redux-F5dueAP3.js";import"./objectSpread2-93s0nBry.js";import"./tiny-invariant-R4kOKlvx.js";import"./pagination-er5fRdi2.js";import"./input-fYKvBwPs.js";import"./input-group-R8LoqKRn.js";import"./input-group-addon-BHVsW9mL.js";import"./number-input-xqup0wHW.js";import"./check-box-Q2GsbR79.js";import"./slider-jx0z5OyT.js";import"./index-ugi_ZH6T.js";import"./popover-rJn7kxkX.js";const ne=o=>o.reduce(({preferredUnits:r,storageUnits:i},{unitKey:s,preferredUnit:a,storageUnit:m})=>(r[s]=a,i[s]=m,{preferredUnits:r,storageUnits:i}),{preferredUnits:{},storageUnits:{}}),ae=({headers:o,rows:r,selectedUnits:i,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:m,enableCosmeticRounding:b,enableDisplayRounding:U})=>{const u=o?o.map(d=>({...d,cells:d.cells.map(c=>{var t;if(c.type===P.AUTO_UNIT){const{testId:C,unitKey:p}=c;return{value:i[p],type:P.SELECT,searchable:!1,options:(t=T.getUnitsForQuantity(p))==null?void 0:t.map(y=>({label:T.label(y),value:y})),native:c.native,onChange:y=>a({unitKey:p,value:y.target.value}),testId:C}}return c})})):[],l=r?r.map((d,c)=>({...d,cells:d.cells.map((t,C)=>{if("autoUnit"in t&&(t!=null&&t.autoUnit)&&(typeof(t==null?void 0:t.value)=="string"||typeof(t==null?void 0:t.value)=="number")){const{unitKey:p,value:y,formatDisplayValue:w}=t,j=U&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,g=i[p],h=s[p],e=g!==h,f=e?T.convertAndGetValue(y,g,h):t.value,x=w?w(f):f;return{...t,value:x,enableCosmeticRounding:b&&e,enableDisplayRounding:U,roundDisplayValue:j,onChange:S=>{const{value:R}=S.target,D=s[p],E=i[p],A=E!==D,B=m?D:E,N=A?T.convertAndGetValue(R,B,E):R;if("onChange"in t){const{onChange:k}=t,$={...S,target:{...S.target,value:String(N),rowIndex:c,cellIndex:C,unit:B}};k($)}}}}return t})})):[];return{convertedHeaders:u,convertedRows:l}},_=({table:o,unitConfig:r,convertBackToStorageUnit:i=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:m,headers:b,...U}=o,{storageUnits:u,preferredUnits:l}=ne(r),d=ee(l),[c,t]=v.useState(l),C=({unitKey:g,value:h})=>{t({...c,[g]:h});const e=r.find(f=>f.unitKey===g);e&&typeof e.onChange=="function"&&e.onChange({oldUnit:c[g],newUnit:h,unitKey:g})},p=g=>ae({headers:b,rows:m,selectedUnits:g,storageUnits:u,onChangeUnit:C,convertBackToStorageUnit:i,enableCosmeticRounding:s,enableDisplayRounding:a}),y=p(c),[w,j]=v.useState(y);return v.useEffect(()=>{!Z.isEqual(l,d)&&(Object.keys(l).forEach(h=>{const e=d==null?void 0:d[h],f=l[h];e!==f&&C({unitKey:h,value:f})}),j(p(l)))},[r]),v.useEffect(()=>{j(p(c))},[o,c]),n.jsx(te,{table:{...U,headers:w.convertedHeaders,rows:w.convertedRows}})};try{_.displayName="UnitTable",_.__docgenInfo={description:"",displayName:"UnitTable",props:{table:{defaultValue:null,description:"",name:"table",required:!0,type:{name:"IUnitTable"}},unitConfig:{defaultValue:null,description:"",name:"unitConfig",required:!0,type:{name:"IUnitConfigItem[]"}},convertBackToStorageUnit:{defaultValue:{value:"true"},description:"",name:"convertBackToStorageUnit",required:!1,type:{name:"boolean"}},enableCosmeticRounding:{defaultValue:{value:"true"},description:"",name:"enableCosmeticRounding",required:!1,type:{name:"boolean"}},enableDisplayRounding:{defaultValue:{value:"true"},description:"",name:"enableDisplayRounding",required:!1,type:{name:"boolean"}},onListReorder:{defaultValue:null,description:"",name:"onListReorder",required:!1,type:{name:"((obj: { from: number; to: number; }) => void)"}}}}}catch{}const ct={title:"Basic/UnitTable",args:{}},re=!0,ie=!0,oe=!0,le=!1,H="ft",J="C",se=3,ue=(o,r,i)=>{const s=[r,r,i],a=[...Array(o)].map((m,b)=>{const U=b,u=b+1.25,l=4+b*.25;return[String(U),String(u),String(l)]});return[s,...a]},de=ue(se,H,J),ce=({reduxTable:o,value:r,unit:i,rowIndex:s,cellIndex:a})=>M(o,m=>{const b=m[0][a],U=(u,l)=>l===0;return m.forEach((u,l)=>{if(U(u,l)){u[a]=i;return}if(l===s+1){u[a]=String(r);return}const d=T.convertAndGetValue(u[a],i,b);u[a]=String(d)}),m}),pe=({reduxTable:o,value:r,rowIndex:i,cellIndex:s})=>M(o,a=>{a[i+1][s]=r}),V=()=>{var g,h;const[o,r]=v.useState(H),[i,s]=v.useState(J),[a,m]=v.useState(de),[b,U]=v.useState(re),[u,l]=v.useState(oe),[d,c]=v.useState(ie),[t,C]=v.useState(le),[p,y]=v.useState(H),w=e=>{const{rowIndex:f,cellIndex:x,value:S,unit:R}=e.target,D=t?ce({reduxTable:a,value:S,unit:R,rowIndex:f,cellIndex:x}):pe({reduxTable:a,value:S,rowIndex:f,cellIndex:x});m(D)},j=a.reduce((e,f,x)=>(x===0?e.headers=[{cells:[{value:"From"},{value:"To"},{value:"Temperature"}]},{cells:[{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"length"},{type:"AutoUnit",unitKey:"temperature",testId:"table-unit-selector-3"}]}]:e.rows=e.rows.concat({cells:f.map((S,R)=>{const D=x===1&&R===1;return{value:S,type:D?"Text":"NumberInput",unitKey:R===2?"temperature":"length",onChange:w,roundDisplayValue:x===3&&R===2?k=>T.roundByMagnitude(k,2):null,formatDisplayValue:D?k=>`T* ${k}`:null,autoUnit:!0}})}),e),{headers:[],rows:[]});return n.jsxs(X,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(F,{heading:n.jsx(W,{children:"Settings"}),children:[n.jsx(L,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:b,onChange:e=>U(e.target.checked)})}),n.jsx(L,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:u,onChange:e=>l(e.target.checked)})}),n.jsx(L,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:d,onChange:e=>c(e.target.checked)})}),n.jsx(L,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(I,{checked:t,onChange:e=>C(e.target.checked)})})]}),n.jsxs(F,{heading:n.jsx(W,{children:"Unit template"}),children:[n.jsx(L,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(K,{options:(g=T.getUnitsForQuantity("length"))==null?void 0:g.map(e=>({value:e,label:T.label(e)})),value:{value:o},onChange:e=>r(e.target.value),width:"100px"})}),n.jsx(L,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:n.jsx(K,{options:(h=T.getUnitsForQuantity("temperature"))==null?void 0:h.map(e=>({value:e,label:T.label(e)})),value:{value:i},onChange:e=>s(e.target.value),width:"100px"})})]}),n.jsx(F,{heading:n.jsx(W,{children:"Storage State (Redux)"}),children:n.jsx("pre",{children:n.jsx("code",{children:JSON.stringify(a,null,2)})})}),n.jsxs(F,{heading:n.jsx(W,{children:"UnitTable"}),children:[n.jsx(_,{table:j,unitConfig:[{unitKey:"length",storageUnit:a[0][0],preferredUnit:o,onChange:({newUnit:e})=>y(e)},{unitKey:"temperature",storageUnit:a[0][2],preferredUnit:i}],convertBackToStorageUnit:b,enableDisplayRounding:u,enableCosmeticRounding:d}),n.jsx(Y,{height:20}),n.jsx(L,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:p})]})]})};var q,G,O,Q,z;V.parameters={...V.parameters,docs:{...(q=V.parameters)==null?void 0:q.docs,source:{originalSource:`() => {
|
|
2
|
+
const [preferredLengthUnit, setPreferredLengthUnit] = useState(initialLengthUnit);
|
|
3
|
+
const [preferredTemperatureUnit, setPreferredTemperatureUnit] = useState(initialTemperatureUnit);
|
|
4
|
+
const [reduxTable, setReduxTable] = useState<TTable>(initialTable);
|
|
5
|
+
const [convertBackToStorageUnit, setConvertBackToStorageUnit] = useState(initialConvertBackToStorageUnit);
|
|
6
|
+
const [enableDisplayRounding, setEnableDisplayRounding] = useState(initialEnableDisplayRounding);
|
|
7
|
+
const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(initialEnableCosmeticRounding);
|
|
8
|
+
const [convertWholeTable, setConvertWholeTable] = useState(initialConvertWholeTable);
|
|
9
|
+
const [displayedLengthUnit, setDisplayedLengthUnit] = useState(initialLengthUnit);
|
|
10
|
+
|
|
11
|
+
/*********************************************************************************************************************
|
|
12
|
+
Cell onChange handler
|
|
13
|
+
*********************************************************************************************************************/
|
|
14
|
+
const onUpdateCell = (evt: IUnitTableOnChangeEvent) => {
|
|
15
|
+
const {
|
|
16
|
+
rowIndex,
|
|
17
|
+
cellIndex,
|
|
18
|
+
value,
|
|
19
|
+
unit
|
|
20
|
+
} = evt.target;
|
|
21
|
+
const nextTable = convertWholeTable ? convertStorageTable({
|
|
22
|
+
reduxTable,
|
|
23
|
+
value,
|
|
24
|
+
unit,
|
|
25
|
+
rowIndex,
|
|
26
|
+
cellIndex
|
|
27
|
+
}) : updateCell({
|
|
28
|
+
reduxTable,
|
|
29
|
+
value,
|
|
30
|
+
rowIndex,
|
|
31
|
+
cellIndex
|
|
32
|
+
});
|
|
33
|
+
setReduxTable(nextTable);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/*********************************************************************************************************************
|
|
37
|
+
Construct table view data (same as old Table component, with a new props)
|
|
38
|
+
*********************************************************************************************************************/
|
|
39
|
+
const tableViewData = reduxTable.reduce((acc, row, rowIndex) => {
|
|
40
|
+
if (rowIndex === 0) {
|
|
41
|
+
acc.headers = [{
|
|
42
|
+
cells: [{
|
|
43
|
+
value: 'From'
|
|
44
|
+
}, {
|
|
45
|
+
value: 'To'
|
|
46
|
+
}, {
|
|
47
|
+
value: 'Temperature'
|
|
48
|
+
}]
|
|
49
|
+
}, {
|
|
50
|
+
cells: [{
|
|
51
|
+
type: 'AutoUnit',
|
|
52
|
+
unitKey: 'length'
|
|
53
|
+
}, {
|
|
54
|
+
type: 'AutoUnit',
|
|
55
|
+
unitKey: 'length'
|
|
56
|
+
}, {
|
|
57
|
+
type: 'AutoUnit',
|
|
58
|
+
unitKey: 'temperature',
|
|
59
|
+
testId: 'table-unit-selector-3'
|
|
60
|
+
}]
|
|
61
|
+
}];
|
|
62
|
+
} else {
|
|
63
|
+
acc.rows = acc.rows.concat({
|
|
64
|
+
cells: row.map((cell, cellIndex) => {
|
|
65
|
+
const specialCell = rowIndex === 1 && cellIndex === 1;
|
|
66
|
+
const type = specialCell ? 'Text' : 'NumberInput';
|
|
67
|
+
const formatDisplayValue = specialCell ? (value: number | string) => \`T* \${value}\` : null;
|
|
68
|
+
const customDisplayRounding = rowIndex === 3 && cellIndex === 2 ? (value: TStringNumberNull) => roundByMagnitude(value, 2) : null;
|
|
69
|
+
const value = cell;
|
|
70
|
+
return {
|
|
71
|
+
value,
|
|
72
|
+
type,
|
|
73
|
+
unitKey: cellIndex === 2 ? 'temperature' : 'length',
|
|
74
|
+
onChange: onUpdateCell,
|
|
75
|
+
roundDisplayValue: customDisplayRounding,
|
|
76
|
+
// optionally customize the display rounding of specific columns/cells
|
|
77
|
+
formatDisplayValue,
|
|
78
|
+
// optionally extend/customize the display formatting of specific columns/cells
|
|
79
|
+
autoUnit: true
|
|
80
|
+
};
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return acc;
|
|
85
|
+
}, {
|
|
86
|
+
headers: ([] as any[]),
|
|
87
|
+
rows: ([] as IUnitTableRow[])
|
|
88
|
+
});
|
|
89
|
+
return <Grid columns="1fr 1fr" gap>
|
|
90
|
+
<Card heading={<Heading>Settings</Heading>}>
|
|
91
|
+
<Field label="Convert back to storage unit:" labelLeft labelWidth={200}>
|
|
92
|
+
<Toggle checked={convertBackToStorageUnit} onChange={evt => setConvertBackToStorageUnit(evt.target.checked)} />
|
|
93
|
+
</Field>
|
|
94
|
+
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
95
|
+
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
96
|
+
</Field>
|
|
97
|
+
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
98
|
+
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
99
|
+
</Field>
|
|
100
|
+
<Field label="Convert whole table:" labelLeft labelWidth={200}>
|
|
101
|
+
<Toggle checked={convertWholeTable} onChange={evt => setConvertWholeTable(evt.target.checked)} />
|
|
102
|
+
</Field>
|
|
103
|
+
</Card>
|
|
104
|
+
<Card heading={<Heading>Unit template</Heading>}>
|
|
105
|
+
<Field label="Length unit:" labelLeft labelWidth={120}>
|
|
106
|
+
<Select options={getUnitsForQuantity('length')?.map(unit => ({
|
|
107
|
+
value: unit,
|
|
108
|
+
label: label(unit)
|
|
109
|
+
}))} value={{
|
|
110
|
+
value: preferredLengthUnit
|
|
111
|
+
}} onChange={evt => setPreferredLengthUnit(evt.target.value)} width="100px" />
|
|
112
|
+
</Field>
|
|
113
|
+
<Field label="Temperature unit:" labelLeft labelWidth={120}>
|
|
114
|
+
<Select options={getUnitsForQuantity('temperature')?.map(unit => ({
|
|
115
|
+
value: unit,
|
|
116
|
+
label: label(unit)
|
|
117
|
+
}))} value={{
|
|
118
|
+
value: preferredTemperatureUnit
|
|
119
|
+
}} onChange={evt => setPreferredTemperatureUnit(evt.target.value)} width="100px" />
|
|
120
|
+
</Field>
|
|
121
|
+
</Card>
|
|
122
|
+
<Card heading={<Heading>Storage State (Redux)</Heading>}>
|
|
123
|
+
<pre>
|
|
124
|
+
<code>{JSON.stringify(reduxTable, null, 2)}</code>
|
|
125
|
+
</pre>
|
|
126
|
+
</Card>
|
|
127
|
+
<Card heading={<Heading>UnitTable</Heading>}>
|
|
128
|
+
<UnitTable table={tableViewData}
|
|
129
|
+
//New props:
|
|
130
|
+
unitConfig={[{
|
|
131
|
+
unitKey: 'length',
|
|
132
|
+
storageUnit: reduxTable[0][0],
|
|
133
|
+
preferredUnit: preferredLengthUnit,
|
|
134
|
+
onChange: ({
|
|
135
|
+
newUnit
|
|
136
|
+
}) => setDisplayedLengthUnit(newUnit)
|
|
137
|
+
}, {
|
|
138
|
+
unitKey: 'temperature',
|
|
139
|
+
storageUnit: reduxTable[0][2],
|
|
140
|
+
preferredUnit: preferredTemperatureUnit
|
|
141
|
+
}]}
|
|
142
|
+
//Most tables should just use the default values here (true):
|
|
143
|
+
convertBackToStorageUnit={convertBackToStorageUnit} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} />
|
|
144
|
+
<Spacer height={20} />
|
|
145
|
+
<Field label="Displayed length unit:" labelLeft labelWidth={150}>
|
|
146
|
+
{displayedLengthUnit}
|
|
147
|
+
</Field>
|
|
148
|
+
</Card>
|
|
149
|
+
</Grid>;
|
|
150
|
+
}`,...(O=(G=V.parameters)==null?void 0:G.docs)==null?void 0:O.source},description:{story:"Story",...(z=(Q=V.parameters)==null?void 0:Q.docs)==null?void 0:z.description}}};const pt=["UnitTablePrototype"];export{V as UnitTablePrototype,pt as __namedExportsOrder,ct as default};
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
window.STORIES = [{"titlePrefix":"","directory":"./src/components","files":"**/*.mdx","importPathMatcher":"^\\.[\\\\/](?:src\\/components(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.mdx)$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];
|
|
23
23
|
window.DOCS_OPTIONS = {"defaultName":"Docs","autodocs":true};
|
|
24
24
|
|
|
25
|
+
|
|
26
|
+
|
|
25
27
|
// We do this so that "module && module.hot" etc. in Storybook source code
|
|
26
28
|
// doesn't fail (it will simply be disabled)
|
|
27
29
|
window.module = undefined;
|
|
@@ -357,7 +359,7 @@
|
|
|
357
359
|
}
|
|
358
360
|
</script>
|
|
359
361
|
|
|
360
|
-
<script type="module" crossorigin src="./assets/iframe-
|
|
362
|
+
<script type="module" crossorigin src="./assets/iframe-oMAlwWd9.js"></script>
|
|
361
363
|
</head>
|
|
362
364
|
|
|
363
365
|
<body>
|