@hitachivantara/uikit-react-core 5.27.4 → 5.27.6

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 (56) hide show
  1. package/dist/cjs/components/Accordion/Accordion.cjs.map +1 -1
  2. package/dist/cjs/components/Banner/Banner.cjs.map +1 -1
  3. package/dist/cjs/components/Carousel/Carousel.cjs.map +1 -1
  4. package/dist/cjs/components/DatePicker/DatePicker.cjs +1 -1
  5. package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
  6. package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
  7. package/dist/cjs/components/Drawer/Drawer.cjs +1 -1
  8. package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
  9. package/dist/cjs/components/Dropdown/Dropdown.cjs.map +1 -1
  10. package/dist/cjs/components/Footer/Footer.cjs +1 -1
  11. package/dist/cjs/components/Footer/Footer.cjs.map +1 -1
  12. package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs +1 -1
  13. package/dist/cjs/components/InlineEditor/InlineEditor.styles.cjs.map +1 -1
  14. package/dist/cjs/components/ListContainer/ListContainer.cjs +1 -1
  15. package/dist/cjs/components/ListContainer/ListContainer.cjs.map +1 -1
  16. package/dist/cjs/components/Loading/Loading.cjs.map +1 -1
  17. package/dist/cjs/components/Radio/Radio.cjs.map +1 -1
  18. package/dist/cjs/components/Snackbar/Snackbar.cjs.map +1 -1
  19. package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
  20. package/dist/cjs/components/Tabs/Tabs.cjs.map +1 -1
  21. package/dist/cjs/components/Tag/Tag.cjs.map +1 -1
  22. package/dist/cjs/components/TextArea/TextArea.cjs.map +1 -1
  23. package/dist/cjs/components/TimePicker/TimePicker.cjs.map +1 -1
  24. package/dist/cjs/components/TimePicker/Unit/Unit.styles.cjs +2 -2
  25. package/dist/cjs/components/TimePicker/Unit/Unit.styles.cjs.map +1 -1
  26. package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.cjs +1 -1
  27. package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.cjs.map +1 -1
  28. package/dist/esm/components/Accordion/Accordion.js.map +1 -1
  29. package/dist/esm/components/Banner/Banner.js.map +1 -1
  30. package/dist/esm/components/Carousel/Carousel.js.map +1 -1
  31. package/dist/esm/components/DatePicker/DatePicker.js +1 -1
  32. package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
  33. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  34. package/dist/esm/components/Drawer/Drawer.js +1 -1
  35. package/dist/esm/components/Drawer/Drawer.js.map +1 -1
  36. package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
  37. package/dist/esm/components/Footer/Footer.js +1 -1
  38. package/dist/esm/components/Footer/Footer.js.map +1 -1
  39. package/dist/esm/components/InlineEditor/InlineEditor.styles.js +1 -1
  40. package/dist/esm/components/InlineEditor/InlineEditor.styles.js.map +1 -1
  41. package/dist/esm/components/ListContainer/ListContainer.js +2 -2
  42. package/dist/esm/components/ListContainer/ListContainer.js.map +1 -1
  43. package/dist/esm/components/Loading/Loading.js.map +1 -1
  44. package/dist/esm/components/Radio/Radio.js.map +1 -1
  45. package/dist/esm/components/Snackbar/Snackbar.js.map +1 -1
  46. package/dist/esm/components/Switch/Switch.js.map +1 -1
  47. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  48. package/dist/esm/components/Tag/Tag.js.map +1 -1
  49. package/dist/esm/components/TextArea/TextArea.js.map +1 -1
  50. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  51. package/dist/esm/components/TimePicker/Unit/Unit.styles.js +2 -2
  52. package/dist/esm/components/TimePicker/Unit/Unit.styles.js.map +1 -1
  53. package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.js +1 -1
  54. package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
  55. package/dist/types/index.d.ts +58 -109
  56. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ListContainer.js","sources":["../../../../src/components/ListContainer/ListContainer.tsx"],"sourcesContent":["import React, { useRef, useContext, useMemo } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useForkRef } from \"@core/hooks/useForkRef\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./ListContainer.styles\";\nimport HvListContext from \"./ListContext\";\n\nexport { staticClasses as listContainerClasses };\n\nexport type HvListContainerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListContainerProps extends HvBaseProps<HTMLUListElement> {\n /**\n * If the list items should be focusable and react to mouse over events.\n * Defaults to true if the list is selectable, false otherwise.\n */\n interactive?: boolean;\n /** If `true` compact the vertical spacing between list items. */\n condensed?: boolean;\n /** If `true`, the list items' left and right padding is removed. */\n disableGutters?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListContainerClasses;\n}\n\n/**\n * A <b>list</b> is any enumeration of a set of items.\n * The simple list is for continuous <b>vertical indexes of text or icons+text</b>. The content of these lists must be simple: ideally simples fields.\n * This pattern is ideal for <b>selections</b>. It should be used inside a HvPanel.\n */\nexport const HvListContainer = React.forwardRef(\n (props: HvListContainerProps, externalRef) => {\n const {\n id,\n classes: classesProp,\n className,\n interactive = false,\n condensed,\n disableGutters,\n children,\n ...others\n } = useDefaultProps(\"HvListContainer\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const containerRef = useRef(null);\n\n const { topContainerRef, nesting = -1 } = useContext(HvListContext);\n\n const listContext = useMemo(\n () => ({\n topContainerRef: topContainerRef || containerRef,\n condensed,\n disableGutters,\n interactive,\n nesting: nesting + 1,\n }),\n [condensed, disableGutters, interactive, nesting, topContainerRef]\n );\n\n const renderChildren = () => {\n if (!interactive) {\n return children;\n }\n\n const anySelected = React.Children.toArray(children)\n .map((child: any) => child.props.selected && !child.props.disabled)\n .reduce((result, selected) => result || selected, false);\n\n return React.Children.map(children, (child: any, i) => {\n const tabIndex =\n child.props.tabIndex ||\n (!anySelected && i === 0) ||\n (child.props.selected && !child.props.disabled)\n ? 0\n : -1;\n\n return React.cloneElement(child, {\n tabIndex,\n interactive,\n });\n });\n };\n\n const handleRef = useForkRef(externalRef, containerRef);\n\n return (\n <HvListContext.Provider value={listContext}>\n <ul\n ref={handleRef}\n id={id}\n className={cx(classes.root, className)}\n {...others}\n >\n {renderChildren()}\n </ul>\n </HvListContext.Provider>\n );\n }\n);\n"],"names":["HvListContainer","React","forwardRef","props","externalRef","id","classes","classesProp","className","interactive","condensed","disableGutters","children","others","useDefaultProps","cx","useClasses","containerRef","useRef","topContainerRef","nesting","useContext","HvListContext","listContext","useMemo","renderChildren","anySelected","Children","toArray","map","child","selected","disabled","reduce","result","i","tabIndex","cloneElement","handleRef","useForkRef","_jsx","Provider","value","ref","root"],"mappings":";;;;;;;AAiCO,MAAMA,kBAAkBC,eAAMC,WACnC,CAACC,OAA6BC,gBAAgB;AACtC,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC,cAAc;AAAA,IACdC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,mBAAmBX,KAAK;AAEtC,QAAA;AAAA,IAAEG;AAAAA,IAASS;AAAAA,EAAAA,IAAOC,WAAWT,WAAW;AAExCU,QAAAA,eAAeC,OAAO,IAAI;AAE1B,QAAA;AAAA,IAAEC;AAAAA,IAAiBC,UAAU;AAAA,EAAA,IAAOC,WAAWC,aAAa;AAE5DC,QAAAA,cAAcC,QAClB,OAAO;AAAA,IACLL,iBAAiBA,mBAAmBF;AAAAA,IACpCP;AAAAA,IACAC;AAAAA,IACAF;AAAAA,IACAW,SAASA,UAAU;AAAA,EAAA,IAErB,CAACV,WAAWC,gBAAgBF,aAAaW,SAASD,eAAe,CACnE;AAEA,QAAMM,iBAAiBA,MAAM;AAC3B,QAAI,CAAChB,aAAa;AACTG,aAAAA;AAAAA,IACT;AAEMc,UAAAA,cAAczB,eAAM0B,SAASC,QAAQhB,QAAQ,EAChDiB,IAAI,CAACC,UAAeA,MAAM3B,MAAM4B,YAAY,CAACD,MAAM3B,MAAM6B,QAAQ,EACjEC,OAAO,CAACC,QAAQH,aAAaG,UAAUH,UAAU,KAAK;AAEzD,WAAO9B,eAAM0B,SAASE,IAAIjB,UAAU,CAACkB,OAAYK,MAAM;AACrD,YAAMC,WACJN,MAAM3B,MAAMiC,YACX,CAACV,eAAeS,MAAM,KACtBL,MAAM3B,MAAM4B,YAAY,CAACD,MAAM3B,MAAM6B,WAClC,IACA;AAEC/B,aAAAA,eAAMoC,aAAaP,OAAO;AAAA,QAC/BM;AAAAA,QACA3B;AAAAA,MAAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA;AAGG6B,QAAAA,YAAYC,WAAWnC,aAAaa,YAAY;AAGpDuB,SAAAA,oBAAClB,cAAcmB,UAAQ;AAAA,IAACC,OAAOnB;AAAAA,IAAYX,8BACzC,MAAA;AAAA,MACE+B,KAAKL;AAAAA,MACLjC;AAAAA,MACAG,WAAWO,GAAGT,QAAQsC,MAAMpC,SAAS;AAAA,MAAE,GACnCK;AAAAA,MAAMD,UAETa,eAAe;AAAA,IAAA,CACd;AAAA,EAAA,CACkB;AAE5B,CACF;"}
1
+ {"version":3,"file":"ListContainer.js","sources":["../../../../src/components/ListContainer/ListContainer.tsx"],"sourcesContent":["import React, { useRef, useContext, useMemo, forwardRef } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useForkRef } from \"@core/hooks/useForkRef\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./ListContainer.styles\";\nimport HvListContext from \"./ListContext\";\n\nexport { staticClasses as listContainerClasses };\n\nexport type HvListContainerClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvListContainerProps extends HvBaseProps<HTMLUListElement> {\n /**\n * If the list items should be focusable and react to mouse over events.\n * Defaults to true if the list is selectable, false otherwise.\n */\n interactive?: boolean;\n /** If `true` compact the vertical spacing between list items. */\n condensed?: boolean;\n /** If `true`, the list items' left and right padding is removed. */\n disableGutters?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvListContainerClasses;\n}\n\n/**\n * A <b>list</b> is any enumeration of a set of items.\n * The simple list is for continuous <b>vertical indexes of text or icons+text</b>. The content of these lists must be simple: ideally simples fields.\n * This pattern is ideal for <b>selections</b>. It should be used inside a HvPanel.\n */\nexport const HvListContainer = forwardRef(\n (props: HvListContainerProps, externalRef) => {\n const {\n id,\n classes: classesProp,\n className,\n interactive = false,\n condensed,\n disableGutters,\n children,\n ...others\n } = useDefaultProps(\"HvListContainer\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const containerRef = useRef(null);\n\n const { topContainerRef, nesting = -1 } = useContext(HvListContext);\n\n const listContext = useMemo(\n () => ({\n topContainerRef: topContainerRef || containerRef,\n condensed,\n disableGutters,\n interactive,\n nesting: nesting + 1,\n }),\n [condensed, disableGutters, interactive, nesting, topContainerRef]\n );\n\n const renderChildren = () => {\n if (!interactive) {\n return children;\n }\n\n const anySelected = React.Children.toArray(children)\n .map((child: any) => child.props.selected && !child.props.disabled)\n .reduce((result, selected) => result || selected, false);\n\n return React.Children.map(children, (child: any, i) => {\n const tabIndex =\n child.props.tabIndex ||\n (!anySelected && i === 0) ||\n (child.props.selected && !child.props.disabled)\n ? 0\n : -1;\n\n return React.cloneElement(child, {\n tabIndex,\n interactive,\n });\n });\n };\n\n const handleRef = useForkRef(externalRef, containerRef);\n\n return (\n <HvListContext.Provider value={listContext}>\n <ul\n ref={handleRef}\n id={id}\n className={cx(classes.root, className)}\n {...others}\n >\n {renderChildren()}\n </ul>\n </HvListContext.Provider>\n );\n }\n);\n"],"names":["HvListContainer","forwardRef","props","externalRef","id","classes","classesProp","className","interactive","condensed","disableGutters","children","others","useDefaultProps","cx","useClasses","containerRef","useRef","topContainerRef","nesting","useContext","HvListContext","listContext","useMemo","renderChildren","anySelected","React","Children","toArray","map","child","selected","disabled","reduce","result","i","tabIndex","cloneElement","handleRef","useForkRef","_jsx","Provider","value","ref","root"],"mappings":";;;;;;;AAiCO,MAAMA,kBAAkBC,WAC7B,CAACC,OAA6BC,gBAAgB;AACtC,QAAA;AAAA,IACJC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC,cAAc;AAAA,IACdC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,mBAAmBX,KAAK;AAEtC,QAAA;AAAA,IAAEG;AAAAA,IAASS;AAAAA,EAAAA,IAAOC,WAAWT,WAAW;AAExCU,QAAAA,eAAeC,OAAO,IAAI;AAE1B,QAAA;AAAA,IAAEC;AAAAA,IAAiBC,UAAU;AAAA,EAAA,IAAOC,WAAWC,aAAa;AAE5DC,QAAAA,cAAcC,QAClB,OAAO;AAAA,IACLL,iBAAiBA,mBAAmBF;AAAAA,IACpCP;AAAAA,IACAC;AAAAA,IACAF;AAAAA,IACAW,SAASA,UAAU;AAAA,EAAA,IAErB,CAACV,WAAWC,gBAAgBF,aAAaW,SAASD,eAAe,CACnE;AAEA,QAAMM,iBAAiBA,MAAM;AAC3B,QAAI,CAAChB,aAAa;AACTG,aAAAA;AAAAA,IACT;AAEMc,UAAAA,cAAcC,eAAMC,SAASC,QAAQjB,QAAQ,EAChDkB,IAAI,CAACC,UAAeA,MAAM5B,MAAM6B,YAAY,CAACD,MAAM5B,MAAM8B,QAAQ,EACjEC,OAAO,CAACC,QAAQH,aAAaG,UAAUH,UAAU,KAAK;AAEzD,WAAOL,eAAMC,SAASE,IAAIlB,UAAU,CAACmB,OAAYK,MAAM;AACrD,YAAMC,WACJN,MAAM5B,MAAMkC,YACX,CAACX,eAAeU,MAAM,KACtBL,MAAM5B,MAAM6B,YAAY,CAACD,MAAM5B,MAAM8B,WAClC,IACA;AAECN,aAAAA,eAAMW,aAAaP,OAAO;AAAA,QAC/BM;AAAAA,QACA5B;AAAAA,MAAAA,CACD;AAAA,IAAA,CACF;AAAA,EAAA;AAGG8B,QAAAA,YAAYC,WAAWpC,aAAaa,YAAY;AAGpDwB,SAAAA,oBAACnB,cAAcoB,UAAQ;AAAA,IAACC,OAAOpB;AAAAA,IAAYX,8BACzC,MAAA;AAAA,MACEgC,KAAKL;AAAAA,MACLlC;AAAAA,MACAG,WAAWO,GAAGT,QAAQuC,MAAMrC,SAAS;AAAA,MAAE,GACnCK;AAAAA,MAAMD,UAETa,eAAe;AAAA,IAAA,CACd;AAAA,EAAA,CACkB;AAE5B,CACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Loading.js","sources":["../../../../src/components/Loading/Loading.tsx"],"sourcesContent":["import { HvColorAny, getColor } from \"@hitachivantara/uikit-styles\";\n\nimport range from \"lodash/range\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { staticClasses, useClasses } from \"./Loading.styles\";\n\nexport { staticClasses as loadingClasses };\n\nexport type HvLoadingClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvLoadingProps extends HvBaseProps {\n /** Indicates if the component should be render in a small size. */\n small?: boolean;\n /** The label to be displayed. */\n label?: string | React.ReactNode;\n /** Whether the loading animation is hidden. */\n hidden?: boolean;\n /** Color applied to the bars. */\n color?: HvColorAny;\n classes?: HvLoadingClasses;\n}\n\n/**\n * Loading provides feedback about a process that is taking place in the application.\n */\nexport const HvLoading = (props: HvLoadingProps) => {\n const {\n color,\n hidden,\n small,\n label,\n classes: classesProp,\n className,\n ...others\n } = useDefaultProps(\"HvLoading\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const size = small ? \"small\" : \"regular\";\n const colorVariant = color ? \"Color\" : \"\";\n const variant = `${size}${colorVariant}` as const;\n\n const inline = {\n backgroundColor: getColor(color, small ? \"secondary\" : \"brand\"),\n };\n return (\n <div\n hidden={!!hidden}\n className={cx(\n classes.root,\n {\n [classes.hidden]: hidden,\n },\n className\n )}\n {...others}\n >\n <div className={classes.barContainer}>\n {range(0, 3).map((e) => (\n <div\n key={e}\n style={inline}\n className={cx(classes.loadingBar, classes[variant])}\n />\n ))}\n </div>\n {label && (\n <HvTypography variant=\"caption1\" className={classes.label}>\n {label}\n </HvTypography>\n )}\n </div>\n );\n};\n"],"names":["HvLoading","props","color","hidden","small","label","classes","classesProp","className","others","useDefaultProps","cx","useClasses","size","colorVariant","variant","inline","backgroundColor","getColor","root","children","_jsx","barContainer","range","map","e","style","loadingBar","HvTypography"],"mappings":";;;;;;;AA8BaA,MAAAA,YAAYA,CAACC,UAA0B;AAC5C,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,aAAaT,KAAK;AAEhC,QAAA;AAAA,IAAEK;AAAAA,IAASK;AAAAA,EAAAA,IAAOC,WAAWL,WAAW;AAExCM,QAAAA,OAAOT,QAAQ,UAAU;AACzBU,QAAAA,eAAeZ,QAAQ,UAAU;AACvC,QAAMa,UAAW,GAAEF,IAAK,GAAEC,YAAa;AAEvC,QAAME,SAAS;AAAA,IACbC,iBAAiBC,SAAShB,OAAOE,QAAQ,cAAc,OAAO;AAAA,EAAA;AAEhE,8BACE,OAAA;AAAA,IACED,QAAQ,CAAC,CAACA;AAAAA,IACVK,WAAWG,GACTL,QAAQa,MACR;AAAA,MACE,CAACb,QAAQH,MAAM,GAAGA;AAAAA,OAEpBK,SACF;AAAA,IAAE,GACEC;AAAAA,IAAMW,WAEVC,oBAAA,OAAA;AAAA,MAAKb,WAAWF,QAAQgB;AAAAA,MAAaF,UAClCG,MAAM,GAAG,CAAC,EAAEC,IAAKC,CAAAA,0BAChB,OAAA;AAAA,QAEEC,OAAOV;AAAAA,QACPR,WAAWG,GAAGL,QAAQqB,YAAYrB,QAAQS,OAAO,CAAC;AAAA,MAAE,GAF/CU,CAGN,CACF;AAAA,IAAA,CACE,GACJpB,SACCgB,oBAACO,cAAY;AAAA,MAACb,SAAQ;AAAA,MAAWP,WAAWF,QAAQD;AAAAA,MAAMe,UACvDf;AAAAA,IAAAA,CACW,CACf;AAAA,EAAA,CACE;AAET;"}
1
+ {"version":3,"file":"Loading.js","sources":["../../../../src/components/Loading/Loading.tsx"],"sourcesContent":["import { HvColorAny, getColor } from \"@hitachivantara/uikit-styles\";\n\nimport range from \"lodash/range\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvTypography } from \"@core/components/Typography\";\n\nimport { staticClasses, useClasses } from \"./Loading.styles\";\n\nexport { staticClasses as loadingClasses };\n\nexport type HvLoadingClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvLoadingProps extends HvBaseProps {\n /** Indicates if the component should be render in a small size. */\n small?: boolean;\n /** The label to be displayed. */\n label?: string | React.ReactNode;\n /** Whether the loading animation is hidden. */\n hidden?: boolean;\n /** Color applied to the bars. */\n color?: HvColorAny;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvLoadingClasses;\n}\n\n/**\n * Loading provides feedback about a process that is taking place in the application.\n */\nexport const HvLoading = (props: HvLoadingProps) => {\n const {\n color,\n hidden,\n small,\n label,\n classes: classesProp,\n className,\n ...others\n } = useDefaultProps(\"HvLoading\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const size = small ? \"small\" : \"regular\";\n const colorVariant = color ? \"Color\" : \"\";\n const variant = `${size}${colorVariant}` as const;\n\n const inline = {\n backgroundColor: getColor(color, small ? \"secondary\" : \"brand\"),\n };\n return (\n <div\n hidden={!!hidden}\n className={cx(\n classes.root,\n {\n [classes.hidden]: hidden,\n },\n className\n )}\n {...others}\n >\n <div className={classes.barContainer}>\n {range(0, 3).map((e) => (\n <div\n key={e}\n style={inline}\n className={cx(classes.loadingBar, classes[variant])}\n />\n ))}\n </div>\n {label && (\n <HvTypography variant=\"caption1\" className={classes.label}>\n {label}\n </HvTypography>\n )}\n </div>\n );\n};\n"],"names":["HvLoading","props","color","hidden","small","label","classes","classesProp","className","others","useDefaultProps","cx","useClasses","size","colorVariant","variant","inline","backgroundColor","getColor","root","children","_jsx","barContainer","range","map","e","style","loadingBar","HvTypography"],"mappings":";;;;;;;AA+BaA,MAAAA,YAAYA,CAACC,UAA0B;AAC5C,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,aAAaT,KAAK;AAEhC,QAAA;AAAA,IAAEK;AAAAA,IAASK;AAAAA,EAAAA,IAAOC,WAAWL,WAAW;AAExCM,QAAAA,OAAOT,QAAQ,UAAU;AACzBU,QAAAA,eAAeZ,QAAQ,UAAU;AACvC,QAAMa,UAAW,GAAEF,IAAK,GAAEC,YAAa;AAEvC,QAAME,SAAS;AAAA,IACbC,iBAAiBC,SAAShB,OAAOE,QAAQ,cAAc,OAAO;AAAA,EAAA;AAEhE,8BACE,OAAA;AAAA,IACED,QAAQ,CAAC,CAACA;AAAAA,IACVK,WAAWG,GACTL,QAAQa,MACR;AAAA,MACE,CAACb,QAAQH,MAAM,GAAGA;AAAAA,OAEpBK,SACF;AAAA,IAAE,GACEC;AAAAA,IAAMW,WAEVC,oBAAA,OAAA;AAAA,MAAKb,WAAWF,QAAQgB;AAAAA,MAAaF,UAClCG,MAAM,GAAG,CAAC,EAAEC,IAAKC,CAAAA,0BAChB,OAAA;AAAA,QAEEC,OAAOV;AAAAA,QACPR,WAAWG,GAAGL,QAAQqB,YAAYrB,QAAQS,OAAO,CAAC;AAAA,MAAE,GAF/CU,CAGN,CACF;AAAA,IAAA,CACE,GACJpB,SACCgB,oBAACO,cAAY;AAAA,MAACb,SAAQ;AAAA,MAAWP,WAAWF,QAAQD;AAAAA,MAAMe,UACvDf;AAAAA,IAAAA,CACW,CACf;AAAA,EAAA,CACE;AAET;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","sources":["../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\n\nimport { RadioProps as MuiRadioProps } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvBaseRadio } from \"@core/components/BaseRadio\";\nimport {\n HvWarningText,\n HvLabelProps,\n isInvalid,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Radio.styles\";\n\nexport { staticClasses as radioClasses };\n\nexport type HvRadioClasses = ExtractNames<typeof useClasses>;\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\">,\n HvBaseProps<HTMLButtonElement, \"onChange\" | \"color\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * Id to be applied to the form element root node.\n */\n id?: string;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided.\n */\n label?: React.ReactNode;\n /**\n * @ignore\n */\n \"aria-label\"?: string;\n /**\n * @ignore\n */\n \"aria-labelledby\"?: string;\n /**\n * @ignore\n */\n \"aria-describedby\"?: string;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n */\n status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /**\n * @ignore\n */\n onBlur?: (event: React.FocusEvent<any>) => void;\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user <b>may select just one option</b> to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = (props: HvRadioProps) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic = false,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = useDefaultProps(\"HvRadio\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvradio\");\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <HvBaseRadio\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={cx(classes.radio, { [classes.invalidRadio]: isStateInvalid })}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {hasLabel ? (\n <div\n className={cx(classes.container, {\n [classes.disabled]: disabled,\n [classes.focusVisible]: !!(focusVisible && label),\n [classes.invalidContainer]: isStateInvalid,\n })}\n >\n {radio}\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n </div>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")} disableBorder>\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n};\n"],"names":["HvRadio","props","classes","classesProp","className","id","name","value","required","readOnly","disabled","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","labelProps","checked","defaultChecked","onChange","status","statusMessage","ariaErrorMessage","semantic","inputProps","onFocusVisible","onBlur","others","useDefaultProps","cx","useClasses","elementId","useUniqueId","focusVisible","setFocusVisible","useState","onFocusVisibleCallback","useCallback","evt","onBlurCallback","isChecked","setIsChecked","useControlled","Boolean","onLocalChange","newChecked","canShowError","undefined","hasLabel","isStateInvalid","isInvalid","errorMessageId","setId","radio","HvBaseRadio","invalidRadio","HvFormElement","root","children","_jsxs","container","invalidContainer","_jsx","HvLabel","htmlFor","HvWarningText","disableBorder"],"mappings":";;;;;;;;;;;;;AA2JaA,MAAAA,UAAUA,CAACC,UAAwB;AACxC,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA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ACL,CAAC;AAAA,IACC,CAAA,IAELqC,OAEDP,oCACEmB,eAAa;AAAA,MAAC3D,IAAI8C,MAAMrB,WAAW,OAAO;AAAA,MAAGmC,eAAa;AAAA,MAAAR,UACxDrC;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACY;AAEnB;"}
1
+ {"version":3,"file":"Radio.js","sources":["../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\n\nimport { RadioProps as MuiRadioProps } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvBaseRadio } from \"@core/components/BaseRadio\";\nimport {\n HvWarningText,\n HvLabelProps,\n isInvalid,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Radio.styles\";\n\nexport { staticClasses as radioClasses };\n\nexport type HvRadioClasses = ExtractNames<typeof useClasses>;\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\">,\n HvBaseProps<HTMLButtonElement, \"onChange\" | \"color\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n */\n status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /** @ignore */\n ref?: MuiRadioProps[\"ref\"];\n /** @ignore */\n component?: MuiRadioProps[\"component\"];\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user <b>may select just one option</b> to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = (props: HvRadioProps) => {\n const {\n classes: classesProp,\n className,\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic = false,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = useDefaultProps(\"HvRadio\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvradio\");\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <HvBaseRadio\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={cx(classes.radio, { [classes.invalidRadio]: isStateInvalid })}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {hasLabel ? (\n <div\n className={cx(classes.container, {\n [classes.disabled]: disabled,\n [classes.focusVisible]: !!(focusVisible && label),\n [classes.invalidContainer]: isStateInvalid,\n })}\n >\n {radio}\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n </div>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")} disableBorder>\n {statusMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n};\n"],"names":["HvRadio","props","classes","classesProp","className","id","name","value","required","readOnly","disabled","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","labelProps","checked","defaultChecked","onChange","status","statusMessage","ariaErrorMessage","semantic","inputProps","onFocusVisible","onBlur","others","useDefaultProps","cx","useClasses","elementId","useUniqueId","focusVisible","setFocusVisible","useState","onFocusVisibleCallback","useCallback","evt","onBlurCallback","isChecked","setIsChecked","useControlled","Boolean","onLocalChange","newChecked","canShowError","undefined","hasLabel","isStateInvalid","isInvalid","errorMessageId","setId","radio","HvBaseRadio","invalidRadio","HvFormElement","root","children","_jsxs","container","invalidContainer","_jsx","HvLabel","htmlFor","HvWarningText","disableBorder"],"mappings":";;;;;;;;;;;;;AAuIaA,MAAAA,UAAUA,CAACC,UAAwB;AACxC,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnB,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC;AAAAA,IACAC,iBAAi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,CACY,CAChB;AAAA,EAAA,CACY;AAEnB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Snackbar.js","sources":["../../../../src/components/Snackbar/Snackbar.tsx"],"sourcesContent":["import Slide from \"@mui/material/Slide\";\nimport {\n SnackbarCloseReason,\n SnackbarOrigin,\n SnackbarProps as MuiSnackbarProps,\n} from \"@mui/material/Snackbar\";\nimport { Snackbar as MuiSnackbar } from \"@mui/material\";\n\nimport capitalize from \"lodash/capitalize\";\n\nimport { SyntheticEvent } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvActionGeneric } from \"@core/components/ActionsGeneric\";\n\nimport { HvSnackbarContentProps, HvSnackbarContent } from \"./SnackbarContent\";\nimport { staticClasses, useClasses } from \"./Snackbar.styles\";\nimport { HvSnackbarVariant } from \"./types\";\n\nexport { staticClasses as snackbarClasses };\n\nexport type HvSnackbarClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSnackbarProps\n extends Omit<MuiSnackbarProps, \"action\" | \"classes\">,\n Omit<HvBaseProps, \"children\"> {\n /** If true, Snackbar is open. */\n open?: boolean;\n /** Callback fired when the component requests to be closed. Typically onClose is used to set state in the parent component, which is used to control the Snackbar open prop. The reason parameter can optionally be used to control the response to onClose, for example ignoring clickaway. */\n onClose?:\n | ((\n event: Event | SyntheticEvent<any, Event>,\n reason: SnackbarCloseReason\n ) => void)\n | undefined;\n /** The message to display. */\n label?: React.ReactNode;\n /** The anchor of the Snackbar. vertical: \"top\", \"bottom\" | horizontal: \"left\",\"center\",\"right. It defines where the snackbar will end his animation */\n anchorOrigin?: SnackbarOrigin;\n /** The number of milliseconds to wait before automatically calling the onClose function. onClose should then set the state of the open prop to hide the Snackbar */\n autoHideDuration?: number;\n /** Variant of the snackbar. */\n variant?: HvSnackbarVariant;\n /** Custom icon to replace the variant default. */\n customIcon?: React.ReactNode;\n /** Controls if the associated icon to the variant should be shown. */\n showIcon?: boolean;\n /** Action to display. */\n action?: React.ReactNode | HvActionGeneric;\n /** The callback function ran when an action is triggered, receiving `action` as param */\n actionCallback?: (\n event: React.SyntheticEvent,\n id: string,\n action: HvActionGeneric\n ) => void;\n /** Duration of transition in milliseconds. */\n transitionDuration?: number;\n /** Direction of slide transition. */\n transitionDirection?: \"up\" | \"down\" | \"left\" | \"right\";\n /** Custom offset from top/bottom of the page, in px. */\n offset?: number;\n /** Others applied to the content of the snackbar. */\n snackbarContentProps?: HvSnackbarContentProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSnackbarClasses;\n}\n\nconst transLeft = (props) => <Slide {...props} direction=\"left\" />;\nconst transRight = (props) => <Slide {...props} direction=\"right\" />;\nconst transUp = (props) => <Slide {...props} direction=\"up\" />;\nconst transDown = (props) => <Slide {...props} direction=\"down\" />;\n\nconst snackBarDirComponent = (direction) => {\n switch (direction) {\n case \"right\":\n return transRight;\n case \"up\":\n return transUp;\n case \"down\":\n return transDown;\n case \"left\":\n default:\n return transLeft;\n }\n};\n\n/**\n * A Snackbar provides brief messages about app processes.\n * It is dismissed automatically after a given interval.\n *\n * Snackbar can be built with two different components.\n * One is the HvSnackbar, which wraps all the positioning, transition, auto hide, etc.\n * The other is the HvSnackbarContent, which allows a finer control and customization of the content of the Snackbar.\n */\nexport const HvSnackbar = ({\n classes: classesProp,\n className,\n id,\n open = false,\n onClose,\n label = \"\",\n anchorOrigin = { vertical: \"top\", horizontal: \"right\" },\n autoHideDuration = 5000,\n variant = \"default\",\n showIcon = false,\n customIcon = null,\n action = null,\n actionCallback,\n transitionDuration = 300,\n transitionDirection = \"left\",\n offset = 60,\n snackbarContentProps,\n ...others\n}: HvSnackbarProps) => {\n const { classes } = useClasses(classesProp);\n\n const anchorOriginOffset = {\n anchorOriginTop: {\n top: `${offset}px`,\n },\n anchorOriginBottom: {\n bottom: `${offset}px`,\n },\n };\n\n return (\n <MuiSnackbar\n style={\n anchorOriginOffset[`anchorOrigin${capitalize(anchorOrigin.vertical)}`]\n }\n classes={classes}\n className={className}\n id={id}\n anchorOrigin={anchorOrigin}\n open={open}\n onClose={onClose}\n autoHideDuration={autoHideDuration}\n transitionDuration={transitionDuration}\n TransitionComponent={snackBarDirComponent(transitionDirection)}\n {...others}\n >\n <HvSnackbarContent\n id={setId(id, \"content\")}\n label={label}\n variant={variant}\n customIcon={customIcon}\n showIcon={showIcon}\n action={action}\n actionCallback={actionCallback}\n {...snackbarContentProps}\n />\n </MuiSnackbar>\n );\n};\n"],"names":["transLeft","props","_jsx","Slide","direction","transRight","transUp","transDown","snackBarDirComponent","HvSnackbar","classes","classesProp","className","id","open","onClose","label","anchorOrigin","vertical","horizontal","autoHideDuration","variant","showIcon","customIcon","action","actionCallback","transitionDuration","transitionDirection","offset","snackbarContentProps","others","useClasses","anchorOriginOffset","anchorOriginTop","top","anchorOriginBottom","bottom","MuiSnackbar","style","capitalize","TransitionComponent","children","HvSnackbarContent","setId"],"mappings":";;;;;;;;AAqEA,MAAMA,YAAaC,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAM,CAAE;AACjE,MAAMC,aAAcJ,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAO,CAAE;AACnE,MAAME,UAAWL,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAI,CAAE;AAC7D,MAAMG,YAAaN,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAM,CAAE;AAEjE,MAAMI,uBAAwBJ,CAAc,cAAA;AAC1C,UAAQA,WAAS;AAAA,IACf,KAAK;AACIC,aAAAA;AAAAA,IACT,KAAK;AACIC,aAAAA;AAAAA,IACT,KAAK;AACIC,aAAAA;AAAAA,IACT,KAAK;AAAA,IACL;AACSP,aAAAA;AAAAA,EACX;AACF;AAUO,MAAMS,aAAaA,CAAC;AAAA,EACzBC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC,OAAO;AAAA,EACPC;AAAAA,EACAC,QAAQ;AAAA,EACRC,eAAe;AAAA,IAAEC,UAAU;AAAA,IAAOC,YAAY;AAAA,EAAQ;AAAA,EACtDC,mBAAmB;AAAA,EACnBC,UAAU;AAAA,EACVC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,SAAS;AAAA,EACTC;AAAAA,EACAC,qBAAqB;AAAA,EACrBC,sBAAsB;AAAA,EACtBC,SAAS;AAAA,EACTC;AAAAA,EACA,GAAGC;AACY,MAAM;AACf,QAAA;AAAA,IAAEpB;AAAAA,EAAAA,IAAYqB,WAAWpB,WAAW;AAE1C,QAAMqB,qBAAqB;AAAA,IACzBC,iBAAiB;AAAA,MACfC,KAAM,GAAEN,MAAO;AAAA,IACjB;AAAA,IACAO,oBAAoB;AAAA,MAClBC,QAAS,GAAER,MAAO;AAAA,IACpB;AAAA,EAAA;AAGF,6BACGS,UAAW;AAAA,IACVC,OACEN,mBAAoB,eAAcO,WAAWtB,aAAaC,QAAQ,CAAE,EAAC;AAAA,IAEvER;AAAAA,IACAE;AAAAA,IACAC;AAAAA,IACAI;AAAAA,IACAH;AAAAA,IACAC;AAAAA,IACAK;AAAAA,IACAM;AAAAA,IACAc,qBAAqBhC,qBAAqBmB,mBAAmB;AAAA,IAAE,GAC3DG;AAAAA,IAAMW,8BAETC,mBAAiB;AAAA,MAChB7B,IAAI8B,MAAM9B,IAAI,SAAS;AAAA,MACvBG;AAAAA,MACAK;AAAAA,MACAE;AAAAA,MACAD;AAAAA,MACAE;AAAAA,MACAC;AAAAA,MAA+B,GAC3BI;AAAAA,IAAAA,CACL;AAAA,EAAA,CACU;AAEjB;"}
1
+ {"version":3,"file":"Snackbar.js","sources":["../../../../src/components/Snackbar/Snackbar.tsx"],"sourcesContent":["import Slide from \"@mui/material/Slide\";\nimport {\n SnackbarCloseReason,\n SnackbarOrigin,\n SnackbarProps as MuiSnackbarProps,\n} from \"@mui/material/Snackbar\";\nimport { Snackbar as MuiSnackbar } from \"@mui/material\";\n\nimport capitalize from \"lodash/capitalize\";\n\nimport { SyntheticEvent } from \"react\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\nimport { HvActionGeneric } from \"@core/components/ActionsGeneric\";\n\nimport { HvSnackbarContentProps, HvSnackbarContent } from \"./SnackbarContent\";\nimport { staticClasses, useClasses } from \"./Snackbar.styles\";\nimport { HvSnackbarVariant } from \"./types\";\n\nexport { staticClasses as snackbarClasses };\n\nexport type HvSnackbarClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSnackbarProps\n extends Omit<MuiSnackbarProps, \"action\" | \"classes\">,\n Omit<HvBaseProps, \"children\"> {\n /** If true, Snackbar is open. */\n open?: boolean;\n /** Callback fired when the component requests to be closed. Typically onClose is used to set state in the parent component, which is used to control the Snackbar open prop. The reason parameter can optionally be used to control the response to onClose, for example ignoring clickaway. */\n onClose?:\n | ((\n event: Event | SyntheticEvent<any, Event>,\n reason: SnackbarCloseReason\n ) => void)\n | undefined;\n /** The message to display. */\n label?: React.ReactNode;\n /** The anchor of the Snackbar. vertical: \"top\", \"bottom\" | horizontal: \"left\",\"center\",\"right. It defines where the snackbar will end his animation */\n anchorOrigin?: SnackbarOrigin;\n /** The number of milliseconds to wait before automatically calling the onClose function. onClose should then set the state of the open prop to hide the Snackbar */\n autoHideDuration?: number;\n /** Variant of the snackbar. */\n variant?: HvSnackbarVariant;\n /** Custom icon to replace the variant default. */\n customIcon?: React.ReactNode;\n /** Controls if the associated icon to the variant should be shown. */\n showIcon?: boolean;\n /** Action to display. */\n action?: React.ReactNode | HvActionGeneric;\n /** The callback function ran when an action is triggered, receiving `action` as param */\n actionCallback?: (\n event: React.SyntheticEvent,\n id: string,\n action: HvActionGeneric\n ) => void;\n /** Duration of transition in milliseconds. */\n transitionDuration?: number;\n /** Direction of slide transition. */\n transitionDirection?: \"up\" | \"down\" | \"left\" | \"right\";\n /** Custom offset from top/bottom of the page, in px. */\n offset?: number;\n /** Others applied to the content of the snackbar. */\n snackbarContentProps?: HvSnackbarContentProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvSnackbarClasses;\n /** @ignore */\n ref?: MuiSnackbarProps[\"ref\"];\n}\n\nconst transLeft = (props) => <Slide {...props} direction=\"left\" />;\nconst transRight = (props) => <Slide {...props} direction=\"right\" />;\nconst transUp = (props) => <Slide {...props} direction=\"up\" />;\nconst transDown = (props) => <Slide {...props} direction=\"down\" />;\n\nconst snackBarDirComponent = (direction) => {\n switch (direction) {\n case \"right\":\n return transRight;\n case \"up\":\n return transUp;\n case \"down\":\n return transDown;\n case \"left\":\n default:\n return transLeft;\n }\n};\n\n/**\n * A Snackbar provides brief messages about app processes.\n * It is dismissed automatically after a given interval.\n *\n * Snackbar can be built with two different components.\n * One is the HvSnackbar, which wraps all the positioning, transition, auto hide, etc.\n * The other is the HvSnackbarContent, which allows a finer control and customization of the content of the Snackbar.\n */\nexport const HvSnackbar = ({\n classes: classesProp,\n className,\n id,\n open = false,\n onClose,\n label = \"\",\n anchorOrigin = { vertical: \"top\", horizontal: \"right\" },\n autoHideDuration = 5000,\n variant = \"default\",\n showIcon = false,\n customIcon = null,\n action = null,\n actionCallback,\n transitionDuration = 300,\n transitionDirection = \"left\",\n offset = 60,\n snackbarContentProps,\n ...others\n}: HvSnackbarProps) => {\n const { classes } = useClasses(classesProp);\n\n const anchorOriginOffset = {\n anchorOriginTop: {\n top: `${offset}px`,\n },\n anchorOriginBottom: {\n bottom: `${offset}px`,\n },\n };\n\n return (\n <MuiSnackbar\n style={\n anchorOriginOffset[`anchorOrigin${capitalize(anchorOrigin.vertical)}`]\n }\n classes={classes}\n className={className}\n id={id}\n anchorOrigin={anchorOrigin}\n open={open}\n onClose={onClose}\n autoHideDuration={autoHideDuration}\n transitionDuration={transitionDuration}\n TransitionComponent={snackBarDirComponent(transitionDirection)}\n {...others}\n >\n <HvSnackbarContent\n id={setId(id, \"content\")}\n label={label}\n variant={variant}\n customIcon={customIcon}\n showIcon={showIcon}\n action={action}\n actionCallback={actionCallback}\n {...snackbarContentProps}\n />\n </MuiSnackbar>\n );\n};\n"],"names":["transLeft","props","_jsx","Slide","direction","transRight","transUp","transDown","snackBarDirComponent","HvSnackbar","classes","classesProp","className","id","open","onClose","label","anchorOrigin","vertical","horizontal","autoHideDuration","variant","showIcon","customIcon","action","actionCallback","transitionDuration","transitionDirection","offset","snackbarContentProps","others","useClasses","anchorOriginOffset","anchorOriginTop","top","anchorOriginBottom","bottom","MuiSnackbar","style","capitalize","TransitionComponent","children","HvSnackbarContent","setId"],"mappings":";;;;;;;;AAuEA,MAAMA,YAAaC,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAM,CAAE;AACjE,MAAMC,aAAcJ,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAO,CAAE;AACnE,MAAME,UAAWL,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAI,CAAE;AAC7D,MAAMG,YAAaN,CAAUC,UAAAA,oBAACC,OAAK;AAAA,EAAA,GAAKF;AAAAA,EAAOG,WAAU;AAAM,CAAE;AAEjE,MAAMI,uBAAwBJ,CAAc,cAAA;AAC1C,UAAQA,WAAS;AAAA,IACf,KAAK;AACIC,aAAAA;AAAAA,IACT,KAAK;AACIC,aAAAA;AAAAA,IACT,KAAK;AACIC,aAAAA;AAAAA,IACT,KAAK;AAAA,IACL;AACSP,aAAAA;AAAAA,EACX;AACF;AAUO,MAAMS,aAAaA,CAAC;AAAA,EACzBC,SAASC;AAAAA,EACTC;AAAAA,EACAC;AAAAA,EACAC,OAAO;AAAA,EACPC;AAAAA,EACAC,QAAQ;AAAA,EACRC,eAAe;AAAA,IAAEC,UAAU;AAAA,IAAOC,YAAY;AAAA,EAAQ;AAAA,EACtDC,mBAAmB;AAAA,EACnBC,UAAU;AAAA,EACVC,WAAW;AAAA,EACXC,aAAa;AAAA,EACbC,SAAS;AAAA,EACTC;AAAAA,EACAC,qBAAqB;AAAA,EACrBC,sBAAsB;AAAA,EACtBC,SAAS;AAAA,EACTC;AAAAA,EACA,GAAGC;AACY,MAAM;AACf,QAAA;AAAA,IAAEpB;AAAAA,EAAAA,IAAYqB,WAAWpB,WAAW;AAE1C,QAAMqB,qBAAqB;AAAA,IACzBC,iBAAiB;AAAA,MACfC,KAAM,GAAEN,MAAO;AAAA,IACjB;AAAA,IACAO,oBAAoB;AAAA,MAClBC,QAAS,GAAER,MAAO;AAAA,IACpB;AAAA,EAAA;AAGF,6BACGS,UAAW;AAAA,IACVC,OACEN,mBAAoB,eAAcO,WAAWtB,aAAaC,QAAQ,CAAE,EAAC;AAAA,IAEvER;AAAAA,IACAE;AAAAA,IACAC;AAAAA,IACAI;AAAAA,IACAH;AAAAA,IACAC;AAAAA,IACAK;AAAAA,IACAM;AAAAA,IACAc,qBAAqBhC,qBAAqBmB,mBAAmB;AAAA,IAAE,GAC3DG;AAAAA,IAAMW,8BAETC,mBAAiB;AAAA,MAChB7B,IAAI8B,MAAM9B,IAAI,SAAS;AAAA,MACvBG;AAAAA,MACAK;AAAAA,MACAE;AAAAA,MACAD;AAAAA,MACAE;AAAAA,MACAC;AAAAA,MAA+B,GAC3BI;AAAAA,IAAAA,CACL;AAAA,EAAA,CACU;AAEjB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\n\nimport { SwitchProps as MuiSwitchProps } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport {\n HvWarningText,\n HvLabelProps,\n HvFormStatus,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { HvBaseSwitch } from \"@core/components/BaseSwitch\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isInvalid } from \"@core/components/Forms/FormElement/validationStates\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Switch.styles\";\n\nexport { staticClasses as switchClasses };\n\nexport type HvSwitchClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSwitchProps\n extends Omit<MuiSwitchProps, \"onChange\" | \"classes\">,\n HvBaseProps<HTMLButtonElement, \"onChange\" | \"color\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the switch.\n */\n classes?: HvSwitchClasses;\n /**\n * Id to be applied to the form element root node.\n */\n id?: string;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * Is up to the application's logic when to consider the submission of this value.\n * Generally it should be used only when the switch is neither unchecked nor indeterminate.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /**\n * @ignore\n */\n \"aria-label\"?: string;\n /**\n * @ignore\n */\n \"aria-labelledby\"?: string;\n /**\n * @ignore\n */\n \"aria-describedby\"?: string;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * If `true` the switch is selected, if set to `false` the switch is not selected.\n *\n * When defined the switch state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the switch.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the switch is pressed.\n */\n onChange?: (event: React.ChangeEvent, checked: boolean, value: any) => void;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * A Switch is <b>binary</b> and work as a digital on/off button.\n *\n * Use when two states are <b>opposite</b> and to trigger immediate\n * changes in the system.\n */\nexport const HvSwitch = (props: HvSwitchProps) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n\n checked,\n defaultChecked = false,\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n inputProps,\n\n ...others\n } = useDefaultProps(\"HvSwitch\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvswitch\");\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const onLocalChange = useCallback(\n (evt, newChecked) => {\n setIsChecked(() => {\n // this will only run if uncontrolled\n if (required && !newChecked) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newChecked;\n });\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, required, setIsChecked, setValidationState, value]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = isInvalid(validationState);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n )}\n <div\n className={cx(classes.switchContainer, {\n [classes.invalidSwitch]: isStateInvalid,\n })}\n >\n <HvBaseSwitch\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n {...others}\n />\n </div>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n disableAdornment\n hideText\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n};\n"],"names":["HvSwitch","props","classes","classesProp","className","id","name","value","required","readOnly","disabled","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","labelProps","checked","defaultChecked","onChange","status","statusMessage","ariaErrorMessage","inputProps","others","useDefaultProps","cx","useClasses","elementId","useUniqueId","isChecked","setIsChecked","useControlled","Boolean","validationState","setValidationState","validationMessage","onLocalChange","useCallback","evt","newChecked","canShowError","undefined","isStateInvalid","isInvalid","errorMessageId","setId","HvFormElement","root","children","_jsx","HvLabel","htmlFor","switchContainer","invalidSwitch","HvBaseSwitch","HvWarningText","error","disableBorder","disableAdornment","hideText"],"mappings":";;;;;;;;;;;;;AAwIaA,MAAAA,WAAWA,CAACC,UAAyB;AAC1C,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnB,oBAAoBC;AAAAA,IACpBC;AAAAA,IAEAC;AAAAA,IACAC,iBAAiB;AAAA,IAEjBC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IAEA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,YAAYvB,KAAK;AAE/B,QAAA;AAAA,IAAEC;AAAAA,IAASuB;AAAAA,EAAAA,IAAOC,WAAWvB,WAAW;AAExCwB,QAAAA,YAAYC,YAAYvB,IAAI,UAAU;AAEtC,QAAA,CAACwB,WAAWC,YAAY,IAAIC,cAChCf,SACAgB,QAAQf,cAAc,CACxB;AAEA,QAAM,CAACgB,iBAAiBC,kBAAkB,IAAIH,cAC5CZ,QACA,SACF;AAEA,QAAM,CAACgB,iBAAiB,IAAIJ,cAAcX,eAAe,UAAU;AAEnE,QAAMgB,gBAAgBC,YACpB,CAACC,KAAKC,eAAe;AACnBT,iBAAa,MAAM;AAEbtB,UAAAA,YAAY,CAAC+B,YAAY;AAC3BL,2BAAmB,SAAS;AAAA,MAAA,OACvB;AACLA,2BAAmB,OAAO;AAAA,MAC5B;AAEOK,aAAAA;AAAAA,IAAAA,CACR;AAEUD,yCAAAA,KAAKC,YAAYhC;AAAAA,EAAK,GAEnC,CAACW,UAAUV,UAAUsB,cAAcI,oBAAoB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AAA,MACZlD,IAAIwC,MAAMlB,WAAW,OAAO;AAAA,MAC5BvB,WAAWF,QAAQsD;AAAAA,MACnBC,eAAa;AAAA,MACbC,kBAAgB;AAAA,MAChBC,UAAQ;AAAA,MAAAX,UAEPb;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACY;AAEnB;"}
1
+ {"version":3,"file":"Switch.js","sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\n\nimport { SwitchProps as MuiSwitchProps } from \"@mui/material\";\n\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport {\n HvWarningText,\n HvLabelProps,\n HvFormStatus,\n HvFormElement,\n HvLabel,\n} from \"@core/components/Forms\";\nimport { HvBaseSwitch } from \"@core/components/BaseSwitch\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { isInvalid } from \"@core/components/Forms/FormElement/validationStates\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./Switch.styles\";\n\nexport { staticClasses as switchClasses };\n\nexport type HvSwitchClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvSwitchProps\n extends Omit<MuiSwitchProps, \"onChange\" | \"classes\">,\n HvBaseProps<HTMLButtonElement, \"onChange\" | \"color\"> {\n /**\n * A Jss Object used to override or extend the styles applied to the switch.\n */\n classes?: HvSwitchClasses;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * Is up to the application's logic when to consider the submission of this value.\n * Generally it should be used only when the switch is neither unchecked nor indeterminate.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be inputted via inputProps.\n */\n label?: React.ReactNode;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n */\n required?: boolean;\n /**\n * If `true` the switch is selected, if set to `false` the switch is not selected.\n *\n * When defined the switch state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to `checked`, depending of the values of both `required` and `checked`.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when the validation status is \"invalid\".\n *\n * Defaults to \"Required\" when the status is uncontrolled and no `aria-errormessage` is provided.\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the switch.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the switch is pressed.\n */\n onChange?: (event: React.ChangeEvent, checked: boolean, value: any) => void;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /** @ignore */\n ref?: MuiSwitchProps[\"ref\"];\n /** @ignore */\n component?: MuiSwitchProps[\"component\"];\n}\n\n/**\n * A Switch is <b>binary</b> and work as a digital on/off button.\n *\n * Use when two states are <b>opposite</b> and to trigger immediate\n * changes in the system.\n */\nexport const HvSwitch = (props: HvSwitchProps) => {\n const {\n classes: classesProp,\n className,\n\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n\n checked,\n defaultChecked = false,\n\n onChange,\n\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n inputProps,\n\n ...others\n } = useDefaultProps(\"HvSwitch\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvswitch\");\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const [validationState, setValidationState] = useControlled(\n status,\n \"standBy\"\n );\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n\n const onLocalChange = useCallback(\n (evt, newChecked) => {\n setIsChecked(() => {\n // this will only run if uncontrolled\n if (required && !newChecked) {\n setValidationState(\"invalid\");\n } else {\n setValidationState(\"valid\");\n }\n\n return newChecked;\n });\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, required, setIsChecked, setValidationState, value]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = isInvalid(validationState);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(classes.root, className)}\n >\n {label && (\n <HvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={classes.label}\n {...labelProps}\n />\n )}\n <div\n className={cx(classes.switchContainer, {\n [classes.invalidSwitch]: isStateInvalid,\n })}\n >\n <HvBaseSwitch\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n {...others}\n />\n </div>\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n disableAdornment\n hideText\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n};\n"],"names":["HvSwitch","props","classes","classesProp","className","id","name","value","required","readOnly","disabled","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","labelProps","checked","defaultChecked","onChange","status","statusMessage","ariaErrorMessage","inputProps","others","useDefaultProps","cx","useClasses","elementId","useUniqueId","isChecked","setIsChecked","useControlled","Boolean","validationState","setValidationState","validationMessage","onLocalChange","useCallback","evt","newChecked","canShowError","undefined","isStateInvalid","isInvalid","errorMessageId","setId","HvFormElement","root","children","_jsx","HvLabel","htmlFor","switchContainer","invalidSwitch","HvBaseSwitch","HvWarningText","error","disableBorder","disableAdornment","hideText"],"mappings":";;;;;;;;;;;;;AAwHaA,MAAAA,WAAWA,CAACC,UAAyB;AAC1C,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IAEXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnB,oBAAoBC;AAAAA,IACpBC;AAAAA,IAEAC;AAAAA,IACAC,iBAAiB;AAAA,IAEjBC;AAAAA,IAEAC;AAAAA,IACAC;AAAAA,IACA,qBAAqBC;AAAAA,IAErBC;AAAAA,IAEA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,YAAYvB,KAAK;AAE/B,QAAA;AAAA,IAAEC;AAAAA,IAASuB;AAAAA,EAAAA,IAAOC,WAAWvB,WAAW;AAExCwB,QAAAA,YAAYC,YAAYvB,IAAI,UAAU;AAEtC,QAAA,CAACwB,WAAWC,YAAY,IAAIC,cAChCf,SACAgB,QAAQf,cAAc,CACxB;AAEA,QAAM,CAACgB,iBAAiBC,kBAAkB,IAAIH,cAC5CZ,QACA,SACF;AAEA,Q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A,QACAI;AAAAA,QACAD;AAAAA,QACAD;AAAAA,QACAU,UAAUkB;AAAAA,QACV7B;AAAAA,QACAS,SAASa;AAAAA,QACTP,YAAY;AAAA,UACV,gBAAgBoB,iBAAiB,OAAOD;AAAAA,UACxC,qBAAqBG;AAAAA,UACrB,cAAchC;AAAAA,UACd,mBAAmBC;AAAAA,UACnB,oBAAoBC;AAAAA,UACpB,GAAGQ;AAAAA,QACL;AAAA,QAAE,GACEC;AAAAA,MAAAA,CACL;AAAA,IAAA,CACE,GACJiB,gBACCS,oBAACM,eAAa;AAAA,MACZlD,IAAIwC,MAAMlB,WAAW,OAAO;AAAA,MAC5BvB,WAAWF,QAAQsD;AAAAA,MACnBC,eAAa;AAAA,MACbC,kBAAgB;AAAA,MAChBC,UAAQ;AAAA,MAAAX,UAEPb;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACY;AAEnB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import { Tabs, TabsProps as MuiTabsProps } from \"@mui/material\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { staticClasses, useClasses } from \"./Tabs.styles\";\n\nexport { staticClasses as tabsClasses };\n\nexport type HvTabsClasses = ExtractNames<typeof useClasses>;\n\n// Mui Tabs props: https://mui.com/material-ui/api/tabs/#props\nexport interface HvTabsProps extends Omit<MuiTabsProps, \"onChange\"> {\n /**\n * The value of the currently selected Tab. If you don't want any selected Tab, you can set this property to `false`.\n */\n value?: any;\n /**\n * Callback fired when the value changes.\n */\n onChange?: (event: React.SyntheticEvent, value: any) => void;\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvTabsClasses;\n}\n\n/**\n * A Tab is a graphical control element that allows multiple documents or panels to be contained within a single window.\n * Tabs can be used as a navigational widget for switching between sets of documents.\n */\nexport const HvTabs = (props: HvTabsProps) => {\n const { classes: classesProp, ...others } = useDefaultProps(\"HvTabs\", props);\n\n const { classes } = useClasses(classesProp);\n\n return (\n <Tabs\n classes={{\n root: classes.root,\n flexContainer: classes.flexContainer,\n indicator: classes.indicator,\n scroller: classes.scroller,\n }}\n TabIndicatorProps={{ children: <div /> }}\n {...others}\n />\n );\n};\n"],"names":["HvTabs","props","classes","classesProp","others","useDefaultProps","useClasses","Tabs","root","flexContainer","indicator","scroller","TabIndicatorProps","children","_jsx"],"mappings":";;;;;AA6BaA,MAAAA,SAASA,CAACC,UAAuB;AACtC,QAAA;AAAA,IAAEC,SAASC;AAAAA,IAAa,GAAGC;AAAAA,EAAAA,IAAWC,gBAAgB,UAAUJ,KAAK;AAErE,QAAA;AAAA,IAAEC;AAAAA,EAAAA,IAAYI,WAAWH,WAAW;AAE1C,6BACGI,MAAI;AAAA,IACHL,SAAS;AAAA,MACPM,MAAMN,QAAQM;AAAAA,MACdC,eAAeP,QAAQO;AAAAA,MACvBC,WAAWR,QAAQQ;AAAAA,MACnBC,UAAUT,QAAQS;AAAAA,IACpB;AAAA,IACAC,mBAAmB;AAAA,MAAEC,UAAUC,oBAAM,OAAA,EAAA;AAAA,IAAE;AAAA,IAAE,GACrCV;AAAAA,EAAAA,CACL;AAEL;"}
1
+ {"version":3,"file":"Tabs.js","sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import { Tabs, TabsProps as MuiTabsProps } from \"@mui/material\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { staticClasses, useClasses } from \"./Tabs.styles\";\n\nexport { staticClasses as tabsClasses };\n\nexport type HvTabsClasses = ExtractNames<typeof useClasses>;\n\n// Mui Tabs props: https://mui.com/material-ui/api/tabs/#props\nexport interface HvTabsProps extends Omit<MuiTabsProps, \"onChange\"> {\n /**\n * The value of the currently selected Tab. If you don't want any selected Tab, you can set this property to `false`.\n */\n value?: any;\n /**\n * Callback fired when the value changes.\n */\n onChange?: (event: React.SyntheticEvent, value: any) => void;\n /**\n * A Jss Object used to override or extend the component styles.\n */\n classes?: HvTabsClasses;\n /** @ignore */\n ref?: MuiTabsProps[\"ref\"];\n /** @ignore */\n component?: MuiTabsProps[\"component\"];\n}\n\n/**\n * A Tab is a graphical control element that allows multiple documents or panels to be contained within a single window.\n * Tabs can be used as a navigational widget for switching between sets of documents.\n */\nexport const HvTabs = (props: HvTabsProps) => {\n const { classes: classesProp, ...others } = useDefaultProps(\"HvTabs\", props);\n\n const { classes } = useClasses(classesProp);\n\n return (\n <Tabs\n classes={{\n root: classes.root,\n flexContainer: classes.flexContainer,\n indicator: classes.indicator,\n scroller: classes.scroller,\n }}\n TabIndicatorProps={{ children: <div /> }}\n {...others}\n />\n );\n};\n"],"names":["HvTabs","props","classes","classesProp","others","useDefaultProps","useClasses","Tabs","root","flexContainer","indicator","scroller","TabIndicatorProps","children","_jsx"],"mappings":";;;;;AAiCaA,MAAAA,SAASA,CAACC,UAAuB;AACtC,QAAA;AAAA,IAAEC,SAASC;AAAAA,IAAa,GAAGC;AAAAA,EAAAA,IAAWC,gBAAgB,UAAUJ,KAAK;AAErE,QAAA;AAAA,IAAEC;AAAAA,EAAAA,IAAYI,WAAWH,WAAW;AAE1C,6BACGI,MAAI;AAAA,IACHL,SAAS;AAAA,MACPM,MAAMN,QAAQM;AAAAA,MACdC,eAAeP,QAAQO;AAAAA,MACvBC,WAAWR,QAAQQ;AAAAA,MACnBC,UAAUT,QAAQS;AAAAA,IACpB;AAAA,IACAC,mBAAmB;AAAA,MAAEC,UAAUC,oBAAM,OAAA,EAAA;AAAA,IAAE;AAAA,IAAE,GACrCV;AAAAA,EAAAA,CACL;AAEL;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tag.js","sources":["../../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import { CSSProperties, useState } from \"react\";\nimport { HvColorAny, theme } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvButton, HvButtonProps } from \"@core/components/Button\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport { staticClasses, useClasses } from \"./Tag.styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nexport { staticClasses as tagClasses };\n\nexport type HvTagClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagProps\n extends Omit<MuiChipProps, \"color\" | \"classes\">,\n HvBaseProps<HTMLDivElement, \"children\"> {\n /** Inline styles to be applied to the root element. */\n style?: CSSProperties;\n /** The label of the tag element. */\n label?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** The type of the tag element. A tag can be of semantic or categoric type. */\n type?: \"semantic\" | \"categorical\";\n /** Background color to be applied to the tag */\n color?: HvColorAny;\n /** Icon used to customize the delete icon in the Chip element */\n deleteIcon?: React.ReactElement;\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component, in order to render the delete icon\n * */\n onDelete?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Callback triggered when any item is clicked. */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** The role of the element with an attributed event. */\n role?: string;\n /** Aria properties to apply to delete button in tag */\n deleteButtonArialLabel?: string; // TODO: fix typo \"ArialLabel\" in next version\n /** Props to apply to delete button */\n deleteButtonProps?: HvButtonProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagClasses;\n}\n\nconst getColor = (customColor, type, colors) => {\n const defaultSemanticColor = theme.colors.neutral_20;\n const defaultCategoricalColor = colors.cat1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor =\n theme.colors[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n colors[customColor] || customColor || defaultCategoricalColor;\n }\n return backgroundColor;\n};\n\n/**\n * A Tag is one word that describes a specific aspect of an asset. A single asset can have\n * multiple tags.\n * Use tags to highlight an item's status for quick recognition and navigation\n * Use color to indicate meanings that users can learn and recognize across products\n *\n * It leverages the Chip component from Material UI\n */\nexport const HvTag = (props: HvTagProps) => {\n const {\n classes: classesProp,\n className,\n style,\n label,\n disabled,\n type = \"semantic\",\n color,\n deleteIcon,\n onDelete,\n onClick,\n role,\n deleteButtonArialLabel = \"Delete tag\",\n deleteButtonProps = {},\n ...others\n } = useDefaultProps(\"HvTag\", props);\n const { colors } = useTheme();\n const { classes, cx, css } = useClasses(classesProp);\n\n const getDeleteIcon = () => {\n const disabledSemanticColor =\n type === \"semantic\" ? \"secondary_60\" : \"base_dark\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n const closeIconStyles = css({\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n \"& svg .color0\": {\n fill: theme.colors[disabled ? disabledSemanticColor : \"base_dark\"],\n },\n });\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n root: classes.button,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n variant=\"secondaryGhost\"\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n className={closeIconStyles}\n color={disabled ? disabledSemanticColor : \"base_dark\"}\n />\n </HvButton>\n );\n };\n\n const inlineStyle = {\n ...style,\n };\n\n const categoricalBackgroundColor =\n type === \"categorical\" ? getColor(color, type, colors) : undefined;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(color, type, {});\n } else if (type === \"categorical\") {\n inlineStyle.backgroundColor = `${categoricalBackgroundColor}30`;\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={cx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled\n ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` }\n : null),\n }}\n classes={{\n root: cx(classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: !!onClick,\n [classes.categorical]: type === \"categorical\",\n [classes.categoricalFocus]: type === \"categorical\" && !disabled,\n [classes.categoricalDisabled]: type === \"categorical\" && disabled,\n }),\n label: classes.label,\n deleteIcon: cx(classes.deleteIcon, {\n [classes.disabledDeleteIcon]: disabled,\n }),\n }}\n deleteIcon={(hasDeleteAction(onDelete) && deleteIcon) || getDeleteIcon()}\n onDelete={getOnDeleteCallback(disabled, onDelete)}\n onClick={disabled ? undefined : onClick}\n role={role || (hasClickAction(onClick) ? \"button\" : undefined)}\n tabIndex={hasDeleteAction(onDelete) ? undefined : 0}\n {...others}\n />\n );\n};\n"],"names":["getColor","customColor","type","colors","defaultSemanticColor","theme","neutral_20","defaultCategoricalColor","cat1","backgroundColor","HvTag","props","classes","classesProp","className","style","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","useDefaultProps","useTheme","cx","css","useClasses","getDeleteIcon","disabledSemanticColor","tabIndex","closeIconStyles","cursor","undefined","height","fill","HvButton","startIcon","tagButton","focusVisible","root","button","variant","children","CloseXS","iconSize","inlineStyle","categoricalBackgroundColor","hover","setHover","useState","Chip","onMouseEnter","onMouseLeave","boxShadow","chipRoot","clickable","categorical","categoricalFocus","categoricalDisabled","disabledDeleteIcon","hasDeleteAction","getOnDeleteCallback","hasClickAction"],"mappings":";;;;;;;;;;;AAiDA,MAAMA,WAAWA,CAACC,aAAaC,MAAMC,WAAW;AACxCC,QAAAA,uBAAuBC,MAAMF,OAAOG;AAC1C,QAAMC,0BAA0BJ,OAAOK;AAEnCC,MAAAA;AAEJ,MAAIP,SAAS,YAAY;AACvBO,sBACEJ,MAAMF,OAAOF,WAAW,KAAKA,eAAeG;AAAAA,EAChD;AACA,MAAIF,SAAS,eAAe;AAExBC,sBAAAA,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A,IACH;AAAA,IACAE,YAAa6C,gBAAgB5C,QAAQ,KAAKD,cAAeY,cAAc;AAAA,IACvEX,UAAU6C,oBAAoBhD,UAAUG,QAAQ;AAAA,IAChDC,SAASJ,WAAWmB,SAAYf;AAAAA,IAChCC,MAAMA,SAAS4C,eAAe7C,OAAO,IAAI,WAAWe;AAAAA,IACpDH,UAAU+B,gBAAgB5C,QAAQ,IAAIgB,SAAY;AAAA,IAAE,GAChDX;AAAAA,EAAAA,CACL;AAEL;"}
1
+ {"version":3,"file":"Tag.js","sources":["../../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { HvColorAny, theme } from \"@hitachivantara/uikit-styles\";\nimport Chip, { ChipProps as MuiChipProps } from \"@mui/material/Chip\";\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport { HvButton, HvButtonProps } from \"@core/components/Button\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { CloseXS } from \"@hitachivantara/uikit-react-icons\";\nimport { staticClasses, useClasses } from \"./Tag.styles\";\nimport { getOnDeleteCallback, hasDeleteAction, hasClickAction } from \"./utils\";\n\nexport { staticClasses as tagClasses };\n\nexport type HvTagClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTagProps\n extends Omit<MuiChipProps, \"color\" | \"classes\">,\n HvBaseProps<HTMLDivElement, \"children\"> {\n /** The label of the tag element. */\n label?: React.ReactNode;\n /** Indicates that the form element is disabled. */\n disabled?: boolean;\n /** The type of the tag element. A tag can be of semantic or categoric type. */\n type?: \"semantic\" | \"categorical\";\n /** Background color to be applied to the tag */\n color?: HvColorAny;\n /** Icon used to customize the delete icon in the Chip element */\n deleteIcon?: React.ReactElement;\n /**\n * The callback fired when the delete icon is pressed.\n * This function has to be provided to the component, in order to render the delete icon\n * */\n onDelete?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Callback triggered when any item is clicked. */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void;\n /** The role of the element with an attributed event. */\n role?: string;\n /** Aria properties to apply to delete button in tag */\n deleteButtonArialLabel?: string; // TODO: fix typo \"ArialLabel\" in next version\n /** Props to apply to delete button */\n deleteButtonProps?: HvButtonProps;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTagClasses;\n /** @ignore */\n ref?: MuiChipProps[\"ref\"];\n /** @ignore */\n component?: MuiChipProps[\"component\"];\n}\n\nconst getColor = (customColor, type, colors) => {\n const defaultSemanticColor = theme.colors.neutral_20;\n const defaultCategoricalColor = colors.cat1;\n\n let backgroundColor;\n\n if (type === \"semantic\") {\n backgroundColor =\n theme.colors[customColor] || customColor || defaultSemanticColor;\n }\n if (type === \"categorical\") {\n backgroundColor =\n colors[customColor] || customColor || defaultCategoricalColor;\n }\n return backgroundColor;\n};\n\n/**\n * A Tag is one word that describes a specific aspect of an asset. A single asset can have\n * multiple tags.\n * Use tags to highlight an item's status for quick recognition and navigation\n * Use color to indicate meanings that users can learn and recognize across products\n *\n * It leverages the Chip component from Material UI\n */\nexport const HvTag = (props: HvTagProps) => {\n const {\n classes: classesProp,\n className,\n style,\n label,\n disabled,\n type = \"semantic\",\n color,\n deleteIcon,\n onDelete,\n onClick,\n role,\n deleteButtonArialLabel = \"Delete tag\",\n deleteButtonProps = {},\n ...others\n } = useDefaultProps(\"HvTag\", props);\n const { colors } = useTheme();\n const { classes, cx, css } = useClasses(classesProp);\n\n const getDeleteIcon = () => {\n const disabledSemanticColor =\n type === \"semantic\" ? \"secondary_60\" : \"base_dark\";\n const { tabIndex = 0 } = deleteButtonProps;\n\n const closeIconStyles = css({\n ...(disabled ? { cursor: \"not-allowed\" } : undefined),\n height: 16,\n \"& svg .color0\": {\n fill: theme.colors[disabled ? disabledSemanticColor : \"base_dark\"],\n },\n });\n return (\n <HvButton\n classes={{\n startIcon: classes.tagButton,\n focusVisible: classes.focusVisible,\n root: classes.button,\n }}\n aria-label={deleteButtonArialLabel}\n tabIndex={tabIndex}\n variant=\"secondaryGhost\"\n {...deleteButtonProps}\n >\n <CloseXS\n iconSize=\"XS\"\n className={closeIconStyles}\n color={disabled ? disabledSemanticColor : \"base_dark\"}\n />\n </HvButton>\n );\n };\n\n const inlineStyle = {\n ...style,\n };\n\n const categoricalBackgroundColor =\n type === \"categorical\" ? getColor(color, type, colors) : undefined;\n\n if (type === \"semantic\") {\n inlineStyle.backgroundColor = getColor(color, type, {});\n } else if (type === \"categorical\") {\n inlineStyle.backgroundColor = `${categoricalBackgroundColor}30`;\n }\n\n const [hover, setHover] = useState(false);\n\n return (\n <Chip\n label={label}\n className={cx(classes.root, className)}\n onMouseEnter={() => {\n setHover(!!onClick);\n }}\n onMouseLeave={() => {\n setHover(false);\n }}\n style={{\n ...(disabled ? null : inlineStyle),\n ...(hover && !disabled\n ? { boxShadow: `0 0 0 1pt ${categoricalBackgroundColor}` }\n : null),\n }}\n classes={{\n root: cx(classes.chipRoot, {\n [classes.disabled]: disabled,\n [classes.clickable]: !!onClick,\n [classes.categorical]: type === \"categorical\",\n [classes.categoricalFocus]: type === \"categorical\" && !disabled,\n [classes.categoricalDisabled]: type === \"categorical\" && disabled,\n }),\n label: classes.label,\n deleteIcon: cx(classes.deleteIcon, {\n [classes.disabledDeleteIcon]: disabled,\n }),\n }}\n deleteIcon={(hasDeleteAction(onDelete) && deleteIcon) || getDeleteIcon()}\n onDelete={getOnDeleteCallback(disabled, onDelete)}\n onClick={disabled ? undefined : onClick}\n role={role || (hasClickAction(onClick) ? \"button\" : undefined)}\n tabIndex={hasDeleteAction(onDelete) ? undefined : 0}\n {...others}\n />\n );\n};\n"],"names":["getColor","customColor","type","colors","defaultSemanticColor","theme","neutral_20","defaultCategoricalColor","cat1","backgroundColor","HvTag","props","classes","classesProp","className","style","label","disabled","color","deleteIcon","onDelete","onClick","role","deleteButtonArialLabel","deleteButtonProps","others","useDefaultProps","useTheme","cx","css","useClasses","getDeleteIcon","disabledSemanticColor","tabIndex","closeIconStyles","cursor","undefined","height","fill","HvButton","startIcon","tagButton","focusVisible","root","button","variant","children","CloseXS","iconSize","inlineStyle","categoricalBackgroundColor","hover","setHover","useState","Chip","onMouseEnter","onMouseLeave","boxShadow","chipRoot","clickable","categorical","categoricalFocus","categoricalDisabled","disabledDeleteIcon","hasDeleteAction","getOnDeleteCallback","hasClickAction"],"mappings":";;;;;;;;;;;AAmDA,MAAMA,WAAWA,CAACC,aAAaC,MAAMC,WAAW;AACxCC,QAAAA,uBAAuBC,MAAMF,OAAOG;AAC1C,QAAMC,0BAA0BJ,OAAOK;AAEnCC,MAAAA;AAEJ,MAAIP,SAAS,YAAY;AACvBO,sBACEJ,MAAMF,OAAOF,WAAW,KAAKA,eAAeG;AAAAA,EAChD;AACA,MAAIF,SAAS,eAAe;AAExBC,sBAAAA,OAAOF,WAAW,KAAKA,eAAeM;AAAAA,EAC1C;AACOE,SAAAA;AACT;AAUaC,MAAAA,QAAQA,CAACC,UAAsB;AACpC,QAAA;AAAA,IACJC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAf,OAAO;AAAA,IACPgB;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,yBAAyB;AAAA,IACzBC,oBAAoB,CAAC;AAAA,IACrB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,SAASf,KAAK;AAC5B,QAAA;AAAA,IAAER;AAAAA,MAAWwB,SAAS;AACtB,QAAA;AAAA,IAAEf;AAAAA,IAASgB;AAAAA,IAAIC;AAAAA,EAAAA,IAAQC,WAAWjB,WAAW;AAEnD,QAAMkB,gBAAgBA,MAAM;AACpBC,UAAAA,wBACJ9B,SAAS,aAAa,iBAAiB;AACnC,UAAA;AAAA,MAAE+B,WAAW;AAAA,IAAMT,IAAAA;AAEzB,UAAMU,kBAAkBL,IAAI;AAAA,MAC1B,GAAIZ,WAAW;AAAA,QAAEkB,QAAQ;A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AA,IACrD;AAAA,IACN;AAAA,IACAtC,SAAS;AAAA,MACP+B,MAAMf,GAAGhB,QAAQ8C,UAAU;AAAA,QACzB,CAAC9C,QAAQK,QAAQ,GAAGA;AAAAA,QACpB,CAACL,QAAQ+C,SAAS,GAAG,CAAC,CAACtC;AAAAA,QACvB,CAACT,QAAQgD,WAAW,GAAG1D,SAAS;AAAA,QAChC,CAACU,QAAQiD,gBAAgB,GAAG3D,SAAS,iBAAiB,CAACe;AAAAA,QACvD,CAACL,QAAQkD,mBAAmB,GAAG5D,SAAS,iBAAiBe;AAAAA,MAAAA,CAC1D;AAAA,MACDD,OAAOJ,QAAQI;AAAAA,MACfG,YAAYS,GAAGhB,QAAQO,YAAY;AAAA,QACjC,CAACP,QAAQmD,kBAAkB,GAAG9C;AAAAA,MAAAA,CAC/B;AAAA,IACH;AAAA,IACAE,YAAa6C,gBAAgB5C,QAAQ,KAAKD,cAAeY,cAAc;AAAA,IACvEX,UAAU6C,oBAAoBhD,UAAUG,QAAQ;AAAA,IAChDC,SAASJ,WAAWmB,SAAYf;AAAAA,IAChCC,MAAMA,SAAS4C,eAAe7C,OAAO,IAAI,WAAWe;AAAAA,IACpDH,UAAU+B,gBAAgB5C,QAAQ,IAAIgB,SAAY;AAAA,IAAE,GAChDX;AAAAA,EAAAA,CACL;AAEL;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sources":["../../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import {\n useCallback,\n useRef,\n useState,\n useMemo,\n useEffect,\n forwardRef,\n} from \"react\";\n\nimport { useForkRef } from \"@mui/material\";\n\nimport isNil from \"lodash/isNil\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport validationStates, {\n isInvalid,\n} from \"@core/components/Forms/FormElement/validationStates\";\nimport { HvValidationMessages } from \"@core/types/forms\";\nimport {\n computeValidationMessage,\n computeValidationState,\n DEFAULT_ERROR_MESSAGES,\n hasBuiltInValidations,\n HvInputValidity,\n validateInput,\n validationTypes,\n} from \"@core/components/BaseInput/validations\";\nimport { HvBaseInput, HvBaseInputProps } from \"@core/components/BaseInput\";\nimport {\n HvCharCounter,\n HvCharCounterProps,\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./TextArea.styles\";\n\nexport { staticClasses as textAreaClasses };\n\nexport type HvTextAreaClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTextAreaProps\n extends Omit<\n HvBaseInputProps,\n \"onChange\" | \"onBlur\" | \"rows\" | \"classes\" | \"onFocus\"\n > {\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: React.ReactNode;\n /**\n * Text between the current char counter and max value.\n */\n middleCountLabel?: string;\n /**\n * An Object containing the various texts associated with the input.\n */\n validationMessages?: HvValidationMessages;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /**\n * The maximum allowed length of the characters, if this value is null no check\n * will be performed.\n */\n maxCharQuantity?: number;\n /**\n * The minimum allowed length of the characters, if this value is null no check\n * will be perform.\n */\n minCharQuantity?: number;\n /**\n * If `true` it should autofocus.\n */\n autoFocus?: boolean;\n /**\n * The number of rows of the text area\n */\n rows?: number;\n /**\n * If `true` the component is resizable.\n */\n resizable?: boolean;\n /**\n * Auto-scroll: automatically scroll to the end on value changes.\n * Will stop if the user scrolls up and resume if scrolled to the bottom.\n */\n autoScroll?: boolean;\n /**\n * If true it isn't possible to pass the `maxCharQuantity`\n */\n blockMax?: boolean;\n /**\n * If `true` the character counter isn't shown even if maxCharQuantity is set.\n */\n hideCounter?: boolean;\n /**\n * Props passed to the char count.\n */\n countCharProps?: Partial<HvCharCounterProps>;\n /**\n * Called back when the value is changed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLTextAreaElement>,\n value: string\n ) => void;\n /**\n * Called back when the value is changed.\n */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement>,\n value: string,\n validationState: HvInputValidity\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement>,\n value: string\n ) => void;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvTextAreaClasses;\n}\n\n/**\n * A text area is a multiline text input box, with an optional character counter when there is a length limit.\n */\nexport const HvTextArea = forwardRef<any, HvTextAreaProps>((props, ref) => {\n const {\n id,\n className,\n classes: classesProp,\n name,\n label,\n description,\n placeholder,\n status,\n statusMessage,\n validationMessages,\n maxCharQuantity,\n minCharQuantity,\n value: valueProp,\n inputRef: inputRefProp,\n rows = 1,\n defaultValue = \"\",\n middleCountLabel = \"/\",\n countCharProps = {},\n inputProps = {},\n required = false,\n readOnly = false,\n disabled = false,\n autoFocus = false,\n resizable = false,\n autoScroll = false,\n hideCounter = false,\n blockMax = false,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n validation,\n onChange,\n onBlur,\n onFocus,\n ...others\n } = useDefaultProps(\"HvTextArea\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvtextarea\");\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef<boolean>(false);\n\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const forkedRef = useForkRef(ref, inputRefProp, inputRef);\n\n const [focused, setFocused] = useState<boolean>(false);\n\n const [autoScrolling, setAutoScrolling] = useState(autoScroll);\n\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\"\n );\n\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isStateInvalid = isInvalid(validationState);\n\n const isEmptyValue = value == null || value === \"\";\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n const hasCounter = maxCharQuantity != null && !hideCounter;\n\n // ValidationMessages reference tends to change, as users will not memorize/useState for it;\n // Dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n [validationMessages]\n );\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationTypes.none,\n validation\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages)\n );\n\n return inputValidity;\n }, [\n errorMessages,\n inputRef,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n value,\n ]);\n\n const isOverflow = (currentValue) =>\n isNil(maxCharQuantity) ? false : currentValue.length > maxCharQuantity;\n\n /**\n * Limit the string to the maxCharQuantity length.\n *\n * @param value - string to evaluate\n * @returns {string|*} - string according the limit\n */\n const limitValue = (currentValue) => {\n if (currentValue === undefined || !blockMax) return currentValue;\n return !isOverflow(currentValue)\n ? currentValue\n : currentValue.substring(0, maxCharQuantity);\n };\n\n /**\n * Validates the text area updating the state and modifying the warning text, also executes\n * the user provided onBlur passing the current validation status and value.\n *\n * @returns {undefined}\n */\n const onContainerBlurHandler = (event) => {\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the length of the string while is being inputted, also executes the user onChange\n * allowing the customization of the input if required.\n *\n * @param {String} value - The value provided by the HvInput\n */\n const onChangeHandler = (event, currentValue) => {\n isDirty.current = true;\n\n const limitedValue = blockMax ? limitValue(currentValue) : currentValue;\n\n // Set the input value (only when value is uncontrolled)\n setValue(limitedValue);\n\n onChange?.(event, limitedValue);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler = (event) => {\n setFocused(true);\n\n // Reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const isScrolledDown = useCallback(() => {\n const el = inputRef.current;\n return el == null || el.offsetHeight + el.scrollTop >= el.scrollHeight;\n }, [inputRef]);\n\n const scrollDown = useCallback(() => {\n const el = inputRef.current;\n if (el != null) {\n el.scrollTop = el.scrollHeight - el.clientHeight;\n }\n }, [inputRef]);\n\n const addScrollListener = useCallback(() => {\n const scrollHandler = {\n handleEvent: () => {\n setAutoScrolling(isScrolledDown());\n },\n };\n inputRef.current?.addEventListener(\"scroll\", scrollHandler);\n }, [inputRef, isScrolledDown]);\n\n useEffect(() => {\n if (autoScroll) {\n addScrollListener();\n }\n }, [autoScroll, addScrollListener]);\n\n useEffect(() => {\n if (autoScrolling) {\n scrollDown();\n }\n }, [valueProp, autoScrolling, scrollDown]);\n\n // Run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // Skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationTypes.none,\n minCharQuantity,\n // If blockMax is true maxCharQuantity will never produce an error\n // unless the value is controlled, so we can't prevent it to overflow maxCharQuantity\n maxCharQuantity != null && (blockMax !== true || value != null)\n ? maxCharQuantity\n : null,\n validation,\n inputProps\n )));\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(\n classes.root,\n {\n [classes.resizable]: resizable,\n [classes.disabled]: disabled,\n [classes.invalid]: isStateInvalid,\n },\n className\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n className={classes.label}\n id={setId(id, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n className={classes.description}\n id={setId(elementId, \"description\")}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n {hasCounter && (\n <HvCharCounter\n id={setId(elementId, \"charCounter\")}\n className={classes.characterCounter}\n separator={middleCountLabel}\n currentCharQuantity={value.length}\n maxCharQuantity={maxCharQuantity}\n {...countCharProps}\n />\n )}\n\n <HvBaseInput\n classes={{\n root: classes.baseInput,\n input: classes.input,\n inputResizable: classes.inputResizable,\n }}\n id={hasLabel ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n invalid={isStateInvalid}\n resizable={resizable}\n multiline\n rows={rows}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : (description && setId(elementId, \"description\")) || undefined,\n \"aria-controls\": maxCharQuantity\n ? setId(elementId, \"charCounter\")\n : undefined,\n ...inputProps,\n }}\n inputRef={forkedRef}\n {...others}\n />\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvTextArea","forwardRef","props","ref","id","className","classes","classesProp","name","label","description","placeholder","status","statusMessage","validationMessages","maxCharQuantity","minCharQuantity","value","valueProp","inputRef","inputRefProp","rows","defaultValue","middleCountLabel","countCharProps","inputProps","required","readOnly","disabled","autoFocus","resizable","autoScroll","hideCounter","blockMax","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaErrorMessage","validation","onChange","onBlur","onFocus","others","useDefaultProps","cx","useClasses","elementId","useUniqueId","isDirty","useRef","forkedRef","useForkRef","focused","setFocused","useState","autoScrolling","setAutoScrolling","validationState","setValidationState","useControlled","validationStates","standBy","validationMessage","setValidationMessage","setValue","isStateInvalid","isInvalid","isEmptyValue","hasLabel","hasDescription","hasCounter","errorMessages","useMemo","DEFAULT_ERROR_MESSAGES","performValidation","useCallback","inputValidity","validateInput","current","validationTypes","none","computeValidationState","computeValidationMessage","isOverflow","currentValue","isNil","length","limitValue","undefined","substring","onContainerBlurHandler","event","onChangeHandler","limitedValue","onFocusHandler","isScrolledDown","el","offsetHeight","scrollTop","scrollHeight","scrollDown","clientHeight","addScrollListener","scrollHandler","handleEvent","addEventListener","useEffect","canShowError","hasBuiltInValidations","errorMessageId","setId","HvFormElement","root","invalid","children","labelContainer","_jsx","HvLabel","htmlFor","HvInfoMessage","HvCharCounter","characterCounter","separator","currentCharQuantity","HvBaseInput","baseInput","input","inputResizable","multiline","HvWarningText","error","disableBorder"],"mappings":";;;;;;;;;;;;;;;;;;AAkKO,MAAMA,aAAaC,WAAiC,CAACC,OAAOC,QAAQ;AACnE,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,OAAOC;AAAAA,IACPC,UAAUC;AAAAA,IACVC,OAAO;AAAA,IACPC,eAAe;AAAA,IACfC,mBAAmB;AAAA,IACnBC,iBAAiB,CAAC;AAAA,IAClBC,aAAa,CAAC;AAAA,IACdC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,YAAY;AAAA,IACZC,YAAY;AAAA,IACZC,aAAa;AAAA,IACbC,cAAc;AAAA,IACdC,WAAW;AAAA,IACX,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnB,oBAAoBC;AAAAA,IACpB,qBAAqBC;AAAAA,IACrBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,cAAczC,KAAK;AAEjC,QAAA;AAAA,IAAEI;AAAAA,IAASsC;AAAAA,EAAAA,IAAOC,WAAWtC,WAAW;AAExCuC,QAAAA,YAAYC,YAAY3C,IAAI,YAAY;AAGxC4C,QAAAA,UAAUC,OAAgB,KAAK;AAE/B9B,QAAAA,WAAW8B,OAA4B,IAAI;AACjD,QAAMC,YAAYC,WAAWhD,KAAKiB,cAAcD,QAAQ;AAExD,QAAM,CAACiC,SAASC,UAAU,IAAIC,SAAkB,KAAK;AAErD,QAAM,CAACC,eAAeC,gBAAgB,IAAIF,SAASvB,UAAU;AAE7D,QAAM,CAAC0B,mBAAiBC,kBAAkB,IAAIC,cAC5C/C,QACAg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AAA,MACXoG,qBAAqB1G,MAAMqE;AAAAA,MAC3BvE;AAAAA,MAAiC,GAC7BS;AAAAA,IAAAA,CACL,GAGH4F,oBAACQ,aAAW;AAAA,MACVtH,SAAS;AAAA,QACP0G,MAAM1G,QAAQuH;AAAAA,QACdC,OAAOxH,QAAQwH;AAAAA,QACfC,gBAAgBzH,QAAQyH;AAAAA,MAC1B;AAAA,MACA3H,IAAIgE,WAAW0C,MAAMhE,WAAW,OAAO,IAAIgE,MAAM1G,IAAI,OAAO;AAAA,MAC5DI;AAAAA,MACAS;AAAAA,MACAS;AAAAA,MACAC;AAAAA,MACAC;AAAAA,MACAW,UAAUqD;AAAAA,MACV/D;AAAAA,MACAY,SAASqD;AAAAA,MACTnF;AAAAA,MACAsG,SAAShD;AAAAA,MACTnC;AAAAA,MACAkG,WAAS;AAAA,MACT3G;AAAAA,MACAI,YAAY;AAAA,QACV,cAAcS;AAAAA,QACd,mBAAmBC;AAAAA,QACnB,gBAAgB8B,iBAAiB,OAAOuB;AAAAA,QACxC,qBAAqBqB;AAAAA,QACrB,oBACEzE,mBAAmB,OACfA,kBACC1B,eAAeoG,MAAMhE,WAAW,aAAa,KAAM0C;AAAAA,QAC1D,iBAAiBzE,kBACb+F,MAAMhE,WAAW,aAAa,IAC9B0C;AAAAA,QACJ,GAAG/D;AAAAA,MACL;AAAA,MACAN,UAAU+B;AAAAA,MAAU,GAChBR;AAAAA,IAAAA,CACL,GAEAiE,gBACCS,oBAACa,eAAa;AAAA,MACZ7H,IAAI0G,MAAMhE,WAAW,OAAO;AAAA,MAC5BzC,WAAWC,QAAQ4H;AAAAA,MACnBC,eAAa;AAAA,MAAAjB,UAEZpD;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACY;AAEnB,CAAC;"}
1
+ {"version":3,"file":"TextArea.js","sources":["../../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import {\n useCallback,\n useRef,\n useState,\n useMemo,\n useEffect,\n forwardRef,\n} from \"react\";\n\nimport { useForkRef } from \"@mui/material\";\n\nimport isNil from \"lodash/isNil\";\n\nimport { setId } from \"@core/utils/setId\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\nimport validationStates, {\n isInvalid,\n} from \"@core/components/Forms/FormElement/validationStates\";\nimport { HvValidationMessages } from \"@core/types/forms\";\nimport {\n computeValidationMessage,\n computeValidationState,\n DEFAULT_ERROR_MESSAGES,\n hasBuiltInValidations,\n HvInputValidity,\n validateInput,\n validationTypes,\n} from \"@core/components/BaseInput/validations\";\nimport { HvBaseInput, HvBaseInputProps } from \"@core/components/BaseInput\";\nimport {\n HvCharCounter,\n HvCharCounterProps,\n HvFormElement,\n HvFormStatus,\n HvInfoMessage,\n HvLabel,\n HvWarningText,\n} from \"@core/components/Forms\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { staticClasses, useClasses } from \"./TextArea.styles\";\n\nexport { staticClasses as textAreaClasses };\n\nexport type HvTextAreaClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvTextAreaProps\n extends Omit<\n HvBaseInputProps,\n \"onChange\" | \"onBlur\" | \"rows\" | \"classes\" | \"onFocus\" | \"placeholder\"\n > {\n /** The placeholder value of the text area. */\n placeholder?: string;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: React.ReactNode;\n /**\n * Text between the current char counter and max value.\n */\n middleCountLabel?: string;\n /**\n * An Object containing the various texts associated with the input.\n */\n validationMessages?: HvValidationMessages;\n /**\n * The custom validation function, it receives the value and must return\n * either `true` for valid or `false` for invalid, default validations would only\n * occur if this function is null or undefined\n */\n validation?: (value: string) => boolean;\n /**\n * The maximum allowed length of the characters, if this value is null no check\n * will be performed.\n */\n maxCharQuantity?: number;\n /**\n * The minimum allowed length of the characters, if this value is null no check\n * will be perform.\n */\n minCharQuantity?: number;\n /**\n * If `true` it should autofocus.\n */\n autoFocus?: boolean;\n /**\n * The number of rows of the text area\n */\n rows?: number;\n /**\n * If `true` the component is resizable.\n */\n resizable?: boolean;\n /**\n * Auto-scroll: automatically scroll to the end on value changes.\n * Will stop if the user scrolls up and resume if scrolled to the bottom.\n */\n autoScroll?: boolean;\n /**\n * If true it isn't possible to pass the `maxCharQuantity`\n */\n blockMax?: boolean;\n /**\n * If `true` the character counter isn't shown even if maxCharQuantity is set.\n */\n hideCounter?: boolean;\n /**\n * Props passed to the char count.\n */\n countCharProps?: Partial<HvCharCounterProps>;\n /**\n * Called back when the value is changed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLTextAreaElement>,\n value: string\n ) => void;\n /**\n * Called back when the value is changed.\n */\n onBlur?: (\n event: React.FocusEvent<HTMLTextAreaElement>,\n value: string,\n validationState: HvInputValidity\n ) => void;\n /**\n * The function that will be executed onBlur, allows checking the value state,\n * it receives the value.\n */\n onFocus?: (\n event: React.FocusEvent<HTMLTextAreaElement>,\n value: string\n ) => void;\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvTextAreaClasses;\n}\n\n/**\n * A text area is a multiline text input box, with an optional character counter when there is a length limit.\n */\nexport const HvTextArea = forwardRef<any, HvTextAreaProps>((props, ref) => {\n const {\n id,\n className,\n classes: classesProp,\n name,\n label,\n description,\n placeholder,\n status,\n statusMessage,\n validationMessages,\n maxCharQuantity,\n minCharQuantity,\n value: valueProp,\n inputRef: inputRefProp,\n rows = 1,\n defaultValue = \"\",\n middleCountLabel = \"/\",\n countCharProps = {},\n inputProps = {},\n required = false,\n readOnly = false,\n disabled = false,\n autoFocus = false,\n resizable = false,\n autoScroll = false,\n hideCounter = false,\n blockMax = false,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n validation,\n onChange,\n onBlur,\n onFocus,\n ...others\n } = useDefaultProps(\"HvTextArea\", props);\n\n const { classes, cx } = useClasses(classesProp);\n\n const elementId = useUniqueId(id, \"hvtextarea\");\n\n // Signals that the user has manually edited the input value\n const isDirty = useRef<boolean>(false);\n\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const forkedRef = useForkRef(ref, inputRefProp, inputRef);\n\n const [focused, setFocused] = useState<boolean>(false);\n\n const [autoScrolling, setAutoScrolling] = useState(autoScroll);\n\n const [validationState, setValidationState] = useControlled(\n status,\n validationStates.standBy\n );\n\n const [validationMessage, setValidationMessage] = useControlled(\n statusMessage,\n \"\"\n );\n\n const [value, setValue] = useControlled(valueProp, defaultValue);\n\n const isStateInvalid = isInvalid(validationState);\n\n const isEmptyValue = value == null || value === \"\";\n\n const hasLabel = label != null;\n\n const hasDescription = description != null;\n\n const hasCounter = maxCharQuantity != null && !hideCounter;\n\n // ValidationMessages reference tends to change, as users will not memorize/useState for it;\n // Dependencies must be more explicit so we set\n const errorMessages = useMemo(\n () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),\n [validationMessages]\n );\n\n // Validates the input, sets the status and the statusMessage accordingly (if uncontrolled)\n // and returns the validity state of the input.\n const performValidation = useCallback(() => {\n const inputValidity = validateInput(\n inputRef.current,\n value,\n required,\n minCharQuantity,\n maxCharQuantity,\n validationTypes.none,\n validation\n );\n\n // This will only run if status is uncontrolled\n setValidationState(computeValidationState(inputValidity, isEmptyValue));\n\n // This will only run if statusMessage is uncontrolled\n setValidationMessage(\n computeValidationMessage(inputValidity, errorMessages)\n );\n\n return inputValidity;\n }, [\n errorMessages,\n inputRef,\n isEmptyValue,\n maxCharQuantity,\n minCharQuantity,\n required,\n setValidationMessage,\n setValidationState,\n validation,\n value,\n ]);\n\n const isOverflow = (currentValue) =>\n isNil(maxCharQuantity) ? false : currentValue.length > maxCharQuantity;\n\n /**\n * Limit the string to the maxCharQuantity length.\n *\n * @param value - string to evaluate\n * @returns {string|*} - string according the limit\n */\n const limitValue = (currentValue) => {\n if (currentValue === undefined || !blockMax) return currentValue;\n return !isOverflow(currentValue)\n ? currentValue\n : currentValue.substring(0, maxCharQuantity);\n };\n\n /**\n * Validates the text area updating the state and modifying the warning text, also executes\n * the user provided onBlur passing the current validation status and value.\n *\n * @returns {undefined}\n */\n const onContainerBlurHandler = (event) => {\n setFocused(false);\n\n const inputValidity = performValidation();\n\n onBlur?.(event, value, inputValidity);\n };\n\n /**\n * Updates the length of the string while is being inputted, also executes the user onChange\n * allowing the customization of the input if required.\n *\n * @param {String} value - The value provided by the HvInput\n */\n const onChangeHandler = (event, currentValue) => {\n isDirty.current = true;\n\n const limitedValue = blockMax ? limitValue(currentValue) : currentValue;\n\n // Set the input value (only when value is uncontrolled)\n setValue(limitedValue);\n\n onChange?.(event, limitedValue);\n };\n\n /**\n * Updates the state putting again the value from the state because the input value is\n * not automatically manage, it also executes the onFocus function from the user passing the value\n */\n const onFocusHandler = (event) => {\n setFocused(true);\n\n // Reset validation status to standBy (only when status is uncontrolled)\n setValidationState(validationStates.standBy);\n\n onFocus?.(event, value);\n };\n\n const isScrolledDown = useCallback(() => {\n const el = inputRef.current;\n return el == null || el.offsetHeight + el.scrollTop >= el.scrollHeight;\n }, [inputRef]);\n\n const scrollDown = useCallback(() => {\n const el = inputRef.current;\n if (el != null) {\n el.scrollTop = el.scrollHeight - el.clientHeight;\n }\n }, [inputRef]);\n\n const addScrollListener = useCallback(() => {\n const scrollHandler = {\n handleEvent: () => {\n setAutoScrolling(isScrolledDown());\n },\n };\n inputRef.current?.addEventListener(\"scroll\", scrollHandler);\n }, [inputRef, isScrolledDown]);\n\n useEffect(() => {\n if (autoScroll) {\n addScrollListener();\n }\n }, [autoScroll, addScrollListener]);\n\n useEffect(() => {\n if (autoScrolling) {\n scrollDown();\n }\n }, [valueProp, autoScrolling, scrollDown]);\n\n // Run initial validation after first render\n // and also when any validation condition changes\n useEffect(() => {\n if (focused || (!isDirty.current && isEmptyValue)) {\n // Skip validation if currently focused or if empty and\n // the user never manually edited the input value\n return;\n }\n\n performValidation();\n }, [focused, isEmptyValue, performValidation]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and any of the built-in validations are active\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined &&\n hasBuiltInValidations(\n required,\n validationTypes.none,\n minCharQuantity,\n // If blockMax is true maxCharQuantity will never produce an error\n // unless the value is controlled, so we can't prevent it to overflow maxCharQuantity\n maxCharQuantity != null && (blockMax !== true || value != null)\n ? maxCharQuantity\n : null,\n validation,\n inputProps\n )));\n\n let errorMessageId;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n return (\n <HvFormElement\n id={id}\n name={name}\n status={validationState}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={cx(\n classes.root,\n {\n [classes.resizable]: resizable,\n [classes.disabled]: disabled,\n [classes.invalid]: isStateInvalid,\n },\n className\n )}\n onBlur={onContainerBlurHandler}\n >\n {(hasLabel || hasDescription) && (\n <div className={classes.labelContainer}>\n {hasLabel && (\n <HvLabel\n className={classes.label}\n id={setId(id, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n />\n )}\n\n {hasDescription && (\n <HvInfoMessage\n className={classes.description}\n id={setId(elementId, \"description\")}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n {hasCounter && (\n <HvCharCounter\n id={setId(elementId, \"charCounter\")}\n className={classes.characterCounter}\n separator={middleCountLabel}\n currentCharQuantity={value.length}\n maxCharQuantity={maxCharQuantity}\n {...countCharProps}\n />\n )}\n\n <HvBaseInput\n classes={{\n root: classes.baseInput,\n input: classes.input,\n inputResizable: classes.inputResizable,\n }}\n id={hasLabel ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n value={value}\n required={required}\n readOnly={readOnly}\n disabled={disabled}\n onChange={onChangeHandler}\n autoFocus={autoFocus}\n onFocus={onFocusHandler}\n placeholder={placeholder}\n invalid={isStateInvalid}\n resizable={resizable}\n multiline\n rows={rows}\n inputProps={{\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-describedby\":\n ariaDescribedBy != null\n ? ariaDescribedBy\n : (description && setId(elementId, \"description\")) || undefined,\n \"aria-controls\": maxCharQuantity\n ? setId(elementId, \"charCounter\")\n : undefined,\n ...inputProps,\n }}\n inputRef={forkedRef}\n {...others}\n />\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n className={classes.error}\n disableBorder\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n});\n"],"names":["HvTextArea","forwardRef","props","ref","id","className","classes","classesProp","name","label","description","placeholder","status","statusMessage","validationMessages","maxCharQuantity","minCharQuantity","value","valueProp","inputRef","inputRefProp","rows","defaultValue","middleCountLabel","countCharProps","inputProps","required","readOnly","disabled","autoFocus","resizable","autoScroll","hideCounter","blockMax","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaErrorMessage","validation","onChange","onBlur","onFocus","others","useDefaultProps","cx","useClasses","elementId","useUniqueId","isDirty","useRef","forkedRef","useForkRef","focused","setFocused","useState","autoScrolling","setAutoScrolling","validationState","setValidationState","useControlled","validationStates","standBy","validationMessage","setValidationMessage","setValue","isStateInvalid","isInvalid","isEmptyValue","hasLabel","hasDescription","hasCounter","errorMessages","useMemo","DEFAULT_ERROR_MESSAGES","performValidation","useCallback","inputValidity","validateInput","current","validationTypes","none","computeValidationState","computeValidationMessage","isOverflow","currentValue","isNil","length","limitValue","undefined","substring","onContainerBlurHandler","event","onChangeHandler","limitedValue","onFocusHandler","isScrolledDown","el","offsetHeight","scrollTop","scrollHeight","scrollDown","clientHeight","addScrollListener","scrollHandler","handleEvent","addEventListener","useEffect","canShowError","hasBuiltInValidations","errorMessageId","setId","HvFormElement","root","invalid","children","labelContainer","_jsx","HvLabel","htmlFor","HvInfoMessage","HvCharCounter","characterCounter","separator","currentCharQuantity","HvBaseInput","baseInput","input","inputResizable","multiline","HvWarningText","error","disableBorder"],"mappings":";;;;;;;;;;;;;;;;;;AAoKO,MAAMA,aAAaC,WAAiC,CAACC,OAAOC,QAAQ;AACnE,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,OAAOC;AAAAA,IACPC,UAAUC;AAAAA,IACVC,OAAO;AAAA,IACPC,eAAe;AAAA,IACfC,mBAAmB;AAAA,IACnBC,iBAAiB,CAAC;AAAA,IAClBC,aAAa,CAAC;AAAA,IACdC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,YAAY;AAAA,IACZC,YAAY;AAAA,IACZC,aAAa;AAAA,IACbC,cAAc;AAAA,IACdC,WAAW;AAAA,IACX,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnB,oBAAoBC;AAAAA,IACpB,qBAAqBC;AAAAA,IACrBC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,cAAczC,KAAK;AAEjC,QAAA;AAAA,IAAEI;AAAAA,IAASsC;AAAAA,EAAAA,IAAOC,WAAWtC,WAAW;AAExCuC,QAAAA,YAAYC,YAAY3C,IAA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7H,IAAI0G,MAAMhE,WAAW,OAAO;AAAA,MAC5BzC,WAAWC,QAAQ4H;AAAAA,MACnBC,eAAa;AAAA,MAAAjB,UAEZpD;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACY;AAEnB,CAAC;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TimePicker.js","sources":["../../../../src/components/TimePicker/TimePicker.tsx"],"sourcesContent":["import { useState, useRef, useMemo } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { Time } from \"@internationalized/date\";\n\nimport { useTimeField } from \"@react-aria/datepicker\";\nimport {\n TimeFieldStateOptions,\n useTimeFieldState,\n} from \"@react-stately/datepicker\";\n\nimport { Time as TimeIcon } from \"@hitachivantara/uikit-react-icons\";\n\nimport {\n HvFormElement,\n HvLabel,\n HvWarningText,\n HvInfoMessage,\n HvFormElementProps,\n} from \"@core/components/Forms\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { Unit } from \"./Unit\";\nimport { Placeholder } from \"./Placeholder\";\nimport { staticClasses, useClasses } from \"./TimePicker.styles\";\n\nconst toTime = (value?: HvTimePickerValue) => {\n if (!value) return undefined;\n const { hours, minutes, seconds } = value;\n return new Time(hours, minutes, seconds);\n};\n\nconst getFormat = (timeFormat?: TimeFormat) => {\n if (timeFormat == null) return 24;\n return timeFormat === \"12\" ? 12 : 24;\n};\n\nexport { staticClasses as timePickerClasses };\n\nexport type TimeFormat = \"12\" | \"24\";\n\nexport type HvTimePickerClasses = ExtractNames<typeof useClasses>;\n\nexport type HvTimePickerClassKey =\n | \"root\"\n | \"input\"\n | \"label\"\n | \"placeholder\"\n | \"timePopperContainer\"\n | \"separator\"\n | \"periodContainer\"\n | \"formElementRoot\"\n | \"dropdownPlaceholder\"\n | \"iconBaseRoot\"\n | \"error\"\n | \"labelContainer\"\n | \"description\"\n | \"dropdownHeaderInvalid\"\n | \"dropdownPlaceholderDisabled\"\n | \"dropdownHeaderOpen\";\n\nexport type HvTimePickerValue = {\n hours: number;\n minutes: number;\n seconds: number;\n};\n\nexport interface HvTimePickerProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"value\" | \"defaultValue\" | \"onChange\" | \"onFocus\" | \"onBlur\"\n > {\n /** Id to be applied to the form element root node. */\n id?: string;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTimePickerClasses;\n /** Current value of the element when _controlled_. Follows the 24-hour format. */\n value?: HvTimePickerValue;\n /** Initial value of the element when _uncontrolled_. Follows the 24-hour format. */\n defaultValue?: HvTimePickerValue;\n /** The placeholder value when no time is selected. */\n placeholder?: string;\n /** The placeholder of the hours input. */\n hoursPlaceholder?: string;\n /** The placeholder of the minutes input. */\n minutesPlaceholder?: string;\n /** The placeholder of the seconds input. */\n secondsPlaceholder?: string;\n /**\n * Whether the time picker should show the AM/PM 12-hour clock or the 24-hour one.\n * If undefined, the component will use a format according to the passed locale.\n */\n timeFormat?: TimeFormat;\n /** Whether to show the seconds when using the native time picker */\n showSeconds?: boolean;\n /** Locale that will provide the time format(12 or 24 hour format). It is \"overwritten\" by `showAmPm` */\n locale?: string;\n /** Whether the dropdown is expandable. */\n disableExpand?: boolean;\n\n /**\n * Callback function to be triggered when the input value is changed.\n * It is invoked with a `{hours, minutes, seconds}` object, always in the 24h format\n */\n onChange?: (value: HvTimePickerValue) => void;\n\n /** Callback called when dropdown changes the expanded state. */\n onToggle?: (event: Event, isOpen: boolean) => void;\n\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n\n /** Sets if the calendar container should follow the date picker input out of the screen or stay visible. */\n escapeWithReference?: boolean;\n\n /** Extra properties to be passed to the TimePicker's dropdown. */\n dropdownProps?: Partial<HvBaseDropdownProps>;\n}\n\n/**\n * A Time Picker allows the user to choose a specific time or a time range.\n */\nexport const HvTimePicker = (props: HvTimePickerProps) => {\n const {\n classes: classesProp,\n className,\n\n id: idProp,\n name,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n placeholder,\n hoursPlaceholder = \"hh\",\n minutesPlaceholder = \"mm\",\n secondsPlaceholder = \"ss\",\n\n value: valueProp,\n defaultValue: defaultValueProp,\n\n timeFormat,\n showSeconds,\n disableExpand,\n locale = \"en\",\n\n onToggle,\n onChange,\n\n // misc properties:\n disablePortal = true,\n escapeWithReference = true,\n dropdownProps,\n ...others\n } = useDefaultProps(\"HvTimePicker\", props);\n const id = useUniqueId(idProp, \"hvtimepicker\");\n const ref = useRef<HTMLDivElement>(null);\n const { classes, cx } = useClasses(classesProp);\n\n const stateProps: TimeFieldStateOptions = {\n value: toTime(valueProp),\n defaultValue: toTime(defaultValueProp),\n label,\n locale,\n isRequired: required,\n isReadOnly: readOnly,\n isDisabled: disabled,\n granularity: \"second\",\n hourCycle: getFormat(timeFormat),\n onChange: (value) => {\n const { hour: hours, minute: minutes, second: seconds } = value;\n onChange?.({ hours, minutes, seconds });\n },\n };\n const state = useTimeFieldState(stateProps);\n const { labelProps, fieldProps, descriptionProps } = useTimeField(\n {\n ...stateProps,\n id,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n },\n state,\n ref\n );\n\n const [open, setOpen] = useState(false);\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n const [validationState] = useControlled(status, \"standBy\");\n\n const placeholders = useMemo(\n () => ({\n hour: hoursPlaceholder,\n minute: minutesPlaceholder,\n second: secondsPlaceholder,\n }),\n [hoursPlaceholder, minutesPlaceholder, secondsPlaceholder]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = validationState === \"invalid\";\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(id, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n status={validationState}\n className={cx(classes.root, className)}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel label={label} className={classes.label} {...labelProps} />\n )}\n {description && (\n <HvInfoMessage\n className={classes.description}\n {...descriptionProps}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n <HvBaseDropdown\n role=\"combobox\"\n variableWidth\n disabled={disabled}\n readOnly={readOnly}\n placeholder={\n placeholder && !state.value ? (\n placeholder\n ) : (\n <Placeholder\n ref={ref}\n name={name}\n state={state}\n placeholders={placeholders}\n className={cx(classes.placeholder, {\n [classes.placeholderDisabled]: disabled,\n })}\n {...fieldProps}\n />\n )\n }\n classes={{\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n panel: classes.dropdownPanel,\n headerOpen: classes.dropdownHeaderOpen,\n }}\n placement=\"right\"\n adornment={\n <TimeIcon\n color={disabled ? \"secondary_60\" : undefined}\n className={classes.icon}\n />\n }\n expanded={open}\n onToggle={(evt, newOpen) => {\n if (disableExpand) return;\n setOpen(newOpen);\n onToggle?.(evt, newOpen);\n }}\n onContainerCreation={(containerRef) => {\n containerRef?.getElementsByTagName(\"input\")[0]?.focus();\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={fieldProps[\"aria-labelledby\"]}\n aria-describedby={fieldProps[\"aria-describedby\"]}\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n disablePortal={disablePortal}\n popperProps={{\n modifiers: [\n { name: \"preventOverflow\", enabled: escapeWithReference },\n ],\n }}\n {...dropdownProps}\n >\n <div ref={ref} className={classes.timePopperContainer}>\n {state.segments.map((segment, i) => (\n <Unit\n key={i}\n state={state}\n segment={segment}\n placeholder={placeholders[segment.type]}\n onAdd={() => state.increment(segment.type)}\n onSub={() => state.decrement(segment.type)}\n onChange={(evt, val) => {\n state.setSegment(segment.type, Number(val));\n }}\n />\n ))}\n </div>\n </HvBaseDropdown>\n\n {canShowError && (\n <HvWarningText\n id={setId(id, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n};\n"],"names":["toTime","value","undefined","hours","minutes","seconds","Time","getFormat","timeFormat","HvTimePicker","props","classes","classesProp","className","id","idProp","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","status","statusMessage","ariaErrorMessage","placeholder","hoursPlaceholder","minutesPlaceholder","secondsPlaceholder","valueProp","defaultValue","defaultValueProp","showSeconds","disableExpand","locale","onToggle","onChange","disablePortal","escapeWithReference","dropdownProps","others","useDefaultProps","useUniqueId","ref","useRef","cx","useClasses","stateProps","isRequired","isReadOnly","isDisabled","granularity","hourCycle","hour","minute","second","state","useTimeFieldState","labelProps","fieldProps","descriptionProps","useTimeField","open","setOpen","useState","validationMessage","useControlled","validationState","placeholders","useMemo","canShowError","isStateInvalid","errorMessageId","setId","HvFormElement","root","children","labelContainer","_jsx","HvLabel","HvInfoMessage","HvBaseDropdown","role","variableWidth","Placeholder","placeholderDisabled","header","dropdownHeader","dropdownHeaderInvalid","panel","dropdownPanel","headerOpen","dropdownHeaderOpen","placement","adornment","TimeIcon","color","icon","expanded","evt","newOpen","onContainerCreation","containerRef","getElementsByTagName","focus","popperProps","modifiers","enabled","timePopperContainer","segments","map","segment","i","Unit","type","onAdd","increment","onSub","decrement","val","setSegment","Number","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;;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tsx"],"sourcesContent":["import { useState, useRef, useMemo } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { Time } from \"@internationalized/date\";\n\nimport { useTimeField } from \"@react-aria/datepicker\";\nimport {\n TimeFieldStateOptions,\n useTimeFieldState,\n} from \"@react-stately/datepicker\";\n\nimport { Time as TimeIcon } from \"@hitachivantara/uikit-react-icons\";\n\nimport {\n HvFormElement,\n HvLabel,\n HvWarningText,\n HvInfoMessage,\n HvFormElementProps,\n} from \"@core/components/Forms\";\nimport {\n HvBaseDropdown,\n HvBaseDropdownProps,\n} from \"@core/components/BaseDropdown\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { setId } from \"@core/utils/setId\";\n\nimport { Unit } from \"./Unit\";\nimport { Placeholder } from \"./Placeholder\";\nimport { staticClasses, useClasses } from \"./TimePicker.styles\";\n\nconst toTime = (value?: HvTimePickerValue) => {\n if (!value) return undefined;\n const { hours, minutes, seconds } = value;\n return new Time(hours, minutes, seconds);\n};\n\nconst getFormat = (timeFormat?: TimeFormat) => {\n if (timeFormat == null) return 24;\n return timeFormat === \"12\" ? 12 : 24;\n};\n\nexport { staticClasses as timePickerClasses };\n\nexport type TimeFormat = \"12\" | \"24\";\n\nexport type HvTimePickerClasses = ExtractNames<typeof useClasses>;\n\nexport type HvTimePickerClassKey =\n | \"root\"\n | \"input\"\n | \"label\"\n | \"placeholder\"\n | \"timePopperContainer\"\n | \"separator\"\n | \"periodContainer\"\n | \"formElementRoot\"\n | \"dropdownPlaceholder\"\n | \"iconBaseRoot\"\n | \"error\"\n | \"labelContainer\"\n | \"description\"\n | \"dropdownHeaderInvalid\"\n | \"dropdownPlaceholderDisabled\"\n | \"dropdownHeaderOpen\";\n\nexport type HvTimePickerValue = {\n hours: number;\n minutes: number;\n seconds: number;\n};\n\nexport interface HvTimePickerProps\n extends Omit<\n HvFormElementProps,\n \"classes\" | \"value\" | \"defaultValue\" | \"onChange\" | \"onFocus\" | \"onBlur\"\n > {\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvTimePickerClasses;\n /** Current value of the element when _controlled_. Follows the 24-hour format. */\n value?: HvTimePickerValue;\n /** Initial value of the element when _uncontrolled_. Follows the 24-hour format. */\n defaultValue?: HvTimePickerValue;\n /** The placeholder value when no time is selected. */\n placeholder?: string;\n /** The placeholder of the hours input. */\n hoursPlaceholder?: string;\n /** The placeholder of the minutes input. */\n minutesPlaceholder?: string;\n /** The placeholder of the seconds input. */\n secondsPlaceholder?: string;\n /**\n * Whether the time picker should show the AM/PM 12-hour clock or the 24-hour one.\n * If undefined, the component will use a format according to the passed locale.\n */\n timeFormat?: TimeFormat;\n /** Whether to show the seconds when using the native time picker */\n showSeconds?: boolean;\n /** Locale that will provide the time format(12 or 24 hour format). It is \"overwritten\" by `showAmPm` */\n locale?: string;\n /** Whether the dropdown is expandable. */\n disableExpand?: boolean;\n /**\n * Callback function to be triggered when the input value is changed.\n * It is invoked with a `{hours, minutes, seconds}` object, always in the 24h format\n */\n onChange?: (value: HvTimePickerValue) => void;\n /** Callback called when dropdown changes the expanded state. */\n onToggle?: (event: Event, isOpen: boolean) => void;\n /** Disable the portal behavior. The children stay within it's parent DOM hierarchy. */\n disablePortal?: boolean;\n /** Sets if the calendar container should follow the date picker input out of the screen or stay visible. */\n escapeWithReference?: boolean;\n /** Extra properties to be passed to the TimePicker's dropdown. */\n dropdownProps?: Partial<HvBaseDropdownProps>;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n}\n\n/**\n * A Time Picker allows the user to choose a specific time or a time range.\n */\nexport const HvTimePicker = (props: HvTimePickerProps) => {\n const {\n classes: classesProp,\n className,\n\n id: idProp,\n name,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n description,\n \"aria-describedby\": ariaDescribedBy,\n status,\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n\n placeholder,\n hoursPlaceholder = \"hh\",\n minutesPlaceholder = \"mm\",\n secondsPlaceholder = \"ss\",\n\n value: valueProp,\n defaultValue: defaultValueProp,\n\n timeFormat,\n showSeconds,\n disableExpand,\n locale = \"en\",\n\n onToggle,\n onChange,\n\n // misc properties:\n disablePortal = true,\n escapeWithReference = true,\n dropdownProps,\n ...others\n } = useDefaultProps(\"HvTimePicker\", props);\n const id = useUniqueId(idProp, \"hvtimepicker\");\n const ref = useRef<HTMLDivElement>(null);\n const { classes, cx } = useClasses(classesProp);\n\n const stateProps: TimeFieldStateOptions = {\n value: toTime(valueProp),\n defaultValue: toTime(defaultValueProp),\n label,\n locale,\n isRequired: required,\n isReadOnly: readOnly,\n isDisabled: disabled,\n granularity: \"second\",\n hourCycle: getFormat(timeFormat),\n onChange: (value) => {\n const { hour: hours, minute: minutes, second: seconds } = value;\n onChange?.({ hours, minutes, seconds });\n },\n };\n const state = useTimeFieldState(stateProps);\n const { labelProps, fieldProps, descriptionProps } = useTimeField(\n {\n ...stateProps,\n id,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n },\n state,\n ref\n );\n\n const [open, setOpen] = useState(false);\n\n const [validationMessage] = useControlled(statusMessage, \"Required\");\n const [validationState] = useControlled(status, \"standBy\");\n\n const placeholders = useMemo(\n () => ({\n hour: hoursPlaceholder,\n minute: minutesPlaceholder,\n second: secondsPlaceholder,\n }),\n [hoursPlaceholder, minutesPlaceholder, secondsPlaceholder]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const isStateInvalid = validationState === \"invalid\";\n const errorMessageId = isStateInvalid\n ? canShowError\n ? setId(id, \"error\")\n : ariaErrorMessage\n : undefined;\n\n return (\n <HvFormElement\n name={name}\n required={required}\n disabled={disabled}\n status={validationState}\n className={cx(classes.root, className)}\n {...others}\n >\n {(label || description) && (\n <div className={classes.labelContainer}>\n {label && (\n <HvLabel label={label} className={classes.label} {...labelProps} />\n )}\n {description && (\n <HvInfoMessage\n className={classes.description}\n {...descriptionProps}\n >\n {description}\n </HvInfoMessage>\n )}\n </div>\n )}\n\n <HvBaseDropdown\n role=\"combobox\"\n variableWidth\n disabled={disabled}\n readOnly={readOnly}\n placeholder={\n placeholder && !state.value ? (\n placeholder\n ) : (\n <Placeholder\n ref={ref}\n name={name}\n state={state}\n placeholders={placeholders}\n className={cx(classes.placeholder, {\n [classes.placeholderDisabled]: disabled,\n })}\n {...fieldProps}\n />\n )\n }\n classes={{\n header: cx(classes.dropdownHeader, {\n [classes.dropdownHeaderInvalid]: isStateInvalid,\n }),\n panel: classes.dropdownPanel,\n headerOpen: classes.dropdownHeaderOpen,\n }}\n placement=\"right\"\n adornment={\n <TimeIcon\n color={disabled ? \"secondary_60\" : undefined}\n className={classes.icon}\n />\n }\n expanded={open}\n onToggle={(evt, newOpen) => {\n if (disableExpand) return;\n setOpen(newOpen);\n onToggle?.(evt, newOpen);\n }}\n onContainerCreation={(containerRef) => {\n containerRef?.getElementsByTagName(\"input\")[0]?.focus();\n }}\n aria-haspopup=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={fieldProps[\"aria-labelledby\"]}\n aria-describedby={fieldProps[\"aria-describedby\"]}\n aria-invalid={isStateInvalid ? true : undefined}\n aria-errormessage={errorMessageId}\n disablePortal={disablePortal}\n popperProps={{\n modifiers: [\n { name: \"preventOverflow\", enabled: escapeWithReference },\n ],\n }}\n {...dropdownProps}\n >\n <div ref={ref} className={classes.timePopperContainer}>\n {state.segments.map((segment, i) => (\n <Unit\n key={i}\n state={state}\n segment={segment}\n placeholder={placeholders[segment.type]}\n onAdd={() => state.increment(segment.type)}\n onSub={() => state.decrement(segment.type)}\n onChange={(evt, val) => {\n state.setSegment(segment.type, Number(val));\n }}\n />\n ))}\n </div>\n </HvBaseDropdown>\n\n {canShowError && (\n <HvWarningText\n id={setId(id, \"error\")}\n disableBorder\n className={classes.error}\n >\n {validationMessage}\n </HvWarningText>\n )}\n </HvFormElement>\n );\n};\n"],"names":["toTime","value","undefined","hours","minutes","seconds","Time","getFormat","timeFormat","HvTimePicker","props","classes","classesProp","className","id","idProp","name","required","disabled","readOnly","label","ariaLabel","ariaLabelledBy","description","ariaDescribedBy","status","statusMessage","ariaErrorMessage","placeholder","hoursPlaceholder","minutesPlaceholder","secondsPlaceholder","valueProp","defaultValue","defaultValueProp","showSeconds","disableExpand","locale","onToggle","onChange","disablePortal","escapeWithReference","dropdownProps","others","useDefaultProps","useUniqueId","ref","useRef","cx","useClasses","stateProps","isRequired","isReadOnly","isDisabled","granularity","hourCycle","hour","minute","second","state","useTimeFieldState","labelProps","fieldProps","descriptionProps","useTimeField","open","setOpen","useState","validationMessage","useControlled","validationState","placeholders","useMemo","canShowError","isStateInvalid","errorMessageId","setId","HvFormElement","root","children","labelContainer","_jsx","HvLabel","HvInfoMessage","HvBaseDropdown","role","variableWidth","Placeholder","placeholderDisabled","header","dropdownHeader","dropdownHeaderInvalid","panel","dropdownPanel","headerOpen","dropdownHeaderOpen","placement","adornment","TimeIcon","color","icon","expanded","evt","newOpen","onContainerCreation","containerRef","getElementsByTagName","focus","popperProps","modifiers","enabled","timePopperContainer","segments","map","segment","i","Unit","type","onAdd","increment","onSub","decrement","val","setSegment","Number","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCA,MAAMA,SAASA,CAACC,UAA8B;AAC5C,MAAI,CAACA;AAAcC,WAAAA;AACb,QAAA;AAAA,IAAEC;AAAAA,IAAOC;AAAAA,IAASC;AAAAA,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MACA,iBAAc;AAAA,MACd,cAAYtF;AAAAA,MACZ,mBAAiByC,WAAW,iBAAiB;AAAA,MAC7C,oBAAkBA,WAAW,kBAAkB;AAAA,MAC/C,gBAAcY,iBAAiB,OAAOxE;AAAAA,MACtC,qBAAmByE;AAAAA,MACnBnC;AAAAA,MACAoE,aAAa;AAAA,QACXC,WAAW,CACT;AAAA,UAAE7F,MAAM;AAAA,UAAmB8F,SAASrE;AAAAA,QAAAA,CAAqB;AAAA,MAE7D;AAAA,MAAE,GACEC;AAAAA,MAAaqC,8BAEjB,OAAA;AAAA,QAAKjC;AAAAA,QAAUjC,WAAWF,QAAQoG;AAAAA,QAAoBhC,UACnDpB,MAAMqD,SAASC,IAAI,CAACC,SAASC,0BAC3BC,MAAI;AAAA,UAEHzD;AAAAA,UACAuD;AAAAA,UACAtF,aAAa2C,aAAa2C,QAAQG,IAAI;AAAA,UACtCC,OAAOA,MAAM3D,MAAM4D,UAAUL,QAAQG,IAAI;AAAA,UACzCG,OAAOA,MAAM7D,MAAM8D,UAAUP,QAAQG,IAAI;AAAA,UACzC9E,UAAUA,CAAC+D,KAAKoB,QAAQ;AACtB/D,kBAAMgE,WAAWT,QAAQG,MAAMO,OAAOF,GAAG,CAAC;AAAA,UAC5C;AAAA,QAAE,GARGP,CASN,CACF;AAAA,MAAA,CACE;AAAA,IAAA,CACS,GAEf1C,gBACCQ,oBAAC4C,eAAa;AAAA,MACZ/G,IAAI8D,MAAM9D,IAAI,OAAO;AAAA,MACrBgH,eAAa;AAAA,MACbjH,WAAWF,QAAQoH;AAAAA,MAAMhD,UAExBX;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACY;AAEnB;"}
@@ -10,7 +10,7 @@ const {
10
10
  justifyContent: "center",
11
11
  alignItems: "center",
12
12
  textAlign: "center",
13
- ...theme.typography.sTitle
13
+ ...theme.typography.title3
14
14
  },
15
15
  separator: {
16
16
  width: 8
@@ -27,7 +27,7 @@ const {
27
27
  width: 40
28
28
  },
29
29
  input: {
30
- ...theme.typography.sTitle,
30
+ ...theme.typography.title3,
31
31
  fontWeight: 600,
32
32
  textAlign: "center",
33
33
  height: 40,
@@ -1 +1 @@
1
- {"version":3,"file":"Unit.styles.js","sources":["../../../../../src/components/TimePicker/Unit/Unit.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTimePickerUnit\", {\n root: {\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n textAlign: \"center\",\n ...theme.typography.sTitle,\n },\n\n separator: {\n width: 8,\n },\n\n periodToggle: {\n height: 40,\n width: 40,\n },\n\n element: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: 40,\n width: 40,\n },\n\n input: {\n ...theme.typography.sTitle,\n fontWeight: 600,\n textAlign: \"center\",\n height: 40,\n width: 40,\n padding: 0,\n margin: 0,\n \"&::placeholder\": {\n fontSize: 16,\n fontWeight: 600,\n },\n },\n inputRoot: {\n width: 40,\n height: 40,\n },\n\n subtractIcon: {\n marginTop: theme.space.xs,\n },\n inputContainer: {\n minWidth: 40,\n maxWidth: 40,\n },\n inputBorderContainer: {\n top: 40,\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","display","flexDirection","justifyContent","alignItems","textAlign","theme","typography","sTitle","separator","width","periodToggle","height","element","input","fontWeight","padding","margin","fontSize","inputRoot","subtractIcon","marginTop","space","xs","inputContainer","minWidth","maxWidth","inputBorderContainer","top"],"mappings":";;AAIa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,oBAAoB;AAAA,EAC7EC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZC,WAAW;AAAA,IACX,GAAGC,MAAMC,WAAWC;AAAAA,EACtB;AAAA,EAEAC,WAAW;AAAA,IACTC,OAAO;AAAA,EACT;AAAA,EAEAC,cAAc;AAAA,IACZC,QAAQ;AAAA,IACRF,OAAO;AAAA,EACT;AAAA,EAEAG,SAAS;AAAA,IACPZ,SAAS;AAAA,IACTE,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZQ,QAAQ;AAAA,IACRF,OAAO;AAAA,EACT;AAAA,EAEAI,OAAO;AAAA,IACL,GAAGR,MAAMC,WAAWC;AAAAA,IACpBO,YAAY;AAAA,IACZV,WAAW;AAAA,IACXO,QAAQ;AAAA,IACRF,OAAO;AAAA,IACPM,SAAS;AAAA,IACTC,QAAQ;AAAA,IACR,kBAAkB;AAAA,MAChBC,UAAU;AAAA,MACVH,YAAY;AAAA,IACd;AAAA,EACF;AAAA,EACAI,WAAW;AAAA,IACTT,OAAO;AAAA,IACPE,QAAQ;AAAA,EACV;AAAA,EAEAQ,cAAc;AAAA,IACZC,WAAWf,MAAMgB,MAAMC;AAAAA,EACzB;AAAA,EACAC,gBAAgB;AAAA,IACdC,UAAU;AAAA,IACVC,UAAU;AAAA,EACZ;AAAA,EACAC,sBAAsB;AAAA,IACpBC,KAAK;AAAA,EACP;AACF,CAAC;"}
1
+ {"version":3,"file":"Unit.styles.js","sources":["../../../../../src/components/TimePicker/Unit/Unit.styles.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { createClasses } from \"@core/utils/classes\";\n\nexport const { staticClasses, useClasses } = createClasses(\"HvTimePickerUnit\", {\n root: {\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n textAlign: \"center\",\n ...theme.typography.title3,\n },\n\n separator: {\n width: 8,\n },\n\n periodToggle: {\n height: 40,\n width: 40,\n },\n\n element: {\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n height: 40,\n width: 40,\n },\n\n input: {\n ...theme.typography.title3,\n fontWeight: 600,\n textAlign: \"center\",\n height: 40,\n width: 40,\n padding: 0,\n margin: 0,\n \"&::placeholder\": {\n fontSize: 16,\n fontWeight: 600,\n },\n },\n inputRoot: {\n width: 40,\n height: 40,\n },\n\n subtractIcon: {\n marginTop: theme.space.xs,\n },\n inputContainer: {\n minWidth: 40,\n maxWidth: 40,\n },\n inputBorderContainer: {\n top: 40,\n },\n});\n"],"names":["staticClasses","useClasses","createClasses","root","display","flexDirection","justifyContent","alignItems","textAlign","theme","typography","title3","separator","width","periodToggle","height","element","input","fontWeight","padding","margin","fontSize","inputRoot","subtractIcon","marginTop","space","xs","inputContainer","minWidth","maxWidth","inputBorderContainer","top"],"mappings":";;AAIa,MAAA;AAAA,EAAEA;AAAAA,EAAeC;AAAW,IAAIC,cAAc,oBAAoB;AAAA,EAC7EC,MAAM;AAAA,IACJC,SAAS;AAAA,IACTC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZC,WAAW;AAAA,IACX,GAAGC,MAAMC,WAAWC;AAAAA,EACtB;AAAA,EAEAC,WAAW;AAAA,IACTC,OAAO;AAAA,EACT;AAAA,EAEAC,cAAc;AAAA,IACZC,QAAQ;AAAA,IACRF,OAAO;AAAA,EACT;AAAA,EAEAG,SAAS;AAAA,IACPZ,SAAS;AAAA,IACTE,gBAAgB;AAAA,IAChBC,YAAY;AAAA,IACZQ,QAAQ;AAAA,IACRF,OAAO;AAAA,EACT;AAAA,EAEAI,OAAO;AAAA,IACL,GAAGR,MAAMC,WAAWC;AAAAA,IACpBO,YAAY;AAAA,IACZV,WAAW;AAAA,IACXO,QAAQ;AAAA,IACRF,OAAO;AAAA,IACPM,SAAS;AAAA,IACTC,QAAQ;AAAA,IACR,kBAAkB;AAAA,MAChBC,UAAU;AAAA,MACVH,YAAY;AAAA,IACd;AAAA,EACF;AAAA,EACAI,WAAW;AAAA,IACTT,OAAO;AAAA,IACPE,QAAQ;AAAA,EACV;AAAA,EAEAQ,cAAc;AAAA,IACZC,WAAWf,MAAMgB,MAAMC;AAAAA,EACzB;AAAA,EACAC,gBAAgB;AAAA,IACdC,UAAU;AAAA,IACVC,UAAU;AAAA,EACZ;AAAA,EACAC,sBAAsB;AAAA,IACpBC,KAAK;AAAA,EACP;AACF,CAAC;"}
@@ -241,7 +241,7 @@ const HvVerticalNavigationTreeViewItem = forwardRef((props, ref) => {
241
241
  onKeyDown: handleKeyDown,
242
242
  "aria-current": selectable && selected || !isOpen && (isChildSelected == null ? void 0 : isChildSelected(nodeId)) ? href ? "page" : true : void 0,
243
243
  "aria-expanded": expandable ? expanded : void 0,
244
- "aria-controls": expandable ? setId(id, "group") : void 0,
244
+ "aria-controls": isOpen && expandable ? setId(id, "group") : void 0,
245
245
  "aria-label": payload == null ? void 0 : payload.label
246
246
  },
247
247
  children: [/* @__PURE__ */ jsx(IconWrapper, {