@oliasoft-open-source/react-ui-library 4.12.0-beta-1 → 4.12.0-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/global.css +643 -643
  2. package/dist/index.js +340 -365
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-CK3d59Om.js → Color-KGDBMAHA-BODMLRvZ.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-C_QE44cn.js → DocsRenderer-PKQXORMH-DEi7ICVq.js} +1 -1
  6. package/dist/storybook/assets/{accordion.stories-C3VY77Jy.js → accordion.stories-C_Vx7GEC.js} +1 -1
  7. package/dist/storybook/assets/{afe.stories-C9XjJj62.js → afe.stories-OEYJqexC.js} +1 -1
  8. package/dist/storybook/assets/{buttons-and-links-FQEbqz9H.js → buttons-and-links-BHNS6Ebw.js} +1 -1
  9. package/dist/storybook/assets/{casing-loads.stories-B7JIoJVk.js → casing-loads.stories-BAdZ87Oc.js} +1 -1
  10. package/dist/storybook/assets/{cell.stories-xZiHEc0P.js → cell.stories-Bu5u9qEl.js} +1 -1
  11. package/dist/storybook/assets/{chunk-HLWAVYOI-EhWEisNT.js → chunk-HLWAVYOI-BbzmrmoZ.js} +1 -1
  12. package/dist/storybook/assets/{color-B3dajHjs.js → color-oeF0-Pph.js} +1 -1
  13. package/dist/storybook/assets/{footer.stories-BxzKeFAK.js → footer.stories-LUxEpSgD.js} +1 -1
  14. package/dist/storybook/assets/{form.stories-BNORsn6Z.js → form.stories-B7V77yuI.js} +1 -1
  15. package/dist/storybook/assets/{formation.stories-C5Hkb3iK.js → formation.stories-D7MX0dSY.js} +1 -1
  16. package/dist/storybook/assets/{iframe-DOUoMheZ.js → iframe-nuCPRPrd.js} +2 -2
  17. package/dist/storybook/assets/{index-AKsHS-dO.js → index-BFtO1KgR.js} +4 -4
  18. package/dist/storybook/assets/{index-KVAIZqzA.js → index-CN6H1a0D.js} +1 -1
  19. package/dist/storybook/assets/{input-group.stories-BCajsqAk.js → input-group.stories-BdQ1prY4.js} +1 -1
  20. package/dist/storybook/assets/{input-validation-BNoUk3q6.js → input-validation-Ccu8WMpy.js} +1 -1
  21. package/dist/storybook/assets/{inputs-Dql6Fq32.js → inputs-C4fsY4Ua.js} +1 -1
  22. package/dist/storybook/assets/{layout-forms-DuFo_rwV.js → layout-forms-DOgsanng.js} +1 -1
  23. package/dist/storybook/assets/{layout-general-C-UddRr1.js → layout-general-DtDx77FI.js} +1 -1
  24. package/dist/storybook/assets/menu.test-case.stories-W-jG-Jk8.js +3 -0
  25. package/dist/storybook/assets/{modal.stories-C2d-Em5V.js → modal.stories-DUXRRhK-.js} +1 -1
  26. package/dist/storybook/assets/{modal.test-case.stories-H8AYyvAl.js → modal.test-case.stories-Ci1WRYdo.js} +2 -2
  27. package/dist/storybook/assets/{number-input.test-case.stories-BBKpBWfA.js → number-input.test-case.stories-CHGSaGbj.js} +1 -1
  28. package/dist/storybook/assets/{padding-and-spacing-B9ObVTUS.js → padding-and-spacing-Mfm_1hn5.js} +1 -1
  29. package/dist/storybook/assets/{pagination-CR1nxnnq.js → pagination-CoyQUC4R.js} +1 -1
  30. package/dist/storybook/assets/{pagination.stories-qXmBYwYc.js → pagination.stories-qfpnU8DC.js} +1 -1
  31. package/dist/storybook/assets/{popover.stories-DZTfimDf.js → popover.stories-TwNkFkWa.js} +1 -1
  32. package/dist/storybook/assets/{preview-_21fnvwa.js → preview-BIv_KaBF.js} +2 -2
  33. package/dist/storybook/assets/{preview-dBqj-M8_.js → preview-DVjsIOwK.js} +1 -1
  34. package/dist/storybook/assets/{reservoirs.stories-r1Ip90kJ.js → reservoirs.stories-DE9FrS0f.js} +1 -1
  35. package/dist/storybook/assets/{rich-text-input.stories-DwaseXZv.js → rich-text-input.stories-BNwcnp92.js} +1 -1
  36. package/dist/storybook/assets/{row.stories-BrPMTnKK.js → row.stories-D3Bnp8i4.js} +1 -1
  37. package/dist/storybook/assets/select-BQzJMnK1.js +61 -0
  38. package/dist/storybook/assets/{select.stories-DjGSNDXK.js → select.stories-BRGk9iYK.js} +1 -1
  39. package/dist/storybook/assets/select.test-case.stories-BYMK9M8u.js +82 -0
  40. package/dist/storybook/assets/{table-iVsvoMpy.js → table-DPbEkZqw.js} +1 -1
  41. package/dist/storybook/assets/{table.stories-DmGMjcFw.js → table.stories-BBzqpsyH.js} +1 -1
  42. package/dist/storybook/assets/{title.stories-D2LDNgbT.js → title.stories-B4PYbA22.js} +1 -1
  43. package/dist/storybook/assets/toaster.test-case.stories-Cy3_Gvs_.js +6 -0
  44. package/dist/storybook/assets/{unit-input.test-case.stories-BwKiucyc.js → unit-input.test-case.stories-BeFM9DuK.js} +1 -1
  45. package/dist/storybook/assets/{unit-table.stories-B7rN0MF0.js → unit-table.stories-9x5S71wv.js} +1 -1
  46. package/dist/storybook/assets/{unit-table.test-case.stories-BIMbgiTz.js → unit-table.test-case.stories-DZJ-hZ72.js} +1 -1
  47. package/dist/storybook/iframe.html +1 -1
  48. package/dist/storybook/project.json +1 -1
  49. package/package.json +1 -1
  50. package/dist/storybook/assets/menu.test-case.stories-BFYhvtSH.js +0 -3
  51. package/dist/storybook/assets/select-Cwks-WA0.js +0 -61
  52. package/dist/storybook/assets/select.test-case.stories-B6On-PjA.js +0 -82
  53. package/dist/storybook/assets/toaster.test-case.stories-BhWnh4Cd.js +0 -6
@@ -1,4 +1,4 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as d}from"./index-DhsZuJvc.js";import{d as b}from"./index-C0x1JmaP.js";import{w as f,u as l,e as r,f as V,a as D}from"./index-DMAnyMX5.js";import{U as u}from"./unit-input-Byipu-z0.js";import{B as o}from"./button-Cbv7WK6k.js";import{S as g}from"./spacer-BWoNR27H.js";import{D as fe}from"./divider-DY9nJ_7N.js";import{R as Ce,C as _}from"./row-Bmiy2Lh0.js";import{F as U}from"./field-HrLaMLbx.js";import{M as pe}from"./message-BRyKdRaX.js";import{G as ge}from"./grid-DRkC-bt8.js";import{C as v}from"./card-EcjmryU9.js";import{H as y}from"./heading-CRNoBc7q.js";import{T as N}from"./toggle-BbFVf61v.js";import{T as q}from"./text-B3-TSWok.js";import{S as xe}from"./select-Cwks-WA0.js";import{I as he}from"./icon-BSFY3vDO.js";import"./index-DRSy5Ssd.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./initialize-context-rEvM6bdZ.js";import"./number-input-CNnU6gOF.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./lodash-c4VUpsOs.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./types-BmbYqTX_.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./spinner-AWUe4xwQ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./select.input-CJed_LLR.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const ht={title:"Forms/UnitInput/Test Cases",component:u,tags:["!autodocs"]},C=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),placeholder:"Type a value...",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};C.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const x=()=>{const[i,a]=d.useState("|m");return e.jsx(u,{name:"example-ft",onChange:t=>a(t.target.value),placeholder:"7|ft",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId-ft"})};x.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Handle input with unit only",async()=>{const n=t.getByTestId("testId-ft");await r(t.getByDisplayValue("")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Clear input and check placeholder",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await r(n).toHaveAttribute("placeholder","2.13")}),await a("Type a correct numeric value and ensure no error",async()=>{const n=t.getByTestId("testId-ft");await l.type(n,"123"),await r(t.getByDisplayValue("123")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Remove value, type incorrect value and check for error",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await l.type(n,"123abc"),await r(t.getByDisplayValue("123abc")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const T=i=>{const[a,t]=d.useState("123|m"),[s,n]=d.useState("223|m"),[c,h]=d.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Change initUnit",onClick:()=>h(c==="m"?"ft":"m")}),e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,initUnit:c,onSwitchUnit:h}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,initUnit:c,onSwitchUnit:h}),e.jsx(fe,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,onSwitchUnit:h}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,onSwitchUnit:h})]})};T.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const I=()=>{const i="500px",[a,t]=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(Ce,{children:[e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(U,{label:"Normal PUI",children:e.jsx(u,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:i,placeholder:"value|unit"})}),e.jsx(U,{label:"Disabled validation",children:e.jsx(u,{name:"example2",onChange:s=>t(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:i})}),e.jsx(U,{label:"Disabled validation and manual error",children:e.jsx(u,{name:"example3",onChange:s=>t(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:i})}),e.jsx(pe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};I.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const j=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("123|ft");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Storage State (Redux)"}),children:[s,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>n(b.withUnit(String(Math.floor(Math.random()*100)),"ft"))})]}),e.jsx(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:i&&e.jsx(u,{name:"example",onChange:c=>n(c.target.value),value:s,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"}})})]})},S=()=>e.jsxs(e.Fragment,{children:[e.jsx(q,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),w=()=>e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"example",unitkey:"moleWeight",initUnit:"g/mol",doNotConvertValue:!0,value:"170|g/mol",unitTemplate:{moleWeight:"g/mol"},testId:"case1"}),e.jsx(g,{}),e.jsx(u,{name:"gor",unitkey:"moleWeight",initUnit:"gor",value:"Infinity|SCF/STB",testId:"case2"})]});w.play=async({canvasElement:i,step:a})=>{const t=f(i);await a("Can enter decimal values",async()=>{await r(t.getByDisplayValue("170")).toBeInTheDocument(),await r(t.getByDisplayValue("")).toBeInTheDocument()})};const B=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("psi"),[c,h]=d.useState(!1),[m,ve]=d.useState(!0),[F,ye]=d.useState(!0),[R,M]=d.useState("672.2388357750001|bar"),[W,be]=d.useState("");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Settings"}),children:[e.jsx(U,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:c,onChange:p=>h(p.target.checked)})}),e.jsx(U,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:m,onChange:p=>ve(p.target.checked)})}),e.jsx(U,{label:"Convert back to storage unit (onChange):",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:F,onChange:p=>ye(p.target.checked)})})]}),e.jsxs(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:[e.jsx(q,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(g,{}),e.jsx(q,{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(g,{}),i&&e.jsx(u,{name:"Example",unitkey:"pressure",initUnit:s,unitTemplate:{pressure:"psi"},value:R,onChange:p=>{const{value:E}=p.target;E&&M(E)},enableDisplayRounding:c,enableCosmeticRounding:m,error:b.convertAndGetValue(R,"bar")>=0?"":"Value must be positive",validationCallback:(p,E)=>{be(E??"")},convertBackToStorageUnit:F})]}),e.jsx(v,{heading:e.jsx(y,{children:"Unit Template"}),children:e.jsx(xe,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:s,width:70,onChange:p=>n(p.target.value)})}),e.jsx(v,{heading:e.jsx(y,{children:"Test Validation Callback"}),children:W&&e.jsx(pe,{message:{content:W,icon:!0,type:"Error",visible:!0}})}),e.jsxs(v,{heading:e.jsx(y,{children:"Storage State / Redux"}),children:[R,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>M(b.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})},k=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};k.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Can enter decimal values",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123.123456789"),await r(t.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"-1.12e3"),await r(t.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123,456"),await r(t.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"0.0000000023"),await r(t.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"999999999999"),await r(t.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const n=t.getByTestId("testId"),c=t.getByTestId("testId-menu");await l.clear(n),await l.type(n,"456.1"),await l.click(c),await l.click(s.getByTestId("testId-unit-ft")),await r(t.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};C.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};x.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"PlaceholderWithUnit"};T.__docgenInfo={description:"",methods:[],displayName:"TestExternalStateChangeWithSynchronizedUnits",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},disabledUnit:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:""},left:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:""},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:""},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:""},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:""},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:""},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
1
+ import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as d}from"./index-DhsZuJvc.js";import{d as b}from"./index-C0x1JmaP.js";import{w as f,u as l,e as r,f as V,a as D}from"./index-DMAnyMX5.js";import{U as u}from"./unit-input-Byipu-z0.js";import{B as o}from"./button-Cbv7WK6k.js";import{S as g}from"./spacer-BWoNR27H.js";import{D as fe}from"./divider-DY9nJ_7N.js";import{R as Ce,C as _}from"./row-Bmiy2Lh0.js";import{F as U}from"./field-HrLaMLbx.js";import{M as pe}from"./message-BRyKdRaX.js";import{G as ge}from"./grid-DRkC-bt8.js";import{C as v}from"./card-EcjmryU9.js";import{H as y}from"./heading-CRNoBc7q.js";import{T as N}from"./toggle-BbFVf61v.js";import{T as q}from"./text-B3-TSWok.js";import{S as xe}from"./select-BQzJMnK1.js";import{I as he}from"./icon-BSFY3vDO.js";import"./index-DRSy5Ssd.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./initialize-context-rEvM6bdZ.js";import"./number-input-CNnU6gOF.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./lodash-c4VUpsOs.js";import"./helpers-JJxzGegQ.js";import"./input-Db9WkmPP.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./actions-Bax0KeqM.js";import"./common-types-Sih75Sav.js";import"./types-BmbYqTX_.js";import"./badge-CLQ59MDF.js";import"./input-group-addon-D68iUKV2.js";import"./input-group-BaRSJAEN.js";import"./spinner-AWUe4xwQ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-CqmyC9he.js";import"./help-icon-Buhx5nl6.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./select.input-CJed_LLR.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";const ht={title:"Forms/UnitInput/Test Cases",component:u,tags:["!autodocs"]},C=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),placeholder:"Type a value...",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};C.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const x=()=>{const[i,a]=d.useState("|m");return e.jsx(u,{name:"example-ft",onChange:t=>a(t.target.value),placeholder:"7|ft",value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId-ft"})};x.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Handle input with unit only",async()=>{const n=t.getByTestId("testId-ft");await r(t.getByDisplayValue("")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Clear input and check placeholder",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await r(n).toHaveAttribute("placeholder","2.13")}),await a("Type a correct numeric value and ensure no error",async()=>{const n=t.getByTestId("testId-ft");await l.type(n,"123"),await r(t.getByDisplayValue("123")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toBeNull(),await V.mouseOver(n),await D(()=>{r(s.queryByText("Must be a numerical value")).not.toBeInTheDocument()})}),await a("Remove value, type incorrect value and check for error",async()=>{const n=t.getByTestId("testId-ft");await l.clear(n),await l.type(n,"123abc"),await r(t.getByDisplayValue("123abc")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};const T=i=>{const[a,t]=d.useState("123|m"),[s,n]=d.useState("223|m"),[c,h]=d.useState("ft");return e.jsxs(e.Fragment,{children:[e.jsx(o,{label:"Change initUnit",onClick:()=>h(c==="m"?"ft":"m")}),e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>t(a==="123|m"?"456|m":"123|m")}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,initUnit:c,onSwitchUnit:h}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,initUnit:c,onSwitchUnit:h}),e.jsx(fe,{}),e.jsx("h4",{children:"Without initUnit property (taken from the redux store)"}),e.jsx(u,{name:"example",onChange:m=>{t(m.target.value)},unitkey:"length",value:a,onSwitchUnit:h}),e.jsx(u,{name:"example2",onChange:m=>{n(m.target.value)},unitkey:"length",value:s,onSwitchUnit:h})]})};T.parameters={docs:{description:{story:"[OW-4380](https://oliasoft.atlassian.net/browse/OW-4380?atlOrigin=eyJpIjoiMmM1N2RkNWU3Mjk5NDYxY2E0YzhkMzk5ZTVmZTJhMjciLCJwIjoiaiJ9)"}}};const I=()=>{const i="500px",[a,t]=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(Ce,{children:[e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity",onClick:()=>t(1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity",onClick:()=>t(-1/0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value null",onClick:()=>t(null)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN",onClick:()=>t(NaN)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)",onClick:()=>t(void 0)}),e.jsx("br",{}),e.jsx(o,{label:"Change value - empty string",onClick:()=>t("")})]}),e.jsxs(_,{width:"25%",children:[e.jsx(o,{label:"Change value infinity|m",onClick:()=>t("Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value -infinity|m",onClick:()=>t("-Infinity|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value null|m",onClick:()=>t("null|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - undefined|m",onClick:()=>t("undefined|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - NaN|m",onClick:()=>t("NaN|m")}),e.jsx("br",{}),e.jsx(o,{label:"Change value - nothing (empty)|m",onClick:()=>t("|m")})]})]}),e.jsx("br",{}),e.jsx(U,{label:"Normal PUI",children:e.jsx(u,{name:"example1",onChange:s=>t(s.target.value),value:a,unitkey:"length",width:i,placeholder:"value|unit"})}),e.jsx(U,{label:"Disabled validation",children:e.jsx(u,{name:"example2",onChange:s=>t(s.target.value),value:a,unitkey:"length",disabledValidation:!0,width:i})}),e.jsx(U,{label:"Disabled validation and manual error",children:e.jsx(u,{name:"example3",onChange:s=>t(s.target.value),value:a,unitkey:"length",error:"test",disabledValidation:!0,width:i})}),e.jsx(pe,{message:{heading:"Current value inside PUI: "+a,visible:!0}})]})};I.parameters={docs:{description:{story:"[OW-8884](https://oliasoft.atlassian.net/browse/OW-8884)"}}};const j=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("123|ft");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Storage State (Redux)"}),children:[s,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>n(b.withUnit(String(Math.floor(Math.random()*100)),"ft"))})]}),e.jsx(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:i&&e.jsx(u,{name:"example",onChange:c=>n(c.target.value),value:s,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"}})})]})},S=()=>e.jsxs(e.Fragment,{children:[e.jsx(q,{faint:!0,children:"Reproduce OW-10614 rounding noise bug when storing values in a different unit to the display unit"}),e.jsx(g,{}),e.jsx(u,{name:"example",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("9750|psi","bar"),"bar"),initUnit:"psi",unitkey:"pressure",unitTemplate:{pressure:"psi"}}),e.jsx(g,{}),e.jsx(u,{name:"example2",onChange:()=>{},value:b.withUnit(b.convertAndGetValue("8642|lbf","tonneForce"),"tonneForce"),initUnit:"lbf",unitkey:"force",unitTemplate:{force:"tonneForce"}})]}),w=()=>e.jsxs(e.Fragment,{children:[e.jsx(u,{name:"example",unitkey:"moleWeight",initUnit:"g/mol",doNotConvertValue:!0,value:"170|g/mol",unitTemplate:{moleWeight:"g/mol"},testId:"case1"}),e.jsx(g,{}),e.jsx(u,{name:"gor",unitkey:"moleWeight",initUnit:"gor",value:"Infinity|SCF/STB",testId:"case2"})]});w.play=async({canvasElement:i,step:a})=>{const t=f(i);await a("Can enter decimal values",async()=>{await r(t.getByDisplayValue("170")).toBeInTheDocument(),await r(t.getByDisplayValue("")).toBeInTheDocument()})};const B=()=>{const[i,a]=d.useState(!0),t=()=>{a(!1),setTimeout(()=>a(!0),0)},[s,n]=d.useState("psi"),[c,h]=d.useState(!1),[m,ve]=d.useState(!0),[F,ye]=d.useState(!0),[R,M]=d.useState("672.2388357750001|bar"),[W,be]=d.useState("");return e.jsxs(ge,{columns:"1fr 1fr",gap:!0,children:[e.jsxs(v,{heading:e.jsx(y,{children:"Settings"}),children:[e.jsx(U,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:c,onChange:p=>h(p.target.checked)})}),e.jsx(U,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:m,onChange:p=>ve(p.target.checked)})}),e.jsx(U,{label:"Convert back to storage unit (onChange):",labelLeft:!0,labelWidth:200,children:e.jsx(N,{checked:F,onChange:p=>ye(p.target.checked)})})]}),e.jsxs(v,{heading:e.jsx(y,{icon:e.jsx(he,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"UnitInput"}),children:[e.jsx(q,{faint:!0,children:"Cosmetic Rounding Test Case: type 9750 then return (compare with enableCosmeticRounding on and off)"}),e.jsx(g,{}),e.jsx(q,{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(g,{}),i&&e.jsx(u,{name:"Example",unitkey:"pressure",initUnit:s,unitTemplate:{pressure:"psi"},value:R,onChange:p=>{const{value:E}=p.target;E&&M(E)},enableDisplayRounding:c,enableCosmeticRounding:m,error:b.convertAndGetValue(R,"bar")>=0?"":"Value must be positive",validationCallback:(p,E)=>{be(E??"")},convertBackToStorageUnit:F})]}),e.jsx(v,{heading:e.jsx(y,{children:"Unit Template"}),children:e.jsx(xe,{options:[{label:"Bar",value:"bar"},{label:"psi",value:"psi"}],value:s,width:70,onChange:p=>n(p.target.value)})}),e.jsx(v,{heading:e.jsx(y,{children:"Test Validation Callback"}),children:W&&e.jsx(pe,{message:{content:W,icon:!0,type:"Error",visible:!0}})}),e.jsxs(v,{heading:e.jsx(y,{children:"Storage State / Redux"}),children:[R,e.jsx(g,{}),e.jsx(o,{label:"Change value",onClick:()=>M(b.withUnit(String(Math.floor(Math.random()*100)),"bar"))})]})]})},k=()=>{const[i,a]=d.useState("123|m");return e.jsx(u,{name:"example",onChange:t=>a(t.target.value),value:i,initUnit:"m",unitkey:"depth",unitTemplate:{depth:"m"},testId:"testId"})};k.play=async({canvasElement:i,step:a})=>{const t=f(i),s=f(i.ownerDocument.body);await a("Can enter decimal values",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123.123456789"),await r(t.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await a("Can enter scientific notation",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"-1.12e3"),await r(t.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await a("Can enter comma decimals (converts to dot)",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123,456"),await r(t.getByDisplayValue("123.456")).toBeInTheDocument()}),await a("Can enter small numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"0.0000000023"),await r(t.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await a("Can enter large numbers",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"999999999999"),await r(t.getByDisplayValue("999999999999")).toBeInTheDocument()}),await a("Can convert units",async()=>{const n=t.getByTestId("testId"),c=t.getByTestId("testId-menu");await l.clear(n),await l.type(n,"456.1"),await l.click(c),await l.click(s.getByTestId("testId-unit-ft")),await r(t.getByDisplayValue("1496")).toBeInTheDocument()}),await a("Shows validation error for non-numeric input",async()=>{const n=t.getByTestId("testId");await l.clear(n),await l.type(n,"123x45s6"),await r(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(n.getAttribute("data-error")).toEqual("Must be a numerical value"),await V.mouseOver(n),await D(()=>{r(s.getByText("Must be a numerical value")).toBeInTheDocument()})})};C.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};x.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"PlaceholderWithUnit"};T.__docgenInfo={description:"",methods:[],displayName:"TestExternalStateChangeWithSynchronizedUnits",props:{name:{required:!0,tsType:{name:"union",raw:"string | { fieldName?: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName?: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!1}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},disabledUnit:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:""},left:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:""},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:""},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | boolean | null",elements:[{name:"string"},{name:"boolean"},{name:"null"}]},description:""},predefinedOptions:{required:!1,tsType:{name:"union",raw:"IPredefinedOption[] | null",elements:[{name:"Array",elements:[{name:"IPredefinedOption"}],raw:"IPredefinedOption[]"},{name:"null"}]},description:""},initialPredefinedOption:{required:!1,tsType:{name:"boolean"},description:""},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:""},selectedPredefinedOptionKey:{required:!1,tsType:{name:"string"},description:""},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:"(name: string, error: string | null) => any",signature:{arguments:[{type:{name:"string"},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"any"}}},description:""},disabledValidation:{required:!1,tsType:{name:"boolean"},description:""},allowEmpty:{required:!1,tsType:{name:"boolean"},description:""},autoValue:{required:!1,tsType:{name:"string"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(event: TChangeEvent | ICustomChangeEvent) => void",signature:{arguments:[{type:{name:"union",raw:"TChangeEvent | ICustomChangeEvent",elements:[{name:"intersection",raw:`ChangeEvent<T> & {
2
2
  target:
3
3
  | T
4
4
  | { name: string; value: any; label?: string; files?: FileList | null };
@@ -1,4 +1,4 @@
1
- import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as f}from"./index-DhsZuJvc.js";import{f as z}from"./immer.esm-BwVl9PS2.js";import{d as w}from"./index-C0x1JmaP.js";import{G as ee}from"./grid-DRkC-bt8.js";import{S as te}from"./spacer-BWoNR27H.js";import{C as V}from"./card-EcjmryU9.js";import{F as R}from"./field-HrLaMLbx.js";import{H as F}from"./heading-CRNoBc7q.js";import{S as N}from"./select-Cwks-WA0.js";import{T as W}from"./toggle-BbFVf61v.js";import{l as ne}from"./lodash-c4VUpsOs.js";import{u as ae,a as ie,g as re,c as K}from"./initialize-context-rEvM6bdZ.js";import{T as oe,C as P}from"./table-iVsvoMpy.js";import{s as le}from"./number-input-CNnU6gOF.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./label-CqmyC9he.js";import"./common-types-Sih75Sav.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-CR1nxnnq.js";import"./input-Db9WkmPP.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./check-box-DPLaOkRR.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";const se=l=>l.reduce(({preferredUnits:i,storageUnits:r},{unitKey:s,preferredUnit:a,storageUnit:h})=>{const{unitTemplate:p=null}=ie()??{};return i[s]=a??re(s,p),r[s]=h,{preferredUnits:i,storageUnits:r}},{preferredUnits:{},storageUnits:{}}),ue=({headers:l,rows:i,selectedUnits:r,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:h,enableCosmeticRounding:p,enableDisplayRounding:T})=>{const d=l?l.map(c=>({...c,cells:c.cells.map(g=>{var t;if(g.type===P.AUTO_UNIT){const{testId:x,unitKey:u}=g;return{value:r[u],type:P.SELECT,searchable:!1,options:(t=w.getUnitsForQuantity(u))==null?void 0:t.map(v=>({label:w.label(v),value:v})),native:g.native,onChange:v=>a({unitKey:u,value:v.target.value}),testId:x}}return g})})):[],o=i?i.map((c,g)=>({...c,cells:c.cells.map((t,x)=>{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:u,value:v,formatDisplayValue:D}=t,L=T&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,m=r[u],b=s[u],e=m!==b,{value:U=v}=K({value:le(v),unitkey:u,toUnit:m,fromUnit:b}),y=e?U:t.value,k=D?D(y):y;return{...t,value:k,enableCosmeticRounding:p&&e,enableDisplayRounding:T,roundDisplayValue:L,onChange:C=>{const{value:S}=C.target,B=s[u],E=r[u],A=E!==B,_=h?B:E,{value:I=S}=K({value:String(S),unitkey:u,toUnit:_,fromUnit:E}),X=A?I:S;if("onChange"in t){const{onChange:Y}=t,Z={...C,target:{...C.target,value:String(X),rowIndex:g,cellIndex:x,unit:_}};Y(Z)}}}}return t})})):[];return{convertedHeaders:d,convertedRows:o}},M=({table:l,unitConfig:i,convertBackToStorageUnit:r=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:h,headers:p,...T}=l,{storageUnits:d,preferredUnits:o}=se(i),c=ae(o),[g,t]=f.useState(o),x=({unitKey:m,value:b})=>{t({...g,[m]:b});const e=i.find(U=>U.unitKey===m);e&&typeof e.onChange=="function"&&e.onChange({oldUnit:g[m],newUnit:b,unitKey:m})},u=m=>ue({headers:p,rows:h,selectedUnits:m,storageUnits:d,onChangeUnit:x,convertBackToStorageUnit:r,enableCosmeticRounding:s,enableDisplayRounding:a}),v=u(g),[D,L]=f.useState(v);return f.useEffect(()=>{!ne.isEqual(o,c)&&(Object.keys(o).forEach(b=>{const e=c==null?void 0:c[b],U=o[b];e!==U&&x({unitKey:b,value:U})}),L(u(o)))},[i]),f.useEffect(()=>{L(u(g))},[l,g]),n.jsx(oe,{table:{...T,headers:D.convertedHeaders,rows:D.convertedRows}})};M.__docgenInfo={description:"",methods:[],displayName:"UnitTable",props:{table:{required:!0,tsType:{name:"IUnitTable"},description:""},unitConfig:{required:!0,tsType:{name:"Array",elements:[{name:"IUnitConfigItem"}],raw:"IUnitConfigItem[]"},description:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}}},composes:["Omit"]};const ft={title:"Basic/UnitTable",args:{}},de=!0,ce=!0,pe=!0,ge=!1,H="ft",J="C",me=3,he=(l,i,r)=>{const s=[i,i,r],a=[...Array(l)].map((h,p)=>{const T=p,d=p+1.25,o=4+p*.25;return[String(T),String(d),String(o)]});return[s,...a]},be=he(me,H,J),fe=({reduxTable:l,value:i,unit:r,rowIndex:s,cellIndex:a})=>z(l,h=>{const p=h[0][a],T=(d,o)=>o===0;return h.forEach((d,o)=>{if(T(d,o)){d[a]=r;return}if(o===s+1){d[a]=String(i);return}const c=w.convertAndGetValue(d[a],r,p);d[a]=String(c)}),h}),ve=({reduxTable:l,value:i,rowIndex:r,cellIndex:s})=>z(l,a=>{a[r+1][s]=i}),j=()=>{var m,b;const[l,i]=f.useState(H),[r,s]=f.useState(J),[a,h]=f.useState(be),[p,T]=f.useState(de),[d,o]=f.useState(pe),[c,g]=f.useState(ce),[t,x]=f.useState(ge),[u,v]=f.useState(H),D=e=>{const{rowIndex:U,cellIndex:y,value:k,unit:C}=e.target,S=t?fe({reduxTable:a,value:k,unit:C,rowIndex:U,cellIndex:y}):ve({reduxTable:a,value:k,rowIndex:U,cellIndex:y});h(S)},L=a.reduce((e,U,y)=>(y===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:U.map((k,C)=>{const S=y===1&&C===1;return{value:k,type:S?"Text":"NumberInput",unitKey:C===2?"temperature":"length",onChange:D,roundDisplayValue:y===3&&C===2?I=>w.roundByMagnitude(I,2):null,formatDisplayValue:S?I=>`T* ${I}`:null,autoUnit:!0,testId:`testId_${y}_${C}`}})}),e),{testId:"testId",headers:[],rows:[]});return n.jsxs(ee,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(V,{heading:n.jsx(F,{children:"Settings"}),children:[n.jsx(R,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:p,onChange:e=>T(e.target.checked)})}),n.jsx(R,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:d,onChange:e=>o(e.target.checked)})}),n.jsx(R,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:c,onChange:e=>g(e.target.checked)})}),n.jsx(R,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:t,onChange:e=>x(e.target.checked)})})]}),n.jsxs(V,{heading:n.jsx(F,{children:"Unit template"}),children:[n.jsx(R,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(m=w.getUnitsForQuantity("length"))==null?void 0:m.map(e=>({value:e,label:w.label(e)})),value:{value:l},onChange:e=>i(e.target.value),width:"100px"})}),n.jsx(R,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(b=w.getUnitsForQuantity("temperature"))==null?void 0:b.map(e=>({value:e,label:w.label(e)})),value:{value:r},onChange:e=>s(e.target.value),width:"100px"})})]}),n.jsx(V,{heading:n.jsx(F,{children:"Storage State (Redux)"}),children:n.jsx("pre",{children:n.jsx("code",{children:JSON.stringify(a,null,2)})})}),n.jsxs(V,{heading:n.jsx(F,{children:"UnitTable"}),children:[n.jsx(M,{table:L,unitConfig:[{unitKey:"length",storageUnit:a[0][0],preferredUnit:l,onChange:({newUnit:e})=>v(e)},{unitKey:"temperature",storageUnit:a[0][2],preferredUnit:r}],convertBackToStorageUnit:p,enableDisplayRounding:d,enableCosmeticRounding:c}),n.jsx(te,{height:20}),n.jsx(R,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:u})]})]})};j.__docgenInfo={description:"",methods:[],displayName:"UnitTableExample"};var O,q,$,G,Q;j.parameters={...j.parameters,docs:{...(O=j.parameters)==null?void 0:O.docs,source:{originalSource:`() => {
1
+ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as f}from"./index-DhsZuJvc.js";import{f as z}from"./immer.esm-BwVl9PS2.js";import{d as w}from"./index-C0x1JmaP.js";import{G as ee}from"./grid-DRkC-bt8.js";import{S as te}from"./spacer-BWoNR27H.js";import{C as V}from"./card-EcjmryU9.js";import{F as R}from"./field-HrLaMLbx.js";import{H as F}from"./heading-CRNoBc7q.js";import{S as N}from"./select-BQzJMnK1.js";import{T as W}from"./toggle-BbFVf61v.js";import{l as ne}from"./lodash-c4VUpsOs.js";import{u as ae,a as ie,g as re,c as K}from"./initialize-context-rEvM6bdZ.js";import{T as oe,C as P}from"./table-DPbEkZqw.js";import{s as le}from"./number-input-CNnU6gOF.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./label-CqmyC9he.js";import"./common-types-Sih75Sav.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-CoyQUC4R.js";import"./input-Db9WkmPP.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./check-box-DPLaOkRR.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";const se=l=>l.reduce(({preferredUnits:i,storageUnits:r},{unitKey:s,preferredUnit:a,storageUnit:h})=>{const{unitTemplate:p=null}=ie()??{};return i[s]=a??re(s,p),r[s]=h,{preferredUnits:i,storageUnits:r}},{preferredUnits:{},storageUnits:{}}),ue=({headers:l,rows:i,selectedUnits:r,storageUnits:s,onChangeUnit:a,convertBackToStorageUnit:h,enableCosmeticRounding:p,enableDisplayRounding:T})=>{const d=l?l.map(c=>({...c,cells:c.cells.map(g=>{var t;if(g.type===P.AUTO_UNIT){const{testId:x,unitKey:u}=g;return{value:r[u],type:P.SELECT,searchable:!1,options:(t=w.getUnitsForQuantity(u))==null?void 0:t.map(v=>({label:w.label(v),value:v})),native:g.native,onChange:v=>a({unitKey:u,value:v.target.value}),testId:x}}return g})})):[],o=i?i.map((c,g)=>({...c,cells:c.cells.map((t,x)=>{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:u,value:v,formatDisplayValue:D}=t,L=T&&"roundDisplayValue"in t?t==null?void 0:t.roundDisplayValue:null,m=r[u],b=s[u],e=m!==b,{value:U=v}=K({value:le(v),unitkey:u,toUnit:m,fromUnit:b}),y=e?U:t.value,k=D?D(y):y;return{...t,value:k,enableCosmeticRounding:p&&e,enableDisplayRounding:T,roundDisplayValue:L,onChange:C=>{const{value:S}=C.target,B=s[u],E=r[u],A=E!==B,_=h?B:E,{value:I=S}=K({value:String(S),unitkey:u,toUnit:_,fromUnit:E}),X=A?I:S;if("onChange"in t){const{onChange:Y}=t,Z={...C,target:{...C.target,value:String(X),rowIndex:g,cellIndex:x,unit:_}};Y(Z)}}}}return t})})):[];return{convertedHeaders:d,convertedRows:o}},M=({table:l,unitConfig:i,convertBackToStorageUnit:r=!0,enableCosmeticRounding:s=!0,enableDisplayRounding:a=!0})=>{const{rows:h,headers:p,...T}=l,{storageUnits:d,preferredUnits:o}=se(i),c=ae(o),[g,t]=f.useState(o),x=({unitKey:m,value:b})=>{t({...g,[m]:b});const e=i.find(U=>U.unitKey===m);e&&typeof e.onChange=="function"&&e.onChange({oldUnit:g[m],newUnit:b,unitKey:m})},u=m=>ue({headers:p,rows:h,selectedUnits:m,storageUnits:d,onChangeUnit:x,convertBackToStorageUnit:r,enableCosmeticRounding:s,enableDisplayRounding:a}),v=u(g),[D,L]=f.useState(v);return f.useEffect(()=>{!ne.isEqual(o,c)&&(Object.keys(o).forEach(b=>{const e=c==null?void 0:c[b],U=o[b];e!==U&&x({unitKey:b,value:U})}),L(u(o)))},[i]),f.useEffect(()=>{L(u(g))},[l,g]),n.jsx(oe,{table:{...T,headers:D.convertedHeaders,rows:D.convertedRows}})};M.__docgenInfo={description:"",methods:[],displayName:"UnitTable",props:{table:{required:!0,tsType:{name:"IUnitTable"},description:""},unitConfig:{required:!0,tsType:{name:"Array",elements:[{name:"IUnitConfigItem"}],raw:"IUnitConfigItem[]"},description:""},convertBackToStorageUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableCosmeticRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}}},composes:["Omit"]};const ft={title:"Basic/UnitTable",args:{}},de=!0,ce=!0,pe=!0,ge=!1,H="ft",J="C",me=3,he=(l,i,r)=>{const s=[i,i,r],a=[...Array(l)].map((h,p)=>{const T=p,d=p+1.25,o=4+p*.25;return[String(T),String(d),String(o)]});return[s,...a]},be=he(me,H,J),fe=({reduxTable:l,value:i,unit:r,rowIndex:s,cellIndex:a})=>z(l,h=>{const p=h[0][a],T=(d,o)=>o===0;return h.forEach((d,o)=>{if(T(d,o)){d[a]=r;return}if(o===s+1){d[a]=String(i);return}const c=w.convertAndGetValue(d[a],r,p);d[a]=String(c)}),h}),ve=({reduxTable:l,value:i,rowIndex:r,cellIndex:s})=>z(l,a=>{a[r+1][s]=i}),j=()=>{var m,b;const[l,i]=f.useState(H),[r,s]=f.useState(J),[a,h]=f.useState(be),[p,T]=f.useState(de),[d,o]=f.useState(pe),[c,g]=f.useState(ce),[t,x]=f.useState(ge),[u,v]=f.useState(H),D=e=>{const{rowIndex:U,cellIndex:y,value:k,unit:C}=e.target,S=t?fe({reduxTable:a,value:k,unit:C,rowIndex:U,cellIndex:y}):ve({reduxTable:a,value:k,rowIndex:U,cellIndex:y});h(S)},L=a.reduce((e,U,y)=>(y===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:U.map((k,C)=>{const S=y===1&&C===1;return{value:k,type:S?"Text":"NumberInput",unitKey:C===2?"temperature":"length",onChange:D,roundDisplayValue:y===3&&C===2?I=>w.roundByMagnitude(I,2):null,formatDisplayValue:S?I=>`T* ${I}`:null,autoUnit:!0,testId:`testId_${y}_${C}`}})}),e),{testId:"testId",headers:[],rows:[]});return n.jsxs(ee,{columns:"1fr 1fr",gap:!0,children:[n.jsxs(V,{heading:n.jsx(F,{children:"Settings"}),children:[n.jsx(R,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:p,onChange:e=>T(e.target.checked)})}),n.jsx(R,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:d,onChange:e=>o(e.target.checked)})}),n.jsx(R,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:c,onChange:e=>g(e.target.checked)})}),n.jsx(R,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:n.jsx(W,{checked:t,onChange:e=>x(e.target.checked)})})]}),n.jsxs(V,{heading:n.jsx(F,{children:"Unit template"}),children:[n.jsx(R,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(m=w.getUnitsForQuantity("length"))==null?void 0:m.map(e=>({value:e,label:w.label(e)})),value:{value:l},onChange:e=>i(e.target.value),width:"100px"})}),n.jsx(R,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:n.jsx(N,{options:(b=w.getUnitsForQuantity("temperature"))==null?void 0:b.map(e=>({value:e,label:w.label(e)})),value:{value:r},onChange:e=>s(e.target.value),width:"100px"})})]}),n.jsx(V,{heading:n.jsx(F,{children:"Storage State (Redux)"}),children:n.jsx("pre",{children:n.jsx("code",{children:JSON.stringify(a,null,2)})})}),n.jsxs(V,{heading:n.jsx(F,{children:"UnitTable"}),children:[n.jsx(M,{table:L,unitConfig:[{unitKey:"length",storageUnit:a[0][0],preferredUnit:l,onChange:({newUnit:e})=>v(e)},{unitKey:"temperature",storageUnit:a[0][2],preferredUnit:r}],convertBackToStorageUnit:p,enableDisplayRounding:d,enableCosmeticRounding:c}),n.jsx(te,{height:20}),n.jsx(R,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:u})]})]})};j.__docgenInfo={description:"",methods:[],displayName:"UnitTableExample"};var O,q,$,G,Q;j.parameters={...j.parameters,docs:{...(O=j.parameters)==null?void 0:O.docs,source:{originalSource:`() => {
2
2
  const [preferredLengthUnit, setPreferredLengthUnit] = useState(initialLengthUnit);
3
3
  const [preferredTemperatureUnit, setPreferredTemperatureUnit] = useState(initialTemperatureUnit);
4
4
  const [reduxTable, setReduxTable] = useState<TTable>(initialTable);
@@ -1 +1 @@
1
- import{w as p,u as i,e as r,f as s,a as n}from"./index-DMAnyMX5.js";import{UnitTableExample as c}from"./unit-table.stories-B7rN0MF0.js";import"./index-CF7H4eMJ.js";import"./jsx-runtime-eps93zm2.js";import"./index-DhsZuJvc.js";import"./immer.esm-BwVl9PS2.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./grid-DRkC-bt8.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./spacer-BWoNR27H.js";import"./card-EcjmryU9.js";import"./index-Bk2sglWO.js";import"./field-HrLaMLbx.js";import"./label-CqmyC9he.js";import"./common-types-Sih75Sav.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./heading-CRNoBc7q.js";import"./select-Cwks-WA0.js";import"./lodash-c4VUpsOs.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./toggle-BbFVf61v.js";import"./initialize-context-rEvM6bdZ.js";import"./number-input-CNnU6gOF.js";import"./input-Db9WkmPP.js";import"./table-iVsvoMpy.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-CR1nxnnq.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./check-box-DPLaOkRR.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";const wt={title:"Basic/UnitTable/Test Cases",args:{},tags:["!autodocs"]},u=c.bind({});u.play=async({canvasElement:o,step:e})=>{const a=p(o),m=p(o.ownerDocument.body);await e("Can enter decimal values",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123.123456789"),await i.click(o),await r(a.getByDisplayValue("123.12")).toBeInTheDocument()}),await e("Can enter comma decimals (converts to dot)",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123,456"),await i.click(o),await r(a.getByDisplayValue("123.46")).toBeInTheDocument()}),await e("Can enter small numbers",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"0.0000000023"),await i.click(o),await r(t).toHaveDisplayValue("0.00")}),await e("Can enter large numbers",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"999999999999"),await i.click(o),await r(a.getByDisplayValue("999999999999.00")).toBeInTheDocument()}),await e("Shows validation error for non-numeric input",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123x45s6"),await i.click(o),await r(a.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(t.getAttribute("data-error")).toEqual("Must be a numerical value"),await s.mouseOver(t),await n(()=>{r(m.getByText("Must be a numerical value")).toBeInTheDocument()})})};const yt=["Test"];export{u as Test,yt as __namedExportsOrder,wt as default};
1
+ import{w as p,u as i,e as r,f as s,a as n}from"./index-DMAnyMX5.js";import{UnitTableExample as c}from"./unit-table.stories-9x5S71wv.js";import"./index-CF7H4eMJ.js";import"./jsx-runtime-eps93zm2.js";import"./index-DhsZuJvc.js";import"./immer.esm-BwVl9PS2.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./grid-DRkC-bt8.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./spacer-BWoNR27H.js";import"./card-EcjmryU9.js";import"./index-Bk2sglWO.js";import"./field-HrLaMLbx.js";import"./label-CqmyC9he.js";import"./common-types-Sih75Sav.js";import"./help-icon-Buhx5nl6.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./heading-CRNoBc7q.js";import"./select-BQzJMnK1.js";import"./lodash-c4VUpsOs.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./toggle-BbFVf61v.js";import"./initialize-context-rEvM6bdZ.js";import"./number-input-CNnU6gOF.js";import"./input-Db9WkmPP.js";import"./table-DPbEkZqw.js";import"./index.es-DazXb-ul.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-CoyQUC4R.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./check-box-DPLaOkRR.js";import"./slider-CcpE4BLD.js";import"./index-BI4_Bp97.js";import"./popover-C_2P8LFJ.js";const wt={title:"Basic/UnitTable/Test Cases",args:{},tags:["!autodocs"]},u=c.bind({});u.play=async({canvasElement:o,step:e})=>{const a=p(o),m=p(o.ownerDocument.body);await e("Can enter decimal values",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123.123456789"),await i.click(o),await r(a.getByDisplayValue("123.12")).toBeInTheDocument()}),await e("Can enter comma decimals (converts to dot)",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123,456"),await i.click(o),await r(a.getByDisplayValue("123.46")).toBeInTheDocument()}),await e("Can enter small numbers",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"0.0000000023"),await i.click(o),await r(t).toHaveDisplayValue("0.00")}),await e("Can enter large numbers",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"999999999999"),await i.click(o),await r(a.getByDisplayValue("999999999999.00")).toBeInTheDocument()}),await e("Shows validation error for non-numeric input",async()=>{const t=a.getByTestId("testId_2_1");await i.clear(t),await i.type(t,"123x45s6"),await i.click(o),await r(a.getByDisplayValue("123x45s6")).toBeInTheDocument(),await r(t.getAttribute("data-error")).toEqual("Must be a numerical value"),await s.mouseOver(t),await n(()=>{r(m.getByText("Must be a numerical value")).toBeInTheDocument()})})};const yt=["Test"];export{u as Test,yt as __namedExportsOrder,wt as default};
@@ -509,7 +509,7 @@
509
509
  }
510
510
  </script>
511
511
 
512
- <script type="module" crossorigin src="./assets/iframe-DOUoMheZ.js"></script>
512
+ <script type="module" crossorigin src="./assets/iframe-nuCPRPrd.js"></script>
513
513
  </head>
514
514
 
515
515
  <body>
@@ -1 +1 @@
1
- {"generatedAt":1725282370950,"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":false,"hasStorybookEslint":true,"refCount":0,"testPackages":{"@types/jest":"29.5.12","@vitest/coverage-c8":"0.31.4","eslint-plugin-vitest":null,"eslint-plugin-vitest-globals":"1.5.0","vitest":"1.6.0"},"packageManager":{"type":"yarn","version":"1.22.19"},"typescriptOptions":{"reactDocgen":"react-docgen"},"preview":{"usesGlobals":false},"framework":{"name":"@storybook/react-vite","options":{}},"builder":"@storybook/builder-vite","renderer":"@storybook/react","storybookVersion":"8.2.8","storybookVersionSpecifier":"^8.2.4","language":"typescript","storybookPackages":{"@storybook/addon-essentials":{"version":"8.2.8"},"@storybook/addon-links":{"version":"8.2.8"},"@storybook/preview-api":{"version":"8.2.8"},"@storybook/react":{"version":"8.2.8"},"@storybook/react-vite":{"version":"8.2.8"},"@storybook/test":{"version":"8.2.8"},"@storybook/test-runner":{"version":"0.19.1"},"eslint-plugin-storybook":{"version":"0.6.15"},"storybook":{"version":"8.2.8"}},"addons":{"@storybook/addon-actions":{"version":"8.2.8"},"@storybook/addon-docs":{"version":"8.2.8"},"@storybook/addon-interactions":{"version":"8.2.8"},"storybook-dark-mode":{"version":"4.0.2"}}}
1
+ {"generatedAt":1725367286051,"hasCustomBabel":false,"hasCustomWebpack":false,"hasStaticDirs":false,"hasStorybookEslint":true,"refCount":0,"testPackages":{"@types/jest":"29.5.12","@vitest/coverage-c8":"0.31.4","eslint-plugin-vitest":null,"eslint-plugin-vitest-globals":"1.5.0","vitest":"1.6.0"},"packageManager":{"type":"yarn","version":"1.22.19"},"typescriptOptions":{"reactDocgen":"react-docgen"},"preview":{"usesGlobals":false},"framework":{"name":"@storybook/react-vite","options":{}},"builder":"@storybook/builder-vite","renderer":"@storybook/react","storybookVersion":"8.2.8","storybookVersionSpecifier":"^8.2.4","language":"typescript","storybookPackages":{"@storybook/addon-essentials":{"version":"8.2.8"},"@storybook/addon-links":{"version":"8.2.8"},"@storybook/preview-api":{"version":"8.2.8"},"@storybook/react":{"version":"8.2.8"},"@storybook/react-vite":{"version":"8.2.8"},"@storybook/test":{"version":"8.2.8"},"@storybook/test-runner":{"version":"0.19.1"},"eslint-plugin-storybook":{"version":"0.6.15"},"storybook":{"version":"8.2.8"}},"addons":{"@storybook/addon-actions":{"version":"8.2.8"},"@storybook/addon-docs":{"version":"8.2.8"},"@storybook/addon-interactions":{"version":"8.2.8"},"storybook-dark-mode":{"version":"4.0.2"}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "4.12.0-beta-1",
3
+ "version": "4.12.0-beta-2",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "homepage": "https://oliasoft-open-source.gitlab.io/react-ui-library",
6
6
  "bugs": {
@@ -1,3 +0,0 @@
1
- import{j as d}from"./jsx-runtime-eps93zm2.js";import{w as u,e as a,u as n}from"./index-DMAnyMX5.js";import{M as l}from"./actions-Bax0KeqM.js";import{m as g}from"./menu.stories-data-CQ59XhzU.js";import"./index-DhsZuJvc.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./lodash-c4VUpsOs.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./flex-EllkLxgO.js";const A={title:"Basic/Menu/Test Cases",component:l,args:{menu:g},tags:["!autodocs"]},y=s=>d.jsx(l,{...s}),e=y.bind({});e.args={testId:"testId"};e.play=async({canvasElement:s,step:i})=>{const t=s.parentElement?u(s.parentElement):null;await a(t).toBeTruthy(),t&&(await i("Clicking trigger should open menu",async()=>{const r=t.getByTestId("testId");await n.click(r);const o=t.getByTestId("testId-layer");await a(o).toBeInTheDocument()}),await i("Clicking disabled item should do nothing",async()=>{await t.getByText("Knight").click();const o=t.getByTestId("testId-layer");await a(o).toBeInTheDocument()}),await i("Clicking item should close menu",async()=>{const r=t.getByText("King");await n.click(r);const o=t.queryByTestId("testId-layer");await a(o).not.toBeInTheDocument()}))};var m,c,p;e.parameters={...e.parameters,docs:{...(m=e.parameters)==null?void 0:m.docs,source:{originalSource:`args => <Menu
2
- // eslint-disable-next-line react/jsx-props-no-spreading
3
- {...args} />`,...(p=(c=e.parameters)==null?void 0:c.docs)==null?void 0:p.source}}};const F=["Test"];export{e as Test,F as __namedExportsOrder,A as default};
@@ -1,61 +0,0 @@
1
- import{j as o}from"./jsx-runtime-eps93zm2.js";import{l as ae}from"./lodash-c4VUpsOs.js";import{r as q}from"./index-DhsZuJvc.js";import{c as G}from"./index-Bk2sglWO.js";import{G as ie,I as Ee}from"./common-types-Sih75Sav.js";import{D as me}from"./disabled-context-rmpd7YJS.js";import{i as ne}from"./types-Dx2TtIG9.js";import{T as pe,u as We,m as ze}from"./tooltip-1V7clEnw.js";import{A as P,E as B,K as Ge}from"./enum-Bnn40S8Q.js";import{a as $e,_ as Ue}from"./inheritsLoose-DP0QEDDI.js";import{_ as ge}from"./assertThisInitialized-B9jnkVVz.js";import{m as le}from"./memoize-one.esm-CcMeOnPo.js";import{M as se}from"./types-BmbYqTX_.js";import{T as ue}from"./text-B3-TSWok.js";import{A as Ve}from"./actions-Bax0KeqM.js";import{I as ce}from"./icon-BSFY3vDO.js";import{s as Ye}from"./select.input-CJed_LLR.js";const Ke="_inputInTable_sl2b5_1",Be="_inputHover_sl2b5_13",Ze="_inputFocus_sl2b5_18",Xe="_inputError_sl2b5_25",Je="_inputWarning_sl2b5_26",Qe="_inputDisabled_sl2b5_61",en="_hideScrollbars_sl2b5_67",nn="_select_sl2b5_77",tn="_isInTable_sl2b5_121",rn="_unSelected_sl2b5_133",an="_small_sl2b5_174",sn="_right_sl2b5_182",ln="_groupOrderFirst_sl2b5_193",on="_groupOrderMiddle_sl2b5_194",un="_groupOrderLast_sl2b5_198",U={inputInTable:Ke,inputHover:Be,inputFocus:Ze,inputError:Xe,inputWarning:Je,inputDisabled:Qe,hideScrollbars:en,select:nn,isInTable:tn,unSelected:rn,small:an,right:sn,groupOrderFirst:ln,groupOrderMiddle:on,groupOrderLast:un},we=({disabled:e=!1,error:n=null,warning:r=null,tooltip:a=null,options:s,onChange:g=ae.noop,onFocus:S=ae.noop,onBlur:u=ae.noop,right:c=!1,small:d=!1,tabIndex:T=0,selectedOption:m,width:b=null,groupOrder:E=null,testId:v,isInTable:t=!1,clearable:i,placeholder:l,hasNonExistentValue:p,maxTooltipWidth:y,borderRadius:I})=>{const f=q.useContext(me),h=m===null||(m==null?void 0:m.value)===null?"unselected":m==null?void 0:m.value,w=h==="unselected",N=(h==="unselected"||i?[o.jsx("option",{value:"unselected",disabled:!i,hidden:!i,children:l||"Select..."},"unselected")]:[]).concat(p?[o.jsx("option",{value:m==null?void 0:m.value,disabled:e||f,children:m==null?void 0:m.label},"selectedNonExistentValue")]:[]).concat(s.map((L,R)=>o.jsx("option",{value:L.value,"data-testid":L.testId,children:L.label},R))),x=(()=>{if(E)switch(E){case ie.FIRST:return U.groupOrderFirst;case ie.LAST:return U.groupOrderLast;default:return U.groupOrderMiddle}return""})();return o.jsx(pe,{error:!!n,warning:!!r,text:a||n||r,enabled:a&&ne(a)||n&&ne(n)||r&&ne(r)||!1,maxWidth:y,placement:"bottom-center",children:o.jsx("select",{className:G(U.select,w?U.unSelected:"",c?U.right:"",d?U.small:"",t?U.isInTable:"",x),style:{width:b||"",borderRadius:I||""},onChange:L=>{const{value:R}=L.target;let C;R==="unselected"?C={value:null}:C=s.find(F=>String(F.value)===String(R))||{value:null},g(L,C)},onFocus:S,onBlur:u,tabIndex:T,value:h,disabled:e||f,"data-error":n||null,"data-warning":r||null,"data-testid":v,children:N})})};we.__docgenInfo={description:"",methods:[],displayName:"NativeSelect",props:{borderRadius:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | React.ReactNode | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactReactNode",raw:"React.ReactNode"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},warning:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | React.ReactNode | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactReactNode",raw:"React.ReactNode"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},tooltip:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | React.ReactNode | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactReactNode",raw:"React.ReactNode"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},options:{required:!0,tsType:{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
2
- evt: ChangeEvent<HTMLSelectElement>,
3
- value: ISelectSelectedOption | { value: null },
4
- ) => void`,signature:{arguments:[{type:{name:"ChangeEvent",elements:[{name:"HTMLSelectElement"}],raw:"ChangeEvent<HTMLSelectElement>"},name:"evt"},{type:{name:"union",raw:"ISelectSelectedOption | { value: null }",elements:[{name:"ISelectSelectedOption"},{name:"signature",type:"object",raw:"{ value: null }",signature:{properties:[{key:"value",value:{name:"null",required:!0}}]}}]},name:"value"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},right:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},tabIndex:{required:!1,tsType:{name:"number"},description:"",defaultValue:{value:"0",computed:!1}},selectedOption:{required:!1,tsType:{name:"ISelectSelectedOption"},description:""},width:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},groupOrder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:"",defaultValue:{value:"null",computed:!1}},testId:{required:!1,tsType:{name:"union",raw:"string | undefined",elements:[{name:"string"},{name:"undefined"}]},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},clearable:{required:!1,tsType:{name:"boolean"},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},hasNonExistentValue:{required:!1,tsType:{name:"boolean"},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""}}};const Oe=()=>{const e=q.useRef(null);return[e,()=>{e.current&&e.current.focus()}]},Le=()=>{const[e,n]=q.useState(!1);return q.useEffect(()=>{(async()=>{document.fonts&&await document.fonts.ready.then(()=>n(!0))})()},[]),e};var cn=typeof performance=="object"&&typeof performance.now=="function",ve=cn?function(){return performance.now()}:function(){return Date.now()};function ye(e){cancelAnimationFrame(e.id)}function dn(e,n){var r=ve();function a(){ve()-r>=n?e.call(null):s.id=requestAnimationFrame(a)}var s={id:requestAnimationFrame(a)};return s}var oe=-1;function he(e){if(e===void 0&&(e=!1),oe===-1||e){var n=document.createElement("div"),r=n.style;r.width="50px",r.height="50px",r.overflow="scroll",document.body.appendChild(n),oe=n.offsetWidth-n.clientWidth,document.body.removeChild(n)}return oe}var ee=null;function Se(e){if(e===void 0&&(e=!1),ee===null||e){var n=document.createElement("div"),r=n.style;r.width="50px",r.height="50px",r.overflow="scroll",r.direction="rtl";var a=document.createElement("div"),s=a.style;return s.width="100px",s.height="100px",n.appendChild(a),document.body.appendChild(n),n.scrollLeft>0?ee="positive-descending":(n.scrollLeft=1,n.scrollLeft===0?ee="negative":ee="positive-ascending"),document.body.removeChild(n),ee}return ee}var mn=150,pn=function(n,r){return n};function fn(e){var n,r=e.getItemOffset,a=e.getEstimatedTotalSize,s=e.getItemSize,g=e.getOffsetForIndexAndAlignment,S=e.getStartIndexForOffset,u=e.getStopIndexForStartIndex,c=e.initInstanceProps,d=e.shouldResetStyleCacheOnItemSizeChange,T=e.validateProps;return n=function(m){$e(b,m);function b(v){var t;return t=m.call(this,v)||this,t._instanceProps=c(t.props,ge(t)),t._outerRef=void 0,t._resetIsScrollingTimeoutId=null,t.state={instance:ge(t),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof t.props.initialScrollOffset=="number"?t.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},t._callOnItemsRendered=void 0,t._callOnItemsRendered=le(function(i,l,p,y){return t.props.onItemsRendered({overscanStartIndex:i,overscanStopIndex:l,visibleStartIndex:p,visibleStopIndex:y})}),t._callOnScroll=void 0,t._callOnScroll=le(function(i,l,p){return t.props.onScroll({scrollDirection:i,scrollOffset:l,scrollUpdateWasRequested:p})}),t._getItemStyle=void 0,t._getItemStyle=function(i){var l=t.props,p=l.direction,y=l.itemSize,I=l.layout,f=t._getItemStyleCache(d&&y,d&&I,d&&p),h;if(f.hasOwnProperty(i))h=f[i];else{var w=r(t.props,i,t._instanceProps),N=s(t.props,i,t._instanceProps),x=p==="horizontal"||I==="horizontal",L=p==="rtl",R=x?w:0;f[i]=h={position:"absolute",left:L?void 0:R,right:L?R:void 0,top:x?0:w,height:x?"100%":N,width:x?N:"100%"}}return h},t._getItemStyleCache=void 0,t._getItemStyleCache=le(function(i,l,p){return{}}),t._onScrollHorizontal=function(i){var l=i.currentTarget,p=l.clientWidth,y=l.scrollLeft,I=l.scrollWidth;t.setState(function(f){if(f.scrollOffset===y)return null;var h=t.props.direction,w=y;if(h==="rtl")switch(Se()){case"negative":w=-y;break;case"positive-descending":w=I-p-y;break}return w=Math.max(0,Math.min(w,I-p)),{isScrolling:!0,scrollDirection:f.scrollOffset<w?"forward":"backward",scrollOffset:w,scrollUpdateWasRequested:!1}},t._resetIsScrollingDebounced)},t._onScrollVertical=function(i){var l=i.currentTarget,p=l.clientHeight,y=l.scrollHeight,I=l.scrollTop;t.setState(function(f){if(f.scrollOffset===I)return null;var h=Math.max(0,Math.min(I,y-p));return{isScrolling:!0,scrollDirection:f.scrollOffset<h?"forward":"backward",scrollOffset:h,scrollUpdateWasRequested:!1}},t._resetIsScrollingDebounced)},t._outerRefSetter=function(i){var l=t.props.outerRef;t._outerRef=i,typeof l=="function"?l(i):l!=null&&typeof l=="object"&&l.hasOwnProperty("current")&&(l.current=i)},t._resetIsScrollingDebounced=function(){t._resetIsScrollingTimeoutId!==null&&ye(t._resetIsScrollingTimeoutId),t._resetIsScrollingTimeoutId=dn(t._resetIsScrolling,mn)},t._resetIsScrolling=function(){t._resetIsScrollingTimeoutId=null,t.setState({isScrolling:!1},function(){t._getItemStyleCache(-1,null)})},t}b.getDerivedStateFromProps=function(t,i){return gn(t,i),T(t),null};var E=b.prototype;return E.scrollTo=function(t){t=Math.max(0,t),this.setState(function(i){return i.scrollOffset===t?null:{scrollDirection:i.scrollOffset<t?"forward":"backward",scrollOffset:t,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},E.scrollToItem=function(t,i){i===void 0&&(i="auto");var l=this.props,p=l.itemCount,y=l.layout,I=this.state.scrollOffset;t=Math.max(0,Math.min(t,p-1));var f=0;if(this._outerRef){var h=this._outerRef;y==="vertical"?f=h.scrollWidth>h.clientWidth?he():0:f=h.scrollHeight>h.clientHeight?he():0}this.scrollTo(g(this.props,t,i,I,this._instanceProps,f))},E.componentDidMount=function(){var t=this.props,i=t.direction,l=t.initialScrollOffset,p=t.layout;if(typeof l=="number"&&this._outerRef!=null){var y=this._outerRef;i==="horizontal"||p==="horizontal"?y.scrollLeft=l:y.scrollTop=l}this._callPropsCallbacks()},E.componentDidUpdate=function(){var t=this.props,i=t.direction,l=t.layout,p=this.state,y=p.scrollOffset,I=p.scrollUpdateWasRequested;if(I&&this._outerRef!=null){var f=this._outerRef;if(i==="horizontal"||l==="horizontal")if(i==="rtl")switch(Se()){case"negative":f.scrollLeft=-y;break;case"positive-ascending":f.scrollLeft=y;break;default:var h=f.clientWidth,w=f.scrollWidth;f.scrollLeft=w-h-y;break}else f.scrollLeft=y;else f.scrollTop=y}this._callPropsCallbacks()},E.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&ye(this._resetIsScrollingTimeoutId)},E.render=function(){var t=this.props,i=t.children,l=t.className,p=t.direction,y=t.height,I=t.innerRef,f=t.innerElementType,h=t.innerTagName,w=t.itemCount,N=t.itemData,x=t.itemKey,L=x===void 0?pn:x,R=t.layout,C=t.outerElementType,A=t.outerTagName,F=t.style,z=t.useIsScrolling,V=t.width,$=this.state.isScrolling,j=p==="horizontal"||R==="horizontal",D=j?this._onScrollHorizontal:this._onScrollVertical,Z=this._getRangeToRender(),te=Z[0],re=Z[1],X=[];if(w>0)for(var k=te;k<=re;k++)X.push(q.createElement(i,{data:N,key:L(k,N),index:k,isScrolling:z?$:void 0,style:this._getItemStyle(k)}));var J=a(this.props,this._instanceProps);return q.createElement(C||A||"div",{className:l,onScroll:D,ref:this._outerRefSetter,style:Ue({position:"relative",height:y,width:V,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:p},F)},q.createElement(f||h||"div",{children:X,ref:I,style:{height:j?"100%":J,pointerEvents:$?"none":void 0,width:j?J:"100%"}}))},E._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var t=this.props.itemCount;if(t>0){var i=this._getRangeToRender(),l=i[0],p=i[1],y=i[2],I=i[3];this._callOnItemsRendered(l,p,y,I)}}if(typeof this.props.onScroll=="function"){var f=this.state,h=f.scrollDirection,w=f.scrollOffset,N=f.scrollUpdateWasRequested;this._callOnScroll(h,w,N)}},E._getRangeToRender=function(){var t=this.props,i=t.itemCount,l=t.overscanCount,p=this.state,y=p.isScrolling,I=p.scrollDirection,f=p.scrollOffset;if(i===0)return[0,0,0,0];var h=S(this.props,f,this._instanceProps),w=u(this.props,h,f,this._instanceProps),N=!y||I==="backward"?Math.max(1,l):1,x=!y||I==="forward"?Math.max(1,l):1;return[Math.max(0,h-N),Math.max(0,Math.min(i-1,w+x)),h,w]},b}(q.PureComponent),n.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},n}var gn=function(n,r){n.children,n.direction,n.height,n.layout,n.innerTagName,n.outerTagName,n.width,r.instance},vn=fn({getItemOffset:function(n,r){var a=n.itemSize;return r*a},getItemSize:function(n,r){var a=n.itemSize;return a},getEstimatedTotalSize:function(n){var r=n.itemCount,a=n.itemSize;return a*r},getOffsetForIndexAndAlignment:function(n,r,a,s,g,S){var u=n.direction,c=n.height,d=n.itemCount,T=n.itemSize,m=n.layout,b=n.width,E=u==="horizontal"||m==="horizontal",v=E?b:c,t=Math.max(0,d*T-v),i=Math.min(t,r*T),l=Math.max(0,r*T-v+T+S);switch(a==="smart"&&(s>=l-v&&s<=i+v?a="auto":a="center"),a){case"start":return i;case"end":return l;case"center":{var p=Math.round(l+(i-l)/2);return p<Math.ceil(v/2)?0:p>t+Math.floor(v/2)?t:p}case"auto":default:return s>=l&&s<=i?s:s<l?l:i}},getStartIndexForOffset:function(n,r){var a=n.itemCount,s=n.itemSize;return Math.max(0,Math.min(a-1,Math.floor(r/s)))},getStopIndexForStartIndex:function(n,r,a){var s=n.direction,g=n.height,S=n.itemCount,u=n.itemSize,c=n.layout,d=n.width,T=s==="horizontal"||c==="horizontal",m=r*u,b=T?d:g,E=Math.ceil((b+a-m)/u);return Math.max(0,Math.min(S-1,r+E-1))},initInstanceProps:function(n){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(n){n.itemSize}});const yn="_layerContainer_1lbvo_1",hn="_layer_1lbvo_1",Sn="_small_1lbvo_23",Tn="_heading_1lbvo_26",bn="_option_1lbvo_27",_n="_message_1lbvo_28",In="_focused_1lbvo_64",En="_selected_1lbvo_68",wn="_disabled_1lbvo_71",On="_check_1lbvo_75",Ln="_optionContent_1lbvo_92",Rn="_label_1lbvo_97",qn="_icon_1lbvo_104",xn="_details_1lbvo_109",H={layerContainer:yn,layer:hn,small:Sn,heading:Tn,option:bn,message:_n,focused:In,selected:En,disabled:wn,check:On,optionContent:Ln,label:Rn,icon:qn,details:xn},Re=({label:e})=>o.jsx("div",{onClick:n=>n.stopPropagation(),className:H.heading,children:e});Re.__docgenInfo={description:"",methods:[],displayName:"Heading",props:{label:{required:!0,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""}}};const qe=({details:e,label:n,icon:r,disabled:a=!1,selected:s=!1,focused:g=!1,onSelectOption:S,actions:u,closeLayer:c,testId:d})=>o.jsxs("div",{className:G(H.option,a?H.disabled:"",s?H.selected:"",g?H.focused:""),onClick:!a&&S?S:void 0,"data-testid":d,children:[o.jsx("div",{className:H.optionContent,children:o.jsxs("span",{className:H.label,title:n,children:[n,r&&o.jsx("span",{className:H.icon,children:r})]})}),e&&o.jsx("div",{className:G(H.details),children:o.jsx(ue,{faint:!0,children:e})}),!!(u!=null&&u.length)&&o.jsx("div",{className:G(H.actions),children:o.jsx(Ve,{actions:u,closeLayer:c})}),o.jsx("span",{className:H.check,children:s?o.jsx(ce,{icon:Ee.CHECK}):null})]});qe.__docgenInfo={description:"",methods:[],displayName:"Option",props:{details:{required:!1,tsType:{name:"string"},description:""},label:{required:!0,tsType:{name:"string"},description:""},icon:{required:!1,tsType:{name:"ReactNode"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},selected:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},focused:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},onSelectOption:{required:!1,tsType:{name:"signature",type:"function",raw:`(
5
- event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
6
- section?: ISelectSectionProps,
7
- ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"signature",type:"object",raw:`{
8
- section: ISelectSection;
9
- selected?: boolean;
10
- focused?: boolean;
11
- onSelectOption?: (
12
- event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
13
- section?: ISelectSectionProps,
14
- ) => void;
15
- closeLayer?: TEmpty;
16
- }`,signature:{properties:[{key:"section",value:{name:"ISelectSection",required:!0}},{key:"selected",value:{name:"boolean",required:!1}},{key:"focused",value:{name:"boolean",required:!1}},{key:"onSelectOption",value:{name:"signature",type:"function",raw:`(
17
- event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
18
- section?: ISelectSectionProps,
19
- ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"ISelectSectionProps"},name:"section"}],return:{name:"void"}},required:!1}},{key:"closeLayer",value:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}},required:!1}}]}},name:"section"}],return:{name:"void"}}},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"any"}],raw:"any[]"},description:""},closeLayer:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({section:e,selected:n,focused:r,onSelectOption:a,closeLayer:s})=>{const g=q.useContext(me);switch(e.type){case se.HEADING:return o.jsx(Re,{label:e.label});case se.OPTION:default:return o.jsx(qe,{closeLayer:s,actions:e.actions,label:e.label,details:e.details,icon:e.icon,disabled:e.disabled||g,selected:n,focused:r,onSelectOption:a,testId:e.testId})}};xe.__docgenInfo={description:"",methods:[],displayName:"Section",props:{section:{required:!0,tsType:{name:"ISelectSection"},description:""},selected:{required:!1,tsType:{name:"boolean"},description:""},focused:{required:!1,tsType:{name:"boolean"},description:""},onSelectOption:{required:!1,tsType:{name:"signature",type:"function",raw:`(
20
- event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
21
- section?: ISelectSectionProps,
22
- ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"signature",type:"object",raw:`{
23
- section: ISelectSection;
24
- selected?: boolean;
25
- focused?: boolean;
26
- onSelectOption?: (
27
- event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
28
- section?: ISelectSectionProps,
29
- ) => void;
30
- closeLayer?: TEmpty;
31
- }`,signature:{properties:[{key:"section",value:{name:"ISelectSection",required:!0}},{key:"selected",value:{name:"boolean",required:!1}},{key:"focused",value:{name:"boolean",required:!1}},{key:"onSelectOption",value:{name:"signature",type:"function",raw:`(
32
- event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
33
- section?: ISelectSectionProps,
34
- ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"ISelectSectionProps"},name:"section"}],return:{name:"void"}},required:!1}},{key:"closeLayer",value:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}},required:!1}}]}},name:"section"}],return:{name:"void"}}},description:""},closeLayer:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""}}};const de=(e,n)=>{const a=document.createElement("canvas").getContext("2d");return a?(a.font=n,a.measureText(e).width):0},Ce="13px",Me="12px",Cn="Roobert",Mn="sans-serif",Nn=12,An=8,Fn=30,Hn=24,jn=5,Dn=3,kn=1,Pn=2,Te=10,Ne=(e=!1,n=!1)=>`${e?Me:Ce} ${n?Cn:Mn}`,Wn=(e=!1,n=!1)=>(e?An:Nn)+(e?Hn:Fn)+(n?17:0),be=(e,n,r,a)=>{const s=Ne(n,r),g=a?de(a,s):0,S=Math.ceil(e.reduce((c,d)=>{var v;const T=(((v=d==null?void 0:d.actions)==null?void 0:v.length)??0)*24,m=d.icon?parseInt(n?Me:Ce)+7:0,b=`${d.label} ${d.details||""}`,E=de(b,s)+T+m;return c=E>c?E:c,c},g)),u=Wn(n,!0);return S+u},zn=(e,n,r)=>{const a=Ne(!0,r),s=de(e.label,a),g=(n?Dn:jn)*2+kn*2+Pn;return Math.ceil(s+g)},Ae=({listRef:e,isMulti:n,sections:r,selectedOptions:a,onSelectOption:s,focusedOptionIndex:g,width:S,small:u,firstSelectedOptionIndex:c,closeLayer:d,testId:T})=>{q.useEffect(()=>{c&&c!==null&&e.current!==null&&e.current.scrollToItem(c,"start")},[c,e]);const m=u?24:30;return o.jsx("div",{"data-testid":T,className:G(H.layer,u&&H.small),children:r.length?o.jsx(vn,{ref:e,height:r.length<Te?m*r.length:m*Te,itemCount:r.length,itemSize:m,width:S,children:({index:b,style:E})=>{var v;return o.jsx("div",{style:E,children:o.jsx(xe,{closeLayer:d,section:r[b],selected:n&&r[b].type!==se.HEADING&&Array.isArray(a)?a.some(t=>{var i;return t&&(t==null?void 0:t.value)===((i=r==null?void 0:r[b])==null?void 0:i.value)}):!Array.isArray(a)&&((v=r==null?void 0:r[b])==null?void 0:v.value)===(a==null?void 0:a.value),focused:g===b,onSelectOption:t=>s(t,r[b])})})}}):o.jsx("ul",{children:o.jsx("li",{children:o.jsx("div",{className:H.message,style:{width:S},children:"No matches"})})})})};Ae.__docgenInfo={description:"",methods:[],displayName:"Layer",props:{listRef:{required:!0,tsType:{name:"RefObject",elements:[{name:"any"}],raw:"RefObject<any>"},description:""},isMulti:{required:!1,tsType:{name:"boolean"},description:""},sections:{required:!0,tsType:{name:"Array",elements:[{name:"ISelectSection"}],raw:"ISelectSection[]"},description:""},selectedOptions:{required:!0,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},onSelectOption:{required:!0,tsType:{name:"signature",type:"function",raw:`(
35
- event?: React.MouseEvent<HTMLDivElement, MouseEvent>,
36
- section?: ISelectSection,
37
- ) => void`,signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"event"},{type:{name:"ISelectSection"},name:"section"}],return:{name:"void"}}},description:""},focusedOptionIndex:{required:!1,tsType:{name:"number"},description:""},width:{required:!0,tsType:{name:"number"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},firstSelectedOptionIndex:{required:!1,tsType:{name:"number"},description:""},closeLayer:{required:!0,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Gn="_inputInTable_7uwhv_1",$n="_inputHover_7uwhv_13",Un="_inputFocus_7uwhv_18",Vn="_inputError_7uwhv_25",Yn="_inputWarning_7uwhv_26",Kn="_inputDisabled_7uwhv_61",Bn="_hideScrollbars_7uwhv_67",Zn="_trigger_7uwhv_77",Xn="_isInTable_7uwhv_93",Jn="_input_7uwhv_1",Qn="_isOpen_7uwhv_114",et="_disabled_7uwhv_156",nt="_icons_7uwhv_162",tt="_clearAll_7uwhv_169",rt="_iconOpen_7uwhv_170",at="_small_7uwhv_181",it="_triggerInputContainer_7uwhv_189",st="_right_7uwhv_198",lt="_multiOptions_7uwhv_211",ot="_multiOption_7uwhv_211",ut="_label_7uwhv_239",ct="_closeMultiOption_7uwhv_242",dt="_focus_7uwhv_253",mt="_selectedSingleValue_7uwhv_257",pt="_placeHolder_7uwhv_258",ft="_groupOrderFirst_7uwhv_297",gt="_groupOrderMiddle_7uwhv_298",vt="_groupOrderLast_7uwhv_302",yt="_detailedLabel_7uwhv_307",M={inputInTable:Gn,inputHover:$n,inputFocus:Un,inputError:Vn,inputWarning:Yn,inputDisabled:Kn,hideScrollbars:Bn,trigger:Zn,isInTable:Xn,input:Jn,isOpen:Qn,disabled:et,icons:nt,clearAll:tt,iconOpen:rt,small:at,triggerInputContainer:it,right:st,multiOptions:lt,multiOption:ot,label:ut,closeMultiOption:ct,focus:dt,selectedSingleValue:mt,placeHolder:pt,groupOrderFirst:ft,groupOrderMiddle:gt,groupOrderLast:vt,detailedLabel:yt},Fe=({selectedOptions:e,small:n,width:r,testId:a})=>{const s=Le(),[g,S]=q.useState([]),[u,c]=q.useState([]);return q.useEffect(()=>{let d=[],T=[],m=0;e.forEach((b,E)=>{m+=zn(b,n,s),E===e.length-1&&m<r||m<r-24?d.push(b):T.push(b)}),S(d),c(T)},[e,s,r]),o.jsxs("div",{className:M.multiOptions,"data-testid":a&&`${a}-value`,children:[g.filter(d=>d&&d.label).map((d,T)=>o.jsx("span",{className:M.multiOption,onClick:m=>{m.stopPropagation()},children:d.label},T)),u.length>0&&o.jsx(pe,{text:u.map((d,T)=>o.jsx("div",{children:d.label},T)),display:"inline-flex",children:o.jsx("span",{className:M.multiOption,children:g.length?`+${u.length}`:`${u.length} items`})})]})};Fe.__docgenInfo={description:"",methods:[],displayName:"MultiSelectedOptions",props:{selectedOptions:{required:!0,tsType:{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!0,tsType:{name:"number"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const He=({selectedOptions:e,searchable:n=!1,searchValue:r,onChange:a=ae.noop,inputRef:s,error:g,placeholder:S="Select...",small:u,testId:c})=>{const d=q.useRef(null),T=Array.isArray(e),m=T?e.length>0:!!e,b=r?r.length+1:1,E=()=>{var i,l;const v=((i=d.current)==null?void 0:i.offsetWidth)||0,t=((l=s.current)==null?void 0:l.offsetWidth)||0;return v-t};return o.jsxs("div",{className:M.triggerInputContainer,ref:d,children:[m?T?o.jsx(Fe,{selectedOptions:e,small:u,width:E(),testId:c}):o.jsx("span",{className:M.selectedSingleValue,"data-testid":c&&`${c}-value`,children:r!=null&&r.length?"":e==null?void 0:e.label}):o.jsx("span",{className:M.placeHolder,children:r!=null&&r.length?"":S}),n?o.jsx("input",{tabIndex:-1,ref:s,size:b,className:M.input,value:r,onChange:v=>a(v.target.value),"data-error":g||null,"data-testid":c&&`${c}-input`}):null]})};He.__docgenInfo={description:"",methods:[],displayName:"Input",props:{selectedOptions:{required:!1,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},searchValue:{required:!1,tsType:{name:"string"},description:""},inputRef:{required:!0,tsType:{name:"MutableRefObject",elements:[{name:"union",raw:"HTMLInputElement | null",elements:[{name:"HTMLInputElement"},{name:"null"}]}],raw:"MutableRefObject<HTMLInputElement | null>"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:"",defaultValue:{value:"noop",computed:!0}},error:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:"",defaultValue:{value:"'Select...'",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const je=({selectedOptions:e,searchValue:n,searchable:r,clearable:a,onClickTrigger:s,element:g,error:S,warning:u,tooltip:c,small:d,isInTable:T,disabled:m,onChangeSearch:b,onClickDeselect:E,onClickClear:v,tabIndex:t,isOpen:i,triggerRef:l,clearAllIsFocused:p,focusedSelectedOptionIndex:y,onFocus:I,onBlur:f,groupOrder:h,maxTooltipWidth:w,placeholder:N,right:x,testId:L})=>{var j;const[R,C]=Oe(),A=Array.isArray(e)?e.length>0&&((j=e[0])==null?void 0:j.value):e==null?void 0:e.value,F=a&&A,z=(()=>{if(h)switch(h){case ie.FIRST:return M.groupOrderFirst;case ie.LAST:return M.groupOrderLast;default:return M.groupOrderMiddle}return""})(),V=!Array.isArray(e)&&(e!=null&&e.details)?{...e,label:o.jsxs("div",{className:G(M.detailedLabel),children:[o.jsx(ue,{children:e.label}),o.jsx(ue,{muted:!0,children:e.details})]})}:e,$=o.jsxs(o.Fragment,{children:[g,o.jsxs("div",{ref:l,tabIndex:t,className:G(M.trigger,i?M.isOpen:"",m?M.disabled:"",d?M.small:"",T?M.isInTable:"",x?M.right:"",z),onClick:D=>{D.stopPropagation(),typeof C=="function"&&C(),s(D)},onFocus:I,onBlur:f,"data-error":S||null,"data-warning":u||null,"data-testid":L,children:[o.jsx(He,{selectedOptions:V,placeholder:N,searchable:r,searchValue:n,inputRef:R,onChange:b,error:S,small:d,testId:L}),o.jsx("span",{className:M.icons,children:F?o.jsx("span",{className:G(M.clearAll,p?M.focus:""),onClick:D=>{D.stopPropagation(),v&&v(D)},"data-testid":L&&`${L}-clear`,children:o.jsx(ce,{icon:Ee.CLOSE})}):o.jsx("span",{className:G(M.iconOpen),children:o.jsx(ce,{icon:"chevron down"})})})]})]});return o.jsx(o.Fragment,{children:o.jsx(pe,{error:!!S,warning:!!u,text:c||S||u,enabled:c&&ne(c)||S&&ne(S)||u&&ne(u)||!1,maxWidth:w,placement:"bottom-center",children:$})})};je.__docgenInfo={description:"",methods:[],displayName:"Trigger",props:{selectedOptions:{required:!1,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},searchValue:{required:!1,tsType:{name:"string"},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:""},clearable:{required:!1,tsType:{name:"boolean"},description:""},onClickTrigger:{required:!0,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLDivElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},element:{required:!1,tsType:{name:"ReactNode"},description:""},error:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},warning:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},tooltip:{required:!1,tsType:{name:"union",raw:"string | ReactNode",elements:[{name:"string"},{name:"ReactNode"}]},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},onChangeSearch:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},onClickDeselect:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLDivElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLDivElement, MouseEvent>",elements:[{name:"HTMLDivElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},onClickClear:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void",signature:{arguments:[{type:{name:"ReactMouseEvent",raw:"React.MouseEvent<HTMLSpanElement, MouseEvent>",elements:[{name:"HTMLSpanElement"},{name:"MouseEvent"}]},name:"evt"}],return:{name:"void"}}},description:""},tabIndex:{required:!1,tsType:{name:"number"},description:""},isOpen:{required:!1,tsType:{name:"boolean"},description:""},triggerRef:{required:!1,tsType:{name:"RefObject",elements:[{name:"HTMLDivElement"}],raw:"RefObject<HTMLDivElement>"},description:""},clearAllIsFocused:{required:!1,tsType:{name:"boolean"},description:""},focusedSelectedOptionIndex:{required:!1,tsType:{name:"number"},description:""},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.FocusEvent<HTMLDivElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLDivElement>",elements:[{name:"HTMLDivElement"}]},name:"evt"}],return:{name:"void"}}},description:""},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: React.FocusEvent<HTMLDivElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLDivElement>",elements:[{name:"HTMLDivElement"}]},name:"evt"}],return:{name:"void"}}},description:""},groupOrder:{required:!1,tsType:{name:"union",raw:"TGroupOrder | string",elements:[{name:"union",raw:"'first' | 'middle' | 'last'",elements:[{name:"literal",value:"'first'"},{name:"literal",value:"'middle'"},{name:"literal",value:"'last'"}]},{name:"string"}]},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var W=(e=>(e.SET_VISIBLE_OPTIONS="SET_VISIBLE_OPTIONS",e.RESET_LAYER_FOCUS="RESET_LAYER_FOCUS",e.CLEAR_SEARCH="CLEAR_SEARCH",e.ON_CHANGE_SEARCH="ON_CHANGE_SEARCH",e.FOCUS_TRIGGER_INPUTS="FOCUS_TRIGGER_INPUTS",e.BLUR_TRIGGER_INPUTS="BLUR_TRIGGER_INPUTS",e.FOCUS_LAYER_OPTIONS="FOCUS_LAYER_OPTIONS",e.OPEN_LAYER="OPEN_LAYER",e.CLOSE_LAYER="CLOSE_LAYER",e))(W||{});const De={options:["none","clearAll"],currentIndex:0,currentOption:!1,clearAll:!1},ht=e=>e!==null?e+1:0,ke=(e,n)=>{const r=["none",...e.map((s,g)=>s.type!==se.HEADING?g:null).filter(s=>s!==null)],a=ht(n);return{options:r,currentIndex:a,current:r[a]}},St=(e,n)=>{const r=e==="up"?-1:1,a=n.currentIndex+r,s=(a<0?n.options.length-1:a)%n.options.length,g=n.options[s];return{...n,currentIndex:s,current:g}},Tt=(e,n,r)=>{const a=e==="left"?-1:1,s=n&&n.length?["none",...Array.from({length:n.length},(d,T)=>T),"clearAll"]:["none","clearAll"],g=r.currentIndex+a,S=(g<0?s.length-1:g)%s.length,u=s[S];return{options:s,currentIndex:S,currentOption:u,clearAll:u==="clearAll"}},_e=()=>De,Ie=e=>({...e,currentIndex:0,current:"none"}),bt=(e,n)=>{switch(n.type){case W.SET_VISIBLE_OPTIONS:return{...e,visibleOptions:n.options||[]};case W.RESET_LAYER_FOCUS:return{...e,layerFocus:ke(n.options||[],n.firstSelectedOptionIndex||0)};case W.CLEAR_SEARCH:return{...e,visibleOptions:n.options||[],searchValue:""};case W.ON_CHANGE_SEARCH:{let a=[...(n.options||[]).filter(s=>(String(s.label)+(s.details?String(s.details):"")).toLowerCase().includes(String(n.value||"").toLowerCase()))];return n.createAble&&n.value&&n.value!==""&&a.push({label:`Create "${n.value}"`,value:n.value,createAble:!0}),{...e,searchValue:n.value,visibleOptions:a,layerFocus:Ie(e.layerFocus)}}case W.FOCUS_TRIGGER_INPUTS:return{...e,triggerFocus:Tt(n.direction||"right",n.selectedOptions||[],e.triggerFocus),layerFocus:Ie(e.layerFocus)};case W.BLUR_TRIGGER_INPUTS:return{...e,triggerFocus:_e()};case W.FOCUS_LAYER_OPTIONS:return n.nextLayerFocus?{...e,layerFocus:n.nextLayerFocus,triggerFocus:_e()}:e;case W.OPEN_LAYER:return{...e,isLayerOpen:!0};case W.CLOSE_LAYER:return{...e,isLayerOpen:!1};default:return e}},_t={auto:!0,possiblePlacements:["bottom-start","top-start"],placement:"bottom-start",preferX:"right",preferY:"bottom"},It=({state:e,dispatch:n,options:r,setTriggerFocus:a,disabled:s,disabledContext:g,onCreate:S,onChange:u,selectedOptions:c,width:d,small:T,isFontLoaded:m,placeholder:b,firstSelectedOptionIndex:E,createAble:v,listRef:t,autoLayerWidth:i})=>{const l=()=>{e.isLayerOpen&&n({type:P.CLOSE_LAYER}),a()},p=()=>n({type:P.OPEN_LAYER}),y=q.useRef(!0);q.useEffect(()=>{y.current?y.current=!1:n({type:P.SET_VISIBLE_OPTIONS,options:r})},[r]);const I=(_,O,Q)=>{if(!(s||g)){if(Q&&Q(),O){if(O.createAble&&S)S(O.value);else if(!O.disabled)if(Array.isArray(c))if(c.some(K=>K.label===O.label)){const K=c.filter(fe=>fe.label!==O.label);u&&u(_,K)}else{const K=[...c,O];u&&u(_,K)}else u&&u(_,O)}n({type:P.CLEAR_SEARCH,options:r}),a()}},f=q.useCallback(()=>d?d!=="auto"?d:be(r,T,m,b):"100%",[r,m]),h=q.useCallback(_=>i?Math.max(be(r,T,m,b),_==null?void 0:_.width):_==null?void 0:_.width,[r,m]),{renderLayer:w,layerProps:N,triggerProps:x,triggerBounds:L}=We({isOpen:(e==null?void 0:e.isLayerOpen)??!1,overflowContainer:!0,..._t,ResizeObserver,onOutsideClick:l,onParentClose:l}),R=()=>{if(!(s||g)){if(e.isLayerOpen){l();return}n({type:P.RESET_LAYER_FOCUS,options:r,firstSelectedOptionIndex:E}),p()}},C=q.useRef(!0);q.useEffect(()=>{C.current?C.current=!1:e.isLayerOpen||n({type:P.CLEAR_SEARCH,options:r})},[e.isLayerOpen]);const A=(_,O)=>{const Q=c instanceof Array?c.filter(Y=>Y.value!==O.value):null;u&&u(_,Q)},F=_=>{const O=c instanceof Array?[]:{value:null};u&&u(_,O)},z=_=>n({type:P.ON_CHANGE_SEARCH,options:r,value:_,createAble:v}),V=()=>{p(),n({type:P.BLUR_TRIGGER_INPUTS})},$=_=>{t.current&&Number.isInteger(_)&&t.current.scrollToItem(_)},j=_=>{const O=St(_,e.layerFocus);n({type:P.FOCUS_LAYER_OPTIONS,nextLayerFocus:O}),$(O.current)},D=_=>{n({type:P.FOCUS_TRIGGER_INPUTS,ICustomSelectDirection:_,selectedOptions:c})},Z=_=>F(_),te=c&&c[e.triggerFocus.currentOption],re=_=>{A(_,c[e.triggerFocus.currentOption])},X=_=>{var O;I(_,(O=e==null?void 0:e.visibleOptions)==null?void 0:O[e.layerFocus.current],l)},k=e.triggerFocus.clearAll;return{getTriggerWidth:f,onKeyEvent:(_,O)=>{switch(_){case B.UP:{j(_);break}case B.DOWN:{e.isLayerOpen?j(_):V();break}case B.LEFT:case B.RIGHT:{D(_);break}case B.ENTER:{k?Z(O):te?re(O):X(O);break}case B.ESC:{l();break}}},clearAllIsFocused:k,triggerProps:x,onClickTrigger:R,onChangeSearch:z,onClickDeselectOption:A,onClickClearAll:F,renderLayer:w,layerProps:N,closeLayer:l,onSelectOption:I,getLayerWidth:h,triggerBounds:L}},Pe=e=>{const{multi:n=!1,disabled:r=!1,error:a=null,warning:s=null,tooltip:g=null,options:S,selectedOptions:u,onCreate:c=null,placeholder:d="",small:T=!1,tabIndex:m=0,onFocus:b=()=>{},onBlur:E=()=>{},searchable:v=!0,clearable:t=!1,maxTooltipWidth:i,closeOnOptionActionClick:l,isInTable:p=!1,groupOrder:y,firstSelectedOptionIndex:I=0,right:f=!1,testId:h=void 0}=e,w=q.useContext(me),N=c!==null,x=q.useRef(null),[L,R]=Oe(),C=Le(),[A,F]=q.useReducer(bt,{options:S,firstSelectedOptionIndex:I},({options:Y})=>({searchValue:"",visibleOptions:Y,layerFocus:ke(Y,I??0),triggerFocus:De,isLayerOpen:!1})),{getTriggerWidth:z,onKeyEvent:V,clearAllIsFocused:$,triggerProps:j,onClickTrigger:D,onChangeSearch:Z,onClickDeselectOption:te,onClickClearAll:re,renderLayer:X,layerProps:k,closeLayer:J,onSelectOption:_,getLayerWidth:O,triggerBounds:Q}=It({...e,state:A,dispatch:F,setTriggerFocus:R,disabledContext:w,isFontLoaded:C,createAble:N,listRef:x});return o.jsx("div",{style:{width:z()},children:o.jsxs(Ge,{handleKeys:Object.values(B),onKeyEvent:V,children:[o.jsx(je,{selectedOptions:u,searchValue:A.searchValue,isOpen:A.isLayerOpen,focusedSelectedOptionIndex:A.triggerFocus.currentOption,clearAllIsFocused:$,searchable:v,triggerRef:ze(L,j.ref),error:a,warning:s,tooltip:g,small:T,isInTable:p,disabled:r||w,clearable:t,tabIndex:m,onClickTrigger:D,onChangeSearch:Z,onClickDeselect:te,onClickClear:re,onFocus:b,onBlur:E,groupOrder:y,maxTooltipWidth:i,placeholder:d,right:f,testId:h}),A.isLayerOpen&&X(o.jsx("div",{...k,className:H.layerContainer,children:o.jsx(Ae,{listRef:x,isMulti:n,sections:A.visibleOptions,selectedOptions:u,onSelectOption:(Y,K)=>{_(Y,K,n?void 0:J)},closeLayer:()=>{l&&J()},width:O(Q),small:T,focusedOptionIndex:A.layerFocus.current,firstSelectedOptionIndex:I??0,testId:h&&`${h}-layer`})}))]})})};Pe.__docgenInfo={description:"",methods:[],displayName:"CustomSelect",props:{multi:{required:!1,tsType:{name:"boolean"},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},error:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},warning:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},tooltip:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},options:{required:!0,tsType:{name:"Array",elements:[{name:"union",raw:"ISelectSelectedOption | Heading",elements:[{name:"ISelectSelectedOption"},{name:"Heading"}]}],raw:"TCustomSelectSelectOption[]"},description:""},selectedOptions:{required:!0,tsType:{name:"union",raw:"ISelectSelectedOption | ISelectSelectedOption[]",elements:[{name:"ISelectSelectedOption"},{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"}]},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
38
- event: TChangeEvent<T>,
39
- ...additionalProps: { [key: string]: any }[]
40
- ) => void`,signature:{arguments:[{type:{name:"intersection",raw:`ChangeEvent<T> & {
41
- target:
42
- | T
43
- | { name: string; value: any; label?: string; files?: FileList | null };
44
- }`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
45
- target:
46
- | T
47
- | { name: string; value: any; label?: string; files?: FileList | null };
48
- }`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
49
- | { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},name:"event"},{type:{name:"Array",elements:[{name:"signature",type:"object",raw:"{ [key: string]: any }",signature:{properties:[{key:{name:"string"},value:{name:"any",required:!0}}]}}],raw:"{ [key: string]: any }[]"},name:"additionalProps",rest:!0}],return:{name:"void"}}},description:""},onCreate:{required:!1,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},tabIndex:{required:!1,tsType:{name:"number"},description:""},width:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"null"}]},description:""},autoLayerWidth:{required:!1,tsType:{name:"boolean"},description:""},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"() => void",signature:{arguments:[],return:{name:"void"}}},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:""},clearable:{required:!1,tsType:{name:"boolean"},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:""},groupOrder:{required:!1,tsType:{name:"union",raw:"TGroupOrder | string",elements:[{name:"union",raw:"'first' | 'middle' | 'last'",elements:[{name:"literal",value:"'first'"},{name:"literal",value:"'middle'"},{name:"literal",value:"'last'"}]},{name:"string"}]},description:""},firstSelectedOptionIndex:{required:!0,tsType:{name:"union",raw:"number | null",elements:[{name:"number"},{name:"null"}]},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},closeOnOptionActionClick:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | undefined",elements:[{name:"string"},{name:"undefined"}]},description:""}}};const Et=e=>{const{name:n="",options:r=[],value:a,native:s=!1,onChange:g=ae.noop,deprecatedEventHandler:S=!1,autoScroll:u=!0,warning:c,error:d,checkNonExistentValues:T=!0,closeOnOptionActionClick:m=!0,testId:b,disabled:E}=e,v=!s&&u===!0,{multi:t,simpleInputs:i,options:l,selectedOptions:p,firstSelectedOptionIndex:y,hasNonExistentValue:I}=Ye(r,a,v,T),f=!t,h=s&&f;s&&!f&&console.warn("Native select does not support provided props (see stories)");const w="Value no longer available for re-selection",N=I&&!E?c?o.jsxs("div",{children:[o.jsx("div",{children:w}),o.jsx("div",{children:c})]}):w:c,x=I&&d&&!E?o.jsxs("div",{children:[o.jsx("div",{children:w}),o.jsx("div",{children:d})]}):d,L=(R,C)=>{if(S){const A=t?C.map(F=>i?F.value:F):i?C.value:C;A&&g(A)}else{const A=!(R instanceof Event),F=t?C:C.value;if(A)R.target.name=n,R.target.value=F,t||(R.target.label=C.label),g(R);else{const z={...R,target:{...R.target,name:n,value:F,label:t?void 0:C.label}};g(z)}}};return h?o.jsx(we,{...e,options:l,selectedOption:p,onChange:L,hasNonExistentValue:I,warning:N,error:x,testId:b}):o.jsx(Pe,{...e,options:l,selectedOptions:p,onChange:L,multi:t,firstSelectedOptionIndex:y,warning:N,error:x,testId:b,closeOnOptionActionClick:m})};Et.__docgenInfo={description:"",methods:[],displayName:"Select",props:{name:{required:!1,tsType:{name:"string"},description:""},multi:{required:!1,tsType:{name:"boolean"},description:""},options:{required:!1,tsType:{name:"Array",elements:[{name:"ISelectSelectedOption"}],raw:"ISelectSelectedOption[]"},description:""},value:{required:!1,tsType:{name:"any"},description:""},native:{required:!1,tsType:{name:"boolean"},description:""},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
50
- event: TChangeEvent<T>,
51
- ...additionalProps: { [key: string]: any }[]
52
- ) => void`,signature:{arguments:[{type:{name:"intersection",raw:`ChangeEvent<T> & {
53
- target:
54
- | T
55
- | { name: string; value: any; label?: string; files?: FileList | null };
56
- }`,elements:[{name:"ChangeEvent",elements:[{name:"T"}],raw:"ChangeEvent<T>"},{name:"signature",type:"object",raw:`{
57
- target:
58
- | T
59
- | { name: string; value: any; label?: string; files?: FileList | null };
60
- }`,signature:{properties:[{key:"target",value:{name:"union",raw:`| T
61
- | { name: string; value: any; label?: string; files?: FileList | null }`,elements:[{name:"T"},{name:"signature",type:"object",raw:"{ name: string; value: any; label?: string; files?: FileList | null }",signature:{properties:[{key:"name",value:{name:"string",required:!0}},{key:"value",value:{name:"any",required:!0}},{key:"label",value:{name:"string",required:!1}},{key:"files",value:{name:"union",raw:"FileList | null",elements:[{name:"FileList"},{name:"null"}],required:!1}}]}}],required:!0}}]}}]},name:"event"},{type:{name:"Array",elements:[{name:"signature",type:"object",raw:"{ [key: string]: any }",signature:{properties:[{key:{name:"string"},value:{name:"any",required:!0}}]}}],raw:"{ [key: string]: any }[]"},name:"additionalProps",rest:!0}],return:{name:"void"}}},description:""},deprecatedEventHandler:{required:!1,tsType:{name:"boolean"},description:""},autoScroll:{required:!1,tsType:{name:"boolean"},description:""},warning:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},error:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:""},checkNonExistentValues:{required:!1,tsType:{name:"boolean"},description:""},closeOnOptionActionClick:{required:!1,tsType:{name:"boolean"},description:""},small:{required:!1,tsType:{name:"boolean"},description:""},width:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | null",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"null"}]},description:""},borderRadius:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},onCreate:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: any) => any",signature:{arguments:[{type:{name:"any"},name:"evt"}],return:{name:"any"}}},description:""},disabled:{required:!1,tsType:{name:"boolean"},description:""},placeholder:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""},isInTable:{required:!1,tsType:{name:"boolean"},description:""},clearable:{required:!1,tsType:{name:"boolean"},description:""},searchable:{required:!1,tsType:{name:"boolean"},description:""},maxTooltipWidth:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""},autoLayerWidth:{required:!1,tsType:{name:"boolean"},description:""},right:{required:!1,tsType:{name:"boolean"},description:""},tabIndex:{required:!1,tsType:{name:"number"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};export{Et as S};
@@ -1,82 +0,0 @@
1
- import{j as _}from"./jsx-runtime-eps93zm2.js";import{r as I}from"./index-DhsZuJvc.js";import{w as r,e as s,u as l}from"./index-DMAnyMX5.js";import{S as T}from"./select-Cwks-WA0.js";import{o as O}from"./select.stories-data-DxgWKlU6.js";import"./index-CF7H4eMJ.js";import"./lodash-c4VUpsOs.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./inheritsLoose-DP0QEDDI.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Bax0KeqM.js";import"./button-Cbv7WK6k.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";const ue={title:"Forms/Select/Test Cases",component:T,args:{options:O},tags:["!autodocs"]},v=n=>{const{multi:o,value:e}=n,[a,t]=I.useState(e||(o?[]:void 0)),i=c=>{const{value:g}=c.target;t(o?g:{value:g})};return _.jsx(T,{value:a,onChange:i,...n})},y=v.bind({});y.args={value:{label:"Vampires",value:"blood"},disabled:!0};const d=v.bind({});d.args={testId:"testId",clearable:!0};d.play=async({canvasElement:n,step:o})=>{const e=n.parentElement?r(n.parentElement):null;await s(e).toBeTruthy(),e&&(await o("Select item with click",async()=>{const a=e.getByTestId("testId");await l.click(a);const t=e.getByTestId("testId-layer");await s(t).toBeInTheDocument();const i=r(t).getByText("Wombats");await l.click(i);const c=e.getByTestId("testId-value");await s(r(c).getByText("Wombats")).toBeInTheDocument()}),await o("Clear selected value",async()=>{const a=e.getByTestId("testId-clear");await l.click(a);const t=e.queryByTestId("testId-value");await s(t).not.toBeInTheDocument()}))};const m=v.bind({});m.args={testId:"testId",clearable:!0,multi:!0};m.play=async({canvasElement:n,step:o})=>{const e=n.parentElement?r(n.parentElement):null;await s(e).toBeTruthy(),e&&(await o("Select items with click",async()=>{const a=e.getByTestId("testId");await l.click(a);const t=e.getByTestId("testId-layer");await s(t).toBeInTheDocument();const i=r(t).getByText("Wombats");await l.click(i);const c=r(t).getByText("Kangaroos");await l.click(c),await l.click(n),await s(t).not.toBeInTheDocument();const g=e.getByTestId("testId-value");await s(r(g).getByText("Wombats")).toBeInTheDocument(),await s(r(g).getByText("Kangaroos")).toBeInTheDocument()}),await o("Deselect item with click",async()=>{const a=e.getByTestId("testId");await l.click(a);const t=e.getByTestId("testId-layer");await s(t).toBeInTheDocument();const i=r(t).getByText("Wombats");await l.click(i),await l.click(n),await s(t).not.toBeInTheDocument();const c=e.getByTestId("testId-value");await s(r(c).queryByText("Wombats")).not.toBeInTheDocument()}),await o("Clear selected values",async()=>{const a=e.getByTestId("testId-clear");await l.click(a);const t=e.queryByTestId("testId-value");await s(t).not.toBeInTheDocument()}))};const p=v.bind({});p.args={testId:"testId",disabled:!0};p.play=async({canvasElement:n,step:o})=>{const e=r(n);await o("Clicking disabled trigger should not show layer",async()=>{await e.getByTestId("testId").click();const t=e.queryByTestId("testId-layer");await s(t).toBeNull()})};const u=()=>{const[n,o]=I.useState(O),[e,a]=I.useState(void 0);return _.jsx(T,{testId:"testId",name:"example",options:n,onChange:t=>a({value:t.target.value}),onCreate:t=>{const i={label:t,value:t};o([...n,i]),a(i)},value:e})};u.args={testId:"testId"};u.play=async({canvasElement:n,step:o})=>{const e=n.parentElement?r(n.parentElement):null;await s(e).toBeTruthy(),e&&await o("Create new item",async()=>{const a=e.getByTestId("testId-input");if(s(a).toBeInTheDocument(),!a)return;await l.type(a,"New value");const t=e.getByText('Create "New value"');await l.click(t);const i=e.getByTestId("testId-value");await s(r(i).getByText("New value")).toBeInTheDocument()})};u.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestCreate"};var w,h,B;y.parameters={...y.parameters,docs:{...(w=y.parameters)==null?void 0:w.docs,source:{originalSource:`(args: any) => {
2
- const {
3
- multi,
4
- value
5
- } = args;
6
- const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
7
- const handleChange = (evt: any) => {
8
- const {
9
- value
10
- } = evt.target;
11
- setSelectedValue(multi ? value : {
12
- value
13
- });
14
- };
15
- return <Select value={selectedValue} onChange={handleChange}
16
- // eslint-disable-next-line react/jsx-props-no-spreading
17
- {...args} />;
18
- }`,...(B=(h=y.parameters)==null?void 0:h.docs)==null?void 0:B.source}}};var S,V,x;d.parameters={...d.parameters,docs:{...(S=d.parameters)==null?void 0:S.docs,source:{originalSource:`(args: any) => {
19
- const {
20
- multi,
21
- value
22
- } = args;
23
- const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
24
- const handleChange = (evt: any) => {
25
- const {
26
- value
27
- } = evt.target;
28
- setSelectedValue(multi ? value : {
29
- value
30
- });
31
- };
32
- return <Select value={selectedValue} onChange={handleChange}
33
- // eslint-disable-next-line react/jsx-props-no-spreading
34
- {...args} />;
35
- }`,...(x=(V=d.parameters)==null?void 0:V.docs)==null?void 0:x.source}}};var b,C,f;m.parameters={...m.parameters,docs:{...(b=m.parameters)==null?void 0:b.docs,source:{originalSource:`(args: any) => {
36
- const {
37
- multi,
38
- value
39
- } = args;
40
- const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
41
- const handleChange = (evt: any) => {
42
- const {
43
- value
44
- } = evt.target;
45
- setSelectedValue(multi ? value : {
46
- value
47
- });
48
- };
49
- return <Select value={selectedValue} onChange={handleChange}
50
- // eslint-disable-next-line react/jsx-props-no-spreading
51
- {...args} />;
52
- }`,...(f=(C=m.parameters)==null?void 0:C.docs)==null?void 0:f.source}}};var D,k,j;p.parameters={...p.parameters,docs:{...(D=p.parameters)==null?void 0:D.docs,source:{originalSource:`(args: any) => {
53
- const {
54
- multi,
55
- value
56
- } = args;
57
- const [selectedValue, setSelectedValue] = useState(value || (multi ? [] : undefined));
58
- const handleChange = (evt: any) => {
59
- const {
60
- value
61
- } = evt.target;
62
- setSelectedValue(multi ? value : {
63
- value
64
- });
65
- };
66
- return <Select value={selectedValue} onChange={handleChange}
67
- // eslint-disable-next-line react/jsx-props-no-spreading
68
- {...args} />;
69
- }`,...(j=(k=p.parameters)==null?void 0:k.docs)==null?void 0:j.source}}};var E,N,W;u.parameters={...u.parameters,docs:{...(E=u.parameters)==null?void 0:E.docs,source:{originalSource:`() => {
70
- const [options, setOptions] = useState(storyData.options);
71
- const [singleValue, setSingleValue] = useState<ISelectSelectedOption | undefined>(undefined);
72
- return <Select testId="testId" name="example" options={options} onChange={evt => setSingleValue({
73
- value: evt.target.value
74
- })} onCreate={value => {
75
- const newValue = {
76
- label: value,
77
- value
78
- };
79
- setOptions([...options, newValue]);
80
- setSingleValue(newValue);
81
- }} value={singleValue} />;
82
- }`,...(W=(N=u.parameters)==null?void 0:N.docs)==null?void 0:W.source}}};const de=["TestDisabledNonExistentValue","Test","TestMulti","TestDisabled","TestCreate"];export{d as Test,u as TestCreate,p as TestDisabled,y as TestDisabledNonExistentValue,m as TestMulti,de as __namedExportsOrder,ue as default};
@@ -1,6 +0,0 @@
1
- import{j as u}from"./jsx-runtime-eps93zm2.js";import{w as d,e as a,u as n,a as c}from"./index-DMAnyMX5.js";import{t as g}from"./toaster-O8ftrUAJ.js";import{B as w}from"./button-Cbv7WK6k.js";import{a as y}from"./message-BRyKdRaX.js";import"./index-DhsZuJvc.js";import"./index-CF7H4eMJ.js";import"./toaster-7wnI6hqB.js";import"./index-CUZDtIZe.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BSFY3vDO.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DP0QEDDI.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";const h={type:y.INFO,icon:!0,heading:"Heading",content:"Long content lorem ipsum dolor est compendum lorem ipsum."},O={title:"Modals/Toaster/Test Cases",parameters:{docs:{story:{inline:!1,iframeHeight:400}}},source:{type:"code"},args:{id:void 0,message:h,autoClose:6e3,onClose:()=>{}},tags:["!autodocs"]},T=r=>u.jsx(w,{onClick:()=>g({...r,onClose:()=>console.log("toast closed")}),label:"Show toast"}),s=T.bind({});s.args={id:"testId",autoClose:50};s.play=async({canvasElement:r,step:i})=>{const t=r.parentElement?d(r.parentElement):null;await a(t).toBeTruthy(),t&&(await i("Toast should appear when triggered",async()=>{const o=t.getByText("Show toast");await n.click(o);const e=t.getByRole("alert");await a(e).toBeInTheDocument()}),await i("Duplicate toasts shouldn't be created",async()=>{const o=t.getByText("Show toast");await n.click(o);const e=t.queryAllByRole("alert");await a(e).toHaveLength(1)}),await i("Toast should disappear when close button pressed",async()=>{const o=t.getByRole("alert"),e=t.getByTestId("testId-dismiss");await n.click(e),await c(()=>a(o).not.toBeInTheDocument(),{timeout:2e3})}),await i("Toast should automatically close",async()=>{const o=t.getByText("Show toast");await n.click(o);const e=t.getByRole("alert");await c(()=>a(e).not.toBeInTheDocument(),{timeout:2e3})}))};var l,m,p;s.parameters={...s.parameters,docs:{...(l=s.parameters)==null?void 0:l.docs,source:{originalSource:`args => {
2
- return <Button onClick={() => toast({
3
- ...args,
4
- onClose: () => console.log('toast closed')
5
- })} label="Show toast" />;
6
- }`,...(p=(m=s.parameters)==null?void 0:m.docs)==null?void 0:p.source}}};const q=["Test"];export{s as Test,q as __namedExportsOrder,O as default};