@oliasoft-open-source/react-ui-library 4.8.2-beta-1 → 4.8.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 (32) hide show
  1. package/dist/404.html +1 -0
  2. package/dist/storybook/assets/{Color-KGDBMAHA-5t9vWuuQ.js → Color-KGDBMAHA-CLI1j7TM.js} +1 -1
  3. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-C4Y4AfWk.js → DocsRenderer-PKQXORMH-C-VGLian.js} +1 -1
  4. package/dist/storybook/assets/{accordion.stories-Bv00H3Md.js → accordion.stories-CjdOndbq.js} +1 -1
  5. package/dist/storybook/assets/{buttons-and-links-CurhOihj.js → buttons-and-links-DLCyz4fu.js} +1 -1
  6. package/dist/storybook/assets/{casing-loads.stories-X3nSWrJV.js → casing-loads.stories-Cb2t61c-.js} +1 -1
  7. package/dist/storybook/assets/{cell.stories-BvYuOEua.js → cell.stories-B6XrqnOz.js} +1 -1
  8. package/dist/storybook/assets/{chunk-HLWAVYOI-BMaNuZAP.js → chunk-HLWAVYOI-B-NqvPla.js} +1 -1
  9. package/dist/storybook/assets/{color-DAqzZJ5g.js → color-DFh0-vFc.js} +1 -1
  10. package/dist/storybook/assets/{footer.stories-DwXUmoze.js → footer.stories-BxFhNGsz.js} +1 -1
  11. package/dist/storybook/assets/{formation.stories-BIW-Dl8H.js → formation.stories-r9JrQX7d.js} +1 -1
  12. package/dist/storybook/assets/{iframe-DKsrL1t6.js → iframe-DOgYbEjR.js} +2 -2
  13. package/dist/storybook/assets/{index--1DEpRYI.js → index-BIH3zom3.js} +1 -1
  14. package/dist/storybook/assets/{index-CZYm9n2f.js → index-MQZw3-wz.js} +88 -88
  15. package/dist/storybook/assets/{input-validation-C6sI0xWh.js → input-validation-BhTmzA8C.js} +1 -1
  16. package/dist/storybook/assets/{inputs-g6Qqs79j.js → inputs-BZwMYCXB.js} +1 -1
  17. package/dist/storybook/assets/{layout-forms-B3vD4GnB.js → layout-forms-j_hFXArR.js} +1 -1
  18. package/dist/storybook/assets/{layout-general-BtQS23Q-.js → layout-general-hZ1fwnpl.js} +1 -1
  19. package/dist/storybook/assets/{number-input-DZ9ERbK_.js → number-input-C8O0lnql.js} +2 -2
  20. package/dist/storybook/assets/{number-input.stories-TArdbUGM.js → number-input.stories-e-MRb-7_.js} +1 -1
  21. package/dist/storybook/assets/{padding-and-spacing-6fonPuoc.js → padding-and-spacing-DZHdCzCJ.js} +1 -1
  22. package/dist/storybook/assets/{preview-I53T45Im.js → preview-_veCKVNG.js} +2 -2
  23. package/dist/storybook/assets/{preview-o8g2WtEI.js → preview-nWTzJqHS.js} +1 -1
  24. package/dist/storybook/assets/{row.stories-Cwjgv2sq.js → row.stories-BRVnImTl.js} +1 -1
  25. package/dist/storybook/assets/{table-D1GJPQfF.js → table-DWBe_npR.js} +1 -1
  26. package/dist/storybook/assets/{table.stories-CZbXa0mx.js → table.stories-Cb7lE3nF.js} +1 -1
  27. package/dist/storybook/assets/{title.stories-DtNSzV-q.js → title.stories-TUTSNdwJ.js} +1 -1
  28. package/dist/storybook/assets/{unit-input.stories-Ds9cL2Sl.js → unit-input.stories-CRAsgJro.js} +1 -1
  29. package/dist/storybook/assets/{unit-table.stories-C0IlAwKr.js → unit-table.stories-BdTJv4W-.js} +1 -1
  30. package/dist/storybook/iframe.html +1 -1
  31. package/dist/storybook/project.json +1 -1
  32. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as r}from"./index-BcNHZKhG.js";import{Z as s,$ as n}from"./index-CZYm9n2f.js";import{NonExistentValue as a,Error as l}from"./select.stories-B0d_sE6g.js";import"./index-DhsZuJvc.js";import"./iframe-DKsrL1t6.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./index-DMAnyMX5.js";import"./index-CF7H4eMJ.js";import"./select-BpALjE__.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"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./spacer-BWoNR27H.js";function o(t){const i={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",strong:"strong",...r(),...t.components};return e.jsxs(e.Fragment,{children:[e.jsx(s,{title:"Input Validation"}),`
1
+ import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as r}from"./index-BcNHZKhG.js";import{Z as s,$ as n}from"./index-MQZw3-wz.js";import{NonExistentValue as a,Error as l}from"./select.stories-B0d_sE6g.js";import"./index-DhsZuJvc.js";import"./iframe-DOgYbEjR.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./index-DMAnyMX5.js";import"./index-CF7H4eMJ.js";import"./select-BpALjE__.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"./enum-Bnn40S8Q.js";import"./index-CEuq6vkz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./spacer-BWoNR27H.js";function o(t){const i={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",strong:"strong",...r(),...t.components};return e.jsxs(e.Fragment,{children:[e.jsx(s,{title:"Input Validation"}),`
2
2
  `,e.jsx(i.h1,{id:"input-validation",children:"Input Validation"}),`
3
3
  `,e.jsx(i.h2,{id:"select",children:"Select"}),`
4
4
  `,e.jsx(i.h3,{id:"invalid-states",children:"Invalid states"}),`
@@ -1,4 +1,4 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as s}from"./index-BcNHZKhG.js";import{Z as r,$ as o}from"./index-CZYm9n2f.js";import{Default as l}from"./button.stories-tM18j4A3.js";import{Default as a}from"./check-box.stories-Q_WICJ_2.js";import{Default as c}from"./file-input.stories-DTRWZyqS.js";import{Default as d,Date as p}from"./input.stories-FKl0qVhm.js";import{Default as h}from"./number-input.stories-TArdbUGM.js";import{Default as m}from"./option-dropdown.stories-ntKLWycS.js";import{Default as u}from"./radio-button.stories-CAHs1mr6.js";import{Native as f,Default as x}from"./select.stories-B0d_sE6g.js";import{Default as j}from"./slider.stories-7oMw2PCp.js";import{Default as b}from"./textarea.stories-CJ-Oqytp.js";import{Default as g}from"./toggle.stories-DOc7uN93.js";import"./index-DhsZuJvc.js";import"./iframe-DKsrL1t6.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./react-router-dom-CMITYWBH.js";import"./index-CEuq6vkz.js";import"./tiny-invariant-DqLgxztJ.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./flex-EllkLxgO.js";import"./button-CzvLc2io.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./tooltip-1V7clEnw.js";import"./index-DMAnyMX5.js";import"./index-CF7H4eMJ.js";import"./check-box-wCvXxtCz.js";import"./help-icon-41R-Z9N1.js";import"./file-input-CMP44wlr.js";import"./lodash-c4VUpsOs.js";import"./input-group-BaRSJAEN.js";import"./input-DTXbDJaL.js";import"./types-Dx2TtIG9.js";import"./spacer-BWoNR27H.js";import"./message-DQ3q8XF9.js";import"./textarea-D6ltcKhz.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./grid-DRkC-bt8.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./card-EcjmryU9.js";import"./heading-NkLgQYoP.js";import"./input-group-addon-D68iUKV2.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./number-input-DZ9ERbK_.js";import"./divider-DY9nJ_7N.js";import"./radio-button-C3RuBqEf.js";import"./slider-CBE03NwD.js";import"./objectSpread2-DW4nTBoq.js";import"./index-BI4_Bp97.js";import"./toggle-C0zvrIOF.js";function i(n){const t={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",strong:"strong",ul:"ul",...s(),...n.components};return e.jsxs(e.Fragment,{children:[e.jsx(r,{title:"Inputs"}),`
1
+ import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as s}from"./index-BcNHZKhG.js";import{Z as r,$ as o}from"./index-MQZw3-wz.js";import{Default as l}from"./button.stories-tM18j4A3.js";import{Default as a}from"./check-box.stories-Q_WICJ_2.js";import{Default as c}from"./file-input.stories-DTRWZyqS.js";import{Default as d,Date as p}from"./input.stories-FKl0qVhm.js";import{Default as h}from"./number-input.stories-e-MRb-7_.js";import{Default as m}from"./option-dropdown.stories-ntKLWycS.js";import{Default as u}from"./radio-button.stories-CAHs1mr6.js";import{Native as f,Default as x}from"./select.stories-B0d_sE6g.js";import{Default as j}from"./slider.stories-7oMw2PCp.js";import{Default as b}from"./textarea.stories-CJ-Oqytp.js";import{Default as g}from"./toggle.stories-DOc7uN93.js";import"./index-DhsZuJvc.js";import"./iframe-DOgYbEjR.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./react-router-dom-CMITYWBH.js";import"./index-CEuq6vkz.js";import"./tiny-invariant-DqLgxztJ.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./flex-EllkLxgO.js";import"./button-CzvLc2io.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./tooltip-1V7clEnw.js";import"./index-DMAnyMX5.js";import"./index-CF7H4eMJ.js";import"./check-box-wCvXxtCz.js";import"./help-icon-41R-Z9N1.js";import"./file-input-CMP44wlr.js";import"./lodash-c4VUpsOs.js";import"./input-group-BaRSJAEN.js";import"./input-DTXbDJaL.js";import"./types-Dx2TtIG9.js";import"./spacer-BWoNR27H.js";import"./message-DQ3q8XF9.js";import"./textarea-D6ltcKhz.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./grid-DRkC-bt8.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./card-EcjmryU9.js";import"./heading-NkLgQYoP.js";import"./input-group-addon-D68iUKV2.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./number-input-C8O0lnql.js";import"./divider-DY9nJ_7N.js";import"./radio-button-C3RuBqEf.js";import"./slider-CBE03NwD.js";import"./objectSpread2-DW4nTBoq.js";import"./index-BI4_Bp97.js";import"./toggle-C0zvrIOF.js";function i(n){const t={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",strong:"strong",ul:"ul",...s(),...n.components};return e.jsxs(e.Fragment,{children:[e.jsx(r,{title:"Inputs"}),`
2
2
  `,e.jsx(t.h1,{id:"inputs",children:"Inputs"}),`
3
3
  `,e.jsx(t.p,{children:"React UI Library provides a comprehensive set of user input components."}),`
4
4
  `,e.jsx(t.h2,{id:"button",children:"Button"}),`
@@ -1,4 +1,4 @@
1
- import{j as t}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as n}from"./index-BcNHZKhG.js";import{Z as s,$ as e}from"./index-CZYm9n2f.js";import{Default as p,LabelOnLeft as m}from"./field.stories-DhiTcelS.js";import{Default as l,LabelsOnLeft as a,Row as h}from"./form.stories-C_zflIAj.js";import"./index-DhsZuJvc.js";import"./iframe-DKsrL1t6.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./field-C5_fLDpy.js";import"./index-Bk2sglWO.js";import"./label-hiSz3I8H.js";import"./common-types-Sih75Sav.js";import"./help-icon-41R-Z9N1.js";import"./tooltip-1V7clEnw.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./input-DTXbDJaL.js";import"./types-Dx2TtIG9.js";import"./lodash-c4VUpsOs.js";import"./text-B3-TSWok.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./check-box-wCvXxtCz.js";import"./button-group-C1PqMW-H.js";import"./toggle-C0zvrIOF.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./slider-CBE03NwD.js";import"./objectSpread2-DW4nTBoq.js";import"./index-BI4_Bp97.js";import"./textarea-D6ltcKhz.js";import"./radio-button-C3RuBqEf.js";import"./form-row-CM112EYF.js";function r(o){const i={code:"code",h1:"h1",h2:"h2",p:"p",...n(),...o.components};return t.jsxs(t.Fragment,{children:[t.jsx(s,{title:"Layout (Forms)"}),`
1
+ import{j as t}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as n}from"./index-BcNHZKhG.js";import{Z as s,$ as e}from"./index-MQZw3-wz.js";import{Default as p,LabelOnLeft as m}from"./field.stories-DhiTcelS.js";import{Default as l,LabelsOnLeft as a,Row as h}from"./form.stories-C_zflIAj.js";import"./index-DhsZuJvc.js";import"./iframe-DOgYbEjR.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./field-C5_fLDpy.js";import"./index-Bk2sglWO.js";import"./label-hiSz3I8H.js";import"./common-types-Sih75Sav.js";import"./help-icon-41R-Z9N1.js";import"./tooltip-1V7clEnw.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./input-DTXbDJaL.js";import"./types-Dx2TtIG9.js";import"./lodash-c4VUpsOs.js";import"./text-B3-TSWok.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./check-box-wCvXxtCz.js";import"./button-group-C1PqMW-H.js";import"./toggle-C0zvrIOF.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./slider-CBE03NwD.js";import"./objectSpread2-DW4nTBoq.js";import"./index-BI4_Bp97.js";import"./textarea-D6ltcKhz.js";import"./radio-button-C3RuBqEf.js";import"./form-row-CM112EYF.js";function r(o){const i={code:"code",h1:"h1",h2:"h2",p:"p",...n(),...o.components};return t.jsxs(t.Fragment,{children:[t.jsx(s,{title:"Layout (Forms)"}),`
2
2
  `,t.jsx(i.h1,{id:"layout-forms",children:"Layout (Forms)"}),`
3
3
  `,t.jsx(i.h2,{id:"field",children:"Field"}),`
4
4
  `,t.jsxs(i.p,{children:["This is a wrapper for any form element with default bottom margin, and props like ",t.jsx(i.code,{children:"label"})," for other default styling."]}),`
@@ -1,4 +1,4 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as s}from"./index-BcNHZKhG.js";import{Z as r,$ as n}from"./index-CZYm9n2f.js";import{Center as d,SpaceBetween as l,JustifyEnd as a,Column as c}from"./flex.stories-DtDxXdHB.js";import{Default as h,CustomColumnWidth as p,DefaultGap as x,CustomGap as m,Responsive as u}from"./grid.stories-DqjhHHwX.js";import{Default as j,FixedWidth as f,NoPadding as w,ResponsiveWidth as g}from"./column.stories-DATtbLrP.js";import"./index-DhsZuJvc.js";import"./iframe-DKsrL1t6.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./flex-EllkLxgO.js";import"./button-CzvLc2io.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./text-B3-TSWok.js";import"./grid-DRkC-bt8.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./card-EcjmryU9.js";import"./row-Bmiy2Lh0.js";import"./heading-NkLgQYoP.js";import"./help-icon-41R-Z9N1.js";function t(i){const o={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",...s(),...i.components};return e.jsxs(e.Fragment,{children:[e.jsx(r,{title:"Layout (General)"}),`
1
+ import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as s}from"./index-BcNHZKhG.js";import{Z as r,$ as n}from"./index-MQZw3-wz.js";import{Center as d,SpaceBetween as l,JustifyEnd as a,Column as c}from"./flex.stories-DtDxXdHB.js";import{Default as h,CustomColumnWidth as p,DefaultGap as x,CustomGap as m,Responsive as u}from"./grid.stories-DqjhHHwX.js";import{Default as j,FixedWidth as f,NoPadding as w,ResponsiveWidth as g}from"./column.stories-DATtbLrP.js";import"./index-DhsZuJvc.js";import"./iframe-DOgYbEjR.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";import"./flex-EllkLxgO.js";import"./button-CzvLc2io.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./text-B3-TSWok.js";import"./grid-DRkC-bt8.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./card-EcjmryU9.js";import"./row-Bmiy2Lh0.js";import"./heading-NkLgQYoP.js";import"./help-icon-41R-Z9N1.js";function t(i){const o={code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",...s(),...i.components};return e.jsxs(e.Fragment,{children:[e.jsx(r,{title:"Layout (General)"}),`
2
2
  `,e.jsx(o.h1,{id:"layout-general",children:"Layout (General)"}),`
3
3
  `,e.jsx(o.h2,{id:"flex",children:"Flex"}),`
4
4
  `,e.jsxs(o.p,{children:["The ",e.jsx(o.code,{children:"Flex"})," component is a basic flexbox wrapper with optional props for ",e.jsx(o.code,{children:"alignItems"}),", ",e.jsx(o.code,{children:"justifyContent"})," and ",e.jsx(o.code,{children:"flexDirection"}),". This is a conveninent way to center items vertically and/or horizontally, to align them to opposite edges, or align them to the far side."]}),`
@@ -1,4 +1,4 @@
1
- import{j as h}from"./jsx-runtime-eps93zm2.js";import{r as s}from"./index-DhsZuJvc.js";import{d as o}from"./index-C0x1JmaP.js";import{K as z,E as G}from"./enum-Bnn40S8Q.js";import{l as J}from"./lodash-c4VUpsOs.js";import{I as Q}from"./input-DTXbDJaL.js";const u=n=>String(o.toString(n)),U=n=>n?typeof n=="string"?n:J.isArray(n)?n[0]:n.fieldName:"",X=({name:n,placeholder:I="",disabled:F=!1,error:c=!1,left:L=!1,small:k=!1,width:x="100%",value:m="",onChange:R=()=>{},onFocus:S=()=>{},onBlur:j=()=>{},tabIndex:C=0,testId:H,tooltip:M=null,warning:K=!1,validationCallback:y=()=>{},allowEmpty:A=!1,isInTable:O,groupOrder:B,enableDisplayRounding:d=!1,roundDisplayValue:v,disableInternalErrorValidationMessages:D=!1})=>{const t=s.useRef(null),[r,T]=s.useState(u(m)),[l,b]=s.useState(!1),i=U(n),w=e=>{const a=o.validateNumber(e);return A&&e===""||a.valid?{...a,valid:!0,errors:void 0}:a},{valid:p,errors:f}=w(r),E=f&&f.length&&!D?f[0]:null;s.useEffect(()=>{T(u(m))},[m,d]),s.useEffect(()=>{!l&&!p?y(i,E):y(i,null)},[l,p,c]);const q=e=>{var N,V;const a=e instanceof KeyboardEvent?r:(N=e==null?void 0:e.target)==null?void 0:N.value,g=o.cleanNumStr(a.replaceAll(" ","").replaceAll("|",""));if(T(g),(V=w(g))!=null&&V.valid){const Z={...e,target:{...e.target,value:o.stripLeadingZeros(u(g)),name:i}};R(Z)}};s.useEffect(()=>{if(t&&(t!=null&&t.current)&&d&&l){const e=t.current;e&&setTimeout(()=>{const{length:a}=u(r);e.setSelectionRange(a,a)},0)}},[l]);const _=e=>{b(!0),S(e)},P=e=>{b(!1),j(e)},W=d&&!l&&p?v?u(v(r)):o.roundToFixed(r,2):r;return h.jsx(z,{handleKeys:[G.ENTER],onKeyEvent:(e,a)=>q(a),children:h.jsx(Q,{type:"text",name:i,testId:H,disabled:F,placeholder:I,value:W,onChange:q,onFocus:_,onBlur:P,error:E||c,warning:K,right:!L,small:k,width:x,isInTable:O,groupOrder:B,tabIndex:C,tooltip:M,ref:t},i)})};X.__docgenInfo={description:"",methods:[],displayName:"NumberInput",props:{name:{required:!1,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:!0}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | boolean",elements:[{name:"string"},{name:"boolean"}]},description:"",defaultValue:{value:"false",computed:!1}},left:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"'100%'",computed:!1}},value:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"''",computed:!1}},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
1
+ import{j as I}from"./jsx-runtime-eps93zm2.js";import{r as t}from"./index-DhsZuJvc.js";import{d as o}from"./index-C0x1JmaP.js";import{K as J,E as Q}from"./enum-Bnn40S8Q.js";import{l as U}from"./lodash-c4VUpsOs.js";import{I as X}from"./input-DTXbDJaL.js";const u=n=>String(o.toString(n)),Y=n=>n?typeof n=="string"?n:U.isArray(n)?n[0]:n.fieldName:"",$=({name:n,placeholder:F="",disabled:L=!1,error:g=!1,left:k=!1,small:S=!1,width:x="100%",value:m="",onChange:R=()=>{},onFocus:j=()=>{},onBlur:C=()=>{},tabIndex:H=0,testId:M,tooltip:K=null,warning:A=!1,validationCallback:y=()=>{},allowEmpty:O=!1,isInTable:B,groupOrder:D,enableDisplayRounding:d=!1,roundDisplayValue:v,disableInternalErrorValidationMessages:P=!1})=>{const r=t.useRef(null),[s,T]=t.useState(u(m)),[l,b]=t.useState(!1),[_,w]=t.useState(!0),i=Y(n),E=e=>{const a=o.validateNumber(e);return O&&e===""||a.valid?{...a,valid:!0,errors:void 0}:a},{valid:p,errors:f}=E(s),q=f&&f.length&&!P?f[0]:null;t.useEffect(()=>{T(u(m)),w(!0)},[m,d]),t.useEffect(()=>{!l&&!p?y(i,q):y(i,null)},[l,p,g]);const N=e=>{var V,h;const a=e instanceof KeyboardEvent?s:(V=e==null?void 0:e.target)==null?void 0:V.value;w(!1);const c=o.cleanNumStr(a.replaceAll(" ","").replaceAll("|",""));if(T(c),(h=E(c))!=null&&h.valid&&!_){const G={...e,target:{...e.target,value:o.stripLeadingZeros(u(c)),name:i}};R(G)}};t.useEffect(()=>{if(r&&(r!=null&&r.current)&&d&&l){const e=r.current;e&&setTimeout(()=>{const{length:a}=u(s);e.setSelectionRange(a,a)},0)}},[l]);const W=e=>{b(!0),j(e)},Z=e=>{b(!1),C(e)},z=d&&!l&&p?v?u(v(s)):o.roundToFixed(s,2):s;return I.jsx(J,{handleKeys:[Q.ENTER],onKeyEvent:(e,a)=>N(a),children:I.jsx(X,{type:"text",name:i,testId:M,disabled:L,placeholder:F,value:z,onChange:N,onFocus:W,onBlur:Z,error:q||g,warning:A,right:!k,small:S,width:x,isInTable:B,groupOrder:D,tabIndex:H,tooltip:K,ref:r},i)})};$.__docgenInfo={description:"",methods:[],displayName:"NumberInput",props:{name:{required:!1,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:!0}}]}}]},description:""},placeholder:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | boolean",elements:[{name:"string"},{name:"boolean"}]},description:"",defaultValue:{value:"false",computed:!1}},left:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"'100%'",computed:!1}},value:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"''",computed:!1}},onChange:{required:!1,tsType:{name:"signature",type:"function",raw:`(
2
2
  event: TChangeEvent<T>,
3
3
  ...additionalProps: { [key: string]: any }[]
4
4
  ) => void`,signature:{arguments:[{type:{name:"intersection",raw:`ChangeEvent<T> & {
@@ -13,4 +13,4 @@ import{j as h}from"./jsx-runtime-eps93zm2.js";import{r as s}from"./index-DhsZuJv
13
13
  | { 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:"",defaultValue:{value:"() => {}",computed:!1}},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: FocusEvent<HTMLInputElement>) => void",signature:{arguments:[{type:{name:"FocusEvent",elements:[{name:"HTMLInputElement"}],raw:"FocusEvent<HTMLInputElement>"},name:"evt"}],return:{name:"void"}}},description:"",defaultValue:{value:"() => {}",computed:!1}},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"(evt: FocusEvent<HTMLInputElement>) => void",signature:{arguments:[{type:{name:"FocusEvent",elements:[{name:"HTMLInputElement"}],raw:"FocusEvent<HTMLInputElement>"},name:"evt"}],return:{name:"void"}}},description:"",defaultValue:{value:"() => {}",computed:!1}},tabIndex:{required:!1,tsType:{name:"number"},description:"",defaultValue:{value:"0",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""},tooltip:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | React.ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactReactNode",raw:"React.ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},warning:{required:!1,tsType:{name:"union",raw:"string | boolean",elements:[{name:"string"},{name:"boolean"}]},description:"",defaultValue:{value:"false",computed:!1}},validationCallback:{required:!1,tsType:{name:"signature",type:"function",raw:`(
14
14
  name: string | { fieldName: string },
15
15
  error: string | null,
16
- ) => void`,signature:{arguments:[{type:{name:"union",raw:"string | { fieldName: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!0}}]}}]},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"void"}}},description:"",defaultValue:{value:"() => {}",computed:!1}},allowEmpty:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},isInTable:{required:!1,tsType:{name:"boolean"},description:""},groupOrder:{required:!1,tsType:{name:"any"},description:""},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},roundDisplayValue:{required:!1,tsType:{name:"signature",type:"function",raw:"(args: TStringOrNumber) => TStringOrNumber",signature:{arguments:[{type:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},name:"args"}],return:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]}}},description:""},disableInternalErrorValidationMessages:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}}}};export{X as N};
16
+ ) => void`,signature:{arguments:[{type:{name:"union",raw:"string | { fieldName: string }",elements:[{name:"string"},{name:"signature",type:"object",raw:"{ fieldName: string }",signature:{properties:[{key:"fieldName",value:{name:"string",required:!0}}]}}]},name:"name"},{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"void"}}},description:"",defaultValue:{value:"() => {}",computed:!1}},allowEmpty:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},isInTable:{required:!1,tsType:{name:"boolean"},description:""},groupOrder:{required:!1,tsType:{name:"any"},description:""},enableDisplayRounding:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},roundDisplayValue:{required:!1,tsType:{name:"signature",type:"function",raw:"(args: TStringOrNumber) => TStringOrNumber",signature:{arguments:[{type:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},name:"args"}],return:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]}}},description:""},disableInternalErrorValidationMessages:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}}}};export{$ as N};
@@ -1,4 +1,4 @@
1
- import{j as s}from"./jsx-runtime-eps93zm2.js";import{r as B}from"./index-DhsZuJvc.js";import{w as S,u as t,e as o,f as Ae,a as Se}from"./index-DMAnyMX5.js";import{d as De}from"./index-C0x1JmaP.js";import{S as Be}from"./spacer-BWoNR27H.js";import{G as xe}from"./grid-DRkC-bt8.js";import{C as x}from"./card-EcjmryU9.js";import{B as _e}from"./button-CzvLc2io.js";import{H as _}from"./heading-NkLgQYoP.js";import{I as Ne}from"./input-group-addon-D68iUKV2.js";import{S as Ee}from"./select-BpALjE__.js";import{I as Ve}from"./input-group-BaRSJAEN.js";import{N as i}from"./number-input-DZ9ERbK_.js";import"./index-CF7H4eMJ.js";import"./index-DRSy5Ssd.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"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./help-icon-41R-Z9N1.js";import"./lodash-c4VUpsOs.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";const{useArgs:Me}=__STORYBOOK_MODULE_PREVIEW_API__,ba={title:"Forms/NumberInput",component:i,parameters:{canvas:{page:null}},args:{label:"Label"}},u=a=>{const[r,e]=Me(),l=n=>{e({value:n.target.value})};return s.jsx(i,{onChange:l,value:123,...a})},D=u.bind({}),m=u.bind({});m.args={small:!0};const g=u.bind({});g.args={width:"150px"};const h=u.bind({});h.args={left:!0};const v=u.bind({});v.args={disabled:!0};const I=u.bind({});I.args={allowEmpty:!0,value:""};const p=()=>{const[a,r]=B.useState("123|m");return s.jsx(i,{name:"example",onChange:e=>r(e.target.value),placeholder:"Type a value...",value:a,testId:"testId"})};p.play=async({canvasElement:a,step:r})=>{const e=S(a),l=S(a.ownerDocument.body);await r("Shows validation error for non-numeric input",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123x45s6"),await t.click(a),await o(e.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Ae.mouseOver(n),await Se(()=>{o(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};const y=u.bind({});y.args={warning:"This input number is almost 100!",value:"99"};const C=u.bind({});C.args={error:"This is a error message"};const b=u.bind({});b.args={value:"123test"};const w=u.bind({});w.args={value:"123.123456789",enableDisplayRounding:!0};const T=u.bind({});T.args={value:"123.123456789",enableDisplayRounding:!0,roundDisplayValue:a=>De.roundToFixed(a,4)};const f=()=>s.jsxs(Ve,{small:!0,children:[s.jsx(i,{value:123}),s.jsx(Ne,{children:"to"}),s.jsx(i,{value:123}),s.jsx(Ee,{options:[{value:"units",label:"units"}],width:"auto",value:"units"})]}),c=()=>{const[a,r]=B.useState("123");return s.jsx(i,{value:a,onChange:e=>{r(e.target.value)},testId:"testId",enableDisplayRounding:!0})};c.play=async({canvasElement:a,step:r})=>{const e=S(a);await r("Value should be rounded on blur",async()=>{const l=e.getByTestId("testId");await t.clear(l),await t.type(l,"123.123456789"),await t.click(a),await o(e.getByDisplayValue("123.12")).toBeInTheDocument()}),await r("Full value shown on focus",async()=>{const l=e.getByTestId("testId");await t.click(l),await o(e.getByDisplayValue("123.123456789")).toBeInTheDocument()})};const A=()=>{const[a,r]=B.useState("123");return s.jsxs(xe,{columns:"1fr 1fr",gap:!0,children:[s.jsxs(x,{heading:s.jsx(_,{children:"Storage State (Redux)"}),children:[a,s.jsx(Be,{}),s.jsx(_e,{label:"Change value",onClick:()=>r(String(Math.floor(Math.random()*100)))})]}),s.jsx(x,{heading:s.jsx(_,{children:"NumberInput"}),children:s.jsx(i,{value:a,onChange:e=>{r(e.target.value)},error:Number(a)>=0?"":"Value must be positive"})})]})},d=()=>{const[a,r]=B.useState("123");return s.jsx(i,{value:a,onChange:e=>{r(e.target.value)},testId:"testId"})};d.play=async({canvasElement:a,step:r})=>{const e=S(a),l=S(a.ownerDocument.body);await r("Can enter decimal values",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123.123456789"),await t.click(a),await o(e.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await r("Can enter scientific notation",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"-1.12e3"),await t.click(a),await o(e.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await r("Can enter comma decimals (converts to dot)",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123,456"),await t.click(a),await o(e.getByDisplayValue("123.456")).toBeInTheDocument()}),await r("Can enter small numbers",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"0.0000000023"),await t.click(a),await o(e.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await r("Can enter large numbers",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"999999999999"),await t.click(a),await o(e.getByDisplayValue("999999999999")).toBeInTheDocument()}),await r("Shows validation error for non-numeric input",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123x45s6"),await t.click(a),await o(e.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Ae.mouseOver(n),await Se(()=>{o(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};p.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};f.__docgenInfo={description:"",methods:[],displayName:"TestInputGroup"};c.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestDisplayRounding"};A.__docgenInfo={description:"",methods:[],displayName:"ManagedTestCase"};d.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestUserInput"};var N,E,V;D.parameters={...D.parameters,docs:{...(N=D.parameters)==null?void 0:N.docs,source:{originalSource:`args => {
1
+ import{j as s}from"./jsx-runtime-eps93zm2.js";import{r as B}from"./index-DhsZuJvc.js";import{w as S,u as t,e as o,f as Ae,a as Se}from"./index-DMAnyMX5.js";import{d as De}from"./index-C0x1JmaP.js";import{S as Be}from"./spacer-BWoNR27H.js";import{G as xe}from"./grid-DRkC-bt8.js";import{C as x}from"./card-EcjmryU9.js";import{B as _e}from"./button-CzvLc2io.js";import{H as _}from"./heading-NkLgQYoP.js";import{I as Ne}from"./input-group-addon-D68iUKV2.js";import{S as Ee}from"./select-BpALjE__.js";import{I as Ve}from"./input-group-BaRSJAEN.js";import{N as i}from"./number-input-C8O0lnql.js";import"./index-CF7H4eMJ.js";import"./index-DRSy5Ssd.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"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./help-icon-41R-Z9N1.js";import"./lodash-c4VUpsOs.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";const{useArgs:Me}=__STORYBOOK_MODULE_PREVIEW_API__,ba={title:"Forms/NumberInput",component:i,parameters:{canvas:{page:null}},args:{label:"Label"}},u=a=>{const[r,e]=Me(),l=n=>{e({value:n.target.value})};return s.jsx(i,{onChange:l,value:123,...a})},D=u.bind({}),m=u.bind({});m.args={small:!0};const g=u.bind({});g.args={width:"150px"};const h=u.bind({});h.args={left:!0};const v=u.bind({});v.args={disabled:!0};const I=u.bind({});I.args={allowEmpty:!0,value:""};const p=()=>{const[a,r]=B.useState("123|m");return s.jsx(i,{name:"example",onChange:e=>r(e.target.value),placeholder:"Type a value...",value:a,testId:"testId"})};p.play=async({canvasElement:a,step:r})=>{const e=S(a),l=S(a.ownerDocument.body);await r("Shows validation error for non-numeric input",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123x45s6"),await t.click(a),await o(e.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Ae.mouseOver(n),await Se(()=>{o(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};const y=u.bind({});y.args={warning:"This input number is almost 100!",value:"99"};const C=u.bind({});C.args={error:"This is a error message"};const b=u.bind({});b.args={value:"123test"};const w=u.bind({});w.args={value:"123.123456789",enableDisplayRounding:!0};const T=u.bind({});T.args={value:"123.123456789",enableDisplayRounding:!0,roundDisplayValue:a=>De.roundToFixed(a,4)};const f=()=>s.jsxs(Ve,{small:!0,children:[s.jsx(i,{value:123}),s.jsx(Ne,{children:"to"}),s.jsx(i,{value:123}),s.jsx(Ee,{options:[{value:"units",label:"units"}],width:"auto",value:"units"})]}),c=()=>{const[a,r]=B.useState("123");return s.jsx(i,{value:a,onChange:e=>{r(e.target.value)},testId:"testId",enableDisplayRounding:!0})};c.play=async({canvasElement:a,step:r})=>{const e=S(a);await r("Value should be rounded on blur",async()=>{const l=e.getByTestId("testId");await t.clear(l),await t.type(l,"123.123456789"),await t.click(a),await o(e.getByDisplayValue("123.12")).toBeInTheDocument()}),await r("Full value shown on focus",async()=>{const l=e.getByTestId("testId");await t.click(l),await o(e.getByDisplayValue("123.123456789")).toBeInTheDocument()})};const A=()=>{const[a,r]=B.useState("123");return s.jsxs(xe,{columns:"1fr 1fr",gap:!0,children:[s.jsxs(x,{heading:s.jsx(_,{children:"Storage State (Redux)"}),children:[a,s.jsx(Be,{}),s.jsx(_e,{label:"Change value",onClick:()=>r(String(Math.floor(Math.random()*100)))})]}),s.jsx(x,{heading:s.jsx(_,{children:"NumberInput"}),children:s.jsx(i,{value:a,onChange:e=>{r(e.target.value)},error:Number(a)>=0?"":"Value must be positive"})})]})},d=()=>{const[a,r]=B.useState("123");return s.jsx(i,{value:a,onChange:e=>{r(e.target.value)},testId:"testId"})};d.play=async({canvasElement:a,step:r})=>{const e=S(a),l=S(a.ownerDocument.body);await r("Can enter decimal values",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123.123456789"),await t.click(a),await o(e.getByDisplayValue("123.123456789")).toBeInTheDocument()}),await r("Can enter scientific notation",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"-1.12e3"),await t.click(a),await o(e.getByDisplayValue("-1.12e3")).toBeInTheDocument()}),await r("Can enter comma decimals (converts to dot)",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123,456"),await t.click(a),await o(e.getByDisplayValue("123.456")).toBeInTheDocument()}),await r("Can enter small numbers",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"0.0000000023"),await t.click(a),await o(e.getByDisplayValue("0.0000000023")).toBeInTheDocument()}),await r("Can enter large numbers",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"999999999999"),await t.click(a),await o(e.getByDisplayValue("999999999999")).toBeInTheDocument()}),await r("Shows validation error for non-numeric input",async()=>{const n=e.getByTestId("testId");await t.clear(n),await t.type(n,"123x45s6"),await t.click(a),await o(e.getByDisplayValue("123x45s6")).toBeInTheDocument(),await Ae.mouseOver(n),await Se(()=>{o(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};p.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"Placeholder"};f.__docgenInfo={description:"",methods:[],displayName:"TestInputGroup"};c.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestDisplayRounding"};A.__docgenInfo={description:"",methods:[],displayName:"ManagedTestCase"};d.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"TestUserInput"};var N,E,V;D.parameters={...D.parameters,docs:{...(N=D.parameters)==null?void 0:N.docs,source:{originalSource:`args => {
2
2
  const [_, updateArgs] = useArgs();
3
3
  const handleChange = (evt: ChangeEvent<HTMLInputElement>) => {
4
4
  updateArgs({
@@ -1,4 +1,4 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as r}from"./index-BcNHZKhG.js";import{Z as t}from"./index-CZYm9n2f.js";import"./index-DhsZuJvc.js";import"./iframe-DKsrL1t6.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";function i(s){const n={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",strong:"strong",ul:"ul",...r(),...s.components};return e.jsxs(e.Fragment,{children:[e.jsx(t,{title:"Padding, Margin & Size"}),`
1
+ import{j as e}from"./jsx-runtime-eps93zm2.js";import{useMDXComponents as r}from"./index-BcNHZKhG.js";import{Z as t}from"./index-MQZw3-wz.js";import"./index-DhsZuJvc.js";import"./iframe-DOgYbEjR.js";import"../sb-preview/runtime.js";import"./index-CUZDtIZe.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-D6rZ4wEC.js";function i(s){const n={code:"code",h1:"h1",h2:"h2",li:"li",p:"p",strong:"strong",ul:"ul",...r(),...s.components};return e.jsxs(e.Fragment,{children:[e.jsx(t,{title:"Padding, Margin & Size"}),`
2
2
  `,e.jsx(n.h1,{id:"padding-margin--size",children:"Padding, Margin & Size"}),`
3
3
  `,e.jsx(n.h2,{id:"padding--margin",children:"Padding & Margin"}),`
4
4
  `,e.jsx(n.p,{children:"There are standard CSS spacing variables for padding and margin."}),`
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DocsRenderer-PKQXORMH-C4Y4AfWk.js","./chunk-HLWAVYOI-BMaNuZAP.js","./iframe-DKsrL1t6.js","./index-DhsZuJvc.js","./react-16-DXAfArL2.js","./index-CUZDtIZe.js","./index-CZYm9n2f.js","./extends-CF3RwP-h.js","./assertThisInitialized-B9jnkVVz.js","./inheritsLoose-DR8r8Ogv.js","./index-D6rZ4wEC.js"])))=>i.map(i=>d[i]);
2
- import{_ as a}from"./iframe-DKsrL1t6.js";import"../sb-preview/runtime.js";const{global:s}=__STORYBOOK_MODULE_GLOBAL__;var _=Object.entries(s.TAGS_OPTIONS??{}).reduce((e,r)=>{let[t,o]=r;return o.excludeFromDocsStories&&(e[t]=!0),e},{}),d={docs:{renderer:async()=>{let{DocsRenderer:e}=await a(()=>import("./DocsRenderer-PKQXORMH-C4Y4AfWk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url);return new e},stories:{filter:e=>{var r;return(e.tags||[]).filter(t=>_[t]).length===0&&!((r=e.parameters.docs)!=null&&r.disable)}}}};export{d as parameters};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DocsRenderer-PKQXORMH-C-VGLian.js","./chunk-HLWAVYOI-B-NqvPla.js","./iframe-DOgYbEjR.js","./index-DhsZuJvc.js","./react-16-DXAfArL2.js","./index-CUZDtIZe.js","./index-MQZw3-wz.js","./extends-CF3RwP-h.js","./assertThisInitialized-B9jnkVVz.js","./inheritsLoose-DR8r8Ogv.js","./index-D6rZ4wEC.js"])))=>i.map(i=>d[i]);
2
+ import{_ as a}from"./iframe-DOgYbEjR.js";import"../sb-preview/runtime.js";const{global:s}=__STORYBOOK_MODULE_GLOBAL__;var _=Object.entries(s.TAGS_OPTIONS??{}).reduce((e,r)=>{let[t,o]=r;return o.excludeFromDocsStories&&(e[t]=!0),e},{}),d={docs:{renderer:async()=>{let{DocsRenderer:e}=await a(()=>import("./DocsRenderer-PKQXORMH-C-VGLian.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]),import.meta.url);return new e},stories:{filter:e=>{var r;return(e.tags||[]).filter(t=>_[t]).length===0&&!((r=e.parameters.docs)!=null&&r.disable)}}}};export{d as parameters};
@@ -1,3 +1,3 @@
1
- import{j as s}from"./jsx-runtime-eps93zm2.js";import{r as P,R as C}from"./index-DhsZuJvc.js";import{T as I}from"./toaster-7wnI6hqB.js";import"./message-DQ3q8XF9.js";import{a4 as d,a5 as M}from"./index-CZYm9n2f.js";import{e as _}from"./index-DRSy5Ssd.js";import"./chunk-HLWAVYOI-BMaNuZAP.js";import"./index-CUZDtIZe.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./iframe-DKsrL1t6.js";import"../sb-preview/runtime.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./index-D6rZ4wEC.js";import"./react-16-DXAfArL2.js";var v="DARK_MODE";function f(r){"@babel/helpers - typeof";return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(r)}var b;function A(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),e.push.apply(e,n)}return e}function k(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?A(Object(e),!0).forEach(function(n){R(r,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):A(Object(e)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(e,n))})}return r}function R(r,t,e){return t=x(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function x(r){var t=K(r,"string");return f(t)==="symbol"?t:String(t)}function K(r,t){if(f(r)!=="object"||r===null)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t||"default");if(f(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function p(r){return B(r)||U(r)||L(r)||N()}function N(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{j as s}from"./jsx-runtime-eps93zm2.js";import{r as P,R as C}from"./index-DhsZuJvc.js";import{T as I}from"./toaster-7wnI6hqB.js";import"./message-DQ3q8XF9.js";import{a4 as d,a5 as M}from"./index-MQZw3-wz.js";import{e as _}from"./index-DRSy5Ssd.js";import"./chunk-HLWAVYOI-B-NqvPla.js";import"./index-CUZDtIZe.js";import"./index-Bk2sglWO.js";import"./common-types-Sih75Sav.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./iframe-DOgYbEjR.js";import"../sb-preview/runtime.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./index-D6rZ4wEC.js";import"./react-16-DXAfArL2.js";var v="DARK_MODE";function f(r){"@babel/helpers - typeof";return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(r)}var b;function A(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),e.push.apply(e,n)}return e}function k(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?A(Object(e),!0).forEach(function(n){R(r,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):A(Object(e)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(e,n))})}return r}function R(r,t,e){return t=x(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function x(r){var t=K(r,"string");return f(t)==="symbol"?t:String(t)}function K(r,t){if(f(r)!=="object"||r===null)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t||"default");if(f(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function p(r){return B(r)||U(r)||L(r)||N()}function N(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function L(r,t){if(r){if(typeof r=="string")return h(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);if(e==="Object"&&r.constructor&&(e=r.constructor.name),e==="Map"||e==="Set")return Array.from(r);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return h(r,t)}}function U(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function B(r){if(Array.isArray(r))return h(r)}function h(r,t){(t==null||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}const{global:Y}=__STORYBOOK_MODULE_GLOBAL__;__STORYBOOK_MODULE_CORE_EVENTS__;var T=Y,$=T.document,g=T.window,j="sb-addon-themes-3";(b=g.matchMedia)===null||b===void 0||b.call(g,"(prefers-color-scheme: dark)");var O={classTarget:"body",dark:d.dark,darkClass:["dark"],light:d.light,lightClass:["light"],stylePreview:!1,userHasExplicitlySetTheTheme:!1},E=function(t){g.localStorage.setItem(j,JSON.stringify(t))},H=function(t,e){var n=e.current,a=e.darkClass,l=a===void 0?O.darkClass:a,o=e.lightClass,i=o===void 0?O.lightClass:o;if(n==="dark"){var u,c;(u=t.classList).remove.apply(u,p(y(i))),(c=t.classList).add.apply(c,p(y(l)))}else{var m,S;(m=t.classList).remove.apply(m,p(y(l))),(S=t.classList).add.apply(S,p(y(i)))}},y=function(t){var e=[];return e.concat(t).map(function(n){return n})},V=function(t){var e=$.querySelector(t.classTarget);e&&H(e,t)},D=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=g.localStorage.getItem(j);if(typeof e=="string"){var n=JSON.parse(e);return t&&(t.dark&&!_(n.dark,t.dark)&&(n.dark=t.dark,E(n)),t.light&&!_(n.light,t.light)&&(n.light=t.light,E(n))),n}return k(k({},O),t)};V(D());function W(r,t){return F(r)||J(r,t)||G(r,t)||q()}function q(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function G(r,t){if(r){if(typeof r=="string")return w(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);if(e==="Object"&&r.constructor&&(e=r.constructor.name),e==="Map"||e==="Set")return Array.from(r);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return w(r,t)}}function w(r,t){(t==null||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function J(r,t){var e=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(e!=null){var n,a,l,o,i=[],u=!0,c=!1;try{if(l=(e=e.call(r)).next,t!==0)for(;!(u=(n=l.call(e)).done)&&(i.push(n.value),i.length!==t);u=!0);}catch(m){c=!0,a=m}finally{try{if(!u&&e.return!=null&&(o=e.return(),Object(o)!==o))return}finally{if(c)throw a}}return i}}function F(r){if(Array.isArray(r))return r}const{addons:z,useState:Q,useEffect:X}=__STORYBOOK_MODULE_PREVIEW_API__;function Z(){var r=Q(D().current==="dark"),t=W(r,2),e=t[0],n=t[1];return X(function(){var a=z.getChannel();return a.on(v,n),function(){return a.off(v,n)}},[]),e}const Sr=[r=>s.jsxs(s.Fragment,{children:[s.jsx(r,{}),s.jsx(I,{})]}),r=>{const t=Z();return P.useEffect(()=>document.documentElement.dataset.theme=t?"dark":"default",[t]),s.jsx(r,{})}],_r={docs:{container:r=>{const[t,e]=C.useState(!1);r.context.channel.on(v,a=>e(a));const n={...r};return n.theme=t?d.dark:d.light,s.jsx(M,{...n})}},darkMode:{current:"light",stylePreview:!0}},Ar=["autodocs"];export{Sr as decorators,_r as parameters,Ar as tags};
@@ -1,4 +1,4 @@
1
- import{j as o}from"./jsx-runtime-eps93zm2.js";import{r as D}from"./index-DhsZuJvc.js";import{T as g}from"./table-D1GJPQfF.js";import{T as z}from"./text-B3-TSWok.js";import{t as R,s as G,u as J,v as K,w as Q}from"./table.stories-data-CYppbCAy.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-NkLgQYoP.js";import"./help-icon-41R-Z9N1.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-DZ9ERbK_.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./flex-EllkLxgO.js";const Pe={title:"Basic/Table/Row",component:g,args:{table:{...R}}},v=n=>o.jsx(g,{...n}),i=v.bind({});i.args={table:G};const p=v.bind({});p.args={table:J};const c=v.bind({});c.args={table:K};const d=v.bind({});d.args={table:Q};const t=v.bind({});t.args={table:{...R,striped:!1}};t.parameters={docs:{description:{story:"`striped: false` removes tinted background on alternative rows."}}};const u=()=>{const[n,e]=D.useState(null),a=r=>e(n===r?null:r);return o.jsx(g,{table:{...R,striped:!1,rows:R.rows.map((r,x)=>({...r,onRowClick:()=>a(x),expandedContent:{content:n===x?o.jsx("div",{children:"Example expanded content"}):null}}))}})},m=()=>{const n={draggable:!0,headers:[{cells:[{value:"Name"},{value:"Weight (kg)"},{value:"Energy (kcal / 100g)"},{value:"Origin"}]}],rows:[{noDrag:!0,cells:[{value:"Undraggable"},{value:100},{value:361},{value:"Vietnam"}]},{cells:[{value:"Buckwheat"},{value:50},{value:358},{value:"Poland"}]},{cells:[{value:"Couscous"},{value:10},{value:368},{value:"France"}]}]},e=(s,b,l)=>{const y=[...s];return s[l].noDrag?s:(y.splice(l,0,y.splice(b,1)[0]),y)},[a,r]=D.useState(n.rows),x=s=>{const{to:b,from:l}=s;e(a,l,b),r(e(a,l,b))};return o.jsx(g,{table:{...n,rows:a},onListReorder:x})},w=()=>{const[n,e]=D.useState("Hover any row!"),a=[1,2,3,4,5].map(r=>({cells:[{value:`Row ${r}`},{value:`${r**2}`}],onRowMouseEnter:()=>e(`Hovering row ${r}`),onRowMouseLeave:()=>e("Not hovering any row...")}));return o.jsxs(o.Fragment,{children:[o.jsx(z,{children:n}),o.jsx(g,{table:{fixedWidth:"100%",headers:[{cells:[{value:"Description"},{value:"Value"}],onRowMouseEnter:()=>e("Hovering header row"),onRowMouseLeave:()=>e("Not hovering any row...")}],rows:a}})]})};u.__docgenInfo={description:"",methods:[],displayName:"Expandable"};m.__docgenInfo={description:"",methods:[],displayName:"DragAndDrop"};w.__docgenInfo={description:"",methods:[],displayName:"OnRowEnter"};var E,h,T;i.parameters={...i.parameters,docs:{...(E=i.parameters)==null?void 0:E.docs,source:{originalSource:`args => {
1
+ import{j as o}from"./jsx-runtime-eps93zm2.js";import{r as D}from"./index-DhsZuJvc.js";import{T as g}from"./table-DWBe_npR.js";import{T as z}from"./text-B3-TSWok.js";import{t as R,s as G,u as J,v as K,w as Q}from"./table.stories-data-CYppbCAy.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-NkLgQYoP.js";import"./help-icon-41R-Z9N1.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-C8O0lnql.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./flex-EllkLxgO.js";const Pe={title:"Basic/Table/Row",component:g,args:{table:{...R}}},v=n=>o.jsx(g,{...n}),i=v.bind({});i.args={table:G};const p=v.bind({});p.args={table:J};const c=v.bind({});c.args={table:K};const d=v.bind({});d.args={table:Q};const t=v.bind({});t.args={table:{...R,striped:!1}};t.parameters={docs:{description:{story:"`striped: false` removes tinted background on alternative rows."}}};const u=()=>{const[n,e]=D.useState(null),a=r=>e(n===r?null:r);return o.jsx(g,{table:{...R,striped:!1,rows:R.rows.map((r,x)=>({...r,onRowClick:()=>a(x),expandedContent:{content:n===x?o.jsx("div",{children:"Example expanded content"}):null}}))}})},m=()=>{const n={draggable:!0,headers:[{cells:[{value:"Name"},{value:"Weight (kg)"},{value:"Energy (kcal / 100g)"},{value:"Origin"}]}],rows:[{noDrag:!0,cells:[{value:"Undraggable"},{value:100},{value:361},{value:"Vietnam"}]},{cells:[{value:"Buckwheat"},{value:50},{value:358},{value:"Poland"}]},{cells:[{value:"Couscous"},{value:10},{value:368},{value:"France"}]}]},e=(s,b,l)=>{const y=[...s];return s[l].noDrag?s:(y.splice(l,0,y.splice(b,1)[0]),y)},[a,r]=D.useState(n.rows),x=s=>{const{to:b,from:l}=s;e(a,l,b),r(e(a,l,b))};return o.jsx(g,{table:{...n,rows:a},onListReorder:x})},w=()=>{const[n,e]=D.useState("Hover any row!"),a=[1,2,3,4,5].map(r=>({cells:[{value:`Row ${r}`},{value:`${r**2}`}],onRowMouseEnter:()=>e(`Hovering row ${r}`),onRowMouseLeave:()=>e("Not hovering any row...")}));return o.jsxs(o.Fragment,{children:[o.jsx(z,{children:n}),o.jsx(g,{table:{fixedWidth:"100%",headers:[{cells:[{value:"Description"},{value:"Value"}],onRowMouseEnter:()=>e("Hovering header row"),onRowMouseLeave:()=>e("Not hovering any row...")}],rows:a}})]})};u.__docgenInfo={description:"",methods:[],displayName:"Expandable"};m.__docgenInfo={description:"",methods:[],displayName:"DragAndDrop"};w.__docgenInfo={description:"",methods:[],displayName:"OnRowEnter"};var E,h,T;i.parameters={...i.parameters,docs:{...(E=i.parameters)==null?void 0:E.docs,source:{originalSource:`args => {
2
2
  return <Table
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
4
  {...args} />;
@@ -1,4 +1,4 @@
1
- import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-D2piFfFj.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Tr0wIZve.js";import{H as Oe}from"./heading-NkLgQYoP.js";import{P as $e}from"./pagination-bLx5-m9c.js";import{A as f,I as B}from"./common-types-Sih75Sav.js";import{I as Be}from"./input-DTXbDJaL.js";import{N as Me}from"./number-input-DZ9ERbK_.js";import{S as Ge}from"./select-BpALjE__.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-wCvXxtCz.js";import{S as ze}from"./slider-CBE03NwD.js";import{I as G}from"./icon-BP4BO6-k.js";import{P as Ke}from"./popover-9ZnEm5Hy.js";import{H as fe}from"./help-icon-41R-Z9N1.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_k0mvt_1",Ye="_error_k0mvt_7",Je="_warning_k0mvt_7",Qe="_inputHover_k0mvt_13",Ze="_inputFocus_k0mvt_18",en="_inputError_k0mvt_25",nn="_inputWarning_k0mvt_26",tn="_inputDisabled_k0mvt_61",rn="_hideScrollbars_k0mvt_67",an="_wrapper_k0mvt_85",on="_bordered_k0mvt_93",sn="_scroll_k0mvt_98",ln="_table_k0mvt_108",dn="_striped_k0mvt_188",L={inputInTable:Xe,error:Ye,warning:Je,inputHover:Qe,inputFocus:Ze,inputError:en,inputWarning:nn,inputDisabled:tn,hideScrollbars:rn,wrapper:an,bordered:on,scroll:sn,table:ln,striped:dn},un="_title_zn5s7_1",cn={title:un},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:o})=>{const a=e!==null,i=t!==null;if(!a&&!i)return null;const l=()=>{if(!i)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":o,children:e})}):null,l()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const mn="_footer_4sumy_1",pn="_section_4sumy_7",J={footer:mn,section:pn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,m;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((m=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:m.value);return u>I}return!1};return a||i||l()?n.jsxs("div",{className:J.footer,children:[i?n.jsx("div",{className:J.section,children:n.jsx("div",{children:o})}):null,a||l()?n.jsxs("div",{className:J.section,children:[l()?n.jsx($e,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,o)=>{const a=o.cells.map(i=>i.colSpan?i.colSpan:1).reduce((i,l)=>i+l,0);return r.concat(a)},[]));return isNaN(t)?0:t},gn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),In=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:o}=e,a=Math.ceil(window.innerHeight/30),[i,l]=o?S.useState(a):[r.length,null],[c,d]=o?S.useState(i<r.length):[!1,null],m=()=>{if(i>=r.length&&d){d(!1);return}l&&l(i+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:o?n.jsx(Le,{dataLength:Math.min(r.length,i+a),next:m,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:i})}):t({visibleRows:i})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const yn="_clickableRow_1ki29_1",Cn="_hoverableRow_1ki29_4",bn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",fn="_flush_1ki29_8",_n="_errorRow_1ki29_12",wn="_warningRow_1ki29_15",vn="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:yn,hoverableRow:Cn,rowActive:bn,expandableRow:hn,flush:fn,errorRow:_n,warningRow:wn,dragIconCell:vn,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(h.expandableRow,r?h.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:o,headerAlignment:a,isHeader:i}=e;switch(i&&a?a:o){case f.LEFT:return r?f.LEFT:t.leftAligned;case f.RIGHT:return r?f.RIGHT:t.rightAligned;case f.CENTER:return r?f.CENTER:t.centerAligned;default:return r?f.LEFT:t.leftAligned}},Tn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const o=e.every(i=>Array.isArray(i)),a=e.every(i=>typeof i=="string");return o&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},jn="_inputInTable_1rtjr_1",kn="_error_1rtjr_7",An="_warning_1rtjr_7",Rn="_inputHover_1rtjr_13",qn="_inputFocus_1rtjr_18",Nn="_inputError_1rtjr_25",Sn="_inputWarning_1rtjr_26",En="_inputDisabled_1rtjr_61",Hn="_hideScrollbars_1rtjr_67",Ln="_cell_1rtjr_77",Wn="_disabledLink_1rtjr_87",Fn="_inputWrapper_1rtjr_91",Pn="_breakWord_1rtjr_106",Dn="_inputCell_1rtjr_109",On="_sliderCell_1rtjr_112",$n="_staticCell_1rtjr_116",Bn="_staticCellContent_1rtjr_119",Mn="_unit_1rtjr_141",Gn="_sortingCell_1rtjr_144",Vn="_sortingCellIcon_1rtjr_155",Un="_icon_1rtjr_166",zn="_checkBoxCell_1rtjr_170",Kn="_iconCellWrapper_1rtjr_174",Xn="_actionsCell_1rtjr_178",Yn="_rightAligned_1rtjr_186",Jn="_centerAligned_1rtjr_192",Qn="_leftAligned_1rtjr_198",Zn="_popover_1rtjr_201",et="_disabledPointerEvents_1rtjr_204",s={inputInTable:jn,error:kn,warning:An,inputHover:Rn,inputFocus:qn,inputError:Nn,inputWarning:Sn,inputDisabled:En,hideScrollbars:Hn,cell:Ln,disabledLink:Wn,inputWrapper:Fn,breakWord:Pn,inputCell:Dn,sliderCell:On,staticCell:$n,staticCellContent:Bn,unit:Mn,sortingCell:Gn,sortingCellIcon:Vn,icon:Un,checkBoxCell:zn,iconCellWrapper:Kn,actionsCell:Xn,rightAligned:Yn,centerAligned:Jn,leftAligned:Qn,popover:Zn,disabledPointerEvents:et},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx(Be,{name:e.name,value:e.value,onChange:a=>{var i;return(i=e.onChange)==null?void 0:i.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var i;return(i=e.onPaste)==null?void 0:i.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:o});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var o;return(o=e.onChange)==null?void 0:o.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:o=>{var a;return(a=e.onChange)==null?void 0:a.call(e,o)},onCreate:e.onCreate?o=>e.onCreate&&e.onCreate(o):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:s.inputWrapper,children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});ve.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:o,warning:a,tooltip:i,maxTooltipWidth:l}=e,c=d=>M(d);return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:c(i)||c(o)||c(a)||!1,maxWidth:l,placement:"bottom-center",children:n.jsx("div",{className:T(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:T((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var m;d.stopPropagation(),(m=e.onClick)==null||m.call(e,d)},"data-testid":t,children:e.value})})})})};xe.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});Te.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const je=({cell:e})=>n.jsx("div",{className:s.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});je.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const ke=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:s.iconCellWrapper,children:n.jsx(oe,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};ke.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Ae=({cell:e})=>n.jsx(ae,{actions:e.actions});Ae.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const Re=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};Re.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:B.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}),o&&r?n.jsx("sup",{children:o}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const ie=({cell:e,isHeader:t,testId:r})=>{const{error:o,warning:a,tooltip:i,maxTooltipWidth:l,hasSort:c,onSort:d,type:m}=e,u=n.jsxs("div",{className:T(s.staticCellContent,m==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(Re,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:i&&M(i)||o&&M(o)||a&&M(a)||!1,maxWidth:l,display:"block",placement:"bottom-center",children:u})})};ie.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i}=e;return n.jsx(Ke,{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i,children:n.jsx("div",{className:s.popover,children:n.jsx(ie,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:o})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ve,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(xe,{cell:e,testId:o});case"CheckBox":return n.jsx(Te,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(ke,{cell:e});case"Actions":return n.jsx(Ae,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(ie,{cell:e,isHeader:t,testId:o})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var A=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(A||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:o=f.LEFT,width:a,snapshot:i,testId:l})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:m,width:u}=e,y=S.useRef(null),I={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(I,s),_=he(I,s,!0),F=e.type===A.INPUT||e.type===A.NUMBER_INPUT||e.type===A.SELECT||e.type===A.POPOVER?s.inputCell:e.type===A.SLIDER?s.sliderCell:e.type===A.CHECKBOX?s.checkBoxCell:e.type===A.ACTIONS?s.actionsCell:s.staticCell,j=T(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&y.current&&y.current.offsetWidth)??void 0,w={width:E,minWidth:E,...c},k=t?"th":"td";return n.jsx(k,{ref:y,className:j,style:w,colSpan:d,rowSpan:m,children:n.jsx(Ee,{cell:e,columnAlignment:_??f.RIGHT,isHeader:t,testId:l})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
1
+ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{c as T}from"./index-Bk2sglWO.js";import{I as Le,D as We,C as Fe,P as Pe}from"./index.es-D2piFfFj.js";import{l as De}from"./lodash-c4VUpsOs.js";import{A as ae}from"./actions-Tr0wIZve.js";import{H as Oe}from"./heading-NkLgQYoP.js";import{P as $e}from"./pagination-bLx5-m9c.js";import{A as f,I as B}from"./common-types-Sih75Sav.js";import{I as Be}from"./input-DTXbDJaL.js";import{N as Me}from"./number-input-C8O0lnql.js";import{S as Ge}from"./select-BpALjE__.js";import{D as Ve}from"./disabled-context-rmpd7YJS.js";import{i as M}from"./types-Dx2TtIG9.js";import{T as oe}from"./tooltip-1V7clEnw.js";import{C as Ue}from"./check-box-wCvXxtCz.js";import{S as ze}from"./slider-CBE03NwD.js";import{I as G}from"./icon-BP4BO6-k.js";import{P as Ke}from"./popover-9ZnEm5Hy.js";import{H as fe}from"./help-icon-41R-Z9N1.js";import{T as Y}from"./text-B3-TSWok.js";const Xe="_inputInTable_k0mvt_1",Ye="_error_k0mvt_7",Je="_warning_k0mvt_7",Qe="_inputHover_k0mvt_13",Ze="_inputFocus_k0mvt_18",en="_inputError_k0mvt_25",nn="_inputWarning_k0mvt_26",tn="_inputDisabled_k0mvt_61",rn="_hideScrollbars_k0mvt_67",an="_wrapper_k0mvt_85",on="_bordered_k0mvt_93",sn="_scroll_k0mvt_98",ln="_table_k0mvt_108",dn="_striped_k0mvt_188",L={inputInTable:Xe,error:Ye,warning:Je,inputHover:Qe,inputFocus:Ze,inputError:en,inputWarning:nn,inputDisabled:tn,hideScrollbars:rn,wrapper:an,bordered:on,scroll:sn,table:ln,striped:dn},un="_title_zn5s7_1",cn={title:un},Q=({name:e=null,actions:t=null,actionsRight:r=!1,testId:o})=>{const a=e!==null,i=t!==null;if(!a&&!i)return null;const l=()=>{if(!i)return null;const c=n.jsx(ae,{actions:t});return r?c:n.jsx("div",{children:c})};return n.jsxs("div",{className:cn.title,children:[a?n.jsx(Oe,{children:n.jsx("span",{"data-testid":o,children:e})}):null,l()]})};Q.__docgenInfo={description:"",methods:[],displayName:"Title",props:{name:{required:!1,tsType:{name:"union",raw:"TStringOrNumber | ReactNode",elements:[{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},{name:"ReactNode"}]},description:"",defaultValue:{value:"null",computed:!1}},actions:{required:!1,tsType:{name:"any"},description:"",defaultValue:{value:"null",computed:!1}},actionsRight:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},testId:{required:!1,tsType:{name:"string"},description:""}}};const mn="_footer_4sumy_1",pn="_section_4sumy_7",J={footer:mn,section:pn},Z=({colSpan:e,pagination:t,actions:r,content:o})=>{const a=r&&r.length,i=o!=null,l=()=>{var d,m;if(t){const{rowCount:u,rowsPerPage:y}=t,I=Number((m=(d=y==null?void 0:y.options)==null?void 0:d[0])==null?void 0:m.value);return u>I}return!1};return a||i||l()?n.jsxs("div",{className:J.footer,children:[i?n.jsx("div",{className:J.section,children:n.jsx("div",{children:o})}):null,a||l()?n.jsxs("div",{className:J.section,children:[l()?n.jsx($e,{pagination:t}):n.jsx("div",{}),a&&n.jsx("div",{children:n.jsx(ae,{actions:r})})]}):null]}):null};Z.__docgenInfo={description:"",methods:[],displayName:"Footer",props:{colSpan:{required:!1,tsType:{name:"number"},description:""},pagination:{required:!0,tsType:{name:"IPagination"},description:""},actions:{required:!1,tsType:{name:"Array",elements:[{name:"IAction"}],raw:"IAction[]"},description:""},content:{required:!1,tsType:{name:"ReactNode"},description:""}}};const Ce=e=>{const t=Math.max(...e.reduce((r,o)=>{const a=o.cells.map(i=>i.colSpan?i.colSpan:1).reduce((i,l)=>i+l,0);return r.concat(a)},[]));return isNaN(t)?0:t},gn=(e,t)=>{const r=[Ce(t),Ce(e)];return Math.max(...r)},be=e=>e.reduce((t,r)=>r.actions&&r.actions.length>0?1:t,0),In=(e,t)=>be(t)>0||be(e)>0,ee=({table:e,children:t})=>{const{rows:r,infiniteScroll:o}=e,a=Math.ceil(window.innerHeight/30),[i,l]=o?S.useState(a):[r.length,null],[c,d]=o?S.useState(i<r.length):[!1,null],m=()=>{if(i>=r.length&&d){d(!1);return}l&&l(i+a)};return n.jsx("div",{id:"scrollWrapper",className:L.scroll,children:o?n.jsx(Le,{dataLength:Math.min(r.length,i+a),next:m,hasMore:c,scrollableTarget:"scrollWrapper",style:{overflow:"initial"},loader:null,children:t({visibleRows:i})}):t({visibleRows:i})})};ee.__docgenInfo={description:"",methods:[],displayName:"TableScrollWrapper",props:{table:{required:!0,tsType:{name:"ITableProps"},description:""},children:{required:!0,tsType:{name:"signature",type:"function",raw:"(props: { visibleRows: number }) => ReactNode",signature:{arguments:[{type:{name:"signature",type:"object",raw:"{ visibleRows: number }",signature:{properties:[{key:"visibleRows",value:{name:"number",required:!0}}]}},name:"props"}],return:{name:"ReactNode"}}},description:""}}};const yn="_clickableRow_1ki29_1",Cn="_hoverableRow_1ki29_4",bn="_rowActive_1ki29_4",hn="_expandableRow_1ki29_8",fn="_flush_1ki29_8",_n="_errorRow_1ki29_12",wn="_warningRow_1ki29_15",vn="_dragIconCell_1ki29_34",xn="_dragIcon_1ki29_34",h={clickableRow:yn,hoverableRow:Cn,rowActive:bn,expandableRow:hn,flush:fn,errorRow:_n,warningRow:wn,dragIconCell:vn,dragIcon:xn},ne=({colSpan:e,children:t,flush:r})=>n.jsx("tr",{children:n.jsx("td",{colSpan:e,className:T(h.expandableRow,r?h.flush:""),children:t})});ne.__docgenInfo={description:"",methods:[],displayName:"ExpandedContentRow",props:{colSpan:{required:!0,tsType:{name:"number"},description:""},children:{required:!0,tsType:{name:"ReactNode"},description:""},flush:{required:!1,tsType:{name:"boolean"},description:""}}};const he=(e,t={leftAligned:"",rightAligned:"",centerAligned:""},r=!1)=>{if(!e)return null;const{bodyAlignment:o,headerAlignment:a,isHeader:i}=e;switch(i&&a?a:o){case f.LEFT:return r?f.LEFT:t.leftAligned;case f.RIGHT:return r?f.RIGHT:t.rightAligned;case f.CENTER:return r?f.CENTER:t.centerAligned;default:return r?f.LEFT:t.leftAligned}},Tn=(e,t=!1,r=0)=>{if(!e||e.length===0)return[];const o=e.every(i=>Array.isArray(i)),a=e.every(i=>typeof i=="string");return o&&t?e[r]||[]:a?e:(console.warn("getHeaderAlignment: alignments array contains a mix of strings and arrays, returning an empty array."),[])},jn="_inputInTable_1rtjr_1",kn="_error_1rtjr_7",An="_warning_1rtjr_7",Rn="_inputHover_1rtjr_13",qn="_inputFocus_1rtjr_18",Nn="_inputError_1rtjr_25",Sn="_inputWarning_1rtjr_26",En="_inputDisabled_1rtjr_61",Hn="_hideScrollbars_1rtjr_67",Ln="_cell_1rtjr_77",Wn="_disabledLink_1rtjr_87",Fn="_inputWrapper_1rtjr_91",Pn="_breakWord_1rtjr_106",Dn="_inputCell_1rtjr_109",On="_sliderCell_1rtjr_112",$n="_staticCell_1rtjr_116",Bn="_staticCellContent_1rtjr_119",Mn="_unit_1rtjr_141",Gn="_sortingCell_1rtjr_144",Vn="_sortingCellIcon_1rtjr_155",Un="_icon_1rtjr_166",zn="_checkBoxCell_1rtjr_170",Kn="_iconCellWrapper_1rtjr_174",Xn="_actionsCell_1rtjr_178",Yn="_rightAligned_1rtjr_186",Jn="_centerAligned_1rtjr_192",Qn="_leftAligned_1rtjr_198",Zn="_popover_1rtjr_201",et="_disabledPointerEvents_1rtjr_204",s={inputInTable:jn,error:kn,warning:An,inputHover:Rn,inputFocus:qn,inputError:Nn,inputWarning:Sn,inputDisabled:En,hideScrollbars:Hn,cell:Ln,disabledLink:Wn,inputWrapper:Fn,breakWord:Pn,inputCell:Dn,sliderCell:On,staticCell:$n,staticCellContent:Bn,unit:Mn,sortingCell:Gn,sortingCellIcon:Vn,icon:Un,checkBoxCell:zn,iconCellWrapper:Kn,actionsCell:Xn,rightAligned:Yn,centerAligned:Jn,leftAligned:Qn,popover:Zn,disabledPointerEvents:et},te=({cell:e,columnAlignment:t,testId:r,type:o})=>n.jsx(Be,{name:e.name,value:e.value,onChange:a=>{var i;return(i=e.onChange)==null?void 0:i.call(e,a)},onFocus:e.onFocus,onBlur:e.onBlur,onPaste:a=>{var i;return(i=e.onPaste)==null?void 0:i.call(e,a)},placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,maxTooltipWidth:e.maxTooltipWidth,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0,tooltip:e.tooltip,type:o});te.__docgenInfo={description:"",methods:[],displayName:"InputCell",props:{cell:{required:!0,tsType:{name:"IInputCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""},type:{required:!1,tsType:{name:"union",raw:"'text' | 'date'",elements:[{name:"literal",value:"'text'"},{name:"literal",value:"'date'"}]},description:""}}};const _e=({cell:e,testId:t})=>n.jsx(Me,{name:e.name,value:e.value,onChange:r=>{var o;return(o=e.onChange)==null?void 0:o.call(e,r)},onFocus:e.onFocus,onBlur:e.onBlur,placeholder:e.placeholder,error:e.error,warning:e.warning,disabled:e.disabled,isInTable:!0,left:e.left,tabIndex:e.disabled?-1:0,testId:t,tooltip:e.tooltip,validationCallback:e.validationCallback,allowEmpty:e.allowEmpty,enableDisplayRounding:e.enableDisplayRounding,roundDisplayValue:e.roundDisplayValue});_e.__docgenInfo={description:"",methods:[],displayName:"NumberInputCell",props:{cell:{required:!0,tsType:{name:"INumberInputCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const we=({cell:e,columnAlignment:t,testId:r})=>n.jsx(Ge,{name:e.name,borderRadius:0,options:e.options,onChange:o=>{var a;return(a=e.onChange)==null?void 0:a.call(e,o)},onCreate:e.onCreate?o=>e.onCreate&&e.onCreate(o):void 0,error:e.error,warning:e.warning,disabled:e.disabled,placeholder:e.placeholder,isInTable:!0,value:e.value,native:e.native,clearable:e.clearable,searchable:e.searchable,deprecatedEventHandler:e.deprecatedEventHandler,maxTooltipWidth:e.maxTooltipWidth,width:"100%",autoLayerWidth:e.autoLayerWidth,multi:e.multi,right:t===f.RIGHT,testId:r,tabIndex:e.disabled?-1:0});we.__docgenInfo={description:"",methods:[],displayName:"SelectCell",props:{cell:{required:!0,tsType:{name:"ISelectCell"},description:""},columnAlignment:{required:!1,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const ve=({cell:e,columnAlignment:t,testId:r})=>n.jsx("div",{className:s.inputWrapper,children:e.type==="Input"?n.jsx(te,{cell:e,columnAlignment:t,testId:r}):e.type==="NumberInput"?n.jsx(_e,{cell:e,testId:r}):e.type==="DateInput"?n.jsx(te,{cell:e,testId:r,type:"date"}):e.type==="Select"?n.jsx(we,{cell:e,columnAlignment:t,testId:r}):null});ve.__docgenInfo={description:"",methods:[],displayName:"InputCellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const xe=({cell:e,testId:t})=>{const r=S.useContext(Ve),{error:o,warning:a,tooltip:i,maxTooltipWidth:l}=e,c=d=>M(d);return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:c(i)||c(o)||c(a)||!1,maxWidth:l,placement:"bottom-center",children:n.jsx("div",{className:T(s.staticCellContent,o?s.error:a?s.warning:""),children:n.jsx("a",{className:T((e.disabled||r)&&s.disabledLink),onClick:e.disabled||r?void 0:d=>{var m;d.stopPropagation(),(m=e.onClick)==null||m.call(e,d)},"data-testid":t,children:e.value})})})})};xe.__docgenInfo={description:"",methods:[],displayName:"LinkCell",props:{cell:{required:!0,tsType:{name:"ILinkCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Te=({cell:e,testId:t})=>n.jsx(Ue,{label:e.label,checked:e.checked,isInTable:!0,disabled:e.disabled,onChange:r=>e.onChange(r),testId:t,tabIndex:e.disabled?-1:0});Te.__docgenInfo={description:"",methods:[],displayName:"CheckBoxCell",props:{cell:{required:!0,tsType:{name:"ICheckBoxCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const je=({cell:e})=>n.jsx("div",{className:s.inputWrapper,children:n.jsx(ze,{label:e.label,value:e.value,min:e.min,max:e.max,step:e.step,marks:e.marks,onChange:t=>e.onChange(t),showArrows:e.showArrows,showTooltip:e.showTooltip,tooltipFormatter:e.tooltipFormatter,disabled:e.disabled})});je.__docgenInfo={description:"",methods:[],displayName:"SliderCell",props:{cell:{required:!0,tsType:{name:"ISliderCell"},description:""}}};const ke=({cell:e})=>{const{tooltip:t,icon:r}=e;return n.jsx("div",{className:s.iconCellWrapper,children:n.jsx(oe,{text:t,enabled:!!t&&M(t),display:"flex",placement:"top-center",children:n.jsx(G,{icon:r})})})};ke.__docgenInfo={description:"",methods:[],displayName:"IconCell",props:{cell:{required:!0,tsType:{name:"IIconCell"},description:""}}};const Ae=({cell:e})=>n.jsx(ae,{actions:e.actions});Ae.__docgenInfo={description:"",methods:[],displayName:"ActionsCell",props:{cell:{required:!0,tsType:{name:"IActionCell"},description:""}}};const Re=({cell:e})=>{const{helpIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip})}):null};Re.__docgenInfo={description:"",methods:[],displayName:"CellHelpIcon",props:{cell:{required:!0,tsType:{name:"IHelpIconCell"},description:""}}};const qe=({cell:e})=>{const{libraryIcon:t}=e;return t?n.jsx("div",{className:s.icon,children:n.jsx(fe,{onClick:t.onClick,text:t.tooltip,icon:B.LIBRARY})}):null};qe.__docgenInfo={description:"",methods:[],displayName:"CellLibraryIcon",props:{cell:{required:!0,tsType:{name:"ILibraryIconCell"},description:""}}};const Ne=({cell:e})=>{const{hasSort:t,sort:r,sortPriority:o}=e;return t?n.jsxs("span",{className:s.sortingCellIcon,children:[r==="down"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_ASCENDING})}):r==="up"?n.jsx(Y,{link:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}):n.jsx(Y,{faint:!0,children:n.jsx(G,{icon:B.SORT_DESCENDING})}),o&&r?n.jsx("sup",{children:o}):null]}):null};Ne.__docgenInfo={description:"",methods:[],displayName:"Sort",props:{cell:{required:!0,tsType:{name:"ISortCell"},description:""}}};const ie=({cell:e,isHeader:t,testId:r})=>{const{error:o,warning:a,tooltip:i,maxTooltipWidth:l,hasSort:c,onSort:d,type:m}=e,u=n.jsxs("div",{className:T(s.staticCellContent,m==="Unit"?s.unit:"",o?s.error:a?s.warning:""),onClick:c?y=>d&&d(y):()=>{},"data-testid":r,children:[e.value,t?n.jsxs(n.Fragment,{children:[n.jsx(Re,{cell:e}),n.jsx(qe,{cell:e}),n.jsx(Ne,{cell:e})]}):null]});return n.jsx("div",{className:s.inputWrapper,children:n.jsx(oe,{error:!!o,warning:!!a,text:i||o||a,enabled:i&&M(i)||o&&M(o)||a&&M(a)||!1,maxWidth:l,display:"block",placement:"bottom-center",children:u})})};ie.__docgenInfo={description:"",methods:[],displayName:"StaticCell",props:{cell:{required:!0,tsType:{name:"IStaticCell"},description:""},isHeader:{required:!1,tsType:{name:"boolean"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Se=({cell:e,testId:t})=>{const{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i}=e;return n.jsx(Ke,{content:r,fullWidth:o,closeOnOutsideClick:a,disabled:i,children:n.jsx("div",{className:s.popover,children:n.jsx(ie,{cell:e,testId:t})})})};Se.__docgenInfo={description:"",methods:[],displayName:"PopoverCell",props:{cell:{required:!0,tsType:{name:"IPopoverCell"},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};const Ee=({cell:e,isHeader:t,columnAlignment:r,testId:o})=>{if(!e)return null;switch(e.type){case"Input":case"NumberInput":case"DateInput":case"Select":return n.jsx(ve,{cell:e,columnAlignment:r,testId:o});case"Link":return n.jsx(xe,{cell:e,testId:o});case"CheckBox":return n.jsx(Te,{cell:e,testId:o});case"Slider":return n.jsx(je,{cell:e});case"Icon":return n.jsx(ke,{cell:e});case"Actions":return n.jsx(Ae,{cell:e});case"Popover":return n.jsx(Se,{cell:e});default:return n.jsx(ie,{cell:e,isHeader:t,testId:o})}};Ee.__docgenInfo={description:"",methods:[],displayName:"CellWrapper",props:{cell:{required:!0,tsType:{name:"any"},description:""},isHeader:{required:!0,tsType:{name:"boolean"},description:""},columnAlignment:{required:!0,tsType:{name:"union",raw:"Align.LEFT | Align.RIGHT | string",elements:[{name:"Align.LEFT"},{name:"Align.RIGHT"},{name:"string"}]},description:""},testId:{required:!1,tsType:{name:"string"},description:""}}};var A=(e=>(e.INPUT="Input",e.NUMBER_INPUT="NumberInput",e.SELECT="Select",e.POPOVER="Popover",e.SLIDER="Slider",e.CHECKBOX="CheckBox",e.ACTIONS="Actions",e.AUTO_UNIT="AutoUnit",e))(A||{});const re=({cell:e,isHeader:t,columnHeaderAlignment:r,columnAlignment:o=f.LEFT,width:a,snapshot:i,testId:l})=>{if(!e)return null;const{style:c,colSpan:d,rowSpan:m,width:u}=e,y=S.useRef(null),I={bodyAlignment:o,headerAlignment:r,isHeader:t},W=he(I,s),_=he(I,s,!0),F=e.type===A.INPUT||e.type===A.NUMBER_INPUT||e.type===A.SELECT||e.type===A.POPOVER?s.inputCell:e.type===A.SLIDER?s.sliderCell:e.type===A.CHECKBOX?s.checkBoxCell:e.type===A.ACTIONS?s.actionsCell:s.staticCell,j=T(s.cell,F,e.hasSort?s.sortingCell:null,W,e.breakWord?s.breakWord:""),E=u??a??((i==null?void 0:i.isDragging)&&y.current&&y.current.offsetWidth)??void 0,w={width:E,minWidth:E,...c},k=t?"th":"td";return n.jsx(k,{ref:y,className:j,style:w,colSpan:d,rowSpan:m,children:n.jsx(Ee,{cell:e,columnAlignment:_??f.RIGHT,isHeader:t,testId:l})})};re.__docgenInfo={description:"",methods:[],displayName:"Cell",props:{cell:{required:!1,tsType:{name:"union",raw:`| IPopoverCell
2
2
  | IStaticCell
3
3
  | ISelectCell
4
4
  | IHelpIconCell
@@ -1,4 +1,4 @@
1
- import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-D1GJPQfF.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-DTXbDJaL.js";import{F as oe}from"./field-C5_fLDpy.js";import{H as un}from"./heading-NkLgQYoP.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-CYppbCAy.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-DZ9ERbK_.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./help-icon-41R-Z9N1.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./label-hiSz3I8H.js";import"./flex-EllkLxgO.js";const wt={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
1
+ import{j as n}from"./jsx-runtime-eps93zm2.js";import{r as S}from"./index-DhsZuJvc.js";import{f as ne}from"./immer.esm-BwVl9PS2.js";import{l as Z}from"./lodash-c4VUpsOs.js";import{G as le}from"./grid-DRkC-bt8.js";import{T as W}from"./text-B3-TSWok.js";import{T as D}from"./table-DWBe_npR.js";import{C as dn}from"./card-EcjmryU9.js";import{I as se}from"./input-DTXbDJaL.js";import{F as oe}from"./field-C5_fLDpy.js";import{H as un}from"./heading-NkLgQYoP.js";import{t as ae,x as pn,y as mn,z as gn,A as bn,B as hn,C as wn,D as yn}from"./table.stories-data-CYppbCAy.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-C8O0lnql.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./help-icon-41R-Z9N1.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./label-hiSz3I8H.js";import"./flex-EllkLxgO.js";const wt={title:"Basic/Table",component:D,args:{table:{...ae}}},A=h=>n.jsx(D,{...h}),te=A.bind({}),E=A.bind({});E.args={table:{...ae,fixedWidth:"400px"}};const L=A.bind({});L.args={table:{...ae,fixedWidth:"auto"}};const _=A.bind({});_.args={table:pn};_.parameters={docs:{description:{story:"Use sparingly when certain columns cannot be below a certain width. Unless the Table is auto width, set one column to `auto` to use remaining space."}}};const Q=A.bind({});Q.args={table:mn};const O=A.bind({});O.args={table:gn};O.parameters={docs:{description:{story:"This is only required when you need to override `columnAlignment` in header cells (i.e. they have different alignment)"}}};const G=A.bind({});G.args={table:bn};const N=A.bind({});N.args={table:hn};N.decorators=[h=>n.jsx("div",{style:{position:"absolute",inset:0,padding:"var(--padding)"},children:n.jsx(h,{})})];const U=A.bind({});U.args={table:wn};U.parameters={docs:{description:{story:"If a `maxHeight` is set, the table should only fill that height if it needs to."}}};const $=A.bind({});$.args={table:yn};const M=()=>n.jsx(dn,{heading:n.jsx(un,{children:"Card heading"}),padding:!1,children:n.jsx(D,{table:{...ae,bordered:!1}})});M.parameters={docs:{source:{type:"dynamic"}}};const q=()=>{const h=["Section","Width","Height"];let g=["","m","m"],o=[...Array(175).keys()].map((l,t)=>[t,t*2,t*2]);const x=(l,t,r)=>l==="m"&&t==="ft"?r*3.28084:l==="ft"&&t==="m"?r/3.28084:r,i=(l,t,r,c)=>{o[t][r]=l.target.value,c()},R=l=>{o=o.concat([["","",""]]),l()},k=(l,t)=>{o=o.filter((r,c)=>c!==l),t()},p=(l,t,r)=>{const c=g[t],b=l.target.value;g=g.map((y,s)=>s===t?b:y),o=o.map(y=>y.map((s,u)=>u===t?x(c,b,s):s)),r()},w=()=>{const l=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[t,r]=S.useState(10),[c,b]=S.useState(1),[y,s]=S.useState(!1),u=()=>{s(!y)},j=()=>{const e=Math.ceil(o.length/t);b(e)},T=(c-1)*t,a=t===0?o.length-1:T+t,m={headers:[{cells:h.map(e=>({value:e})),actions:[{primary:!0,label:"Add",icon:"add",onClick:()=>{R(u),j()}}]},{cells:[{},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[1],type:"Select",native:!0,onChange:e=>p(e,1,u)},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:g[2],type:"Select",native:!0,onChange:e=>p(e,2,u)}]}],rows:o.slice(T,a).map((e,d)=>{const I=T+d;return{cells:[...Array(3).keys()].map((P,v)=>({value:e[v],type:"Input",onChange:C=>i(C,I,v,u)})),actions:[{label:"Delete",icon:"minus",onClick:()=>k(I,u)}]}}),footer:{pagination:{rowCount:o.length,selectedPage:c,rowsPerPage:{onChange:e=>{const{value:d}=e.target;r(Number(d))},options:l,value:t},onSelectPage:e=>b(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(w,{})},K=()=>{const h=["Section","Width","Height"];let g=[...Array(20).keys()].map((x,i)=>({Section:Z.random(0,100),Width:Z.random(0,100),Height:Z.random(0,100)}));const o=()=>{const[x,i]=S.useState({Section:"up"}),R=(r,c)=>r.sort((b,y)=>Object.entries(c).map(([s,u])=>{switch(u){case"up":return b[s]-y[s];case"down":return y[s]-b[s];default:return 0}}).reduce((s,u)=>s||u,0)),k=(r,c,b)=>({dataSortCells:r.map(s=>{const u=Object.keys(c).includes(s)?c[s]:"",j=`${s[0].toUpperCase()}${s.slice(1)}`;return{key:s,value:j,hasSort:!0,sort:u,onSort:()=>{const T=u==="up"?"down":"up";b({[s]:T})}}})}),{dataSortCells:p}=k(h,x,i),l=[...R(g,x).map(r=>({cells:Object.entries(r).map(([b,y])=>({key:b,value:y,type:"Input",disabled:!0}))}))],t={headers:[{cells:p}],rows:l};return n.jsx(D,{table:t})};return n.jsx(o,{})},B=()=>{const h=["Section","Width","Height"];let g=[...Array(175).keys()].map((x,i)=>({Section:i,Width:i*2,Height:i*2}));const o=()=>{const x=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[i,R]=S.useState(10),[k,p]=S.useState(1),[w,l]=S.useState({}),[t,r]=S.useState({});S.useEffect(()=>{p(1)},[w,t]);const c=(k-1)*i,b=i===0?g.length-1:c+i,y=(e,d,I)=>e.filter(P=>Object.keys(d).every(v=>d[v]===""?!0:P[v].toString().includes(d[v]))).sort((P,v)=>Object.entries(I).map(([C,H])=>{switch(H){case"up":return P[C]-v[C];case"down":return v[C]-P[C];default:return 0}}).reduce((C,H)=>C||H,0)),s=(e,d,I,P,v)=>{const C=e.map(f=>{const V=Object.keys(P).includes(f)?P[f]:"",F=`${f[0].toUpperCase()}${f.slice(1)}`;return{key:f,value:F,hasSort:!0,sort:V,onSort:()=>{const ee=V===""?"up":V==="up"?"down":"";v({...P,[f]:ee})}}}),H=e.map(f=>{const V=Object.keys(d).includes(f)?d[f]:"";return{key:f,value:V,type:"Input",placeholder:"Filter",onChange:F=>I({...d,[f]:F.target.value})}});return{dataSortCells:C,dataFilterCells:H}},{dataSortCells:u,dataFilterCells:j}=s(h,w,l,t,r),T=y(g,w,t),a=[...T.slice(c,b).map(e=>({cells:Object.entries(e).map(([I,P])=>({key:I,value:P,type:"Input",disabled:!0}))}))],m={headers:[{cells:u},{cells:j}],rows:a,footer:{pagination:{rowCount:T.length,selectedPage:k,rowsPerPage:{onChange:e=>{const{value:d}=e.target;R(Number(d))},options:x,value:i},onSelectPage:e=>p(e),small:!0}}};return n.jsx(D,{table:m})};return n.jsx(o,{})},z=()=>{const h={tea:3.6,coffee:3.2,orange:4.1},g=[{label:"Tea",value:"tea"},{label:"Coffee",value:"coffee"},{label:"Orange juice",value:"orange"}],o={cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input"},{type:"Static"}]},x=[...Array(15).keys()].map((a,m)=>({cells:[{type:"Select",options:g,value:{value:"tea"}},{type:"Input",value:m+1},{type:"Static"}]})),[i,R]=S.useState(x),k=[{label:"10 / page",value:10},{label:"20 / page",value:20},{label:"50 / page",value:50},{label:"Show all",value:0}],[p,w]=S.useState(10),[l,t]=S.useState(1),r=(l-1)*p,c=p===0?i.length-1:r+p,b=({newRow:a}={})=>{const m=ne(i,e=>{e.push(a??o)});R(m)},y=({rowIndex:a})=>{const m=ne(i,e=>{delete e[a]}).filter(e=>e);R(m)},s=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[0].value.value=m});R(e)},u=({rowIndex:a,value:m})=>{const e=ne(i,d=>{d[a].cells[1].value=m});R(e)},j=({value:a})=>{const m=Number(a);return!Z.isNaN(m)&&Z.isInteger(m)&&m>0},T=i.slice(r,c).map((a,m)=>{const e=r+m;return i.length-1,{...a,cells:a==null?void 0:a.cells.map((d,I)=>{var f,V,F,ee,ie;const P=(F=(V=(f=a==null?void 0:a.cells)==null?void 0:f[0])==null?void 0:V.value)==null?void 0:F.value,v=Number((ie=(ee=a==null?void 0:a.cells)==null?void 0:ee[1])==null?void 0:ie.value),C=h==null?void 0:h[P],H=C&&j({value:v})?(C*v).toFixed(2):null;if(I===0)return{...d,onChange:re=>s({rowIndex:e,value:re.target.value})};if(I===1)return{...d,onChange:re=>u({rowIndex:e,value:re.target.value}),error:j({value:d.value})?null:"Must be valid whole number"};if(I===2)return{...d,value:H}}),actions:[{label:"Delete",icon:"minus",onClick:()=>y({rowIndex:e})}]}});return n.jsx(D,{table:{defaultEmptyRow:o,onAddRow:b,columnAlignment:["left","right","right"],headers:[{cells:[{value:"Drink"},{value:"Quantity"},{value:"Total Price (£)"}],actions:[{primary:!0,icon:"plus",label:"Add",onClick:()=>b()}]}],rows:T,footer:{pagination:{rowCount:i.length,selectedPage:l,rowsPerPage:{onChange:a=>{const{value:m}=a.target;w(Number(m))},options:k,value:p},onSelectPage:a=>t(a),small:!0}}}})},J=()=>{const h=["Section","Width","Height"];let g=Array.from(Array(10),(p,w)=>[w,w*2,w*2]);const[o,x]=S.useState({pastedValues:"",rowIndex:0,cellIndex:0}),i=(p,w,l,t)=>{g[w][l]=Number(p.target.value),t()},R=(p,w,l,t)=>{var c;let r=((c=p==null?void 0:p.clipboardData)==null?void 0:c.getData("text"))??"";return x({rowIndex:w,cellIndex:l,pastedValues:r}),t(),{pastedData:o}},k=()=>{const[p,w]=S.useState(!1),l=()=>{w(!p)},t={headers:[{cells:h.map(r=>({value:r}))}],rows:g.map((r,c)=>{const b=c;return{cells:[...Array(3).keys()].map((y,s)=>({value:r[s],type:"Input",onChange:u=>i(u,b,s,l),onPaste:u=>R(u,b,s,l)}))}})};return n.jsxs(n.Fragment,{children:[n.jsx(D,{table:t}),n.jsx(oe,{label:"Pasted Data",children:n.jsx(se,{value:o.pastedValues})}),n.jsx(oe,{label:"At Row",children:n.jsx(se,{value:o.rowIndex})}),n.jsx(oe,{label:"At Cell Index",children:n.jsx(se,{value:o.cellIndex})})]})};return n.jsx(k,{})},X=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],columnAlignment:[...Array(10)].map((g,o)=>"right"),headers:[{cells:[...Array(10)].map((g,o)=>({value:"Heading"}))},{cells:[...Array(10)].map((g,o)=>({options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],type:"Select",searchable:!1,value:{label:"m",value:"m"},autoLayerWidth:!0}))}],rows:[...Array(10)].map((g,o)=>({cells:[...Array(10)].map((x,i)=>({value:123.45})),actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here lorem ipsum"}),n.jsx(W,{children:"Label: 123.45m"}),n.jsx(W,{children:"Another label: 123.45m"}),n.jsx(W,{children:"Label: 123.45m"})]})}]}))};return n.jsx(D,{table:h})},Y=()=>{const h={fixedWidth:"auto",name:"Table title",actions:[{icon:"download",tooltip:"Download"}],headers:[{cells:[{value:"Label"},{value:"Value",colSpan:2}]}],rows:[{cells:[{value:"Country",style:{fontWeight:"bold"},width:"120px"},{value:"Norway",colSpan:2}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]},{cells:[{value:"Depth",style:{fontWeight:"bold"}},{value:123,width:"80px"},{options:[{label:"m",value:"m"},{label:"ft",value:"ft"}],value:{label:"m",value:"m"},type:"Select",width:"80px"}],actions:[{icon:"help",tooltip:n.jsxs(le,{children:[n.jsx(W,{bold:!0,children:"Title goes here"}),n.jsx(W,{children:"Details go here"})]})}]}]};return n.jsx(D,{table:h})};M.__docgenInfo={description:"",methods:[],displayName:"InCard"};q.__docgenInfo={description:"",methods:[],displayName:"Managed"};K.__docgenInfo={description:"",methods:[],displayName:"ManagedWithSort"};B.__docgenInfo={description:"",methods:[],displayName:"ManagedWithFilterAndMultipleSort"};z.__docgenInfo={description:"",methods:[],displayName:"AutoAddNewRow"};J.__docgenInfo={description:"",methods:[],displayName:"OnPasteCallback"};X.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInfoTooltips"};Y.__docgenInfo={description:"",methods:[],displayName:"ExampleTableWithInlineUnits"};var ce,de,ue;te.parameters={...te.parameters,docs:{...(ce=te.parameters)==null?void 0:ce.docs,source:{originalSource:`args => {
2
2
  return <Table
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
4
  {...args} />;
@@ -1,4 +1,4 @@
1
- import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-D1GJPQfF.js";import{t as K,E as O,s as W,F as k,G as q,H as z,I as D,J as M,K as P,L as Q}from"./table.stories-data-CYppbCAy.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-NkLgQYoP.js";import"./help-icon-41R-Z9N1.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-DZ9ERbK_.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./flex-EllkLxgO.js";const Wr={title:"Basic/Table/Title & Header",component:X,args:{table:{...K}}},r=B=>G.jsx(X,{...B}),e=r.bind({});e.args={table:O};const s=r.bind({});s.args={table:W};const a=r.bind({});a.args={table:k};const t=r.bind({});t.args={table:q};const o=r.bind({});o.args={table:z};const n=r.bind({});n.args={table:D};const i=r.bind({});i.args={table:M};const p=r.bind({});p.args={table:P};const m=r.bind({});m.args={table:Q};var l,c,d;e.parameters={...e.parameters,docs:{...(l=e.parameters)==null?void 0:l.docs,source:{originalSource:`args => {
1
+ import{j as G}from"./jsx-runtime-eps93zm2.js";import{T as X}from"./table-DWBe_npR.js";import{t as K,E as O,s as W,F as k,G as q,H as z,I as D,J as M,K as P,L as Q}from"./table.stories-data-CYppbCAy.js";import"./index-DhsZuJvc.js";import"./index-Bk2sglWO.js";import"./index.es-D2piFfFj.js";import"./inheritsLoose-DR8r8Ogv.js";import"./extends-CF3RwP-h.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./index-CUZDtIZe.js";import"./memoize-one.esm-CcMeOnPo.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./lodash-c4VUpsOs.js";import"./actions-Tr0wIZve.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./icon-BP4BO6-k.js";import"./index-CEuq6vkz.js";import"./tooltip-1V7clEnw.js";import"./types-BmbYqTX_.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./heading-NkLgQYoP.js";import"./help-icon-41R-Z9N1.js";import"./pagination-bLx5-m9c.js";import"./select-BpALjE__.js";import"./enum-Bnn40S8Q.js";import"./assertThisInitialized-B9jnkVVz.js";import"./text-B3-TSWok.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-C8O0lnql.js";import"./index-C0x1JmaP.js";import"./index-DRSy5Ssd.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";import"./flex-EllkLxgO.js";const Wr={title:"Basic/Table/Title & Header",component:X,args:{table:{...K}}},r=B=>G.jsx(X,{...B}),e=r.bind({});e.args={table:O};const s=r.bind({});s.args={table:W};const a=r.bind({});a.args={table:k};const t=r.bind({});t.args={table:q};const o=r.bind({});o.args={table:z};const n=r.bind({});n.args={table:D};const i=r.bind({});i.args={table:M};const p=r.bind({});p.args={table:P};const m=r.bind({});m.args={table:Q};var l,c,d;e.parameters={...e.parameters,docs:{...(l=e.parameters)==null?void 0:l.docs,source:{originalSource:`args => {
2
2
  return <Table
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
4
  {...args} />;
@@ -1,4 +1,4 @@
1
- import{j as e}from"./jsx-runtime-eps93zm2.js";import{r as m}from"./index-DhsZuJvc.js";import{d as l}from"./index-C0x1JmaP.js";import{c as Un}from"./index-Bk2sglWO.js";import{u as wn}from"./use-previous-D775JrO6.js";import{M as Ee}from"./actions-Tr0wIZve.js";import{I as xn}from"./input-group-addon-D68iUKV2.js";import{B as g}from"./button-CzvLc2io.js";import{T as In}from"./tooltip-1V7clEnw.js";import{I as Tn}from"./input-group-BaRSJAEN.js";import{S as I}from"./spacer-BWoNR27H.js";import{T as Yt}from"./text-B3-TSWok.js";import{M as Ne}from"./types-BmbYqTX_.js";import{l as V}from"./lodash-c4VUpsOs.js";import{i as Vn}from"./helpers-JJxzGegQ.js";import{N as kn}from"./number-input-DZ9ERbK_.js";import{D as jn}from"./divider-DY9nJ_7N.js";import{R as Zt,C as ye}from"./row-Bmiy2Lh0.js";import{F as T}from"./field-C5_fLDpy.js";import{M as be}from"./message-DQ3q8XF9.js";import{w as de,u as d,e as w,f as Qt,a as Xt}from"./index-DMAnyMX5.js";import"./index-DRSy5Ssd.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./spinner-AWUe4xwQ.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./input-DTXbDJaL.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-hiSz3I8H.js";import"./help-icon-41R-Z9N1.js";import"./index-CF7H4eMJ.js";const Sn=()=>{const t=m.useRef(null);return m.useLayoutEffect(()=>{t.current&&(t.current(),t.current=null)}),n=>{t.current=n}},En=(t,a)=>{const n=a==null?void 0:a[t];return n||(console.log(`Warning: 'unitTemplate' missing for '${t}'. Using initial unit, preferred unit or value unit.`),l.unitFromQuantity(t)??"")};var b=(t=>(t.CUSTOM="custom",t.PREDEFINED="predefined",t))(b||{});const en=t=>t==="undefined"||t===void 0||t===""||t==="null"||t===null||t==="NaN"||isNaN(t),tn=(t="",a,n="",s=!1)=>{if(s)return t;if(a&&!en(t))try{const i=l.isValueWithUnit(t)?t:l.withUnit(t,n),p=l.convertSamePrecision(i,a);return l.getValue(p)}catch{}return t},Nn=t=>t?!!l.getUnit(t):!1,O=(t="",a,n,s)=>{if(s)return t;const i=Nn(t)||l.isValueWithUnit(t),p=l.getValue(t);return en(p)?p:i?tn(p,a,n,s):t},Ae=t=>V.isObject(t)&&!V.isArray(t)&&!V.isFunction(t)?V.get(t,"fieldName",""):typeof t=="string"?t:"",qe=(t="")=>{var a;return(a=l.KNOWN_UNITS)==null?void 0:a.includes(t)},An=(t,a)=>{const n=l.getUnit(t||"");return qe(a)&&qe(n)};let qn=m.createContext(null);const Dn=()=>m.useContext(qn),Fn="_predefinedMenuActive_ye9w9_1",Pn="_inputWrapper_ye9w9_4",De={predefinedMenuActive:Fn,inputWrapper:Pn},c=({name:t,placeholder:a="",disabled:n=!1,disabledUnit:s=!1,error:i=null,left:p=!1,small:o=!1,width:h="100%",value:v,unitkey:ie="",initUnit:nn,noConversion:an=!1,onChange:ce=V.noop,onClick:_n=V.noop,onFocus:rn=V.noop,onSwitchUnit:Ce=V.noop,unitTemplate:Ue,doNotConvertValue:B=!1,testId:E,warning:we=null,predefinedOptions:x,initialPredefinedOption:sn=!1,shouldLinkAutomaticly:xe=!0,selectedPredefinedOptionKey:Ie,validationCallback:ln=()=>({name:"",error:null}),disabledValidation:un=!1,allowEmpty:on=!1,autoValue:k})=>{const N=Dn(),dn=Sn();typeof v=="number"&&(v=`${v}`);const[Te="",_=""]=v!==void 0?l.split(v):[],Ve=k?l.getUnit(k):"",ke=m.useMemo(()=>En(ie,Ue||(N==null?void 0:N.unitTemplate)),[ie,Ue,N==null?void 0:N.unitTemplate]),cn=An(v,ke),C=nn||ke||_,mn=wn(C),je=O(v,C,_,B),Se=O(k,C,Ve,B),pn=je!==""?{value:je,unit:C}:Se!==""?{value:Se,unit:C}:{value:Te,unit:_},[f,me]=m.useState(pn),[j,pe]=m.useState(sn?b.PREDEFINED:b.CUSTOM),ge=Te===""&&k,gn=!!(un||k||a&&Vn(v)),M=x&&x.find(r=>{if(!(r!=null&&r.value))return;if(Ie)return Ie===r.valueKey;const u=l.isValueWithUnit(r.value)?l.getUnit(r.value):"";return l.withUnit(tn(v,u),u)===r.value}),hn=()=>{if(ie)try{const r=ge?k:v??"";let u=l.altUnitsList(r,ie);return l.getValue(r)===""?u.map(U=>["",U[1]]):u}catch{return null}},vn=r=>{const u=Ae(t),U=r.target,{value:S,selectionStart:ue}=U,ve=l.withUnit(S,(f==null?void 0:f.unit)||"");ce({target:{value:ve,name:u}});const[fe,Cn]=l.split(ve);me({value:fe,unit:Cn}),dn(()=>{U.selectionStart=ue,U.selectionEnd=ue})},fn=(r,u)=>{u===f.unit||isNaN(Number(r))||(me({value:r,unit:u}),Ce&&Ce(u))};m.useEffect(()=>{if(C){let r,u="";mn!==C?(r=O(v,C,_,B),u=C):l.withUnit(f.value,f.unit)!==v&&(r=O(v,f.unit,_,B),u=f.unit),r!==void 0&&me({value:r,unit:u}),x&&pe(M&&xe?b.PREDEFINED:b.CUSTOM)}},[C,v,i,xe]);const re=hn(),se=l.label(f.unit)||f.unit||"",yn=an||!re||re&&re.length===1,he=Ae(t);let le;const bn=r=>{const u=r!=null&&r.value?r.value:"",[U="",S=""]=l.isValueWithUnit(u)?l.split(u):[u];return{type:Ne.OPTION,inline:!0,onClick:()=>{l.validateNumber(U).valid&&!n&&(pe(b.PREDEFINED),ce({target:{value:u,name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||"",predefinedSelected:!0,predefinedOption:r}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(Yt,{children:r.label}),e.jsx(I,{width:"20px",height:"0"})]}),description:l.isValueWithUnit(u)?`${U} ${S}`:u,selected:M===r&&j===b.PREDEFINED}};if(le=[{type:Ne.OPTION,inline:!0,onClick:()=>{j!==b.CUSTOM&&!n&&ce({target:{value:l.withUnit(f.value,f.unit),name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||""}})},label:"Custom",selected:j===b.CUSTOM}],x!=null&&x.length){const r=x.map(bn);le=[...le,...r]}return e.jsx("div",{className:j===b.PREDEFINED?Un(De.predefinedMenuActive):"",children:e.jsxs(Tn,{small:o,width:h,children:[x&&e.jsx(In,{text:j===b.PREDEFINED?M==null?void 0:M.label:"",children:e.jsx(Ee,{maxHeight:380,groupOrder:"first",testId:E&&`${E}-predefined-menu`,disabled:n,menu:{colored:!0,trigger:"Component",component:e.jsx(g,{groupOrder:"first",active:j===b.PREDEFINED,icon:j===b.PREDEFINED?"link":"unlink"}),small:o,sections:le}})}),e.jsx("div",{className:De.inputWrapper,children:e.jsx(kn,{name:he,testId:E,disabled:n,placeholder:ge?O(k,f.unit,Ve,B):a,value:f.value,onChange:vn,onFocus:rn,error:i===null?void 0:i,warning:we===null?void 0:we,left:p,allowEmpty:on,validationCallback:(r,u)=>ln(he,u),groupOrder:x?"middle":"first",disableInternalErrorValidationMessages:gn},he)}),se&&(yn||!cn?e.jsx(xn,{groupOrder:"last",children:se}):e.jsx(Ee,{maxHeight:380,groupOrder:"last",disabled:s,testId:E&&`${E}-menu`,menu:{label:se,trigger:"DropDownButton",small:o,sections:re.map(([r,u,U])=>{const S=U||u||"";return{type:"Option",label:isNaN(Number(r))?"":r,inline:!0,onClick:fe=>{fe.stopPropagation(),fn(ge?"":r,u)},description:S,selected:S===se,testId:`${E}-unit-${S}`}})}}))]})})};c.__docgenInfo={description:"",methods:[],displayName:"UnitInput",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:"",defaultValue:{value:"''",computed:!1}},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},disabledUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:"",defaultValue:{value:"null",computed:!1}},left:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"'100%'",computed:!1}},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},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:"",defaultValue:{value:"null",computed:!1}},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:"",defaultValue:{value:"false",computed:!1}},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},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:"",defaultValue:{value:"() => ({ name: '', error: null })",computed:!1}},disabledValidation:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},allowEmpty:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},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 m}from"./index-DhsZuJvc.js";import{d as l}from"./index-C0x1JmaP.js";import{c as Un}from"./index-Bk2sglWO.js";import{u as wn}from"./use-previous-D775JrO6.js";import{M as Ee}from"./actions-Tr0wIZve.js";import{I as xn}from"./input-group-addon-D68iUKV2.js";import{B as g}from"./button-CzvLc2io.js";import{T as In}from"./tooltip-1V7clEnw.js";import{I as Tn}from"./input-group-BaRSJAEN.js";import{S as I}from"./spacer-BWoNR27H.js";import{T as Yt}from"./text-B3-TSWok.js";import{M as Ne}from"./types-BmbYqTX_.js";import{l as V}from"./lodash-c4VUpsOs.js";import{i as Vn}from"./helpers-JJxzGegQ.js";import{N as kn}from"./number-input-C8O0lnql.js";import{D as jn}from"./divider-DY9nJ_7N.js";import{R as Zt,C as ye}from"./row-Bmiy2Lh0.js";import{F as T}from"./field-C5_fLDpy.js";import{M as be}from"./message-DQ3q8XF9.js";import{w as de,u as d,e as w,f as Qt,a as Xt}from"./index-DMAnyMX5.js";import"./index-DRSy5Ssd.js";import"./common-types-Sih75Sav.js";import"./disabled-context-rmpd7YJS.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./types-Dx2TtIG9.js";import"./badge-CLQ59MDF.js";import"./spinner-AWUe4xwQ.js";import"./index-CUZDtIZe.js";import"./enum-Bnn40S8Q.js";import"./input-DTXbDJaL.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./label-hiSz3I8H.js";import"./help-icon-41R-Z9N1.js";import"./index-CF7H4eMJ.js";const Sn=()=>{const t=m.useRef(null);return m.useLayoutEffect(()=>{t.current&&(t.current(),t.current=null)}),n=>{t.current=n}},En=(t,a)=>{const n=a==null?void 0:a[t];return n||(console.log(`Warning: 'unitTemplate' missing for '${t}'. Using initial unit, preferred unit or value unit.`),l.unitFromQuantity(t)??"")};var b=(t=>(t.CUSTOM="custom",t.PREDEFINED="predefined",t))(b||{});const en=t=>t==="undefined"||t===void 0||t===""||t==="null"||t===null||t==="NaN"||isNaN(t),tn=(t="",a,n="",s=!1)=>{if(s)return t;if(a&&!en(t))try{const i=l.isValueWithUnit(t)?t:l.withUnit(t,n),p=l.convertSamePrecision(i,a);return l.getValue(p)}catch{}return t},Nn=t=>t?!!l.getUnit(t):!1,O=(t="",a,n,s)=>{if(s)return t;const i=Nn(t)||l.isValueWithUnit(t),p=l.getValue(t);return en(p)?p:i?tn(p,a,n,s):t},Ae=t=>V.isObject(t)&&!V.isArray(t)&&!V.isFunction(t)?V.get(t,"fieldName",""):typeof t=="string"?t:"",qe=(t="")=>{var a;return(a=l.KNOWN_UNITS)==null?void 0:a.includes(t)},An=(t,a)=>{const n=l.getUnit(t||"");return qe(a)&&qe(n)};let qn=m.createContext(null);const Dn=()=>m.useContext(qn),Fn="_predefinedMenuActive_ye9w9_1",Pn="_inputWrapper_ye9w9_4",De={predefinedMenuActive:Fn,inputWrapper:Pn},c=({name:t,placeholder:a="",disabled:n=!1,disabledUnit:s=!1,error:i=null,left:p=!1,small:o=!1,width:h="100%",value:v,unitkey:ie="",initUnit:nn,noConversion:an=!1,onChange:ce=V.noop,onClick:_n=V.noop,onFocus:rn=V.noop,onSwitchUnit:Ce=V.noop,unitTemplate:Ue,doNotConvertValue:B=!1,testId:E,warning:we=null,predefinedOptions:x,initialPredefinedOption:sn=!1,shouldLinkAutomaticly:xe=!0,selectedPredefinedOptionKey:Ie,validationCallback:ln=()=>({name:"",error:null}),disabledValidation:un=!1,allowEmpty:on=!1,autoValue:k})=>{const N=Dn(),dn=Sn();typeof v=="number"&&(v=`${v}`);const[Te="",_=""]=v!==void 0?l.split(v):[],Ve=k?l.getUnit(k):"",ke=m.useMemo(()=>En(ie,Ue||(N==null?void 0:N.unitTemplate)),[ie,Ue,N==null?void 0:N.unitTemplate]),cn=An(v,ke),C=nn||ke||_,mn=wn(C),je=O(v,C,_,B),Se=O(k,C,Ve,B),pn=je!==""?{value:je,unit:C}:Se!==""?{value:Se,unit:C}:{value:Te,unit:_},[f,me]=m.useState(pn),[j,pe]=m.useState(sn?b.PREDEFINED:b.CUSTOM),ge=Te===""&&k,gn=!!(un||k||a&&Vn(v)),M=x&&x.find(r=>{if(!(r!=null&&r.value))return;if(Ie)return Ie===r.valueKey;const u=l.isValueWithUnit(r.value)?l.getUnit(r.value):"";return l.withUnit(tn(v,u),u)===r.value}),hn=()=>{if(ie)try{const r=ge?k:v??"";let u=l.altUnitsList(r,ie);return l.getValue(r)===""?u.map(U=>["",U[1]]):u}catch{return null}},vn=r=>{const u=Ae(t),U=r.target,{value:S,selectionStart:ue}=U,ve=l.withUnit(S,(f==null?void 0:f.unit)||"");ce({target:{value:ve,name:u}});const[fe,Cn]=l.split(ve);me({value:fe,unit:Cn}),dn(()=>{U.selectionStart=ue,U.selectionEnd=ue})},fn=(r,u)=>{u===f.unit||isNaN(Number(r))||(me({value:r,unit:u}),Ce&&Ce(u))};m.useEffect(()=>{if(C){let r,u="";mn!==C?(r=O(v,C,_,B),u=C):l.withUnit(f.value,f.unit)!==v&&(r=O(v,f.unit,_,B),u=f.unit),r!==void 0&&me({value:r,unit:u}),x&&pe(M&&xe?b.PREDEFINED:b.CUSTOM)}},[C,v,i,xe]);const re=hn(),se=l.label(f.unit)||f.unit||"",yn=an||!re||re&&re.length===1,he=Ae(t);let le;const bn=r=>{const u=r!=null&&r.value?r.value:"",[U="",S=""]=l.isValueWithUnit(u)?l.split(u):[u];return{type:Ne.OPTION,inline:!0,onClick:()=>{l.validateNumber(U).valid&&!n&&(pe(b.PREDEFINED),ce({target:{value:u,name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||"",predefinedSelected:!0,predefinedOption:r}}))},label:e.jsxs(e.Fragment,{children:[e.jsx(Yt,{children:r.label}),e.jsx(I,{width:"20px",height:"0"})]}),description:l.isValueWithUnit(u)?`${U} ${S}`:u,selected:M===r&&j===b.PREDEFINED}};if(le=[{type:Ne.OPTION,inline:!0,onClick:()=>{j!==b.CUSTOM&&!n&&ce({target:{value:l.withUnit(f.value,f.unit),name:typeof t=="string"?t:(t==null?void 0:t.fieldName)||""}})},label:"Custom",selected:j===b.CUSTOM}],x!=null&&x.length){const r=x.map(bn);le=[...le,...r]}return e.jsx("div",{className:j===b.PREDEFINED?Un(De.predefinedMenuActive):"",children:e.jsxs(Tn,{small:o,width:h,children:[x&&e.jsx(In,{text:j===b.PREDEFINED?M==null?void 0:M.label:"",children:e.jsx(Ee,{maxHeight:380,groupOrder:"first",testId:E&&`${E}-predefined-menu`,disabled:n,menu:{colored:!0,trigger:"Component",component:e.jsx(g,{groupOrder:"first",active:j===b.PREDEFINED,icon:j===b.PREDEFINED?"link":"unlink"}),small:o,sections:le}})}),e.jsx("div",{className:De.inputWrapper,children:e.jsx(kn,{name:he,testId:E,disabled:n,placeholder:ge?O(k,f.unit,Ve,B):a,value:f.value,onChange:vn,onFocus:rn,error:i===null?void 0:i,warning:we===null?void 0:we,left:p,allowEmpty:on,validationCallback:(r,u)=>ln(he,u),groupOrder:x?"middle":"first",disableInternalErrorValidationMessages:gn},he)}),se&&(yn||!cn?e.jsx(xn,{groupOrder:"last",children:se}):e.jsx(Ee,{maxHeight:380,groupOrder:"last",disabled:s,testId:E&&`${E}-menu`,menu:{label:se,trigger:"DropDownButton",small:o,sections:re.map(([r,u,U])=>{const S=U||u||"";return{type:"Option",label:isNaN(Number(r))?"":r,inline:!0,onClick:fe=>{fe.stopPropagation(),fn(ge?"":r,u)},description:S,selected:S===se,testId:`${E}-unit-${S}`}})}}))]})})};c.__docgenInfo={description:"",methods:[],displayName:"UnitInput",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:"",defaultValue:{value:"''",computed:!1}},disabled:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},disabledUnit:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},error:{required:!1,tsType:{name:"union",raw:"string | null | boolean",elements:[{name:"string"},{name:"null"},{name:"boolean"}]},description:"",defaultValue:{value:"null",computed:!1}},left:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},small:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},width:{required:!1,tsType:{name:"union",raw:"string | number",elements:[{name:"string"},{name:"number"}]},description:"",defaultValue:{value:"'100%'",computed:!1}},value:{required:!1,tsType:{name:"string"},description:""},unitkey:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:"''",computed:!1}},initUnit:{required:!1,tsType:{name:"string"},description:""},noConversion:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},doNotConvertValue:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},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:"",defaultValue:{value:"null",computed:!1}},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:"",defaultValue:{value:"false",computed:!1}},shouldLinkAutomaticly:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},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:"",defaultValue:{value:"() => ({ name: '', error: null })",computed:!1}},disabledValidation:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},allowEmpty:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},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 i}from"./jsx-runtime-eps93zm2.js";import{r as v}from"./index-DhsZuJvc.js";import{f as J}from"./immer.esm-BwVl9PS2.js";import{d as T}from"./index-C0x1JmaP.js";import{G as ne}from"./grid-DRkC-bt8.js";import{S as ae}from"./spacer-BWoNR27H.js";import{w as O,u as d,e as B,f as ie,a as re}from"./index-DMAnyMX5.js";import{C as F}from"./card-EcjmryU9.js";import{F as R}from"./field-C5_fLDpy.js";import{H as _}from"./heading-NkLgQYoP.js";import{S as P}from"./select-BpALjE__.js";import{T as W}from"./toggle-C0zvrIOF.js";import{l as oe}from"./lodash-c4VUpsOs.js";import{u as le}from"./use-previous-D775JrO6.js";import{T as se,C as G}from"./table-D1GJPQfF.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./label-hiSz3I8H.js";import"./common-types-Sih75Sav.js";import"./help-icon-41R-Z9N1.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./index.es-D2piFfFj.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-bLx5-m9c.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-DZ9ERbK_.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";const ue=r=>r.reduce(({preferredUnits:o,storageUnits:a},{unitKey:l,preferredUnit:e,storageUnit:b})=>(o[l]=e,a[l]=b,{preferredUnits:o,storageUnits:a}),{preferredUnits:{},storageUnits:{}}),ce=({headers:r,rows:o,selectedUnits:a,storageUnits:l,onChangeUnit:e,convertBackToStorageUnit:b,enableCosmeticRounding:m,enableDisplayRounding:C})=>{const u=r?r.map(c=>({...c,cells:c.cells.map(p=>{var n;if(p.type===G.AUTO_UNIT){const{testId:x,unitKey:g}=p;return{value:a[g],type:G.SELECT,searchable:!1,options:(n=T.getUnitsForQuantity(g))==null?void 0:n.map(U=>({label:T.label(U),value:U})),native:p.native,onChange:U=>e({unitKey:g,value:U.target.value}),testId:x}}return p})})):[],s=o?o.map((c,p)=>({...c,cells:c.cells.map((n,x)=>{if("autoUnit"in n&&(n!=null&&n.autoUnit)&&(typeof(n==null?void 0:n.value)=="string"||typeof(n==null?void 0:n.value)=="number")){const{unitKey:g,value:U,formatDisplayValue:I}=n,V=C&&"roundDisplayValue"in n?n==null?void 0:n.roundDisplayValue:null,h=a[g],y=l[g],t=h!==y,f=t?T.convertAndGetValue(U,h,y):n.value,w=T.isScientificStringNum(U),k=m&&(t||!w)?T.roundToPrecision(f,14):f,S=I?I(k):k;return{...n,value:S,enableCosmeticRounding:m,enableDisplayRounding:C,roundDisplayValue:V,onChange:D=>{const{value:H}=D.target,A=l[g],E=a[g],K=E!==A,j=b?A:E,Z=K?T.convertAndGetValue(H,j,E):H;if("onChange"in n){const{onChange:ee}=n,te={...D,target:{...D.target,value:String(Z),rowIndex:p,cellIndex:x,unit:j}};ee(te)}}}}return n})})):[];return{convertedHeaders:u,convertedRows:s}},X=({table:r,unitConfig:o,convertBackToStorageUnit:a=!0,enableCosmeticRounding:l=!0,enableDisplayRounding:e=!0})=>{const{rows:b,headers:m,...C}=r,{storageUnits:u,preferredUnits:s}=ue(o),c=le(s),[p,n]=v.useState(s),x=({unitKey:h,value:y})=>{n({...p,[h]:y});const t=o.find(f=>f.unitKey===h);t&&typeof t.onChange=="function"&&t.onChange({oldUnit:p[h],newUnit:y,unitKey:h})},g=h=>ce({headers:m,rows:b,selectedUnits:h,storageUnits:u,onChangeUnit:x,convertBackToStorageUnit:a,enableCosmeticRounding:l,enableDisplayRounding:e}),U=g(p),[I,V]=v.useState(U);return v.useEffect(()=>{!oe.isEqual(s,c)&&(Object.keys(s).forEach(y=>{const t=c==null?void 0:c[y],f=s[y];t!==f&&x({unitKey:y,value:f})}),V(g(s)))},[o]),v.useEffect(()=>{V(g(p))},[r,p]),i.jsx(se,{table:{...C,headers:I.convertedHeaders,rows:I.convertedRows}})};X.__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 Ut={title:"Basic/UnitTable",args:{}},de=!0,pe=!0,ge=!0,me=!1,N="m",Y="C",he=3,be=(r,o,a)=>{const l=[o,o,a],e=[...Array(r)].map((b,m)=>{const C=m,u=m+1.25,s=4+m*.25;return[String(C),String(u),String(s)]});return[l,...e]},ye=be(he,N,Y),fe=({reduxTable:r,value:o,unit:a,rowIndex:l,cellIndex:e})=>J(r,b=>{const m=b[0][e],C=(u,s)=>s===0;return b.forEach((u,s)=>{if(C(u,s)){u[e]=a;return}if(s===l+1){u[e]=String(o);return}const c=T.convertAndGetValue(u[e],a,m);u[e]=String(c)}),b}),ve=({reduxTable:r,value:o,rowIndex:a,cellIndex:l})=>J(r,e=>{e[a+1][l]=o}),L=()=>{var h,y;const[r,o]=v.useState(N),[a,l]=v.useState(Y),[e,b]=v.useState(ye),[m,C]=v.useState(de),[u,s]=v.useState(ge),[c,p]=v.useState(pe),[n,x]=v.useState(me),[g,U]=v.useState(N),I=t=>{const{rowIndex:f,cellIndex:w,value:k,unit:S}=t.target,D=n?fe({reduxTable:e,value:k,unit:S,rowIndex:f,cellIndex:w}):ve({reduxTable:e,value:k,rowIndex:f,cellIndex:w});b(D)},V=e.reduce((t,f,w)=>(w===0?t.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"}]}]:t.rows=t.rows.concat({cells:f.map((k,S)=>{const D=w===1&&S===1;return{value:k,type:D?"Text":"NumberInput",unitKey:S===2?"temperature":"length",onChange:I,roundDisplayValue:w===3&&S===2?j=>T.roundByMagnitude(j,2):null,formatDisplayValue:D?j=>`T* ${j}`:null,autoUnit:!0,testId:`testId_${w}_${S}`}})}),t),{testId:"testId",headers:[],rows:[]});return i.jsxs(ne,{columns:"1fr 1fr",gap:!0,children:[i.jsxs(F,{heading:i.jsx(_,{children:"Settings"}),children:[i.jsx(R,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:m,onChange:t=>C(t.target.checked)})}),i.jsx(R,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:u,onChange:t=>s(t.target.checked)})}),i.jsx(R,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:c,onChange:t=>p(t.target.checked)})}),i.jsx(R,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:n,onChange:t=>x(t.target.checked)})})]}),i.jsxs(F,{heading:i.jsx(_,{children:"Unit template"}),children:[i.jsx(R,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(h=T.getUnitsForQuantity("length"))==null?void 0:h.map(t=>({value:t,label:T.label(t)})),value:{value:r},onChange:t=>o(t.target.value),width:"100px"})}),i.jsx(R,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(y=T.getUnitsForQuantity("temperature"))==null?void 0:y.map(t=>({value:t,label:T.label(t)})),value:{value:a},onChange:t=>l(t.target.value),width:"100px"})})]}),i.jsx(F,{heading:i.jsx(_,{children:"Storage State (Redux)"}),children:i.jsx("pre",{children:i.jsx("code",{children:JSON.stringify(e,null,2)})})}),i.jsxs(F,{heading:i.jsx(_,{children:"UnitTable"}),children:[i.jsx(X,{table:V,unitConfig:[{unitKey:"length",storageUnit:e[0][0],preferredUnit:r,onChange:({newUnit:t})=>U(t)},{unitKey:"temperature",storageUnit:e[0][2],preferredUnit:a}],convertBackToStorageUnit:m,enableDisplayRounding:u,enableCosmeticRounding:c}),i.jsx(ae,{height:20}),i.jsx(R,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:g})]})]})};L.play=async({canvasElement:r,step:o})=>{const a=O(r),l=O(r.ownerDocument.body);await o("Can enter decimal values",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123.123456789"),await d.click(r),await B(a.getByDisplayValue("123.12")).toBeInTheDocument()}),await o("Can enter comma decimals (converts to dot)",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123,456"),await d.click(r),await B(a.getByDisplayValue("123.46")).toBeInTheDocument()}),await o("Can enter small numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"0.0000000023"),await d.click(r),await B(e).toHaveDisplayValue("0.00")}),await o("Can enter large numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"999999999999"),await d.click(r),await B(a.getByDisplayValue("999999999999.00")).toBeInTheDocument()}),await o("Shows validation error for non-numeric input",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123x45s6"),await d.click(r),await ie.mouseOver(e),await re(()=>{B(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};L.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"UnitTableExample"};var q,$,Q,M,z;L.parameters={...L.parameters,docs:{...(q=L.parameters)==null?void 0:q.docs,source:{originalSource:`() => {
1
+ import{j as i}from"./jsx-runtime-eps93zm2.js";import{r as v}from"./index-DhsZuJvc.js";import{f as J}from"./immer.esm-BwVl9PS2.js";import{d as T}from"./index-C0x1JmaP.js";import{G as ne}from"./grid-DRkC-bt8.js";import{S as ae}from"./spacer-BWoNR27H.js";import{w as O,u as d,e as B,f as ie,a as re}from"./index-DMAnyMX5.js";import{C as F}from"./card-EcjmryU9.js";import{F as R}from"./field-C5_fLDpy.js";import{H as _}from"./heading-NkLgQYoP.js";import{S as P}from"./select-BpALjE__.js";import{T as W}from"./toggle-C0zvrIOF.js";import{l as oe}from"./lodash-c4VUpsOs.js";import{u as le}from"./use-previous-D775JrO6.js";import{T as se,C as G}from"./table-DWBe_npR.js";import"./index-DRSy5Ssd.js";import"./styled-components.browser.esm-BQ9GQzDc.js";import"./index-CF7H4eMJ.js";import"./index-Bk2sglWO.js";import"./label-hiSz3I8H.js";import"./common-types-Sih75Sav.js";import"./help-icon-41R-Z9N1.js";import"./tooltip-1V7clEnw.js";import"./index-CUZDtIZe.js";import"./icon-BP4BO6-k.js";import"./objectWithoutPropertiesLoose-CAYKN5F1.js";import"./inheritsLoose-DR8r8Ogv.js";import"./index-CEuq6vkz.js";import"./disabled-context-rmpd7YJS.js";import"./types-Dx2TtIG9.js";import"./enum-Bnn40S8Q.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B9jnkVVz.js";import"./memoize-one.esm-CcMeOnPo.js";import"./types-BmbYqTX_.js";import"./text-B3-TSWok.js";import"./actions-Tr0wIZve.js";import"./button-CzvLc2io.js";import"./spinner-AWUe4xwQ.js";import"./badge-CLQ59MDF.js";import"./select.input-CJed_LLR.js";import"./helpers-JJxzGegQ.js";import"./index.es-D2piFfFj.js";import"./redux-tRgGMjwY.js";import"./objectSpread2-DW4nTBoq.js";import"./tiny-invariant-DqLgxztJ.js";import"./pagination-bLx5-m9c.js";import"./input-DTXbDJaL.js";import"./input-group-BaRSJAEN.js";import"./input-group-addon-D68iUKV2.js";import"./number-input-C8O0lnql.js";import"./check-box-wCvXxtCz.js";import"./slider-CBE03NwD.js";import"./index-BI4_Bp97.js";import"./popover-9ZnEm5Hy.js";const ue=r=>r.reduce(({preferredUnits:o,storageUnits:a},{unitKey:l,preferredUnit:e,storageUnit:b})=>(o[l]=e,a[l]=b,{preferredUnits:o,storageUnits:a}),{preferredUnits:{},storageUnits:{}}),ce=({headers:r,rows:o,selectedUnits:a,storageUnits:l,onChangeUnit:e,convertBackToStorageUnit:b,enableCosmeticRounding:m,enableDisplayRounding:C})=>{const u=r?r.map(c=>({...c,cells:c.cells.map(p=>{var n;if(p.type===G.AUTO_UNIT){const{testId:x,unitKey:g}=p;return{value:a[g],type:G.SELECT,searchable:!1,options:(n=T.getUnitsForQuantity(g))==null?void 0:n.map(U=>({label:T.label(U),value:U})),native:p.native,onChange:U=>e({unitKey:g,value:U.target.value}),testId:x}}return p})})):[],s=o?o.map((c,p)=>({...c,cells:c.cells.map((n,x)=>{if("autoUnit"in n&&(n!=null&&n.autoUnit)&&(typeof(n==null?void 0:n.value)=="string"||typeof(n==null?void 0:n.value)=="number")){const{unitKey:g,value:U,formatDisplayValue:I}=n,V=C&&"roundDisplayValue"in n?n==null?void 0:n.roundDisplayValue:null,h=a[g],y=l[g],t=h!==y,f=t?T.convertAndGetValue(U,h,y):n.value,w=T.isScientificStringNum(U),k=m&&(t||!w)?T.roundToPrecision(f,14):f,S=I?I(k):k;return{...n,value:S,enableCosmeticRounding:m,enableDisplayRounding:C,roundDisplayValue:V,onChange:D=>{const{value:H}=D.target,A=l[g],E=a[g],K=E!==A,j=b?A:E,Z=K?T.convertAndGetValue(H,j,E):H;if("onChange"in n){const{onChange:ee}=n,te={...D,target:{...D.target,value:String(Z),rowIndex:p,cellIndex:x,unit:j}};ee(te)}}}}return n})})):[];return{convertedHeaders:u,convertedRows:s}},X=({table:r,unitConfig:o,convertBackToStorageUnit:a=!0,enableCosmeticRounding:l=!0,enableDisplayRounding:e=!0})=>{const{rows:b,headers:m,...C}=r,{storageUnits:u,preferredUnits:s}=ue(o),c=le(s),[p,n]=v.useState(s),x=({unitKey:h,value:y})=>{n({...p,[h]:y});const t=o.find(f=>f.unitKey===h);t&&typeof t.onChange=="function"&&t.onChange({oldUnit:p[h],newUnit:y,unitKey:h})},g=h=>ce({headers:m,rows:b,selectedUnits:h,storageUnits:u,onChangeUnit:x,convertBackToStorageUnit:a,enableCosmeticRounding:l,enableDisplayRounding:e}),U=g(p),[I,V]=v.useState(U);return v.useEffect(()=>{!oe.isEqual(s,c)&&(Object.keys(s).forEach(y=>{const t=c==null?void 0:c[y],f=s[y];t!==f&&x({unitKey:y,value:f})}),V(g(s)))},[o]),v.useEffect(()=>{V(g(p))},[r,p]),i.jsx(se,{table:{...C,headers:I.convertedHeaders,rows:I.convertedRows}})};X.__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 Ut={title:"Basic/UnitTable",args:{}},de=!0,pe=!0,ge=!0,me=!1,N="m",Y="C",he=3,be=(r,o,a)=>{const l=[o,o,a],e=[...Array(r)].map((b,m)=>{const C=m,u=m+1.25,s=4+m*.25;return[String(C),String(u),String(s)]});return[l,...e]},ye=be(he,N,Y),fe=({reduxTable:r,value:o,unit:a,rowIndex:l,cellIndex:e})=>J(r,b=>{const m=b[0][e],C=(u,s)=>s===0;return b.forEach((u,s)=>{if(C(u,s)){u[e]=a;return}if(s===l+1){u[e]=String(o);return}const c=T.convertAndGetValue(u[e],a,m);u[e]=String(c)}),b}),ve=({reduxTable:r,value:o,rowIndex:a,cellIndex:l})=>J(r,e=>{e[a+1][l]=o}),L=()=>{var h,y;const[r,o]=v.useState(N),[a,l]=v.useState(Y),[e,b]=v.useState(ye),[m,C]=v.useState(de),[u,s]=v.useState(ge),[c,p]=v.useState(pe),[n,x]=v.useState(me),[g,U]=v.useState(N),I=t=>{const{rowIndex:f,cellIndex:w,value:k,unit:S}=t.target,D=n?fe({reduxTable:e,value:k,unit:S,rowIndex:f,cellIndex:w}):ve({reduxTable:e,value:k,rowIndex:f,cellIndex:w});b(D)},V=e.reduce((t,f,w)=>(w===0?t.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"}]}]:t.rows=t.rows.concat({cells:f.map((k,S)=>{const D=w===1&&S===1;return{value:k,type:D?"Text":"NumberInput",unitKey:S===2?"temperature":"length",onChange:I,roundDisplayValue:w===3&&S===2?j=>T.roundByMagnitude(j,2):null,formatDisplayValue:D?j=>`T* ${j}`:null,autoUnit:!0,testId:`testId_${w}_${S}`}})}),t),{testId:"testId",headers:[],rows:[]});return i.jsxs(ne,{columns:"1fr 1fr",gap:!0,children:[i.jsxs(F,{heading:i.jsx(_,{children:"Settings"}),children:[i.jsx(R,{label:"Convert back to storage unit:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:m,onChange:t=>C(t.target.checked)})}),i.jsx(R,{label:"Enable display rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:u,onChange:t=>s(t.target.checked)})}),i.jsx(R,{label:"Enable cosmetic rounding:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:c,onChange:t=>p(t.target.checked)})}),i.jsx(R,{label:"Convert whole table:",labelLeft:!0,labelWidth:200,children:i.jsx(W,{checked:n,onChange:t=>x(t.target.checked)})})]}),i.jsxs(F,{heading:i.jsx(_,{children:"Unit template"}),children:[i.jsx(R,{label:"Length unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(h=T.getUnitsForQuantity("length"))==null?void 0:h.map(t=>({value:t,label:T.label(t)})),value:{value:r},onChange:t=>o(t.target.value),width:"100px"})}),i.jsx(R,{label:"Temperature unit:",labelLeft:!0,labelWidth:120,children:i.jsx(P,{options:(y=T.getUnitsForQuantity("temperature"))==null?void 0:y.map(t=>({value:t,label:T.label(t)})),value:{value:a},onChange:t=>l(t.target.value),width:"100px"})})]}),i.jsx(F,{heading:i.jsx(_,{children:"Storage State (Redux)"}),children:i.jsx("pre",{children:i.jsx("code",{children:JSON.stringify(e,null,2)})})}),i.jsxs(F,{heading:i.jsx(_,{children:"UnitTable"}),children:[i.jsx(X,{table:V,unitConfig:[{unitKey:"length",storageUnit:e[0][0],preferredUnit:r,onChange:({newUnit:t})=>U(t)},{unitKey:"temperature",storageUnit:e[0][2],preferredUnit:a}],convertBackToStorageUnit:m,enableDisplayRounding:u,enableCosmeticRounding:c}),i.jsx(ae,{height:20}),i.jsx(R,{label:"Displayed length unit:",labelLeft:!0,labelWidth:150,children:g})]})]})};L.play=async({canvasElement:r,step:o})=>{const a=O(r),l=O(r.ownerDocument.body);await o("Can enter decimal values",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123.123456789"),await d.click(r),await B(a.getByDisplayValue("123.12")).toBeInTheDocument()}),await o("Can enter comma decimals (converts to dot)",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123,456"),await d.click(r),await B(a.getByDisplayValue("123.46")).toBeInTheDocument()}),await o("Can enter small numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"0.0000000023"),await d.click(r),await B(e).toHaveDisplayValue("0.00")}),await o("Can enter large numbers",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"999999999999"),await d.click(r),await B(a.getByDisplayValue("999999999999.00")).toBeInTheDocument()}),await o("Shows validation error for non-numeric input",async()=>{const e=a.getByTestId("testId_2_1");await d.clear(e),await d.type(e,"123x45s6"),await d.click(r),await ie.mouseOver(e),await re(()=>{B(l.getByText("Must be a numerical value")).toBeInTheDocument()})})};L.__docgenInfo={description:"",methods:[{name:"play",docblock:null,modifiers:["static"],params:[{name:"{ canvasElement, step }",optional:!1,type:null}],returns:null}],displayName:"UnitTableExample"};var q,$,Q,M,z;L.parameters={...L.parameters,docs:{...(q=L.parameters)==null?void 0:q.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);
@@ -509,7 +509,7 @@
509
509
  }
510
510
  </script>
511
511
 
512
- <script type="module" crossorigin src="./assets/iframe-DKsrL1t6.js"></script>
512
+ <script type="module" crossorigin src="./assets/iframe-DOgYbEjR.js"></script>
513
513
  </head>
514
514
 
515
515
  <body>
@@ -1 +1 @@
1
- {"generatedAt":1722598619836,"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.7","storybookVersionSpecifier":"^8.2.4","language":"typescript","storybookPackages":{"@storybook/addon-essentials":{"version":"8.2.7"},"@storybook/addon-links":{"version":"8.2.7"},"@storybook/preview-api":{"version":"8.2.7"},"@storybook/react":{"version":"8.2.7"},"@storybook/react-vite":{"version":"8.2.7"},"@storybook/test":{"version":"8.2.7"},"@storybook/test-runner":{"version":"0.19.1"},"eslint-plugin-storybook":{"version":"0.6.15"},"storybook":{"version":"8.2.7"}},"addons":{"@storybook/addon-actions":{"version":"8.2.7"},"@storybook/addon-docs":{"version":"8.2.7"},"@storybook/addon-interactions":{"version":"8.2.7"},"storybook-dark-mode":{"version":"4.0.2"}}}
1
+ {"generatedAt":1722590938465,"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.7","storybookVersionSpecifier":"^8.2.4","language":"typescript","storybookPackages":{"@storybook/addon-essentials":{"version":"8.2.7"},"@storybook/addon-links":{"version":"8.2.7"},"@storybook/preview-api":{"version":"8.2.7"},"@storybook/react":{"version":"8.2.7"},"@storybook/react-vite":{"version":"8.2.7"},"@storybook/test":{"version":"8.2.7"},"@storybook/test-runner":{"version":"0.19.1"},"eslint-plugin-storybook":{"version":"0.6.15"},"storybook":{"version":"8.2.7"}},"addons":{"@storybook/addon-actions":{"version":"8.2.7"},"@storybook/addon-docs":{"version":"8.2.7"},"@storybook/addon-interactions":{"version":"8.2.7"},"storybook-dark-mode":{"version":"4.0.2"}}}