@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.
- package/dist/index.d.ts +54 -0
- package/dist/index.js +151 -1
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/Color-6VNJS4EI-e16af034.js +1 -0
- package/dist/storybook/assets/DocsRenderer-NNNQARDV-eaf66766.js +1 -0
- package/dist/storybook/assets/WithTooltip-4HIR6TLV-86dbd99d.js +1 -0
- package/dist/storybook/assets/{accordion-168fa7c5.js → accordion-1b587708.js} +1 -1
- package/dist/storybook/assets/accordion-with-default-toggle-775c8135.js +1 -0
- package/dist/storybook/assets/accordion.stories-a9cecbe0.js +170 -0
- package/dist/storybook/assets/{actions-2d4e1c8e.js → actions-83a2a04e.js} +1 -1
- package/dist/storybook/assets/{actions.stories-81a7cb7a.js → actions.stories-a38cd26e.js} +1 -1
- package/dist/storybook/assets/{afe.stories-afb9be07.js → afe.stories-e25ea064.js} +2 -2
- package/dist/storybook/assets/{badge.stories-5ce7957f.js → badge.stories-1cbf35f9.js} +1 -1
- package/dist/storybook/assets/{blowout.stories-ee7f932b.js → blowout.stories-af7f9432.js} +1 -1
- package/dist/storybook/assets/breadcrumb-f8742fbd.js +1 -0
- package/dist/storybook/assets/breadcrumb.stories-b5582cfb.js +1 -0
- package/dist/storybook/assets/{button-74c97e4a.js → button-050c998a.js} +1 -1
- package/dist/storybook/assets/{button-group-fa895d0c.js → button-group-0176fca3.js} +1 -1
- package/dist/storybook/assets/{button-group.stories-22f072b7.js → button-group.stories-7659a587.js} +1 -1
- package/dist/storybook/assets/{button.stories-9b954335.js → button.stories-5f73ddef.js} +1 -1
- package/dist/storybook/assets/buttons-and-links-153efc05.js +14 -0
- package/dist/storybook/assets/{card.stories-537a1772.js → card.stories-0437a4e2.js} +1 -1
- package/dist/storybook/assets/casing-loads.stories-90bc0b91.js +209 -0
- package/dist/storybook/assets/{cell.stories-524a7418.js → cell.stories-0ae4bf08.js} +2 -2
- package/dist/storybook/assets/{check-box-e21258d5.js → check-box-b38490e5.js} +1 -1
- package/dist/storybook/assets/{check-box.stories-5f7d06e0.js → check-box.stories-9bf1c260.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-6a96cff0.js → chunk-HLWAVYOI-64001074.js} +1 -1
- package/dist/storybook/assets/color-e82f5009.js +25 -0
- package/dist/storybook/assets/{column.stories-ae7588c5.js → column.stories-d5ca2c42.js} +1 -1
- package/dist/storybook/assets/{drawer-7f450988.js → drawer-308b0a03.js} +1 -1
- package/dist/storybook/assets/{drawer.stories-39625e91.js → drawer.stories-724ec941.js} +2 -2
- package/dist/storybook/assets/empty-2d83d50b.js +1 -0
- package/dist/storybook/assets/empty.stories-1871df42.js +1 -0
- package/dist/storybook/assets/extends-98964cd2.js +1 -0
- package/dist/storybook/assets/{field-a094cd72.js → field-248df38c.js} +1 -1
- package/dist/storybook/assets/{field.stories-f1318053.js → field.stories-60d1a82f.js} +1 -1
- package/dist/storybook/assets/file-input-31a9b5bf.js +1 -0
- package/dist/storybook/assets/file-input.stories-dbedc9fc.js +55 -0
- package/dist/storybook/assets/{flex.stories-09e9c602.js → flex.stories-6a278b40.js} +1 -1
- package/dist/storybook/assets/footer.stories-50a2e3db.js +3 -0
- package/dist/storybook/assets/form.stories-2184d699.js +49 -0
- package/dist/storybook/assets/formation.stories-e27935eb.js +74 -0
- package/dist/storybook/assets/{formatter-SWP5E3XI-06c7911e.js → formatter-SWP5E3XI-598bdf16.js} +2 -2
- package/dist/storybook/assets/{preview-d47a2f40.css → global-aa71ac9c.css} +1 -1
- package/dist/storybook/assets/{heading-d29eb744.js → heading-39e599c8.js} +1 -1
- package/dist/storybook/assets/{heading.stories-9689bddc.js → heading.stories-6ff7f5ed.js} +1 -1
- package/dist/storybook/assets/{help-icon-d4189b1b.js → help-icon-c0abd380.js} +1 -1
- package/dist/storybook/assets/{help-icon.stories-15d1620d.js → help-icon.stories-a30b7058.js} +1 -1
- package/dist/storybook/assets/icon-8acf9925.js +8 -0
- package/dist/storybook/assets/{icon.stories-8dae69e1.js → icon.stories-466d158f.js} +1 -1
- package/dist/storybook/assets/iframe-2ec6fd1b.js +1 -0
- package/dist/storybook/assets/{index-97b8789c.js → index-85e6b336.js} +4 -4
- package/dist/storybook/assets/{index.es-85cc7dfc.js → index.es-37e2ce0d.js} +4 -4
- package/dist/storybook/assets/inheritsLoose-c82a83d4.js +1 -0
- package/dist/storybook/assets/{input-d68625a5.js → input-05f21b51.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-a2a3400e.js → input-group.stories-602e1e93.js} +2 -2
- package/dist/storybook/assets/{input-validation-64e7abcc.js → input-validation-83a841e7.js} +2 -2
- package/dist/storybook/assets/{input.stories-164d93ab.js → input.stories-bf58ba7c.js} +1 -1
- package/dist/storybook/assets/{inputs-e48e1acb.js → inputs-679d81e4.js} +14 -14
- package/dist/storybook/assets/{label-13d490a3.js → label-e6d15b59.js} +1 -1
- package/dist/storybook/assets/{label.stories-427ba162.js → label.stories-1c98204a.js} +1 -1
- package/dist/storybook/assets/layout-forms-9382a8d3.js +16 -0
- package/dist/storybook/assets/{layout-general-545e69b0.js → layout-general-cab7e55d.js} +2 -2
- package/dist/storybook/assets/{list-0dc3df85.js → list-d40713ca.js} +1 -1
- package/dist/storybook/assets/{list.stories-5715452e.js → list.stories-5daa007f.js} +2 -2
- package/dist/storybook/assets/{list.stories-data-94f7c623.js → list.stories-data-ba40864f.js} +1 -1
- package/dist/storybook/assets/{loader.stories-6107832a.js → loader.stories-4e8e8df7.js} +1 -1
- package/dist/storybook/assets/{menu.stories-927adf3d.js → menu.stories-8d724757.js} +1 -1
- package/dist/storybook/assets/{message-7e627e60.js → message-f4352d69.js} +1 -1
- package/dist/storybook/assets/{message.stories-f41a0c22.js → message.stories-bb7952c5.js} +1 -1
- package/dist/storybook/assets/meta-content-c2771b33.js +1 -0
- package/dist/storybook/assets/modal-90ebced9.js +1 -0
- package/dist/storybook/assets/modal-f1e8e468.css +1 -0
- package/dist/storybook/assets/{modal.stories-0e068cc1.js → modal.stories-24646454.js} +2 -2
- package/dist/storybook/assets/{number-input-7d49b0b3.js → number-input-cfbd9eb7.js} +1 -1
- package/dist/storybook/assets/{number-input.stories-02528124.js → number-input.stories-8137782e.js} +2 -2
- package/dist/storybook/assets/option-dropdown-14e7d023.js +1 -0
- package/dist/storybook/assets/option-dropdown.stories-f251610f.js +21 -0
- package/dist/storybook/assets/{padding-and-spacing-7aefd342.js → padding-and-spacing-89974d3f.js} +2 -2
- package/dist/storybook/assets/page.stories-7a6f330e.js +57 -0
- package/dist/storybook/assets/{pagination-8aade846.js → pagination-443065a8.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-423b4938.js → pagination.stories-985230f7.js} +2 -2
- package/dist/storybook/assets/pop-confirm-ce206de8.js +1 -0
- package/dist/storybook/assets/pop-confirm.stories-5772f622.js +7 -0
- package/dist/storybook/assets/{popover-06e375a5.js → popover-c1234faa.js} +1 -1
- package/dist/storybook/assets/popover.stories-7542a367.js +1 -0
- package/dist/storybook/assets/preview-65e4021c.js +1 -0
- package/dist/storybook/assets/preview-a5b25924.css +1 -0
- package/dist/storybook/assets/{preview-88cc5d68.js → preview-a99e63ce.js} +3 -3
- package/dist/storybook/assets/print-header-bd013690.js +1 -0
- package/dist/storybook/assets/projects.stories-f8294ed5.js +47 -0
- package/dist/storybook/assets/{radio-button-135a9615.js → radio-button-d69b72e4.js} +1 -1
- package/dist/storybook/assets/{radio-button.stories-0e8377ea.js → radio-button.stories-6ff0dc9b.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-6b14a37f.js → reservoirs.stories-80ad2f26.js} +2 -2
- package/dist/storybook/assets/{rich-text-input.stories-661f34f1.js → rich-text-input-a0f4a598.js} +52 -127
- package/dist/storybook/assets/rich-text-input.stories-988bbe20.js +76 -0
- package/dist/storybook/assets/{row.stories-d5b6b4a6.js → row.stories-c12a3e52.js} +2 -2
- package/dist/storybook/assets/select-d4593fc0.js +1 -0
- package/dist/storybook/assets/{select.stories-60f055e6.js → select.stories-6651d3f2.js} +2 -2
- package/dist/storybook/assets/{side-bar-88e8cf41.js → side-bar-10cceacd.js} +1 -1
- package/dist/storybook/assets/{side-bar.stories-2c06f8a6.js → side-bar.stories-02211e0d.js} +1 -1
- package/dist/storybook/assets/{site.stories-dee8ce1c.js → site.stories-284e27be.js} +2 -2
- package/dist/storybook/assets/slider-5d5442fe.js +7 -0
- package/dist/storybook/assets/{slider.stories-79ab0e97.js → slider.stories-a55df653.js} +2 -2
- package/dist/storybook/assets/{spacer.stories-38071af8.js → spacer.stories-a2798d47.js} +1 -1
- package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-007a6982.js +1 -0
- package/dist/storybook/assets/{table-da6f6045.js → table-134da40b.js} +1 -1
- package/dist/storybook/assets/{table.stories-67a3023a.js → table.stories-8dd2a568.js} +2 -2
- package/dist/storybook/assets/{table.stories-data-8a836b92.js → table.stories-data-ddbcf8c3.js} +1 -1
- package/dist/storybook/assets/text-link-f4589768.js +1 -0
- package/dist/storybook/assets/text-link.stories-6b7c8329.js +1 -0
- package/dist/storybook/assets/{textarea-d48efea2.js → textarea-820c62b6.js} +1 -1
- package/dist/storybook/assets/{textarea.stories-89c8afd7.js → textarea.stories-aeaa9aa0.js} +1 -1
- package/dist/storybook/assets/{title.stories-5b4a226c.js → title.stories-2ba6aa87.js} +2 -2
- package/dist/storybook/assets/{toaster-541ce85b.js → toaster-55ac121d.js} +1 -1
- package/dist/storybook/assets/{toaster.stories-5e4d95b1.js → toaster.stories-28d11f39.js} +1 -1
- package/dist/storybook/assets/{toggle-bb34b2a2.js → toggle-6f4d5797.js} +1 -1
- package/dist/storybook/assets/{toggle.stories-b771ed81.js → toggle.stories-a289f544.js} +1 -1
- package/dist/storybook/assets/{tooltip-23e84186.js → tooltip-856042a7.js} +1 -1
- package/dist/storybook/assets/{tooltip.stories-e8ba5fff.js → tooltip.stories-666868d0.js} +1 -1
- package/dist/storybook/assets/{tooltip.test-case.stories-9817078b.js → tooltip.test-case.stories-4c1ea273.js} +1 -1
- package/dist/storybook/assets/{top-bar-a84b9365.js → top-bar-38689fe2.js} +1 -1
- package/dist/storybook/assets/{top-bar.stories-e93330f0.js → top-bar.stories-3d9a6da1.js} +1 -1
- package/dist/storybook/assets/{top-bar.testcase.stories-3a824a14.js → top-bar.testcase.stories-dc051455.js} +1 -1
- package/dist/storybook/assets/tree-a2bbc2e4.js +6 -0
- package/dist/storybook/assets/tree.stories-0e132447.js +123 -0
- package/dist/storybook/assets/unit-input-c16535f7.js +1 -0
- package/dist/storybook/assets/unit-input.stories-0f7705d6.js +273 -0
- package/dist/storybook/assets/unit-table.stories-71ef347c.js +229 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/stories.json +1 -1
- package/package.json +1 -1
- package/dist/404.html +0 -1
- package/dist/storybook/assets/Color-6VNJS4EI-11a1508d.js +0 -1
- package/dist/storybook/assets/DocsRenderer-NNNQARDV-8f214a0a.js +0 -1
- package/dist/storybook/assets/WithTooltip-4HIR6TLV-bcdb019a.js +0 -1
- package/dist/storybook/assets/accordion.stories-0f8af16e.js +0 -170
- package/dist/storybook/assets/breadcrumb.stories-e4334a75.js +0 -1
- package/dist/storybook/assets/buttons-and-links-72daa9ae.js +0 -14
- package/dist/storybook/assets/casing-loads.stories-cfbab702.js +0 -209
- package/dist/storybook/assets/color-9bdf643a.js +0 -25
- package/dist/storybook/assets/dialog-8e840c50.css +0 -1
- package/dist/storybook/assets/dialog-cd58dd09.js +0 -1
- package/dist/storybook/assets/empty.stories-e0e3ac78.js +0 -1
- package/dist/storybook/assets/file-input.stories-1c6ce0ea.js +0 -55
- package/dist/storybook/assets/footer.stories-57f07ea2.js +0 -3
- package/dist/storybook/assets/form.stories-45c0cd59.js +0 -49
- package/dist/storybook/assets/formation.stories-5eeaa826.js +0 -74
- package/dist/storybook/assets/icon-e9cbb4d7.js +0 -8
- package/dist/storybook/assets/iframe-c1fab5c5.js +0 -1
- package/dist/storybook/assets/inheritsLoose-d4851ab8.js +0 -1
- package/dist/storybook/assets/layout-forms-289235b9.js +0 -16
- package/dist/storybook/assets/list-heading-88cc8a9b.js +0 -1
- package/dist/storybook/assets/option-dropdown.stories-5030bdb8.js +0 -21
- package/dist/storybook/assets/page.stories-7cb68fed.js +0 -57
- package/dist/storybook/assets/pop-confirm.stories-81b30901.js +0 -7
- package/dist/storybook/assets/popover.stories-f651a81c.js +0 -1
- package/dist/storybook/assets/preview-5405e1e8.js +0 -1
- package/dist/storybook/assets/projects.stories-3884a80c.js +0 -47
- package/dist/storybook/assets/select-205cd538.js +0 -1
- package/dist/storybook/assets/slider-160e2152.js +0 -7
- package/dist/storybook/assets/syntaxhighlighter-NMPM6SWI-5e884b35.js +0 -1
- package/dist/storybook/assets/text-link.stories-c1227c6f.js +0 -1
- package/dist/storybook/assets/tree.stories-590bdd69.js +0 -128
- package/dist/storybook/assets/unit-input.stories-50ac8b0f.js +0 -257
- /package/dist/storybook/assets/{accordion.stories-e92bccf3.css → accordion-with-default-toggle-e92bccf3.css} +0 -0
- /package/dist/storybook/assets/{breadcrumb.stories-a644544e.css → breadcrumb-a644544e.css} +0 -0
- /package/dist/storybook/assets/{empty.stories-9914c767.css → empty-9914c767.css} +0 -0
- /package/dist/storybook/assets/{file-input.stories-f40408e6.css → file-input-f40408e6.css} +0 -0
- /package/dist/storybook/assets/{list-heading-d7e578fa.css → meta-content-d7e578fa.css} +0 -0
- /package/dist/storybook/assets/{option-dropdown.stories-ddc96b15.css → option-dropdown-ddc96b15.css} +0 -0
- /package/dist/storybook/assets/{pop-confirm.stories-c9faec6b.css → pop-confirm-c9faec6b.css} +0 -0
- /package/dist/storybook/assets/{page.stories-dd8c1b35.css → print-header-dd8c1b35.css} +0 -0
- /package/dist/storybook/assets/{rich-text-input.stories-023a1c99.css → rich-text-input-023a1c99.css} +0 -0
- /package/dist/storybook/assets/{tree.stories-3406c5f6.css → tree-3406c5f6.css} +0 -0
- /package/dist/storybook/assets/{unit-input.stories-c251e2c8.css → unit-input-c251e2c8.css} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import{j as r}from"./jsx-runtime-f961835c.js";import{r as n}from"./index-f80c8c95.js";import{T as re,a as se}from"./icon-8acf9925.js";import{T as h}from"./tree-a2bbc2e4.js";import{T as oe}from"./text-ad1f5f1d.js";import{B as ie}from"./button-050c998a.js";import"./index-a80ed1cf.js";import"./inheritsLoose-c82a83d4.js";import"./tslib.es6-dfef685f.js";import"./index-c89a1915.js";import"./disabled-context-d654f6ff.js";import"./index-54f0d271.js";import"./common-types-2c81813f.js";import"./meta-content-c2771b33.js";import"./heading-39e599c8.js";import"./help-icon-c0abd380.js";import"./tooltip-856042a7.js";import"./index-3d476d02.js";import"./actions-83a2a04e.js";import"./lodash-75c70a11.js";import"./types-cc224262.js";import"./types-332ceaf3.js";import"./badge-20e7ee0b.js";import"./redux-10ee6be7.js";import"./objectSpread2-fdee9b6d.js";import"./spinner-a81ebe38.js";const s={name:"Animals",items:[{id:1,parent:0,droppable:!0,name:"Mammals",onClick:()=>console.log("Test")},{id:2,parent:1,droppable:!0,name:"Cats"},{id:3,parent:1,droppable:!0,name:"Dogs"},{id:4,parent:0,droppable:!0,name:"Amphibians"},{id:5,parent:4,droppable:!0,name:"Frogs"},{id:6,parent:0,droppable:!0,name:"Reptiles",active:!0}]},pe={...s,header:{actions:[{label:"Add",primary:!0,icon:"add",onClick:()=>{}}]},items:s.items.map(e=>({...e,actions:[{label:"Delete",icon:"delete",onClick:()=>{}}]}))},me={...s,items:s.items.map(e=>({...e,droppable:e.parent===0,details:e.parent===0?"Droppable":"Not droppable"}))},de={...s,items:s.items.map(e=>({...e,parent:0,droppable:!1}))},He={title:"Basic/Tree",component:h,args:{list:s}},a=e=>r.jsx(h,{...e}),T=a.bind({}),d=a.bind({});d.args={list:pe};const l=a.bind({});l.args={draggable:!0};const p=a.bind({});p.args={draggable:!0,list:me};p.parameters={docs:{description:{story:"Use the `droppable` prop to specify which items can have other items dropped into them."}}};const c=a.bind({});c.args={draggable:!0,list:de};const u=a.bind({});u.args={isInitialOpen:!0};const g=a.bind({});g.args={onChangeOpen:e=>console.log("onChangeOpen here",e)};const C=()=>{const[e,x]=n.useState([{id:1,parent:0,droppable:!0,name:"Mammals"},{id:2,parent:1,droppable:!0,name:"Cats"},{id:3,parent:1,droppable:!0,name:"Dogs"},{id:4,parent:0,droppable:!0,name:"Amphibians"},{id:5,parent:4,droppable:!0,name:"Frogs"},{id:6,parent:0,droppable:!0,name:"Reptiles"}]),o=()=>{const f={id:Math.max(...e.map(L=>L.id))+1,parent:0,droppable:!0,name:"New Item"};x([f].concat(e))},I={name:"Animals",actions:[{label:"Add",primary:!0,icon:"add",onClick:()=>o()}],items:e};return r.jsx(h,{list:I,draggable:!0,onListReorder:x})},le=[{id:1,parent:0,droppable:!0,name:"Mammals",onClick:()=>console.log("Test")},{id:4,parent:0,droppable:!0,name:"Amphibians"},{id:6,parent:0,droppable:!0,name:"Reptiles",active:!0}],ce=[{id:2,parent:1,droppable:!0,name:"Cats"},{id:3,parent:1,droppable:!0,name:"Dogs"},{id:5,parent:4,droppable:!0,name:"Frogs"}],S=()=>{const[e,x]=n.useState(le),[o,I]=n.useState({}),f=n.useRef(0);n.useEffect(()=>()=>clearTimeout(f.current),[]);const L=t=>t.parent===0,te=n.useCallback((t,i)=>{I(m=>({...m,[t.id]:{isOpen:i,isLoading:i}})),i&&(console.log("Loading"),f.current=window.setTimeout(()=>{console.log("Loaded"),x(m=>m.filter(A=>A.parent!==t.id).concat(ce.filter(A=>A.parent===t.id))),I(m=>({...m,[t.id]:{isOpen:i,isLoading:!1}}))},1e3))},[]),ae=n.useMemo(()=>Object.keys(o).filter(t=>o[+t].isOpen).map(t=>{const i=o[+t];return{id:`${t}_extra`,parent:+t,name:i.isLoading?r.jsx(oe,{muted:!0,children:"Loading..."}):r.jsx(ie,{label:"Load more...",onClick:()=>console.log(`Load more for parent ${t}`)})}}),[o]),ne={name:"Animals",items:e.concat(ae)};return r.jsx(h,{list:ne,itemHasChild:L,onItemToggle:te})},b=a.bind({});b.args={icons:{expand:r.jsx(re,{}),collapse:r.jsx(se,{})}};var j,O,k;T.parameters={...T.parameters,docs:{...(j=T.parameters)==null?void 0:j.docs,source:{originalSource:`args => <Tree
|
|
2
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
3
|
+
{...args} />`,...(k=(O=T.parameters)==null?void 0:O.docs)==null?void 0:k.source}}};var y,D,R;d.parameters={...d.parameters,docs:{...(y=d.parameters)==null?void 0:y.docs,source:{originalSource:`args => <Tree
|
|
4
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
5
|
+
{...args} />`,...(R=(D=d.parameters)==null?void 0:D.docs)==null?void 0:R.source}}};var w,M,F;l.parameters={...l.parameters,docs:{...(w=l.parameters)==null?void 0:w.docs,source:{originalSource:`args => <Tree
|
|
6
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
7
|
+
{...args} />`,...(F=(M=l.parameters)==null?void 0:M.docs)==null?void 0:F.source}}};var v,E,B;p.parameters={...p.parameters,docs:{...(v=p.parameters)==null?void 0:v.docs,source:{originalSource:`args => <Tree
|
|
8
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
9
|
+
{...args} />`,...(B=(E=p.parameters)==null?void 0:E.docs)==null?void 0:B.source}}};var N,_,H;c.parameters={...c.parameters,docs:{...(N=c.parameters)==null?void 0:N.docs,source:{originalSource:`args => <Tree
|
|
10
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
11
|
+
{...args} />`,...(H=(_=c.parameters)==null?void 0:_.docs)==null?void 0:H.source}}};var $,U,z;u.parameters={...u.parameters,docs:{...($=u.parameters)==null?void 0:$.docs,source:{originalSource:`args => <Tree
|
|
12
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
13
|
+
{...args} />`,...(z=(U=u.parameters)==null?void 0:U.docs)==null?void 0:z.source}}};var G,P,q;g.parameters={...g.parameters,docs:{...(G=g.parameters)==null?void 0:G.docs,source:{originalSource:`args => <Tree
|
|
14
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
15
|
+
{...args} />`,...(q=(P=g.parameters)==null?void 0:P.docs)==null?void 0:q.source}}};var J,K,Q;C.parameters={...C.parameters,docs:{...(J=C.parameters)==null?void 0:J.docs,source:{originalSource:`() => {
|
|
16
|
+
const [items, setItems] = useState([{
|
|
17
|
+
id: 1,
|
|
18
|
+
parent: 0,
|
|
19
|
+
droppable: true,
|
|
20
|
+
name: 'Mammals'
|
|
21
|
+
}, {
|
|
22
|
+
id: 2,
|
|
23
|
+
parent: 1,
|
|
24
|
+
droppable: true,
|
|
25
|
+
name: 'Cats'
|
|
26
|
+
}, {
|
|
27
|
+
id: 3,
|
|
28
|
+
parent: 1,
|
|
29
|
+
droppable: true,
|
|
30
|
+
name: 'Dogs'
|
|
31
|
+
}, {
|
|
32
|
+
id: 4,
|
|
33
|
+
parent: 0,
|
|
34
|
+
droppable: true,
|
|
35
|
+
name: 'Amphibians'
|
|
36
|
+
}, {
|
|
37
|
+
id: 5,
|
|
38
|
+
parent: 4,
|
|
39
|
+
droppable: true,
|
|
40
|
+
name: 'Frogs'
|
|
41
|
+
}, {
|
|
42
|
+
id: 6,
|
|
43
|
+
parent: 0,
|
|
44
|
+
droppable: true,
|
|
45
|
+
name: 'Reptiles'
|
|
46
|
+
}]);
|
|
47
|
+
const addItem = () => {
|
|
48
|
+
const newItem = {
|
|
49
|
+
id: Math.max(...items.map(item => item.id)) + 1,
|
|
50
|
+
parent: 0,
|
|
51
|
+
droppable: true,
|
|
52
|
+
name: 'New Item'
|
|
53
|
+
};
|
|
54
|
+
setItems([newItem].concat(items));
|
|
55
|
+
};
|
|
56
|
+
const list = {
|
|
57
|
+
name: 'Animals',
|
|
58
|
+
actions: [{
|
|
59
|
+
label: 'Add',
|
|
60
|
+
primary: true,
|
|
61
|
+
icon: 'add',
|
|
62
|
+
onClick: () => addItem()
|
|
63
|
+
}],
|
|
64
|
+
items
|
|
65
|
+
};
|
|
66
|
+
return <Tree list={list} draggable onListReorder={setItems} />;
|
|
67
|
+
}`,...(Q=(K=C.parameters)==null?void 0:K.docs)==null?void 0:Q.source}}};var V,W,X;S.parameters={...S.parameters,docs:{...(V=S.parameters)==null?void 0:V.docs,source:{originalSource:`() => {
|
|
68
|
+
const [items, setItems] = useState<Item[]>(itemsAnimalClasses);
|
|
69
|
+
const [itemsState, setItemsState] = useState<Record<number, {
|
|
70
|
+
isOpen: boolean;
|
|
71
|
+
isLoading: boolean;
|
|
72
|
+
}>>({});
|
|
73
|
+
const timerRef = useRef<number>(0);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
// Clear the timeout when the component unmounts
|
|
76
|
+
return () => clearTimeout(timerRef.current);
|
|
77
|
+
}, []);
|
|
78
|
+
const itemHasChild = (data: NodeModel<any>): boolean => {
|
|
79
|
+
return data.parent === 0;
|
|
80
|
+
};
|
|
81
|
+
const onItemToggle = useCallback((item: NodeModel<any>, isOpen: boolean) => {
|
|
82
|
+
// simulate action that is loading items
|
|
83
|
+
setItemsState(prevItemsState => ({
|
|
84
|
+
...prevItemsState,
|
|
85
|
+
[item.id]: {
|
|
86
|
+
isOpen,
|
|
87
|
+
isLoading: isOpen
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
if (!isOpen) return;
|
|
91
|
+
console.log('Loading');
|
|
92
|
+
timerRef.current = window.setTimeout(() => {
|
|
93
|
+
// Use window.setTimeout for correct type
|
|
94
|
+
console.log('Loaded');
|
|
95
|
+
setItems(currentItems => currentItems.filter(existingItem => existingItem.parent !== item.id) // Use item.id here
|
|
96
|
+
.concat(itemsAnimalGroups.filter(groupItem => groupItem.parent === item.id)) // And here
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
setItemsState(prevItemsState => ({
|
|
100
|
+
...prevItemsState,
|
|
101
|
+
[item.id]: {
|
|
102
|
+
isOpen,
|
|
103
|
+
isLoading: false
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
}, 1000);
|
|
107
|
+
}, []);
|
|
108
|
+
const extraItems = useMemo(() => Object.keys(itemsState).filter(id => itemsState[+id].isOpen).map(id => {
|
|
109
|
+
const state = itemsState[+id];
|
|
110
|
+
return {
|
|
111
|
+
id: \`\${id}_extra\`,
|
|
112
|
+
parent: +id,
|
|
113
|
+
name: state.isLoading ? <Text muted>Loading...</Text> : <Button label="Load more..." onClick={() => console.log(\`Load more for parent \${id}\`)} />
|
|
114
|
+
};
|
|
115
|
+
}), [itemsState]);
|
|
116
|
+
const list = {
|
|
117
|
+
name: 'Animals',
|
|
118
|
+
items: items.concat(extraItems)
|
|
119
|
+
};
|
|
120
|
+
return <Tree list={list} itemHasChild={itemHasChild} onItemToggle={onItemToggle} />;
|
|
121
|
+
}`,...(X=(W=S.parameters)==null?void 0:W.docs)==null?void 0:X.source}}};var Y,Z,ee;b.parameters={...b.parameters,docs:{...(Y=b.parameters)==null?void 0:Y.docs,source:{originalSource:`args => <Tree
|
|
122
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
123
|
+
{...args} />`,...(ee=(Z=b.parameters)==null?void 0:Z.docs)==null?void 0:ee.source}}};const $e=["Default","Actions","Draggable","Droppable","Flat","ExpandedByDefault","OnOpenChangeCallback","Managed","LazyLoading","CustomIcons"];export{d as Actions,b as CustomIcons,T as Default,l as Draggable,p as Droppable,u as ExpandedByDefault,c as Flat,S as LazyLoading,C as Managed,g as OnOpenChangeCallback,$e as __namedExportsOrder,He as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as d}from"./jsx-runtime-f961835c.js";import{r as g}from"./index-f80c8c95.js";import{d as n,r as De}from"./index-57d7693e.js";import{c as we}from"./index-a80ed1cf.js";import{M as te}from"./actions-83a2a04e.js";import{I as Ce}from"./input-group-addon-f8f6683a.js";import{B as xe}from"./button-050c998a.js";import{T as Me}from"./tooltip-856042a7.js";import{I as Pe}from"./input-group-20c3add3.js";import{S as Se}from"./spacer-54db0620.js";import{T as Ae}from"./text-ad1f5f1d.js";import{I as Oe}from"./input-05f21b51.js";import{M as ne}from"./types-cc224262.js";import{l as b}from"./lodash-75c70a11.js";const Re=()=>{const e=g.useRef(null);return g.useLayoutEffect(()=>{e.current&&(e.current(),e.current=null)}),l=>{e.current=l}},je=e=>{const i=g.useRef();return g.useEffect(()=>{i.current=e},[e]),i.current},Fe=(e,i)=>{const l=i==null?void 0:i[e];return l||(console.log(`Warning: 'unitTemplate' does not define a preferred unit for '${e}'. Defaulting to standard unit.`),n.unitFromQuantity(e)??"")};var o=(e=>(e.CUSTOM="custom",e.PREDEFINED="predefined",e))(o||{});const se=e=>e==="undefined"||e===void 0||e===""||e==="null"||e===null||e==="NaN"||isNaN(e),ue=(e="",i,l="",v=!1)=>{if(v)return e;if(i&&!se(e))try{const p=n.isValueWithUnit(e)?e:n.withUnit(e,l),m=n.convertSamePrecision(p,i);return n.getValue(m)}catch{}return e},Te=e=>e?!!n.getUnit(e):!1,C=(e="",i,l,v)=>{if(v)return e;const p=Te(e)||n.isValueWithUnit(e),m=n.getValue(e);return se(m)?m:p?ue(m,i,l,v):e},ie=e=>b.isObject(e)&&!b.isArray(e)&&!b.isFunction(e)?b.get(e,"fieldName",""):typeof e=="string"?e:"",ke=e=>b.isObjectLike(e)&&b.has(e,"message"),We=e=>typeof e=="string"?e:ke(e)?e.message:null;var _e=De();const Le=e=>e.search(RegExp(/(^0{2}\.)|(^0+[1-9])/g))===0,re=(e,i)=>{var V;const{allowEmpty:l=!1,autoValue:v,placeholder:p,disabledValidation:m=!1}=i||{},y=String(e);if(m||v||p)return null;const N=_e.isValueWithUnit(y)?n.getValue(y):y;if(l&&N==="")return null;if(Le(N))return"Invalid number format due to leading zeroes";const a=n.validateNumber(N);if(!a.valid){const O=((V=a==null?void 0:a.errors)==null?void 0:V[0])??null;return We(O)}return null},ae=(e="")=>{var i;return(i=n.KNOWN_UNITS)==null?void 0:i.includes(e)},$e=(e,i)=>{const l=n.getUnit(e||"");return ae(i)&&ae(l)},He="_predefinedMenuActive_1yvt4_1",Ke={predefinedMenuActive:He},le=({name:e,placeholder:i="",disabled:l=!1,disabledUnit:v=!1,error:p=null,left:m=!1,small:y=!1,width:N="100%",value:a,unitkey:V="",initUnit:O,noConversion:oe=!1,onChange:R=()=>{},onClick:Be=()=>{},onFocus:de=()=>{},onSwitchUnit:L=()=>{},unitTemplate:$,doNotConvertValue:q=!1,testId:I,warning:ce=null,predefinedOptions:U,initialPredefinedOption:fe=!1,shouldLinkAutomaticly:H=!0,selectedPredefinedOptionKey:K,validationCallback:B=()=>({name:"",error:null}),disabledValidation:G=!1,allowEmpty:z=!1,autoValue:E})=>{typeof a=="number"&&(a=`${a}`);const pe=Re(),[j="",D=""]=a!==void 0?n.split(a):[],Q=E?n.getUnit(E):"",Z=g.useMemo(()=>Fe(V,$),[V,$]),me=$e(a,Z),c=O||Z||D,ge=je(c),J=C(a,c,D,q),X=C(E,c,Q,q),ve=J!==""?{value:J,unit:c}:X!==""?{value:X,unit:c}:{value:j,unit:D},[s,x]=g.useState(ve),[ye,F]=g.useState(null),[h,T]=g.useState(fe?o.PREDEFINED:o.CUSTOM),k=j===""&&E,w=U&&U.find(t=>{if(K)return K===t.valueKey;const r=n.isValueWithUnit(t.value)?n.getUnit(t.value):"";return n.withUnit(ue(a,r),r)===t.value}),Ue=()=>{if(V)try{const t=k?E:a??"";let r=n.altUnitsList(t,V);return n.getValue(t)===""?r.map(u=>["",u[1]]):r}catch{return null}},Ee=t=>{const r=ie(e),u=t.target,{value:f,selectionStart:A}=u,ee=n.cleanNumStr(f.replaceAll(" ","").replaceAll("|","")),W=n.withUnit(ee,(s==null?void 0:s.unit)||""),be=n.getValue(W),_=re(be,{allowEmpty:z,autoValue:E,placeholder:i,disabledValidation:G});if(_===null){R({target:{value:W,name:r}});const[Ne,qe]=n.split(W);x({value:Ne,unit:qe}),F(null),B(r,null)}else x({value:ee,unit:s.unit}),F(_),B(r,_);pe(()=>{u.selectionStart=A,u.selectionEnd=A})},Ve=(t,r)=>{r===s.unit||isNaN(Number(t))||(x({value:t,unit:r}),L&&L(r))};g.useEffect(()=>{if(c){let u,f="";ge!==c?(u=C(a,c,D,q),f=c):n.withUnit(s.value,s.unit)!==a&&(u=C(a,s.unit,D,q),f=s.unit),u!==void 0&&x({value:u,unit:f}),U&&T(w&&H?o.PREDEFINED:o.CUSTOM)}const t=n.checkAndCleanDecimalComma(j),r=re(t,{allowEmpty:z,autoValue:E,placeholder:i,disabledValidation:G});F(r)},[c,a,p,H]);const M=Ue(),P=n.label(s.unit)||s.unit||"",he=oe||!M||M&&M.length===1,Y=ie(e);let S;const Ie=t=>{const[r,u=""]=n.isValueWithUnit(t.value)?n.split(t.value):[t.value];return{type:ne.OPTION,inline:!0,onClick:()=>{n.validateNumber(r).valid&&!l&&(T(o.PREDEFINED),R({target:{value:t.value,name:typeof e=="string"?e:(e==null?void 0:e.fieldName)||"",predefinedSelected:!0,predefinedOption:t}}))},label:d.jsxs(d.Fragment,{children:[d.jsx(Ae,{children:t.label}),d.jsx(Se,{width:"20px",height:"0"})]}),description:n.isValueWithUnit(t.value)?`${r} ${u}`:t.value,selected:w===t&&h===o.PREDEFINED}};if(S=[{type:ne.OPTION,inline:!0,onClick:()=>{h!==o.CUSTOM&&!l&&R({target:{value:n.withUnit(s.value,s.unit),name:typeof e=="string"?e:(e==null?void 0:e.fieldName)||""}})},label:"Custom",selected:h===o.CUSTOM}],U!=null&&U.length){const t=U.map(Ie);S=[...S,...t]}return d.jsx("div",{className:h===o.PREDEFINED?we(Ke.predefinedMenuActive):"",children:d.jsxs(Pe,{small:y,width:N,children:[U&&d.jsx(Me,{text:h===o.PREDEFINED?w==null?void 0:w.label:"",children:d.jsx(te,{maxHeight:380,groupOrder:"first",testId:I&&`${I}-predefined-menu`,disabled:l,menu:{colored:!0,trigger:"Component",component:d.jsx(xe,{groupOrder:"first",active:h===o.PREDEFINED,icon:h===o.PREDEFINED?"link":"unlink"}),small:y,sections:S}})}),d.jsx(Oe,{type:"text",name:Y,testId:I,disabled:l,placeholder:k?C(E,s.unit,Q,q):i,value:s.value,onChange:Ee,onFocus:de,error:p||ye,warning:ce,right:!m},Y),P&&(he||!me?d.jsx(Ce,{groupOrder:"last",children:P}):d.jsx(te,{maxHeight:380,groupOrder:"last",disabled:v,testId:I&&`${I}-menu`,menu:{label:P,trigger:"DropDownButton",small:y,sections:M.map(([t,r,u])=>{const f=u||r||"";return{type:"Option",label:isNaN(Number(t))?"":t,inline:!0,onClick:A=>{A.stopPropagation(),Ve(k?"":t,r)},description:f,selected:f===P,testId:`${I}-unit-${f}`}})}}))]})})};try{le.displayName="UnitInput",le.__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:"null"},description:"",name:"error",required:!1,type:{name:"string | boolean | null"}},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:"null"},description:"",name:"warning",required:!1,type:{name:"string | null"}},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:{value:"() => ({ name: '', error: null })"},description:"",name:"validationCallback",required:!1,type:{name:"((name: string, message: string | null) => { name: string; error: string | null; })"}},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>"}}}}}catch{}export{le as U};
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import{j as e}from"./jsx-runtime-f961835c.js";import{r as d}from"./index-f80c8c95.js";import{U as i}from"./unit-input-c16535f7.js";import{B as l}from"./button-050c998a.js";import{S as p}from"./spacer-54db0620.js";import{D as Je}from"./divider-182aa58c.js";import{R as ze,C as F}from"./row-2299f0e7.js";import{F as h}from"./field-248df38c.js";import{M as _}from"./message-f4352d69.js";import"./index-57d7693e.js";import"./index-54f0d271.js";import"./index-a80ed1cf.js";import"./actions-83a2a04e.js";import"./lodash-75c70a11.js";import"./common-types-2c81813f.js";import"./disabled-context-d654f6ff.js";import"./tooltip-856042a7.js";import"./index-3d476d02.js";import"./icon-8acf9925.js";import"./inheritsLoose-c82a83d4.js";import"./tslib.es6-dfef685f.js";import"./index-c89a1915.js";import"./types-cc224262.js";import"./types-332ceaf3.js";import"./badge-20e7ee0b.js";import"./input-group-addon-f8f6683a.js";import"./input-group-20c3add3.js";import"./text-ad1f5f1d.js";import"./input-05f21b51.js";import"./spinner-a81ebe38.js";import"./styled-components.browser.esm-416d73e5.js";import"./label-e6d15b59.js";import"./help-icon-c0abd380.js";const{useArgs:Ye}=__STORYBOOK_MODULE_ADDONS__,Ia={title:"Basic/UnitInput",component:i,args:{name:"example",unitkey:"length",value:"123|m"}},u=s=>{const[t,a]=Ye(),r=o=>{a({value:o.target.value})};return e.jsx(i,{...s,onChange:r})},N=u.bind({}),v=u.bind({});v.args={initUnit:"ft",unitTemplate:{length:"ft"}};const C=u.bind({});C.args={value:'123|"',unitkey:'"'};const b=u.bind({});b.args={width:"180px"};const x=u.bind({});x.args={noConversion:!0};const U=u.bind({});U.args={small:!0};const y=u.bind({});y.args={error:"Error message goes here"};const j=u.bind({});j.args={value:"asas123asd|%"};const m=u.bind({});m.args={disabled:!0,disabledUnit:!0};m.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=u.bind({});k.args={disabled:!0,disabledUnit:!0,noConversion:!0};const V=u.bind({});V.args={disabledUnit:!0,unitkey:void 0};const I=u.bind({});I.args={disabledUnit:!0,unitkey:"length"};const S=u.bind({});S.args={disabledUnit:!1,disabled:!0};const f=s=>{const[t,a]=d.useState("123|m"),[r,o]=d.useState("223|m"),[g,n]=d.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(l,{label:"Change initUnit",onClick:()=>n(g==="m"?"ft":"m")}),e.jsx(p,{}),e.jsx(l,{label:"Change value",onClick:()=>a(t==="123|m"?"456|m":"123|m")}),e.jsx(p,{}),e.jsx(i,{name:"example",onChange:c=>{a(c.target.value)},unitkey:"length",value:t,initUnit:g,onSwitchUnit:n}),e.jsx(p,{}),e.jsx(i,{name:"example2",onChange:c=>{o(c.target.value)},unitkey:"length",value:r,initUnit:g,onSwitchUnit:n}),e.jsx(Je,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(i,{name:"example",onChange:c=>{a(c.target.value)},unitkey:"length",value:t,onSwitchUnit:n}),e.jsx(i,{name:"example2",onChange:c=>{o(c.target.value)},unitkey:"length",value:r,onSwitchUnit:n})]})};f.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const w=u.bind({});w.args={predefinedOptions:[{label:"bottom of casing",value:"12|km"},{label:"mud weight at shoe depth",value:"8|mm"}]};const A=()=>{const s="500px",[t,a]=d.useState(void 0);return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different edge cases such as +/- infinity, undefined, NaN, null:"}),e.jsxs(ze,{children:[e.jsxs(F,{width:"25%",children:[e.jsx(l,{label:"Change value infinity",onClick:()=>a(1/0)}),e.jsx("br",{}),e.jsx(l,{label:"Change value -infinity",onClick:()=>a(-1/0)}),e.jsx("br",{}),e.jsx(l,{label:"Change value null",onClick:()=>a(null)}),e.jsx("br",{}),e.jsx(l,{label:"Change value - undefined",onClick:()=>a(void 0)}),e.jsx("br",{}),e.jsx(l,{label:"Change value - NaN",onClick:()=>a(NaN)}),e.jsx("br",{}),e.jsx(l,{label:"Change value - nothing (empty)",onClick:()=>a(void 0)}),e.jsx("br",{}),e.jsx(l,{label:"Change value - empty string",onClick:()=>a("")})]}),e.jsxs(F,{width:"25%",children:[e.jsx(l,{label:"Change value infinity|m",onClick:()=>a("Infinity|m")}),e.jsx("br",{}),e.jsx(l,{label:"Change value -infinity|m",onClick:()=>a("-Infinity|m")}),e.jsx("br",{}),e.jsx(l,{label:"Change value null|m",onClick:()=>a(null+"|m")}),e.jsx("br",{}),e.jsx(l,{label:"Change value - undefined|m",onClick:()=>a(void 0+"|m")}),e.jsx("br",{}),e.jsx(l,{label:"Change value - NaN|m",onClick:()=>a("NaN|m")}),e.jsx("br",{}),e.jsx(l,{label:"Change value - nothing (empty)|m",onClick:()=>a("|m")})]})]}),e.jsx("br",{}),e.jsx(h,{label:"Normal PUI",children:e.jsx(i,{name:"example1",onChange:r=>a(r.target.value),value:t,unitkey:"length",width:s,placeholder:"value|unit"})}),e.jsx(h,{label:"Disabled validation",children:e.jsx(i,{name:"example2",onChange:r=>a(r.target.value),value:t,unitkey:"length",disabledValidation:!0,width:s})}),e.jsx(h,{label:"Disabled validation and manual error",children:e.jsx(i,{name:"example3",onChange:r=>a(r.target.value),value:t,unitkey:"length",error:"test",disabledValidation:!0,width:s})}),e.jsx(_,{message:{heading:"Current value inside PUI: "+t,visible:!0}})]})},P=()=>{const s="500px",[t,a]=d.useState("1|m"),[r,o]=d.useState("|m"),g="123|km";return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Different cases for automatic (placeholder) values:"}),e.jsx(ze,{children:e.jsxs(F,{width:"25%",children:[e.jsx(l,{label:"Change value to ''",onClick:()=>a("")}),e.jsx("br",{}),e.jsx(l,{label:"Change value to 1",onClick:()=>a("1")}),e.jsx("br",{}),e.jsx(l,{label:"Change value to 1|m",onClick:()=>a("1|m")}),e.jsx("br",{}),e.jsx(l,{label:"Change value to |m - empty value",onClick:()=>a("|m")})]})}),e.jsx("br",{}),e.jsx(h,{label:"Normal PUI (placeholder + auto)",children:e.jsx(i,{name:"example1",onChange:n=>a(n.target.value),value:t,unitkey:"length",width:s,placeholder:"value|unit",autoValue:g})}),e.jsx(h,{label:"Normal PUI (only auto)",children:e.jsx(i,{name:"example1",onChange:n=>a(n.target.value),value:t,unitkey:"length",width:s,autoValue:g})}),e.jsx(h,{label:"Empty PUI with autoValue",children:e.jsx(i,{name:"example1",onChange:n=>o(n.target.value),value:r,unitkey:"length",width:s,autoValue:g})}),e.jsx(h,{label:"Normal PUI (only placeholder)",children:e.jsx(i,{name:"example1",onChange:n=>a(n.target.value),value:t,unitkey:"length",width:s,placeholder:"Placeholder test"})}),e.jsx(h,{label:"Normal PUI (placeholder + allowEmpty)",children:e.jsx(i,{name:"example1",onChange:n=>a(n.target.value),value:t,unitkey:"length",width:s,placeholder:"Placeholder test",allowEmpty:!0})}),e.jsx(_,{message:{heading:"Current value inside PUI: "+t,visible:!0}})]})};A.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const B=()=>{const[s,t]=d.useState("123|%"),[a,r]=d.useState(null),o="This should be visible when an error appears",g=(n,c)=>(r(c),{name:n,error:c});return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"3rd party validation message when inputting invalid value:"}),e.jsx(i,{name:"example",onChange:n=>t(n.target.value),error:!a||o,validationCallback:g,value:s}),e.jsx("br",{}),e.jsx(p,{}),e.jsx("h4",{children:"Original validation message: "}),e.jsx(_,{message:{heading:a,visible:!0}})]})},E=()=>{const[s,t]=d.useState("123|m"),[a,r]=d.useState(""),[o,g]=d.useState("km"),n=()=>{g("ft"),r("placeholder"),t("|m")};return e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Empty value case:"}),e.jsx(i,{name:"example",onChange:c=>t(c.target.value),value:s,allowEmpty:!0,placeholder:a,initUnit:o,unitkey:"length"}),e.jsx("br",{}),e.jsx(p,{}),e.jsx(l,{label:"Change value |m and unit ft",onClick:()=>n()})]})},D=()=>{const[s,t]=d.useState("123|m"),[a,r]=d.useState("m");return e.jsxs(e.Fragment,{children:[e.jsx(i,{name:"example",onChange:o=>t(o.target.value),value:s,initUnit:a,unitkey:"length",onSwitchUnit:r}),e.jsx(p,{}),e.jsx(i,{name:"example",onChange:o=>t(o.target.value),value:s,initUnit:a,unitkey:"length",onSwitchUnit:r})]})};var M,W,O;N.parameters={...N.parameters,docs:{...(M=N.parameters)==null?void 0:M.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
|
+
}`,...(O=(W=N.parameters)==null?void 0:W.docs)==null?void 0:O.source}}};var T,R,K;v.parameters={...v.parameters,docs:{...(T=v.parameters)==null?void 0:T.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
|
+
}`,...(K=(R=v.parameters)==null?void 0:R.docs)==null?void 0:K.source}}};var z,J,Y;C.parameters={...C.parameters,docs:{...(z=C.parameters)==null?void 0:z.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
|
+
}`,...(Y=(J=C.parameters)==null?void 0:J.docs)==null?void 0:Y.source}}};var L,Z,q;b.parameters={...b.parameters,docs:{...(L=b.parameters)==null?void 0:L.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
|
+
}`,...(q=(Z=b.parameters)==null?void 0:Z.docs)==null?void 0:q.source}}};var G,H,Q;x.parameters={...x.parameters,docs:{...(G=x.parameters)==null?void 0:G.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
|
+
}`,...(Q=(H=x.parameters)==null?void 0:H.docs)==null?void 0:Q.source}}};var X,$,ee;U.parameters={...U.parameters,docs:{...(X=U.parameters)==null?void 0:X.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
|
+
}`,...(ee=($=U.parameters)==null?void 0:$.docs)==null?void 0:ee.source}}};var ae,te,ne;y.parameters={...y.parameters,docs:{...(ae=y.parameters)==null?void 0:ae.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
|
+
}`,...(ne=(te=y.parameters)==null?void 0:te.docs)==null?void 0:ne.source}}};var le,se,re;j.parameters={...j.parameters,docs:{...(le=j.parameters)==null?void 0:le.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
|
+
}`,...(re=(se=j.parameters)==null?void 0:se.docs)==null?void 0:re.source}}};var ie,oe,ue;m.parameters={...m.parameters,docs:{...(ie=m.parameters)==null?void 0:ie.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
|
+
}`,...(ue=(oe=m.parameters)==null?void 0:oe.docs)==null?void 0:ue.source}}};var de,ce,ge;k.parameters={...k.parameters,docs:{...(de=k.parameters)==null?void 0:de.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
|
+
}`,...(ge=(ce=k.parameters)==null?void 0:ce.docs)==null?void 0:ge.source}}};var he,me,pe;V.parameters={...V.parameters,docs:{...(he=V.parameters)==null?void 0:he.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
|
+
}`,...(pe=(me=V.parameters)==null?void 0:me.docs)==null?void 0:pe.source}}};var ve,Ce,be;I.parameters={...I.parameters,docs:{...(ve=I.parameters)==null?void 0:ve.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
|
+
}`,...(be=(Ce=I.parameters)==null?void 0:Ce.docs)==null?void 0:be.source}}};var xe,Ue,ye;S.parameters={...S.parameters,docs:{...(xe=S.parameters)==null?void 0:xe.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
|
+
}`,...(ye=(Ue=S.parameters)==null?void 0:Ue.docs)==null?void 0:ye.source}}};var je,ke,Ve;f.parameters={...f.parameters,docs:{...(je=f.parameters)==null?void 0:je.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
|
+
}`,...(Ve=(ke=f.parameters)==null?void 0:ke.docs)==null?void 0:Ve.source}}};var Ie,Se,fe;w.parameters={...w.parameters,docs:{...(Ie=w.parameters)==null?void 0:Ie.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
|
+
}`,...(fe=(Se=w.parameters)==null?void 0:Se.docs)==null?void 0:fe.source}}};var we,Ae,Ne;A.parameters={...A.parameters,docs:{...(we=A.parameters)==null?void 0:we.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
|
+
}`,...(Ne=(Ae=A.parameters)==null?void 0:Ae.docs)==null?void 0:Ne.source}}};var Pe,Be,Ee;P.parameters={...P.parameters,docs:{...(Pe=P.parameters)==null?void 0:Pe.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
|
+
}`,...(Ee=(Be=P.parameters)==null?void 0:Be.docs)==null?void 0:Ee.source}}};var De,Fe,_e;B.parameters={...B.parameters,docs:{...(De=B.parameters)==null?void 0:De.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 = (name: string, message: string | null) => {
|
|
232
|
+
setValidation(message);
|
|
233
|
+
return {
|
|
234
|
+
name,
|
|
235
|
+
error: message
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
return <>
|
|
239
|
+
<h4>3rd party validation message when inputting invalid value:</h4>
|
|
240
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} error={!validation || predictedMessage} validationCallback={handleValidation} value={value} />
|
|
241
|
+
<br />
|
|
242
|
+
<Spacer />
|
|
243
|
+
<h4>Original validation message: </h4>
|
|
244
|
+
<Message message={{
|
|
245
|
+
heading: validation,
|
|
246
|
+
visible: true
|
|
247
|
+
}} />
|
|
248
|
+
</>;
|
|
249
|
+
}`,...(_e=(Fe=B.parameters)==null?void 0:Fe.docs)==null?void 0:_e.source}}};var Me,We,Oe;E.parameters={...E.parameters,docs:{...(Me=E.parameters)==null?void 0:Me.docs,source:{originalSource:`() => {
|
|
250
|
+
const [value, setValue] = useState('123|m');
|
|
251
|
+
const [placeholder, setPlaceholder] = useState('');
|
|
252
|
+
const [initUnit, setInitUnit] = useState('km');
|
|
253
|
+
const setPlaceholderValue = () => {
|
|
254
|
+
setInitUnit('ft');
|
|
255
|
+
setPlaceholder('placeholder');
|
|
256
|
+
setValue('|m');
|
|
257
|
+
};
|
|
258
|
+
return <>
|
|
259
|
+
<h4>Empty value case:</h4>
|
|
260
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} allowEmpty placeholder={placeholder} initUnit={initUnit} unitkey="length" />
|
|
261
|
+
<br />
|
|
262
|
+
<Spacer />
|
|
263
|
+
<Button label="Change value |m and unit ft" onClick={() => setPlaceholderValue()} />
|
|
264
|
+
</>;
|
|
265
|
+
}`,...(Oe=(We=E.parameters)==null?void 0:We.docs)==null?void 0:Oe.source}}};var Te,Re,Ke;D.parameters={...D.parameters,docs:{...(Te=D.parameters)==null?void 0:Te.docs,source:{originalSource:`() => {
|
|
266
|
+
const [value, setValue] = useState('123|m');
|
|
267
|
+
const [unit, setUnit] = useState('m');
|
|
268
|
+
return <>
|
|
269
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
270
|
+
<Spacer />
|
|
271
|
+
<UnitInput name="example" onChange={evt => setValue(evt.target.value)} value={value} initUnit={unit} unitkey="length" onSwitchUnit={setUnit} />
|
|
272
|
+
</>;
|
|
273
|
+
}`,...(Ke=(Re=D.parameters)==null?void 0:Re.docs)==null?void 0:Ke.source}}};const Sa=["Default","InitUnit","notKnownUnit","Width","NoConversion","Small","Error","InternalValidationError","Disabled","DisabledNoConversion","DisabledUnitWithoutUnitKey","DisabledUnitWithUnitKey","DisabledWithEnabledUnitMenu","TestExternalStateChangeWithSynchronizedUnits","PredefinedOptionsMenu","TestEdgeCases","AutomaticValues","ValidationCallback","AllowEmptyPUI","onSwitchUnit"];export{E as AllowEmptyPUI,P as AutomaticValues,N as Default,m as Disabled,k as DisabledNoConversion,I as DisabledUnitWithUnitKey,V as DisabledUnitWithoutUnitKey,S as DisabledWithEnabledUnitMenu,y as Error,v as InitUnit,j as InternalValidationError,x as NoConversion,w as PredefinedOptionsMenu,U as Small,A as TestEdgeCases,f as TestExternalStateChangeWithSynchronizedUnits,B as ValidationCallback,b as Width,Sa as __namedExportsOrder,Ia as default,C as notKnownUnit,D as onSwitchUnit};
|