@oliasoft-open-source/react-ui-library 4.12.0-beta-2 → 4.12.0-beta-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-BVCFmQTa.js → index-BMWyiwz3.js} +169 -145
- package/dist/assets/{index-BU9wzZv9.css → index-BaYhOc6M.css} +37 -5
- package/dist/index.html +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/storybook/assets/{Color-KGDBMAHA-BODMLRvZ.js → Color-KGDBMAHA-BU5Cvr93.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-PKQXORMH-DEi7ICVq.js → DocsRenderer-PKQXORMH-giM41WN8.js} +1 -1
- package/dist/storybook/assets/{accordion.stories-C_Vx7GEC.js → accordion.stories-BlHfHegj.js} +1 -1
- package/dist/storybook/assets/{afe.stories-OEYJqexC.js → afe.stories-C9XjJj62.js} +1 -1
- package/dist/storybook/assets/{buttons-and-links-BHNS6Ebw.js → buttons-and-links-BA3MNFjq.js} +1 -1
- package/dist/storybook/assets/{casing-loads.stories-BAdZ87Oc.js → casing-loads.stories-Cl2tJipP.js} +1 -1
- package/dist/storybook/assets/{cell.stories-Bu5u9qEl.js → cell.stories-rzJE_qJC.js} +1 -1
- package/dist/storybook/assets/{chunk-HLWAVYOI-BbzmrmoZ.js → chunk-HLWAVYOI-Dvbg03uT.js} +1 -1
- package/dist/storybook/assets/{color-oeF0-Pph.js → color-DIyQ13kP.js} +1 -1
- package/dist/storybook/assets/{footer.stories-LUxEpSgD.js → footer.stories-C6M5S0UZ.js} +1 -1
- package/dist/storybook/assets/{form.stories-B7V77yuI.js → form.stories-BNORsn6Z.js} +1 -1
- package/dist/storybook/assets/{formation.stories-D7MX0dSY.js → formation.stories-1WX1Nu1P.js} +1 -1
- package/dist/storybook/assets/{iframe-nuCPRPrd.js → iframe-B0e2q2Zd.js} +2 -2
- package/dist/storybook/assets/{index-CN6H1a0D.js → index-BXJ79Lvz.js} +1 -1
- package/dist/storybook/assets/{index-BFtO1KgR.js → index-BlyDuQBv.js} +4 -4
- package/dist/storybook/assets/{initialize-context-rEvM6bdZ.js → initialize-context-Y03pJPr5.js} +1 -1
- package/dist/storybook/assets/{input-group.stories-BdQ1prY4.js → input-group.stories-BCajsqAk.js} +1 -1
- package/dist/storybook/assets/{input-validation-Ccu8WMpy.js → input-validation-CLZKtfoW.js} +1 -1
- package/dist/storybook/assets/{inputs-C4fsY4Ua.js → inputs-DlW6Jeem.js} +1 -1
- package/dist/storybook/assets/{layout-forms-DOgsanng.js → layout-forms-C6ZH-nYk.js} +1 -1
- package/dist/storybook/assets/{layout-general-DtDx77FI.js → layout-general-CWqOMwXA.js} +1 -1
- package/dist/storybook/assets/menu.test-case.stories-XN9XFV-D.js +3 -0
- package/dist/storybook/assets/{modal.stories-DUXRRhK-.js → modal.stories-C2d-Em5V.js} +1 -1
- package/dist/storybook/assets/{number-input-CNnU6gOF.js → number-input-B3_gmeWr.js} +1 -1
- package/dist/storybook/assets/{number-input.stories-Bo26PJmJ.js → number-input.stories-epjUq9ve.js} +1 -1
- package/dist/storybook/assets/number-input.test-case.stories-DeEtalIU.js +95 -0
- package/dist/storybook/assets/{padding-and-spacing-Mfm_1hn5.js → padding-and-spacing-CfnXk0Zn.js} +1 -1
- package/dist/storybook/assets/{pagination-CoyQUC4R.js → pagination-CR1nxnnq.js} +1 -1
- package/dist/storybook/assets/{pagination.stories-qfpnU8DC.js → pagination.stories-qXmBYwYc.js} +1 -1
- package/dist/storybook/assets/{popover.stories-TwNkFkWa.js → popover.stories-DZTfimDf.js} +1 -1
- package/dist/storybook/assets/{preview-BIv_KaBF.js → preview-b9pkIJl_.js} +2 -2
- package/dist/storybook/assets/{preview-DVjsIOwK.js → preview-jWpKVqju.js} +1 -1
- package/dist/storybook/assets/{reservoirs.stories-DE9FrS0f.js → reservoirs.stories-r1Ip90kJ.js} +1 -1
- package/dist/storybook/assets/{rich-text-input.stories-BNwcnp92.js → rich-text-input.stories-DwaseXZv.js} +1 -1
- package/dist/storybook/assets/{row.stories-D3Bnp8i4.js → row.stories-DRvH8Grn.js} +1 -1
- package/dist/storybook/assets/select-Cwks-WA0.js +61 -0
- package/dist/storybook/assets/{select.stories-BRGk9iYK.js → select.stories-DjGSNDXK.js} +1 -1
- package/dist/storybook/assets/select.test-case.stories-CrXzt4qn.js +82 -0
- package/dist/storybook/assets/{table-DPbEkZqw.js → table-DoyDBG6l.js} +1 -1
- package/dist/storybook/assets/{table.stories-BBzqpsyH.js → table.stories-BgWKzIob.js} +1 -1
- package/dist/storybook/assets/{title.stories-B4PYbA22.js → title.stories-Rv6ZO_Wl.js} +1 -1
- package/dist/storybook/assets/{unit-input-Byipu-z0.js → unit-input-BXg4VphV.js} +1 -1
- package/dist/storybook/assets/{unit-input.stories-CChVbxmI.js → unit-input.stories-Btz2M_TP.js} +1 -1
- package/dist/storybook/assets/{unit-input.test-case.stories-BeFM9DuK.js → unit-input.test-case.stories-CZD1jf36.js} +1 -1
- package/dist/storybook/assets/{unit-table.stories-9x5S71wv.js → unit-table.stories-CISvZMxX.js} +1 -1
- package/dist/storybook/assets/{unit-table.test-case.stories-DZJ-hZ72.js → unit-table.test-case.stories-tEype9om.js} +1 -1
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/package.json +1 -1
- package/dist/storybook/assets/menu.test-case.stories-W-jG-Jk8.js +0 -3
- package/dist/storybook/assets/number-input.test-case.stories-CHGSaGbj.js +0 -92
- package/dist/storybook/assets/select-BQzJMnK1.js +0 -61
- package/dist/storybook/assets/select.test-case.stories-BYMK9M8u.js +0 -82
|
@@ -1 +1 @@
|
|
|
1
|
-
{"generatedAt":
|
|
1
|
+
{"generatedAt":1725450186420,"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,3 +0,0 @@
|
|
|
1
|
-
import{j as y}from"./jsx-runtime-eps93zm2.js";import{w as n,u as m,e as r,a as g}from"./index-DMAnyMX5.js";import{M as l}from"./actions-Bax0KeqM.js";import{m as w}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 G={title:"Basic/Menu/Test Cases",component:l,args:{menu:w},tags:["!autodocs"]},I=s=>y.jsx(l,{...s}),t=I.bind({});t.args={testId:"testId"};t.play=async({canvasElement:s,step:a})=>{const u=n(s),e=n(s.ownerDocument.body);await a("Clicking trigger should open menu",async()=>{const i=u.getByTestId("testId");await m.click(i);const o=await e.findByTestId("testId-layer");r(o).toBeInTheDocument()}),await a("Clicking disabled item should do nothing",async()=>{await e.getByText("Knight").click();const o=await e.findByTestId("testId-layer");r(o).toBeInTheDocument()}),await a("Clicking item should close menu",async()=>{const i=e.getByText("King");await m.click(i),await g(()=>{const o=e.queryByTestId("testId-layer");r(o).not.toBeInTheDocument()})})};var c,p,d;t.parameters={...t.parameters,docs:{...(c=t.parameters)==null?void 0:c.docs,source:{originalSource:`args => <Menu
|
|
2
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
3
|
-
{...args} />`,...(d=(p=t.parameters)==null?void 0:p.docs)==null?void 0:d.source}}};const H=["Test"];export{t as Test,H as __namedExportsOrder,G as default};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import{j as a}from"./jsx-runtime-eps93zm2.js";import{r as l}from"./index-DhsZuJvc.js";import{w as c,u as n,e as o,f as B,a as C}from"./index-DMAnyMX5.js";import{S as x}from"./spacer-BWoNR27H.js";import{G as K}from"./grid-DRkC-bt8.js";import{C as m}from"./card-EcjmryU9.js";import{B as Q}from"./button-Cbv7WK6k.js";import{H as p}from"./heading-CRNoBc7q.js";import{I as ee}from"./input-group-addon-D68iUKV2.js";import{S as te}from"./select-BQzJMnK1.js";import{I as ae}from"./input-group-BaRSJAEN.js";import{F as V}from"./field-HrLaMLbx.js";import{T as R}from"./toggle-BbFVf61v.js";import{T as ne}from"./text-B3-TSWok.js";import{M as se}from"./message-BRyKdRaX.js";import{I as X}from"./icon-BSFY3vDO.js";import{N as u}from"./number-input-CNnU6gOF.js";import"./index-CF7H4eMJ.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./help-icon-Buhx5nl6.js";import"./lodash-c4VUpsOs.js";import"./types-Dx2TtIG9.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"./actions-Bax0KeqM.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./label-CqmyC9he.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./input-Db9WkmPP.js";const Ke={title:"Forms/NumberInput/Test Cases",component:u,parameters:{canvas:{page:null}},args:{label:"Label"},tags:["!autodocs"]},v=()=>a.jsxs(ae,{small:!0,children:[a.jsx(u,{value:123}),a.jsx(ee,{children:"to"}),a.jsx(u,{value:123}),a.jsx(te,{options:[{value:"units",label:"units"}],width:"auto",value:"units"})]}),g=()=>{const[r,s]=l.useState("123|m");return a.jsx(u,{name:"example",onChange:t=>s(t.target.value),placeholder:"Type a value...",value:r,testId:"testId"})};g.play=async({canvasElement:r,step:s})=>{const t=c(r),i=c(r.ownerDocument.body);await s("Shows validation error for non-numeric input",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"123x45s6"),await o(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await B.mouseOver(e),await o(e.getAttribute("data-error")).toEqual("Must be a numerical value"),await C(()=>{o(i.getByText("Must be a numerical value")).toBeInTheDocument()})})};const y=()=>{const[r,s]=l.useState("123");return a.jsx(u,{value:r,onChange:t=>{s(t.target.value)},testId:"testId",enableDisplayRounding:!0})};y.play=async({canvasElement:r,step:s})=>{const t=c(r);await s("Value should be rounded on blur",async()=>{const i=t.getByTestId("testId");await n.clear(i),await n.type(i,"123.123456789"),await n.click(r),await o(t.getByDisplayValue("123.12")).toBeInTheDocument()}),await s("Full value shown on focus",async()=>{const i=t.getByTestId("testId");await n.click(i),await o(t.getByDisplayValue("123.123456789")).toBeInTheDocument()})};const w=()=>{const[r,s]=l.useState(!0),t=()=>{s(!1),setTimeout(()=>s(!0),0)},[i,e]=l.useState("123");return a.jsxs(K,{columns:"1fr 1fr",gap:!0,children:[a.jsxs(m,{heading:a.jsx(p,{children:"Storage State (Redux)"}),children:[i,a.jsx(x,{}),a.jsx(Q,{label:"Change value",onClick:()=>e(String(Math.floor(Math.random()*100)))})]}),a.jsx(m,{heading:a.jsx(p,{icon:a.jsx(X,{icon:"refresh"}),onIconClick:t,children:"NumberInput"}),children:r&&a.jsx(u,{value:i,onChange:h=>{e(h.target.value)},error:Number(i)>=0?"":"Value must be positive"})})]})},I=()=>{const[r,s]=l.useState(!0),t=()=>{s(!1),setTimeout(()=>s(!0),0)},[i,e]=l.useState(!1),[h,Y]=l.useState(!0),[f,D]=l.useState("0.6889763779527558"),[S,Z]=l.useState(""),$=Number(f)*.3048;return a.jsxs(K,{columns:"1fr 1fr",gap:!0,children:[a.jsxs(m,{heading:a.jsx(p,{children:"Settings"}),children:[a.jsx(V,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:a.jsx(R,{checked:i,onChange:d=>e(d.target.checked)})}),a.jsx(V,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:a.jsx(R,{checked:h,onChange:d=>Y(d.target.checked)})})]}),a.jsxs(m,{heading:a.jsx(p,{icon:a.jsx(X,{icon:"refresh",testId:"triggerRerenderTestId"}),onIconClick:t,children:"NumberInput (displayed in Meters)"}),children:[a.jsx(ne,{faint:!0,children:"Cosmetic Rounding Test Cases: type 0.21 then return (compare with enableCosmeticRounding on and off)"}),a.jsx(x,{}),r&&a.jsx(u,{name:"Example",value:$,onChange:d=>{const T=String(Number(d.target.value)/.3048);D(T)},enableDisplayRounding:i,enableCosmeticRounding:h,error:Number(f)>=0?"":"Value must be positive",validationCallback:(d,T)=>{Z(T??"")},testId:"testId"})]}),a.jsxs(m,{heading:a.jsx(p,{children:"Storage State / Redux (stored in Feet)"}),children:[f,a.jsx(x,{}),a.jsx(Q,{label:"Change value",onClick:()=>D(String(Math.floor(Math.random()*100)))})]}),a.jsx(m,{heading:a.jsx(p,{children:"Test Validation Callback"}),children:S&&a.jsx(se,{message:{content:S,icon:!0,type:"Error",visible:!0}})})]})};I.play=async({canvasElement:r,step:s})=>{const t=c(r),i=c(r.ownerDocument.body);await s("Can enter decimal values",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"123.123456789"),await n.click(r),await o(t.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await s("Can enter scientific notation when storage unit is different",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"-1.12e-3"),await o(t.getByDisplayValue("-1.12e-3")).toBeInTheDocument(),await t.getByTestId("triggerRerenderTestId").click(),await C(()=>{o(t.getByDisplayValue(-.00112)).toBeInTheDocument()})}),await s("Can enter comma decimals (converts to dot)",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"123,456"),await o(t.getByDisplayValue("123.456")).toBeInTheDocument()}),await s("Can enter small numbers",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"0.0000000023"),await o(t.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await s("Can enter large numbers",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"999999999999"),await o(t.getByDisplayValue("999999999999")).toBeInTheDocument()}),await s("Shows validation error for non-numeric input",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"123x45s6"),await n.click(r),await o(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await o(e.getAttribute("data-error")).toEqual("Must be a numerical value"),await B.mouseOver(e),await C(()=>{o(i.getAllByText("Must be a numerical value").length).toEqual(2)})})};const b=()=>{const[r,s]=l.useState("123");return a.jsx(u,{value:r,onChange:t=>{s(t.target.value)},testId:"testId"})};b.play=async({canvasElement:r,step:s})=>{const t=c(r),i=c(r.ownerDocument.body);await s("Can enter decimal values",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"123.123456789"),await o(t.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await s("Can enter scientific notation",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"-1.12e3"),await o(t.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await s("Can enter comma decimals (converts to dot)",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"123,456"),await o(t.getByDisplayValue("123.456")).toBeInTheDocument()}),await s("Can enter small numbers",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"0.0000000023"),await o(t.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await s("Can enter large numbers",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"999999999999"),await o(t.getByDisplayValue("999999999999")).toBeInTheDocument()}),await s("Shows validation error for non-numeric input",async()=>{const e=t.getByTestId("testId");await n.clear(e),await n.type(e,"123x45s6"),await o(t.getByDisplayValue("123x45s6")).toBeInTheDocument(),await o(e.getAttribute("data-error")).toEqual("Must be a numerical value"),await B.mouseOver(e),await C(()=>{o(i.getByText("Must be a numerical value")).toBeInTheDocument()})})};v.__docgenInfo={description:"",methods:[],displayName:"TestInputGroup"};g.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};y.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestDisplayRounding"};w.__docgenInfo={description:"",methods:[],displayName:"ManagedTestCase"};I.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"DemoCosmeticRounding"};b.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestUserInput"};var j,k,E;v.parameters={...v.parameters,docs:{...(j=v.parameters)==null?void 0:j.docs,source:{originalSource:`() => <InputGroup small>
|
|
2
|
-
<NumberInput value={123} />
|
|
3
|
-
<InputGroupAddon>to</InputGroupAddon>
|
|
4
|
-
<NumberInput value={123} />
|
|
5
|
-
<Select options={[{
|
|
6
|
-
value: 'units',
|
|
7
|
-
label: 'units'
|
|
8
|
-
}]} width="auto" value="units" />
|
|
9
|
-
</InputGroup>`,...(E=(k=v.parameters)==null?void 0:k.docs)==null?void 0:E.source}}};var N,M,F;g.parameters={...g.parameters,docs:{...(N=g.parameters)==null?void 0:N.docs,source:{originalSource:`() => {
|
|
10
|
-
const [value, setValue] = useState('123|m');
|
|
11
|
-
return <NumberInput name="example" onChange={evt => setValue(evt.target.value)} placeholder="Type a value..." value={value} testId="testId" />;
|
|
12
|
-
}`,...(F=(M=g.parameters)==null?void 0:M.docs)==null?void 0:F.source}}};var _,G,H;y.parameters={...y.parameters,docs:{...(_=y.parameters)==null?void 0:_.docs,source:{originalSource:`() => {
|
|
13
|
-
const [value, setValue] = useState('123');
|
|
14
|
-
return <NumberInput value={value} onChange={evt => {
|
|
15
|
-
setValue(evt.target.value);
|
|
16
|
-
}} testId="testId" enableDisplayRounding />;
|
|
17
|
-
}`,...(H=(G=y.parameters)==null?void 0:G.docs)==null?void 0:H.source}}};var A,L,q;w.parameters={...w.parameters,docs:{...(A=w.parameters)==null?void 0:A.docs,source:{originalSource:`() => {
|
|
18
|
-
const [visible, setVisible] = useState(true);
|
|
19
|
-
const triggerRerender = () => {
|
|
20
|
-
setVisible(false);
|
|
21
|
-
setTimeout(() => setVisible(true), 0);
|
|
22
|
-
};
|
|
23
|
-
const [value, setValue] = useState('123');
|
|
24
|
-
return <Grid columns="1fr 1fr" gap>
|
|
25
|
-
<Card heading={<Heading>Storage State (Redux)</Heading>}>
|
|
26
|
-
{value}
|
|
27
|
-
<Spacer />
|
|
28
|
-
<Button label="Change value" onClick={() => setValue(String(Math.floor(Math.random() * 100)))} />
|
|
29
|
-
</Card>
|
|
30
|
-
<Card heading={<Heading icon={<Icon icon="refresh" />} onIconClick={triggerRerender}>
|
|
31
|
-
NumberInput
|
|
32
|
-
</Heading>}>
|
|
33
|
-
{visible && <NumberInput value={value} onChange={evt => {
|
|
34
|
-
setValue(evt.target.value);
|
|
35
|
-
}} error={Number(value) >= 0 ? '' : 'Value must be positive'} />}
|
|
36
|
-
</Card>
|
|
37
|
-
</Grid>;
|
|
38
|
-
}`,...(q=(L=w.parameters)==null?void 0:L.docs)==null?void 0:q.source}}};var O,W,P;I.parameters={...I.parameters,docs:{...(O=I.parameters)==null?void 0:O.docs,source:{originalSource:`() => {
|
|
39
|
-
const [visible, setVisible] = useState(true);
|
|
40
|
-
const triggerRerender = () => {
|
|
41
|
-
setVisible(false);
|
|
42
|
-
setTimeout(() => setVisible(true), 0);
|
|
43
|
-
};
|
|
44
|
-
const [enableDisplayRounding, setEnableDisplayRounding] = useState(false);
|
|
45
|
-
const [enableCosmeticRounding, setEnableCosmeticRounding] = useState(true);
|
|
46
|
-
const [valueInFeet, setValueInFeet] = useState('0.6889763779527558');
|
|
47
|
-
const [callBackError, setCallBackError] = useState('');
|
|
48
|
-
const valueInMeters = Number(valueInFeet) * 0.3048;
|
|
49
|
-
return <Grid columns="1fr 1fr" gap>
|
|
50
|
-
<Card heading={<Heading>Settings</Heading>}>
|
|
51
|
-
<Field label="Enable display rounding:" labelLeft labelWidth={200}>
|
|
52
|
-
<Toggle checked={enableDisplayRounding} onChange={evt => setEnableDisplayRounding(evt.target.checked)} />
|
|
53
|
-
</Field>
|
|
54
|
-
<Field label="Enable cosmetic rounding:" labelLeft labelWidth={200}>
|
|
55
|
-
<Toggle checked={enableCosmeticRounding} onChange={evt => setEnableCosmeticRounding(evt.target.checked)} />
|
|
56
|
-
</Field>
|
|
57
|
-
</Card>
|
|
58
|
-
<Card heading={<Heading icon={<Icon icon="refresh" testId="triggerRerenderTestId" />} onIconClick={triggerRerender}>
|
|
59
|
-
NumberInput (displayed in Meters)
|
|
60
|
-
</Heading>}>
|
|
61
|
-
<Text faint>
|
|
62
|
-
Cosmetic Rounding Test Cases: type 0.21 then return (compare with
|
|
63
|
-
enableCosmeticRounding on and off)
|
|
64
|
-
</Text>
|
|
65
|
-
<Spacer />
|
|
66
|
-
{visible && <NumberInput name="Example" value={valueInMeters} onChange={evt => {
|
|
67
|
-
const nextValueInFeet = String(Number(evt.target.value) / 0.3048);
|
|
68
|
-
setValueInFeet(nextValueInFeet); // convert back to ft
|
|
69
|
-
}} enableDisplayRounding={enableDisplayRounding} enableCosmeticRounding={enableCosmeticRounding} error={Number(valueInFeet) >= 0 ? '' : 'Value must be positive'} validationCallback={(name, error) => {
|
|
70
|
-
setCallBackError(error ?? '');
|
|
71
|
-
}} testId="testId" />}
|
|
72
|
-
</Card>
|
|
73
|
-
<Card heading={<Heading>Storage State / Redux (stored in Feet)</Heading>}>
|
|
74
|
-
{valueInFeet}
|
|
75
|
-
<Spacer />
|
|
76
|
-
<Button label="Change value" onClick={() => setValueInFeet(String(Math.floor(Math.random() * 100)))} />
|
|
77
|
-
</Card>
|
|
78
|
-
<Card heading={<Heading>Test Validation Callback</Heading>}>
|
|
79
|
-
{callBackError && <Message message={{
|
|
80
|
-
content: callBackError,
|
|
81
|
-
icon: true,
|
|
82
|
-
type: 'Error',
|
|
83
|
-
visible: true
|
|
84
|
-
}} />}
|
|
85
|
-
</Card>
|
|
86
|
-
</Grid>;
|
|
87
|
-
}`,...(P=(W=I.parameters)==null?void 0:W.docs)==null?void 0:P.source}}};var U,z,J;b.parameters={...b.parameters,docs:{...(U=b.parameters)==null?void 0:U.docs,source:{originalSource:`() => {
|
|
88
|
-
const [value, setValue] = useState('123');
|
|
89
|
-
return <NumberInput value={value} onChange={evt => {
|
|
90
|
-
setValue(evt.target.value);
|
|
91
|
-
}} testId="testId" />;
|
|
92
|
-
}`,...(J=(z=b.parameters)==null?void 0:z.docs)==null?void 0:J.source}}};const Qe=["TestInputGroup","Placeholder","TestDisplayRounding","ManagedTestCase","DemoCosmeticRounding","TestUserInput"];export{I as DemoCosmeticRounding,w as ManagedTestCase,g as Placeholder,y as TestDisplayRounding,v as TestInputGroup,b as TestUserInput,Qe as __namedExportsOrder,Ke 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 M}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 Pe,m as We}from"./tooltip-1V7clEnw.js";import{A as P,E as B,K as ze}from"./enum-Bnn40S8Q.js";import{a as Ge,_ as $e}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 Ue}from"./actions-Bax0KeqM.js";import{I as ce}from"./icon-BSFY3vDO.js";import{s as Ve}from"./select.input-CJed_LLR.js";const Ye="_inputInTable_sl2b5_1",Ke="_inputHover_sl2b5_13",Be="_inputFocus_sl2b5_18",Ze="_inputError_sl2b5_25",Xe="_inputWarning_sl2b5_26",Je="_inputDisabled_sl2b5_61",Qe="_hideScrollbars_sl2b5_67",en="_select_sl2b5_77",nn="_isInTable_sl2b5_121",tn="_unSelected_sl2b5_133",rn="_small_sl2b5_174",an="_right_sl2b5_182",sn="_groupOrderFirst_sl2b5_193",ln="_groupOrderMiddle_sl2b5_194",on="_groupOrderLast_sl2b5_198",U={inputInTable:Ye,inputHover:Ke,inputFocus:Be,inputError:Ze,inputWarning:Xe,inputDisabled:Je,hideScrollbars:Qe,select:en,isInTable:nn,unSelected:tn,small:rn,right:an,groupOrderFirst:sn,groupOrderMiddle:ln,groupOrderLast:on},we=({disabled:e=!1,error:n=null,warning:r=null,tooltip:a=null,options:l,onChange:g=ae.noop,onFocus:T=ae.noop,onBlur:u=ae.noop,right:c=!1,small:d=!1,tabIndex:S=0,selectedOption:m,width:b=null,groupOrder:E=null,testId:v,isInTable:t=!1,clearable:i,placeholder:s,hasNonExistentValue:p,maxTooltipWidth:y,borderRadius:I})=>{const f=M.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:s||"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(l.map((L,R)=>o.jsx("option",{value:L.value,"data-testid":L.testId,children:L.label},R))),q=(()=>{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:"",q),style:{width:b||"",borderRadius:I||""},onChange:L=>{const{value:R}=L.target;let x;R==="unselected"?x={value:null}:x=l.find(F=>String(F.value)===String(R))||{value:null},g(L,x)},onFocus:T,onBlur:u,tabIndex:S,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=M.useRef(null);return[e,()=>{e.current&&e.current.focus()}]};var un=typeof performance=="object"&&typeof performance.now=="function",ve=un?function(){return performance.now()}:function(){return Date.now()};function ye(e){cancelAnimationFrame(e.id)}function cn(e,n){var r=ve();function a(){ve()-r>=n?e.call(null):l.id=requestAnimationFrame(a)}var l={id:requestAnimationFrame(a)};return l}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 Te(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"),l=a.style;return l.width="100px",l.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 dn=150,mn=function(n,r){return n};function pn(e){var n,r=e.getItemOffset,a=e.getEstimatedTotalSize,l=e.getItemSize,g=e.getOffsetForIndexAndAlignment,T=e.getStartIndexForOffset,u=e.getStopIndexForStartIndex,c=e.initInstanceProps,d=e.shouldResetStyleCacheOnItemSizeChange,S=e.validateProps;return n=function(m){Ge(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,s,p,y){return t.props.onItemsRendered({overscanStartIndex:i,overscanStopIndex:s,visibleStartIndex:p,visibleStopIndex:y})}),t._callOnScroll=void 0,t._callOnScroll=le(function(i,s,p){return t.props.onScroll({scrollDirection:i,scrollOffset:s,scrollUpdateWasRequested:p})}),t._getItemStyle=void 0,t._getItemStyle=function(i){var s=t.props,p=s.direction,y=s.itemSize,I=s.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=l(t.props,i,t._instanceProps),q=p==="horizontal"||I==="horizontal",L=p==="rtl",R=q?w:0;f[i]=h={position:"absolute",left:L?void 0:R,right:L?R:void 0,top:q?0:w,height:q?"100%":N,width:q?N:"100%"}}return h},t._getItemStyleCache=void 0,t._getItemStyleCache=le(function(i,s,p){return{}}),t._onScrollHorizontal=function(i){var s=i.currentTarget,p=s.clientWidth,y=s.scrollLeft,I=s.scrollWidth;t.setState(function(f){if(f.scrollOffset===y)return null;var h=t.props.direction,w=y;if(h==="rtl")switch(Te()){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 s=i.currentTarget,p=s.clientHeight,y=s.scrollHeight,I=s.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 s=t.props.outerRef;t._outerRef=i,typeof s=="function"?s(i):s!=null&&typeof s=="object"&&s.hasOwnProperty("current")&&(s.current=i)},t._resetIsScrollingDebounced=function(){t._resetIsScrollingTimeoutId!==null&&ye(t._resetIsScrollingTimeoutId),t._resetIsScrollingTimeoutId=cn(t._resetIsScrolling,dn)},t._resetIsScrolling=function(){t._resetIsScrollingTimeoutId=null,t.setState({isScrolling:!1},function(){t._getItemStyleCache(-1,null)})},t}b.getDerivedStateFromProps=function(t,i){return fn(t,i),S(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 s=this.props,p=s.itemCount,y=s.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,s=t.initialScrollOffset,p=t.layout;if(typeof s=="number"&&this._outerRef!=null){var y=this._outerRef;i==="horizontal"||p==="horizontal"?y.scrollLeft=s:y.scrollTop=s}this._callPropsCallbacks()},E.componentDidUpdate=function(){var t=this.props,i=t.direction,s=t.layout,p=this.state,y=p.scrollOffset,I=p.scrollUpdateWasRequested;if(I&&this._outerRef!=null){var f=this._outerRef;if(i==="horizontal"||s==="horizontal")if(i==="rtl")switch(Te()){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,s=t.className,p=t.direction,y=t.height,I=t.innerRef,f=t.innerElementType,h=t.innerTagName,w=t.itemCount,N=t.itemData,q=t.itemKey,L=q===void 0?mn:q,R=t.layout,x=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(M.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 M.createElement(x||A||"div",{className:s,onScroll:D,ref:this._outerRefSetter,style:$e({position:"relative",height:y,width:V,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:p},F)},M.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(),s=i[0],p=i[1],y=i[2],I=i[3];this._callOnItemsRendered(s,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,s=t.overscanCount,p=this.state,y=p.isScrolling,I=p.scrollDirection,f=p.scrollOffset;if(i===0)return[0,0,0,0];var h=T(this.props,f,this._instanceProps),w=u(this.props,h,f,this._instanceProps),N=!y||I==="backward"?Math.max(1,s):1,q=!y||I==="forward"?Math.max(1,s):1;return[Math.max(0,h-N),Math.max(0,Math.min(i-1,w+q)),h,w]},b}(M.PureComponent),n.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},n}var fn=function(n,r){n.children,n.direction,n.height,n.layout,n.innerTagName,n.outerTagName,n.width,r.instance},gn=pn({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,l,g,T){var u=n.direction,c=n.height,d=n.itemCount,S=n.itemSize,m=n.layout,b=n.width,E=u==="horizontal"||m==="horizontal",v=E?b:c,t=Math.max(0,d*S-v),i=Math.min(t,r*S),s=Math.max(0,r*S-v+S+T);switch(a==="smart"&&(l>=s-v&&l<=i+v?a="auto":a="center"),a){case"start":return i;case"end":return s;case"center":{var p=Math.round(s+(i-s)/2);return p<Math.ceil(v/2)?0:p>t+Math.floor(v/2)?t:p}case"auto":default:return l>=s&&l<=i?l:l<s?s:i}},getStartIndexForOffset:function(n,r){var a=n.itemCount,l=n.itemSize;return Math.max(0,Math.min(a-1,Math.floor(r/l)))},getStopIndexForStartIndex:function(n,r,a){var l=n.direction,g=n.height,T=n.itemCount,u=n.itemSize,c=n.layout,d=n.width,S=l==="horizontal"||c==="horizontal",m=r*u,b=S?d:g,E=Math.ceil((b+a-m)/u);return Math.max(0,Math.min(T-1,r+E-1))},initInstanceProps:function(n){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(n){n.itemSize}});const vn="_layerContainer_1lbvo_1",yn="_layer_1lbvo_1",hn="_small_1lbvo_23",Tn="_heading_1lbvo_26",Sn="_option_1lbvo_27",bn="_message_1lbvo_28",_n="_focused_1lbvo_64",In="_selected_1lbvo_68",En="_disabled_1lbvo_71",wn="_check_1lbvo_75",On="_optionContent_1lbvo_92",Ln="_label_1lbvo_97",Rn="_icon_1lbvo_104",qn="_details_1lbvo_109",H={layerContainer:vn,layer:yn,small:hn,heading:Tn,option:Sn,message:bn,focused:_n,selected:In,disabled:En,check:wn,optionContent:On,label:Ln,icon:Rn,details:qn},Le=({label:e})=>o.jsx("div",{onClick:n=>n.stopPropagation(),className:H.heading,children:e});Le.__docgenInfo={description:"",methods:[],displayName:"Heading",props:{label:{required:!0,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:""}}};const Re=({details:e,label:n,icon:r,disabled:a=!1,selected:l=!1,focused:g=!1,onSelectOption:T,actions:u,closeLayer:c,testId:d})=>o.jsxs("div",{className:G(H.option,a?H.disabled:"",l?H.selected:"",g?H.focused:""),onClick:!a&&T?T: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(Ue,{actions:u,closeLayer:c})}),o.jsx("span",{className:H.check,children:l?o.jsx(ce,{icon:Ee.CHECK}):null})]});Re.__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 qe=({section:e,selected:n,focused:r,onSelectOption:a,closeLayer:l})=>{const g=M.useContext(me);switch(e.type){case se.HEADING:return o.jsx(Le,{label:e.label});case se.OPTION:default:return o.jsx(Re,{closeLayer:l,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})}};qe.__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},xe="13px",Ce="12px",xn="Roobert",Cn="sans-serif",Mn=12,Nn=8,An=30,Fn=24,Hn=5,jn=3,Dn=1,kn=2,Se=10,Me=(e=!1,n=!1)=>`${e?Ce:xe} ${n?xn:Cn}`,Pn=(e=!1,n=!1)=>(e?Nn:Mn)+(e?Fn:An)+(n?17:0),be=(e,n,r,a)=>{const l=Me(n,r),g=a?de(a,l):0,T=Math.ceil(e.reduce((c,d)=>{var v;const S=(((v=d==null?void 0:d.actions)==null?void 0:v.length)??0)*24,m=d.icon?parseInt(n?Ce:xe)+7:0,b=`${d.label} ${d.details||""}`,E=de(b,l)+S+m;return c=E>c?E:c,c},g)),u=Pn(n,!0);return T+u},Wn=(e,n,r)=>{const a=Me(!0,r),l=de(e.label,a),g=(n?jn:Hn)*2+Dn*2+kn;return Math.ceil(l+g)},Ne=({listRef:e,isMulti:n,sections:r,selectedOptions:a,onSelectOption:l,focusedOptionIndex:g,width:T,small:u,firstSelectedOptionIndex:c,closeLayer:d,testId:S})=>{M.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":S,className:G(H.layer,u&&H.small),children:r.length?o.jsx(gn,{ref:e,height:r.length<Se?m*r.length:m*Se,itemCount:r.length,itemSize:m,width:T,children:({index:b,style:E})=>{var v;return o.jsx("div",{style:E,children:o.jsx(qe,{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=>l(t,r[b])})})}}):o.jsx("ul",{children:o.jsx("li",{children:o.jsx("div",{className:H.message,style:{width:T},children:"No matches"})})})})};Ne.__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 zn="_inputInTable_7uwhv_1",Gn="_inputHover_7uwhv_13",$n="_inputFocus_7uwhv_18",Un="_inputError_7uwhv_25",Vn="_inputWarning_7uwhv_26",Yn="_inputDisabled_7uwhv_61",Kn="_hideScrollbars_7uwhv_67",Bn="_trigger_7uwhv_77",Zn="_isInTable_7uwhv_93",Xn="_input_7uwhv_1",Jn="_isOpen_7uwhv_114",Qn="_disabled_7uwhv_156",et="_icons_7uwhv_162",nt="_clearAll_7uwhv_169",tt="_iconOpen_7uwhv_170",rt="_small_7uwhv_181",at="_triggerInputContainer_7uwhv_189",it="_right_7uwhv_198",st="_multiOptions_7uwhv_211",lt="_multiOption_7uwhv_211",ot="_label_7uwhv_239",ut="_closeMultiOption_7uwhv_242",ct="_focus_7uwhv_253",dt="_selectedSingleValue_7uwhv_257",mt="_placeHolder_7uwhv_258",pt="_groupOrderFirst_7uwhv_297",ft="_groupOrderMiddle_7uwhv_298",gt="_groupOrderLast_7uwhv_302",vt="_detailedLabel_7uwhv_307",C={inputInTable:zn,inputHover:Gn,inputFocus:$n,inputError:Un,inputWarning:Vn,inputDisabled:Yn,hideScrollbars:Kn,trigger:Bn,isInTable:Zn,input:Xn,isOpen:Jn,disabled:Qn,icons:et,clearAll:nt,iconOpen:tt,small:rt,triggerInputContainer:at,right:it,multiOptions:st,multiOption:lt,label:ot,closeMultiOption:ut,focus:ct,selectedSingleValue:dt,placeHolder:mt,groupOrderFirst:pt,groupOrderMiddle:ft,groupOrderLast:gt,detailedLabel:vt},Ae=({selectedOptions:e,small:n,width:r,testId:a})=>{const[g,T]=M.useState([]),[u,c]=M.useState([]);return M.useEffect(()=>{let d=[],S=[],m=0;e.forEach((b,E)=>{m+=Wn(b,n,!0),E===e.length-1&&m<r||m<r-24?d.push(b):S.push(b)}),T(d),c(S)},[e,!0,r]),o.jsxs("div",{className:C.multiOptions,"data-testid":a&&`${a}-value`,children:[g.filter(d=>d&&d.label).map((d,S)=>o.jsx("span",{className:C.multiOption,onClick:m=>{m.stopPropagation()},children:d.label},S)),u.length>0&&o.jsx(pe,{text:u.map((d,S)=>o.jsx("div",{children:d.label},S)),display:"inline-flex",children:o.jsx("span",{className:C.multiOption,children:g.length?`+${u.length}`:`${u.length} items`})})]})};Ae.__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 Fe=({selectedOptions:e,searchable:n=!1,searchValue:r,onChange:a=ae.noop,inputRef:l,error:g,placeholder:T="Select...",small:u,testId:c})=>{const d=M.useRef(null),S=Array.isArray(e),m=S?e.length>0:!!e,b=r?r.length+1:1,E=()=>{var i,s;const v=((i=d.current)==null?void 0:i.offsetWidth)||0,t=((s=l.current)==null?void 0:s.offsetWidth)||0;return v-t};return o.jsxs("div",{className:C.triggerInputContainer,ref:d,children:[m?S?o.jsx(Ae,{selectedOptions:e,small:u,width:E(),testId:c}):o.jsx("span",{className:C.selectedSingleValue,"data-testid":c&&`${c}-value`,children:r!=null&&r.length?"":e==null?void 0:e.label}):o.jsx("span",{className:C.placeHolder,children:r!=null&&r.length?"":T}),n?o.jsx("input",{tabIndex:-1,ref:l,size:b,className:C.input,value:r,onChange:v=>a(v.target.value),"data-error":g||null,"data-testid":c&&`${c}-input`}):null]})};Fe.__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 He=({selectedOptions:e,searchValue:n,searchable:r,clearable:a,onClickTrigger:l,element:g,error:T,warning:u,tooltip:c,small:d,isInTable:S,disabled:m,onChangeSearch:b,onClickDeselect:E,onClickClear:v,tabIndex:t,isOpen:i,triggerRef:s,clearAllIsFocused:p,focusedSelectedOptionIndex:y,onFocus:I,onBlur:f,groupOrder:h,maxTooltipWidth:w,placeholder:N,right:q,testId:L})=>{var j;const[R,x]=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 C.groupOrderFirst;case ie.LAST:return C.groupOrderLast;default:return C.groupOrderMiddle}return""})(),V=!Array.isArray(e)&&(e!=null&&e.details)?{...e,label:o.jsxs("div",{className:G(C.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:s,tabIndex:t,className:G(C.trigger,i?C.isOpen:"",m?C.disabled:"",d?C.small:"",S?C.isInTable:"",q?C.right:"",z),onClick:D=>{D.stopPropagation(),typeof x=="function"&&x(),l(D)},onFocus:I,onBlur:f,"data-error":T||null,"data-warning":u||null,"data-testid":L,children:[o.jsx(Fe,{selectedOptions:V,placeholder:N,searchable:r,searchValue:n,inputRef:R,onChange:b,error:T,small:d,testId:L}),o.jsx("span",{className:C.icons,children:F?o.jsx("span",{className:G(C.clearAll,p?C.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(C.iconOpen),children:o.jsx(ce,{icon:"chevron down"})})})]})]});return o.jsx(o.Fragment,{children:o.jsx(pe,{error:!!T,warning:!!u,text:c||T||u,enabled:c&&ne(c)||T&&ne(T)||u&&ne(u)||!1,maxWidth:w,placement:"bottom-center",children:$})})};He.__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 je={options:["none","clearAll"],currentIndex:0,currentOption:!1,clearAll:!1},yt=e=>e!==null?e+1:0,De=(e,n)=>{const r=["none",...e.map((l,g)=>l.type!==se.HEADING?g:null).filter(l=>l!==null)],a=yt(n);return{options:r,currentIndex:a,current:r[a]}},ht=(e,n)=>{const r=e==="up"?-1:1,a=n.currentIndex+r,l=(a<0?n.options.length-1:a)%n.options.length,g=n.options[l];return{...n,currentIndex:l,current:g}},Tt=(e,n,r)=>{const a=e==="left"?-1:1,l=n&&n.length?["none",...Array.from({length:n.length},(d,S)=>S),"clearAll"]:["none","clearAll"],g=r.currentIndex+a,T=(g<0?l.length-1:g)%l.length,u=l[T];return{options:l,currentIndex:T,currentOption:u,clearAll:u==="clearAll"}},_e=()=>je,Ie=e=>({...e,currentIndex:0,current:"none"}),St=(e,n)=>{switch(n.type){case W.SET_VISIBLE_OPTIONS:return{...e,visibleOptions:n.options||[]};case W.RESET_LAYER_FOCUS:return{...e,layerFocus:De(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(l=>(String(l.label)+(l.details?String(l.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}},bt={auto:!0,possiblePlacements:["bottom-start","top-start"],placement:"bottom-start",preferX:"right",preferY:"bottom"},_t=({state:e,dispatch:n,options:r,setTriggerFocus:a,disabled:l,disabledContext:g,onCreate:T,onChange:u,selectedOptions:c,width:d,small:S,isFontLoaded:m,placeholder:b,firstSelectedOptionIndex:E,createAble:v,listRef:t,autoLayerWidth:i})=>{const s=()=>{e.isLayerOpen&&n({type:P.CLOSE_LAYER}),a()},p=()=>n({type:P.OPEN_LAYER}),y=M.useRef(!0);M.useEffect(()=>{y.current?y.current=!1:n({type:P.SET_VISIBLE_OPTIONS,options:r})},[r]);const I=(_,O,Q)=>{if(!(l||g)){if(Q&&Q(),O){if(O.createAble&&T)T(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=M.useCallback(()=>d?d!=="auto"?d:be(r,S,m,b):"100%",[r,m]),h=M.useCallback(_=>i?Math.max(be(r,S,m,b),_==null?void 0:_.width):_==null?void 0:_.width,[r,m]),{renderLayer:w,layerProps:N,triggerProps:q,triggerBounds:L}=Pe({isOpen:(e==null?void 0:e.isLayerOpen)??!1,overflowContainer:!0,...bt,ResizeObserver,onOutsideClick:s,onParentClose:s}),R=()=>{if(!(l||g)){if(e.isLayerOpen){s();return}n({type:P.RESET_LAYER_FOCUS,options:r,firstSelectedOptionIndex:E}),p()}},x=M.useRef(!0);M.useEffect(()=>{x.current?x.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=ht(_,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],s)},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:{s();break}}},clearAllIsFocused:k,triggerProps:q,onClickTrigger:R,onChangeSearch:z,onClickDeselectOption:A,onClickClearAll:F,renderLayer:w,layerProps:N,closeLayer:s,onSelectOption:I,getLayerWidth:h,triggerBounds:L}},ke=e=>{const{multi:n=!1,disabled:r=!1,error:a=null,warning:l=null,tooltip:g=null,options:T,selectedOptions:u,onCreate:c=null,placeholder:d="",small:S=!1,tabIndex:m=0,onFocus:b=()=>{},onBlur:E=()=>{},searchable:v=!0,clearable:t=!1,maxTooltipWidth:i,closeOnOptionActionClick:s,isInTable:p=!1,groupOrder:y,firstSelectedOptionIndex:I=0,right:f=!1,testId:h=void 0}=e,w=M.useContext(me),N=c!==null,q=M.useRef(null),[L,R]=Oe(),x=!0,[A,F]=M.useReducer(St,{options:T,firstSelectedOptionIndex:I},({options:Y})=>({searchValue:"",visibleOptions:Y,layerFocus:De(Y,I??0),triggerFocus:je,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}=_t({...e,state:A,dispatch:F,setTriggerFocus:R,disabledContext:w,isFontLoaded:x,createAble:N,listRef:q});return o.jsx("div",{style:{width:z()},children:o.jsxs(ze,{handleKeys:Object.values(B),onKeyEvent:V,children:[o.jsx(He,{selectedOptions:u,searchValue:A.searchValue,isOpen:A.isLayerOpen,focusedSelectedOptionIndex:A.triggerFocus.currentOption,clearAllIsFocused:$,searchable:v,triggerRef:We(L,j.ref),error:a,warning:l,tooltip:g,small:S,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(Ne,{listRef:q,isMulti:n,sections:A.visibleOptions,selectedOptions:u,onSelectOption:(Y,K)=>{_(Y,K,n?void 0:J)},closeLayer:()=>{s&&J()},width:O(Q),small:S,focusedOptionIndex:A.layerFocus.current,firstSelectedOptionIndex:I??0,testId:h&&`${h}-layer`})}))]})})};ke.__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 It=e=>{const{name:n="",options:r=[],value:a,native:l=!1,onChange:g=ae.noop,deprecatedEventHandler:T=!1,autoScroll:u=!0,warning:c,error:d,checkNonExistentValues:S=!0,closeOnOptionActionClick:m=!0,testId:b,disabled:E}=e,v=!l&&u===!0,{multi:t,simpleInputs:i,options:s,selectedOptions:p,firstSelectedOptionIndex:y,hasNonExistentValue:I}=Ve(r,a,v,S),f=!t,h=l&&f;l&&!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,q=I&&d&&!E?o.jsxs("div",{children:[o.jsx("div",{children:w}),o.jsx("div",{children:d})]}):d,L=(R,x)=>{if(T){const A=t?x.map(F=>i?F.value:F):i?x.value:x;A&&g(A)}else{const A=!(R instanceof Event),F=t?x:x.value;if(A)R.target.name=n,R.target.value=F,t||(R.target.label=x.label),g(R);else{const z={...R,target:{...R.target,name:n,value:F,label:t?void 0:x.label}};g(z)}}};return h?o.jsx(we,{...e,options:s,selectedOption:p,onChange:L,hasNonExistentValue:I,warning:N,error:q,testId:b}):o.jsx(ke,{...e,options:s,selectedOptions:p,onChange:L,multi:t,firstSelectedOptionIndex:y,warning:N,error:q,testId:b,closeOnOptionActionClick:m})};It.__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{It as S};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import{j as q}from"./jsx-runtime-eps93zm2.js";import{r as I}from"./index-DhsZuJvc.js";import{w as s,u as c,e as l,a as F}from"./index-DMAnyMX5.js";import{S as T}from"./select-BQzJMnK1.js";import{o as K}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 me={title:"Forms/Select/Test Cases",component:T,args:{options:K},tags:["!autodocs"]},v=n=>{const{multi:o,value:a}=n,[r,t]=I.useState(a||(o?[]:void 0)),e=i=>{const{value:u}=i.target;t(o?u:{value:u})};return q.jsx(T,{value:r,onChange:e,...n})},y=v.bind({});y.args={value:{label:"Vampires",value:"blood"},disabled:!0};const m=v.bind({});m.args={testId:"testId",clearable:!0};m.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Select item with click",async()=>{const t=a.getByTestId("testId");await c.click(t);const e=await r.findByTestId("testId-layer");l(e).toBeInTheDocument();const i=s(e).getByText("Wombats");await c.click(i);const u=await a.findByTestId("testId-value");l(s(u).getByText("Wombats")).toBeInTheDocument()}),await o("Clear selected value",async()=>{const t=a.getByTestId("testId-clear");await c.click(t);const e=a.queryByTestId("testId-value");l(e).not.toBeInTheDocument()})};const p=v.bind({});p.args={testId:"testId",clearable:!0,multi:!0};p.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Select items with click",async()=>{const t=a.getByTestId("testId");await c.click(t);const e=await r.findByTestId("testId-layer");l(e).toBeInTheDocument();const i=s(e).getByText("Wombats");await c.click(i);const u=s(e).getByText("Kangaroos");await c.click(u),await c.click(n),l(e).not.toBeInTheDocument();const w=await a.findByTestId("testId-value");l(s(w).getByText("Wombats")).toBeInTheDocument(),l(s(w).getByText("Kangaroos")).toBeInTheDocument()}),await o("Deselect item with click",async()=>{const t=a.getByTestId("testId");await c.click(t);const e=await r.findByTestId("testId-layer");l(e).toBeInTheDocument();const i=s(e).getByText("Wombats");await c.click(i),await c.click(n),l(e).not.toBeInTheDocument();const u=await a.findByTestId("testId-value");l(s(u).queryByText("Wombats")).not.toBeInTheDocument()}),await o("Clear selected values",async()=>{const t=a.getByTestId("testId-clear");await c.click(t),await F(()=>{const e=a.queryByTestId("testId-value");l(e).not.toBeInTheDocument()})})};const g=v.bind({});g.args={testId:"testId",disabled:!0};g.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Clicking disabled trigger should not show layer",async()=>{await a.getByTestId("testId").click(),await F(()=>{const e=r.queryByTestId("testId-layer");l(e).not.toBeInTheDocument()})})};const d=()=>{const[n,o]=I.useState(K),[a,r]=I.useState(void 0);return q.jsx(T,{testId:"testId",name:"example",options:n,onChange:t=>r({value:t.target.value}),onCreate:t=>{const e={label:t,value:t};o([...n,e]),r(e)},value:a})};d.args={testId:"testId"};d.play=async({canvasElement:n,step:o})=>{const a=s(n),r=s(n.ownerDocument.body);await o("Create new item",async()=>{const t=a.getByTestId("testId-input");if(l(t).toBeInTheDocument(),!t)return;await c.type(t,"New value");const e=r.getByText('Create "New value"');await c.click(e);const i=await a.findByTestId("testId-value");l(s(i).getByText("New value")).toBeInTheDocument()})};d.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestCreate"};var h,B,S;y.parameters={...y.parameters,docs:{...(h=y.parameters)==null?void 0:h.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
|
-
}`,...(S=(B=y.parameters)==null?void 0:B.docs)==null?void 0:S.source}}};var b,V,x;m.parameters={...m.parameters,docs:{...(b=m.parameters)==null?void 0:b.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=m.parameters)==null?void 0:V.docs)==null?void 0:x.source}}};var C,D,f;p.parameters={...p.parameters,docs:{...(C=p.parameters)==null?void 0:C.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=(D=p.parameters)==null?void 0:D.docs)==null?void 0:f.source}}};var k,j,N;g.parameters={...g.parameters,docs:{...(k=g.parameters)==null?void 0:k.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
|
-
}`,...(N=(j=g.parameters)==null?void 0:j.docs)==null?void 0:N.source}}};var W,_,O;d.parameters={...d.parameters,docs:{...(W=d.parameters)==null?void 0:W.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
|
-
}`,...(O=(_=d.parameters)==null?void 0:_.docs)==null?void 0:O.source}}};const pe=["TestDisabledNonExistentValue","Test","TestMulti","TestDisabled","TestCreate"];export{m as Test,d as TestCreate,g as TestDisabled,y as TestDisabledNonExistentValue,p as TestMulti,pe as __namedExportsOrder,me as default};
|